2002-04-25 22:29:14 +00:00
/* GDK - The GIMP Drawing Kit
* gdkdisplay - x11 . c
*
New API to handle the clipboard manager.
2004-10-25 Anders Carlsson <andersca@imendio.com>
* gdk/gdk.symbols:
* gdk/gdkdisplay.h:
* gdk/x11/gdkdisplay-x11.c:
(gdk_display_supports_clipboard_persistence),
(gdk_display_store_clipboard):
New API to handle the clipboard manager.
* gtk/gtk.symbols:
* gtk/gtkclipboard.c: (gtk_clipboard_class_init),
(gtk_clipboard_finalize), (selection_clear_event_cb),
(clipboard_unset), (gtk_clipboard_set_text),
(gtk_clipboard_request_targets), (gtk_clipboard_wait_for_targets),
(clipboard_peek), (gtk_clipboard_owner_change),
(gtk_clipboard_wait_is_target_available),
(gtk_clipboard_store_timeout), (gtk_clipboard_set_can_store),
(gtk_clipboard_selection_notify), (gtk_clipboard_store),
(_gtk_clipboard_store_all):
* gtk/gtkclipboard.h:
Add API for clipboard persistence and implement it, also add
gtk_clipboard_wait_is_target_available.
* gtk/gtkmain.c: (gtk_main):
Call _gtk_clipboard_store_all before exiting.
2004-10-25 18:53:30 +00:00
* Copyright 2001 Sun Microsystems Inc .
* Copyright ( C ) 2004 Nokia Corporation
2002-04-25 22:29:14 +00:00
*
* Erwann Chenede < erwann . chenede @ sun . com >
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details .
*
* You should have received a copy of the GNU Library General Public
2012-02-27 13:01:10 +00:00
* License along with this library . If not , see < http : //www.gnu.org/licenses/>.
2002-04-25 22:29:14 +00:00
*/
2008-06-22 14:28:52 +00:00
# include "config.h"
2002-04-25 22:29:14 +00:00
2016-11-28 15:34:01 +00:00
# define VK_USE_PLATFORM_XLIB_KHR
2017-11-19 17:06:13 +00:00
# include "gdkdisplay-x11.h"
# include "gdkdisplayprivate.h"
2009-01-26 19:38:20 +00:00
# include "gdkasync.h"
2002-04-25 22:29:14 +00:00
# include "gdkdisplay.h"
2010-05-25 22:38:44 +00:00
# include "gdkeventsource.h"
# include "gdkeventtranslator.h"
2013-02-12 20:47:38 +00:00
# include "gdkframeclockprivate.h"
2010-11-22 23:55:39 +00:00
# include "gdkinternals.h"
2010-05-25 22:38:44 +00:00
# include "gdkdeviceprivate.h"
2019-04-22 01:14:46 +00:00
# include "gdksurfaceprivate.h"
2010-12-16 05:08:42 +00:00
# include "gdkkeysprivate.h"
2017-12-12 23:43:30 +00:00
# include "gdkmarshalers.h"
2002-04-25 22:29:14 +00:00
# include "xsettings-client.h"
2020-04-07 17:12:58 +00:00
# include "gdkcairocontext-x11.h"
2017-11-19 17:06:13 +00:00
# include "gdkclipboard-x11.h"
2020-04-07 17:12:58 +00:00
# include "gdkglcontext-x11.h"
# include "gdkkeys-x11.h"
2010-12-16 03:09:35 +00:00
# include "gdkprivate-x11.h"
# include "gdkscreen-x11.h"
2016-11-28 15:34:01 +00:00
# include "gdkvulkancontext-x11.h"
2020-04-07 17:12:58 +00:00
2014-11-07 14:33:53 +00:00
# include "gdk-private.h"
2002-04-25 22:29:14 +00:00
2010-10-15 02:05:51 +00:00
# include <glib.h>
# include <glib/gprintf.h>
# include <stdlib.h>
# include <string.h>
# include <errno.h>
# include <unistd.h>
2002-04-25 22:29:14 +00:00
# include <X11/Xatom.h>
2014-02-03 20:37:00 +00:00
# include <X11/Xlibint.h>
2002-04-25 22:29:14 +00:00
# ifdef HAVE_XKB
# include <X11/XKBlib.h>
# endif
2004-05-18 20:56:54 +00:00
# ifdef HAVE_XFIXES
# include <X11/extensions/Xfixes.h>
# endif
2006-02-20 01:36:50 +00:00
# include <X11/extensions/shape.h>
2007-06-01 12:16:12 +00:00
# ifdef HAVE_XCOMPOSITE
# include <X11/extensions/Xcomposite.h>
# endif
2007-12-13 18:27:05 +00:00
# ifdef HAVE_RANDR
# include <X11/extensions/Xrandr.h>
# endif
2017-12-12 23:43:30 +00:00
enum {
2017-12-13 00:53:17 +00:00
XEVENT ,
2017-12-12 23:43:30 +00:00
LAST_SIGNAL
} ;
2010-09-18 22:19:27 +00:00
typedef struct _GdkErrorTrap GdkErrorTrap ;
struct _GdkErrorTrap
{
/* Next sequence when trap was pushed, i.e. first sequence to
* ignore
*/
gulong start_sequence ;
/* Next sequence when trap was popped, i.e. first sequence
* to not ignore . 0 if trap is still active .
*/
gulong end_sequence ;
/* Most recent error code within the sequence */
int error_code ;
} ;
2006-02-20 01:36:50 +00:00
2010-12-20 18:20:10 +00:00
static void gdk_x11_display_dispose ( GObject * object ) ;
static void gdk_x11_display_finalize ( GObject * object ) ;
2002-04-25 22:29:14 +00:00
2010-12-20 18:20:10 +00:00
static void gdk_x11_display_event_translator_init ( GdkEventTranslatorIface * iface ) ;
2010-05-25 22:38:44 +00:00
2020-02-15 17:09:31 +00:00
static GdkEvent * gdk_x11_display_translate_event ( GdkEventTranslator * translator ,
GdkDisplay * display ,
const XEvent * xevent ) ;
2010-05-25 22:38:44 +00:00
2002-05-20 19:04:33 +00:00
static void gdk_internal_connection_watch ( Display * display ,
XPointer arg ,
2020-07-24 13:54:49 +00:00
int fd ,
2002-05-20 19:04:33 +00:00
gboolean opening ,
XPointer * watch_data ) ;
2010-05-25 22:38:44 +00:00
typedef struct _GdkEventTypeX11 GdkEventTypeX11 ;
struct _GdkEventTypeX11
{
2020-07-24 13:54:49 +00:00
int base ;
int n_events ;
2010-05-25 22:38:44 +00:00
} ;
2003-07-05 01:54:05 +00:00
/* Note that we never *directly* use WM_LOCALE_NAME, WM_PROTOCOLS,
* but including them here has the side - effect of getting them
* into the internal Xlib cache
*/
static const char * const precache_atoms [ ] = {
" UTF8_STRING " ,
" WM_CLIENT_LEADER " ,
" WM_DELETE_WINDOW " ,
2008-12-08 00:01:29 +00:00
" WM_ICON_NAME " ,
2003-07-05 01:54:05 +00:00
" WM_LOCALE_NAME " ,
2008-12-08 00:01:29 +00:00
" WM_NAME " ,
2003-07-05 01:54:05 +00:00
" WM_PROTOCOLS " ,
" WM_TAKE_FOCUS " ,
2008-12-08 00:01:29 +00:00
" WM_WINDOW_ROLE " ,
2020-02-22 15:08:46 +00:00
" WM_STATE " ,
2008-12-08 00:01:29 +00:00
" _NET_ACTIVE_WINDOW " ,
" _NET_CURRENT_DESKTOP " ,
" _NET_FRAME_EXTENTS " ,
" _NET_STARTUP_ID " ,
2006-04-25 14:27:32 +00:00
" _NET_WM_CM_S0 " ,
2003-07-05 01:54:05 +00:00
" _NET_WM_DESKTOP " ,
" _NET_WM_ICON " ,
" _NET_WM_ICON_NAME " ,
" _NET_WM_NAME " ,
" _NET_WM_PID " ,
" _NET_WM_PING " ,
" _NET_WM_STATE " ,
2008-12-08 00:01:29 +00:00
" _NET_WM_STATE_ABOVE " ,
" _NET_WM_STATE_BELOW " ,
" _NET_WM_STATE_FULLSCREEN " ,
2013-04-13 23:48:38 +00:00
" _NET_WM_STATE_HIDDEN " ,
2008-12-08 00:01:29 +00:00
" _NET_WM_STATE_MODAL " ,
2003-07-05 01:54:05 +00:00
" _NET_WM_STATE_MAXIMIZED_VERT " ,
" _NET_WM_STATE_MAXIMIZED_HORZ " ,
2008-12-08 00:01:29 +00:00
" _NET_WM_STATE_SKIP_TASKBAR " ,
" _NET_WM_STATE_SKIP_PAGER " ,
" _NET_WM_STATE_STICKY " ,
2004-07-11 13:26:57 +00:00
" _NET_WM_SYNC_REQUEST " ,
" _NET_WM_SYNC_REQUEST_COUNTER " ,
2003-07-05 01:54:05 +00:00
" _NET_WM_WINDOW_TYPE " ,
2013-04-13 23:48:38 +00:00
" _NET_WM_WINDOW_TYPE_COMBO " ,
" _NET_WM_WINDOW_TYPE_DIALOG " ,
" _NET_WM_WINDOW_TYPE_DND " ,
" _NET_WM_WINDOW_TYPE_DROPDOWN_MENU " ,
" _NET_WM_WINDOW_TYPE_MENU " ,
2003-07-05 01:54:05 +00:00
" _NET_WM_WINDOW_TYPE_NORMAL " ,
2013-04-13 23:48:38 +00:00
" _NET_WM_WINDOW_TYPE_POPUP_MENU " ,
" _NET_WM_WINDOW_TYPE_TOOLTIP " ,
" _NET_WM_WINDOW_TYPE_UTILITY " ,
2004-04-18 14:33:07 +00:00
" _NET_WM_USER_TIME " ,
2013-04-13 23:48:38 +00:00
" _NET_WM_USER_TIME_WINDOW " ,
2010-12-15 23:42:38 +00:00
" _NET_VIRTUAL_ROOTS " ,
2011-10-28 22:29:01 +00:00
" GDK_SELECTION " ,
2014-10-29 12:33:08 +00:00
" _NET_WM_STATE_FOCUSED " ,
2020-02-22 15:08:46 +00:00
" GDK_VISUALS " ,
" XdndAware " ,
" XdndProxy " ,
" XdndActionAsk " ,
" XdndActionCopy " ,
" XdndActionLink " ,
" XdndActionList " ,
" XdndActionMove " ,
" XdndActionPrivate " ,
" XdndDrop " ,
" XdndEnter " ,
" XdndFinished " ,
" XdndLeave " ,
" XdndPosition " ,
" XdndSelection " ,
" XdndStatus " ,
" XdndTypeList "
2003-07-05 01:54:05 +00:00
} ;
2010-12-13 18:45:38 +00:00
static char * gdk_sm_client_id ;
2017-12-12 23:43:30 +00:00
static guint signals [ LAST_SIGNAL ] = { 0 } ;
2010-12-20 18:42:53 +00:00
G_DEFINE_TYPE_WITH_CODE ( GdkX11Display , gdk_x11_display , GDK_TYPE_DISPLAY ,
2010-05-25 22:38:44 +00:00
G_IMPLEMENT_INTERFACE ( GDK_TYPE_EVENT_TRANSLATOR ,
2010-12-20 18:20:10 +00:00
gdk_x11_display_event_translator_init ) )
2010-05-25 22:38:44 +00:00
2006-04-04 14:02:03 +00:00
static void
2020-05-12 17:46:40 +00:00
gdk_x11_display_init ( GdkX11Display * self )
2006-04-04 14:02:03 +00:00
{
2020-05-12 17:46:40 +00:00
self - > monitors = g_list_store_new ( GDK_TYPE_MONITOR ) ;
2006-04-04 14:02:03 +00:00
}
Make gtk argument parsing use goption. Add gtk_get_option_group and
2004-09-05 Anders Carlsson <andersca@gnome.org>
* gdk/gdk.c: (gdk_arg_class_cb), (gdk_arg_name_cb),
(gdk_add_option_entries_libgtk_only), (gdk_pre_parse_libgtk_only),
(gdk_parse_args):
* gdk/gdk.h:
* gdk/gdkinternals.h:
* gdk/linux-fb/gdkmain-fb.c: (_gdk_windowing_init):
* gdk/win32/gdkmain-win32.c: (_gdk_windowing_init):
* gdk/x11/gdkdisplay-x11.c: (gdk_display_open):
* gdk/x11/gdkmain-x11.c: (_gdk_windowing_init):
* gtk/gtkmain.c: (gtk_arg_debug_cb), (gtk_arg_no_debug_cb),
(gtk_arg_module_cb), (gtk_arg_warnings_cb),
(do_pre_parse_initialization), (do_post_parse_initialization),
(pre_parse_hook), (post_parse_hook), (gtk_get_option_group),
(gtk_init_with_args), (gtk_parse_args):
* gtk/gtkmain.h:
Make gtk argument parsing use goption. Add gtk_get_option_group and
gtk_init_with_args.
* tests/testtreemodel.c: (main):
Use gtk_init_with_args.
2004-09-05 15:09:55 +00:00
2010-05-25 22:38:44 +00:00
static void
2010-12-20 18:20:10 +00:00
gdk_x11_display_event_translator_init ( GdkEventTranslatorIface * iface )
2010-05-25 22:38:44 +00:00
{
2010-12-20 18:20:10 +00:00
iface - > translate_event = gdk_x11_display_translate_event ;
2010-05-25 22:38:44 +00:00
}
2020-09-10 04:39:03 +00:00
# define ANY_EDGE_TILED (GDK_TOPLEVEL_STATE_LEFT_TILED | \
GDK_TOPLEVEL_STATE_RIGHT_TILED | \
GDK_TOPLEVEL_STATE_TOP_TILED | \
GDK_TOPLEVEL_STATE_BOTTOM_TILED )
2017-10-26 14:51:51 +00:00
2017-08-18 23:09:15 +00:00
static void
2018-03-20 14:14:10 +00:00
do_edge_constraint_state_check ( GdkSurface * surface ,
2020-09-10 04:39:03 +00:00
GdkToplevelState old_state ,
GdkToplevelState * set ,
GdkToplevelState * unset )
2017-08-18 23:09:15 +00:00
{
2018-03-20 14:14:10 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_surface_get_toplevel ( surface ) ;
2020-09-10 04:39:03 +00:00
GdkToplevelState local_set , local_unset ;
2017-08-18 23:09:15 +00:00
guint edge_constraints ;
local_set = * set ;
local_unset = * unset ;
edge_constraints = toplevel - > edge_constraints ;
/* If the WM doesn't support _GTK_EDGE_CONSTRAINTS, rely on the fallback
2017-10-26 14:51:51 +00:00
* implementation . If it supports _GTK_EDGE_CONSTRAINTS , arrange for
2020-09-10 04:39:03 +00:00
* GDK_TOPLEVEL_STATE_TILED to be set if any edge is tiled , and cleared
2017-10-26 14:51:51 +00:00
* if no edge is tiled .
2017-08-18 23:09:15 +00:00
*/
2020-03-09 18:38:08 +00:00
if ( ! gdk_x11_surface_supports_edge_constraints ( surface ) )
2017-08-18 23:09:15 +00:00
{
/* FIXME: we rely on implementation details of mutter here:
* mutter only tiles horizontally , and sets maxvert when it does
* and if it tiles , it always affects all edges
*/
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_TILED )
2017-08-18 23:09:15 +00:00
{
if ( ! toplevel - > have_maxvert )
2020-09-10 04:39:03 +00:00
local_unset | = GDK_TOPLEVEL_STATE_TILED ;
2017-08-18 23:09:15 +00:00
}
else
{
if ( toplevel - > have_maxvert & & ! toplevel - > have_maxhorz )
2020-09-10 04:39:03 +00:00
local_set | = GDK_TOPLEVEL_STATE_TILED ;
2017-08-18 23:09:15 +00:00
}
}
else
{
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_TILED )
2017-10-26 14:51:51 +00:00
{
if ( ! ( edge_constraints & ANY_EDGE_TILED ) )
2020-09-10 04:39:03 +00:00
local_unset | = GDK_TOPLEVEL_STATE_TILED ;
2017-10-26 14:51:51 +00:00
}
else
{
if ( edge_constraints & ANY_EDGE_TILED )
2020-09-10 04:39:03 +00:00
local_set | = GDK_TOPLEVEL_STATE_TILED ;
2017-10-26 14:51:51 +00:00
}
2017-08-18 23:09:15 +00:00
}
/* Top edge */
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_TOP_TILED )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_TOP_TILED ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_TOP_TILED ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_TOP_TILED )
local_set | = GDK_TOPLEVEL_STATE_TOP_TILED ;
2017-08-18 23:09:15 +00:00
}
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_TOP_RESIZABLE )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_TOP_RESIZABLE ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_TOP_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_TOP_RESIZABLE )
local_set | = GDK_TOPLEVEL_STATE_TOP_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
/* Right edge */
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_RIGHT_TILED )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_RIGHT_TILED ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_RIGHT_TILED ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_RIGHT_TILED )
local_set | = GDK_TOPLEVEL_STATE_RIGHT_TILED ;
2017-08-18 23:09:15 +00:00
}
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_RIGHT_RESIZABLE )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_RIGHT_RESIZABLE ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_RIGHT_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_RIGHT_RESIZABLE )
local_set | = GDK_TOPLEVEL_STATE_RIGHT_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
/* Bottom edge */
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_BOTTOM_TILED )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_BOTTOM_TILED ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_BOTTOM_TILED ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_BOTTOM_TILED )
local_set | = GDK_TOPLEVEL_STATE_BOTTOM_TILED ;
2017-08-18 23:09:15 +00:00
}
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE )
local_set | = GDK_TOPLEVEL_STATE_BOTTOM_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
/* Left edge */
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_LEFT_TILED )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_LEFT_TILED ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_LEFT_TILED ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_LEFT_TILED )
local_set | = GDK_TOPLEVEL_STATE_LEFT_TILED ;
2017-08-18 23:09:15 +00:00
}
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_LEFT_RESIZABLE )
2017-08-18 23:09:15 +00:00
{
2020-09-10 04:39:03 +00:00
if ( ( edge_constraints & GDK_TOPLEVEL_STATE_LEFT_RESIZABLE ) = = 0 )
local_unset | = GDK_TOPLEVEL_STATE_LEFT_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
else
{
2020-09-10 04:39:03 +00:00
if ( edge_constraints & GDK_TOPLEVEL_STATE_LEFT_RESIZABLE )
local_set | = GDK_TOPLEVEL_STATE_LEFT_RESIZABLE ;
2017-08-18 23:09:15 +00:00
}
* set = local_set ;
* unset = local_unset ;
}
2010-05-25 22:38:44 +00:00
static void
2018-03-20 14:14:10 +00:00
do_net_wm_state_changes ( GdkSurface * surface )
2010-05-25 22:38:44 +00:00
{
2018-03-20 14:14:10 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_surface_get_toplevel ( surface ) ;
2020-09-10 04:39:03 +00:00
GdkToplevelState old_state , set , unset ;
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
if ( GDK_SURFACE_DESTROYED ( surface ) | |
2020-03-08 20:38:03 +00:00
! GDK_IS_TOPLEVEL ( surface ) )
2010-05-25 22:38:44 +00:00
return ;
2020-03-01 01:43:34 +00:00
old_state = gdk_toplevel_get_state ( GDK_TOPLEVEL ( surface ) ) ;
2010-05-25 22:38:44 +00:00
2014-02-23 02:42:05 +00:00
set = unset = 0 ;
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_FULLSCREEN )
2010-05-25 22:38:44 +00:00
{
if ( ! toplevel - > have_fullscreen )
2020-09-10 04:39:03 +00:00
unset | = GDK_TOPLEVEL_STATE_FULLSCREEN ;
2010-05-25 22:38:44 +00:00
}
else
{
if ( toplevel - > have_fullscreen )
2020-09-10 04:39:03 +00:00
set | = GDK_TOPLEVEL_STATE_FULLSCREEN ;
2010-05-25 22:38:44 +00:00
}
/* Our "maximized" means both vertical and horizontal; if only one,
* we don ' t expose that via GDK
*/
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_MAXIMIZED )
2010-05-25 22:38:44 +00:00
{
if ( ! ( toplevel - > have_maxvert & & toplevel - > have_maxhorz ) )
2020-09-10 04:39:03 +00:00
unset | = GDK_TOPLEVEL_STATE_MAXIMIZED ;
2010-05-25 22:38:44 +00:00
}
else
{
if ( toplevel - > have_maxvert & & toplevel - > have_maxhorz )
2020-09-10 04:39:03 +00:00
set | = GDK_TOPLEVEL_STATE_MAXIMIZED ;
2010-05-25 22:38:44 +00:00
}
2011-10-28 22:29:01 +00:00
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_FOCUSED )
2011-10-28 22:29:01 +00:00
{
if ( ! toplevel - > have_focused )
2020-09-10 04:39:03 +00:00
unset | = GDK_TOPLEVEL_STATE_FOCUSED ;
2011-10-28 22:29:01 +00:00
}
else
{
if ( toplevel - > have_focused )
2020-09-10 04:39:03 +00:00
set | = GDK_TOPLEVEL_STATE_FOCUSED ;
2011-10-28 22:29:01 +00:00
}
2012-02-21 16:14:16 +00:00
2020-09-10 04:39:03 +00:00
if ( old_state & GDK_TOPLEVEL_STATE_MINIMIZED )
2012-02-21 16:14:16 +00:00
{
if ( ! toplevel - > have_hidden )
2020-09-10 04:39:03 +00:00
unset | = GDK_TOPLEVEL_STATE_MINIMIZED ;
2012-02-21 16:14:16 +00:00
}
else
{
if ( toplevel - > have_hidden )
2020-09-10 04:39:03 +00:00
set | = GDK_TOPLEVEL_STATE_MINIMIZED ;
2012-02-21 16:14:16 +00:00
}
2014-02-23 02:42:05 +00:00
2017-08-18 23:09:15 +00:00
/* Update edge constraints and tiling */
2018-03-20 14:14:10 +00:00
do_edge_constraint_state_check ( surface , old_state , & set , & unset ) ;
2017-08-18 23:09:15 +00:00
2018-03-20 14:14:10 +00:00
gdk_synthesize_surface_state ( surface , unset , set ) ;
2010-05-25 22:38:44 +00:00
}
static void
2018-03-20 14:14:10 +00:00
gdk_check_wm_desktop_changed ( GdkSurface * surface )
2010-05-25 22:38:44 +00:00
{
2018-03-20 14:14:10 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_surface_get_toplevel ( surface ) ;
GdkDisplay * display = GDK_SURFACE_DISPLAY ( surface ) ;
2010-05-25 22:38:44 +00:00
Atom type ;
2020-07-24 13:54:49 +00:00
int format ;
2010-05-25 22:38:44 +00:00
gulong nitems ;
gulong bytes_after ;
guchar * data ;
gulong * desktop ;
type = None ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_push ( display ) ;
2010-05-25 22:38:44 +00:00
XGetWindowProperty ( GDK_DISPLAY_XDISPLAY ( display ) ,
2018-03-20 14:14:10 +00:00
GDK_SURFACE_XID ( surface ) ,
2010-05-25 22:38:44 +00:00
gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_DESKTOP " ) ,
0 , G_MAXLONG , False , XA_CARDINAL , & type ,
& format , & nitems ,
& bytes_after , & data ) ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_pop_ignored ( display ) ;
2010-05-25 22:38:44 +00:00
if ( type ! = None )
{
desktop = ( gulong * ) data ;
2011-12-28 16:20:47 +00:00
toplevel - > on_all_desktops = ( ( * desktop & 0xFFFFFFFF ) = = 0xFFFFFFFF ) ;
2010-05-25 22:38:44 +00:00
XFree ( desktop ) ;
}
else
toplevel - > on_all_desktops = FALSE ;
2018-03-20 14:14:10 +00:00
do_net_wm_state_changes ( surface ) ;
2010-05-25 22:38:44 +00:00
}
static void
2018-03-20 14:14:10 +00:00
gdk_check_wm_state_changed ( GdkSurface * surface )
2010-05-25 22:38:44 +00:00
{
2018-03-20 14:14:10 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_surface_get_toplevel ( surface ) ;
GdkDisplay * display = GDK_SURFACE_DISPLAY ( surface ) ;
GdkX11Screen * screen = GDK_SURFACE_SCREEN ( surface ) ;
2010-05-25 22:38:44 +00:00
Atom type ;
2020-07-24 13:54:49 +00:00
int format ;
2010-05-25 22:38:44 +00:00
gulong nitems ;
gulong bytes_after ;
guchar * data ;
Atom * atoms = NULL ;
gulong i ;
toplevel - > have_maxvert = FALSE ;
toplevel - > have_maxhorz = FALSE ;
toplevel - > have_fullscreen = FALSE ;
2011-10-28 22:29:01 +00:00
toplevel - > have_focused = FALSE ;
2012-02-21 16:14:16 +00:00
toplevel - > have_hidden = FALSE ;
2010-05-25 22:38:44 +00:00
type = None ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_push ( display ) ;
2018-03-20 14:14:10 +00:00
XGetWindowProperty ( GDK_DISPLAY_XDISPLAY ( display ) , GDK_SURFACE_XID ( surface ) ,
2010-05-25 22:38:44 +00:00
gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE " ) ,
0 , G_MAXLONG , False , XA_ATOM , & type , & format , & nitems ,
& bytes_after , & data ) ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_pop_ignored ( display ) ;
2010-05-25 22:38:44 +00:00
if ( type ! = None )
{
Atom maxvert_atom = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE_MAXIMIZED_VERT " ) ;
Atom maxhorz_atom = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE_MAXIMIZED_HORZ " ) ;
Atom fullscreen_atom = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE_FULLSCREEN " ) ;
2011-10-28 22:29:01 +00:00
Atom focused_atom = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE_FOCUSED " ) ;
2012-02-21 16:14:16 +00:00
Atom hidden_atom = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE_HIDDEN " ) ;
2010-05-25 22:38:44 +00:00
atoms = ( Atom * ) data ;
i = 0 ;
while ( i < nitems )
{
2020-03-14 05:39:35 +00:00
if ( atoms [ i ] = = maxvert_atom )
2010-05-25 22:38:44 +00:00
toplevel - > have_maxvert = TRUE ;
else if ( atoms [ i ] = = maxhorz_atom )
toplevel - > have_maxhorz = TRUE ;
else if ( atoms [ i ] = = fullscreen_atom )
toplevel - > have_fullscreen = TRUE ;
2011-10-28 22:29:01 +00:00
else if ( atoms [ i ] = = focused_atom )
toplevel - > have_focused = TRUE ;
2012-02-21 16:14:16 +00:00
else if ( atoms [ i ] = = hidden_atom )
toplevel - > have_hidden = TRUE ;
2010-05-25 22:38:44 +00:00
+ + i ;
}
XFree ( atoms ) ;
}
2011-10-28 22:29:01 +00:00
if ( ! gdk_x11_screen_supports_net_wm_hint ( screen ,
2017-12-14 04:39:03 +00:00
g_intern_static_string ( " _NET_WM_STATE_FOCUSED " ) ) )
2011-10-28 22:29:01 +00:00
toplevel - > have_focused = TRUE ;
2020-03-14 05:39:35 +00:00
do_net_wm_state_changes ( surface ) ;
2010-05-25 22:38:44 +00:00
}
2017-08-18 23:09:15 +00:00
static void
2018-03-20 14:14:10 +00:00
gdk_check_edge_constraints_changed ( GdkSurface * surface )
2017-08-18 23:09:15 +00:00
{
2018-03-20 14:14:10 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_surface_get_toplevel ( surface ) ;
GdkDisplay * display = GDK_SURFACE_DISPLAY ( surface ) ;
2017-08-18 23:09:15 +00:00
Atom type ;
2020-07-24 13:54:49 +00:00
int format ;
2017-08-18 23:09:15 +00:00
gulong nitems ;
gulong bytes_after ;
guchar * data ;
gulong * constraints ;
type = None ;
gdk_x11_display_error_trap_push ( display ) ;
XGetWindowProperty ( GDK_DISPLAY_XDISPLAY ( display ) ,
2018-03-20 14:14:10 +00:00
GDK_SURFACE_XID ( surface ) ,
2017-08-18 23:09:15 +00:00
gdk_x11_get_xatom_by_name_for_display ( display , " _GTK_EDGE_CONSTRAINTS " ) ,
0 , G_MAXLONG , False , XA_CARDINAL , & type ,
& format , & nitems ,
& bytes_after , & data ) ;
gdk_x11_display_error_trap_pop_ignored ( display ) ;
if ( type ! = None )
{
constraints = ( gulong * ) data ;
/* The GDK enum for these states does not begin at zero so, to avoid
* messing around with shifts , just make the passed value and GDK ' s
* enum values match by shifting to the first tiled state .
*/
toplevel - > edge_constraints = constraints [ 0 ] < < 9 ;
XFree ( constraints ) ;
}
else
{
toplevel - > edge_constraints = 0 ;
}
2018-03-20 14:14:10 +00:00
do_net_wm_state_changes ( surface ) ;
2017-08-18 23:09:15 +00:00
}
2012-09-19 02:13:06 +00:00
static Window
2017-12-12 23:39:32 +00:00
get_event_xwindow ( const XEvent * xevent )
2010-05-25 22:38:44 +00:00
{
Window xwindow ;
switch ( xevent - > type )
{
case DestroyNotify :
xwindow = xevent - > xdestroywindow . window ;
break ;
case UnmapNotify :
xwindow = xevent - > xunmap . window ;
break ;
case MapNotify :
xwindow = xevent - > xmap . window ;
break ;
case ConfigureNotify :
xwindow = xevent - > xconfigure . window ;
break ;
2012-09-19 02:13:06 +00:00
case ReparentNotify :
xwindow = xevent - > xreparent . window ;
break ;
case GravityNotify :
xwindow = xevent - > xgravity . window ;
break ;
case CirculateNotify :
xwindow = xevent - > xcirculate . window ;
break ;
2010-05-25 22:38:44 +00:00
default :
xwindow = xevent - > xany . window ;
}
2012-09-19 02:13:06 +00:00
return xwindow ;
2010-05-25 22:38:44 +00:00
}
2020-02-15 17:09:31 +00:00
static GdkEvent *
2010-12-20 18:20:10 +00:00
gdk_x11_display_translate_event ( GdkEventTranslator * translator ,
2010-05-25 22:38:44 +00:00
GdkDisplay * display ,
2017-12-12 23:39:32 +00:00
const XEvent * xevent )
2010-05-25 22:38:44 +00:00
{
2012-09-19 02:13:06 +00:00
Window xwindow ;
2018-03-20 14:14:10 +00:00
GdkSurface * surface ;
2012-09-19 02:13:06 +00:00
gboolean is_substructure ;
2019-04-22 01:14:46 +00:00
GdkX11Surface * surface_impl = NULL ;
2010-12-21 01:32:13 +00:00
GdkX11Screen * x11_screen = NULL ;
2010-05-25 22:38:44 +00:00
GdkToplevelX11 * toplevel = NULL ;
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
2020-02-15 17:09:31 +00:00
GdkEvent * event ;
event = NULL ;
2010-05-25 22:38:44 +00:00
2018-03-20 10:40:08 +00:00
/* Find the GdkSurface that this event relates to. If that's
2018-03-20 14:14:10 +00:00
* not the same as the surface that the event was sent to ,
2012-09-19 02:13:06 +00:00
* we are getting an event from SubstructureNotifyMask .
* We ignore such events for internal operation , but we
* need to report them to the application because of
* GDK_SUBSTRUCTURE_MASK ( which should be removed at next
* opportunity . ) The most likely reason for getting these
* events is when we are used in the Metacity or Mutter
* window managers .
2010-05-25 22:38:44 +00:00
*/
2012-09-19 02:13:06 +00:00
xwindow = get_event_xwindow ( xevent ) ;
is_substructure = xwindow ! = xevent - > xany . window ;
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
surface = gdk_x11_surface_lookup_for_display ( display , xwindow ) ;
if ( surface )
2010-05-25 22:38:44 +00:00
{
/* We may receive events such as NoExpose/GraphicsExpose
* and ShmCompletion for pixmaps
*/
2018-03-20 14:14:10 +00:00
if ( ! GDK_IS_SURFACE ( surface ) )
2020-02-15 17:09:31 +00:00
return NULL ;
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
x11_screen = GDK_SURFACE_SCREEN ( surface ) ;
toplevel = _gdk_x11_surface_get_toplevel ( surface ) ;
2019-04-22 01:14:46 +00:00
surface_impl = GDK_X11_SURFACE ( surface ) ;
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
g_object_ref ( surface ) ;
2010-05-25 22:38:44 +00:00
}
2018-03-20 14:14:10 +00:00
if ( surface & & GDK_SURFACE_DESTROYED ( surface ) )
2010-05-25 22:38:44 +00:00
{
if ( xevent - > type ! = DestroyNotify )
2020-02-15 17:09:31 +00:00
goto done ;
2010-05-25 22:38:44 +00:00
}
2012-09-19 02:13:06 +00:00
if ( xevent - > type = = DestroyNotify & & ! is_substructure )
2010-05-25 22:38:44 +00:00
{
2017-11-17 15:18:20 +00:00
x11_screen = GDK_X11_DISPLAY ( display ) - > screen ;
2010-05-25 22:38:44 +00:00
2013-04-04 14:22:12 +00:00
if ( x11_screen - > wmspec_check_window = = xevent - > xdestroywindow . window )
2010-05-25 22:38:44 +00:00
{
2013-04-04 14:22:12 +00:00
x11_screen - > wmspec_check_window = None ;
x11_screen - > last_wmspec_check_time = 0 ;
g_free ( x11_screen - > window_manager_name ) ;
x11_screen - > window_manager_name = g_strdup ( " unknown " ) ;
/* careful, reentrancy */
2017-11-17 15:18:20 +00:00
_gdk_x11_screen_window_manager_changed ( x11_screen ) ;
2013-04-04 14:22:12 +00:00
goto done ;
2010-05-25 22:38:44 +00:00
}
}
/* We do a "manual" conversion of the XEvent to a
* GdkEvent . The structures are mostly the same so
* the conversion is fairly straightforward . We also
* optionally print debugging info regarding events
* received .
*/
switch ( xevent - > type )
{
case KeymapNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS , g_message ( " keymap notify " ) ) ;
2010-05-25 22:38:44 +00:00
/* Not currently handled */
break ;
case Expose :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2020-02-18 03:18:56 +00:00
g_message ( " expose: \t \t window: %ld %d x,y: %d %d w,h: %d %d " ,
2010-05-25 22:38:44 +00:00
xevent - > xexpose . window , xevent - > xexpose . count ,
xevent - > xexpose . x , xevent - > xexpose . y ,
2020-02-18 03:18:56 +00:00
xevent - > xexpose . width , xevent - > xexpose . height ) ) ;
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
if ( surface = = NULL )
2020-02-15 17:09:31 +00:00
break ;
2010-05-25 22:38:44 +00:00
{
GdkRectangle expose_rect ;
2013-06-20 09:40:07 +00:00
int x2 , y2 ;
2010-05-25 22:38:44 +00:00
2018-03-20 11:05:26 +00:00
expose_rect . x = xevent - > xexpose . x / surface_impl - > surface_scale ;
expose_rect . y = xevent - > xexpose . y / surface_impl - > surface_scale ;
2013-06-20 09:40:07 +00:00
2018-03-20 11:05:26 +00:00
x2 = ( xevent - > xexpose . x + xevent - > xexpose . width + surface_impl - > surface_scale - 1 ) / surface_impl - > surface_scale ;
2013-06-20 09:40:07 +00:00
expose_rect . width = x2 - expose_rect . x ;
2018-03-20 11:05:26 +00:00
y2 = ( xevent - > xexpose . y + xevent - > xexpose . height + surface_impl - > surface_scale - 1 ) / surface_impl - > surface_scale ;
2013-06-20 09:40:07 +00:00
expose_rect . height = y2 - expose_rect . y ;
2010-05-25 22:38:44 +00:00
2018-03-21 03:07:37 +00:00
gdk_surface_invalidate_rect ( surface , & expose_rect ) ;
2010-05-25 22:38:44 +00:00
}
break ;
case GraphicsExpose :
{
GdkRectangle expose_rect ;
2013-06-20 09:40:07 +00:00
int x2 , y2 ;
2010-05-25 22:38:44 +00:00
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " graphics expose: \t drawable: %ld " ,
xevent - > xgraphicsexpose . drawable ) ) ;
2018-03-20 14:14:10 +00:00
if ( surface = = NULL )
2020-02-15 17:09:31 +00:00
break ;
2010-05-25 22:38:44 +00:00
2018-03-20 11:05:26 +00:00
expose_rect . x = xevent - > xgraphicsexpose . x / surface_impl - > surface_scale ;
expose_rect . y = xevent - > xgraphicsexpose . y / surface_impl - > surface_scale ;
2013-06-20 09:40:07 +00:00
2018-03-20 11:05:26 +00:00
x2 = ( xevent - > xgraphicsexpose . x + xevent - > xgraphicsexpose . width + surface_impl - > surface_scale - 1 ) / surface_impl - > surface_scale ;
2013-06-20 09:40:07 +00:00
expose_rect . width = x2 - expose_rect . x ;
2018-03-20 11:05:26 +00:00
y2 = ( xevent - > xgraphicsexpose . y + xevent - > xgraphicsexpose . height + surface_impl - > surface_scale - 1 ) / surface_impl - > surface_scale ;
2013-06-20 09:40:07 +00:00
expose_rect . height = y2 - expose_rect . y ;
2010-05-25 22:38:44 +00:00
2018-03-21 03:07:37 +00:00
gdk_surface_invalidate_rect ( surface , & expose_rect ) ;
2010-05-25 22:38:44 +00:00
}
break ;
case VisibilityNotify :
# ifdef G_ENABLE_DEBUG
2018-01-12 00:48:27 +00:00
if ( GDK_DISPLAY_DEBUG_CHECK ( display , EVENTS ) )
2010-05-25 22:38:44 +00:00
switch ( xevent - > xvisibility . state )
{
case VisibilityFullyObscured :
g_message ( " visibility notify: \t window: %ld none " ,
xevent - > xvisibility . window ) ;
break ;
case VisibilityPartiallyObscured :
g_message ( " visibility notify: \t window: %ld partial " ,
xevent - > xvisibility . window ) ;
break ;
case VisibilityUnobscured :
g_message ( " visibility notify: \t window: %ld full " ,
xevent - > xvisibility . window ) ;
break ;
2017-10-06 19:19:42 +00:00
default :
break ;
2010-05-25 22:38:44 +00:00
}
# endif /* G_ENABLE_DEBUG */
2017-11-01 20:59:45 +00:00
/* not handled */
2010-05-25 22:38:44 +00:00
break ;
case CreateNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " create notify: \t window: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d " ,
xevent - > xcreatewindow . window ,
xevent - > xcreatewindow . x ,
xevent - > xcreatewindow . y ,
xevent - > xcreatewindow . width ,
xevent - > xcreatewindow . height ,
xevent - > xcreatewindow . border_width ,
xevent - > xcreatewindow . parent ,
xevent - > xcreatewindow . override_redirect ) ) ;
/* not really handled */
break ;
case DestroyNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " destroy notify: \t window: %ld " ,
xevent - > xdestroywindow . window ) ) ;
2012-09-19 02:13:06 +00:00
if ( ! is_substructure )
2010-05-25 22:38:44 +00:00
{
2020-08-03 02:43:48 +00:00
if ( surface )
event = gdk_delete_event_new ( surface ) ;
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
if ( surface & & GDK_SURFACE_XID ( surface ) ! = x11_screen - > xroot_window )
gdk_surface_destroy_notify ( surface ) ;
2010-05-25 22:38:44 +00:00
}
break ;
case UnmapNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " unmap notify: \t \t window: %ld " ,
xevent - > xmap . window ) ) ;
2018-03-20 14:14:10 +00:00
if ( surface & & ! is_substructure )
2012-09-19 02:13:06 +00:00
{
/* If the WM supports the _NET_WM_STATE_HIDDEN hint, we do not want to
* interpret UnmapNotify events as implying iconic state .
* http : //bugzilla.gnome.org/show_bug.cgi?id=590726.
2012-02-21 16:14:16 +00:00
*/
2017-11-17 15:18:20 +00:00
if ( x11_screen & &
! gdk_x11_screen_supports_net_wm_hint ( x11_screen ,
2017-12-14 04:39:03 +00:00
g_intern_static_string ( " _NET_WM_STATE_HIDDEN " ) ) )
2012-09-19 02:13:06 +00:00
{
/* If we are shown (not withdrawn) and get an unmap, it means we were
* iconified in the X sense . If we are withdrawn , and get an unmap , it
* means we hid the window ourselves , so we will have already flipped
2019-11-16 19:50:57 +00:00
* the minimized bit off .
2012-09-19 02:13:06 +00:00
*/
2018-03-20 14:14:10 +00:00
if ( GDK_SURFACE_IS_MAPPED ( surface ) )
gdk_synthesize_surface_state ( surface ,
2019-11-16 19:50:57 +00:00
0 ,
2020-09-10 04:39:03 +00:00
GDK_TOPLEVEL_STATE_MINIMIZED ) ;
2012-09-19 02:13:06 +00:00
}
2010-05-25 22:38:44 +00:00
2018-03-20 11:05:26 +00:00
if ( surface_impl - > toplevel & &
surface_impl - > toplevel - > frame_pending )
2012-09-18 13:37:03 +00:00
{
2018-03-20 11:05:26 +00:00
surface_impl - > toplevel - > frame_pending = FALSE ;
2020-02-22 16:41:29 +00:00
gdk_surface_thaw_updates ( surface ) ;
2012-09-18 13:37:03 +00:00
}
2012-10-04 00:13:42 +00:00
if ( toplevel )
2019-05-19 02:53:17 +00:00
gdk_surface_freeze_updates ( surface ) ;
2012-10-04 00:13:42 +00:00
2018-03-20 14:14:10 +00:00
_gdk_x11_surface_grab_check_unmap ( surface , xevent - > xany . serial ) ;
2020-02-12 11:44:43 +00:00
2020-08-19 22:49:34 +00:00
gdk_profiler_add_markf ( GDK_PROFILER_CURRENT_TIME , 0 , " unmapped window " , " 0x%lx " , GDK_SURFACE_XID ( surface ) ) ;
2012-09-19 02:13:06 +00:00
}
2012-05-16 21:18:51 +00:00
2010-05-25 22:38:44 +00:00
break ;
case MapNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " map notify: \t \t window: %ld " ,
xevent - > xmap . window ) ) ;
2018-03-20 14:14:10 +00:00
if ( surface & & ! is_substructure )
2012-09-19 02:13:06 +00:00
{
2019-11-16 19:50:57 +00:00
/* Unset minimized if it was set */
2020-09-10 04:39:03 +00:00
if ( surface - > state & GDK_TOPLEVEL_STATE_MINIMIZED )
2018-03-20 14:14:10 +00:00
gdk_synthesize_surface_state ( surface ,
2020-09-10 04:39:03 +00:00
GDK_TOPLEVEL_STATE_MINIMIZED ,
2019-11-16 19:50:57 +00:00
0 ) ;
2012-10-04 00:13:42 +00:00
if ( toplevel )
2019-05-19 02:53:17 +00:00
gdk_surface_thaw_updates ( surface ) ;
2020-02-12 11:44:43 +00:00
if ( GDK_PROFILER_IS_RUNNING )
{
2020-02-12 13:26:16 +00:00
gdk_profiler_end_markf ( surface_impl - > map_time , " mapped window " , " 0x%lx " , GDK_SURFACE_XID ( surface ) ) ;
2020-02-12 11:44:43 +00:00
surface_impl - > map_time = 0 ;
}
2012-09-19 02:13:06 +00:00
}
2010-05-25 22:38:44 +00:00
break ;
case ReparentNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " reparent notify: \t window: %ld x,y: %d %d parent: %ld ovr: %d " ,
xevent - > xreparent . window ,
xevent - > xreparent . x ,
xevent - > xreparent . y ,
xevent - > xreparent . parent ,
xevent - > xreparent . override_redirect ) ) ;
/* Not currently handled */
break ;
case ConfigureNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " configure notify: \t window: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s " ,
xevent - > xconfigure . window ,
xevent - > xconfigure . x ,
xevent - > xconfigure . y ,
xevent - > xconfigure . width ,
xevent - > xconfigure . height ,
xevent - > xconfigure . border_width ,
xevent - > xconfigure . above ,
xevent - > xconfigure . override_redirect ,
2019-03-22 18:24:39 +00:00
! surface ? " (discarding) " : " " ) ) ;
2017-11-13 21:47:50 +00:00
if ( _gdk_x11_display_is_root_window ( display , xevent - > xconfigure . window ) )
2010-05-25 22:38:44 +00:00
{
2017-11-17 15:18:20 +00:00
_gdk_x11_screen_size_changed ( x11_screen , xevent ) ;
2010-05-25 22:38:44 +00:00
}
# ifdef HAVE_XSYNC
2012-09-18 13:31:17 +00:00
if ( ! is_substructure & & toplevel & & display_x11 - > use_sync & & toplevel - > pending_counter_value ! = 0 )
2010-05-25 22:38:44 +00:00
{
2012-09-18 13:31:17 +00:00
toplevel - > configure_counter_value = toplevel - > pending_counter_value ;
2012-12-19 17:01:52 +00:00
toplevel - > configure_counter_value_is_extended = toplevel - > pending_counter_value_is_extended ;
2012-09-18 13:31:17 +00:00
toplevel - > pending_counter_value = 0 ;
2010-05-25 22:38:44 +00:00
}
# endif
2020-02-15 17:09:31 +00:00
if ( surface & &
xevent - > xconfigure . event = = xevent - > xconfigure . window )
{
int x , y ;
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
int c_w = ( xevent - > xconfigure . width + surface_impl - > surface_scale - 1 ) / surface_impl - > surface_scale ;
int c_h = ( xevent - > xconfigure . height + surface_impl - > surface_scale - 1 ) / surface_impl - > surface_scale ;
2020-02-15 17:09:31 +00:00
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
event = gdk_configure_event_new ( surface , c_w , c_h ) ;
2010-05-25 22:38:44 +00:00
if ( ! xevent - > xconfigure . send_event & &
! xevent - > xconfigure . override_redirect & &
2018-03-20 14:14:10 +00:00
! GDK_SURFACE_DESTROYED ( surface ) )
2010-05-25 22:38:44 +00:00
{
2020-07-24 13:54:49 +00:00
int tx = 0 ;
int ty = 0 ;
2010-05-25 22:38:44 +00:00
Window child_window = 0 ;
2020-02-15 17:09:31 +00:00
x = y = 0 ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_push ( display ) ;
2018-03-20 14:14:10 +00:00
if ( XTranslateCoordinates ( GDK_SURFACE_XDISPLAY ( surface ) ,
GDK_SURFACE_XID ( surface ) ,
2010-12-21 01:32:13 +00:00
x11_screen - > xroot_window ,
2010-05-25 22:38:44 +00:00
0 , 0 ,
& tx , & ty ,
& child_window ) )
{
2020-02-15 17:09:31 +00:00
x = tx / surface_impl - > surface_scale ;
y = ty / surface_impl - > surface_scale ;
2010-05-25 22:38:44 +00:00
}
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_pop_ignored ( display ) ;
2010-05-25 22:38:44 +00:00
}
else
{
2020-02-15 17:09:31 +00:00
x = xevent - > xconfigure . x / surface_impl - > surface_scale ;
y = xevent - > xconfigure . y / surface_impl - > surface_scale ;
2010-05-25 22:38:44 +00:00
}
2012-09-19 02:13:06 +00:00
if ( ! is_substructure )
{
2020-02-15 23:28:01 +00:00
int new_abs_x , new_abs_y ;
2020-02-15 17:09:31 +00:00
new_abs_x = x ;
new_abs_y = y ;
2020-02-15 23:28:01 +00:00
surface_impl - > abs_x = new_abs_x ;
surface_impl - > abs_y = new_abs_y ;
if ( surface - > parent )
2019-04-22 15:22:33 +00:00
{
2020-02-15 23:28:01 +00:00
GdkX11Surface * parent_impl =
GDK_X11_SURFACE ( surface - > parent ) ;
surface - > x = new_abs_x - parent_impl - > abs_x ;
surface - > y = new_abs_y - parent_impl - > abs_y ;
2019-04-22 15:22:33 +00:00
}
2010-05-25 22:38:44 +00:00
2018-03-20 11:05:26 +00:00
if ( surface_impl - > unscaled_width ! = xevent - > xconfigure . width | |
surface_impl - > unscaled_height ! = xevent - > xconfigure . height )
2014-11-27 01:07:56 +00:00
{
2018-03-20 11:05:26 +00:00
surface_impl - > unscaled_width = xevent - > xconfigure . width ;
surface_impl - > unscaled_height = xevent - > xconfigure . height ;
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
gdk_configure_event_get_size ( event , & surface - > width , & surface - > height ) ;
2014-11-27 01:07:56 +00:00
2018-03-20 14:14:10 +00:00
_gdk_surface_update_size ( surface ) ;
2018-03-20 11:05:26 +00:00
_gdk_x11_surface_update_size ( surface_impl ) ;
2014-11-27 01:07:56 +00:00
}
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
if ( surface - > resize_count > = 1 )
2012-09-19 02:13:06 +00:00
{
2018-03-20 14:14:10 +00:00
surface - > resize_count - = 1 ;
2010-05-25 22:38:44 +00:00
2018-03-20 14:14:10 +00:00
if ( surface - > resize_count = = 0 )
_gdk_x11_moveresize_configure_done ( display , surface ) ;
2018-07-15 23:52:28 +00:00
}
2019-04-22 15:22:33 +00:00
gdk_x11_surface_update_popups ( surface ) ;
2020-04-16 10:58:39 +00:00
gdk_x11_surface_enter_leave_monitors ( surface ) ;
2012-09-19 02:13:06 +00:00
}
2010-12-15 22:55:04 +00:00
}
2010-05-25 22:38:44 +00:00
break ;
case PropertyNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " property notify: \t window: %ld, atom(%ld): %s%s%s " ,
xevent - > xproperty . window ,
xevent - > xproperty . atom ,
" \" " ,
gdk_x11_get_xatom_name_for_display ( display , xevent - > xproperty . atom ) ,
" \" " ) ) ;
2018-03-20 14:14:10 +00:00
if ( surface = = NULL )
2020-02-15 17:09:31 +00:00
break ;
2010-05-25 22:38:44 +00:00
/* We compare with the serial of the last time we mapped the
* window to avoid refetching properties that we set ourselves
*/
if ( toplevel & &
xevent - > xproperty . serial > = toplevel - > map_serial )
{
if ( xevent - > xproperty . atom = = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE " ) )
2018-03-20 14:14:10 +00:00
gdk_check_wm_state_changed ( surface ) ;
2010-05-25 22:38:44 +00:00
if ( xevent - > xproperty . atom = = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_DESKTOP " ) )
2018-03-20 14:14:10 +00:00
gdk_check_wm_desktop_changed ( surface ) ;
2017-08-18 23:09:15 +00:00
if ( xevent - > xproperty . atom = = gdk_x11_get_xatom_by_name_for_display ( display , " _GTK_EDGE_CONSTRAINTS " ) )
2018-03-20 14:14:10 +00:00
gdk_check_edge_constraints_changed ( surface ) ;
2010-05-25 22:38:44 +00:00
}
break ;
case ColormapNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " colormap notify: \t window: %ld " ,
xevent - > xcolormap . window ) ) ;
/* Not currently handled */
break ;
case ClientMessage :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2011-02-01 05:30:27 +00:00
g_message ( " client message: \t window: %ld " ,
xevent - > xclient . window ) ) ;
2010-05-25 22:38:44 +00:00
2011-02-01 05:30:27 +00:00
/* Not currently handled */
2010-05-25 22:38:44 +00:00
break ;
case MappingNotify :
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " mapping notify " ) ) ;
/* Let XLib know that there is a new keyboard mapping.
*/
2017-12-12 23:39:32 +00:00
XRefreshKeyboardMapping ( ( XMappingEvent * ) xevent ) ;
2010-12-16 04:49:31 +00:00
_gdk_x11_keymap_keys_changed ( display ) ;
2010-05-25 22:38:44 +00:00
break ;
default :
# ifdef HAVE_RANDR
if ( xevent - > type - display_x11 - > xrandr_event_base = = RRScreenChangeNotify | |
xevent - > type - display_x11 - > xrandr_event_base = = RRNotify )
{
2017-11-17 15:18:20 +00:00
if ( x11_screen )
_gdk_x11_screen_size_changed ( x11_screen , xevent ) ;
2010-05-25 22:38:44 +00:00
}
else
# endif
# ifdef HAVE_XKB
if ( xevent - > type = = display_x11 - > xkb_event_type )
{
XkbEvent * xkb_event = ( XkbEvent * ) xevent ;
switch ( xkb_event - > any . xkb_type )
{
case XkbNewKeyboardNotify :
case XkbMapNotify :
2010-12-16 04:49:31 +00:00
_gdk_x11_keymap_keys_changed ( display ) ;
2010-05-25 22:38:44 +00:00
break ;
case XkbStateNotify :
2010-12-16 04:49:31 +00:00
_gdk_x11_keymap_state_changed ( display , xevent ) ;
2010-05-25 22:38:44 +00:00
break ;
2017-10-06 19:19:42 +00:00
default :
break ;
2010-05-25 22:38:44 +00:00
}
}
# endif
}
done :
2018-03-20 14:14:10 +00:00
if ( surface )
g_object_unref ( surface ) ;
2010-05-25 22:38:44 +00:00
2020-02-15 17:09:31 +00:00
return event ;
2010-05-25 22:38:44 +00:00
}
2012-11-14 17:49:06 +00:00
static GdkFrameTimings *
find_frame_timings ( GdkFrameClock * clock ,
guint64 serial )
{
gint64 start_frame , end_frame , i ;
2013-02-12 20:03:21 +00:00
start_frame = gdk_frame_clock_get_history_start ( clock ) ;
2013-02-12 20:47:38 +00:00
end_frame = gdk_frame_clock_get_frame_counter ( clock ) ;
2012-11-14 17:49:06 +00:00
for ( i = end_frame ; i > = start_frame ; i - - )
{
2013-02-12 20:47:38 +00:00
GdkFrameTimings * timings = gdk_frame_clock_get_timings ( clock , i ) ;
2012-11-14 17:49:06 +00:00
2013-02-12 21:14:24 +00:00
if ( timings - > cookie = = serial )
2012-11-14 17:49:06 +00:00
return timings ;
}
return NULL ;
}
2015-07-15 16:38:38 +00:00
/* _NET_WM_FRAME_DRAWN and _NET_WM_FRAME_TIMINGS messages represent time
* as a " high resolution server time " - this is the server time interpolated
* to microsecond resolution . The advantage of this time representation
* is that if X server is running on the same computer as a client , and
* the Xserver uses ' clock_gettime ( CLOCK_MONOTONIC , . . . ) ' for the server
* time , the client can detect this , and all such clients will share a
* a time representation with high accuracy . If there is not a common
* time source , then the time synchronization will be less accurate .
*/
2017-04-28 21:55:47 +00:00
static gint64
2015-07-15 16:38:38 +00:00
server_time_to_monotonic_time ( GdkX11Display * display_x11 ,
gint64 server_time )
{
if ( display_x11 - > server_time_query_time = = 0 | |
( ! display_x11 - > server_time_is_monotonic_time & &
server_time > display_x11 - > server_time_query_time + 10 * 1000 * 1000 ) ) /* 10 seconds */
{
2018-03-20 10:40:08 +00:00
gint64 current_server_time = gdk_x11_get_server_time ( display_x11 - > leader_gdk_surface ) ;
2015-07-15 16:38:38 +00:00
gint64 current_server_time_usec = ( gint64 ) current_server_time * 1000 ;
gint64 current_monotonic_time = g_get_monotonic_time ( ) ;
display_x11 - > server_time_query_time = current_monotonic_time ;
/* If the server time is within a second of the monotonic time,
* we assume that they are identical . This seems like a big margin ,
* but we want to be as robust as possible even if the system
* is under load and our processing of the server response is
* delayed .
*/
if ( current_server_time_usec > current_monotonic_time - 1000 * 1000 & &
current_server_time_usec < current_monotonic_time + 1000 * 1000 )
display_x11 - > server_time_is_monotonic_time = TRUE ;
display_x11 - > server_time_offset = current_server_time_usec - current_monotonic_time ;
}
if ( display_x11 - > server_time_is_monotonic_time )
return server_time ;
else
return server_time - display_x11 - > server_time_offset ;
}
2011-02-01 04:31:41 +00:00
GdkFilterReturn
2020-02-15 15:43:29 +00:00
_gdk_wm_protocols_filter ( const XEvent * xevent ,
GdkSurface * win ,
GdkEvent * * event ,
gpointer data )
2010-05-25 22:38:44 +00:00
{
GdkDisplay * display ;
Atom atom ;
2018-03-20 10:40:08 +00:00
if ( ! GDK_IS_X11_SURFACE ( win ) | | GDK_SURFACE_DESTROYED ( win ) )
2011-02-01 04:31:41 +00:00
return GDK_FILTER_CONTINUE ;
if ( xevent - > type ! = ClientMessage )
return GDK_FILTER_CONTINUE ;
2010-05-25 22:38:44 +00:00
2018-03-20 10:40:08 +00:00
display = GDK_SURFACE_DISPLAY ( win ) ;
2011-02-01 04:31:41 +00:00
2012-11-14 17:49:06 +00:00
/* This isn't actually WM_PROTOCOLS because that wouldn't leave enough space
* in the message for everything that gets stuffed in */
if ( xevent - > xclient . message_type = = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_FRAME_DRAWN " ) )
{
2019-04-22 01:14:46 +00:00
GdkX11Surface * surface_impl ;
surface_impl = GDK_X11_SURFACE ( win ) ;
2018-03-20 11:05:26 +00:00
if ( surface_impl - > toplevel )
2012-11-14 17:49:06 +00:00
{
guint32 d0 = xevent - > xclient . data . l [ 0 ] ;
guint32 d1 = xevent - > xclient . data . l [ 1 ] ;
guint32 d2 = xevent - > xclient . data . l [ 2 ] ;
guint32 d3 = xevent - > xclient . data . l [ 3 ] ;
2012-12-19 17:01:52 +00:00
guint64 serial = ( ( guint64 ) d1 < < 32 ) | d0 ;
2015-07-15 16:38:38 +00:00
gint64 frame_drawn_time = server_time_to_monotonic_time ( GDK_X11_DISPLAY ( display ) , ( ( guint64 ) d3 < < 32 ) | d2 ) ;
2012-11-15 19:11:41 +00:00
gint64 refresh_interval , presentation_time ;
2012-11-14 17:49:06 +00:00
2018-03-20 10:40:08 +00:00
GdkFrameClock * clock = gdk_surface_get_frame_clock ( win ) ;
2012-11-14 17:49:06 +00:00
GdkFrameTimings * timings = find_frame_timings ( clock , serial ) ;
if ( timings )
2013-02-12 21:14:24 +00:00
timings - > drawn_time = frame_drawn_time ;
2012-11-14 17:49:06 +00:00
2020-06-30 18:15:53 +00:00
if ( ! surface_impl - > toplevel - > frame_still_painting & & surface_impl - > toplevel - > frame_pending )
2012-11-14 17:49:06 +00:00
{
2018-03-20 11:05:26 +00:00
surface_impl - > toplevel - > frame_pending = FALSE ;
2020-02-15 15:43:29 +00:00
gdk_surface_thaw_updates ( win ) ;
2012-11-14 17:49:06 +00:00
}
2012-11-15 19:11:41 +00:00
gdk_frame_clock_get_refresh_info ( clock ,
frame_drawn_time ,
& refresh_interval ,
& presentation_time ) ;
if ( presentation_time ! = 0 )
2018-03-20 11:05:26 +00:00
surface_impl - > toplevel - > throttled_presentation_time = presentation_time + refresh_interval ;
2012-11-14 17:49:06 +00:00
}
return GDK_FILTER_REMOVE ;
}
if ( xevent - > xclient . message_type = = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_FRAME_TIMINGS " ) )
{
2019-04-22 01:14:46 +00:00
GdkX11Surface * surface_impl ;
surface_impl = GDK_X11_SURFACE ( win ) ;
2018-03-20 11:05:26 +00:00
if ( surface_impl - > toplevel )
2012-11-14 17:49:06 +00:00
{
guint32 d0 = xevent - > xclient . data . l [ 0 ] ;
guint32 d1 = xevent - > xclient . data . l [ 1 ] ;
guint32 d2 = xevent - > xclient . data . l [ 2 ] ;
guint32 d3 = xevent - > xclient . data . l [ 3 ] ;
2012-12-19 17:01:52 +00:00
guint64 serial = ( ( guint64 ) d1 < < 32 ) | d0 ;
2012-11-14 17:49:06 +00:00
2018-03-20 10:40:08 +00:00
GdkFrameClock * clock = gdk_surface_get_frame_clock ( win ) ;
2012-11-14 17:49:06 +00:00
GdkFrameTimings * timings = find_frame_timings ( clock , serial ) ;
if ( timings )
{
gint32 presentation_time_offset = ( gint32 ) d2 ;
gint32 refresh_interval = d3 ;
2013-02-12 21:14:24 +00:00
if ( timings - > drawn_time & & presentation_time_offset )
timings - > presentation_time = timings - > drawn_time + presentation_time_offset ;
2012-11-14 17:49:06 +00:00
if ( refresh_interval )
2013-02-12 21:14:24 +00:00
timings - > refresh_interval = refresh_interval ;
2012-11-14 17:49:06 +00:00
2013-02-12 21:14:24 +00:00
timings - > complete = TRUE ;
2012-11-15 00:21:33 +00:00
# ifdef G_ENABLE_DEBUG
2018-01-12 00:48:27 +00:00
if ( GDK_DISPLAY_DEBUG_CHECK ( display , FRAMES ) )
2013-02-12 20:47:38 +00:00
_gdk_frame_clock_debug_print_timings ( clock , timings ) ;
2019-05-16 19:08:34 +00:00
2020-02-12 10:05:01 +00:00
if ( GDK_PROFILER_IS_RUNNING )
2019-05-16 19:08:34 +00:00
_gdk_frame_clock_add_timings_to_profiler ( clock , timings ) ;
2012-11-15 00:21:33 +00:00
# endif /* G_ENABLE_DEBUG */
2012-11-14 17:49:06 +00:00
}
}
}
2011-02-01 04:31:41 +00:00
if ( xevent - > xclient . message_type ! = gdk_x11_get_xatom_by_name_for_display ( display , " WM_PROTOCOLS " ) )
return GDK_FILTER_CONTINUE ;
atom = ( Atom ) xevent - > xclient . data . l [ 0 ] ;
2010-05-25 22:38:44 +00:00
if ( atom = = gdk_x11_get_xatom_by_name_for_display ( display , " WM_DELETE_WINDOW " ) )
{
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
/* The delete window request specifies a window
* to delete . We don ' t actually destroy the
* window because " it is only a request " . ( The
* window might contain vital data that the
* program does not want destroyed ) . Instead
* the event is passed along to the program ,
* which should then destroy the window .
*/
2018-01-12 00:48:27 +00:00
GDK_DISPLAY_NOTE ( display , EVENTS ,
2010-05-25 22:38:44 +00:00
g_message ( " delete window: \t \t window: %ld " ,
xevent - > xclient . window ) ) ;
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
* event = gdk_delete_event_new ( win ) ;
2010-05-25 22:38:44 +00:00
2018-03-20 10:40:08 +00:00
gdk_x11_surface_set_user_time ( win , xevent - > xclient . data . l [ 1 ] ) ;
2010-05-25 22:38:44 +00:00
return GDK_FILTER_TRANSLATE ;
}
else if ( atom = = gdk_x11_get_xatom_by_name_for_display ( display , " WM_TAKE_FOCUS " ) )
{
2018-03-20 10:40:08 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_surface_get_toplevel ( win ) ;
2010-05-25 22:38:44 +00:00
/* There is no way of knowing reliably whether we are viewable;
2011-02-27 03:13:06 +00:00
* so trap errors asynchronously around the XSetInputFocus call
2010-05-25 22:38:44 +00:00
*/
2020-03-14 14:06:57 +00:00
if ( toplevel )
2011-02-27 03:13:06 +00:00
{
gdk_x11_display_error_trap_push ( display ) ;
XSetInputFocus ( GDK_DISPLAY_XDISPLAY ( display ) ,
toplevel - > focus_window ,
RevertToParent ,
xevent - > xclient . data . l [ 1 ] ) ;
gdk_x11_display_error_trap_pop_ignored ( display ) ;
}
2010-05-25 22:38:44 +00:00
return GDK_FILTER_REMOVE ;
}
else if ( atom = = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_PING " ) & &
2017-11-13 21:39:54 +00:00
! _gdk_x11_display_is_root_window ( display , xevent - > xclient . window ) )
2010-05-25 22:38:44 +00:00
{
XClientMessageEvent xclient = xevent - > xclient ;
2018-03-20 10:40:08 +00:00
xclient . window = GDK_SURFACE_XROOTWIN ( win ) ;
XSendEvent ( GDK_SURFACE_XDISPLAY ( win ) ,
2010-05-25 22:38:44 +00:00
xclient . window ,
False ,
SubstructureRedirectMask | SubstructureNotifyMask , ( XEvent * ) & xclient ) ;
return GDK_FILTER_REMOVE ;
}
else if ( atom = = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_SYNC_REQUEST " ) & &
2010-12-20 18:20:10 +00:00
GDK_X11_DISPLAY ( display ) - > use_sync )
2010-05-25 22:38:44 +00:00
{
2018-03-20 10:40:08 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_surface_get_toplevel ( win ) ;
2010-05-25 22:38:44 +00:00
if ( toplevel )
{
# ifdef HAVE_XSYNC
2012-09-18 13:31:17 +00:00
toplevel - > pending_counter_value = xevent - > xclient . data . l [ 2 ] + ( ( gint64 ) xevent - > xclient . data . l [ 3 ] < < 32 ) ;
2012-12-19 17:01:52 +00:00
toplevel - > pending_counter_value_is_extended = xevent - > xclient . data . l [ 4 ] ! = 0 ;
2010-05-25 22:38:44 +00:00
# endif
}
return GDK_FILTER_REMOVE ;
}
return GDK_FILTER_CONTINUE ;
}
static void
2010-12-11 00:42:09 +00:00
gdk_event_init ( GdkDisplay * display )
2010-05-25 22:38:44 +00:00
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2010-05-25 22:38:44 +00:00
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-12-15 17:25:38 +00:00
display_x11 - > event_source = gdk_x11_event_source_new ( display ) ;
2010-05-25 22:38:44 +00:00
2010-12-15 17:25:38 +00:00
gdk_x11_event_source_add_translator ( ( GdkEventSource * ) display_x11 - > event_source ,
GDK_EVENT_TRANSLATOR ( display ) ) ;
2010-05-25 22:38:44 +00:00
2010-12-15 17:25:38 +00:00
gdk_x11_event_source_add_translator ( ( GdkEventSource * ) display_x11 - > event_source ,
2017-11-24 14:14:17 +00:00
GDK_EVENT_TRANSLATOR ( display_x11 - > device_manager ) ) ;
2010-05-25 22:38:44 +00:00
}
2010-12-13 18:45:38 +00:00
static void
set_sm_client_id ( GdkDisplay * display ,
2020-07-24 18:40:36 +00:00
const char * sm_client_id )
2010-12-13 18:45:38 +00:00
{
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-12-13 18:45:38 +00:00
if ( gdk_display_is_closed ( display ) )
return ;
if ( sm_client_id & & strcmp ( sm_client_id , " " ) )
XChangeProperty ( display_x11 - > xdisplay , display_x11 - > leader_window ,
gdk_x11_get_xatom_by_name_for_display ( display , " SM_CLIENT_ID " ) ,
XA_STRING , 8 , PropModeReplace , ( guchar * ) sm_client_id ,
strlen ( sm_client_id ) ) ;
else
XDeleteProperty ( display_x11 - > xdisplay , display_x11 - > leader_window ,
gdk_x11_get_xatom_by_name_for_display ( display , " SM_CLIENT_ID " ) ) ;
}
2016-11-03 22:40:54 +00:00
void
gdk_display_setup_window_visual ( GdkDisplay * display ,
2020-07-24 13:54:49 +00:00
int depth ,
2016-11-03 22:40:54 +00:00
Visual * visual ,
Colormap colormap ,
gboolean rgba )
{
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
display_x11 - > window_depth = depth ;
display_x11 - > window_visual = visual ;
display_x11 - > window_colormap = colormap ;
gdk_display_set_rgba ( display , rgba ) ;
}
2017-11-01 14:31:36 +00:00
/**
* gdk_x11_display_open :
* @ display_name : ( allow - none ) : name of the X display .
* See the XOpenDisplay ( ) for details .
*
* Tries to open a new display to the X server given by
* @ display_name . If opening the display fails , % NULL is
* returned .
*
* Returns : ( nullable ) ( transfer full ) : The new display or
* % NULL on error .
* */
2002-04-25 22:29:14 +00:00
GdkDisplay *
2020-07-24 18:40:36 +00:00
gdk_x11_display_open ( const char * display_name )
2002-04-25 22:29:14 +00:00
{
2002-04-30 18:32:08 +00:00
Display * xdisplay ;
2002-04-25 22:29:14 +00:00
GdkDisplay * display ;
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2020-07-24 13:54:49 +00:00
int argc ;
2020-07-24 18:40:36 +00:00
char * argv [ 1 ] ;
2002-04-25 22:29:14 +00:00
XClassHint * class_hint ;
2020-07-24 13:54:49 +00:00
int ignore ;
int maj , min ;
2020-02-23 00:33:56 +00:00
char * cm_name ;
2002-04-30 18:32:08 +00:00
2017-01-12 01:01:07 +00:00
XInitThreads ( ) ;
2002-04-30 18:32:08 +00:00
xdisplay = XOpenDisplay ( display_name ) ;
if ( ! xdisplay )
return NULL ;
2012-03-11 04:27:21 +00:00
2010-12-20 18:20:10 +00:00
display = g_object_new ( GDK_TYPE_X11_DISPLAY , NULL ) ;
display_x11 = GDK_X11_DISPLAY ( display ) ;
2002-04-25 22:29:14 +00:00
2002-04-30 18:32:08 +00:00
display_x11 - > xdisplay = xdisplay ;
2002-05-20 19:04:33 +00:00
/* Set up handlers for Xlib internal connections */
XAddConnectionWatch ( xdisplay , gdk_internal_connection_watch , NULL ) ;
2012-03-11 04:27:21 +00:00
2008-12-13 05:33:14 +00:00
_gdk_x11_precache_atoms ( display , precache_atoms , G_N_ELEMENTS ( precache_atoms ) ) ;
2007-12-13 18:27:05 +00:00
/* RandR must be initialized before we initialize the screens */
2010-12-23 12:50:13 +00:00
display_x11 - > have_randr12 = FALSE ;
2009-02-13 18:12:57 +00:00
display_x11 - > have_randr13 = FALSE ;
2015-02-02 06:02:04 +00:00
display_x11 - > have_randr15 = FALSE ;
2007-12-13 18:27:05 +00:00
# ifdef HAVE_RANDR
if ( XRRQueryExtension ( display_x11 - > xdisplay ,
& display_x11 - > xrandr_event_base , & ignore ) )
{
int major , minor ;
2010-12-11 00:42:09 +00:00
2007-12-13 18:27:05 +00:00
XRRQueryVersion ( display_x11 - > xdisplay , & major , & minor ) ;
2010-12-23 12:50:13 +00:00
if ( ( major = = 1 & & minor > = 2 ) | | major > 1 ) {
display_x11 - > have_randr12 = TRUE ;
if ( minor > = 3 | | major > 1 )
display_x11 - > have_randr13 = TRUE ;
2015-02-02 06:02:04 +00:00
# ifdef HAVE_RANDR15
if ( minor > = 5 | | major > 1 )
display_x11 - > have_randr15 = TRUE ;
# endif
2010-12-23 12:50:13 +00:00
}
2007-12-13 18:27:05 +00:00
}
# endif
2010-12-11 00:42:09 +00:00
2002-05-03 19:03:03 +00:00
/* initialize the display's screens */
2016-11-03 22:40:54 +00:00
display_x11 - > screen = _gdk_x11_screen_new ( display , DefaultScreen ( display_x11 - > xdisplay ) , TRUE ) ;
2002-04-25 22:29:14 +00:00
2002-08-01 23:43:13 +00:00
/* We need to initialize events after we have the screen
* structures in places
*/
2012-11-25 19:17:30 +00:00
_gdk_x11_xsettings_init ( GDK_X11_SCREEN ( display_x11 - > screen ) ) ;
2003-12-09 23:12:53 +00:00
2017-11-24 14:14:17 +00:00
display_x11 - > device_manager = _gdk_x11_device_manager_new ( display ) ;
2010-05-25 22:38:44 +00:00
2010-12-11 00:42:09 +00:00
gdk_event_init ( display ) ;
2010-05-25 22:38:44 +00:00
2019-04-20 04:31:27 +00:00
{
GdkRectangle rect = { - 100 , - 100 , 1 , 1 } ;
2019-04-21 16:51:10 +00:00
display_x11 - > leader_gdk_surface = gdk_surface_new_temp ( display , & rect ) ;
2019-04-20 04:31:27 +00:00
}
2018-03-20 10:40:08 +00:00
( _gdk_x11_surface_get_toplevel ( display_x11 - > leader_gdk_surface ) ) - > is_leader = TRUE ;
2004-10-18 21:02:37 +00:00
2018-03-20 10:40:08 +00:00
display_x11 - > leader_window = GDK_SURFACE_XID ( display_x11 - > leader_gdk_surface ) ;
2003-12-09 23:12:53 +00:00
2002-11-08 22:29:33 +00:00
display_x11 - > leader_window_title_set = FALSE ;
2002-11-02 05:37:04 +00:00
2004-05-18 20:56:54 +00:00
# ifdef HAVE_XFIXES
if ( XFixesQueryExtension ( display_x11 - > xdisplay ,
& display_x11 - > xfixes_event_base ,
& ignore ) )
{
display_x11 - > have_xfixes = TRUE ;
}
else
# endif
2006-02-20 01:36:50 +00:00
display_x11 - > have_xfixes = FALSE ;
2007-06-01 12:16:12 +00:00
# ifdef HAVE_XCOMPOSITE
if ( XCompositeQueryExtension ( display_x11 - > xdisplay ,
& ignore , & ignore ) )
2008-09-27 03:43:50 +00:00
{
int major , minor ;
XCompositeQueryVersion ( display_x11 - > xdisplay , & major , & minor ) ;
/* Prior to Composite version 0.4, composited windows clipped their
* parents , so you had to use IncludeInferiors to draw to the parent
* This isn ' t useful for our purposes , so require 0.4
*/
display_x11 - > have_xcomposite = major > 0 | | ( major = = 0 & & minor > = 4 ) ;
}
2007-06-01 12:16:12 +00:00
else
# endif
display_x11 - > have_xcomposite = FALSE ;
2006-02-20 01:36:50 +00:00
display_x11 - > have_shapes = FALSE ;
display_x11 - > have_input_shapes = FALSE ;
2009-06-06 03:06:12 +00:00
2010-02-05 00:15:54 +00:00
if ( XShapeQueryExtension ( GDK_DISPLAY_XDISPLAY ( display ) , & display_x11 - > shape_event_base , & ignore ) )
2006-02-20 01:36:50 +00:00
{
display_x11 - > have_shapes = TRUE ;
2010-02-05 00:15:54 +00:00
# ifdef ShapeInput
2006-02-20 01:36:50 +00:00
if ( XShapeQueryVersion ( GDK_DISPLAY_XDISPLAY ( display ) , & maj , & min ) )
display_x11 - > have_input_shapes = ( maj = = 1 & & min > = 1 ) ;
# endif
}
2004-05-18 20:56:54 +00:00
2020-05-18 02:05:24 +00:00
gdk_display_set_input_shapes ( display , display_x11 - > have_input_shapes ) ;
2006-05-25 05:30:14 +00:00
display_x11 - > trusted_client = TRUE ;
{
Window root , child ;
int rootx , rooty , winx , winy ;
unsigned int xmask ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_push ( display ) ;
XQueryPointer ( display_x11 - > xdisplay ,
2012-11-25 19:17:30 +00:00
GDK_X11_SCREEN ( display_x11 - > screen ) - > xroot_window ,
2006-05-25 05:30:14 +00:00
& root , & child , & rootx , & rooty , & winx , & winy , & xmask ) ;
2010-12-15 07:05:05 +00:00
if ( G_UNLIKELY ( gdk_x11_display_error_trap_pop ( display ) = = BadWindow ) )
2006-05-25 05:30:14 +00:00
{
g_warning ( " Connection to display %s appears to be untrusted. Pointer and keyboard grabs and inter-client communication may not work as expected. " , gdk_display_get_name ( display ) ) ;
display_x11 - > trusted_client = FALSE ;
}
}
2010-12-16 04:11:21 +00:00
if ( g_getenv ( " GDK_SYNCHRONIZE " ) )
2002-04-25 22:29:14 +00:00
XSynchronize ( display_x11 - > xdisplay , True ) ;
2010-12-16 04:11:21 +00:00
2002-04-25 22:29:14 +00:00
class_hint = XAllocClassHint ( ) ;
2013-01-13 18:01:29 +00:00
class_hint - > res_name = ( char * ) g_get_prgname ( ) ;
2017-11-17 04:18:58 +00:00
class_hint - > res_class = ( char * ) g_get_prgname ( ) ;
Make gtk argument parsing use goption. Add gtk_get_option_group and
2004-09-05 Anders Carlsson <andersca@gnome.org>
* gdk/gdk.c: (gdk_arg_class_cb), (gdk_arg_name_cb),
(gdk_add_option_entries_libgtk_only), (gdk_pre_parse_libgtk_only),
(gdk_parse_args):
* gdk/gdk.h:
* gdk/gdkinternals.h:
* gdk/linux-fb/gdkmain-fb.c: (_gdk_windowing_init):
* gdk/win32/gdkmain-win32.c: (_gdk_windowing_init):
* gdk/x11/gdkdisplay-x11.c: (gdk_display_open):
* gdk/x11/gdkmain-x11.c: (_gdk_windowing_init):
* gtk/gtkmain.c: (gtk_arg_debug_cb), (gtk_arg_no_debug_cb),
(gtk_arg_module_cb), (gtk_arg_warnings_cb),
(do_pre_parse_initialization), (do_post_parse_initialization),
(pre_parse_hook), (post_parse_hook), (gtk_get_option_group),
(gtk_init_with_args), (gtk_parse_args):
* gtk/gtkmain.h:
Make gtk argument parsing use goption. Add gtk_get_option_group and
gtk_init_with_args.
* tests/testtreemodel.c: (main):
Use gtk_init_with_args.
2004-09-05 15:09:55 +00:00
/* XmbSetWMProperties sets the RESOURCE_NAME environment variable
* from argv [ 0 ] , so we just synthesize an argument array here .
*/
argc = 1 ;
2013-01-13 18:01:29 +00:00
argv [ 0 ] = ( char * ) g_get_prgname ( ) ;
2010-12-16 04:11:21 +00:00
2002-04-25 22:29:14 +00:00
XmbSetWMProperties ( display_x11 - > xdisplay ,
display_x11 - > leader_window ,
NULL , NULL , argv , argc , NULL , NULL ,
class_hint ) ;
XFree ( class_hint ) ;
2010-12-13 18:45:38 +00:00
if ( gdk_sm_client_id )
set_sm_client_id ( display , gdk_sm_client_id ) ;
2002-09-30 19:38:12 +00:00
2018-05-28 16:09:47 +00:00
if ( ! gdk_running_in_sandbox ( ) )
{
/* if sandboxed, we're likely in a pid namespace and would only confuse the wm with this */
2019-01-03 00:26:56 +00:00
long pid = getpid ( ) ;
2018-05-28 16:09:47 +00:00
XChangeProperty ( display_x11 - > xdisplay ,
display_x11 - > leader_window ,
gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_PID " ) ,
XA_CARDINAL , 32 , PropModeReplace , ( guchar * ) & pid , 1 ) ;
}
2004-04-18 14:33:07 +00:00
/* We don't yet know a valid time. */
display_x11 - > user_time = 0 ;
2002-04-25 22:29:14 +00:00
# ifdef HAVE_XKB
{
2020-07-24 13:54:49 +00:00
int xkb_major = XkbMajorVersion ;
int xkb_minor = XkbMinorVersion ;
2002-04-25 22:29:14 +00:00
if ( XkbLibraryVersion ( & xkb_major , & xkb_minor ) )
{
xkb_major = XkbMajorVersion ;
xkb_minor = XkbMinorVersion ;
if ( XkbQueryExtension ( display_x11 - > xdisplay ,
NULL , & display_x11 - > xkb_event_type , NULL ,
& xkb_major , & xkb_minor ) )
{
Bool detectable_autorepeat_supported ;
display_x11 - > use_xkb = TRUE ;
XkbSelectEvents ( display_x11 - > xdisplay ,
XkbUseCoreKbd ,
2003-04-18 18:51:20 +00:00
XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask ,
XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask ) ;
2002-04-25 22:29:14 +00:00
2010-12-16 04:49:31 +00:00
/* keep this in sync with _gdk_x11_keymap_state_changed() */
2005-09-20 05:28:34 +00:00
XkbSelectEventDetails ( display_x11 - > xdisplay ,
XkbUseCoreKbd , XkbStateNotify ,
2006-06-28 12:44:30 +00:00
XkbAllStateComponentsMask ,
2012-02-20 23:30:44 +00:00
XkbModifierStateMask | XkbGroupStateMask ) ;
2005-09-20 05:28:34 +00:00
2002-04-25 22:29:14 +00:00
XkbSetDetectableAutoRepeat ( display_x11 - > xdisplay ,
True ,
& detectable_autorepeat_supported ) ;
GDK_NOTE ( MISC , g_message ( " Detectable autorepeat %s. " ,
2010-12-16 04:49:31 +00:00
detectable_autorepeat_supported ?
2002-04-25 22:29:14 +00:00
" supported " : " not supported " ) ) ;
display_x11 - > have_xkb_autorepeat = detectable_autorepeat_supported ;
}
}
}
# endif
2004-07-11 13:26:57 +00:00
display_x11 - > use_sync = FALSE ;
# ifdef HAVE_XSYNC
{
int major , minor ;
int error_base , event_base ;
if ( XSyncQueryExtension ( display_x11 - > xdisplay ,
& event_base , & error_base ) & &
XSyncInitialize ( display_x11 - > xdisplay ,
& major , & minor ) )
display_x11 - > use_sync = TRUE ;
}
# endif
2010-05-25 22:38:44 +00:00
2020-05-27 18:53:10 +00:00
# ifdef HAVE_XDAMAGE
display_x11 - > have_damage = FALSE ;
if ( XDamageQueryExtension ( display_x11 - > xdisplay ,
& display_x11 - > damage_event_base ,
& display_x11 - > damage_error_base ) )
display_x11 - > have_damage = TRUE ;
# endif
2017-11-19 17:06:13 +00:00
display - > clipboard = gdk_x11_clipboard_new ( display , " CLIPBOARD " ) ;
display - > primary_clipboard = gdk_x11_clipboard_new ( display , " PRIMARY " ) ;
2016-10-29 02:37:20 +00:00
/*
* It is important that we first request the selection
* notification , and then setup the initial state of
* is_composited to avoid a race condition here .
*/
2020-02-23 00:33:56 +00:00
cm_name = g_strdup_printf ( " _NET_WM_CM_S%d " , DefaultScreen ( GDK_DISPLAY_XDISPLAY ( display ) ) ) ;
gdk_x11_display_request_selection_notification ( display , cm_name ) ;
2016-10-29 02:37:20 +00:00
gdk_display_set_composited ( GDK_DISPLAY ( display ) ,
2020-02-23 00:33:56 +00:00
XGetSelectionOwner ( GDK_DISPLAY_XDISPLAY ( display ) ,
gdk_x11_get_xatom_by_name_for_display ( display , cm_name ) ) ! = None ) ;
g_free ( cm_name ) ;
2006-04-25 14:27:32 +00:00
2017-10-08 15:38:38 +00:00
gdk_display_emit_opened ( display ) ;
2002-06-20 19:59:30 +00:00
2002-04-25 22:29:14 +00:00
return display ;
}
2017-11-17 04:18:58 +00:00
/**
* gdk_x11_display_set_program_class :
* @ display : a # GdkDisplay
* @ program_class : a string
*
* Sets the program class .
*
* The X11 backend uses the program class to set the class name part
* of the ` WM_CLASS ` property on toplevel windows ; see the ICCCM .
*/
void
gdk_x11_display_set_program_class ( GdkDisplay * display ,
const char * program_class )
{
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
XClassHint * class_hint ;
g_free ( display_x11 - > program_class ) ;
display_x11 - > program_class = g_strdup ( program_class ) ;
class_hint = XAllocClassHint ( ) ;
class_hint - > res_name = ( char * ) g_get_prgname ( ) ;
class_hint - > res_class = ( char * ) program_class ;
XSetClassHint ( display_x11 - > xdisplay , display_x11 - > leader_window , class_hint ) ;
XFree ( class_hint ) ;
}
2002-05-20 19:04:33 +00:00
/*
* XLib internal connection handling
*/
typedef struct _GdkInternalConnection GdkInternalConnection ;
struct _GdkInternalConnection
{
2020-07-24 13:54:49 +00:00
int fd ;
2002-05-20 19:04:33 +00:00
GSource * source ;
Display * display ;
} ;
static gboolean
process_internal_connection ( GIOChannel * gioc ,
GIOCondition cond ,
gpointer data )
{
GdkInternalConnection * connection = ( GdkInternalConnection * ) data ;
XProcessInternalConnection ( ( Display * ) connection - > display , connection - > fd ) ;
return TRUE ;
}
2010-12-13 19:05:59 +00:00
static gulong
gdk_x11_display_get_next_serial ( GdkDisplay * display )
2009-01-23 20:07:53 +00:00
{
return NextRequest ( GDK_DISPLAY_XDISPLAY ( display ) ) ;
}
2002-05-20 19:04:33 +00:00
static GdkInternalConnection *
gdk_add_connection_handler ( Display * display ,
guint fd )
{
GIOChannel * io_channel ;
GdkInternalConnection * connection ;
connection = g_new ( GdkInternalConnection , 1 ) ;
connection - > fd = fd ;
connection - > display = display ;
io_channel = g_io_channel_unix_new ( fd ) ;
connection - > source = g_io_create_watch ( io_channel , G_IO_IN ) ;
g_source_set_callback ( connection - > source ,
( GSourceFunc ) process_internal_connection , connection , NULL ) ;
g_source_attach ( connection - > source , NULL ) ;
g_io_channel_unref ( io_channel ) ;
return connection ;
}
static void
gdk_remove_connection_handler ( GdkInternalConnection * connection )
{
g_source_destroy ( connection - > source ) ;
g_free ( connection ) ;
}
static void
gdk_internal_connection_watch ( Display * display ,
XPointer arg ,
2020-07-24 13:54:49 +00:00
int fd ,
2002-05-20 19:04:33 +00:00
gboolean opening ,
XPointer * watch_data )
{
if ( opening )
* watch_data = ( XPointer ) gdk_add_connection_handler ( display , fd ) ;
else
2002-05-21 20:51:15 +00:00
gdk_remove_connection_handler ( ( GdkInternalConnection * ) * watch_data ) ;
2002-05-20 19:04:33 +00:00
}
2020-07-24 18:40:36 +00:00
static const char *
2010-12-05 21:37:03 +00:00
gdk_x11_display_get_name ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
2020-07-24 18:40:36 +00:00
return ( char * ) DisplayString ( GDK_X11_DISPLAY ( display ) - > xdisplay ) ;
2002-04-25 22:29:14 +00:00
}
gboolean
_gdk_x11_display_is_root_window ( GdkDisplay * display ,
Window xroot_window )
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2010-12-11 00:42:09 +00:00
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-12-11 00:42:09 +00:00
2012-11-25 19:17:30 +00:00
return GDK_SCREEN_XROOTWIN ( display_x11 - > screen ) = = xroot_window ;
2002-04-25 22:29:14 +00:00
}
2009-01-26 19:38:20 +00:00
struct XPointerUngrabInfo {
GdkDisplay * display ;
guint32 time ;
} ;
2010-12-21 23:42:30 +00:00
static void
device_grab_update_callback ( GdkDisplay * display ,
gpointer data ,
gulong serial )
{
GdkDevice * device = data ;
2020-07-28 21:00:02 +00:00
_gdk_display_device_grab_update ( display , device , serial ) ;
2010-12-21 23:42:30 +00:00
}
2005-06-27 18:37:41 +00:00
# define XSERVER_TIME_IS_LATER(time1, time2) \
( ( ( time1 > time2 ) & & ( time1 - time2 < ( ( guint32 ) - 1 ) / 2 ) ) | | \
( ( time1 < time2 ) & & ( time2 - time1 > ( ( guint32 ) - 1 ) / 2 ) ) \
)
2002-04-25 22:29:14 +00:00
void
2010-12-10 17:13:25 +00:00
_gdk_x11_display_update_grab_info ( GdkDisplay * display ,
GdkDevice * device ,
2020-07-24 13:54:49 +00:00
int status )
2002-04-25 22:29:14 +00:00
{
2010-12-10 17:13:25 +00:00
if ( status = = GrabSuccess )
2010-12-21 23:42:30 +00:00
_gdk_x11_roundtrip_async ( display , device_grab_update_callback , device ) ;
2010-12-10 17:13:25 +00:00
}
2009-01-31 18:42:44 +00:00
2010-12-10 17:13:25 +00:00
void
_gdk_x11_display_update_grab_info_ungrab ( GdkDisplay * display ,
GdkDevice * device ,
guint32 time ,
gulong serial )
{
GdkDeviceGrabInfo * grab ;
2010-05-25 22:38:44 +00:00
2010-12-10 17:13:25 +00:00
XFlush ( GDK_DISPLAY_XDISPLAY ( display ) ) ;
2005-06-27 18:37:41 +00:00
2010-05-25 22:38:44 +00:00
grab = _gdk_display_get_last_device_grab ( display , device ) ;
2009-01-31 18:42:44 +00:00
if ( grab & &
2010-12-10 17:13:25 +00:00
( time = = GDK_CURRENT_TIME | |
2009-01-31 18:42:44 +00:00
grab - > time = = GDK_CURRENT_TIME | |
2010-12-10 17:13:25 +00:00
! XSERVER_TIME_IS_LATER ( grab - > time , time ) ) )
2008-07-18 13:03:42 +00:00
{
2009-01-31 18:42:44 +00:00
grab - > serial_end = serial ;
2010-12-21 23:42:30 +00:00
_gdk_x11_roundtrip_async ( display , device_grab_update_callback , device ) ;
2008-07-18 13:03:42 +00:00
}
2002-04-25 22:29:14 +00:00
}
2010-12-05 21:37:03 +00:00
static void
gdk_x11_display_beep ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
2010-05-21 16:13:05 +00:00
# ifdef HAVE_XKB
2009-09-14 03:16:44 +00:00
XkbBell ( GDK_DISPLAY_XDISPLAY ( display ) , None , 0 , None ) ;
2010-05-21 16:13:05 +00:00
# else
XBell ( GDK_DISPLAY_XDISPLAY ( display ) , 0 ) ;
# endif
2002-04-25 22:29:14 +00:00
}
2010-12-05 21:37:03 +00:00
static void
gdk_x11_display_sync ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
XSync ( GDK_DISPLAY_XDISPLAY ( display ) , False ) ;
}
2010-12-05 21:37:03 +00:00
static void
gdk_x11_display_flush ( GdkDisplay * display )
2003-07-05 01:54:05 +00:00
{
if ( ! display - > closed )
XFlush ( GDK_DISPLAY_XDISPLAY ( display ) ) ;
}
2010-12-11 00:42:09 +00:00
static gboolean
gdk_x11_display_has_pending ( GdkDisplay * display )
{
return XPending ( GDK_DISPLAY_XDISPLAY ( display ) ) ;
}
2020-07-30 02:55:19 +00:00
/**
* gdk_x11_display_get_default_group :
2020-07-31 17:11:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2020-07-30 02:55:19 +00:00
*
* Returns the default group leader surface for all toplevel surfaces
* on @ display . This surface is implicitly created by GDK .
2020-08-05 19:42:27 +00:00
* See gdk_x11_surface_set_group ( ) .
2020-07-30 02:55:19 +00:00
*
* Returns : ( transfer none ) : The default group leader surface
* for @ display
*/
GdkSurface *
2010-12-05 21:37:03 +00:00
gdk_x11_display_get_default_group ( GdkDisplay * display )
2003-12-09 23:12:53 +00:00
{
g_return_val_if_fail ( GDK_IS_DISPLAY ( display ) , NULL ) ;
2018-03-20 10:40:08 +00:00
return GDK_X11_DISPLAY ( display ) - > leader_gdk_surface ;
2003-12-09 23:12:53 +00:00
}
2002-10-22 22:11:22 +00:00
/**
* gdk_x11_display_grab :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2002-10-22 22:11:22 +00:00
*
* Call XGrabServer ( ) on @ display .
* To ungrab the display again , use gdk_x11_display_ungrab ( ) .
*
* gdk_x11_display_grab ( ) / gdk_x11_display_ungrab ( ) calls can be nested .
* */
2002-04-25 22:29:14 +00:00
void
2006-05-22 04:11:42 +00:00
gdk_x11_display_grab ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2002-04-25 22:29:14 +00:00
g_return_if_fail ( GDK_IS_DISPLAY ( display ) ) ;
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2002-04-25 22:29:14 +00:00
if ( display_x11 - > grab_count = = 0 )
XGrabServer ( display_x11 - > xdisplay ) ;
display_x11 - > grab_count + + ;
}
2002-10-22 22:11:22 +00:00
/**
* gdk_x11_display_ungrab :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2002-10-22 22:11:22 +00:00
*
* Ungrab @ display after it has been grabbed with
* gdk_x11_display_grab ( ) .
* */
2002-04-25 22:29:14 +00:00
void
2006-05-22 04:11:42 +00:00
gdk_x11_display_ungrab ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2002-04-25 22:29:14 +00:00
g_return_if_fail ( GDK_IS_DISPLAY ( display ) ) ;
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ; ;
2002-04-25 22:29:14 +00:00
g_return_if_fail ( display_x11 - > grab_count > 0 ) ;
display_x11 - > grab_count - - ;
if ( display_x11 - > grab_count = = 0 )
2003-04-07 23:47:59 +00:00
{
XUngrabServer ( display_x11 - > xdisplay ) ;
XFlush ( display_x11 - > xdisplay ) ;
}
2002-04-25 22:29:14 +00:00
}
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-08-01 15:28:40 +00:00
static void
2010-12-20 18:20:10 +00:00
gdk_x11_display_dispose ( GObject * object )
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-08-01 15:28:40 +00:00
{
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( object ) ;
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-08-01 15:28:40 +00:00
2010-05-25 22:38:44 +00:00
if ( display_x11 - > event_source )
{
g_source_destroy ( display_x11 - > event_source ) ;
g_source_unref ( display_x11 - > event_source ) ;
display_x11 - > event_source = NULL ;
}
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-08-01 15:28:40 +00:00
2010-12-20 18:42:53 +00:00
G_OBJECT_CLASS ( gdk_x11_display_parent_class ) - > dispose ( object ) ;
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-08-01 15:28:40 +00:00
}
2002-04-25 22:29:14 +00:00
static void
2010-12-20 18:20:10 +00:00
gdk_x11_display_finalize ( GObject * object )
2002-04-25 22:29:14 +00:00
{
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( object ) ;
2005-11-10 12:09:42 +00:00
/* Keymap */
if ( display_x11 - > keymap )
g_object_unref ( display_x11 - > keymap ) ;
2010-12-20 16:11:00 +00:00
_gdk_x11_cursor_display_finalize ( GDK_DISPLAY ( display_x11 ) ) ;
2009-01-20 02:15:59 +00:00
2017-11-19 17:06:13 +00:00
/* Get rid of pending streams */
2017-11-25 20:59:39 +00:00
g_slist_free_full ( display_x11 - > streams , g_object_unref ) ;
2017-11-19 17:06:13 +00:00
2002-04-25 22:29:14 +00:00
/* Atom Hashtable */
2020-02-23 00:33:56 +00:00
g_hash_table_destroy ( display_x11 - > atom_from_string ) ;
g_hash_table_destroy ( display_x11 - > atom_to_string ) ;
2005-11-10 12:09:42 +00:00
2002-04-25 22:29:14 +00:00
/* Leader Window */
XDestroyWindow ( display_x11 - > xdisplay , display_x11 - > leader_window ) ;
2005-11-10 12:09:42 +00:00
2017-11-17 15:37:52 +00:00
/* Free all GdkX11Screens */
2012-11-25 19:17:30 +00:00
g_object_unref ( display_x11 - > screen ) ;
2015-07-28 03:18:27 +00:00
g_list_free_full ( display_x11 - > screens , g_object_unref ) ;
2005-11-10 12:09:42 +00:00
2020-05-12 17:46:40 +00:00
g_list_store_remove_all ( display_x11 - > monitors ) ;
g_object_unref ( display_x11 - > monitors ) ;
2016-04-03 04:12:39 +00:00
2002-11-02 05:37:04 +00:00
g_free ( display_x11 - > startup_notification_id ) ;
2005-11-10 12:09:42 +00:00
2005-11-15 14:42:48 +00:00
/* X ID hashtable */
g_hash_table_destroy ( display_x11 - > xid_ht ) ;
2005-11-10 12:09:42 +00:00
XCloseDisplay ( display_x11 - > xdisplay ) ;
2010-09-19 03:03:31 +00:00
/* error traps */
while ( display_x11 - > error_traps ! = NULL )
{
GdkErrorTrap * trap = display_x11 - > error_traps - > data ;
display_x11 - > error_traps =
g_slist_delete_link ( display_x11 - > error_traps ,
display_x11 - > error_traps ) ;
if ( trap - > end_sequence = = 0 )
g_warning ( " Display finalized with an unpopped error trap " ) ;
g_slice_free ( GdkErrorTrap , trap ) ;
}
2017-11-17 04:18:58 +00:00
g_free ( display_x11 - > program_class ) ;
2010-12-20 18:42:53 +00:00
G_OBJECT_CLASS ( gdk_x11_display_parent_class ) - > finalize ( object ) ;
2002-04-25 22:29:14 +00:00
}
/**
* gdk_x11_lookup_xdisplay :
* @ xdisplay : a pointer to an X Display
*
2014-01-20 22:45:37 +00:00
* Find the # GdkDisplay corresponding to @ xdisplay , if any exists .
2002-04-25 22:29:14 +00:00
*
2014-02-19 23:49:43 +00:00
* Returns : ( transfer none ) ( type GdkX11Display ) : the # GdkDisplay , if found , otherwise % NULL .
2002-04-25 22:29:14 +00:00
* */
GdkDisplay *
gdk_x11_lookup_xdisplay ( Display * xdisplay )
{
2010-12-11 00:42:09 +00:00
GSList * list , * l ;
GdkDisplay * display ;
display = NULL ;
2002-04-25 22:29:14 +00:00
2010-12-11 00:42:09 +00:00
list = gdk_display_manager_list_displays ( gdk_display_manager_get ( ) ) ;
for ( l = list ; l ; l = l - > next )
2002-04-25 22:29:14 +00:00
{
2014-10-24 22:38:15 +00:00
if ( GDK_IS_X11_DISPLAY ( l - > data ) & &
GDK_DISPLAY_XDISPLAY ( l - > data ) = = xdisplay )
2010-12-11 00:42:09 +00:00
{
display = l - > data ;
break ;
}
2002-04-25 22:29:14 +00:00
}
2010-12-11 00:42:09 +00:00
g_slist_free ( list ) ;
return display ;
2002-04-25 22:29:14 +00:00
}
/**
* _gdk_x11_display_screen_for_xrootwin :
2006-05-22 04:11:42 +00:00
* @ display : a # GdkDisplay
2020-05-28 08:00:03 +00:00
* @ xrootwin : window ID for one of the screen ’ s of the display .
2002-04-25 22:29:14 +00:00
*
2014-02-07 18:01:26 +00:00
* Given the root window ID of one of the screen ’ s of a # GdkDisplay ,
2002-04-25 22:29:14 +00:00
* finds the screen .
*
2017-11-17 15:37:52 +00:00
* Returns : ( transfer none ) : the # GdkX11Screen corresponding to
2011-01-18 09:01:17 +00:00
* @ xrootwin , or % NULL .
2002-04-25 22:29:14 +00:00
* */
2017-11-17 15:18:20 +00:00
GdkX11Screen *
2002-04-25 22:29:14 +00:00
_gdk_x11_display_screen_for_xrootwin ( GdkDisplay * display ,
Window xrootwin )
{
2017-11-17 15:18:20 +00:00
GdkX11Screen * screen ;
2015-07-28 03:18:27 +00:00
XWindowAttributes attrs ;
gboolean result ;
GdkX11Display * display_x11 ;
GList * l ;
2017-11-01 22:06:24 +00:00
screen = GDK_X11_DISPLAY ( display ) - > screen ;
2002-04-25 22:29:14 +00:00
2012-11-25 19:17:30 +00:00
if ( GDK_SCREEN_XROOTWIN ( screen ) = = xrootwin )
return screen ;
2002-04-25 22:29:14 +00:00
2015-07-28 03:18:27 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
for ( l = display_x11 - > screens ; l ; l = l - > next )
{
screen = l - > data ;
if ( GDK_SCREEN_XROOTWIN ( screen ) = = xrootwin )
return screen ;
}
gdk_x11_display_error_trap_push ( display ) ;
result = XGetWindowAttributes ( display_x11 - > xdisplay , xrootwin , & attrs ) ;
if ( gdk_x11_display_error_trap_pop ( display ) | | ! result )
return NULL ;
2016-11-03 22:40:54 +00:00
screen = _gdk_x11_screen_new ( display , XScreenNumberOfScreen ( attrs . screen ) , FALSE ) ;
2015-07-28 03:18:27 +00:00
display_x11 - > screens = g_list_prepend ( display_x11 - > screens , screen ) ;
return screen ;
2002-04-25 22:29:14 +00:00
}
2002-05-02 22:28:50 +00:00
/**
2011-07-28 11:17:35 +00:00
* gdk_x11_display_get_xdisplay :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2002-05-02 22:28:50 +00:00
*
* Returns the X display of a # GdkDisplay .
2002-11-28 00:33:17 +00:00
*
2011-12-16 04:08:07 +00:00
* Returns : ( transfer none ) : an X display
2002-05-02 22:28:50 +00:00
*/
2002-04-25 22:29:14 +00:00
Display *
2006-05-22 04:11:42 +00:00
gdk_x11_display_get_xdisplay ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
2007-06-21 22:37:21 +00:00
g_return_val_if_fail ( GDK_IS_DISPLAY ( display ) , NULL ) ;
2017-11-01 21:56:46 +00:00
2010-12-20 18:20:10 +00:00
return GDK_X11_DISPLAY ( display ) - > xdisplay ;
2002-04-25 22:29:14 +00:00
}
2002-11-02 05:37:04 +00:00
2017-11-01 21:56:46 +00:00
/**
* gdk_x11_display_get_xscreen :
* @ display : ( type GdkX11Display ) : a # GdkDisplay
*
* Returns the X Screen used by # GdkDisplay .
*
* Returns : ( transfer none ) : an X Screen
*/
Screen *
gdk_x11_display_get_xscreen ( GdkDisplay * display )
{
g_return_val_if_fail ( GDK_IS_DISPLAY ( display ) , NULL ) ;
return GDK_X11_SCREEN ( GDK_X11_DISPLAY ( display ) - > screen ) - > xscreen ;
}
/**
* gdk_x11_display_get_xrootwindow :
* @ display : ( type GdkX11Display ) : a # GdkDisplay
*
* Returns the root X window used by # GdkDisplay .
*
2017-12-21 18:46:08 +00:00
* Returns : an X Window
2017-11-01 21:56:46 +00:00
*/
Window
gdk_x11_display_get_xrootwindow ( GdkDisplay * display )
{
g_return_val_if_fail ( GDK_IS_DISPLAY ( display ) , None ) ;
return GDK_SCREEN_XROOTWIN ( GDK_X11_DISPLAY ( display ) - > screen ) ;
}
2013-04-09 11:32:03 +00:00
static void
gdk_x11_display_make_default ( GdkDisplay * display )
2002-11-02 05:37:04 +00:00
{
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
2020-07-24 18:40:36 +00:00
const char * startup_id ;
2002-11-02 05:37:04 +00:00
g_free ( display_x11 - > startup_notification_id ) ;
display_x11 - > startup_notification_id = NULL ;
2010-12-11 00:42:09 +00:00
2018-06-11 15:09:06 +00:00
startup_id = gdk_get_startup_notification_id ( ) ;
if ( startup_id )
gdk_x11_display_set_startup_notification_id ( display , startup_id ) ;
2002-11-02 05:37:04 +00:00
}
static void
2006-05-22 04:11:42 +00:00
broadcast_xmessage ( GdkDisplay * display ,
const char * message_type ,
const char * message_type_begin ,
const char * message )
2002-11-02 05:37:04 +00:00
{
Display * xdisplay = GDK_DISPLAY_XDISPLAY ( display ) ;
2017-11-13 21:09:47 +00:00
Window xroot_window = GDK_DISPLAY_XROOTWIN ( display ) ;
2002-11-02 05:37:04 +00:00
Atom type_atom ;
Atom type_atom_begin ;
Window xwindow ;
2010-12-20 18:20:10 +00:00
if ( ! G_LIKELY ( GDK_X11_DISPLAY ( display ) - > trusted_client ) )
2007-04-29 18:13:42 +00:00
return ;
2002-11-02 05:37:04 +00:00
{
XSetWindowAttributes attrs ;
attrs . override_redirect = True ;
attrs . event_mask = PropertyChangeMask | StructureNotifyMask ;
xwindow =
XCreateWindow ( xdisplay ,
xroot_window ,
- 100 , - 100 , 1 , 1 ,
0 ,
CopyFromParent ,
CopyFromParent ,
2004-10-28 15:00:05 +00:00
( Visual * ) CopyFromParent ,
2002-11-02 05:37:04 +00:00
CWOverrideRedirect | CWEventMask ,
& attrs ) ;
}
2017-11-13 21:09:47 +00:00
type_atom = gdk_x11_get_xatom_by_name_for_display ( display , message_type ) ;
type_atom_begin = gdk_x11_get_xatom_by_name_for_display ( display , message_type_begin ) ;
2002-11-02 05:37:04 +00:00
{
2007-01-04 01:28:07 +00:00
XClientMessageEvent xclient ;
2002-11-02 05:37:04 +00:00
const char * src ;
const char * src_end ;
char * dest ;
char * dest_end ;
2017-11-13 21:09:47 +00:00
memset ( & xclient , 0 , sizeof ( xclient ) ) ;
2007-01-04 01:28:07 +00:00
xclient . type = ClientMessage ;
xclient . message_type = type_atom_begin ;
xclient . display = xdisplay ;
xclient . window = xwindow ;
xclient . format = 8 ;
2002-11-02 05:37:04 +00:00
src = message ;
src_end = message + strlen ( message ) + 1 ; /* +1 to include nul byte */
while ( src ! = src_end )
{
2007-01-04 01:28:07 +00:00
dest = & xclient . data . b [ 0 ] ;
2017-11-13 21:09:47 +00:00
dest_end = dest + 20 ;
2002-11-02 05:37:04 +00:00
while ( dest ! = dest_end & &
src ! = src_end )
{
* dest = * src ;
+ + dest ;
+ + src ;
}
2003-05-20 21:01:08 +00:00
while ( dest ! = dest_end )
{
* dest = 0 ;
+ + dest ;
}
2002-11-02 05:37:04 +00:00
XSendEvent ( xdisplay ,
xroot_window ,
False ,
PropertyChangeMask ,
2007-01-04 01:28:07 +00:00
( XEvent * ) & xclient ) ;
2002-11-02 05:37:04 +00:00
2007-01-04 01:28:07 +00:00
xclient . message_type = type_atom ;
2002-11-02 05:37:04 +00:00
}
}
XDestroyWindow ( xdisplay , xwindow ) ;
XFlush ( xdisplay ) ;
}
2007-04-29 18:13:42 +00:00
/**
* gdk_x11_display_broadcast_startup_message :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2007-04-29 18:13:42 +00:00
* @ message_type : startup notification message type ( " new " , " change " ,
* or " remove " )
* @ . . . : a list of key / value pairs ( as strings ) , terminated by a
* % NULL key . ( A % NULL value for a key will cause that key to be
* skipped in the output . )
*
* Sends a startup notification message of type @ message_type to
* @ display .
*
* This is a convenience function for use by code that implements the
* freedesktop startup notification specification . Applications should
2014-02-03 21:56:15 +00:00
* not normally need to call it directly . See the
* [ Startup Notification Protocol specification ] ( http : //standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt)
* for definitions of the message types and keys that can be used .
2007-04-29 18:13:42 +00:00
* */
void
gdk_x11_display_broadcast_startup_message ( GdkDisplay * display ,
const char * message_type ,
. . . )
{
GString * message ;
va_list ap ;
const char * key , * value , * p ;
message = g_string_new ( message_type ) ;
g_string_append_c ( message , ' : ' ) ;
va_start ( ap , message_type ) ;
while ( ( key = va_arg ( ap , const char * ) ) )
{
value = va_arg ( ap , const char * ) ;
if ( ! value )
continue ;
g_string_append_printf ( message , " %s= \" " , key ) ;
for ( p = value ; * p ; p + + )
{
switch ( * p )
{
case ' ' :
case ' " ' :
case ' \\ ' :
g_string_append_c ( message , ' \\ ' ) ;
break ;
2017-10-06 19:19:42 +00:00
default :
break ;
2007-04-29 18:13:42 +00:00
}
g_string_append_c ( message , * p ) ;
}
g_string_append_c ( message , ' \" ' ) ;
}
va_end ( ap ) ;
broadcast_xmessage ( display ,
2010-12-14 01:46:00 +00:00
" _NET_STARTUP_INFO " ,
2007-04-29 18:13:42 +00:00
" _NET_STARTUP_INFO_BEGIN " ,
message - > str ) ;
g_string_free ( message , TRUE ) ;
}
2010-12-14 01:46:00 +00:00
static void
gdk_x11_display_notify_startup_complete ( GdkDisplay * display ,
2020-07-24 18:40:36 +00:00
const char * startup_id )
2007-03-13 17:03:54 +00:00
{
2020-07-24 18:40:36 +00:00
char * free_this = NULL ;
2016-01-27 14:50:42 +00:00
2010-12-14 01:46:00 +00:00
if ( startup_id = = NULL )
{
2016-01-27 14:50:42 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
startup_id = free_this = display_x11 - > startup_notification_id ;
display_x11 - > startup_notification_id = NULL ;
2010-12-14 01:46:00 +00:00
if ( startup_id = = NULL )
return ;
}
2007-03-13 17:03:54 +00:00
2007-04-29 18:13:42 +00:00
gdk_x11_display_broadcast_startup_message ( display , " remove " ,
2010-12-14 01:46:00 +00:00
" ID " , startup_id ,
NULL ) ;
2016-01-27 14:50:42 +00:00
g_free ( free_this ) ;
2002-11-02 05:37:04 +00:00
}
2004-05-18 20:56:54 +00:00
2017-12-14 03:20:48 +00:00
gboolean
2010-12-05 21:37:03 +00:00
gdk_x11_display_request_selection_notification ( GdkDisplay * display ,
2017-12-14 03:20:48 +00:00
const char * selection )
2004-05-18 20:56:54 +00:00
{
# ifdef HAVE_XFIXES
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
2004-05-18 20:56:54 +00:00
Atom atom ;
if ( display_x11 - > have_xfixes )
{
2017-12-14 03:20:48 +00:00
atom = gdk_x11_get_xatom_by_name_for_display ( display , selection ) ;
2004-05-18 20:56:54 +00:00
XFixesSelectSelectionInput ( display_x11 - > xdisplay ,
display_x11 - > leader_window ,
atom ,
XFixesSetSelectionOwnerNotifyMask |
XFixesSelectionWindowDestroyNotifyMask |
XFixesSelectionClientCloseNotifyMask ) ;
return TRUE ;
}
else
# endif
return FALSE ;
}
New API to handle the clipboard manager.
2004-10-25 Anders Carlsson <andersca@imendio.com>
* gdk/gdk.symbols:
* gdk/gdkdisplay.h:
* gdk/x11/gdkdisplay-x11.c:
(gdk_display_supports_clipboard_persistence),
(gdk_display_store_clipboard):
New API to handle the clipboard manager.
* gtk/gtk.symbols:
* gtk/gtkclipboard.c: (gtk_clipboard_class_init),
(gtk_clipboard_finalize), (selection_clear_event_cb),
(clipboard_unset), (gtk_clipboard_set_text),
(gtk_clipboard_request_targets), (gtk_clipboard_wait_for_targets),
(clipboard_peek), (gtk_clipboard_owner_change),
(gtk_clipboard_wait_is_target_available),
(gtk_clipboard_store_timeout), (gtk_clipboard_set_can_store),
(gtk_clipboard_selection_notify), (gtk_clipboard_store),
(_gtk_clipboard_store_all):
* gtk/gtkclipboard.h:
Add API for clipboard persistence and implement it, also add
gtk_clipboard_wait_is_target_available.
* gtk/gtkmain.c: (gtk_main):
Call _gtk_clipboard_store_all before exiting.
2004-10-25 18:53:30 +00:00
2005-01-19 14:37:56 +00:00
/**
* gdk_x11_display_get_user_time :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2005-01-19 14:37:56 +00:00
*
* Returns the timestamp of the last user interaction on
* @ display . The timestamp is taken from events caused
* by user interaction such as key presses or pointer
2018-03-20 10:40:08 +00:00
* movements . See gdk_x11_surface_set_user_time ( ) .
2005-01-19 14:37:56 +00:00
*
* Returns : the timestamp of the last user interaction
*/
guint32
gdk_x11_display_get_user_time ( GdkDisplay * display )
{
2010-12-20 18:20:10 +00:00
return GDK_X11_DISPLAY ( display ) - > user_time ;
2005-01-19 14:37:56 +00:00
}
2005-03-16 03:17:27 +00:00
2007-03-13 17:03:54 +00:00
/**
* gdk_x11_display_get_startup_notification_id :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2007-03-13 17:03:54 +00:00
*
2007-05-26 20:50:34 +00:00
* Gets the startup notification ID for a display .
*
* Returns : the startup notification ID for @ display
2007-03-13 17:03:54 +00:00
*/
2020-07-24 18:40:36 +00:00
const char *
2007-03-13 17:03:54 +00:00
gdk_x11_display_get_startup_notification_id ( GdkDisplay * display )
{
2010-12-20 18:20:10 +00:00
return GDK_X11_DISPLAY ( display ) - > startup_notification_id ;
2007-03-13 17:03:54 +00:00
}
2010-10-18 15:11:58 +00:00
/**
* gdk_x11_display_set_startup_notification_id :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2010-10-18 15:11:58 +00:00
* @ startup_id : the startup notification ID ( must be valid utf8 )
*
* Sets the startup notification ID for a display .
*
* This is usually taken from the value of the DESKTOP_STARTUP_ID
* environment variable , but in some cases ( such as the application not
* being launched using exec ( ) ) it can come from other sources .
*
* If the ID contains the string " _TIME " then the portion following that
* string is taken to be the X11 timestamp of the event that triggered
* the application to be launched and the GDK current event time is set
* accordingly .
*
* The startup ID is also what is used to signal that the startup is
* complete ( for example , when opening a window or when calling
2020-08-05 19:42:27 +00:00
* gdk_display_notify_startup_complete ( ) ) .
2010-10-18 15:11:58 +00:00
* */
void
gdk_x11_display_set_startup_notification_id ( GdkDisplay * display ,
2020-07-24 18:40:36 +00:00
const char * startup_id )
2010-10-18 15:11:58 +00:00
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2020-07-24 18:40:36 +00:00
char * time_str ;
2010-10-18 15:11:58 +00:00
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-10-18 15:11:58 +00:00
g_free ( display_x11 - > startup_notification_id ) ;
display_x11 - > startup_notification_id = g_strdup ( startup_id ) ;
2015-07-06 18:08:11 +00:00
if ( startup_id ! = NULL )
2010-10-18 15:11:58 +00:00
{
2015-07-06 18:08:11 +00:00
/* Find the launch time from the startup_id, if it's there. Newer spec
* states that the startup_id is of the form < unique > _TIME < timestamp >
*/
time_str = g_strrstr ( startup_id , " _TIME " ) ;
if ( time_str ! = NULL )
{
gulong retval ;
2020-07-24 18:40:36 +00:00
char * end ;
2015-07-06 18:08:11 +00:00
errno = 0 ;
2010-10-18 15:11:58 +00:00
2015-07-06 18:08:11 +00:00
/* Skip past the "_TIME" part */
time_str + = 5 ;
2010-10-18 15:11:58 +00:00
2015-07-06 18:08:11 +00:00
retval = strtoul ( time_str , & end , 0 ) ;
if ( end ! = time_str & & errno = = 0 )
display_x11 - > user_time = retval ;
}
else
display_x11 - > user_time = 0 ;
2010-10-18 15:11:58 +00:00
2015-07-06 18:08:11 +00:00
/* Set the startup id on the leader window so it
* applies to all windows we create on this display
*/
XChangeProperty ( display_x11 - > xdisplay ,
display_x11 - > leader_window ,
gdk_x11_get_xatom_by_name_for_display ( display , " _NET_STARTUP_ID " ) ,
gdk_x11_get_xatom_by_name_for_display ( display , " UTF8_STRING " ) , 8 ,
PropModeReplace ,
( guchar * ) startup_id , strlen ( startup_id ) ) ;
}
else
{
XDeleteProperty ( display_x11 - > xdisplay , display_x11 - > leader_window ,
gdk_x11_get_xatom_by_name_for_display ( display , " _NET_STARTUP_ID " ) ) ;
display_x11 - > user_time = 0 ;
}
2010-10-18 15:11:58 +00:00
}
2014-02-03 20:37:00 +00:00
/* look up the extension name for a given major opcode. grubs around in
2014-02-07 18:01:26 +00:00
* xlib to do it since a ) it ’ s already cached there b ) XQueryExtension
2014-02-07 18:32:47 +00:00
* emits protocol so we can ’ t use it in an error handler .
2014-02-03 20:37:00 +00:00
*/
static const char *
_gdk_x11_decode_request_code ( Display * dpy , int code )
{
_XExtension * ext ;
if ( code < 128 )
return " core protocol " ;
for ( ext = dpy - > ext_procs ; ext ; ext = ext - > next )
{
if ( ext - > codes . major_opcode = = code )
return ext - > name ;
}
return " unknown " ;
}
2010-09-18 22:19:27 +00:00
/* compare X sequence numbers handling wraparound */
# define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
/* delivers an error event from the error handler in gdkmain-x11.c */
void
_gdk_x11_display_error_event ( GdkDisplay * display ,
XErrorEvent * error )
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2010-09-18 22:19:27 +00:00
GSList * tmp_list ;
gboolean ignore ;
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-09-18 22:19:27 +00:00
ignore = FALSE ;
for ( tmp_list = display_x11 - > error_traps ;
tmp_list ! = NULL ;
tmp_list = tmp_list - > next )
{
GdkErrorTrap * trap ;
trap = tmp_list - > data ;
if ( SEQUENCE_COMPARE ( trap - > start_sequence , < = , error - > serial ) & &
( trap - > end_sequence = = 0 | |
SEQUENCE_COMPARE ( trap - > end_sequence , > , error - > serial ) ) )
{
ignore = TRUE ;
trap - > error_code = error - > error_code ;
2010-09-20 20:12:11 +00:00
break ; /* only innermost trap gets the error code */
2010-09-18 22:19:27 +00:00
}
}
if ( ! ignore )
{
2020-07-24 18:40:36 +00:00
char buf [ 64 ] ;
char * msg ;
2010-09-18 22:19:27 +00:00
XGetErrorText ( display_x11 - > xdisplay , error - > error_code , buf , 63 ) ;
msg =
g_strdup_printf ( " The program '%s' received an X Window System error. \n "
" This probably reflects a bug in the program. \n "
" The error was '%s'. \n "
2014-02-03 20:37:00 +00:00
" (Details: serial %ld error_code %d request_code %d (%s) minor_code %d) \n "
2010-09-18 22:19:27 +00:00
" (Note to programmers: normally, X errors are reported asynchronously; \n "
" that is, you will receive the error a while after causing it. \n "
2011-10-21 01:48:54 +00:00
" To debug your program, run it with the GDK_SYNCHRONIZE environment \n "
" variable to change this behavior. You can then get a meaningful \n "
2010-09-18 22:19:27 +00:00
" backtrace from your debugger if you break on the gdk_x_error() function.) " ,
g_get_prgname ( ) ,
buf ,
error - > serial ,
error - > error_code ,
error - > request_code ,
2014-02-03 20:37:00 +00:00
_gdk_x11_decode_request_code ( display_x11 - > xdisplay ,
error - > request_code ) ,
2010-09-18 22:19:27 +00:00
error - > minor_code ) ;
# ifdef G_ENABLE_DEBUG
g_error ( " %s " , msg ) ;
# else /* !G_ENABLE_DEBUG */
2016-02-28 17:19:58 +00:00
g_warning ( " %s " , msg ) ;
2010-09-18 22:19:27 +00:00
2011-03-31 23:59:00 +00:00
_exit ( 1 ) ;
2010-09-18 22:19:27 +00:00
# endif /* G_ENABLE_DEBUG */
}
}
static void
2010-12-20 16:14:04 +00:00
delete_outdated_error_traps ( GdkX11Display * display_x11 )
2010-09-18 22:19:27 +00:00
{
GSList * tmp_list ;
gulong processed_sequence ;
processed_sequence = XLastKnownRequestProcessed ( display_x11 - > xdisplay ) ;
tmp_list = display_x11 - > error_traps ;
while ( tmp_list ! = NULL )
{
GdkErrorTrap * trap = tmp_list - > data ;
if ( trap - > end_sequence ! = 0 & &
2010-09-22 01:10:15 +00:00
SEQUENCE_COMPARE ( trap - > end_sequence , < = , processed_sequence ) )
2010-09-18 22:19:27 +00:00
{
GSList * free_me = tmp_list ;
tmp_list = tmp_list - > next ;
display_x11 - > error_traps =
g_slist_delete_link ( display_x11 - > error_traps , free_me ) ;
g_slice_free ( GdkErrorTrap , trap ) ;
}
else
{
tmp_list = tmp_list - > next ;
}
}
}
/**
* gdk_x11_display_error_trap_push :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2010-09-18 22:19:27 +00:00
*
2010-10-01 12:16:38 +00:00
* Begins a range of X requests on @ display for which X error events
* will be ignored . Unignored errors ( when no trap is pushed ) will abort
* the application . Use gdk_x11_display_error_trap_pop ( ) or
* gdk_x11_display_error_trap_pop_ignored ( ) to lift a trap pushed
* with this function .
2010-09-18 22:19:27 +00:00
*/
void
gdk_x11_display_error_trap_push ( GdkDisplay * display )
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2010-09-18 22:19:27 +00:00
GdkErrorTrap * trap ;
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-09-18 22:19:27 +00:00
delete_outdated_error_traps ( display_x11 ) ;
/* set up the Xlib callback to tell us about errors */
_gdk_x11_error_handler_push ( ) ;
trap = g_slice_new0 ( GdkErrorTrap ) ;
trap - > start_sequence = XNextRequest ( display_x11 - > xdisplay ) ;
trap - > error_code = Success ;
display_x11 - > error_traps =
g_slist_prepend ( display_x11 - > error_traps , trap ) ;
}
2020-07-24 13:54:49 +00:00
static int
2010-09-18 22:19:27 +00:00
gdk_x11_display_error_trap_pop_internal ( GdkDisplay * display ,
gboolean need_code )
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2010-09-18 22:19:27 +00:00
GdkErrorTrap * trap ;
GSList * tmp_list ;
int result ;
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-09-18 22:19:27 +00:00
g_return_val_if_fail ( display_x11 - > error_traps ! = NULL , Success ) ;
/* Find the first trap that hasn't been popped already */
trap = NULL ; /* quiet gcc */
for ( tmp_list = display_x11 - > error_traps ;
tmp_list ! = NULL ;
tmp_list = tmp_list - > next )
{
trap = tmp_list - > data ;
if ( trap - > end_sequence = = 0 )
break ;
}
2020-03-05 06:02:24 +00:00
if ( trap = = NULL )
{
g_critical ( " gdk_x11_display_error_trap_pop() called without gdk_x11_display_error_trap_push() " ) ;
return Success ;
}
2010-09-18 22:19:27 +00:00
g_assert ( trap - > end_sequence = = 0 ) ;
/* May need to sync to fill in trap->error_code if we care about
* getting an error code .
*/
if ( need_code )
{
gulong processed_sequence ;
gulong next_sequence ;
next_sequence = XNextRequest ( display_x11 - > xdisplay ) ;
processed_sequence = XLastKnownRequestProcessed ( display_x11 - > xdisplay ) ;
/* If our last request was already processed, there is no point
* in syncing . i . e . if last request was a round trip ( or even if
* we got an event with the serial of a non - round - trip )
*/
if ( ( next_sequence - 1 ) ! = processed_sequence )
{
XSync ( display_x11 - > xdisplay , False ) ;
}
result = trap - > error_code ;
}
else
{
result = Success ;
}
/* record end of trap, giving us a range of
* error sequences we ' ll ignore .
*/
trap - > end_sequence = XNextRequest ( display_x11 - > xdisplay ) ;
/* remove the Xlib callback */
_gdk_x11_error_handler_pop ( ) ;
/* we may already be outdated */
delete_outdated_error_traps ( display_x11 ) ;
return result ;
}
2013-08-20 09:15:08 +00:00
/**
2018-03-20 11:05:26 +00:00
* gdk_x11_display_set_surface_scale :
2013-08-20 09:15:08 +00:00
* @ display : ( type GdkX11Display ) : the display
* @ scale : The new scale value
*
* Forces a specific window scale for all windows on this display ,
* instead of using the default or user configured scale . This
* is can be used to disable scaling support by setting @ scale to
* 1 , or to programmatically set the window scale .
*
* Once the scale is set by this call it will not change in response
* to later user configuration changes .
*/
void
2018-03-20 11:05:26 +00:00
gdk_x11_display_set_surface_scale ( GdkDisplay * display ,
2020-07-24 13:54:49 +00:00
int scale )
2013-08-20 09:15:08 +00:00
{
GdkX11Screen * x11_screen ;
2014-03-05 20:42:38 +00:00
gboolean need_reread_settings = FALSE ;
2013-08-20 09:15:08 +00:00
g_return_if_fail ( GDK_IS_X11_DISPLAY ( display ) ) ;
scale = MAX ( scale , 1 ) ;
x11_screen = GDK_X11_SCREEN ( GDK_X11_DISPLAY ( display ) - > screen ) ;
2018-03-20 11:05:26 +00:00
if ( ! x11_screen - > fixed_surface_scale )
2014-03-05 20:42:38 +00:00
{
2018-03-20 11:05:26 +00:00
x11_screen - > fixed_surface_scale = TRUE ;
2014-03-05 20:42:38 +00:00
/* We treat screens with a window scale set differently when
2014-07-10 22:35:54 +00:00
* reading xsettings , so we need to reread
*/
2014-03-05 20:42:38 +00:00
need_reread_settings = TRUE ;
}
2018-03-20 11:05:26 +00:00
_gdk_x11_screen_set_surface_scale ( x11_screen , scale ) ;
2014-03-05 20:42:38 +00:00
if ( need_reread_settings )
_gdk_x11_settings_force_reread ( x11_screen ) ;
2013-08-20 09:15:08 +00:00
}
2010-09-18 22:19:27 +00:00
/**
* gdk_x11_display_error_trap_pop :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : the display
2010-09-18 22:19:27 +00:00
*
* Pops the error trap pushed by gdk_x11_display_error_trap_push ( ) .
* Will XSync ( ) if necessary and will always block until
* the error is known to have occurred or not occurred ,
* so the error code can be returned .
*
2014-02-07 18:32:47 +00:00
* If you don ’ t need to use the return value ,
2010-09-18 22:19:27 +00:00
* gdk_x11_display_error_trap_pop_ignored ( ) would be more efficient .
*
2014-02-19 23:49:43 +00:00
* Returns : X error code or 0 on success
2010-09-18 22:19:27 +00:00
*/
2020-07-24 13:54:49 +00:00
int
2010-09-18 22:19:27 +00:00
gdk_x11_display_error_trap_pop ( GdkDisplay * display )
{
2010-12-20 18:20:10 +00:00
g_return_val_if_fail ( GDK_IS_X11_DISPLAY ( display ) , Success ) ;
2010-09-18 22:19:27 +00:00
return gdk_x11_display_error_trap_pop_internal ( display , TRUE ) ;
}
/**
* gdk_x11_display_error_trap_pop_ignored :
2011-07-28 11:27:23 +00:00
* @ display : ( type GdkX11Display ) : the display
2010-09-18 22:19:27 +00:00
*
* Pops the error trap pushed by gdk_x11_display_error_trap_push ( ) .
* Does not block to see if an error occurred ; merely records the
* range of requests to ignore errors for , and ignores those errors
* if they arrive asynchronously .
*/
void
gdk_x11_display_error_trap_pop_ignored ( GdkDisplay * display )
{
2010-12-20 18:20:10 +00:00
g_return_if_fail ( GDK_IS_X11_DISPLAY ( display ) ) ;
2010-09-18 22:19:27 +00:00
gdk_x11_display_error_trap_pop_internal ( display , FALSE ) ;
}
2010-12-05 21:37:03 +00:00
2010-12-13 18:45:38 +00:00
/**
* gdk_x11_set_sm_client_id :
2018-11-18 12:36:50 +00:00
* @ sm_client_id : ( nullable ) : the client id assigned by the session manager
* when the connection was opened , or % NULL to remove the property .
2010-12-13 18:45:38 +00:00
*
2014-02-07 18:01:26 +00:00
* Sets the ` SM_CLIENT_ID ` property on the application ’ s leader window so that
* the window manager can save the application ’ s state using the X11R6 ICCCM
2010-12-13 18:45:38 +00:00
* session management protocol .
*
* See the X Session Management Library documentation for more information on
* session management and the Inter - Client Communication Conventions Manual
*/
void
2020-07-24 18:40:36 +00:00
gdk_x11_set_sm_client_id ( const char * sm_client_id )
2010-12-13 18:45:38 +00:00
{
GSList * displays , * l ;
g_free ( gdk_sm_client_id ) ;
gdk_sm_client_id = g_strdup ( sm_client_id ) ;
displays = gdk_display_manager_list_displays ( gdk_display_manager_get ( ) ) ;
for ( l = displays ; l ; l = l - > next )
2014-10-24 22:38:15 +00:00
{
if ( GDK_IS_X11_DISPLAY ( l - > data ) )
set_sm_client_id ( l - > data , sm_client_id ) ;
}
2010-12-13 18:45:38 +00:00
g_slist_free ( displays ) ;
}
2017-11-25 00:25:31 +00:00
gsize
gdk_x11_display_get_max_request_size ( GdkDisplay * display )
{
Display * xdisplay = GDK_DISPLAY_XDISPLAY ( display ) ;
gsize size ;
size = XExtendedMaxRequestSize ( xdisplay ) ;
if ( size < = 0 )
size = XMaxRequestSize ( xdisplay ) ;
size = MIN ( 262144 , size - 100 ) ;
return size ;
}
2010-12-13 18:45:38 +00:00
2017-12-21 18:49:25 +00:00
/**
* gdk_x11_display_get_screen :
2020-07-31 17:11:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkX11Display
2017-12-21 18:49:25 +00:00
*
* Retrieves the # GdkX11Screen of the @ display .
*
* Returns : ( transfer none ) : the # GdkX11Screen
*/
2017-11-17 15:18:20 +00:00
GdkX11Screen *
2017-11-01 22:39:05 +00:00
gdk_x11_display_get_screen ( GdkDisplay * display )
{
return GDK_X11_DISPLAY ( display ) - > screen ;
}
2010-12-16 05:08:42 +00:00
static GdkKeymap *
gdk_x11_display_get_keymap ( GdkDisplay * display )
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2010-12-16 05:08:42 +00:00
g_return_val_if_fail ( GDK_IS_DISPLAY ( display ) , NULL ) ;
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-12-16 05:08:42 +00:00
if ( ! display_x11 - > keymap )
2018-01-12 02:45:32 +00:00
{
display_x11 - > keymap = g_object_new ( GDK_TYPE_X11_KEYMAP , NULL ) ;
display_x11 - > keymap - > display = display ; /* beware of ref cycle */
}
2010-12-16 05:08:42 +00:00
return display_x11 - > keymap ;
}
2015-11-26 18:53:36 +00:00
static GdkSeat *
gdk_x11_display_get_default_seat ( GdkDisplay * display )
{
GList * seats , * l ;
int device_id ;
2016-05-11 01:29:10 +00:00
gboolean result = FALSE ;
2015-11-26 18:53:36 +00:00
seats = gdk_display_list_seats ( display ) ;
2016-05-11 01:29:10 +00:00
gdk_x11_display_error_trap_push ( display ) ;
result = XIGetClientPointer ( GDK_DISPLAY_XDISPLAY ( display ) ,
None , & device_id ) ;
gdk_x11_display_error_trap_pop_ignored ( display ) ;
2015-11-26 18:53:36 +00:00
for ( l = seats ; l ; l = l - > next )
{
GdkDevice * pointer ;
pointer = gdk_seat_get_pointer ( l - > data ) ;
2016-05-11 01:29:10 +00:00
if ( gdk_x11_device_get_id ( pointer ) = = device_id | | ! result )
2016-01-18 16:22:09 +00:00
{
GdkSeat * seat = l - > data ;
g_list_free ( seats ) ;
return seat ;
}
2015-11-26 18:53:36 +00:00
}
g_list_free ( seats ) ;
return NULL ;
}
2020-05-13 05:00:35 +00:00
static GListModel *
gdk_x11_display_get_monitors ( GdkDisplay * display )
{
GdkX11Display * self = GDK_X11_DISPLAY ( display ) ;
return G_LIST_MODEL ( self - > monitors ) ;
}
2020-01-30 20:01:24 +00:00
/**
* gdk_x11_display_get_primary_monitor :
2020-07-31 17:11:23 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2020-01-30 20:01:24 +00:00
*
* Gets the primary monitor for the display .
*
* The primary monitor is considered the monitor where the “ main desktop ”
* lives . While normal application surfaces typically allow the window
* manager to place the surfaces , specialized desktop applications
* such as panels should place themselves on the primary monitor .
*
* If no monitor is the designated primary monitor , any monitor
2020-02-02 17:12:08 +00:00
* ( usually the first ) may be returned .
2020-01-30 20:01:24 +00:00
*
* Returns : ( transfer none ) : the primary monitor , or any monitor if no
* primary monitor is configured by the user
*/
GdkMonitor *
2016-04-03 04:12:39 +00:00
gdk_x11_display_get_primary_monitor ( GdkDisplay * display )
{
2020-05-12 17:46:40 +00:00
GdkX11Display * self = GDK_X11_DISPLAY ( display ) ;
GdkMonitor * monitor ;
2016-04-03 04:12:39 +00:00
2020-05-12 17:46:40 +00:00
monitor = g_list_model_get_item ( G_LIST_MODEL ( self - > monitors ) , self - > primary_monitor ) ;
if ( monitor = = NULL )
2020-08-08 14:17:06 +00:00
monitor = g_list_model_get_item ( G_LIST_MODEL ( self - > monitors ) , 0 ) ;
2020-05-12 17:46:40 +00:00
/* because g_list_model_get_item() returns a ref */
2020-08-08 14:17:06 +00:00
if ( monitor )
g_object_unref ( monitor ) ;
2020-05-12 17:46:40 +00:00
return monitor ;
2016-04-03 04:12:39 +00:00
}
2016-11-03 21:40:36 +00:00
int
gdk_x11_display_get_window_depth ( GdkX11Display * display )
{
2016-11-03 22:40:54 +00:00
return display - > window_depth ;
2016-11-03 21:40:36 +00:00
}
Visual *
gdk_x11_display_get_window_visual ( GdkX11Display * display )
{
2016-11-03 22:40:54 +00:00
return display - > window_visual ;
2016-11-03 21:40:36 +00:00
}
Colormap
gdk_x11_display_get_window_colormap ( GdkX11Display * display )
{
2016-11-03 22:40:54 +00:00
return display - > window_colormap ;
2016-11-03 21:40:36 +00:00
}
2017-10-30 20:44:18 +00:00
static gboolean
gdk_x11_display_get_setting ( GdkDisplay * display ,
2020-07-24 18:40:36 +00:00
const char * name ,
2017-10-30 20:44:18 +00:00
GValue * value )
{
return gdk_x11_screen_get_setting ( GDK_X11_DISPLAY ( display ) - > screen , name , value ) ;
}
2017-11-05 23:33:56 +00:00
GList *
gdk_x11_display_get_toplevel_windows ( GdkDisplay * display )
{
2017-11-13 21:32:34 +00:00
return GDK_X11_DISPLAY ( display ) - > toplevels ;
2017-11-05 23:33:56 +00:00
}
2017-12-12 23:43:30 +00:00
static gboolean
2017-12-13 00:53:17 +00:00
gdk_boolean_handled_accumulator ( GSignalInvocationHint * ihint ,
GValue * return_accu ,
const GValue * handler_return ,
gpointer dummy )
2017-12-12 23:43:30 +00:00
{
2017-12-13 00:53:17 +00:00
gboolean continue_emission ;
gboolean signal_handled ;
2017-12-12 23:43:30 +00:00
2017-12-13 00:53:17 +00:00
signal_handled = g_value_get_boolean ( handler_return ) ;
g_value_set_boolean ( return_accu , signal_handled ) ;
continue_emission = ! signal_handled ;
2017-12-12 23:43:30 +00:00
2017-12-13 00:53:17 +00:00
return continue_emission ;
2017-12-12 23:43:30 +00:00
}
2010-12-05 21:37:03 +00:00
static void
2010-12-20 18:42:53 +00:00
gdk_x11_display_class_init ( GdkX11DisplayClass * class )
2010-12-05 21:37:03 +00:00
{
GObjectClass * object_class = G_OBJECT_CLASS ( class ) ;
GdkDisplayClass * display_class = GDK_DISPLAY_CLASS ( class ) ;
2010-12-20 18:20:10 +00:00
object_class - > dispose = gdk_x11_display_dispose ;
object_class - > finalize = gdk_x11_display_finalize ;
2010-12-05 21:37:03 +00:00
2018-04-12 14:48:31 +00:00
display_class - > cairo_context_type = GDK_TYPE_X11_CAIRO_CONTEXT ;
2016-12-09 19:11:37 +00:00
# ifdef GDK_RENDERING_VULKAN
2016-11-28 15:34:01 +00:00
display_class - > vk_context_type = GDK_TYPE_X11_VULKAN_CONTEXT ;
display_class - > vk_extension_name = VK_KHR_XLIB_SURFACE_EXTENSION_NAME ;
# endif
2010-12-21 02:34:31 +00:00
2010-12-05 21:37:03 +00:00
display_class - > get_name = gdk_x11_display_get_name ;
display_class - > beep = gdk_x11_display_beep ;
display_class - > sync = gdk_x11_display_sync ;
display_class - > flush = gdk_x11_display_flush ;
2013-04-09 11:32:03 +00:00
display_class - > make_default = gdk_x11_display_make_default ;
2010-12-11 00:42:09 +00:00
display_class - > has_pending = gdk_x11_display_has_pending ;
2010-12-11 01:46:42 +00:00
display_class - > queue_events = _gdk_x11_display_queue_events ;
2010-12-09 06:08:05 +00:00
display_class - > get_app_launch_context = _gdk_x11_display_get_app_launch_context ;
2010-12-13 18:30:05 +00:00
2010-12-13 19:05:59 +00:00
display_class - > get_next_serial = gdk_x11_display_get_next_serial ;
2018-06-04 16:27:36 +00:00
display_class - > get_startup_notification_id = gdk_x11_display_get_startup_notification_id ;
2010-12-14 01:46:00 +00:00
display_class - > notify_startup_complete = gdk_x11_display_notify_startup_complete ;
2019-04-22 01:14:46 +00:00
display_class - > create_surface = _gdk_x11_display_create_surface ;
2010-12-16 05:08:42 +00:00
display_class - > get_keymap = gdk_x11_display_get_keymap ;
2013-05-01 16:11:26 +00:00
2014-10-09 08:45:44 +00:00
display_class - > make_gl_context_current = gdk_x11_display_make_gl_context_current ;
2015-11-26 18:53:36 +00:00
display_class - > get_default_seat = gdk_x11_display_get_default_seat ;
2020-05-13 05:00:35 +00:00
display_class - > get_monitors = gdk_x11_display_get_monitors ;
2017-10-30 20:44:18 +00:00
display_class - > get_setting = gdk_x11_display_get_setting ;
2017-11-17 22:42:12 +00:00
display_class - > set_cursor_theme = gdk_x11_display_set_cursor_theme ;
2016-04-03 04:12:39 +00:00
2017-12-13 00:53:17 +00:00
class - > xevent = gdk_event_source_xevent ;
2017-12-12 23:43:30 +00:00
/**
2017-12-13 00:53:17 +00:00
* GdkX11Display : : xevent :
2020-07-31 17:11:23 +00:00
* @ display : ( type GdkX11Display ) : the object on which the signal is emitted
2017-12-12 23:43:30 +00:00
* @ xevent : a pointer to the XEvent to process
*
2017-12-13 00:53:17 +00:00
* The : : xevent signal is a low level signal that is emitted
* whenever an XEvent has been received .
2017-12-12 23:43:30 +00:00
*
2017-12-13 00:53:17 +00:00
* When handlers to this signal return % TRUE , no other handlers will be
* invoked . In particular , the default handler for this function is
* GDK ' s own event handling mechanism , so by returning % TRUE for an event
* that GDK expects to translate , you may break GDK and / or GTK + in
* interesting ways . You have been warned .
2017-12-12 23:43:30 +00:00
*
2017-12-13 00:53:17 +00:00
* If you want this signal handler to queue a # GdkEvent , you can use
* gdk_display_put_event ( ) .
2017-12-12 23:43:30 +00:00
*
* If you are interested in X GenericEvents , bear in mind that
* XGetEventData ( ) has been already called on the event , and
* XFreeEventData ( ) will be called afterwards .
*
2017-12-13 00:53:17 +00:00
* Returns : % TRUE to stop other handlers from being invoked for the event .
* % FALSE to propagate the event further .
2017-12-12 23:43:30 +00:00
*/
2017-12-13 00:53:17 +00:00
signals [ XEVENT ] =
g_signal_new ( g_intern_static_string ( " xevent " ) ,
2017-12-12 23:43:30 +00:00
G_OBJECT_CLASS_TYPE ( object_class ) ,
G_SIGNAL_RUN_LAST ,
2017-12-13 00:53:17 +00:00
G_STRUCT_OFFSET ( GdkX11DisplayClass , xevent ) ,
gdk_boolean_handled_accumulator , NULL ,
_gdk_marshal_BOOLEAN__POINTER ,
G_TYPE_BOOLEAN , 1 , G_TYPE_POINTER ) ;
2017-12-12 23:43:30 +00:00
2018-03-20 10:40:08 +00:00
_gdk_x11_surfaceing_init ( ) ;
2010-12-05 21:37:03 +00:00
}