mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
win32: Experimental implementation of device support
Mostly lifted from the core pointer and keyboard X11 backend support. The win32 backend registers two devices (a core pointer and a core keyboard) and assigns them to the event structure when doing the translation from native events to Clutter events. Thanks to: Samuel Degrande <Samuel.Degrande@lifl.fr> for testing this patch.
This commit is contained in:
parent
850dd5a38f
commit
74dbcede25
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "../clutter-event.h"
|
#include "../clutter-event.h"
|
||||||
#include "../clutter-main.h"
|
#include "../clutter-main.h"
|
||||||
|
#include "../clutter-input-device.h"
|
||||||
#include "../clutter-debug.h"
|
#include "../clutter-debug.h"
|
||||||
#include "../clutter-private.h"
|
#include "../clutter-private.h"
|
||||||
#include "../clutter-version.h"
|
#include "../clutter-version.h"
|
||||||
@ -64,8 +65,30 @@ clutter_backend_win32_pre_parse (ClutterBackend *backend,
|
|||||||
static void
|
static void
|
||||||
clutter_backend_win32_init_events (ClutterBackend *backend)
|
clutter_backend_win32_init_events (ClutterBackend *backend)
|
||||||
{
|
{
|
||||||
|
ClutterBackendWin32 *backend_win32 = CLUTTER_BACKEND_WIN32 (backend);
|
||||||
|
ClutterDeviceManager *manager;
|
||||||
|
ClutterInputDevice *device;
|
||||||
|
|
||||||
CLUTTER_NOTE (EVENT, "initialising the event loop");
|
CLUTTER_NOTE (EVENT, "initialising the event loop");
|
||||||
|
|
||||||
|
manager = clutter_device_manager_get_default ();
|
||||||
|
|
||||||
|
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE,
|
||||||
|
"id", 0,
|
||||||
|
"name", "Core Pointer",
|
||||||
|
"device-type", CLUTTER_POINTER_DEVICE,
|
||||||
|
NULL);
|
||||||
|
_clutter_device_manager_add_device (manager, device);
|
||||||
|
backend_win32->core_pointer = device;
|
||||||
|
|
||||||
|
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE,
|
||||||
|
"id", 1,
|
||||||
|
"name", "Core Keyboard",
|
||||||
|
"device-type", CLUTTER_KEYBOARD_DEVICE,
|
||||||
|
NULL);
|
||||||
|
_clutter_device_manager_add_device (manager, device);
|
||||||
|
backend_win32->core_keyboard = device;
|
||||||
|
|
||||||
_clutter_backend_win32_events_init (backend);
|
_clutter_backend_win32_events_init (backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,9 @@ struct _ClutterBackendWin32
|
|||||||
HCURSOR invisible_cursor;
|
HCURSOR invisible_cursor;
|
||||||
|
|
||||||
GSource *event_source;
|
GSource *event_source;
|
||||||
|
|
||||||
|
ClutterInputDevice *core_pointer;
|
||||||
|
ClutterInputDevice *core_keyboard;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ClutterBackendWin32Class
|
struct _ClutterBackendWin32Class
|
||||||
|
@ -201,9 +201,13 @@ get_modifier_state (WPARAM wparam)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
make_button_event (const MSG *msg, ClutterEvent *event,
|
make_button_event (const MSG *msg,
|
||||||
int button, int click_count, gboolean release)
|
ClutterEvent *event,
|
||||||
|
int button,
|
||||||
|
int click_count,
|
||||||
|
gboolean release,
|
||||||
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
event->type = release ? CLUTTER_BUTTON_RELEASE : CLUTTER_BUTTON_PRESS;
|
event->type = release ? CLUTTER_BUTTON_RELEASE : CLUTTER_BUTTON_PRESS;
|
||||||
event->button.time = msg->time;
|
event->button.time = msg->time;
|
||||||
@ -212,6 +216,7 @@ make_button_event (const MSG *msg, ClutterEvent *event,
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -326,11 +331,11 @@ message_translate (ClutterBackend *backend,
|
|||||||
const MSG *msg,
|
const MSG *msg,
|
||||||
gboolean *call_def_window_proc)
|
gboolean *call_def_window_proc)
|
||||||
{
|
{
|
||||||
ClutterBackendWin32 *backend_win32;
|
ClutterBackendWin32 *backend_win32;
|
||||||
ClutterStageWin32 *stage_win32;
|
ClutterStageWin32 *stage_win32;
|
||||||
ClutterStage *stage;
|
ClutterStage *stage;
|
||||||
ClutterStageWindow *impl;
|
ClutterStageWindow *impl;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
backend_win32 = CLUTTER_BACKEND_WIN32 (backend);
|
backend_win32 = CLUTTER_BACKEND_WIN32 (backend);
|
||||||
|
|
||||||
@ -429,39 +434,39 @@ message_translate (ClutterBackend *backend,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
make_button_event (msg, event, 1, 1, FALSE);
|
make_button_event (msg, event, 1, 1, FALSE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
make_button_event (msg, event, 2, 1, FALSE);
|
make_button_event (msg, event, 2, 1, FALSE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
make_button_event (msg, event, 3, 1, FALSE);
|
make_button_event (msg, event, 3, 1, FALSE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
make_button_event (msg, event, 1, 1, TRUE);
|
make_button_event (msg, event, 1, 1, TRUE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
make_button_event (msg, event, 2, 1, TRUE);
|
make_button_event (msg, event, 2, 1, TRUE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
make_button_event (msg, event, 3, 1, TRUE);
|
make_button_event (msg, event, 3, 1, TRUE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK:
|
||||||
make_button_event (msg, event, 1, 2, FALSE);
|
make_button_event (msg, event, 1, 2, FALSE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MBUTTONDBLCLK:
|
case WM_MBUTTONDBLCLK:
|
||||||
make_button_event (msg, event, 2, 2, FALSE);
|
make_button_event (msg, event, 2, 2, FALSE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_RBUTTONDBLCLK:
|
case WM_RBUTTONDBLCLK:
|
||||||
make_button_event (msg, event, 3, 2, FALSE);
|
make_button_event (msg, event, 3, 2, FALSE, backend_win32->core_pointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
@ -469,8 +474,8 @@ message_translate (ClutterBackend *backend,
|
|||||||
|
|
||||||
event->type = CLUTTER_SCROLL;
|
event->type = CLUTTER_SCROLL;
|
||||||
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 = backend_win32->core_pointer;
|
||||||
|
|
||||||
/* conversion to window coordinates is required */
|
/* conversion to window coordinates is required */
|
||||||
{
|
{
|
||||||
@ -500,7 +505,9 @@ message_translate (ClutterBackend *backend,
|
|||||||
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);
|
||||||
/* We need to start tracking when the mouse leaves the stage if
|
event->motion.device = backend_win32->core_pointer;
|
||||||
|
|
||||||
|
/* 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)
|
||||||
{
|
{
|
||||||
@ -511,6 +518,9 @@ message_translate (ClutterBackend *backend,
|
|||||||
tmevent.hwndTrack = stage_win32->hwnd;
|
tmevent.hwndTrack = stage_win32->hwnd;
|
||||||
TrackMouseEvent (&tmevent);
|
TrackMouseEvent (&tmevent);
|
||||||
|
|
||||||
|
/* we entered the stage */
|
||||||
|
_clutter_input_device_set_stage (event->motion.device, stage);
|
||||||
|
|
||||||
stage_win32->tracking_mouse = TRUE;
|
stage_win32->tracking_mouse = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -520,6 +530,10 @@ message_translate (ClutterBackend *backend,
|
|||||||
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 = backend_win32->core_pointer;
|
||||||
|
|
||||||
|
/* we left the stage */
|
||||||
|
_clutter_input_device_set_stage (event->crossing.device, NULL);
|
||||||
|
|
||||||
/* 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
|
||||||
@ -604,6 +618,7 @@ message_translate (ClutterBackend *backend,
|
|||||||
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 = backend_win32->core_keyboard;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user