]> Pileus Git - ~andy/gtk/blob - gdk/gdkdisplayprivate.h
gdk: Remove GdkEventClient
[~andy/gtk] / gdk / gdkdisplayprivate.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 2010 Red Hat, Inc.
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GDK_DISPLAY_PRIVATE_H__
21 #define __GDK_DISPLAY_PRIVATE_H__
22
23 #include "gdkdisplay.h"
24 #include "gdkwindow.h"
25 #include "gdkcursor.h"
26
27 G_BEGIN_DECLS
28
29 #define GDK_DISPLAY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass))
30 #define GDK_IS_DISPLAY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY))
31 #define GDK_DISPLAY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass))
32
33
34 typedef struct _GdkDisplayClass GdkDisplayClass;
35
36 /* Tracks information about the keyboard grab on this display */
37 typedef struct
38 {
39   GdkWindow *window;
40   GdkWindow *native_window;
41   gulong serial;
42   gboolean owner_events;
43   guint32 time;
44 } GdkKeyboardGrabInfo;
45
46 /* Tracks information about the pointer grab on this display */
47 typedef struct
48 {
49   GdkWindow *window;
50   GdkWindow *native_window;
51   gulong serial_start;
52   gulong serial_end; /* exclusive, i.e. not active on serial_end */
53   gboolean owner_events;
54   guint event_mask;
55   gboolean implicit;
56   guint32 time;
57   GdkGrabOwnership ownership;
58
59   guint activated : 1;
60   guint implicit_ungrab : 1;
61 } GdkDeviceGrabInfo;
62
63 /* Tracks information about which window and position the pointer last was in.
64  * This is useful when we need to synthesize events later.
65  * Note that we track toplevel_under_pointer using enter/leave events,
66  * so in the case of a grab, either with owner_events==FALSE or with the
67  * pointer in no clients window the x/y coordinates may actually be outside
68  * the window.
69  */
70 typedef struct
71 {
72   GdkWindow *toplevel_under_pointer; /* toplevel window containing the pointer, */
73                                      /* tracked via native events */
74   GdkWindow *window_under_pointer;   /* window that last got a normal enter event */
75   gdouble toplevel_x, toplevel_y;
76   guint32 state;
77   guint32 button;
78 } GdkPointerWindowInfo;
79
80 typedef struct
81 {
82   guint32 button_click_time[2]; /* last 2 button click times */
83   GdkWindow *button_window[2];  /* last 2 windows to receive button presses */
84   gint button_number[2];        /* last 2 buttons to be pressed */
85   gint button_x[2];             /* last 2 button click positions */
86   gint button_y[2];
87 } GdkMultipleClickInfo;
88
89 struct _GdkDisplay
90 {
91   GObject parent_instance;
92
93   GList *queued_events;
94   GList *queued_tail;
95
96   /* Information for determining if the latest button click
97    * is part of a double-click or triple-click
98    */
99   GHashTable *multiple_click_info;
100   guint double_click_time;  /* Maximum time between clicks in msecs */
101   GdkDevice *core_pointer;  /* Core pointer device */
102
103   guint closed             : 1;  /* Whether this display has been closed */
104   guint ignore_core_events : 1;  /* Don't send core motion and button event */
105
106   guint double_click_distance;   /* Maximum distance between clicks in pixels */
107
108   GHashTable *device_grabs;
109   GHashTable *motion_hint_info;
110
111   GHashTable *pointers_info;  /* GdkPointerWindowInfo for each device */
112   guint32 last_event_time;    /* Last reported event time from server */
113
114   GdkDeviceManager *device_manager;
115 };
116
117 struct _GdkDisplayClass
118 {
119   GObjectClass parent_class;
120
121   GType window_type;          /* type for native windows for this display, set in class_init */
122
123   G_CONST_RETURN gchar *     (*get_name)           (GdkDisplay *display);
124   gint                       (*get_n_screens)      (GdkDisplay *display);
125   GdkScreen *                (*get_screen)         (GdkDisplay *display,
126                                                     gint        screen_num);
127   GdkScreen *                (*get_default_screen) (GdkDisplay *display);
128   void                       (*beep)               (GdkDisplay *display);
129   void                       (*sync)               (GdkDisplay *display);
130   void                       (*flush)              (GdkDisplay *display);
131   gboolean                   (*has_pending)        (GdkDisplay *display);
132   void                       (*queue_events)       (GdkDisplay *display);
133   GdkWindow *                (*get_default_group)  (GdkDisplay *display);
134   gboolean                   (*supports_selection_notification) (GdkDisplay *display);
135   gboolean                   (*request_selection_notification)  (GdkDisplay *display,
136                                                                  GdkAtom     selection);
137   gboolean                   (*supports_shapes)       (GdkDisplay *display);
138   gboolean                   (*supports_input_shapes) (GdkDisplay *display);
139   gboolean                   (*supports_composite)    (GdkDisplay *display);
140   gboolean                   (*supports_cursor_alpha) (GdkDisplay *display);
141   gboolean                   (*supports_cursor_color) (GdkDisplay *display);
142
143   gboolean                   (*supports_clipboard_persistence)  (GdkDisplay *display);
144   void                       (*store_clipboard)    (GdkDisplay    *display,
145                                                     GdkWindow     *clipboard_window,
146                                                     guint32        time_,
147                                                     const GdkAtom *targets,
148                                                     gint           n_targets);
149
150   void                       (*get_default_cursor_size) (GdkDisplay *display,
151                                                          guint      *width,
152                                                          guint      *height);
153   void                       (*get_maximal_cursor_size) (GdkDisplay *display,
154                                                          guint      *width,
155                                                          guint      *height);
156   GdkCursor *                (*get_cursor_for_type)     (GdkDisplay    *display,
157                                                          GdkCursorType  type);
158   GdkCursor *                (*get_cursor_for_name)     (GdkDisplay    *display,
159                                                          const gchar   *name);
160   GdkCursor *                (*get_cursor_for_pixbuf)   (GdkDisplay    *display,
161                                                          GdkPixbuf     *pixbuf,
162                                                          gint           x,
163                                                          gint           y);
164
165   GList *                    (*list_devices)       (GdkDisplay *display);
166   GdkAppLaunchContext *      (*get_app_launch_context) (GdkDisplay *display);
167   GdkNativeWindow            (*get_drag_protocol)      (GdkDisplay      *display,
168                                                         GdkNativeWindow  winid,
169                                                         GdkDragProtocol *protocol,
170                                                         guint           *version);
171
172   void                       (*before_process_all_updates) (GdkDisplay *display);
173   void                       (*after_process_all_updates)  (GdkDisplay *display);
174
175   gulong                     (*get_next_serial) (GdkDisplay *display);
176
177   void                       (*notify_startup_complete) (GdkDisplay  *display,
178                                                          const gchar *startup_id);
179   void                       (*event_data_copy) (GdkDisplay     *display,
180                                                  const GdkEvent *event,
181                                                  GdkEvent       *new_event);
182   void                       (*event_data_free) (GdkDisplay     *display,
183                                                  GdkEvent       *event);
184   void                       (*create_window_impl) (GdkDisplay    *display,
185                                                     GdkWindow     *window,
186                                                     GdkWindow     *real_parent,
187                                                     GdkScreen     *screen,
188                                                     GdkEventMask   event_mask,
189                                                     GdkWindowAttr *attributes,
190                                                     gint           attributes_mask);
191
192   GdkKeymap *                (*get_keymap)         (GdkDisplay    *display);
193   void                       (*push_error_trap)    (GdkDisplay    *display);
194   gint                       (*pop_error_trap)     (GdkDisplay    *display,
195                                                     gboolean       ignore);
196
197   GdkWindow *                (*get_selection_owner) (GdkDisplay   *display,
198                                                      GdkAtom       selection);
199   gboolean                   (*set_selection_owner) (GdkDisplay   *display,
200                                                      GdkWindow    *owner,
201                                                      GdkAtom       selection,
202                                                      guint32       time,
203                                                      gboolean      send_event);
204   void                       (*send_selection_notify) (GdkDisplay *dispay,
205                                                        GdkNativeWindow  requestor,
206                                                        GdkAtom          selection,
207                                                        GdkAtom          target,
208                                                        GdkAtom          property,
209                                                        guint32          time);
210   gint                       (*get_selection_property) (GdkDisplay  *display,
211                                                         GdkWindow   *requestor,
212                                                         guchar     **data,
213                                                         GdkAtom     *type,
214                                                         gint        *format);
215   void                       (*convert_selection)      (GdkDisplay  *display,
216                                                         GdkWindow   *requestor,
217                                                         GdkAtom      selection,
218                                                         GdkAtom      target,
219                                                         guint32      time);
220
221   gint                   (*text_property_to_utf8_list) (GdkDisplay     *display,
222                                                         GdkAtom         encoding,
223                                                         gint            format,
224                                                         const guchar   *text,
225                                                         gint            length,
226                                                         gchar        ***list);
227   gchar *                (*utf8_to_string_target)      (GdkDisplay     *display,
228                                                         const gchar    *text);
229
230   /* Signals */
231   void (*closed) (GdkDisplay *display,
232                   gboolean    is_error);
233 };
234
235
236 typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay           *display,
237                                                GdkDevice            *device,
238                                                GdkPointerWindowInfo *device_info,
239                                                gpointer              user_data);
240
241 void                _gdk_display_device_grab_update   (GdkDisplay *display,
242                                                        GdkDevice  *device,
243                                                        GdkDevice  *source_device,
244                                                        gulong      current_serial);
245 GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display,
246                                                        GdkDevice  *device);
247 GdkDeviceGrabInfo * _gdk_display_add_device_grab      (GdkDisplay       *display,
248                                                        GdkDevice        *device,
249                                                        GdkWindow        *window,
250                                                        GdkWindow        *native_window,
251                                                        GdkGrabOwnership  grab_ownership,
252                                                        gboolean          owner_events,
253                                                        GdkEventMask      event_mask,
254                                                        gulong            serial_start,
255                                                        guint32           time,
256                                                        gboolean          implicit);
257 GdkDeviceGrabInfo * _gdk_display_has_device_grab      (GdkDisplay       *display,
258                                                        GdkDevice        *device,
259                                                        gulong            serial);
260 gboolean            _gdk_display_end_device_grab      (GdkDisplay       *display,
261                                                        GdkDevice        *device,
262                                                        gulong            serial,
263                                                        GdkWindow        *if_child,
264                                                        gboolean          implicit);
265 gboolean            _gdk_display_check_grab_ownership (GdkDisplay       *display,
266                                                        GdkDevice        *device,
267                                                        gulong            serial);
268 void                _gdk_display_enable_motion_hints  (GdkDisplay       *display,
269                                                        GdkDevice        *device);
270 GdkPointerWindowInfo * _gdk_display_get_pointer_info  (GdkDisplay       *display,
271                                                        GdkDevice        *device);
272 void                _gdk_display_pointer_info_foreach (GdkDisplay       *display,
273                                                        GdkDisplayPointerInfoForeach func,
274                                                        gpointer          user_data);
275 gulong              _gdk_display_get_next_serial      (GdkDisplay       *display);
276 void                _gdk_display_event_data_copy      (GdkDisplay       *display,
277                                                        const GdkEvent   *event,
278                                                        GdkEvent         *new_event);
279 void                _gdk_display_event_data_free      (GdkDisplay       *display,
280                                                        GdkEvent         *event);
281 void                _gdk_display_create_window_impl   (GdkDisplay       *display,
282                                                        GdkWindow        *window,
283                                                        GdkWindow        *real_parent,
284                                                        GdkScreen        *screen,
285                                                        GdkEventMask      event_mask,
286                                                        GdkWindowAttr    *attributes,
287                                                        gint              attributes_mask);
288 GdkWindow *         _gdk_display_create_window        (GdkDisplay       *display);
289
290 G_END_DECLS
291
292 #endif  /* __GDK_DISPLAY_PRIVATE_H__ */