gdkdisplayprivate.h 18.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* GDK - The GIMP Drawing Kit
 * Copyright (C) 2010 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21
 */

#ifndef __GDK_DISPLAY_PRIVATE_H__
#define __GDK_DISPLAY_PRIVATE_H__

#include "gdkdisplay.h"
22
#include "gdkwindow.h"
23
#include "gdkcursor.h"
24
#include "gdkmonitor.h"
25
#include "gdkinternals.h"
26 27 28

G_BEGIN_DECLS

29 30 31 32 33
#define GDK_DISPLAY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass))
#define GDK_IS_DISPLAY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY))
#define GDK_DISPLAY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass))


34 35
typedef struct _GdkDisplayClass GdkDisplayClass;

36
/* Tracks information about the device grab on this display */
37 38 39 40 41 42 43 44 45 46 47 48
typedef struct
{
  GdkWindow *window;
  GdkWindow *native_window;
  gulong serial_start;
  gulong serial_end; /* exclusive, i.e. not active on serial_end */
  guint event_mask;
  guint32 time;
  GdkGrabOwnership ownership;

  guint activated : 1;
  guint implicit_ungrab : 1;
49 50
  guint owner_events : 1;
  guint implicit : 1;
51 52
} GdkDeviceGrabInfo;

53 54 55 56 57 58 59 60 61 62 63 64 65
/* Tracks information about a touch implicit grab on this display */
typedef struct
{
  GdkDevice *device;
  GdkEventSequence *sequence;

  GdkWindow *window;
  GdkWindow *native_window;
  gulong serial;
  guint event_mask;
  guint32 time;
} GdkTouchGrabInfo;

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
/* Tracks information about which window and position the pointer last was in.
 * This is useful when we need to synthesize events later.
 * Note that we track toplevel_under_pointer using enter/leave events,
 * so in the case of a grab, either with owner_events==FALSE or with the
 * pointer in no clients window the x/y coordinates may actually be outside
 * the window.
 */
typedef struct
{
  GdkWindow *toplevel_under_pointer; /* toplevel window containing the pointer, */
                                     /* tracked via native events */
  GdkWindow *window_under_pointer;   /* window that last got a normal enter event */
  gdouble toplevel_x, toplevel_y;
  guint32 state;
  guint32 button;
81
  GdkDevice *last_slave;
82
  guint need_touch_press_enter : 1;
83 84 85 86 87 88 89 90 91
} GdkPointerWindowInfo;

typedef struct
{
  guint32 button_click_time[2]; /* last 2 button click times */
  GdkWindow *button_window[2];  /* last 2 windows to receive button presses */
  gint button_number[2];        /* last 2 buttons to be pressed */
  gint button_x[2];             /* last 2 button click positions */
  gint button_y[2];
92
  GdkDevice *last_slave;
93 94 95 96 97 98 99 100 101 102 103 104 105 106
} GdkMultipleClickInfo;

struct _GdkDisplay
{
  GObject parent_instance;

  GList *queued_events;
  GList *queued_tail;

  /* Information for determining if the latest button click
   * is part of a double-click or triple-click
   */
  GHashTable *multiple_click_info;

107 108
  guint event_pause_count;       /* How many times events are blocked */

109 110
  guint closed             : 1;  /* Whether this display has been closed */

111
  GArray *touch_implicit_grabs;
112 113
  GHashTable *device_grabs;
  GHashTable *motion_hint_info;
114
  GdkDeviceManager *device_manager;
115
  GList *input_devices; /* Deprecated, only used to keep gdk_display_list_devices working */
116 117 118 119

  GHashTable *pointers_info;  /* GdkPointerWindowInfo for each device */
  guint32 last_event_time;    /* Last reported event time from server */

Matthias Clasen's avatar
Matthias Clasen committed
120
  guint double_click_time;  /* Maximum time between clicks in msecs */
121
  guint double_click_distance;   /* Maximum distance between clicks in pixels */
122 123 124

  guint has_gl_extension_texture_non_power_of_two : 1;
  guint has_gl_extension_texture_rectangle : 1;
125

126 127 128
  guint debug_updates     : 1;
  guint debug_updates_set : 1;

129
  GdkRenderingMode rendering_mode;
130 131

  GList *seats;
132 133 134 135 136 137
};

struct _GdkDisplayClass
{
  GObjectClass parent_class;

138 139
  GType window_type;          /* type for native windows for this display, set in class_init */

140
  const gchar *              (*get_name)           (GdkDisplay *display);
141 142 143 144 145 146
  GdkScreen *                (*get_default_screen) (GdkDisplay *display);
  void                       (*beep)               (GdkDisplay *display);
  void                       (*sync)               (GdkDisplay *display);
  void                       (*flush)              (GdkDisplay *display);
  gboolean                   (*has_pending)        (GdkDisplay *display);
  void                       (*queue_events)       (GdkDisplay *display);
147
  void                       (*make_default)       (GdkDisplay *display);
148 149 150 151
  GdkWindow *                (*get_default_group)  (GdkDisplay *display);
  gboolean                   (*supports_selection_notification) (GdkDisplay *display);
  gboolean                   (*request_selection_notification)  (GdkDisplay *display,
                                                                 GdkAtom     selection);
152 153 154 155 156 157
  gboolean                   (*supports_shapes)       (GdkDisplay *display);
  gboolean                   (*supports_input_shapes) (GdkDisplay *display);
  gboolean                   (*supports_composite)    (GdkDisplay *display);
  gboolean                   (*supports_cursor_alpha) (GdkDisplay *display);
  gboolean                   (*supports_cursor_color) (GdkDisplay *display);

158 159 160 161 162 163
  gboolean                   (*supports_clipboard_persistence)  (GdkDisplay *display);
  void                       (*store_clipboard)    (GdkDisplay    *display,
                                                    GdkWindow     *clipboard_window,
                                                    guint32        time_,
                                                    const GdkAtom *targets,
                                                    gint           n_targets);
164 165 166 167 168 169 170 171 172 173 174

  void                       (*get_default_cursor_size) (GdkDisplay *display,
                                                         guint      *width,
                                                         guint      *height);
  void                       (*get_maximal_cursor_size) (GdkDisplay *display,
                                                         guint      *width,
                                                         guint      *height);
  GdkCursor *                (*get_cursor_for_type)     (GdkDisplay    *display,
                                                         GdkCursorType  type);
  GdkCursor *                (*get_cursor_for_name)     (GdkDisplay    *display,
                                                         const gchar   *name);
175 176 177 178
  GdkCursor *                (*get_cursor_for_surface)  (GdkDisplay    *display,
                                                         cairo_surface_t *surface,
                                                         gdouble          x,
                                                         gdouble          y);
179

180 181
  GdkAppLaunchContext *      (*get_app_launch_context) (GdkDisplay *display);

182 183 184
  void                       (*before_process_all_updates) (GdkDisplay *display);
  void                       (*after_process_all_updates)  (GdkDisplay *display);

185 186
  gulong                     (*get_next_serial) (GdkDisplay *display);

187 188
  void                       (*notify_startup_complete) (GdkDisplay  *display,
                                                         const gchar *startup_id);
189 190 191 192 193
  void                       (*event_data_copy) (GdkDisplay     *display,
                                                 const GdkEvent *event,
                                                 GdkEvent       *new_event);
  void                       (*event_data_free) (GdkDisplay     *display,
                                                 GdkEvent       *event);
194 195 196 197 198 199 200
  void                       (*create_window_impl) (GdkDisplay    *display,
                                                    GdkWindow     *window,
                                                    GdkWindow     *real_parent,
                                                    GdkScreen     *screen,
                                                    GdkEventMask   event_mask,
                                                    GdkWindowAttr *attributes,
                                                    gint           attributes_mask);
201

202
  GdkKeymap *                (*get_keymap)         (GdkDisplay    *display);
203 204 205
  void                       (*push_error_trap)    (GdkDisplay    *display);
  gint                       (*pop_error_trap)     (GdkDisplay    *display,
                                                    gboolean       ignore);
206

207 208 209 210 211 212 213
  GdkWindow *                (*get_selection_owner) (GdkDisplay   *display,
                                                     GdkAtom       selection);
  gboolean                   (*set_selection_owner) (GdkDisplay   *display,
                                                     GdkWindow    *owner,
                                                     GdkAtom       selection,
                                                     guint32       time,
                                                     gboolean      send_event);
214
  void                       (*send_selection_notify) (GdkDisplay *dispay,
215
                                                       GdkWindow        *requestor,
216 217 218
                                                       GdkAtom          selection,
                                                       GdkAtom          target,
                                                       GdkAtom          property,
219
                                                       guint32          time);
220 221 222 223 224
  gint                       (*get_selection_property) (GdkDisplay  *display,
                                                        GdkWindow   *requestor,
                                                        guchar     **data,
                                                        GdkAtom     *type,
                                                        gint        *format);
225 226 227 228 229
  void                       (*convert_selection)      (GdkDisplay  *display,
                                                        GdkWindow   *requestor,
                                                        GdkAtom      selection,
                                                        GdkAtom      target,
                                                        guint32      time);
230

231 232 233 234 235 236 237 238 239
  gint                   (*text_property_to_utf8_list) (GdkDisplay     *display,
                                                        GdkAtom         encoding,
                                                        gint            format,
                                                        const guchar   *text,
                                                        gint            length,
                                                        gchar        ***list);
  gchar *                (*utf8_to_string_target)      (GdkDisplay     *display,
                                                        const gchar    *text);

240 241
  gboolean               (*make_gl_context_current)    (GdkDisplay        *display,
                                                        GdkGLContext      *context);
242

243 244
  GdkSeat *              (*get_default_seat)           (GdkDisplay     *display);

245 246 247 248
  int                    (*get_n_monitors)             (GdkDisplay     *display);
  GdkMonitor *           (*get_monitor)                (GdkDisplay     *display,
                                                        int             index);
  GdkMonitor *           (*get_primary_monitor)        (GdkDisplay     *display);
249 250
  GdkMonitor *           (*get_monitor_at_window)      (GdkDisplay     *display,
                                                        GdkWindow      *window);
251

252
  /* Signals */
253
  void                   (*opened)                     (GdkDisplay     *display);
254 255 256 257 258 259 260 261 262 263
  void (*closed) (GdkDisplay *display,
                  gboolean    is_error);
};


typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay           *display,
                                               GdkDevice            *device,
                                               GdkPointerWindowInfo *device_info,
                                               gpointer              user_data);

264 265
void                _gdk_display_update_last_event    (GdkDisplay     *display,
                                                       const GdkEvent *event);
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
void                _gdk_display_device_grab_update   (GdkDisplay *display,
                                                       GdkDevice  *device,
                                                       GdkDevice  *source_device,
                                                       gulong      current_serial);
GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display,
                                                       GdkDevice  *device);
GdkDeviceGrabInfo * _gdk_display_add_device_grab      (GdkDisplay       *display,
                                                       GdkDevice        *device,
                                                       GdkWindow        *window,
                                                       GdkWindow        *native_window,
                                                       GdkGrabOwnership  grab_ownership,
                                                       gboolean          owner_events,
                                                       GdkEventMask      event_mask,
                                                       gulong            serial_start,
                                                       guint32           time,
                                                       gboolean          implicit);
GdkDeviceGrabInfo * _gdk_display_has_device_grab      (GdkDisplay       *display,
                                                       GdkDevice        *device,
                                                       gulong            serial);
gboolean            _gdk_display_end_device_grab      (GdkDisplay       *display,
                                                       GdkDevice        *device,
                                                       gulong            serial,
                                                       GdkWindow        *if_child,
                                                       gboolean          implicit);
gboolean            _gdk_display_check_grab_ownership (GdkDisplay       *display,
                                                       GdkDevice        *device,
                                                       gulong            serial);
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
void                _gdk_display_add_touch_grab       (GdkDisplay       *display,
                                                       GdkDevice        *device,
                                                       GdkEventSequence *sequence,
                                                       GdkWindow        *window,
                                                       GdkWindow        *native_window,
                                                       GdkEventMask      event_mask,
                                                       unsigned long     serial_start,
                                                       guint32           time);
GdkTouchGrabInfo *  _gdk_display_has_touch_grab       (GdkDisplay       *display,
                                                       GdkDevice        *device,
                                                       GdkEventSequence *sequence,
                                                       gulong            serial);
gboolean            _gdk_display_end_touch_grab       (GdkDisplay       *display,
                                                       GdkDevice        *device,
                                                       GdkEventSequence *sequence);
308 309 310 311 312 313 314
void                _gdk_display_enable_motion_hints  (GdkDisplay       *display,
                                                       GdkDevice        *device);
GdkPointerWindowInfo * _gdk_display_get_pointer_info  (GdkDisplay       *display,
                                                       GdkDevice        *device);
void                _gdk_display_pointer_info_foreach (GdkDisplay       *display,
                                                       GdkDisplayPointerInfoForeach func,
                                                       gpointer          user_data);
315
gulong              _gdk_display_get_next_serial      (GdkDisplay       *display);
316 317
void                _gdk_display_pause_events         (GdkDisplay       *display);
void                _gdk_display_unpause_events       (GdkDisplay       *display);
318 319 320 321 322
void                _gdk_display_event_data_copy      (GdkDisplay       *display,
                                                       const GdkEvent   *event,
                                                       GdkEvent         *new_event);
void                _gdk_display_event_data_free      (GdkDisplay       *display,
                                                       GdkEvent         *event);
323 324 325 326 327 328 329
void                _gdk_display_create_window_impl   (GdkDisplay       *display,
                                                       GdkWindow        *window,
                                                       GdkWindow        *real_parent,
                                                       GdkScreen        *screen,
                                                       GdkEventMask      event_mask,
                                                       GdkWindowAttr    *attributes,
                                                       gint              attributes_mask);
330
GdkWindow *         _gdk_display_create_window        (GdkDisplay       *display);
331

332
gboolean            gdk_display_make_gl_context_current  (GdkDisplay        *display,
333 334
                                                          GdkGLContext      *context);

335 336 337 338
void                gdk_display_add_seat              (GdkDisplay       *display,
                                                       GdkSeat          *seat);
void                gdk_display_remove_seat           (GdkDisplay       *display,
                                                       GdkSeat          *seat);
339 340 341 342
void                gdk_display_monitor_added         (GdkDisplay       *display,
                                                       GdkMonitor       *monitor);
void                gdk_display_monitor_removed       (GdkDisplay       *display,
                                                       GdkMonitor       *monitor);
343

344 345 346
G_END_DECLS

#endif  /* __GDK_DISPLAY_PRIVATE_H__ */