[clutter/multi-backend: 14/15] gdk/events: Clean up the event handling code
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/multi-backend: 14/15] gdk/events: Clean up the event handling code
- Date: Tue, 11 Oct 2011 23:01:20 +0000 (UTC)
commit 0cd16eede0a8ff9221f601e810b7def78d416d9b
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Oct 3 15:25:40 2011 +0100
gdk/events: Clean up the event handling code
We need debugging notes, to see what's happening when handling events.
We need to queue a (clipped) redraw when receiving a GDK_EXPOSE event.
We need to check the device (both master and source) of the event using
the GdkEvent API, and pass them to the ClutterEvent using the
corresponding Clutter API.
clutter/gdk/clutter-event-gdk.c | 93 +++++++++++++++++++++++++-------
clutter/gdk/clutter-input-device-gdk.c | 2 +-
2 files changed, 75 insertions(+), 20 deletions(-)
---
diff --git a/clutter/gdk/clutter-event-gdk.c b/clutter/gdk/clutter-event-gdk.c
index 87cf8ff..540d7d4 100644
--- a/clutter/gdk/clutter-event-gdk.c
+++ b/clutter/gdk/clutter-event-gdk.c
@@ -31,10 +31,12 @@
#include "clutter-backend-gdk.h"
#include "clutter-device-manager-gdk.h"
-#include "clutter-debug.h"
-#include "clutter-main.h"
+#include "clutter-actor-private.h"
#include "clutter-backend-private.h"
+#include "clutter-debug.h"
#include "clutter-event-private.h"
+#include "clutter-main.h"
+#include "clutter-paint-volume-private.h"
#include "clutter-stage-private.h"
#include <string.h>
@@ -87,6 +89,8 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
ClutterEvent *event = NULL;
gint spin = 0;
GdkFilterReturn result = GDK_FILTER_CONTINUE;
+ ClutterInputDevice *device, *source_device;
+ GdkDevice *gdk_device;
backend = clutter_get_default_backend ();
if (!CLUTTER_IS_BACKEND_GDK (backend))
@@ -99,6 +103,20 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
stage = clutter_gdk_get_stage_from_window (gdk_event->any.window);
device_manager = clutter_device_manager_get_default ();
+ gdk_device = gdk_event_get_device (gdk_event);
+ if (gdk_device != NULL)
+ device = _clutter_device_manager_gdk_lookup_device (device_manager,
+ gdk_device);
+ else
+ device = NULL;
+
+ gdk_device = gdk_event_get_source_device (gdk_event);
+ if (gdk_device != NULL)
+ source_device = _clutter_device_manager_gdk_lookup_device (device_manager,
+ gdk_device);
+ else
+ source_device = NULL;
+
if (stage == NULL)
return GDK_FILTER_CONTINUE;
@@ -115,7 +133,32 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
break;
case GDK_EXPOSE:
- clutter_redraw (stage);
+ {
+ ClutterPaintVolume clip;
+ ClutterVertex origin;
+
+ CLUTTER_NOTE (EVENT, "Expose for stage '%s' [%p] { %d, %d - %d x %d }",
+ _clutter_actor_get_debug_name (CLUTTER_ACTOR (stage)),
+ stage,
+ gdk_event->expose.area.x,
+ gdk_event->expose.area.y,
+ gdk_event->expose.area.width,
+ gdk_event->expose.area.height);
+
+ origin.x = gdk_event->expose.area.x;
+ origin.y = gdk_event->expose.area.y;
+ origin.z = 0;
+
+ _clutter_paint_volume_init_static (&clip, CLUTTER_ACTOR (stage));
+
+ clutter_paint_volume_set_origin (&clip, &origin);
+ clutter_paint_volume_set_width (&clip, gdk_event->expose.area.width);
+ clutter_paint_volume_set_height (&clip, gdk_event->expose.area.height);
+
+ _clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), 0, &clip);
+
+ clutter_paint_volume_free (&clip);
+ }
break;
case GDK_DAMAGE:
@@ -130,9 +173,11 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
event->motion.axes = NULL;
/* It's all X in the end, right? */
event->motion.modifier_state = gdk_event->motion.state;
- event->motion.device =
- _clutter_device_manager_gdk_lookup_device (device_manager,
- gdk_event->motion.device);
+ clutter_event_set_device (event, device);
+ clutter_event_set_source_device (event, source_device);
+ CLUTTER_NOTE (EVENT, "Motion notifiy [%.2f, %.2f]",
+ event->motion.x,
+ event->motion.y);
break;
case GDK_BUTTON_PRESS:
@@ -147,9 +192,13 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
event->button.modifier_state = gdk_event->button.state;
event->button.button = gdk_event->button.button;
event->button.click_count = 1;
- event->button.device =
- _clutter_device_manager_gdk_lookup_device (device_manager,
- gdk_event->button.device);
+ clutter_event_set_device (event, device);
+ clutter_event_set_source_device (event, source_device);
+ CLUTTER_NOTE (EVENT, "Button %d %s [%.2f, %.2f]",
+ event->button.button,
+ event->type == CLUTTER_BUTTON_PRESS ? "press" : "release",
+ event->button.x,
+ event->button.y);
break;
case GDK_2BUTTON_PRESS:
@@ -167,6 +216,11 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
event->key.keyval = gdk_event->key.keyval;
event->key.hardware_keycode = gdk_event->key.hardware_keycode;
event->key.unicode_value = g_utf8_get_char (gdk_event->key.string);
+ clutter_event_set_device (event, device);
+ clutter_event_set_source_device (event, source_device);
+ CLUTTER_NOTE (EVENT, "Key %d %s",
+ event->key.keyval,
+ event->type == CLUTTER_KEY_PRESS ? "press" : "release");
break;
case GDK_ENTER_NOTIFY:
@@ -175,19 +229,21 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
CLUTTER_ENTER :
CLUTTER_LEAVE);
event->crossing.source = CLUTTER_ACTOR (stage);
- event->crossing.time = gdk_event->crossing.time;
+ event->crossing.time = gdk_event_get_time (gdk_event);
event->crossing.x = gdk_event->crossing.x;
event->crossing.y = gdk_event->crossing.y;
/* XXX: no better fallback here? */
- event->crossing.device =
- clutter_device_manager_get_core_device (device_manager,
- CLUTTER_POINTER_DEVICE);
-
+ clutter_event_set_device (event, device);
+ clutter_event_set_source_device (event, source_device);
if (gdk_event->type == GDK_ENTER_NOTIFY)
- _clutter_stage_add_device (stage, event->crossing.device);
+ _clutter_stage_add_device (stage, clutter_event_get_device (event));
else
- _clutter_stage_remove_device (stage, event->crossing.device);
+ _clutter_stage_remove_device (stage, clutter_event_get_device (event));
+ CLUTTER_NOTE (EVENT, "Crossing %s [%.2f, %.2f]",
+ event->type == CLUTTER_ENTER ? "enter" : "leave",
+ event->crossing.x,
+ event->crossing.y);
break;
case GDK_FOCUS_CHANGE:
@@ -223,9 +279,8 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
event->scroll.modifier_state = gdk_event->scroll.state;
event->scroll.axes = NULL;
event->scroll.direction = gdk_event->scroll.direction;
- event->scroll.device =
- _clutter_device_manager_gdk_lookup_device (device_manager,
- gdk_event->scroll.device);
+ clutter_event_set_device (event, device);
+ clutter_event_set_source_device (event, source_device);
break;
case GDK_WINDOW_STATE:
diff --git a/clutter/gdk/clutter-input-device-gdk.c b/clutter/gdk/clutter-input-device-gdk.c
index 9d37dbc..44150ff 100644
--- a/clutter/gdk/clutter-input-device-gdk.c
+++ b/clutter/gdk/clutter-input-device-gdk.c
@@ -141,8 +141,8 @@ _clutter_input_device_gdk_new (ClutterDeviceManager *manager,
}
if (device_type != CLUTTER_KEYBOARD_DEVICE)
- /* why Gdk asserts if passed a GDK_SOURCE_KEYBOARD device? */
has_cursor = gdk_device_get_has_cursor (device);
+
name = gdk_device_get_name (device);
clutter_device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_GDK,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]