diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2014-06-10 15:35:42 +1200 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2014-10-22 11:02:53 -0500 |
commit | 84590d40acb17caafdbd88529b733ef932f7089b (patch) | |
tree | 88bd425986b380438000c6fa57db7b833f533f75 | |
parent | f6229528be860b0e110f8f623efd9d14cdcbbe10 (diff) | |
download | gtk+-84590d40acb17caafdbd88529b733ef932f7089b.tar.gz |
Move debugging into a separate file
-rw-r--r-- | gdk/mir/Makefile.am | 1 | ||||
-rw-r--r-- | gdk/mir/gdkmir-debug.c | 293 | ||||
-rw-r--r-- | gdk/mir/gdkmir-private.h | 12 | ||||
-rw-r--r-- | gdk/mir/gdkmireventsource.c | 277 |
4 files changed, 307 insertions, 276 deletions
diff --git a/gdk/mir/Makefile.am b/gdk/mir/Makefile.am index f3f908c25a..026ce7981a 100644 --- a/gdk/mir/Makefile.am +++ b/gdk/mir/Makefile.am @@ -30,6 +30,7 @@ libgdk_mir_la_SOURCES = \ gdkmirscreen.c \ gdkmirwindow.c \ gdkmirwindowimpl.c \ + gdkmir-debug.c \ gdkmir.h libgdkinclude_HEADERS = \ diff --git a/gdk/mir/gdkmir-debug.c b/gdk/mir/gdkmir-debug.c new file mode 100644 index 0000000000..ef57eff973 --- /dev/null +++ b/gdk/mir/gdkmir-debug.c @@ -0,0 +1,293 @@ +/* + * Copyright © 2014 Canonical Ltd + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "gdkmir-private.h" + +void +_gdk_mir_print_modifiers (unsigned int modifiers) +{ + g_printerr (" Modifiers"); + if ((modifiers & mir_key_modifier_alt) != 0) + g_printerr (" alt"); + if ((modifiers & mir_key_modifier_alt_left) != 0) + g_printerr (" alt-left"); + if ((modifiers & mir_key_modifier_alt_right) != 0) + g_printerr (" alt-right"); + if ((modifiers & mir_key_modifier_shift) != 0) + g_printerr (" shift"); + if ((modifiers & mir_key_modifier_shift_left) != 0) + g_printerr (" shift-left"); + if ((modifiers & mir_key_modifier_shift_right) != 0) + g_printerr (" shift-right"); + if ((modifiers & mir_key_modifier_sym) != 0) + g_printerr (" sym"); + if ((modifiers & mir_key_modifier_function) != 0) + g_printerr (" function"); + if ((modifiers & mir_key_modifier_ctrl) != 0) + g_printerr (" ctrl"); + if ((modifiers & mir_key_modifier_ctrl_left) != 0) + g_printerr (" ctrl-left"); + if ((modifiers & mir_key_modifier_ctrl_right) != 0) + g_printerr (" ctrl-right"); + if ((modifiers & mir_key_modifier_meta) != 0) + g_printerr (" meta"); + if ((modifiers & mir_key_modifier_meta_left) != 0) + g_printerr (" meta-left"); + if ((modifiers & mir_key_modifier_meta_right) != 0) + g_printerr (" meta-right"); + if ((modifiers & mir_key_modifier_caps_lock) != 0) + g_printerr (" caps-lock"); + if ((modifiers & mir_key_modifier_num_lock) != 0) + g_printerr (" num-lock"); + if ((modifiers & mir_key_modifier_scroll_lock) != 0) + g_printerr (" scroll-lock"); + g_printerr ("\n"); +} + +void +_gdk_mir_print_key_event (const MirKeyEvent *event) +{ + g_printerr ("KEY\n"); + g_printerr (" Device %i\n", event->device_id); + g_printerr (" Source %i\n", event->source_id); + g_printerr (" Action "); + switch (event->action) + { + case mir_key_action_down: + g_printerr ("down"); + break; + case mir_key_action_up: + g_printerr ("up"); + break; + case mir_key_action_multiple: + g_printerr ("multiple"); + break; + default: + g_printerr ("%u", event->action); + break; + } + g_printerr ("\n"); + g_printerr (" Flags"); + if ((event->flags & mir_key_flag_woke_here) != 0) + g_printerr (" woke-here"); + if ((event->flags & mir_key_flag_soft_keyboard) != 0) + g_printerr (" soft-keyboard"); + if ((event->flags & mir_key_flag_keep_touch_mode) != 0) + g_printerr (" keep-touch-mode"); + if ((event->flags & mir_key_flag_from_system) != 0) + g_printerr (" from-system"); + if ((event->flags & mir_key_flag_editor_action) != 0) + g_printerr (" editor-action"); + if ((event->flags & mir_key_flag_canceled) != 0) + g_printerr (" canceled"); + if ((event->flags & mir_key_flag_virtual_hard_key) != 0) + g_printerr (" virtual-hard-key"); + if ((event->flags & mir_key_flag_long_press) != 0) + g_printerr (" long-press"); + if ((event->flags & mir_key_flag_canceled_long_press) != 0) + g_printerr (" canceled-long-press"); + if ((event->flags & mir_key_flag_tracking) != 0) + g_printerr (" tracking"); + if ((event->flags & mir_key_flag_fallback) != 0) + g_printerr (" fallback"); + g_printerr ("\n"); + _gdk_mir_print_modifiers (event->modifiers); + g_printerr (" Key Code %i\n", event->key_code); + g_printerr (" Scan Code %i\n", event->scan_code); + g_printerr (" Repeat Count %i\n", event->repeat_count); + g_printerr (" Down Time %lli\n", (long long int) event->down_time); + g_printerr (" Event Time %lli\n", (long long int) event->event_time); + g_printerr (" Is System Key %s\n", event->is_system_key ? "true" : "false"); +} + +void +_gdk_mir_print_motion_event (const MirMotionEvent *event) +{ + size_t i; + + g_printerr ("MOTION\n"); + g_printerr (" Device %i\n", event->device_id); + g_printerr (" Source %i\n", event->source_id); + g_printerr (" Action "); + switch (event->action) + { + case mir_motion_action_down: + g_printerr ("down"); + break; + case mir_motion_action_up: + g_printerr ("up"); + break; + case mir_motion_action_move: + g_printerr ("move"); + break; + case mir_motion_action_cancel: + g_printerr ("cancel"); + break; + case mir_motion_action_outside: + g_printerr ("outside"); + break; + case mir_motion_action_pointer_down: + g_printerr ("pointer-down"); + break; + case mir_motion_action_pointer_up: + g_printerr ("pointer-up"); + break; + case mir_motion_action_hover_move: + g_printerr ("hover-move"); + break; + case mir_motion_action_scroll: + g_printerr ("scroll"); + break; + case mir_motion_action_hover_enter: + g_printerr ("hover-enter"); + break; + case mir_motion_action_hover_exit: + g_printerr ("hover-exit"); + break; + default: + g_printerr ("%u", event->action); + } + g_printerr ("\n"); + g_printerr (" Flags"); + switch (event->flags) + { + case mir_motion_flag_window_is_obscured: + g_printerr (" window-is-obscured"); + break; + } + g_printerr ("\n"); + _gdk_mir_print_modifiers (event->modifiers); + g_printerr (" Edge Flags %i\n", event->edge_flags); + g_printerr (" Button State"); + switch (event->button_state) + { + case mir_motion_button_primary: + g_printerr (" primary"); + break; + case mir_motion_button_secondary: + g_printerr (" secondary"); + break; + case mir_motion_button_tertiary: + g_printerr (" tertiary"); + break; + case mir_motion_button_back: + g_printerr (" back"); + break; + case mir_motion_button_forward: + g_printerr (" forward"); + break; + } + g_printerr ("\n"); + g_printerr (" Offset (%f, %f)\n", event->x_offset, event->y_offset); + g_printerr (" Precision (%f, %f)\n", event->x_precision, event->y_precision); + g_printerr (" Down Time %lli\n", (long long int) event->down_time); + g_printerr (" Event Time %lli\n", (long long int) event->event_time); + g_printerr (" Pointer Coordinates\n"); + for (i = 0; i < event->pointer_count; i++) + { + g_printerr (" ID=%i location=(%f, %f) raw=(%f, %f) touch=(%f, %f) size=%f pressure=%f orientation=%f scroll=(%f, %f) tool=", + event->pointer_coordinates[i].id, + event->pointer_coordinates[i].x, event->pointer_coordinates[i].y, + event->pointer_coordinates[i].raw_x, event->pointer_coordinates[i].raw_y, + event->pointer_coordinates[i].touch_major, event->pointer_coordinates[i].touch_minor, + event->pointer_coordinates[i].size, + event->pointer_coordinates[i].pressure, + event->pointer_coordinates[i].orientation, + event->pointer_coordinates[i].hscroll, event->pointer_coordinates[i].vscroll); + switch (event->pointer_coordinates[i].tool_type) + { + case mir_motion_tool_type_unknown: + g_printerr ("unknown"); + break; + case mir_motion_tool_type_finger: + g_printerr ("finger"); + break; + case mir_motion_tool_type_stylus: + g_printerr ("stylus"); + break; + case mir_motion_tool_type_mouse: + g_printerr ("mouse"); + break; + case mir_motion_tool_type_eraser: + g_printerr ("eraser"); + break; + default: + g_printerr ("%u", event->pointer_coordinates[i].tool_type); + break; + } + g_printerr ("\n"); + } +} + +void +_gdk_mir_print_surface_event (const MirSurfaceEvent *event) +{ + g_printerr ("SURFACE\n"); + g_printerr (" Surface %i\n", event->id); + g_printerr (" Attribute "); + switch (event->attrib) + { + case mir_surface_attrib_type: + g_printerr ("type"); + break; + case mir_surface_attrib_state: + g_printerr ("state"); + break; + case mir_surface_attrib_swapinterval: + g_printerr ("swapinterval"); + break; + case mir_surface_attrib_focus: + g_printerr ("focus"); + break; + default: + g_printerr ("%u", event->attrib); + break; + } + g_printerr ("\n"); + g_printerr (" Value %i\n", event->value); +} + +void +_gdk_mir_print_resize_event (const MirResizeEvent *event) +{ + g_printerr ("RESIZE\n"); + g_printerr (" Surface %i\n", event->surface_id); + g_printerr (" Size (%i, %i)\n", event->width, event->height); +} + +void +_gdk_mir_print_event (const MirEvent *event) +{ + switch (event->type) + { + case mir_event_type_key: + _gdk_mir_print_key_event (&event->key); + break; + case mir_event_type_motion: + _gdk_mir_print_motion_event (&event->motion); + break; + case mir_event_type_surface: + _gdk_mir_print_surface_event (&event->surface); + break; + case mir_event_type_resize: + _gdk_mir_print_resize_event (&event->resize); + break; + default: + g_printerr ("EVENT %u\n", event->type); + break; + } +} diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h index d1792a1131..89a2b40503 100644 --- a/gdk/mir/gdkmir-private.h +++ b/gdk/mir/gdkmir-private.h @@ -71,4 +71,16 @@ void _gdk_mir_window_reference_unref (GdkMirWindowReference *ref); void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEvent *event); +void _gdk_mir_print_modifiers (unsigned int modifiers); + +void _gdk_mir_print_key_event (const MirKeyEvent *event); + +void _gdk_mir_print_motion_event (const MirMotionEvent *event); + +void _gdk_mir_print_surface_event (const MirSurfaceEvent *event); + +void _gdk_mir_print_resize_event (const MirResizeEvent *event); + +void _gdk_mir_print_event (const MirEvent *event); + #endif /* __GDK_PRIVATE_MIR_H__ */ diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c index 831962baac..7396eba8b1 100644 --- a/gdk/mir/gdkmireventsource.c +++ b/gdk/mir/gdkmireventsource.c @@ -44,281 +44,6 @@ struct _GdkMirEventSource }; static void -print_modifiers (unsigned int modifiers) -{ - g_printerr (" Modifiers"); - if ((modifiers & mir_key_modifier_alt) != 0) - g_printerr (" alt"); - if ((modifiers & mir_key_modifier_alt_left) != 0) - g_printerr (" alt-left"); - if ((modifiers & mir_key_modifier_alt_right) != 0) - g_printerr (" alt-right"); - if ((modifiers & mir_key_modifier_shift) != 0) - g_printerr (" shift"); - if ((modifiers & mir_key_modifier_shift_left) != 0) - g_printerr (" shift-left"); - if ((modifiers & mir_key_modifier_shift_right) != 0) - g_printerr (" shift-right"); - if ((modifiers & mir_key_modifier_sym) != 0) - g_printerr (" sym"); - if ((modifiers & mir_key_modifier_function) != 0) - g_printerr (" function"); - if ((modifiers & mir_key_modifier_ctrl) != 0) - g_printerr (" ctrl"); - if ((modifiers & mir_key_modifier_ctrl_left) != 0) - g_printerr (" ctrl-left"); - if ((modifiers & mir_key_modifier_ctrl_right) != 0) - g_printerr (" ctrl-right"); - if ((modifiers & mir_key_modifier_meta) != 0) - g_printerr (" meta"); - if ((modifiers & mir_key_modifier_meta_left) != 0) - g_printerr (" meta-left"); - if ((modifiers & mir_key_modifier_meta_right) != 0) - g_printerr (" meta-right"); - if ((modifiers & mir_key_modifier_caps_lock) != 0) - g_printerr (" caps-lock"); - if ((modifiers & mir_key_modifier_num_lock) != 0) - g_printerr (" num-lock"); - if ((modifiers & mir_key_modifier_scroll_lock) != 0) - g_printerr (" scroll-lock"); - g_printerr ("\n"); -} - -static void -print_key_event (const MirKeyEvent *event) -{ - g_printerr ("KEY\n"); - g_printerr (" Device %i\n", event->device_id); - g_printerr (" Source %i\n", event->source_id); - g_printerr (" Action "); - switch (event->action) - { - case mir_key_action_down: - g_printerr ("down"); - break; - case mir_key_action_up: - g_printerr ("up"); - break; - case mir_key_action_multiple: - g_printerr ("multiple"); - break; - default: - g_printerr ("%u", event->action); - break; - } - g_printerr ("\n"); - g_printerr (" Flags"); - if ((event->flags & mir_key_flag_woke_here) != 0) - g_printerr (" woke-here"); - if ((event->flags & mir_key_flag_soft_keyboard) != 0) - g_printerr (" soft-keyboard"); - if ((event->flags & mir_key_flag_keep_touch_mode) != 0) - g_printerr (" keep-touch-mode"); - if ((event->flags & mir_key_flag_from_system) != 0) - g_printerr (" from-system"); - if ((event->flags & mir_key_flag_editor_action) != 0) - g_printerr (" editor-action"); - if ((event->flags & mir_key_flag_canceled) != 0) - g_printerr (" canceled"); - if ((event->flags & mir_key_flag_virtual_hard_key) != 0) - g_printerr (" virtual-hard-key"); - if ((event->flags & mir_key_flag_long_press) != 0) - g_printerr (" long-press"); - if ((event->flags & mir_key_flag_canceled_long_press) != 0) - g_printerr (" canceled-long-press"); - if ((event->flags & mir_key_flag_tracking) != 0) - g_printerr (" tracking"); - if ((event->flags & mir_key_flag_fallback) != 0) - g_printerr (" fallback"); - g_printerr ("\n"); - print_modifiers (event->modifiers); - g_printerr (" Key Code %i\n", event->key_code); - g_printerr (" Scan Code %i\n", event->scan_code); - g_printerr (" Repeat Count %i\n", event->repeat_count); - g_printerr (" Down Time %lli\n", (long long int) event->down_time); - g_printerr (" Event Time %lli\n", (long long int) event->event_time); - g_printerr (" Is System Key %s\n", event->is_system_key ? "true" : "false"); -} - -static void -print_motion_event (const MirMotionEvent *event) -{ - size_t i; - - g_printerr ("MOTION\n"); - g_printerr (" Device %i\n", event->device_id); - g_printerr (" Source %i\n", event->source_id); - g_printerr (" Action "); - switch (event->action) - { - case mir_motion_action_down: - g_printerr ("down"); - break; - case mir_motion_action_up: - g_printerr ("up"); - break; - case mir_motion_action_move: - g_printerr ("move"); - break; - case mir_motion_action_cancel: - g_printerr ("cancel"); - break; - case mir_motion_action_outside: - g_printerr ("outside"); - break; - case mir_motion_action_pointer_down: - g_printerr ("pointer-down"); - break; - case mir_motion_action_pointer_up: - g_printerr ("pointer-up"); - break; - case mir_motion_action_hover_move: - g_printerr ("hover-move"); - break; - case mir_motion_action_scroll: - g_printerr ("scroll"); - break; - case mir_motion_action_hover_enter: - g_printerr ("hover-enter"); - break; - case mir_motion_action_hover_exit: - g_printerr ("hover-exit"); - break; - default: - g_printerr ("%u", event->action); - } - g_printerr ("\n"); - g_printerr (" Flags"); - switch (event->flags) - { - case mir_motion_flag_window_is_obscured: - g_printerr (" window-is-obscured"); - break; - } - g_printerr ("\n"); - print_modifiers (event->modifiers); - g_printerr (" Edge Flags %i\n", event->edge_flags); - g_printerr (" Button State"); - switch (event->button_state) - { - case mir_motion_button_primary: - g_printerr (" primary"); - break; - case mir_motion_button_secondary: - g_printerr (" secondary"); - break; - case mir_motion_button_tertiary: - g_printerr (" tertiary"); - break; - case mir_motion_button_back: - g_printerr (" back"); - break; - case mir_motion_button_forward: - g_printerr (" forward"); - break; - } - g_printerr ("\n"); - g_printerr (" Offset (%f, %f)\n", event->x_offset, event->y_offset); - g_printerr (" Precision (%f, %f)\n", event->x_precision, event->y_precision); - g_printerr (" Down Time %lli\n", (long long int) event->down_time); - g_printerr (" Event Time %lli\n", (long long int) event->event_time); - g_printerr (" Pointer Coordinates\n"); - for (i = 0; i < event->pointer_count; i++) - { - g_printerr (" ID=%i location=(%f, %f) raw=(%f, %f) touch=(%f, %f) size=%f pressure=%f orientation=%f scroll=(%f, %f) tool=", - event->pointer_coordinates[i].id, - event->pointer_coordinates[i].x, event->pointer_coordinates[i].y, - event->pointer_coordinates[i].raw_x, event->pointer_coordinates[i].raw_y, - event->pointer_coordinates[i].touch_major, event->pointer_coordinates[i].touch_minor, - event->pointer_coordinates[i].size, - event->pointer_coordinates[i].pressure, - event->pointer_coordinates[i].orientation, - event->pointer_coordinates[i].hscroll, event->pointer_coordinates[i].vscroll); - switch (event->pointer_coordinates[i].tool_type) - { - case mir_motion_tool_type_unknown: - g_printerr ("unknown"); - break; - case mir_motion_tool_type_finger: - g_printerr ("finger"); - break; - case mir_motion_tool_type_stylus: - g_printerr ("stylus"); - break; - case mir_motion_tool_type_mouse: - g_printerr ("mouse"); - break; - case mir_motion_tool_type_eraser: - g_printerr ("eraser"); - break; - default: - g_printerr ("%u", event->pointer_coordinates[i].tool_type); - break; - } - g_printerr ("\n"); - } -} - -static void -print_surface_event (const MirSurfaceEvent *event) -{ - g_printerr ("SURFACE\n"); - g_printerr (" Surface %i\n", event->id); - g_printerr (" Attribute "); - switch (event->attrib) - { - case mir_surface_attrib_type: - g_printerr ("type"); - break; - case mir_surface_attrib_state: - g_printerr ("state"); - break; - case mir_surface_attrib_swapinterval: - g_printerr ("swapinterval"); - break; - case mir_surface_attrib_focus: - g_printerr ("focus"); - break; - default: - g_printerr ("%u", event->attrib); - break; - } - g_printerr ("\n"); - g_printerr (" Value %i\n", event->value); -} - -static void -print_resize_event (const MirResizeEvent *event) -{ - g_printerr ("RESIZE\n"); - g_printerr (" Surface %i\n", event->surface_id); - g_printerr (" Size (%i, %i)\n", event->width, event->height); -} - -static void -print_event (const MirEvent *event) -{ - switch (event->type) - { - case mir_event_type_key: - print_key_event (&event->key); - break; - case mir_event_type_motion: - print_motion_event (&event->motion); - break; - case mir_event_type_surface: - print_surface_event (&event->surface); - break; - case mir_event_type_resize: - print_resize_event (&event->resize); - break; - default: - g_printerr ("EVENT %u\n", event->type); - break; - } -} - -static void send_event (GdkWindow *window, GdkDevice *device, GdkEvent *event) { GdkDisplay *display; @@ -671,7 +396,7 @@ gdk_mir_event_source_queue_event (GdkDisplay *display, const MirEvent *event) { if (g_getenv ("GDK_MIR_LOG_EVENTS")) - print_event (event); + _gdk_mir_print_event (event); // FIXME: Only generate events if the window wanted them? switch (event->type) |