]> Pileus Git - ~andy/gtk/blob - gdk/gdkdisplay.h
Hide GdkDisplayClass from public header
[~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 /**
120  * GdkDisplayPointerHooks:
121  * @get_pointer: Obtains the current pointer position and modifier state.
122  *  The position is given in coordinates relative to the screen containing
123  *  the pointer, which is returned in @screen.
124  * @window_get_pointer: Obtains the window underneath the mouse pointer.
125  *  Current pointer position and modifier state are returned in @x, @y and
126  *  @mask. The position is given in coordinates relative to @window.
127  * @window_at_pointer: Obtains the window underneath the mouse pointer,
128  *  returning the location of that window in @win_x, @win_y. Returns %NULL
129  *  if the window under the mouse pointer is not known to GDK (for example,
130  *  belongs to another application).
131  *
132  * A table of pointers to functions for getting quantities related to
133  * the current pointer position. Each #GdkDisplay has a table of this type,
134  * which can be set using gdk_display_set_pointer_hooks().
135  *
136  * This is only useful for such low-level tools as an event recorder.
137  * Applications should never have any reason to use this facility
138  *
139  * Since: 2.2
140  */
141 struct _GdkDisplayPointerHooks
142 {
143   void (*get_pointer)              (GdkDisplay      *display,
144                                     GdkScreen      **screen,
145                                     gint            *x,
146                                     gint            *y,
147                                     GdkModifierType *mask);
148   GdkWindow* (*window_get_pointer) (GdkDisplay      *display,
149                                     GdkWindow       *window,
150                                     gint            *x,
151                                     gint            *y,
152                                     GdkModifierType *mask);
153   GdkWindow* (*window_at_pointer)  (GdkDisplay      *display,
154                                     gint            *win_x,
155                                     gint            *win_y);
156 };
157
158 /**
159  * GdkDisplayDeviceHooks:
160  * @get_device_state: Obtains the current position and modifier state for
161  * @device. The position is given in coordinates relative to the window
162  * containing the pointer, which is returned in @window.
163  * @window_get_device_position: Obtains the window underneath the device
164  * position. Current device position and modifier state are returned in
165  * @x, @y and @mask. The position is given in coordinates relative to
166  * @window.
167  * @window_at_device_position: Obtains the window underneath the device
168  * position, returning the location of that window in @win_x, @win_y.
169  * Returns %NULL if the window under the mouse pointer is not known to
170  * GDK (for example, belongs to another application).
171  *
172  * A table of pointers to functions for getting quantities related to
173  * the current device position. Each #GdkDisplay has a table of this type,
174  * which can be set using gdk_display_set_device_hooks().
175  */
176 struct _GdkDisplayDeviceHooks
177 {
178   void (* get_device_state)                  (GdkDisplay       *display,
179                                               GdkDevice        *device,
180                                               GdkScreen       **screen,
181                                               gint             *x,
182                                               gint             *y,
183                                               GdkModifierType  *mask);
184   GdkWindow * (* window_get_device_position) (GdkDisplay      *display,
185                                               GdkDevice       *device,
186                                               GdkWindow       *window,
187                                               gint            *x,
188                                               gint            *y,
189                                               GdkModifierType *mask);
190   GdkWindow * (* window_at_device_position)  (GdkDisplay *display,
191                                               GdkDevice  *device,
192                                               gint       *win_x,
193                                               gint       *win_y);
194 };
195
196 GType       gdk_display_get_type (void) G_GNUC_CONST;
197 GdkDisplay *gdk_display_open                (const gchar *display_name);
198
199 G_CONST_RETURN gchar * gdk_display_get_name (GdkDisplay *display);
200
201 gint        gdk_display_get_n_screens      (GdkDisplay  *display);
202 GdkScreen * gdk_display_get_screen         (GdkDisplay  *display,
203                                             gint         screen_num);
204 GdkScreen * gdk_display_get_default_screen (GdkDisplay  *display);
205
206 #ifndef GDK_MULTIDEVICE_SAFE
207 void        gdk_display_pointer_ungrab     (GdkDisplay  *display,
208                                             guint32      time_);
209 void        gdk_display_keyboard_ungrab    (GdkDisplay  *display,
210                                             guint32      time_);
211 gboolean    gdk_display_pointer_is_grabbed (GdkDisplay  *display);
212 #endif /* GDK_MULTIDEVICE_SAFE */
213
214 gboolean    gdk_display_device_is_grabbed  (GdkDisplay  *display,
215                                             GdkDevice   *device);
216 void        gdk_display_beep               (GdkDisplay  *display);
217 void        gdk_display_sync               (GdkDisplay  *display);
218 void        gdk_display_flush              (GdkDisplay  *display);
219
220 void        gdk_display_close                  (GdkDisplay  *display);
221 gboolean    gdk_display_is_closed          (GdkDisplay  *display);
222
223 #ifndef GDK_DISABLE_DEPRECATED
224 GList *     gdk_display_list_devices       (GdkDisplay  *display);
225 #endif /* GDK_DISABLE_DEPRECATED */
226
227 GdkEvent* gdk_display_get_event  (GdkDisplay     *display);
228 GdkEvent* gdk_display_peek_event (GdkDisplay     *display);
229 void      gdk_display_put_event  (GdkDisplay     *display,
230                                   const GdkEvent *event);
231
232 void gdk_display_add_client_message_filter (GdkDisplay   *display,
233                                             GdkAtom       message_type,
234                                             GdkFilterFunc func,
235                                             gpointer      data);
236
237 void gdk_display_set_double_click_time     (GdkDisplay   *display,
238                                             guint         msec);
239 void gdk_display_set_double_click_distance (GdkDisplay   *display,
240                                             guint         distance);
241
242 GdkDisplay *gdk_display_get_default (void);
243
244 #ifndef GDK_MULTIDEVICE_SAFE
245
246 void             gdk_display_get_pointer           (GdkDisplay             *display,
247                                                     GdkScreen             **screen,
248                                                     gint                   *x,
249                                                     gint                   *y,
250                                                     GdkModifierType        *mask);
251 GdkWindow *      gdk_display_get_window_at_pointer (GdkDisplay             *display,
252                                                     gint                   *win_x,
253                                                     gint                   *win_y);
254 void             gdk_display_warp_pointer          (GdkDisplay             *display,
255                                                     GdkScreen              *screen,
256                                                     gint                   x,
257                                                     gint                   y);
258 #endif /* GDK_MULTIDEVICE_SAFE */
259
260 void             gdk_display_get_device_state              (GdkDisplay            *display,
261                                                             GdkDevice             *device,
262                                                             GdkScreen            **screen,
263                                                             gint                  *x,
264                                                             gint                  *y,
265                                                             GdkModifierType       *mask);
266 GdkWindow *      gdk_display_get_window_at_device_position (GdkDisplay            *display,
267                                                             GdkDevice             *device,
268                                                             gint                  *win_x,
269                                                             gint                  *win_y);
270 void             gdk_display_warp_device                   (GdkDisplay            *display,
271                                                             GdkDevice             *device,
272                                                             GdkScreen             *screen,
273                                                             gint                   x,
274                                                             gint                   y);
275
276 #ifndef GDK_MULTIDEVICE_SAFE
277 GdkDisplayPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay                   *display,
278                                                        const GdkDisplayPointerHooks *new_hooks);
279 #endif /* GDK_MULTIDEVICE_SAFE */
280
281 GdkDisplayDeviceHooks *gdk_display_set_device_hooks (GdkDisplay                  *display,
282                                                      const GdkDisplayDeviceHooks *new_hooks);
283
284 GdkDisplay *gdk_display_open_default_libgtk_only (void);
285
286 gboolean gdk_display_supports_cursor_alpha     (GdkDisplay    *display);
287 gboolean gdk_display_supports_cursor_color     (GdkDisplay    *display);
288 guint    gdk_display_get_default_cursor_size   (GdkDisplay    *display);
289 void     gdk_display_get_maximal_cursor_size   (GdkDisplay    *display,
290                                                 guint         *width,
291                                                 guint         *height);
292
293 GdkWindow *gdk_display_get_default_group       (GdkDisplay *display); 
294
295 gboolean gdk_display_supports_selection_notification (GdkDisplay *display);
296 gboolean gdk_display_request_selection_notification  (GdkDisplay *display,
297                                                       GdkAtom     selection);
298
299 gboolean gdk_display_supports_clipboard_persistence (GdkDisplay    *display);
300 void     gdk_display_store_clipboard                (GdkDisplay    *display,
301                                                      GdkWindow     *clipboard_window,
302                                                      guint32        time_,
303                                                      const GdkAtom *targets,
304                                                      gint           n_targets);
305
306 gboolean gdk_display_supports_shapes           (GdkDisplay    *display);
307 gboolean gdk_display_supports_input_shapes     (GdkDisplay    *display);
308 gboolean gdk_display_supports_composite        (GdkDisplay    *display);
309
310 GdkDeviceManager * gdk_display_get_device_manager (GdkDisplay *display);
311
312
313 G_END_DECLS
314
315 #endif  /* __GDK_DISPLAY_H__ */