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