seat: Reorder handle_event helpers near handle_event

This commit is contained in:
Jasper St. Pierre 2014-04-17 19:07:43 -04:00
parent 1abdd7be10
commit 72e4d42267

View File

@ -162,6 +162,72 @@ meta_wayland_seat_free (MetaWaylandSeat *seat)
g_slice_free (MetaWaylandSeat, seat); g_slice_free (MetaWaylandSeat, seat);
} }
static int
count_buttons (const ClutterEvent *event)
{
static gint maskmap[5] =
{
CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON2_MASK, CLUTTER_BUTTON3_MASK,
CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK
};
ClutterModifierType mod_mask;
int i, count;
mod_mask = clutter_event_get_state (event);
count = 0;
for (i = 0; i < 5; i++)
{
if (mod_mask & maskmap[i])
count++;
}
return count;
}
static void
meta_wayland_seat_update_pointer (MetaWaylandSeat *seat,
const ClutterEvent *event)
{
float x, y;
clutter_event_get_coords (event, &x, &y);
seat->pointer.x = wl_fixed_from_double (x);
seat->pointer.y = wl_fixed_from_double (y);
seat->pointer.button_count = count_buttons (event);
if (seat->pointer.cursor_tracker)
{
meta_cursor_tracker_update_position (seat->pointer.cursor_tracker,
wl_fixed_to_int (seat->pointer.x),
wl_fixed_to_int (seat->pointer.y));
if (seat->pointer.current == NULL)
meta_cursor_tracker_unset_window_cursor (seat->pointer.cursor_tracker);
}
}
void
meta_wayland_seat_update (MetaWaylandSeat *seat,
const ClutterEvent *event)
{
switch (event->type)
{
case CLUTTER_MOTION:
case CLUTTER_BUTTON_PRESS:
case CLUTTER_BUTTON_RELEASE:
case CLUTTER_SCROLL:
meta_wayland_seat_update_pointer (seat, event);
break;
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
meta_wayland_keyboard_update (&seat->keyboard, (const ClutterKeyEvent *) event);
break;
default:
break;
}
}
static void static void
notify_motion (MetaWaylandSeat *seat, notify_motion (MetaWaylandSeat *seat,
const ClutterEvent *event) const ClutterEvent *event)
@ -261,72 +327,6 @@ handle_scroll_event (MetaWaylandSeat *seat,
} }
} }
static int
count_buttons (const ClutterEvent *event)
{
static gint maskmap[5] =
{
CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON2_MASK, CLUTTER_BUTTON3_MASK,
CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK
};
ClutterModifierType mod_mask;
int i, count;
mod_mask = clutter_event_get_state (event);
count = 0;
for (i = 0; i < 5; i++)
{
if (mod_mask & maskmap[i])
count++;
}
return count;
}
static void
meta_wayland_seat_update_pointer (MetaWaylandSeat *seat,
const ClutterEvent *event)
{
float x, y;
clutter_event_get_coords (event, &x, &y);
seat->pointer.x = wl_fixed_from_double (x);
seat->pointer.y = wl_fixed_from_double (y);
seat->pointer.button_count = count_buttons (event);
if (seat->pointer.cursor_tracker)
{
meta_cursor_tracker_update_position (seat->pointer.cursor_tracker,
wl_fixed_to_int (seat->pointer.x),
wl_fixed_to_int (seat->pointer.y));
if (seat->pointer.current == NULL)
meta_cursor_tracker_unset_window_cursor (seat->pointer.cursor_tracker);
}
}
void
meta_wayland_seat_update (MetaWaylandSeat *seat,
const ClutterEvent *event)
{
switch (event->type)
{
case CLUTTER_MOTION:
case CLUTTER_BUTTON_PRESS:
case CLUTTER_BUTTON_RELEASE:
case CLUTTER_SCROLL:
meta_wayland_seat_update_pointer (seat, event);
break;
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
meta_wayland_keyboard_update (&seat->keyboard, (const ClutterKeyEvent *) event);
break;
default:
break;
}
}
gboolean gboolean
meta_wayland_seat_handle_event (MetaWaylandSeat *seat, meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
const ClutterEvent *event) const ClutterEvent *event)