]> Pileus Git - ~andy/gtk/blob - gdk/gdkdisplay.h
docs: Move documentation to inline comments: gdkdisplay
[~andy/gtk] / gdk / gdkdisplay.h
1 /*
2  * gdkdisplay.h
3  * 
4  * Copyright 2001 Sun Microsystems Inc. 
5  *
6  * Erwann Chenede <erwann.chenede@sun.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
25 #error "Only <gdk/gdk.h> can be included directly."
26 #endif
27
28 #ifndef __GDK_DISPLAY_H__
29 #define __GDK_DISPLAY_H__
30
31 #include <gdk/gdktypes.h>
32 #include <gdk/gdkevents.h>
33 #include <gdk/gdkdevicemanager.h>
34
35 G_BEGIN_DECLS
36
37 typedef struct _GdkDisplayClass GdkDisplayClass;
38 typedef struct _GdkDisplayPointerHooks GdkDisplayPointerHooks;
39 typedef struct _GdkDisplayDeviceHooks GdkDisplayDeviceHooks;
40
41 #define GDK_TYPE_DISPLAY              (gdk_display_get_type ())
42 #define GDK_DISPLAY_OBJECT(object)    (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY, GdkDisplay))
43 #define GDK_DISPLAY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass))
44 #define GDK_IS_DISPLAY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY))
45 #define GDK_IS_DISPLAY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY))
46 #define GDK_DISPLAY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass))
47
48 /* Tracks information about the keyboard grab on this display */
49 typedef struct
50 {
51   GdkWindow *window;
52   GdkWindow *native_window;
53   gulong serial;
54   gboolean owner_events;
55   guint32 time;
56 } GdkKeyboardGrabInfo;
57
58 /* Tracks information about which window and position the pointer last was in.
59  * This is useful when we need to synthesize events later.
60  * Note that we track toplevel_under_pointer using enter/leave events,
61  * so in the case of a grab, either with owner_events==FALSE or with the
62  * pointer in no clients window the x/y coordinates may actually be outside
63  * the window.
64  */
65 typedef struct
66 {
67   GdkWindow *toplevel_under_pointer; /* The toplevel window with mouse inside, tracked via native events */
68   GdkWindow *window_under_pointer; /* The window that last got sent a normal enter event */
69   gdouble toplevel_x, toplevel_y; 
70   guint32 state;
71   guint32 button;
72 } GdkPointerWindowInfo;
73
74 typedef struct
75 {
76   guint32 button_click_time[2]; /* The last 2 button click times. */
77   GdkWindow *button_window[2];  /* The last 2 windows to receive button presses. */
78   gint button_number[2];        /* The last 2 buttons to be pressed. */
79   gint button_x[2];             /* The last 2 button click positions. */
80   gint button_y[2];
81 } GdkMultipleClickInfo;
82
83 struct _GdkDisplay
84 {
85   GObject parent_instance;
86
87   /*< private >*/
88   GList *GSEAL (queued_events);
89   GList *GSEAL (queued_tail);
90
91   /* Information for determining if the latest button click
92    * is part of a double-click or triple-click
93    */
94   GHashTable *GSEAL (multiple_click_info);
95
96   guint GSEAL (double_click_time);      /* Maximum time between clicks in msecs */
97   GdkDevice *GSEAL (core_pointer);      /* Core pointer device */
98
99   const GdkDisplayDeviceHooks *GSEAL (device_hooks); /* Current hooks for querying pointer */
100   
101   guint GSEAL (closed) : 1;             /* Whether this display has been closed */
102   guint GSEAL (ignore_core_events) : 1; /* Don't send core motion and button event */
103
104   guint GSEAL (double_click_distance);  /* Maximum distance between clicks in pixels */
105
106   GHashTable *GSEAL (device_grabs);
107   GHashTable *GSEAL (motion_hint_info);
108
109   /* Hashtable containing a GdkPointerWindowInfo for each device */
110   GHashTable *GSEAL (pointers_info);
111
112   /* Last reported event time from server */
113   guint32 GSEAL (last_event_time);
114
115   /* Device manager associated to the display */
116   GdkDeviceManager *GSEAL (device_manager);
117 };
118
119 struct _GdkDisplayClass
120 {
121   GObjectClass parent_class;
122   
123   G_CONST_RETURN gchar *     (*get_display_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
129   
130   /* Signals */
131   void (*closed) (GdkDisplay *display,
132                   gboolean    is_error);
133 };
134
135 /**
136  * GdkDisplayPointerHooks:
137  * @get_pointer: Obtains the current pointer position and modifier state.
138  *  The position is given in coordinates relative to the screen containing
139  *  the pointer, which is returned in @screen.
140  * @window_get_pointer: Obtains the window underneath the mouse pointer.
141  *  Current pointer position and modifier state are returned in @x, @y and
142  *  @mask. The position is given in coordinates relative to @window.
143  * @window_at_pointer: Obtains the window underneath the mouse pointer,
144  *  returning the location of that window in @win_x, @win_y. Returns %NULL
145  *  if the window under the mouse pointer is not known to GDK (for example,
146  *  belongs to another application).
147  *
148  * A table of pointers to functions for getting quantities related to
149  * the current pointer position. Each #GdkDisplay has a table of this type,
150  * which can be set using gdk_display_set_pointer_hooks().
151  *
152  * This is only useful for such low-level tools as an event recorder.
153  * Applications should never have any reason to use this facility
154  *
155  * Since: 2.2
156  */
157 struct _GdkDisplayPointerHooks
158 {
159   void (*get_pointer)              (GdkDisplay      *display,
160                                     GdkScreen      **screen,
161                                     gint            *x,
162                                     gint            *y,
163                                     GdkModifierType *mask);
164   GdkWindow* (*window_get_pointer) (GdkDisplay      *display,
165                                     GdkWindow       *window,
166                                     gint            *x,
167                                     gint            *y,
168                                     GdkModifierType *mask);
169   GdkWindow* (*window_at_pointer)  (GdkDisplay      *display,
170                                     gint            *win_x,
171                                     gint            *win_y);
172 };
173
174 /**
175  * GdkDisplayDeviceHooks:
176  * @get_device_state: Obtains the current position and modifier state for
177  * @device. The position is given in coordinates relative to the window
178  * containing the pointer, which is returned in @window.
179  * @window_get_device_position: Obtains the window underneath the device
180  * position. Current device position and modifier state are returned in
181  * @x, @y and @mask. The position is given in coordinates relative to
182  * @window.
183  * @window_at_device_position: Obtains the window underneath the device
184  * position, returning the location of that window in @win_x, @win_y.
185  * Returns %NULL if the window under the mouse pointer is not known to
186  * GDK (for example, belongs to another application).
187  *
188  * A table of pointers to functions for getting quantities related to
189  * the current device position. Each #GdkDisplay has a table of this type,
190  * which can be set using gdk_display_set_device_hooks().
191  */
192 struct _GdkDisplayDeviceHooks
193 {
194   void (* get_device_state)                  (GdkDisplay       *display,
195                                               GdkDevice        *device,
196                                               GdkScreen       **screen,
197                                               gint             *x,
198                                               gint             *y,
199                                               GdkModifierType  *mask);
200   GdkWindow * (* window_get_device_position) (GdkDisplay      *display,
201                                               GdkDevice       *device,
202                                               GdkWindow       *window,
203                                               gint            *x,
204                                               gint            *y,
205                                               GdkModifierType *mask);
206   GdkWindow * (* window_at_device_position)  (GdkDisplay *display,
207                                               GdkDevice  *device,
208                                               gint       *win_x,
209                                               gint       *win_y);
210 };
211
212 GType       gdk_display_get_type (void) G_GNUC_CONST;
213 GdkDisplay *gdk_display_open                (const gchar *display_name);
214
215 G_CONST_RETURN gchar * gdk_display_get_name (GdkDisplay *display);
216
217 gint        gdk_display_get_n_screens      (GdkDisplay  *display);
218 GdkScreen * gdk_display_get_screen         (GdkDisplay  *display,
219                                             gint         screen_num);
220 GdkScreen * gdk_display_get_default_screen (GdkDisplay  *display);
221
222 #ifndef GDK_MULTIDEVICE_SAFE
223 void        gdk_display_pointer_ungrab     (GdkDisplay  *display,
224                                             guint32      time_);
225 void        gdk_display_keyboard_ungrab    (GdkDisplay  *display,
226                                             guint32      time_);
227 gboolean    gdk_display_pointer_is_grabbed (GdkDisplay  *display);
228 #endif /* GDK_MULTIDEVICE_SAFE */
229
230 gboolean    gdk_display_device_is_grabbed  (GdkDisplay  *display,
231                                             GdkDevice   *device);
232 void        gdk_display_beep               (GdkDisplay  *display);
233 void        gdk_display_sync               (GdkDisplay  *display);
234 void        gdk_display_flush              (GdkDisplay  *display);
235
236 void        gdk_display_close                  (GdkDisplay  *display);
237 gboolean    gdk_display_is_closed          (GdkDisplay  *display);
238
239 #ifndef GDK_DISABLE_DEPRECATED
240 GList *     gdk_display_list_devices       (GdkDisplay  *display);
241 #endif /* GDK_DISABLE_DEPRECATED */
242
243 GdkEvent* gdk_display_get_event  (GdkDisplay     *display);
244 GdkEvent* gdk_display_peek_event (GdkDisplay     *display);
245 void      gdk_display_put_event  (GdkDisplay     *display,
246                                   const GdkEvent *event);
247
248 void gdk_display_add_client_message_filter (GdkDisplay   *display,
249                                             GdkAtom       message_type,
250                                             GdkFilterFunc func,
251                                             gpointer      data);
252
253 void gdk_display_set_double_click_time     (GdkDisplay   *display,
254                                             guint         msec);
255 void gdk_display_set_double_click_distance (GdkDisplay   *display,
256                                             guint         distance);
257
258 GdkDisplay *gdk_display_get_default (void);
259
260 #ifndef GDK_MULTIDEVICE_SAFE
261
262 #ifndef GDK_DISABLE_DEPRECATED
263 GdkDevice  *gdk_display_get_core_pointer (GdkDisplay *display);
264 #endif /* GDK_DISABLE_DEPRECATED */
265
266 void             gdk_display_get_pointer           (GdkDisplay             *display,
267                                                     GdkScreen             **screen,
268                                                     gint                   *x,
269                                                     gint                   *y,
270                                                     GdkModifierType        *mask);
271 GdkWindow *      gdk_display_get_window_at_pointer (GdkDisplay             *display,
272                                                     gint                   *win_x,
273                                                     gint                   *win_y);
274 void             gdk_display_warp_pointer          (GdkDisplay             *display,
275                                                     GdkScreen              *screen,
276                                                     gint                   x,
277                                                     gint                   y);
278 #endif /* GDK_MULTIDEVICE_SAFE */
279
280 void             gdk_display_get_device_state              (GdkDisplay            *display,
281                                                             GdkDevice             *device,
282                                                             GdkScreen            **screen,
283                                                             gint                  *x,
284                                                             gint                  *y,
285                                                             GdkModifierType       *mask);
286 GdkWindow *      gdk_display_get_window_at_device_position (GdkDisplay            *display,
287                                                             GdkDevice             *device,
288                                                             gint                  *win_x,
289                                                             gint                  *win_y);
290 void             gdk_display_warp_device                   (GdkDisplay            *display,
291                                                             GdkDevice             *device,
292                                                             GdkScreen             *screen,
293                                                             gint                   x,
294                                                             gint                   y);
295
296 #ifndef GDK_MULTIDEVICE_SAFE
297 GdkDisplayPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay                   *display,
298                                                        const GdkDisplayPointerHooks *new_hooks);
299 #endif /* GDK_MULTIDEVICE_SAFE */
300
301 GdkDisplayDeviceHooks *gdk_display_set_device_hooks (GdkDisplay                  *display,
302                                                      const GdkDisplayDeviceHooks *new_hooks);
303
304 GdkDisplay *gdk_display_open_default_libgtk_only (void);
305
306 gboolean gdk_display_supports_cursor_alpha     (GdkDisplay    *display);
307 gboolean gdk_display_supports_cursor_color     (GdkDisplay    *display);
308 guint    gdk_display_get_default_cursor_size   (GdkDisplay    *display);
309 void     gdk_display_get_maximal_cursor_size   (GdkDisplay    *display,
310                                                 guint         *width,
311                                                 guint         *height);
312
313 GdkWindow *gdk_display_get_default_group       (GdkDisplay *display); 
314
315 gboolean gdk_display_supports_selection_notification (GdkDisplay *display);
316 gboolean gdk_display_request_selection_notification  (GdkDisplay *display,
317                                                       GdkAtom     selection);
318
319 gboolean gdk_display_supports_clipboard_persistence (GdkDisplay    *display);
320 void     gdk_display_store_clipboard                (GdkDisplay    *display,
321                                                      GdkWindow     *clipboard_window,
322                                                      guint32        time_,
323                                                      const GdkAtom *targets,
324                                                      gint           n_targets);
325
326 gboolean gdk_display_supports_shapes           (GdkDisplay    *display);
327 gboolean gdk_display_supports_input_shapes     (GdkDisplay    *display);
328 gboolean gdk_display_supports_composite        (GdkDisplay    *display);
329
330 GdkDeviceManager * gdk_display_get_device_manager (GdkDisplay *display);
331
332
333 G_END_DECLS
334
335 #endif  /* __GDK_DISPLAY_H__ */