mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
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.
This commit is contained in:
parent
405e72f2e4
commit
8eb71af23d
@ -31,10 +31,12 @@
|
|||||||
#include "clutter-backend-gdk.h"
|
#include "clutter-backend-gdk.h"
|
||||||
#include "clutter-device-manager-gdk.h"
|
#include "clutter-device-manager-gdk.h"
|
||||||
|
|
||||||
#include "clutter-debug.h"
|
#include "clutter-actor-private.h"
|
||||||
#include "clutter-main.h"
|
|
||||||
#include "clutter-backend-private.h"
|
#include "clutter-backend-private.h"
|
||||||
|
#include "clutter-debug.h"
|
||||||
#include "clutter-event-private.h"
|
#include "clutter-event-private.h"
|
||||||
|
#include "clutter-main.h"
|
||||||
|
#include "clutter-paint-volume-private.h"
|
||||||
#include "clutter-stage-private.h"
|
#include "clutter-stage-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -87,6 +89,8 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
|
|||||||
ClutterEvent *event = NULL;
|
ClutterEvent *event = NULL;
|
||||||
gint spin = 0;
|
gint spin = 0;
|
||||||
GdkFilterReturn result = GDK_FILTER_CONTINUE;
|
GdkFilterReturn result = GDK_FILTER_CONTINUE;
|
||||||
|
ClutterInputDevice *device, *source_device;
|
||||||
|
GdkDevice *gdk_device;
|
||||||
|
|
||||||
backend = clutter_get_default_backend ();
|
backend = clutter_get_default_backend ();
|
||||||
if (!CLUTTER_IS_BACKEND_GDK (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);
|
stage = clutter_gdk_get_stage_from_window (gdk_event->any.window);
|
||||||
device_manager = clutter_device_manager_get_default ();
|
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)
|
if (stage == NULL)
|
||||||
return GDK_FILTER_CONTINUE;
|
return GDK_FILTER_CONTINUE;
|
||||||
|
|
||||||
@ -115,7 +133,32 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_EXPOSE:
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_DAMAGE:
|
case GDK_DAMAGE:
|
||||||
@ -130,9 +173,11 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
|
|||||||
event->motion.axes = NULL;
|
event->motion.axes = NULL;
|
||||||
/* It's all X in the end, right? */
|
/* It's all X in the end, right? */
|
||||||
event->motion.modifier_state = gdk_event->motion.state;
|
event->motion.modifier_state = gdk_event->motion.state;
|
||||||
event->motion.device =
|
clutter_event_set_device (event, device);
|
||||||
_clutter_device_manager_gdk_lookup_device (device_manager,
|
clutter_event_set_source_device (event, source_device);
|
||||||
gdk_event->motion.device);
|
CLUTTER_NOTE (EVENT, "Motion notifiy [%.2f, %.2f]",
|
||||||
|
event->motion.x,
|
||||||
|
event->motion.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_BUTTON_PRESS:
|
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.modifier_state = gdk_event->button.state;
|
||||||
event->button.button = gdk_event->button.button;
|
event->button.button = gdk_event->button.button;
|
||||||
event->button.click_count = 1;
|
event->button.click_count = 1;
|
||||||
event->button.device =
|
clutter_event_set_device (event, device);
|
||||||
_clutter_device_manager_gdk_lookup_device (device_manager,
|
clutter_event_set_source_device (event, source_device);
|
||||||
gdk_event->button.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;
|
break;
|
||||||
|
|
||||||
case GDK_2BUTTON_PRESS:
|
case GDK_2BUTTON_PRESS:
|
||||||
@ -167,6 +216,11 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
|
|||||||
event->key.keyval = gdk_event->key.keyval;
|
event->key.keyval = gdk_event->key.keyval;
|
||||||
event->key.hardware_keycode = gdk_event->key.hardware_keycode;
|
event->key.hardware_keycode = gdk_event->key.hardware_keycode;
|
||||||
event->key.unicode_value = g_utf8_get_char (gdk_event->key.string);
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_ENTER_NOTIFY:
|
case GDK_ENTER_NOTIFY:
|
||||||
@ -175,19 +229,21 @@ clutter_gdk_handle_event (GdkEvent *gdk_event)
|
|||||||
CLUTTER_ENTER :
|
CLUTTER_ENTER :
|
||||||
CLUTTER_LEAVE);
|
CLUTTER_LEAVE);
|
||||||
event->crossing.source = CLUTTER_ACTOR (stage);
|
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.x = gdk_event->crossing.x;
|
||||||
event->crossing.y = gdk_event->crossing.y;
|
event->crossing.y = gdk_event->crossing.y;
|
||||||
|
|
||||||
/* XXX: no better fallback here? */
|
/* XXX: no better fallback here? */
|
||||||
event->crossing.device =
|
clutter_event_set_device (event, device);
|
||||||
clutter_device_manager_get_core_device (device_manager,
|
clutter_event_set_source_device (event, source_device);
|
||||||
CLUTTER_POINTER_DEVICE);
|
|
||||||
|
|
||||||
if (gdk_event->type == GDK_ENTER_NOTIFY)
|
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
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_FOCUS_CHANGE:
|
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.modifier_state = gdk_event->scroll.state;
|
||||||
event->scroll.axes = NULL;
|
event->scroll.axes = NULL;
|
||||||
event->scroll.direction = gdk_event->scroll.direction;
|
event->scroll.direction = gdk_event->scroll.direction;
|
||||||
event->scroll.device =
|
clutter_event_set_device (event, device);
|
||||||
_clutter_device_manager_gdk_lookup_device (device_manager,
|
clutter_event_set_source_device (event, source_device);
|
||||||
gdk_event->scroll.device);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_WINDOW_STATE:
|
case GDK_WINDOW_STATE:
|
||||||
|
@ -141,8 +141,8 @@ _clutter_input_device_gdk_new (ClutterDeviceManager *manager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (device_type != CLUTTER_KEYBOARD_DEVICE)
|
if (device_type != CLUTTER_KEYBOARD_DEVICE)
|
||||||
/* why Gdk asserts if passed a GDK_SOURCE_KEYBOARD device? */
|
|
||||||
has_cursor = gdk_device_get_has_cursor (device);
|
has_cursor = gdk_device_get_has_cursor (device);
|
||||||
|
|
||||||
name = gdk_device_get_name (device);
|
name = gdk_device_get_name (device);
|
||||||
|
|
||||||
clutter_device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_GDK,
|
clutter_device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_GDK,
|
||||||
|
Loading…
Reference in New Issue
Block a user