1 | /* GDK - The GIMP Drawing Kit |
2 | * Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #include "config.h" |
19 | |
20 | #include "gdkeventtranslator.h" |
21 | #include "gdksurface-x11.h" |
22 | |
23 | typedef GdkEventTranslatorIface GdkEventTranslatorInterface; |
24 | G_DEFINE_INTERFACE (GdkEventTranslator, _gdk_x11_event_translator, G_TYPE_OBJECT); |
25 | |
26 | |
27 | static void |
28 | _gdk_x11_event_translator_default_init (GdkEventTranslatorInterface *iface) |
29 | { |
30 | } |
31 | |
32 | |
33 | GdkEvent * |
34 | _gdk_x11_event_translator_translate (GdkEventTranslator *translator, |
35 | GdkDisplay *display, |
36 | const XEvent *xevent) |
37 | { |
38 | GdkEventTranslatorIface *iface; |
39 | |
40 | g_return_val_if_fail (GDK_IS_EVENT_TRANSLATOR (translator), NULL); |
41 | g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); |
42 | |
43 | iface = GDK_EVENT_TRANSLATOR_GET_IFACE (translator); |
44 | |
45 | if (!iface->translate_event) |
46 | return NULL; |
47 | |
48 | return (iface->translate_event) (translator, display, xevent); |
49 | } |
50 | |
51 | GdkEventMask |
52 | _gdk_x11_event_translator_get_handled_events (GdkEventTranslator *translator) |
53 | { |
54 | GdkEventTranslatorIface *iface; |
55 | |
56 | g_return_val_if_fail (GDK_IS_EVENT_TRANSLATOR (translator), 0); |
57 | |
58 | iface = GDK_EVENT_TRANSLATOR_GET_IFACE (translator); |
59 | |
60 | if (iface->get_handled_events) |
61 | return iface->get_handled_events (translator); |
62 | |
63 | return 0; |
64 | } |
65 | |
66 | void |
67 | _gdk_x11_event_translator_select_surface_events (GdkEventTranslator *translator, |
68 | Window window, |
69 | GdkEventMask event_mask) |
70 | { |
71 | GdkEventTranslatorIface *iface; |
72 | |
73 | g_return_if_fail (GDK_IS_EVENT_TRANSLATOR (translator)); |
74 | |
75 | iface = GDK_EVENT_TRANSLATOR_GET_IFACE (translator); |
76 | |
77 | if (iface->select_surface_events) |
78 | iface->select_surface_events (translator, window, event_mask); |
79 | } |
80 | |
81 | GdkSurface * |
82 | _gdk_x11_event_translator_get_surface (GdkEventTranslator *translator, |
83 | GdkDisplay *display, |
84 | const XEvent *xevent) |
85 | { |
86 | GdkEventTranslatorIface *iface; |
87 | |
88 | g_return_val_if_fail (GDK_IS_EVENT_TRANSLATOR (translator), NULL); |
89 | |
90 | iface = GDK_EVENT_TRANSLATOR_GET_IFACE (translator); |
91 | |
92 | if (iface->get_surface) |
93 | return iface->get_surface (translator, xevent); |
94 | |
95 | return NULL; |
96 | } |
97 | |