1 /*
2  * gdkdisplay-x11.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, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef __GDK_X11_DISPLAY__
23 #define __GDK_X11_DISPLAY__
24 
25 #include "gdkdisplayprivate.h"
26 #include "gdkkeys.h"
27 #include "gdksurface.h"
28 #include "gdkinternals.h"
29 #include "gdkx11devicemanager.h"
30 #include "gdkx11display.h"
31 #include "gdkx11screen.h"
32 #include "gdkprivate-x11.h"
33 
34 #include <X11/X.h>
35 #include <X11/Xlib.h>
36 
37 G_BEGIN_DECLS
38 
39 
40 struct _GdkX11Display
41 {
42   GdkDisplay parent_instance;
43   Display *xdisplay;
44   GdkX11Screen *screen;
45   GList *toplevels;
46   GdkX11DeviceManagerXI2 *device_manager;
47 
48   GSource *event_source;
49 
50   int grab_count;
51 
52   /* Visual infos for creating Windows */
53   int window_depth;
54   Visual *window_visual;
55   Colormap window_colormap;
56 
57   /* Keyboard related information */
58   int xkb_event_type;
59   gboolean use_xkb;
60 
61   /* Whether we were able to turn on detectable-autorepeat using
62    * XkbSetDetectableAutorepeat. If FALSE, we'll fall back
63    * to checking the next event with XPending().
64    */
65   gboolean have_xkb_autorepeat;
66 
67   GdkKeymap *keymap;
68   guint      keymap_serial;
69 
70   gboolean have_xfixes;
71   int xfixes_event_base;
72 
73   gboolean have_randr12;
74   gboolean have_randr13;
75   gboolean have_randr15;
76   int xrandr_event_base;
77 
78   /* If the SECURITY extension is in place, whether this client holds
79    * a trusted authorization and so is allowed to make various requests
80    * (grabs, properties etc.) Otherwise always TRUE.
81    */
82   gboolean trusted_client;
83 
84   /* drag and drop information */
85   GdkDrop *current_drop;
86 
87   /* Mapping to/from virtual atoms */
88   GHashTable *atom_from_string;
89   GHashTable *atom_to_string;
90 
91   /* Session Management leader window see ICCCM */
92   char *program_class;
93   Window leader_window;
94   GdkSurface *leader_gdk_surface;
95   gboolean leader_window_title_set;
96 
97   /* X ID hashtable */
98   GHashTable *xid_ht;
99 
100   /* streams reading selections */
101   GSList *streams;
102 
103   /* GdkCursor => XCursor */
104   GHashTable *cursors;
105 
106   GListStore *monitors;
107   int primary_monitor;
108 
109   /* Startup notification */
110   char *startup_notification_id;
111 
112   /* Time of most recent user interaction. */
113   gulong user_time;
114 
115   /* Sets of atoms for DND */
116   guint use_sync : 1;
117 
118   guint have_shapes : 1;
119   guint have_input_shapes : 1;
120   int shape_event_base;
121 
122   GSList *error_traps;
123 
124   int wm_moveresize_button;
125 
126 #ifdef HAVE_XDAMAGE
127   int damage_event_base;
128   int damage_error_base;
129   guint have_damage;
130 #endif
131 
132   /* If GL is not supported, store the error here */
133   GError *gl_error;
134 
135   /* GLX information */
136   /* GLXFBConfig */ gpointer glx_config;
137   int glx_version;
138 
139   /* EGL information */
140   /* We use gpointer here so we don't have to pull in EGL headers (which glx doesn't like) */
141   /* EGLDisplay */ gpointer egl_display;
142   /* EGLConfig */ gpointer egl_config;
143   int egl_version;
144 
145   /* Translation between X server time and system-local monotonic time */
146   gint64 server_time_query_time;
147   gint64 server_time_offset;
148 
149   guint server_time_is_monotonic_time : 1;
150 
151   /* GLX extensions we check */
152   guint has_glx_swap_interval : 1;
153   guint has_glx_create_context : 1;
154   guint has_glx_texture_from_pixmap : 1;
155   guint has_glx_video_sync : 1;
156   guint has_glx_buffer_age : 1;
157   guint has_glx_sync_control : 1;
158   guint has_glx_multisample : 1;
159   guint has_glx_visual_rating : 1;
160   guint has_glx_create_es2_context : 1;
161   guint has_async_glx_swap_buffers : 1;
162 
163   /* EGL extensions we check */
164   guint has_egl_khr_create_context : 1;
165   guint has_egl_buffer_age : 1;
166   guint has_egl_swap_buffers_with_damage : 1;
167 };
168 
169 struct _GdkX11DisplayClass
170 {
171   GdkDisplayClass parent_class;
172 
173   gboolean              (* xevent)                              (GdkX11Display          *display,
174                                                                  const XEvent           *event);
175 };
176 
177 void            _gdk_x11_display_error_event                    (GdkDisplay             *display,
178                                                                  XErrorEvent            *error);
179 gsize           gdk_x11_display_get_max_request_size            (GdkDisplay             *display);
180 gboolean        gdk_x11_display_request_selection_notification  (GdkDisplay             *display,
181                                                                  const char             *selection);
182 
183 GdkFilterReturn _gdk_wm_protocols_filter        (const XEvent   *xevent,
184                                                  GdkSurface     *win,
185                                                  GdkEvent      **event,
186                                                  gpointer        data);
187 
188 G_END_DECLS
189 
190 #endif  /* __GDK_X11_DISPLAY__ */
191