]> Pileus Git - ~andy/gtk/blob - gdk/gdkdisplayprivate.h
gdk: Use const instead G_CONST_RETURN
[~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   guint event_mask;
54   guint32 time;
55   GdkGrabOwnership ownership;
56
57   guint activated : 1;
58   guint implicit_ungrab : 1;
59   guint owner_events : 1;
60   guint implicit : 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   GHashTable *device_grabs;
107   GHashTable *motion_hint_info;
108   GdkDeviceManager *device_manager;
109
110   GHashTable *pointers_info;  /* GdkPointerWindowInfo for each device */
111   guint32 last_event_time;    /* Last reported event time from server */
112
113   guint double_click_distance;   /* Maximum distance between clicks in pixels */
114 };
115
116 struct _GdkDisplayClass
117 {
118   GObjectClass parent_class;
119
120   GType window_type;          /* type for native windows for this display, set in class_init */
121
122   const gchar *              (*get_name)           (GdkDisplay *display);
123   gint                       (*get_n_screens)      (GdkDisplay *display);
124   GdkScreen *                (*get_screen)         (GdkDisplay *display,
125                                                     gint        screen_num);
126   GdkScreen *                (*get_default_screen) (GdkDisplay *display);
127   void                       (*beep)               (GdkDisplay *display);
128   void                       (*sync)               (GdkDisplay *display);
129   void                       (*flush)              (GdkDisplay *display);
130   gboolean                   (*has_pending)        (GdkDisplay *display);
131   void                       (*queue_events)       (GdkDisplay *display);
132   GdkWindow *                (*get_default_group)  (GdkDisplay *display);
133   gboolean                   (*supports_selection_notification) (GdkDisplay *display);
134   gboolean                   (*request_selection_notification)  (GdkDisplay *display,
135                                                                  GdkAtom     selection);
136   gboolean                   (*supports_shapes)       (GdkDisplay *display);
137   gboolean                   (*supports_input_shapes) (GdkDisplay *display);
138   gboolean                   (*supports_composite)    (GdkDisplay *display);
139   gboolean                   (*supports_cursor_alpha) (GdkDisplay *display);
140   gboolean                   (*supports_cursor_color) (GdkDisplay *display);
141
142   gboolean                   (*supports_clipboard_persistence)  (GdkDisplay *display);
143   void                       (*store_clipboard)    (GdkDisplay    *display,
144                                                     GdkWindow     *clipboard_window,
145                                                     guint32        time_,
146                                                     const GdkAtom *targets,
147                                                     gint           n_targets);
148
149   void                       (*get_default_cursor_size) (GdkDisplay *display,
150                                                          guint      *width,
151                                                          guint      *height);
152   void                       (*get_maximal_cursor_size) (GdkDisplay *display,
153                                                          guint      *width,
154                                                          guint      *height);
155   GdkCursor *                (*get_cursor_for_type)     (GdkDisplay    *display,
156                                                          GdkCursorType  type);
157   GdkCursor *                (*get_cursor_for_name)     (GdkDisplay    *display,
158                                                          const gchar   *name);
159   GdkCursor *                (*get_cursor_for_pixbuf)   (GdkDisplay    *display,
160                                                          GdkPixbuf     *pixbuf,
161                                                          gint           x,
162                                                          gint           y);
163
164   GList *                    (*list_devices)       (GdkDisplay *display);
165   GdkAppLaunchContext *      (*get_app_launch_context) (GdkDisplay *display);
166
167   void                       (*before_process_all_updates) (GdkDisplay *display);
168   void                       (*after_process_all_updates)  (GdkDisplay *display);
169
170   gulong                     (*get_next_serial) (GdkDisplay *display);
171
172   void                       (*notify_startup_complete) (GdkDisplay  *display,
173                                                          const gchar *startup_id);
174   void                       (*event_data_copy) (GdkDisplay     *display,
175                                                  const GdkEvent *event,
176                                                  GdkEvent       *new_event);
177   void                       (*event_data_free) (GdkDisplay     *display,
178                                                  GdkEvent       *event);
179   void                       (*create_window_impl) (GdkDisplay    *display,
180                                                     GdkWindow     *window,
181                                                     GdkWindow     *real_parent,
182                                                     GdkScreen     *screen,
183                                                     GdkEventMask   event_mask,
184                                                     GdkWindowAttr *attributes,
185                                                     gint           attributes_mask);
186
187   GdkKeymap *                (*get_keymap)         (GdkDisplay    *display);
188   void                       (*push_error_trap)    (GdkDisplay    *display);
189   gint                       (*pop_error_trap)     (GdkDisplay    *display,
190                                                     gboolean       ignore);
191
192   GdkWindow *                (*get_selection_owner) (GdkDisplay   *display,
193                                                      GdkAtom       selection);
194   gboolean                   (*set_selection_owner) (GdkDisplay   *display,
195                                                      GdkWindow    *owner,
196                                                      GdkAtom       selection,
197                                                      guint32       time,
198                                                      gboolean      send_event);
199   void                       (*send_selection_notify) (GdkDisplay *dispay,
200                                                        GdkWindow        *requestor,
201                                                        GdkAtom          selection,
202                                                        GdkAtom          target,
203                                                        GdkAtom          property,
204                                                        guint32          time);
205   gint                       (*get_selection_property) (GdkDisplay  *display,
206                                                         GdkWindow   *requestor,
207                                                         guchar     **data,
208                                                         GdkAtom     *type,
209                                                         gint        *format);
210   void                       (*convert_selection)      (GdkDisplay  *display,
211                                                         GdkWindow   *requestor,
212                                                         GdkAtom      selection,
213                                                         GdkAtom      target,
214                                                         guint32      time);
215
216   gint                   (*text_property_to_utf8_list) (GdkDisplay     *display,
217                                                         GdkAtom         encoding,
218                                                         gint            format,
219                                                         const guchar   *text,
220                                                         gint            length,
221                                                         gchar        ***list);
222   gchar *                (*utf8_to_string_target)      (GdkDisplay     *display,
223                                                         const gchar    *text);
224
225   /* Signals */
226   void (*closed) (GdkDisplay *display,
227                   gboolean    is_error);
228 };
229
230
231 typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay           *display,
232                                                GdkDevice            *device,
233                                                GdkPointerWindowInfo *device_info,
234                                                gpointer              user_data);
235
236 void                _gdk_display_device_grab_update   (GdkDisplay *display,
237                                                        GdkDevice  *device,
238                                                        GdkDevice  *source_device,
239                                                        gulong      current_serial);
240 GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display,
241                                                        GdkDevice  *device);
242 GdkDeviceGrabInfo * _gdk_display_add_device_grab      (GdkDisplay       *display,
243                                                        GdkDevice        *device,
244                                                        GdkWindow        *window,
245                                                        GdkWindow        *native_window,
246                                                        GdkGrabOwnership  grab_ownership,
247                                                        gboolean          owner_events,
248                                                        GdkEventMask      event_mask,
249                                                        gulong            serial_start,
250                                                        guint32           time,
251                                                        gboolean          implicit);
252 GdkDeviceGrabInfo * _gdk_display_has_device_grab      (GdkDisplay       *display,
253                                                        GdkDevice        *device,
254                                                        gulong            serial);
255 gboolean            _gdk_display_end_device_grab      (GdkDisplay       *display,
256                                                        GdkDevice        *device,
257                                                        gulong            serial,
258                                                        GdkWindow        *if_child,
259                                                        gboolean          implicit);
260 gboolean            _gdk_display_check_grab_ownership (GdkDisplay       *display,
261                                                        GdkDevice        *device,
262                                                        gulong            serial);
263 void                _gdk_display_enable_motion_hints  (GdkDisplay       *display,
264                                                        GdkDevice        *device);
265 GdkPointerWindowInfo * _gdk_display_get_pointer_info  (GdkDisplay       *display,
266                                                        GdkDevice        *device);
267 void                _gdk_display_pointer_info_foreach (GdkDisplay       *display,
268                                                        GdkDisplayPointerInfoForeach func,
269                                                        gpointer          user_data);
270 gulong              _gdk_display_get_next_serial      (GdkDisplay       *display);
271 void                _gdk_display_event_data_copy      (GdkDisplay       *display,
272                                                        const GdkEvent   *event,
273                                                        GdkEvent         *new_event);
274 void                _gdk_display_event_data_free      (GdkDisplay       *display,
275                                                        GdkEvent         *event);
276 void                _gdk_display_create_window_impl   (GdkDisplay       *display,
277                                                        GdkWindow        *window,
278                                                        GdkWindow        *real_parent,
279                                                        GdkScreen        *screen,
280                                                        GdkEventMask      event_mask,
281                                                        GdkWindowAttr    *attributes,
282                                                        gint              attributes_mask);
283 GdkWindow *         _gdk_display_create_window        (GdkDisplay       *display);
284
285 G_END_DECLS
286
287 #endif  /* __GDK_DISPLAY_PRIVATE_H__ */