mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
win32: Small clean ups in the event code
Use clutter_event_set_device() instead of setting the device field. Also, use G_N_ELEMENTS() to determine the size of the key symbols mapping array.
This commit is contained in:
parent
82d1e5a6ee
commit
f4508be4ab
@ -129,8 +129,8 @@ static const struct
|
|||||||
{ VK_LCONTROL, CLUTTER_KEY_Control_L },
|
{ VK_LCONTROL, CLUTTER_KEY_Control_L },
|
||||||
{ VK_RCONTROL, CLUTTER_KEY_Control_R }
|
{ VK_RCONTROL, CLUTTER_KEY_Control_R }
|
||||||
};
|
};
|
||||||
#define CLUTTER_WIN32_KEY_MAP_SIZE (sizeof (clutter_win32_key_map) \
|
|
||||||
/ sizeof (clutter_win32_key_map[0]))
|
#define CLUTTER_WIN32_KEY_MAP_SIZE (G_N_ELEMENTS (clutter_win32_key_map))
|
||||||
|
|
||||||
static GSource *
|
static GSource *
|
||||||
clutter_event_source_new (ClutterBackend *backend)
|
clutter_event_source_new (ClutterBackend *backend)
|
||||||
@ -140,6 +140,8 @@ clutter_event_source_new (ClutterBackend *backend)
|
|||||||
|
|
||||||
event_source->backend = backend;
|
event_source->backend = backend;
|
||||||
|
|
||||||
|
g_source_set_name (source, "Clutter Win32 Event Source");
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +206,7 @@ get_modifier_state (WPARAM wparam)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
take_and_queue_event (ClutterEvent *event)
|
take_and_queue_event (ClutterEvent *event)
|
||||||
{
|
{
|
||||||
/* The event is added directly to the queue instead of using
|
/* The event is added directly to the queue instead of using
|
||||||
@ -224,14 +226,16 @@ make_button_event (const MSG *msg,
|
|||||||
ClutterEvent *event = clutter_event_new (release ?
|
ClutterEvent *event = clutter_event_new (release ?
|
||||||
CLUTTER_BUTTON_RELEASE :
|
CLUTTER_BUTTON_RELEASE :
|
||||||
CLUTTER_BUTTON_PRESS);
|
CLUTTER_BUTTON_PRESS);
|
||||||
|
|
||||||
|
event->any.stage = stage;
|
||||||
|
|
||||||
event->button.time = msg->time;
|
event->button.time = msg->time;
|
||||||
event->button.x = GET_X_LPARAM (msg->lParam);
|
event->button.x = GET_X_LPARAM (msg->lParam);
|
||||||
event->button.y = GET_Y_LPARAM (msg->lParam);
|
event->button.y = GET_Y_LPARAM (msg->lParam);
|
||||||
event->button.modifier_state = get_modifier_state (msg->wParam);
|
event->button.modifier_state = get_modifier_state (msg->wParam);
|
||||||
event->button.button = button;
|
event->button.button = button;
|
||||||
event->button.click_count = click_count;
|
event->button.click_count = click_count;
|
||||||
event->button.device = device;
|
clutter_event_set_device (event, device);
|
||||||
event->any.stage = stage;
|
|
||||||
|
|
||||||
take_and_queue_event (event);
|
take_and_queue_event (event);
|
||||||
}
|
}
|
||||||
@ -508,9 +512,10 @@ clutter_win32_handle_event (const MSG *msg)
|
|||||||
event->scroll.time = msg->time;
|
event->scroll.time = msg->time;
|
||||||
event->scroll.modifier_state =
|
event->scroll.modifier_state =
|
||||||
get_modifier_state (LOWORD (msg->wParam));
|
get_modifier_state (LOWORD (msg->wParam));
|
||||||
event->scroll.device = core_pointer;
|
|
||||||
event->any.stage = stage;
|
event->any.stage = stage;
|
||||||
|
|
||||||
|
clutter_event_set_device (event, core_pointer);
|
||||||
|
|
||||||
/* conversion to window coordinates is required */
|
/* conversion to window coordinates is required */
|
||||||
pt.x = GET_X_LPARAM (msg->lParam);
|
pt.x = GET_X_LPARAM (msg->lParam);
|
||||||
pt.y = GET_Y_LPARAM (msg->lParam);
|
pt.y = GET_Y_LPARAM (msg->lParam);
|
||||||
@ -541,9 +546,10 @@ clutter_win32_handle_event (const MSG *msg)
|
|||||||
event->motion.x = GET_X_LPARAM (msg->lParam);
|
event->motion.x = GET_X_LPARAM (msg->lParam);
|
||||||
event->motion.y = GET_Y_LPARAM (msg->lParam);
|
event->motion.y = GET_Y_LPARAM (msg->lParam);
|
||||||
event->motion.modifier_state = get_modifier_state (msg->wParam);
|
event->motion.modifier_state = get_modifier_state (msg->wParam);
|
||||||
event->motion.device = core_pointer;
|
|
||||||
event->any.stage = stage;
|
event->any.stage = stage;
|
||||||
|
|
||||||
|
clutter_event_set_device (event, core_pointer);
|
||||||
|
|
||||||
/* We need to start tracking when the mouse enters the stage if
|
/* We need to start tracking when the mouse enters the stage if
|
||||||
we're not already */
|
we're not already */
|
||||||
if (!stage_win32->tracking_mouse)
|
if (!stage_win32->tracking_mouse)
|
||||||
@ -559,11 +565,12 @@ clutter_win32_handle_event (const MSG *msg)
|
|||||||
event->crossing.time = msg->time;
|
event->crossing.time = msg->time;
|
||||||
event->crossing.x = event->motion.x;
|
event->crossing.x = event->motion.x;
|
||||||
event->crossing.y = event->motion.y;
|
event->crossing.y = event->motion.y;
|
||||||
event->crossing.device = event->motion.device;
|
|
||||||
event->crossing.stage = stage;
|
event->crossing.stage = stage;
|
||||||
event->crossing.source = CLUTTER_ACTOR (stage);
|
event->crossing.source = CLUTTER_ACTOR (stage);
|
||||||
event->crossing.related = NULL;
|
event->crossing.related = NULL;
|
||||||
|
|
||||||
|
clutter_event_set_device (event, core_pointer);
|
||||||
|
|
||||||
/* we entered the stage */
|
/* we entered the stage */
|
||||||
_clutter_stage_add_device (stage, event->crossing.device);
|
_clutter_stage_add_device (stage, event->crossing.device);
|
||||||
|
|
||||||
@ -583,13 +590,14 @@ clutter_win32_handle_event (const MSG *msg)
|
|||||||
event->crossing.time = msg->time;
|
event->crossing.time = msg->time;
|
||||||
event->crossing.x = msg->pt.x;
|
event->crossing.x = msg->pt.x;
|
||||||
event->crossing.y = msg->pt.y;
|
event->crossing.y = msg->pt.y;
|
||||||
event->crossing.device = core_pointer;
|
|
||||||
event->crossing.stage = stage;
|
event->crossing.stage = stage;
|
||||||
event->crossing.source = CLUTTER_ACTOR (stage);
|
event->crossing.source = CLUTTER_ACTOR (stage);
|
||||||
event->crossing.related = NULL;
|
event->crossing.related = NULL;
|
||||||
|
|
||||||
|
clutter_event_set_device (event, core_pointer);
|
||||||
|
|
||||||
/* we left the stage */
|
/* we left the stage */
|
||||||
_clutter_stage_remove_device (stage, event->crossing.device);
|
_clutter_stage_remove_device (stage, core_pointer);
|
||||||
|
|
||||||
/* When we get a leave message the mouse tracking is
|
/* When we get a leave message the mouse tracking is
|
||||||
automatically cancelled so we'll need to start it again when
|
automatically cancelled so we'll need to start it again when
|
||||||
@ -678,9 +686,10 @@ clutter_win32_handle_event (const MSG *msg)
|
|||||||
event->key.time = msg->time;
|
event->key.time = msg->time;
|
||||||
event->key.modifier_state = get_key_modifier_state (key_states);
|
event->key.modifier_state = get_key_modifier_state (key_states);
|
||||||
event->key.hardware_keycode = scan_code;
|
event->key.hardware_keycode = scan_code;
|
||||||
event->key.device = core_keyboard;
|
|
||||||
event->any.stage = stage;
|
event->any.stage = stage;
|
||||||
|
|
||||||
|
clutter_event_set_device (event, core_keyboard);
|
||||||
|
|
||||||
take_and_queue_event (event);
|
take_and_queue_event (event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user