[gtk+/broadway: 2/71] Remove event translators
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/broadway: 2/71] Remove event translators
- Date: Thu, 25 Nov 2010 21:15:25 +0000 (UTC)
commit a54e556ad8c14d34f2bedb7ce9f68f8d539bd34e
Author: Alexander Larsson <alexl redhat com>
Date: Fri Nov 12 22:50:47 2010 +0100
Remove event translators
gdk/broadway/Makefile.am | 2 -
gdk/broadway/gdkdevicemanager-broadway.c | 531 +----------------------
gdk/broadway/gdkdisplay-broadway.c | 707 +-----------------------------
gdk/broadway/gdkeventsource.c | 44 --
gdk/broadway/gdkeventsource.h | 5 -
gdk/broadway/gdkeventtranslator.c | 89 ----
gdk/broadway/gdkeventtranslator.h | 65 ---
7 files changed, 2 insertions(+), 1441 deletions(-)
---
diff --git a/gdk/broadway/Makefile.am b/gdk/broadway/Makefile.am
index e61e92b..5f3c455 100644
--- a/gdk/broadway/Makefile.am
+++ b/gdk/broadway/Makefile.am
@@ -33,8 +33,6 @@ libgdk_broadway_la_SOURCES = \
gdkdrawable-broadway.h \
gdkeventsource.c \
gdkeventsource.h \
- gdkeventtranslator.c \
- gdkeventtranslator.h \
gdkgeometry-broadway.c \
gdkglobals-broadway.c \
gdkim-broadway.c \
diff --git a/gdk/broadway/gdkdevicemanager-broadway.c b/gdk/broadway/gdkdevicemanager-broadway.c
index 7b69bd0..bb6a3b6 100644
--- a/gdk/broadway/gdkdevicemanager-broadway.c
+++ b/gdk/broadway/gdkdevicemanager-broadway.c
@@ -23,7 +23,6 @@
#include "gdktypes.h"
#include "gdkdevicemanager.h"
-#include "gdkeventtranslator.h"
#include "gdkdevice-broadway.h"
#include "gdkkeysyms.h"
#include "gdkprivate-broadway.h"
@@ -44,17 +43,7 @@ static GList * gdk_device_manager_core_list_devices (GdkDeviceManager *device_ma
GdkDeviceType type);
static GdkDevice * gdk_device_manager_core_get_client_pointer (GdkDeviceManager *device_manager);
-static void gdk_device_manager_event_translator_init (GdkEventTranslatorIface *iface);
-
-static gboolean gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
- GdkDisplay *display,
- GdkEvent *event,
- XEvent *xevent);
-
-
-G_DEFINE_TYPE_WITH_CODE (GdkDeviceManagerCore, gdk_device_manager_core, GDK_TYPE_DEVICE_MANAGER,
- G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
- gdk_device_manager_event_translator_init))
+G_DEFINE_TYPE (GdkDeviceManagerCore, gdk_device_manager_core, GDK_TYPE_DEVICE_MANAGER)
static void
gdk_device_manager_core_class_init (GdkDeviceManagerCoreClass *klass)
@@ -68,12 +57,6 @@ gdk_device_manager_core_class_init (GdkDeviceManagerCoreClass *klass)
device_manager_class->get_client_pointer = gdk_device_manager_core_get_client_pointer;
}
-static void
-gdk_device_manager_event_translator_init (GdkEventTranslatorIface *iface)
-{
- iface->translate_event = gdk_device_manager_core_translate_event;
-}
-
static GdkDevice *
create_core_pointer (GdkDeviceManager *device_manager,
GdkDisplay *display)
@@ -373,518 +356,6 @@ is_parent_of (GdkWindow *parent,
return FALSE;
}
-static GdkWindow *
-get_event_window (GdkEventTranslator *translator,
- XEvent *xevent)
-{
- GdkDeviceManager *device_manager;
- GdkDisplay *display;
- GdkWindow *window;
-
- device_manager = GDK_DEVICE_MANAGER (translator);
- display = gdk_device_manager_get_display (device_manager);
- window = gdk_window_lookup_for_display (display, xevent->xany.window);
-
- /* Apply keyboard grabs to non-native windows */
- if (xevent->type == KeyPress || xevent->type == KeyRelease)
- {
- GdkDeviceGrabInfo *info;
- gulong serial;
-
- serial = _gdk_windowing_window_get_next_serial (display);
- info = _gdk_display_has_device_grab (display,
- GDK_DEVICE_MANAGER_CORE (device_manager)->core_keyboard,
- serial);
- if (info &&
- (!is_parent_of (info->window, window) ||
- !info->owner_events))
- {
- /* Report key event against grab window */
- window = info->window;
- }
- }
-
- return window;
-}
-
-static gboolean
-gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
- GdkDisplay *display,
- GdkEvent *event,
- XEvent *xevent)
-{
- GdkDeviceManagerCore *device_manager;
- GdkWindow *window;
- GdkWindowObject *window_private;
- GdkWindowImplX11 *window_impl = NULL;
- gboolean return_val;
- GdkToplevelX11 *toplevel = NULL;
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
-
- device_manager = GDK_DEVICE_MANAGER_CORE (translator);
- return_val = FALSE;
-
- window = get_event_window (translator, xevent);
- window_private = (GdkWindowObject *) window;
-
- if (window)
- {
- if (GDK_WINDOW_DESTROYED (window) || !GDK_IS_WINDOW (window))
- return FALSE;
-
- toplevel = _gdk_x11_window_get_toplevel (window);
- window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
- g_object_ref (window);
- }
-
- event->any.window = window;
- event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
-
- if (window_private && GDK_WINDOW_DESTROYED (window))
- {
- if (xevent->type != DestroyNotify)
- {
- return_val = FALSE;
- goto done;
- }
- }
-
- if (window &&
- (xevent->type == MotionNotify ||
- xevent->type == ButtonRelease))
- {
- if (_gdk_moveresize_handle_event (xevent))
- {
- return_val = FALSE;
- goto done;
- }
- }
-
- /* We do a "manual" conversion of the XEvent to a
- * GdkEvent. The structures are mostly the same so
- * the conversion is fairly straightforward. We also
- * optionally print debugging info regarding events
- * received.
- */
-
- return_val = TRUE;
-
- switch (xevent->type)
- {
- case KeyPress:
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
- translate_key_event (display, device_manager, event, xevent);
- set_user_time (window, event);
- break;
-
- case KeyRelease:
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- /* Emulate detectable auto-repeat by checking to see
- * if the next event is a key press with the same
- * keycode and timestamp, and if so, ignoring the event.
- */
-
- if (!display_x11->have_xkb_autorepeat && XPending (xevent->xkey.display))
- {
- XEvent next_event;
-
- XPeekEvent (xevent->xkey.display, &next_event);
-
- if (next_event.type == KeyPress &&
- next_event.xkey.keycode == xevent->xkey.keycode &&
- next_event.xkey.time == xevent->xkey.time)
- {
- return_val = FALSE;
- break;
- }
- }
-
- translate_key_event (display, device_manager, event, xevent);
- break;
-
- case ButtonPress:
- GDK_NOTE (EVENTS,
- g_message ("button press:\t\twindow: %ld x,y: %d %d button: %d",
- xevent->xbutton.window,
- xevent->xbutton.x, xevent->xbutton.y,
- xevent->xbutton.button));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- /* If we get a ButtonPress event where the button is 4 or 5,
- it's a Scroll event */
- switch (xevent->xbutton.button)
- {
- case 4: /* up */
- case 5: /* down */
- case 6: /* left */
- case 7: /* right */
- event->scroll.type = GDK_SCROLL;
-
- if (xevent->xbutton.button == 4)
- event->scroll.direction = GDK_SCROLL_UP;
- else if (xevent->xbutton.button == 5)
- event->scroll.direction = GDK_SCROLL_DOWN;
- else if (xevent->xbutton.button == 6)
- event->scroll.direction = GDK_SCROLL_LEFT;
- else
- event->scroll.direction = GDK_SCROLL_RIGHT;
-
- event->scroll.window = window;
- event->scroll.time = xevent->xbutton.time;
- event->scroll.x = (gdouble) xevent->xbutton.x;
- event->scroll.y = (gdouble) xevent->xbutton.y;
- event->scroll.x_root = (gdouble) xevent->xbutton.x_root;
- event->scroll.y_root = (gdouble) xevent->xbutton.y_root;
- event->scroll.state = (GdkModifierType) xevent->xbutton.state;
- event->scroll.device = device_manager->core_pointer;
-
- if (!set_screen_from_root (display, event, xevent->xbutton.root))
- {
- return_val = FALSE;
- break;
- }
-
- break;
-
- default:
- event->button.type = GDK_BUTTON_PRESS;
- event->button.window = window;
- event->button.time = xevent->xbutton.time;
- event->button.x = (gdouble) xevent->xbutton.x;
- event->button.y = (gdouble) xevent->xbutton.y;
- event->button.x_root = (gdouble) xevent->xbutton.x_root;
- event->button.y_root = (gdouble) xevent->xbutton.y_root;
- event->button.axes = NULL;
- event->button.state = (GdkModifierType) xevent->xbutton.state;
- event->button.button = xevent->xbutton.button;
- event->button.device = device_manager->core_pointer;
-
- if (!set_screen_from_root (display, event, xevent->xbutton.root))
- return_val = FALSE;
-
- break;
- }
-
- set_user_time (window, event);
-
- break;
-
- case ButtonRelease:
- GDK_NOTE (EVENTS,
- g_message ("button release:\twindow: %ld x,y: %d %d button: %d",
- xevent->xbutton.window,
- xevent->xbutton.x, xevent->xbutton.y,
- xevent->xbutton.button));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- /* We treat button presses as scroll wheel events, so ignore the release */
- if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5 ||
- xevent->xbutton.button == 6 || xevent->xbutton.button == 7)
- {
- return_val = FALSE;
- break;
- }
-
- event->button.type = GDK_BUTTON_RELEASE;
- event->button.window = window;
- event->button.time = xevent->xbutton.time;
- event->button.x = (gdouble) xevent->xbutton.x;
- event->button.y = (gdouble) xevent->xbutton.y;
- event->button.x_root = (gdouble) xevent->xbutton.x_root;
- event->button.y_root = (gdouble) xevent->xbutton.y_root;
- event->button.axes = NULL;
- event->button.state = (GdkModifierType) xevent->xbutton.state;
- event->button.button = xevent->xbutton.button;
- event->button.device = device_manager->core_pointer;
-
- if (!set_screen_from_root (display, event, xevent->xbutton.root))
- return_val = FALSE;
-
- break;
-
- case MotionNotify:
- GDK_NOTE (EVENTS,
- g_message ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s",
- xevent->xmotion.window,
- xevent->xmotion.x, xevent->xmotion.y,
- (xevent->xmotion.is_hint) ? "true" : "false"));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- event->motion.type = GDK_MOTION_NOTIFY;
- event->motion.window = window;
- event->motion.time = xevent->xmotion.time;
- event->motion.x = (gdouble) xevent->xmotion.x;
- event->motion.y = (gdouble) xevent->xmotion.y;
- event->motion.x_root = (gdouble) xevent->xmotion.x_root;
- event->motion.y_root = (gdouble) xevent->xmotion.y_root;
- event->motion.axes = NULL;
- event->motion.state = (GdkModifierType) xevent->xmotion.state;
- event->motion.is_hint = xevent->xmotion.is_hint;
- event->motion.device = device_manager->core_pointer;
-
- if (!set_screen_from_root (display, event, xevent->xbutton.root))
- {
- return_val = FALSE;
- break;
- }
-
- break;
-
- case EnterNotify:
- GDK_NOTE (EVENTS,
- g_message ("enter notify:\t\twindow: %ld detail: %d subwin: %ld",
- xevent->xcrossing.window,
- xevent->xcrossing.detail,
- xevent->xcrossing.subwindow));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- if (!set_screen_from_root (display, event, xevent->xbutton.root))
- {
- return_val = FALSE;
- break;
- }
-
- event->crossing.type = GDK_ENTER_NOTIFY;
- event->crossing.window = window;
- gdk_event_set_device (event, device_manager->core_pointer);
-
- /* If the subwindow field of the XEvent is non-NULL, then
- * lookup the corresponding GdkWindow.
- */
- if (xevent->xcrossing.subwindow != None)
- event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow);
- else
- event->crossing.subwindow = NULL;
-
- event->crossing.time = xevent->xcrossing.time;
- event->crossing.x = (gdouble) xevent->xcrossing.x;
- event->crossing.y = (gdouble) xevent->xcrossing.y;
- event->crossing.x_root = (gdouble) xevent->xcrossing.x_root;
- event->crossing.y_root = (gdouble) xevent->xcrossing.y_root;
-
- event->crossing.mode = translate_crossing_mode (xevent->xcrossing.mode);
- event->crossing.detail = translate_notify_type (xevent->xcrossing.detail);
-
- event->crossing.focus = xevent->xcrossing.focus;
- event->crossing.state = xevent->xcrossing.state;
-
- break;
-
- case LeaveNotify:
- GDK_NOTE (EVENTS,
- g_message ("leave notify:\t\twindow: %ld detail: %d subwin: %ld",
- xevent->xcrossing.window,
- xevent->xcrossing.detail, xevent->xcrossing.subwindow));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- if (!set_screen_from_root (display, event, xevent->xbutton.root))
- {
- return_val = FALSE;
- break;
- }
-
- event->crossing.type = GDK_LEAVE_NOTIFY;
- event->crossing.window = window;
- gdk_event_set_device (event, device_manager->core_pointer);
-
- /* If the subwindow field of the XEvent is non-NULL, then
- * lookup the corresponding GdkWindow.
- */
- if (xevent->xcrossing.subwindow != None)
- event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow);
- else
- event->crossing.subwindow = NULL;
-
- event->crossing.time = xevent->xcrossing.time;
- event->crossing.x = (gdouble) xevent->xcrossing.x;
- event->crossing.y = (gdouble) xevent->xcrossing.y;
- event->crossing.x_root = (gdouble) xevent->xcrossing.x_root;
- event->crossing.y_root = (gdouble) xevent->xcrossing.y_root;
-
- event->crossing.mode = translate_crossing_mode (xevent->xcrossing.mode);
- event->crossing.detail = translate_notify_type (xevent->xcrossing.detail);
-
- event->crossing.focus = xevent->xcrossing.focus;
- event->crossing.state = xevent->xcrossing.state;
-
- break;
-
- /* We only care about focus events that indicate that _this_
- * window (not a ancestor or child) got or lost the focus
- */
- case FocusIn:
- GDK_NOTE (EVENTS,
- g_message ("focus in:\t\twindow: %ld, detail: %s, mode: %s",
- xevent->xfocus.window,
- notify_details[xevent->xfocus.detail],
- notify_modes[xevent->xfocus.mode]));
-
- if (toplevel)
- {
- gboolean had_focus = HAS_FOCUS (toplevel);
-
- switch (xevent->xfocus.detail)
- {
- case NotifyAncestor:
- case NotifyVirtual:
- /* When the focus moves from an ancestor of the window to
- * the window or a descendent of the window, *and* the
- * pointer is inside the window, then we were previously
- * receiving keystroke events in the has_pointer_focus
- * case and are now receiving them in the
- * has_focus_window case.
- */
- if (toplevel->has_pointer &&
- xevent->xfocus.mode != NotifyGrab &&
- xevent->xfocus.mode != NotifyUngrab)
- toplevel->has_pointer_focus = FALSE;
-
- /* fall through */
- case NotifyNonlinear:
- case NotifyNonlinearVirtual:
- if (xevent->xfocus.mode != NotifyGrab &&
- xevent->xfocus.mode != NotifyUngrab)
- toplevel->has_focus_window = TRUE;
- /* We pretend that the focus moves to the grab
- * window, so we pay attention to NotifyGrab
- * NotifyUngrab, and ignore NotifyWhileGrabbed
- */
- if (xevent->xfocus.mode != NotifyWhileGrabbed)
- toplevel->has_focus = TRUE;
- break;
- case NotifyPointer:
- /* The X server sends NotifyPointer/NotifyGrab,
- * but the pointer focus is ignored while a
- * grab is in effect
- */
- if (xevent->xfocus.mode != NotifyGrab &&
- xevent->xfocus.mode != NotifyUngrab)
- toplevel->has_pointer_focus = TRUE;
- break;
- case NotifyInferior:
- case NotifyPointerRoot:
- case NotifyDetailNone:
- break;
- }
-
- if (HAS_FOCUS (toplevel) != had_focus)
- generate_focus_event (device_manager, window, TRUE);
- }
- break;
- case FocusOut:
- GDK_NOTE (EVENTS,
- g_message ("focus out:\t\twindow: %ld, detail: %s, mode: %s",
- xevent->xfocus.window,
- notify_details[xevent->xfocus.detail],
- notify_modes[xevent->xfocus.mode]));
-
- if (toplevel)
- {
- gboolean had_focus = HAS_FOCUS (toplevel);
-
- switch (xevent->xfocus.detail)
- {
- case NotifyAncestor:
- case NotifyVirtual:
- /* When the focus moves from the window or a descendent
- * of the window to an ancestor of the window, *and* the
- * pointer is inside the window, then we were previously
- * receiving keystroke events in the has_focus_window
- * case and are now receiving them in the
- * has_pointer_focus case.
- */
- if (toplevel->has_pointer &&
- xevent->xfocus.mode != NotifyGrab &&
- xevent->xfocus.mode != NotifyUngrab)
- toplevel->has_pointer_focus = TRUE;
-
- /* fall through */
- case NotifyNonlinear:
- case NotifyNonlinearVirtual:
- if (xevent->xfocus.mode != NotifyGrab &&
- xevent->xfocus.mode != NotifyUngrab)
- toplevel->has_focus_window = FALSE;
- if (xevent->xfocus.mode != NotifyWhileGrabbed)
- toplevel->has_focus = FALSE;
- break;
- case NotifyPointer:
- if (xevent->xfocus.mode != NotifyGrab &&
- xevent->xfocus.mode != NotifyUngrab)
- toplevel->has_pointer_focus = FALSE;
- break;
- case NotifyInferior:
- case NotifyPointerRoot:
- case NotifyDetailNone:
- break;
- }
-
- if (HAS_FOCUS (toplevel) != had_focus)
- generate_focus_event (device_manager, window, FALSE);
- }
- break;
-
- default:
- return_val = FALSE;
- }
-
- done:
- if (return_val)
- {
- if (event->any.window)
- g_object_ref (event->any.window);
-
- if (((event->any.type == GDK_ENTER_NOTIFY) ||
- (event->any.type == GDK_LEAVE_NOTIFY)) &&
- (event->crossing.subwindow != NULL))
- g_object_ref (event->crossing.subwindow);
- }
- else
- {
- /* Mark this event as having no resources to be freed */
- event->any.window = NULL;
- event->any.type = GDK_NOTHING;
- }
-
- if (window)
- g_object_unref (window);
-
- return return_val;
-}
-
static GList *
gdk_device_manager_core_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type)
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 8a8e1ba..7380bb4 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -30,7 +30,6 @@
#include "gdkasync.h"
#include "gdkdisplay.h"
#include "gdkeventsource.h"
-#include "gdkeventtranslator.h"
#include "gdkscreen.h"
#include "gdkscreen-broadway.h"
#include "gdkinternals.h"
@@ -90,13 +89,6 @@ struct _GdkErrorTrap
static void gdk_display_x11_dispose (GObject *object);
static void gdk_display_x11_finalize (GObject *object);
-static void gdk_display_x11_event_translator_init (GdkEventTranslatorIface *iface);
-
-static gboolean gdk_display_x11_translate_event (GdkEventTranslator *translator,
- GdkDisplay *display,
- GdkEvent *event,
- XEvent *xevent);
-
#ifdef HAVE_X11R6
static void gdk_internal_connection_watch (Display *display,
XPointer arg,
@@ -156,9 +148,7 @@ static const char *const precache_atoms[] = {
"_NET_VIRTUAL_ROOTS"
};
-G_DEFINE_TYPE_WITH_CODE (GdkDisplayX11, _gdk_display_x11, GDK_TYPE_DISPLAY,
- G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
- gdk_display_x11_event_translator_init))
+G_DEFINE_TYPE (GdkDisplayX11, _gdk_display_x11, GDK_TYPE_DISPLAY)
static void
@@ -176,12 +166,6 @@ _gdk_display_x11_init (GdkDisplayX11 *display)
}
static void
-gdk_display_x11_event_translator_init (GdkEventTranslatorIface *iface)
-{
- iface->translate_event = gdk_display_x11_translate_event;
-}
-
-static void
do_net_wm_state_changes (GdkWindow *window)
{
GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
@@ -345,687 +329,6 @@ gdk_check_wm_state_changed (GdkWindow *window)
do_net_wm_state_changes (window);
}
-static GdkWindow *
-get_event_window (GdkEventTranslator *translator,
- XEvent *xevent)
-{
- GdkDisplay *display;
- Window xwindow;
-
- display = (GdkDisplay *) translator;
-
- switch (xevent->type)
- {
- case DestroyNotify:
- xwindow = xevent->xdestroywindow.window;
- break;
- case UnmapNotify:
- xwindow = xevent->xunmap.window;
- break;
- case MapNotify:
- xwindow = xevent->xmap.window;
- break;
- case ConfigureNotify:
- xwindow = xevent->xconfigure.window;
- break;
- default:
- xwindow = xevent->xany.window;
- }
-
- return gdk_window_lookup_for_display (display, xwindow);
-}
-
-static gboolean
-gdk_display_x11_translate_event (GdkEventTranslator *translator,
- GdkDisplay *display,
- GdkEvent *event,
- XEvent *xevent)
-{
- GdkWindow *window;
- GdkWindowObject *window_private;
- GdkWindowImplX11 *window_impl = NULL;
- GdkScreen *screen = NULL;
- GdkScreenX11 *screen_x11 = NULL;
- GdkToplevelX11 *toplevel = NULL;
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
- gboolean return_val;
- Window xwindow = None;
-
- /* Find the GdkWindow that this event relates to.
- * Basically this means substructure events
- * are reported same as structure events
- */
- window = get_event_window (translator, xevent);
- window_private = (GdkWindowObject *) window;
-
- if (window)
- {
- /* We may receive events such as NoExpose/GraphicsExpose
- * and ShmCompletion for pixmaps
- */
- if (!GDK_IS_WINDOW (window))
- return FALSE;
-
- screen = GDK_WINDOW_SCREEN (window);
- screen_x11 = GDK_SCREEN_X11 (screen);
- toplevel = _gdk_x11_window_get_toplevel (window);
- window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
- xwindow = GDK_WINDOW_XID (window);
-
- g_object_ref (window);
- }
-
- event->any.window = window;
- event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
-
- if (window_private && GDK_WINDOW_DESTROYED (window))
- {
- if (xevent->type != DestroyNotify)
- {
- return_val = FALSE;
- goto done;
- }
- }
-
- if (xevent->type == DestroyNotify)
- {
- int i, n;
-
- n = gdk_display_get_n_screens (display);
- for (i = 0; i < n; i++)
- {
- screen = gdk_display_get_screen (display, i);
- screen_x11 = GDK_SCREEN_X11 (screen);
-
- if (screen_x11->wmspec_check_window == xwindow)
- {
- screen_x11->wmspec_check_window = None;
- screen_x11->last_wmspec_check_time = 0;
- g_free (screen_x11->window_manager_name);
- screen_x11->window_manager_name = g_strdup ("unknown");
-
- /* careful, reentrancy */
- _gdk_x11_screen_window_manager_changed (screen);
-
- return_val = FALSE;
- goto done;
- }
- }
- }
-
- /* We do a "manual" conversion of the XEvent to a
- * GdkEvent. The structures are mostly the same so
- * the conversion is fairly straightforward. We also
- * optionally print debugging info regarding events
- * received.
- */
-
- return_val = TRUE;
-
- switch (xevent->type)
- {
- case KeymapNotify:
- GDK_NOTE (EVENTS,
- g_message ("keymap notify"));
-
- /* Not currently handled */
- return_val = FALSE;
- break;
-
- case Expose:
- GDK_NOTE (EVENTS,
- g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
- xevent->xexpose.window, xevent->xexpose.count,
- xevent->xexpose.x, xevent->xexpose.y,
- xevent->xexpose.width, xevent->xexpose.height,
- event->any.send_event ? " (send)" : ""));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- {
- GdkRectangle expose_rect;
-
- expose_rect.x = xevent->xexpose.x;
- expose_rect.y = xevent->xexpose.y;
- expose_rect.width = xevent->xexpose.width;
- expose_rect.height = xevent->xexpose.height;
-
- _gdk_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
- return_val = FALSE;
- }
-
- break;
-
- case GraphicsExpose:
- {
- GdkRectangle expose_rect;
-
- GDK_NOTE (EVENTS,
- g_message ("graphics expose:\tdrawable: %ld",
- xevent->xgraphicsexpose.drawable));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- expose_rect.x = xevent->xgraphicsexpose.x;
- expose_rect.y = xevent->xgraphicsexpose.y;
- expose_rect.width = xevent->xgraphicsexpose.width;
- expose_rect.height = xevent->xgraphicsexpose.height;
-
- _gdk_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
- return_val = FALSE;
- }
- break;
-
- case NoExpose:
- GDK_NOTE (EVENTS,
- g_message ("no expose:\t\tdrawable: %ld",
- xevent->xnoexpose.drawable));
-
- event->no_expose.type = GDK_NO_EXPOSE;
- event->no_expose.window = window;
-
- break;
-
- case VisibilityNotify:
-#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
- switch (xevent->xvisibility.state)
- {
- case VisibilityFullyObscured:
- g_message ("visibility notify:\twindow: %ld none",
- xevent->xvisibility.window);
- break;
- case VisibilityPartiallyObscured:
- g_message ("visibility notify:\twindow: %ld partial",
- xevent->xvisibility.window);
- break;
- case VisibilityUnobscured:
- g_message ("visibility notify:\twindow: %ld full",
- xevent->xvisibility.window);
- break;
- }
-#endif /* G_ENABLE_DEBUG */
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- event->visibility.type = GDK_VISIBILITY_NOTIFY;
- event->visibility.window = window;
-
- switch (xevent->xvisibility.state)
- {
- case VisibilityFullyObscured:
- event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
- break;
-
- case VisibilityPartiallyObscured:
- event->visibility.state = GDK_VISIBILITY_PARTIAL;
- break;
-
- case VisibilityUnobscured:
- event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
- break;
- }
-
- break;
-
- case CreateNotify:
- GDK_NOTE (EVENTS,
- g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
- xevent->xcreatewindow.window,
- xevent->xcreatewindow.x,
- xevent->xcreatewindow.y,
- xevent->xcreatewindow.width,
- xevent->xcreatewindow.height,
- xevent->xcreatewindow.border_width,
- xevent->xcreatewindow.parent,
- xevent->xcreatewindow.override_redirect));
- /* not really handled */
- break;
-
- case DestroyNotify:
- GDK_NOTE (EVENTS,
- g_message ("destroy notify:\twindow: %ld",
- xevent->xdestroywindow.window));
-
- /* Ignore DestroyNotify from SubstructureNotifyMask */
- if (xevent->xdestroywindow.window == xevent->xdestroywindow.event)
- {
- event->any.type = GDK_DESTROY;
- event->any.window = window;
-
- return_val = window_private && !GDK_WINDOW_DESTROYED (window);
-
- if (window && GDK_WINDOW_XID (window) != screen_x11->xroot_window)
- gdk_window_destroy_notify (window);
- }
- else
- return_val = FALSE;
-
- break;
-
- case UnmapNotify:
- GDK_NOTE (EVENTS,
- g_message ("unmap notify:\t\twindow: %ld",
- xevent->xmap.window));
-
- event->any.type = GDK_UNMAP;
- event->any.window = window;
-
- /* If we are shown (not withdrawn) and get an unmap, it means we
- * were iconified in the X sense. If we are withdrawn, and get
- * an unmap, it means we hid the window ourselves, so we
- * will have already flipped the iconified bit off.
- */
- if (window)
- {
- if (GDK_WINDOW_IS_MAPPED (window))
- gdk_synthesize_window_state (window,
- 0,
- GDK_WINDOW_STATE_ICONIFIED);
-
- _gdk_xgrab_check_unmap (window, xevent->xany.serial);
- }
-
- break;
-
- case MapNotify:
- GDK_NOTE (EVENTS,
- g_message ("map notify:\t\twindow: %ld",
- xevent->xmap.window));
-
- event->any.type = GDK_MAP;
- event->any.window = window;
-
- /* Unset iconified if it was set */
- if (window && (((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_ICONIFIED))
- gdk_synthesize_window_state (window,
- GDK_WINDOW_STATE_ICONIFIED,
- 0);
-
- break;
-
- case ReparentNotify:
- GDK_NOTE (EVENTS,
- g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
- xevent->xreparent.window,
- xevent->xreparent.x,
- xevent->xreparent.y,
- xevent->xreparent.parent,
- xevent->xreparent.override_redirect));
-
- /* Not currently handled */
- return_val = FALSE;
- break;
-
- case ConfigureNotify:
- GDK_NOTE (EVENTS,
- g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
- xevent->xconfigure.window,
- xevent->xconfigure.x,
- xevent->xconfigure.y,
- xevent->xconfigure.width,
- xevent->xconfigure.height,
- xevent->xconfigure.border_width,
- xevent->xconfigure.above,
- xevent->xconfigure.override_redirect,
- !window
- ? " (discarding)"
- : GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD
- ? " (discarding child)"
- : xevent->xconfigure.event != xevent->xconfigure.window
- ? " (discarding substructure)"
- : ""));
- if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
- {
- window_private->width = xevent->xconfigure.width;
- window_private->height = xevent->xconfigure.height;
-
- _gdk_window_update_size (window);
- _gdk_x11_drawable_update_size (window_private->impl);
- _gdk_x11_screen_size_changed (screen, xevent);
- }
-
-#ifdef HAVE_XSYNC
- if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
- {
- toplevel->current_counter_value = toplevel->pending_counter_value;
- XSyncIntToValue (&toplevel->pending_counter_value, 0);
- }
-#endif
-
- if (!window ||
- xevent->xconfigure.event != xevent->xconfigure.window ||
- GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ||
- GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
- return_val = FALSE;
- else
- {
- event->configure.type = GDK_CONFIGURE;
- event->configure.window = window;
- event->configure.width = xevent->xconfigure.width;
- event->configure.height = xevent->xconfigure.height;
-
- if (!xevent->xconfigure.send_event &&
- !xevent->xconfigure.override_redirect &&
- !GDK_WINDOW_DESTROYED (window))
- {
- gint tx = 0;
- gint ty = 0;
- Window child_window = 0;
-
- gdk_error_trap_push ();
- if (XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window),
- GDK_DRAWABLE_XID (window),
- screen_x11->xroot_window,
- 0, 0,
- &tx, &ty,
- &child_window))
- {
- event->configure.x = tx;
- event->configure.y = ty;
- }
- gdk_error_trap_pop_ignored ();
- }
- else
- {
- event->configure.x = xevent->xconfigure.x;
- event->configure.y = xevent->xconfigure.y;
- }
- window_private->x = event->configure.x;
- window_private->y = event->configure.y;
- window_private->width = xevent->xconfigure.width;
- window_private->height = xevent->xconfigure.height;
-
- _gdk_window_update_size (window);
- _gdk_x11_drawable_update_size (window_private->impl);
-
- if (window_private->resize_count >= 1)
- {
- window_private->resize_count -= 1;
-
- if (window_private->resize_count == 0)
- _gdk_moveresize_configure_done (display, window);
- }
- }
- break;
-
- case PropertyNotify:
- GDK_NOTE (EVENTS,
- g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
- xevent->xproperty.window,
- xevent->xproperty.atom,
- "\"",
- gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom),
- "\""));
-
- if (window_private == NULL)
- {
- return_val = FALSE;
- break;
- }
-
- /* We compare with the serial of the last time we mapped the
- * window to avoid refetching properties that we set ourselves
- */
- if (toplevel &&
- xevent->xproperty.serial >= toplevel->map_serial)
- {
- if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"))
- gdk_check_wm_state_changed (window);
-
- if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"))
- gdk_check_wm_desktop_changed (window);
- }
-
- if (window_private->event_mask & GDK_PROPERTY_CHANGE_MASK)
- {
- event->property.type = GDK_PROPERTY_NOTIFY;
- event->property.window = window;
- event->property.atom = gdk_x11_xatom_to_atom_for_display (display, xevent->xproperty.atom);
- event->property.time = xevent->xproperty.time;
- event->property.state = xevent->xproperty.state;
- }
- else
- return_val = FALSE;
-
- break;
-
- case SelectionClear:
- GDK_NOTE (EVENTS,
- g_message ("selection clear:\twindow: %ld",
- xevent->xproperty.window));
-
- if (_gdk_selection_filter_clear_event (&xevent->xselectionclear))
- {
- event->selection.type = GDK_SELECTION_CLEAR;
- event->selection.window = window;
- event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionclear.selection);
- event->selection.time = xevent->xselectionclear.time;
- }
- else
- return_val = FALSE;
-
- break;
-
- case SelectionRequest:
- GDK_NOTE (EVENTS,
- g_message ("selection request:\twindow: %ld",
- xevent->xproperty.window));
-
- event->selection.type = GDK_SELECTION_REQUEST;
- event->selection.window = window;
- event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection);
- event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target);
- event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property);
- event->selection.requestor = xevent->xselectionrequest.requestor;
- event->selection.time = xevent->xselectionrequest.time;
-
- break;
-
- case SelectionNotify:
- GDK_NOTE (EVENTS,
- g_message ("selection notify:\twindow: %ld",
- xevent->xproperty.window));
-
- event->selection.type = GDK_SELECTION_NOTIFY;
- event->selection.window = window;
- event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.selection);
- event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.target);
- if (xevent->xselection.property == None)
- event->selection.property = GDK_NONE;
- else
- event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.property);
- event->selection.time = xevent->xselection.time;
-
- break;
-
- case ColormapNotify:
- GDK_NOTE (EVENTS,
- g_message ("colormap notify:\twindow: %ld",
- xevent->xcolormap.window));
-
- /* Not currently handled */
- return_val = FALSE;
- break;
-
- case ClientMessage:
- {
- GList *tmp_list;
- GdkFilterReturn result = GDK_FILTER_CONTINUE;
- GdkAtom message_type = gdk_x11_xatom_to_atom_for_display (display, xevent->xclient.message_type);
-
- GDK_NOTE (EVENTS,
- g_message ("client message:\twindow: %ld",
- xevent->xclient.window));
-
- tmp_list = display_x11->client_filters;
- while (tmp_list)
- {
- GdkClientFilter *filter = tmp_list->data;
- tmp_list = tmp_list->next;
-
- if (filter->type == message_type)
- {
- result = (*filter->function) (xevent, event, filter->data);
- if (result != GDK_FILTER_CONTINUE)
- break;
- }
- }
-
- switch (result)
- {
- case GDK_FILTER_REMOVE:
- return_val = FALSE;
- break;
- case GDK_FILTER_TRANSLATE:
- return_val = TRUE;
- break;
- case GDK_FILTER_CONTINUE:
- /* Send unknown ClientMessage's on to Gtk for it to use */
- if (window_private == NULL)
- {
- return_val = FALSE;
- }
- else
- {
- event->client.type = GDK_CLIENT_EVENT;
- event->client.window = window;
- event->client.message_type = message_type;
- event->client.data_format = xevent->xclient.format;
- memcpy(&event->client.data, &xevent->xclient.data,
- sizeof(event->client.data));
- }
- break;
- }
- }
-
- break;
-
- case MappingNotify:
- GDK_NOTE (EVENTS,
- g_message ("mapping notify"));
-
- /* Let XLib know that there is a new keyboard mapping.
- */
- XRefreshKeyboardMapping (&xevent->xmapping);
- _gdk_keymap_keys_changed (display);
- return_val = FALSE;
- break;
-
- default:
-#ifdef HAVE_XFIXES
- if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify)
- {
- XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
-
- _gdk_x11_screen_process_owner_change (screen, xevent);
-
- event->owner_change.type = GDK_OWNER_CHANGE;
- event->owner_change.window = window;
- event->owner_change.owner = selection_notify->owner;
- event->owner_change.reason = selection_notify->subtype;
- event->owner_change.selection =
- gdk_x11_xatom_to_atom_for_display (display,
- selection_notify->selection);
- event->owner_change.time = selection_notify->timestamp;
- event->owner_change.selection_time = selection_notify->selection_timestamp;
-
- return_val = TRUE;
- }
- else
-#endif
-#ifdef HAVE_RANDR
- if (xevent->type - display_x11->xrandr_event_base == RRScreenChangeNotify ||
- xevent->type - display_x11->xrandr_event_base == RRNotify)
- {
- if (screen)
- _gdk_x11_screen_size_changed (screen, xevent);
- }
- else
-#endif
-#if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
- if (display_x11->have_xdamage && window_private && window_private->composited &&
- xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
- ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
- {
- XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
- XserverRegion repair;
- GdkRectangle rect;
-
- rect.x = window_private->x + damage_event->area.x;
- rect.y = window_private->y + damage_event->area.y;
- rect.width = damage_event->area.width;
- rect.height = damage_event->area.height;
-
- repair = XFixesCreateRegion (display_x11->xdisplay,
- &damage_event->area, 1);
- XDamageSubtract (display_x11->xdisplay,
- window_impl->damage,
- repair, None);
- XFixesDestroyRegion (display_x11->xdisplay, repair);
-
- if (window_private->parent != NULL)
- _gdk_window_process_expose (GDK_WINDOW (window_private->parent),
- damage_event->serial, &rect);
-
- return_val = TRUE;
- }
- else
-#endif
-#ifdef HAVE_XKB
- if (xevent->type == display_x11->xkb_event_type)
- {
- XkbEvent *xkb_event = (XkbEvent *) xevent;
-
- switch (xkb_event->any.xkb_type)
- {
- case XkbNewKeyboardNotify:
- case XkbMapNotify:
- _gdk_keymap_keys_changed (display);
-
- return_val = FALSE;
- break;
-
- case XkbStateNotify:
- _gdk_keymap_state_changed (display, xevent);
- break;
- }
- }
- else
-#endif
- return_val = FALSE;
- }
-
- done:
- if (return_val)
- {
- if (event->any.window)
- g_object_ref (event->any.window);
- }
- else
- {
- /* Mark this event as having no resources to be freed */
- event->any.window = NULL;
- event->any.type = GDK_NOTHING;
- }
-
- if (window)
- g_object_unref (window);
-
- return return_val;
-}
static GdkFilterReturn
gdk_wm_protocols_filter (GdkXEvent *xev,
@@ -1114,18 +417,10 @@ static void
_gdk_event_init (GdkDisplay *display)
{
GdkDisplayX11 *display_x11;
- GdkDeviceManager *device_manager;
display_x11 = GDK_DISPLAY_X11 (display);
display_x11->event_source = gdk_event_source_new (display);
- gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
- GDK_EVENT_TRANSLATOR (display));
-
- device_manager = gdk_display_get_device_manager (display);
- gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
- GDK_EVENT_TRANSLATOR (device_manager));
-
gdk_display_add_client_message_filter (display,
gdk_atom_intern_static_string ("WM_PROTOCOLS"),
gdk_wm_protocols_filter,
diff --git a/gdk/broadway/gdkeventsource.c b/gdk/broadway/gdkeventsource.c
index f3b850e..5b8c9fe 100644
--- a/gdk/broadway/gdkeventsource.c
+++ b/gdk/broadway/gdkeventsource.c
@@ -42,7 +42,6 @@ struct _GdkEventSource
GdkDisplay *display;
GPollFD event_poll_fd;
- GList *translators;
};
static GSourceFuncs event_funcs = {
@@ -133,7 +132,6 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
XEvent *xevent)
{
GdkEvent *event = gdk_event_new (GDK_NOTHING);
- GList *list = event_source->translators;
GdkFilterReturn result;
GdkWindow *filter_window;
@@ -182,16 +180,6 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
gdk_event_free (event);
event = NULL;
- while (list && !event)
- {
- GdkEventTranslator *translator = list->data;
-
- list = list->next;
- event = gdk_event_translator_translate (translator,
- event_source->display,
- xevent);
- }
-
if (event &&
(event->type == GDK_ENTER_NOTIFY ||
event->type == GDK_LEAVE_NOTIFY) &&
@@ -315,9 +303,6 @@ gdk_event_source_finalize (GSource *source)
{
GdkEventSource *event_source = (GdkEventSource *)source;
- g_list_free (event_source->translators);
- event_source->translators = NULL;
-
event_sources = g_list_remove (event_sources, source);
}
@@ -355,43 +340,14 @@ gdk_event_source_new (GdkDisplay *display)
}
void
-gdk_event_source_add_translator (GdkEventSource *source,
- GdkEventTranslator *translator)
-{
- g_return_if_fail (GDK_IS_EVENT_TRANSLATOR (translator));
-
- source->translators = g_list_append (source->translators, translator);
-}
-
-void
gdk_event_source_select_events (GdkEventSource *source,
Window window,
GdkEventMask event_mask,
unsigned int extra_x_mask)
{
unsigned int xmask = extra_x_mask;
- GList *list;
gint i;
- list = source->translators;
-
- while (list)
- {
- GdkEventTranslator *translator = list->data;
- GdkEventMask translator_mask, mask;
-
- translator_mask = gdk_event_translator_get_handled_events (translator);
- mask = event_mask & translator_mask;
-
- if (mask != 0)
- {
- gdk_event_translator_select_window_events (translator, window, mask);
- event_mask &= ~mask;
- }
-
- list = list->next;
- }
-
for (i = 0; i < _gdk_nenvent_masks; i++)
{
if (event_mask & (1 << (i + 1)))
diff --git a/gdk/broadway/gdkeventsource.h b/gdk/broadway/gdkeventsource.h
index 424338c..4ef6755 100644
--- a/gdk/broadway/gdkeventsource.h
+++ b/gdk/broadway/gdkeventsource.h
@@ -20,7 +20,6 @@
#ifndef __GDK_EVENT_SOURCE_H__
#define __GDK_EVENT_SOURCE_H__
-#include "gdkeventtranslator.h"
#include "gdkprivate-broadway.h"
G_BEGIN_DECLS
@@ -31,10 +30,6 @@ G_GNUC_INTERNAL
GSource * gdk_event_source_new (GdkDisplay *display);
G_GNUC_INTERNAL
-void gdk_event_source_add_translator (GdkEventSource *source,
- GdkEventTranslator *translator);
-
-G_GNUC_INTERNAL
void gdk_event_source_select_events (GdkEventSource *source,
Window window,
GdkEventMask event_mask,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]