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
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"
2002-04-25 22:29:14 +00:00
# include "gdkscreen.h"
# include "gdkinternals.h"
2010-05-25 22:38:44 +00:00
# include "gdkdeviceprivate.h"
2010-12-16 05:08:42 +00:00
# include "gdkkeysprivate.h"
2010-05-25 22:38:44 +00:00
# include "gdkdevicemanager.h"
2002-04-25 22:29:14 +00:00
# include "xsettings-client.h"
2010-12-16 03:09:35 +00:00
# include "gdkdisplay-x11.h"
# include "gdkprivate-x11.h"
# include "gdkscreen-x11.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
# ifdef HAVE_XDAMAGE
# include <X11/extensions/Xdamage.h>
# endif
2007-12-13 18:27:05 +00:00
# ifdef HAVE_RANDR
# include <X11/extensions/Xrandr.h>
# endif
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
2010-12-20 18:20:10 +00:00
static gboolean gdk_x11_display_translate_event ( GdkEventTranslator * translator ,
2010-05-25 22:38:44 +00:00
GdkDisplay * display ,
GdkEvent * event ,
XEvent * xevent ) ;
2002-05-20 19:04:33 +00:00
static void gdk_internal_connection_watch ( Display * display ,
XPointer arg ,
gint fd ,
gboolean opening ,
XPointer * watch_data ) ;
2010-05-25 22:38:44 +00:00
typedef struct _GdkEventTypeX11 GdkEventTypeX11 ;
struct _GdkEventTypeX11
{
gint base ;
gint n_events ;
} ;
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 " ,
" _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 " ,
" _NET_WM_STATE_FOCUSED "
2003-07-05 01:54:05 +00:00
} ;
2010-12-13 18:45:38 +00:00
static char * gdk_sm_client_id ;
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
2002-04-25 22:29:14 +00:00
2006-04-04 14:02:03 +00:00
static void
2010-12-20 18:42:53 +00:00
gdk_x11_display_init ( GdkX11Display * display )
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
}
static void
do_net_wm_state_changes ( GdkWindow * window )
{
GdkToplevelX11 * toplevel = _gdk_x11_window_get_toplevel ( window ) ;
2014-02-23 02:42:05 +00:00
GdkWindowState old_state , set , unset ;
2010-05-25 22:38:44 +00:00
if ( GDK_WINDOW_DESTROYED ( window ) | |
gdk_window_get_window_type ( window ) ! = GDK_WINDOW_TOPLEVEL )
return ;
old_state = gdk_window_get_state ( window ) ;
2014-02-23 02:42:05 +00:00
set = unset = 0 ;
2010-05-25 22:38:44 +00:00
/* For found_sticky to remain TRUE, we have to also be on desktop
* 0xFFFFFFFF
*/
if ( old_state & GDK_WINDOW_STATE_STICKY )
{
if ( ! ( toplevel - > have_sticky & & toplevel - > on_all_desktops ) )
2014-02-23 02:42:05 +00:00
unset | = GDK_WINDOW_STATE_STICKY ;
2010-05-25 22:38:44 +00:00
}
else
{
2011-12-28 16:20:47 +00:00
if ( toplevel - > have_sticky & & toplevel - > on_all_desktops )
2014-02-23 02:42:05 +00:00
set | = GDK_WINDOW_STATE_STICKY ;
2010-05-25 22:38:44 +00:00
}
if ( old_state & GDK_WINDOW_STATE_FULLSCREEN )
{
if ( ! toplevel - > have_fullscreen )
2014-02-23 02:42:05 +00:00
unset | = GDK_WINDOW_STATE_FULLSCREEN ;
2010-05-25 22:38:44 +00:00
}
else
{
if ( toplevel - > have_fullscreen )
2014-02-23 02:42:05 +00:00
set | = GDK_WINDOW_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
*/
if ( old_state & GDK_WINDOW_STATE_MAXIMIZED )
{
if ( ! ( toplevel - > have_maxvert & & toplevel - > have_maxhorz ) )
2014-02-23 02:42:05 +00:00
unset | = GDK_WINDOW_STATE_MAXIMIZED ;
2010-05-25 22:38:44 +00:00
}
else
{
if ( toplevel - > have_maxvert & & toplevel - > have_maxhorz )
2014-02-23 02:42:05 +00:00
set | = GDK_WINDOW_STATE_MAXIMIZED ;
2010-05-25 22:38:44 +00:00
}
2011-10-28 22:29:01 +00:00
2013-05-26 05:05:25 +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
*/
if ( old_state & GDK_WINDOW_STATE_TILED )
{
if ( ! toplevel - > have_maxvert )
2014-02-23 02:42:05 +00:00
unset | = GDK_WINDOW_STATE_TILED ;
2013-05-26 05:05:25 +00:00
}
else
{
2014-02-23 02:42:05 +00:00
if ( toplevel - > have_maxvert & & ! toplevel - > have_maxhorz )
set | = GDK_WINDOW_STATE_TILED ;
2013-05-26 05:05:25 +00:00
}
2011-10-28 22:29:01 +00:00
if ( old_state & GDK_WINDOW_STATE_FOCUSED )
{
if ( ! toplevel - > have_focused )
2014-02-23 02:42:05 +00:00
unset | = GDK_WINDOW_STATE_FOCUSED ;
2011-10-28 22:29:01 +00:00
}
else
{
if ( toplevel - > have_focused )
2014-02-23 02:42:05 +00:00
set | = GDK_WINDOW_STATE_FOCUSED ;
2011-10-28 22:29:01 +00:00
}
2012-02-21 16:14:16 +00:00
if ( old_state & GDK_WINDOW_STATE_ICONIFIED )
{
if ( ! toplevel - > have_hidden )
2014-02-23 02:42:05 +00:00
unset | = GDK_WINDOW_STATE_ICONIFIED ;
2012-02-21 16:14:16 +00:00
}
else
{
if ( toplevel - > have_hidden )
2014-02-23 02:42:05 +00:00
set | = GDK_WINDOW_STATE_ICONIFIED ;
2012-02-21 16:14:16 +00:00
}
2014-02-23 02:42:05 +00:00
gdk_synthesize_window_state ( window , unset , set ) ;
2010-05-25 22:38:44 +00:00
}
static void
gdk_check_wm_desktop_changed ( GdkWindow * window )
{
GdkToplevelX11 * toplevel = _gdk_x11_window_get_toplevel ( window ) ;
GdkDisplay * display = GDK_WINDOW_DISPLAY ( window ) ;
Atom type ;
gint format ;
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 ) ,
GDK_WINDOW_XID ( window ) ,
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 ;
do_net_wm_state_changes ( window ) ;
}
static void
gdk_check_wm_state_changed ( GdkWindow * window )
{
GdkToplevelX11 * toplevel = _gdk_x11_window_get_toplevel ( window ) ;
GdkDisplay * display = GDK_WINDOW_DISPLAY ( window ) ;
2011-10-28 22:29:01 +00:00
GdkScreen * screen = GDK_WINDOW_SCREEN ( window ) ;
2010-05-25 22:38:44 +00:00
Atom type ;
gint format ;
gulong nitems ;
gulong bytes_after ;
guchar * data ;
Atom * atoms = NULL ;
gulong i ;
gboolean had_sticky = toplevel - > have_sticky ;
toplevel - > have_sticky = FALSE ;
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 ) ;
2010-05-25 22:38:44 +00:00
XGetWindowProperty ( GDK_DISPLAY_XDISPLAY ( display ) , GDK_WINDOW_XID ( window ) ,
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 sticky_atom = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_STATE_STICKY " ) ;
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 )
{
if ( atoms [ i ] = = sticky_atom )
toplevel - > have_sticky = TRUE ;
else if ( atoms [ i ] = = maxvert_atom )
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 ,
gdk_atom_intern_static_string ( " _NET_WM_STATE_FOCUSED " ) ) )
toplevel - > have_focused = TRUE ;
2010-05-25 22:38:44 +00:00
/* When have_sticky is turned on, we have to check the DESKTOP property
* as well .
*/
if ( toplevel - > have_sticky & & ! had_sticky )
gdk_check_wm_desktop_changed ( window ) ;
else
do_net_wm_state_changes ( window ) ;
}
2012-09-19 02:13:06 +00:00
static Window
get_event_xwindow ( 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
}
static gboolean
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 ,
GdkEvent * event ,
XEvent * xevent )
{
2012-09-19 02:13:06 +00:00
Window xwindow ;
2010-05-25 22:38:44 +00:00
GdkWindow * window ;
2012-09-19 02:13:06 +00:00
gboolean is_substructure ;
2010-05-25 22:38:44 +00:00
GdkWindowImplX11 * window_impl = NULL ;
GdkScreen * screen = 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 ) ;
2010-05-25 22:38:44 +00:00
gboolean return_val ;
2012-09-19 02:13:06 +00:00
/* Find the GdkWindow that this event relates to. If that's
* not the same as the window that the event was sent to ,
* 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
2012-09-19 02:13:06 +00:00
window = gdk_x11_window_lookup_for_display ( display , xwindow ) ;
2010-05-25 22:38:44 +00:00
if ( window )
{
/* We may receive events such as NoExpose/GraphicsExpose
* and ShmCompletion for pixmaps
*/
if ( ! GDK_IS_WINDOW ( window ) )
return FALSE ;
screen = GDK_WINDOW_SCREEN ( window ) ;
2010-12-21 01:32:13 +00:00
x11_screen = GDK_X11_SCREEN ( screen ) ;
2010-05-25 22:38:44 +00:00
toplevel = _gdk_x11_window_get_toplevel ( window ) ;
2010-11-22 23:55:39 +00:00
window_impl = GDK_WINDOW_IMPL_X11 ( window - > impl ) ;
2010-05-25 22:38:44 +00:00
g_object_ref ( window ) ;
}
event - > any . window = window ;
event - > any . send_event = xevent - > xany . send_event ? TRUE : FALSE ;
2010-11-22 23:55:39 +00:00
if ( window & & GDK_WINDOW_DESTROYED ( window ) )
2010-05-25 22:38:44 +00:00
{
if ( xevent - > type ! = DestroyNotify )
{
return_val = FALSE ;
goto done ;
}
}
2012-09-19 02:13:06 +00:00
if ( xevent - > type = = DestroyNotify & & ! is_substructure )
2010-05-25 22:38:44 +00:00
{
2013-04-04 14:22:12 +00:00
screen = GDK_X11_DISPLAY ( display ) - > screen ;
x11_screen = GDK_X11_SCREEN ( 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 */
_gdk_x11_screen_window_manager_changed ( screen ) ;
return_val = FALSE ;
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 .
*/
return_val = TRUE ;
switch ( xevent - > type )
{
case KeymapNotify :
GDK_NOTE ( EVENTS ,
g_message ( " keymap notify " ) ) ;
/* Not currently handled */
return_val = FALSE ;
break ;
case Expose :
GDK_NOTE ( EVENTS ,
g_message ( " expose: \t \t window: %ld %d x,y: %d %d w,h: %d %d%s " ,
xevent - > xexpose . window , xevent - > xexpose . count ,
xevent - > xexpose . x , xevent - > xexpose . y ,
xevent - > xexpose . width , xevent - > xexpose . height ,
event - > any . send_event ? " (send) " : " " ) ) ;
2010-11-22 23:55:39 +00:00
if ( window = = NULL )
2010-05-25 22:38:44 +00:00
{
return_val = FALSE ;
break ;
}
{
GdkRectangle expose_rect ;
2013-06-20 09:40:07 +00:00
int x2 , y2 ;
2010-05-25 22:38:44 +00:00
2013-06-20 09:40:07 +00:00
expose_rect . x = xevent - > xexpose . x / window_impl - > window_scale ;
expose_rect . y = xevent - > xexpose . y / window_impl - > window_scale ;
x2 = ( xevent - > xexpose . x + xevent - > xexpose . width + window_impl - > window_scale - 1 ) / window_impl - > window_scale ;
expose_rect . width = x2 - expose_rect . x ;
y2 = ( xevent - > xexpose . y + xevent - > xexpose . height + window_impl - > window_scale - 1 ) / window_impl - > window_scale ;
expose_rect . height = y2 - expose_rect . y ;
2010-05-25 22:38:44 +00:00
2010-12-16 03:21:39 +00:00
_gdk_x11_window_process_expose ( window , xevent - > xexpose . serial , & expose_rect ) ;
2010-05-25 22:38:44 +00:00
return_val = FALSE ;
}
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
GDK_NOTE ( EVENTS ,
g_message ( " graphics expose: \t drawable: %ld " ,
xevent - > xgraphicsexpose . drawable ) ) ;
2010-11-22 23:55:39 +00:00
if ( window = = NULL )
2010-05-25 22:38:44 +00:00
{
return_val = FALSE ;
break ;
}
2013-06-20 09:40:07 +00:00
expose_rect . x = xevent - > xgraphicsexpose . x / window_impl - > window_scale ;
expose_rect . y = xevent - > xgraphicsexpose . y / window_impl - > window_scale ;
x2 = ( xevent - > xgraphicsexpose . x + xevent - > xgraphicsexpose . width + window_impl - > window_scale - 1 ) / window_impl - > window_scale ;
expose_rect . width = x2 - expose_rect . x ;
y2 = ( xevent - > xgraphicsexpose . y + xevent - > xgraphicsexpose . height + window_impl - > window_scale - 1 ) / window_impl - > window_scale ;
expose_rect . height = y2 - expose_rect . y ;
2010-05-25 22:38:44 +00:00
2010-12-16 03:21:39 +00:00
_gdk_x11_window_process_expose ( window , xevent - > xgraphicsexpose . serial , & expose_rect ) ;
2010-05-25 22:38:44 +00:00
return_val = FALSE ;
}
break ;
case VisibilityNotify :
# ifdef G_ENABLE_DEBUG
if ( _gdk_debug_flags & GDK_DEBUG_EVENTS )
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 ;
}
# endif /* G_ENABLE_DEBUG */
2010-11-22 23:55:39 +00:00
if ( window = = NULL )
2010-05-25 22:38:44 +00:00
{
return_val = FALSE ;
break ;
}
event - > visibility . type = GDK_VISIBILITY_NOTIFY ;
event - > visibility . window = window ;
switch ( xevent - > xvisibility . state )
{
case VisibilityFullyObscured :
event - > visibility . state = GDK_VISIBILITY_FULLY_OBSCURED ;
break ;
case VisibilityPartiallyObscured :
event - > visibility . state = GDK_VISIBILITY_PARTIAL ;
break ;
case VisibilityUnobscured :
event - > visibility . state = GDK_VISIBILITY_UNOBSCURED ;
break ;
}
break ;
case CreateNotify :
GDK_NOTE ( EVENTS ,
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 :
GDK_NOTE ( EVENTS ,
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
{
event - > any . type = GDK_DESTROY ;
event - > any . window = window ;
2010-11-22 23:55:39 +00:00
return_val = window & & ! GDK_WINDOW_DESTROYED ( window ) ;
2010-05-25 22:38:44 +00:00
2010-12-21 01:32:13 +00:00
if ( window & & GDK_WINDOW_XID ( window ) ! = x11_screen - > xroot_window )
2010-05-25 22:38:44 +00:00
gdk_window_destroy_notify ( window ) ;
}
else
return_val = FALSE ;
break ;
case UnmapNotify :
GDK_NOTE ( EVENTS ,
g_message ( " unmap notify: \t \t window: %ld " ,
xevent - > xmap . window ) ) ;
event - > any . type = GDK_UNMAP ;
event - > any . window = window ;
2012-09-19 02:13:06 +00:00
if ( window & & ! is_substructure )
{
/* 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
*/
2012-09-19 02:13:06 +00:00
if ( screen & &
! gdk_x11_screen_supports_net_wm_hint ( screen ,
gdk_atom_intern_static_string ( " _NET_WM_STATE_HIDDEN " ) ) )
{
/* 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
* the iconified bit off .
*/
if ( GDK_WINDOW_IS_MAPPED ( window ) )
gdk_synthesize_window_state ( window ,
0 ,
GDK_WINDOW_STATE_ICONIFIED ) ;
}
2010-05-25 22:38:44 +00:00
2012-09-18 13:37:03 +00:00
if ( window_impl - > toplevel & &
window_impl - > toplevel - > frame_pending )
{
window_impl - > toplevel - > frame_pending = FALSE ;
2013-02-12 20:03:21 +00:00
_gdk_frame_clock_thaw ( gdk_window_get_frame_clock ( event - > any . window ) ) ;
2012-09-18 13:37:03 +00:00
}
2012-10-04 00:13:42 +00:00
if ( toplevel )
gdk_window_freeze_toplevel_updates_libgtk_only ( window ) ;
2012-09-19 02:13:06 +00:00
_gdk_x11_window_grab_check_unmap ( window , xevent - > xany . serial ) ;
}
2012-05-16 21:18:51 +00:00
2010-05-25 22:38:44 +00:00
break ;
case MapNotify :
GDK_NOTE ( EVENTS ,
g_message ( " map notify: \t \t window: %ld " ,
xevent - > xmap . window ) ) ;
event - > any . type = GDK_MAP ;
event - > any . window = window ;
2012-09-19 02:13:06 +00:00
if ( window & & ! is_substructure )
{
/* Unset iconified if it was set */
if ( window - > state & GDK_WINDOW_STATE_ICONIFIED )
gdk_synthesize_window_state ( window ,
GDK_WINDOW_STATE_ICONIFIED ,
0 ) ;
2012-10-04 00:13:42 +00:00
if ( toplevel )
gdk_window_thaw_toplevel_updates_libgtk_only ( window ) ;
2012-09-19 02:13:06 +00:00
}
2010-05-25 22:38:44 +00:00
break ;
case ReparentNotify :
GDK_NOTE ( EVENTS ,
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 */
return_val = FALSE ;
break ;
case ConfigureNotify :
GDK_NOTE ( EVENTS ,
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 ,
! window
? " (discarding) "
2010-11-22 23:55:39 +00:00
: window - > window_type = = GDK_WINDOW_CHILD
2010-05-25 22:38:44 +00:00
? " (discarding child) "
: xevent - > xconfigure . event ! = xevent - > xconfigure . window
? " (discarding substructure) "
: " " ) ) ;
if ( window & & GDK_WINDOW_TYPE ( window ) = = GDK_WINDOW_ROOT )
{
2013-06-20 09:40:07 +00:00
window - > width = xevent - > xconfigure . width / window_impl - > window_scale ;
window - > height = xevent - > xconfigure . height / window_impl - > window_scale ;
2010-05-25 22:38:44 +00:00
_gdk_window_update_size ( window ) ;
2010-11-22 23:55:39 +00:00
_gdk_x11_window_update_size ( GDK_WINDOW_IMPL_X11 ( window - > impl ) ) ;
2010-05-25 22:38:44 +00:00
_gdk_x11_screen_size_changed ( screen , xevent ) ;
}
# 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
if ( ! window | |
xevent - > xconfigure . event ! = xevent - > xconfigure . window | |
GDK_WINDOW_TYPE ( window ) = = GDK_WINDOW_CHILD | |
GDK_WINDOW_TYPE ( window ) = = GDK_WINDOW_ROOT )
return_val = FALSE ;
else
{
event - > configure . type = GDK_CONFIGURE ;
event - > configure . window = window ;
2013-06-20 09:40:07 +00:00
event - > configure . width = xevent - > xconfigure . width / window_impl - > window_scale ;
event - > configure . height = xevent - > xconfigure . height / window_impl - > window_scale ;
2010-05-25 22:38:44 +00:00
if ( ! xevent - > xconfigure . send_event & &
! xevent - > xconfigure . override_redirect & &
! GDK_WINDOW_DESTROYED ( window ) )
{
gint tx = 0 ;
gint ty = 0 ;
Window child_window = 0 ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_push ( display ) ;
2010-10-05 23:22:45 +00:00
if ( XTranslateCoordinates ( GDK_WINDOW_XDISPLAY ( window ) ,
GDK_WINDOW_XID ( window ) ,
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 ) )
{
2013-06-20 09:40:07 +00:00
event - > configure . x = tx / window_impl - > window_scale ;
event - > configure . y = ty / window_impl - > window_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
{
2013-06-20 09:40:07 +00:00
event - > configure . x = xevent - > xconfigure . x / window_impl - > window_scale ;
event - > configure . y = xevent - > xconfigure . y / window_impl - > window_scale ;
2010-05-25 22:38:44 +00:00
}
2012-09-19 02:13:06 +00:00
if ( ! is_substructure )
{
window - > x = event - > configure . x ;
window - > y = event - > configure . y ;
2013-06-20 09:40:07 +00:00
window - > width = xevent - > xconfigure . width / window_impl - > window_scale ;
window - > height = xevent - > xconfigure . height / window_impl - > window_scale ;
2010-05-25 22:38:44 +00:00
2012-09-19 02:13:06 +00:00
_gdk_window_update_size ( window ) ;
_gdk_x11_window_update_size ( GDK_WINDOW_IMPL_X11 ( window - > impl ) ) ;
2010-05-25 22:38:44 +00:00
2012-09-19 02:13:06 +00:00
if ( window - > resize_count > = 1 )
{
window - > resize_count - = 1 ;
2010-05-25 22:38:44 +00:00
2012-09-19 02:13:06 +00:00
if ( window - > resize_count = = 0 )
_gdk_x11_moveresize_configure_done ( display , window ) ;
}
}
2010-12-15 22:55:04 +00:00
}
2010-05-25 22:38:44 +00:00
break ;
case PropertyNotify :
GDK_NOTE ( EVENTS ,
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 ) ,
" \" " ) ) ;
2010-11-22 23:55:39 +00:00
if ( window = = NULL )
2010-05-25 22:38:44 +00:00
{
return_val = FALSE ;
break ;
}
/* 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 " ) )
gdk_check_wm_state_changed ( window ) ;
if ( xevent - > xproperty . atom = = gdk_x11_get_xatom_by_name_for_display ( display , " _NET_WM_DESKTOP " ) )
gdk_check_wm_desktop_changed ( window ) ;
}
2010-11-22 23:55:39 +00:00
if ( window - > event_mask & GDK_PROPERTY_CHANGE_MASK )
2010-05-25 22:38:44 +00:00
{
event - > property . type = GDK_PROPERTY_NOTIFY ;
event - > property . window = window ;
event - > property . atom = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xproperty . atom ) ;
event - > property . time = xevent - > xproperty . time ;
event - > property . state = xevent - > xproperty . state ;
}
else
return_val = FALSE ;
break ;
case SelectionClear :
GDK_NOTE ( EVENTS ,
g_message ( " selection clear: \t window: %ld " ,
xevent - > xproperty . window ) ) ;
2010-12-17 00:26:05 +00:00
if ( _gdk_x11_selection_filter_clear_event ( & xevent - > xselectionclear ) )
2010-05-25 22:38:44 +00:00
{
event - > selection . type = GDK_SELECTION_CLEAR ;
event - > selection . window = window ;
event - > selection . selection = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xselectionclear . selection ) ;
event - > selection . time = xevent - > xselectionclear . time ;
}
else
return_val = FALSE ;
break ;
case SelectionRequest :
GDK_NOTE ( EVENTS ,
g_message ( " selection request: \t window: %ld " ,
xevent - > xproperty . window ) ) ;
event - > selection . type = GDK_SELECTION_REQUEST ;
event - > selection . window = window ;
event - > selection . selection = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xselectionrequest . selection ) ;
event - > selection . target = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xselectionrequest . target ) ;
event - > selection . property = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xselectionrequest . property ) ;
2011-02-01 16:22:04 +00:00
if ( xevent - > xselectionrequest . requestor ! = None )
event - > selection . requestor = gdk_x11_window_foreign_new_for_display ( display ,
xevent - > xselectionrequest . requestor ) ;
else
event - > selection . requestor = NULL ;
2010-05-25 22:38:44 +00:00
event - > selection . time = xevent - > xselectionrequest . time ;
break ;
case SelectionNotify :
GDK_NOTE ( EVENTS ,
g_message ( " selection notify: \t window: %ld " ,
xevent - > xproperty . window ) ) ;
event - > selection . type = GDK_SELECTION_NOTIFY ;
event - > selection . window = window ;
event - > selection . selection = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xselection . selection ) ;
event - > selection . target = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xselection . target ) ;
if ( xevent - > xselection . property = = None )
event - > selection . property = GDK_NONE ;
else
event - > selection . property = gdk_x11_xatom_to_atom_for_display ( display , xevent - > xselection . property ) ;
event - > selection . time = xevent - > xselection . time ;
break ;
case ColormapNotify :
GDK_NOTE ( EVENTS ,
g_message ( " colormap notify: \t window: %ld " ,
xevent - > xcolormap . window ) ) ;
/* Not currently handled */
return_val = FALSE ;
break ;
case ClientMessage :
2011-02-01 05:30:27 +00:00
GDK_NOTE ( EVENTS ,
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 */
return_val = FALSE ;
2010-05-25 22:38:44 +00:00
break ;
case MappingNotify :
GDK_NOTE ( EVENTS ,
g_message ( " mapping notify " ) ) ;
/* Let XLib know that there is a new keyboard mapping.
*/
XRefreshKeyboardMapping ( & xevent - > xmapping ) ;
2010-12-16 04:49:31 +00:00
_gdk_x11_keymap_keys_changed ( display ) ;
2010-05-25 22:38:44 +00:00
return_val = FALSE ;
break ;
default :
# ifdef HAVE_XFIXES
if ( xevent - > type - display_x11 - > xfixes_event_base = = XFixesSelectionNotify )
{
XFixesSelectionNotifyEvent * selection_notify = ( XFixesSelectionNotifyEvent * ) xevent ;
_gdk_x11_screen_process_owner_change ( screen , xevent ) ;
event - > owner_change . type = GDK_OWNER_CHANGE ;
event - > owner_change . window = window ;
2011-02-01 00:35:51 +00:00
if ( selection_notify - > owner ! = None )
event - > owner_change . owner = gdk_x11_window_foreign_new_for_display ( display ,
selection_notify - > owner ) ;
else
event - > owner_change . owner = NULL ;
2010-05-25 22:38:44 +00:00
event - > owner_change . reason = selection_notify - > subtype ;
event - > owner_change . selection =
gdk_x11_xatom_to_atom_for_display ( display ,
selection_notify - > selection ) ;
event - > owner_change . time = selection_notify - > timestamp ;
event - > owner_change . selection_time = selection_notify - > selection_timestamp ;
return_val = TRUE ;
}
else
# endif
# ifdef HAVE_RANDR
if ( xevent - > type - display_x11 - > xrandr_event_base = = RRScreenChangeNotify | |
xevent - > type - display_x11 - > xrandr_event_base = = RRNotify )
{
if ( screen )
_gdk_x11_screen_size_changed ( screen , xevent ) ;
}
else
# endif
# if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
2010-11-22 23:55:39 +00:00
if ( display_x11 - > have_xdamage & & window & & window - > composited & &
2010-05-25 22:38:44 +00:00
xevent - > type = = display_x11 - > xdamage_event_base + XDamageNotify & &
( ( XDamageNotifyEvent * ) xevent ) - > damage = = window_impl - > damage )
{
XDamageNotifyEvent * damage_event = ( XDamageNotifyEvent * ) xevent ;
XserverRegion repair ;
GdkRectangle rect ;
2013-06-20 09:40:07 +00:00
int x2 , y2 ;
rect . x = window - > x + damage_event - > area . x / window_impl - > window_scale ;
rect . y = window - > y + damage_event - > area . y / window_impl - > window_scale ;
2010-05-25 22:38:44 +00:00
2013-06-20 09:40:07 +00:00
x2 = ( rect . x * window_impl - > window_scale + damage_event - > area . width + window_impl - > window_scale - 1 ) / window_impl - > window_scale ;
y2 = ( rect . y * window_impl - > window_scale + damage_event - > area . height + window_impl - > window_scale - 1 ) / window_impl - > window_scale ;
rect . width = x2 - rect . x ;
rect . height = y2 - rect . y ;
2010-05-25 22:38:44 +00:00
repair = XFixesCreateRegion ( display_x11 - > xdisplay ,
& damage_event - > area , 1 ) ;
XDamageSubtract ( display_x11 - > xdisplay ,
window_impl - > damage ,
repair , None ) ;
XFixesDestroyRegion ( display_x11 - > xdisplay , repair ) ;
2010-12-16 03:21:39 +00:00
if ( window - > parent ! = NULL )
_gdk_x11_window_process_expose ( window - > parent ,
damage_event - > serial , & rect ) ;
2010-05-25 22:38:44 +00:00
return_val = TRUE ;
}
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
return_val = FALSE ;
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 ;
}
}
else
# endif
return_val = FALSE ;
}
done :
if ( return_val )
{
if ( event - > any . window )
g_object_ref ( event - > any . window ) ;
}
else
{
/* Mark this event as having no resources to be freed */
event - > any . window = NULL ;
event - > any . type = GDK_NOTHING ;
}
if ( window )
g_object_unref ( window ) ;
return return_val ;
}
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 ;
}
2011-02-01 04:31:41 +00:00
GdkFilterReturn
_gdk_wm_protocols_filter ( GdkXEvent * xev ,
GdkEvent * event ,
gpointer data )
2010-05-25 22:38:44 +00:00
{
XEvent * xevent = ( XEvent * ) xev ;
GdkWindow * win = event - > any . window ;
GdkDisplay * display ;
Atom atom ;
2013-02-14 18:52:09 +00:00
if ( ! GDK_IS_X11_WINDOW ( win ) | | GDK_WINDOW_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
display = GDK_WINDOW_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 " ) )
{
GdkWindowImplX11 * window_impl ;
2013-02-14 18:52:09 +00:00
window_impl = GDK_WINDOW_IMPL_X11 ( win - > impl ) ;
2012-11-14 17:49:06 +00:00
if ( window_impl - > toplevel )
{
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 ;
gint64 frame_drawn_time = ( ( 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
2013-02-14 18:52:09 +00:00
GdkFrameClock * clock = gdk_window_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
if ( window_impl - > toplevel - > frame_pending )
{
window_impl - > toplevel - > frame_pending = FALSE ;
2013-02-12 20:03:21 +00:00
_gdk_frame_clock_thaw ( clock ) ;
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 )
window_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 " ) )
{
GdkWindowImplX11 * window_impl ;
2013-02-14 18:52:09 +00:00
window_impl = GDK_WINDOW_IMPL_X11 ( win - > impl ) ;
2012-11-14 17:49:06 +00:00
if ( window_impl - > toplevel )
{
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
2013-02-14 18:52:09 +00:00
GdkFrameClock * clock = gdk_window_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
if ( ( _gdk_debug_flags & GDK_DEBUG_FRAMES ) ! = 0 )
2013-02-12 20:47:38 +00:00
_gdk_frame_clock_debug_print_timings ( 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 " ) )
{
/* 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 .
*/
GDK_NOTE ( EVENTS ,
g_message ( " delete window: \t \t window: %ld " ,
xevent - > xclient . window ) ) ;
event - > any . type = GDK_DELETE ;
gdk_x11_window_set_user_time ( win , xevent - > xclient . data . l [ 1 ] ) ;
return GDK_FILTER_TRANSLATE ;
}
else if ( atom = = gdk_x11_get_xatom_by_name_for_display ( display , " WM_TAKE_FOCUS " ) )
{
2013-02-14 18:52:09 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_window_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
*/
2010-11-22 23:55:39 +00:00
if ( toplevel & & win - > accept_focus )
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 " ) & &
! _gdk_x11_display_is_root_window ( display ,
xevent - > xclient . window ) )
{
XClientMessageEvent xclient = xevent - > xclient ;
xclient . window = GDK_WINDOW_XROOTWIN ( win ) ;
XSendEvent ( GDK_WINDOW_XDISPLAY ( win ) ,
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
{
2013-02-14 18:52:09 +00:00
GdkToplevelX11 * toplevel = _gdk_x11_window_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
GdkDeviceManager * device_manager ;
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
device_manager = gdk_display_get_device_manager ( display ) ;
2010-12-15 17:25:38 +00:00
gdk_x11_event_source_add_translator ( ( GdkEventSource * ) display_x11 - > event_source ,
GDK_EVENT_TRANSLATOR ( device_manager ) ) ;
2010-05-25 22:38:44 +00:00
}
static void
2010-12-16 16:33:43 +00:00
gdk_x11_display_init_input ( 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
GdkDeviceManager * device_manager ;
GdkDevice * device ;
GList * list , * l ;
2010-12-20 18:20:10 +00:00
display_x11 = GDK_X11_DISPLAY ( display ) ;
2010-05-25 22:38:44 +00:00
device_manager = gdk_display_get_device_manager ( display ) ;
/* For backwards compatibility, just add
* floating devices that are not keyboards .
*/
list = gdk_device_manager_list_devices ( device_manager , GDK_DEVICE_TYPE_FLOATING ) ;
for ( l = list ; l ; l = l - > next )
{
device = l - > data ;
2010-11-23 19:25:13 +00:00
if ( gdk_device_get_source ( device ) = = GDK_SOURCE_KEYBOARD )
2010-05-25 22:38:44 +00:00
continue ;
2010-09-19 02:57:36 +00:00
display_x11 - > input_devices = g_list_prepend ( display_x11 - > input_devices ,
g_object_ref ( l - > data ) ) ;
2010-05-25 22:38:44 +00:00
}
g_list_free ( list ) ;
/* Now set "core" pointer to the first
* master device that is a pointer .
*/
list = gdk_device_manager_list_devices ( device_manager , GDK_DEVICE_TYPE_MASTER ) ;
for ( l = list ; l ; l = l - > next )
{
2011-01-03 02:40:49 +00:00
device = l - > data ;
2010-05-25 22:38:44 +00:00
2010-11-23 19:25:13 +00:00
if ( gdk_device_get_source ( device ) ! = GDK_SOURCE_MOUSE )
2010-05-25 22:38:44 +00:00
continue ;
display - > core_pointer = device ;
break ;
}
/* Add the core pointer to the devices list */
2010-09-19 02:57:36 +00:00
display_x11 - > input_devices = g_list_prepend ( display_x11 - > input_devices ,
g_object_ref ( display - > core_pointer ) ) ;
2010-05-25 22:38:44 +00:00
g_list_free ( list ) ;
}
2010-12-13 18:45:38 +00:00
static void
set_sm_client_id ( GdkDisplay * display ,
const gchar * sm_client_id )
{
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 " ) ) ;
}
2002-04-25 22:29:14 +00:00
GdkDisplay *
2010-12-11 00:42:09 +00:00
_gdk_x11_display_open ( const gchar * 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 ;
2003-12-09 23:12:53 +00:00
GdkWindowAttr attr ;
2002-04-25 22:29:14 +00:00
gint argc ;
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
gchar * argv [ 1 ] ;
2010-12-13 18:45:38 +00:00
2002-04-25 22:29:14 +00:00
XClassHint * class_hint ;
gulong pid ;
2004-05-18 20:56:54 +00:00
gint ignore ;
2006-02-20 01:36:50 +00:00
gint maj , min ;
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 ;
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 ;
}
2009-02-13 22:15:23 +00:00
gdk_x11_register_standard_event_type ( display , display_x11 - > xrandr_event_base , RRNumberEvents ) ;
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 */
2012-11-25 19:17:30 +00:00
display_x11 - > screen = _gdk_x11_screen_new ( display , DefaultScreen ( display_x11 - > xdisplay ) ) ;
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
2010-12-15 19:49:23 +00:00
display - > 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
2003-12-09 23:12:53 +00:00
attr . window_type = GDK_WINDOW_TOPLEVEL ;
attr . wclass = GDK_INPUT_OUTPUT ;
attr . x = 10 ;
attr . y = 10 ;
attr . width = 10 ;
attr . height = 10 ;
attr . event_mask = 0 ;
2012-11-25 19:17:30 +00:00
display_x11 - > leader_gdk_window = gdk_window_new ( GDK_X11_SCREEN ( display_x11 - > screen ) - > root_window ,
2003-12-09 23:12:53 +00:00
& attr , GDK_WA_X | GDK_WA_Y ) ;
2004-10-18 21:02:37 +00:00
( _gdk_x11_window_get_toplevel ( display_x11 - > leader_gdk_window ) ) - > is_leader = TRUE ;
2003-12-09 23:12:53 +00:00
display_x11 - > leader_window = GDK_WINDOW_XID ( display_x11 - > leader_gdk_window ) ;
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 ;
gdk_x11_register_standard_event_type ( display ,
display_x11 - > xfixes_event_base ,
XFixesNumberEvents ) ;
}
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 ;
# ifdef HAVE_XDAMAGE
if ( XDamageQueryExtension ( display_x11 - > xdisplay ,
& display_x11 - > xdamage_event_base ,
& ignore ) )
{
display_x11 - > have_xdamage = TRUE ;
gdk_x11_register_standard_event_type ( display ,
display_x11 - > xdamage_event_base ,
XDamageNumberEvents ) ;
}
else
# endif
display_x11 - > have_xdamage = 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
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 ( ) ;
2002-04-25 22:29:14 +00:00
class_hint - > res_class = ( char * ) gdk_get_program_class ( ) ;
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
2002-04-25 22:29:14 +00:00
pid = getpid ( ) ;
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
{
gint xkb_major = XkbMajorVersion ;
gint xkb_minor = XkbMinorVersion ;
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
2010-12-16 16:33:43 +00:00
gdk_x11_display_init_input ( display ) ;
2002-04-25 22:29:14 +00:00
2012-11-25 19:17:30 +00:00
_gdk_x11_screen_setup ( display_x11 - > screen ) ;
2006-04-25 14:27:32 +00:00
2010-05-25 22:38:44 +00:00
g_signal_emit_by_name ( display , " opened " ) ;
2002-06-20 19:59:30 +00:00
2002-04-25 22:29:14 +00:00
return display ;
}
2002-05-20 19:04:33 +00:00
/*
* XLib internal connection handling
*/
typedef struct _GdkInternalConnection GdkInternalConnection ;
struct _GdkInternalConnection
{
gint fd ;
GSource * source ;
Display * display ;
} ;
static gboolean
process_internal_connection ( GIOChannel * gioc ,
GIOCondition cond ,
gpointer data )
{
GdkInternalConnection * connection = ( GdkInternalConnection * ) data ;
2012-07-28 12:40:04 +00:00
gdk_threads_enter ( ) ;
2002-05-20 19:04:33 +00:00
XProcessInternalConnection ( ( Display * ) connection - > display , connection - > fd ) ;
2012-07-28 12:40:04 +00:00
gdk_threads_leave ( ) ;
2002-05-20 19:04:33 +00:00
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 ,
gint fd ,
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
}
2011-06-06 18:05:18 +00:00
static const gchar *
2010-12-05 21:37:03 +00:00
gdk_x11_display_get_name ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
2010-12-20 18:20:10 +00:00
return ( gchar * ) DisplayString ( GDK_X11_DISPLAY ( display ) - > xdisplay ) ;
2002-04-25 22:29:14 +00:00
}
2010-12-05 21:37:03 +00:00
static GdkScreen *
gdk_x11_display_get_default_screen ( GdkDisplay * display )
2002-04-25 22:29:14 +00:00
{
2012-11-25 19:17:30 +00:00
return GDK_X11_DISPLAY ( display ) - > screen ;
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 )
{
2011-12-03 14:04:19 +00:00
GdkPointerWindowInfo * pointer_info ;
2010-12-21 23:42:30 +00:00
GdkDevice * device = data ;
2011-12-03 14:04:19 +00:00
pointer_info = _gdk_display_get_pointer_info ( display , device ) ;
_gdk_display_device_grab_update ( display , device ,
2013-06-18 11:20:10 +00:00
pointer_info - > last_slave ? pointer_info - > last_slave : 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 ,
gint 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 ) ) ;
}
2010-12-05 21:37:03 +00:00
static GdkWindow *
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 ) ;
2010-12-20 18:20:10 +00:00
return GDK_X11_DISPLAY ( display ) - > leader_gdk_window ;
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-11-28 00:33:17 +00:00
*
* Since : 2.2
2002-10-22 22:11:22 +00:00
* */
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-11-28 00:33:17 +00:00
*
* Since : 2.2
2002-10-22 22:11:22 +00:00
* */
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
2008-11-30 05:33:57 +00:00
g_list_foreach ( display_x11 - > input_devices , ( GFunc ) g_object_run_dispose , NULL ) ;
2012-11-25 19:17:30 +00:00
_gdk_screen_close ( display_x11 - > screen ) ;
2005-11-10 12:09:42 +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
2011-04-09 01:34:25 +00:00
/* Empty the event queue */
_gdk_x11_display_free_translate_queue ( GDK_DISPLAY ( display_x11 ) ) ;
2002-04-25 22:29:14 +00:00
/* Atom Hashtable */
g_hash_table_destroy ( display_x11 - > atom_from_virtual ) ;
g_hash_table_destroy ( display_x11 - > atom_to_virtual ) ;
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
2003-07-11 19:57:01 +00:00
/* List of event window extraction functions */
g_slist_foreach ( display_x11 - > event_types , ( GFunc ) g_free , NULL ) ;
g_slist_free ( display_x11 - > event_types ) ;
2005-11-10 12:09:42 +00:00
2002-04-25 22:29:14 +00:00
/* input GdkDevice list */
2012-01-03 01:18:50 +00:00
g_list_free_full ( display_x11 - > input_devices , g_object_unref ) ;
2005-11-10 12:09:42 +00:00
2002-04-25 22:29:14 +00:00
/* input GdkWindow list */
2012-01-03 01:18:50 +00:00
g_list_free_full ( display_x11 - > input_windows , g_free ) ;
2005-11-10 12:09:42 +00:00
2002-04-25 22:29:14 +00:00
/* Free all GdkScreens */
2012-11-25 19:17:30 +00:00
g_object_unref ( display_x11 - > screen ) ;
2005-11-10 12:09:42 +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 ) ;
}
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-11-28 00:33:17 +00:00
*
* Since : 2.2
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
{
2010-12-11 00:42:09 +00:00
if ( GDK_DISPLAY_XDISPLAY ( l - > data ) = = xdisplay )
{
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
2014-02-07 18:01:26 +00:00
* @ xrootwin : window ID for one of 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 .
*
2014-02-19 23:49:43 +00:00
* Returns : ( transfer none ) : the # GdkScreen corresponding to
2011-01-18 09:01:17 +00:00
* @ xrootwin , or % NULL .
2002-04-25 22:29:14 +00:00
* */
GdkScreen *
_gdk_x11_display_screen_for_xrootwin ( GdkDisplay * display ,
Window xrootwin )
{
2012-11-25 19:17:30 +00:00
GdkScreen * screen = gdk_display_get_default_screen ( display ) ;
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
return NULL ;
}
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-11-28 00:33:17 +00:00
* Since : 2.2
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 ) ;
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
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 ) ;
2002-11-02 05:37:04 +00:00
const gchar * startup_id ;
g_free ( display_x11 - > startup_notification_id ) ;
display_x11 - > startup_notification_id = NULL ;
2010-12-11 00:42:09 +00:00
2002-11-02 05:37:04 +00:00
startup_id = g_getenv ( " DESKTOP_STARTUP_ID " ) ;
if ( startup_id & & * startup_id ! = ' \0 ' )
{
if ( ! g_utf8_validate ( startup_id , - 1 , NULL ) )
2010-10-18 15:11:58 +00:00
g_warning ( " DESKTOP_STARTUP_ID contains invalid UTF-8 " ) ;
2002-11-02 05:37:04 +00:00
else
2010-10-18 15:11:58 +00:00
gdk_x11_display_set_startup_notification_id ( display , startup_id ) ;
2010-12-11 00:42:09 +00:00
2002-11-02 05:37:04 +00:00
/* Clear the environment variable so it won't be inherited by
2010-12-11 00:42:09 +00:00
* child processes and confuse things .
2002-11-02 05:37:04 +00:00
*/
2003-08-02 21:35:44 +00:00
g_unsetenv ( " DESKTOP_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 ) ;
GdkScreen * screen = gdk_display_get_default_screen ( display ) ;
GdkWindow * root_window = gdk_screen_get_root_window ( screen ) ;
Window xroot_window = GDK_WINDOW_XID ( root_window ) ;
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 ) ;
}
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 ) ;
{
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 ;
2007-01-04 01:28:07 +00:00
memset ( & xclient , 0 , sizeof ( xclient ) ) ;
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 ] ;
2002-11-02 05:37:04 +00:00
dest_end = dest + 20 ;
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
*
* Since : 2.12
* */
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 ;
}
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 ,
const gchar * startup_id )
2007-03-13 17:03:54 +00:00
{
2010-12-14 01:46:00 +00:00
if ( startup_id = = NULL )
{
2010-12-20 18:20:10 +00:00
startup_id = GDK_X11_DISPLAY ( display ) - > startup_notification_id ;
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 ) ;
2002-11-02 05:37:04 +00:00
}
2004-05-18 20:56:54 +00:00
2010-12-05 21:37:03 +00:00
static gboolean
gdk_x11_display_supports_selection_notification ( GdkDisplay * display )
2004-05-18 20:56:54 +00:00
{
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
2004-05-18 20:56:54 +00:00
return display_x11 - > have_xfixes ;
}
2010-12-05 21:37:03 +00:00
static gboolean
gdk_x11_display_request_selection_notification ( GdkDisplay * display ,
GdkAtom 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 )
{
atom = gdk_x11_atom_to_xatom_for_display ( display ,
selection ) ;
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
2010-12-05 21:37:03 +00:00
static gboolean
gdk_x11_display_supports_clipboard_persistence ( GdkDisplay * display )
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
{
2006-05-22 04:11:42 +00:00
Atom clipboard_manager ;
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
/* It might make sense to cache this */
2006-05-22 04:11:42 +00:00
clipboard_manager = gdk_x11_get_xatom_by_name_for_display ( display , " CLIPBOARD_MANAGER " ) ;
2010-12-20 18:20:10 +00:00
return XGetSelectionOwner ( GDK_X11_DISPLAY ( display ) - > xdisplay , clipboard_manager ) ! = None ;
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
}
2010-12-05 21:37:03 +00:00
static void
gdk_x11_display_store_clipboard ( GdkDisplay * display ,
GdkWindow * clipboard_window ,
guint32 time_ ,
const GdkAtom * targets ,
gint n_targets )
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
{
2010-12-20 18:20:10 +00:00
GdkX11Display * display_x11 = GDK_X11_DISPLAY ( display ) ;
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
Atom clipboard_manager , save_targets ;
2008-07-18 13:03:42 +00:00
g_return_if_fail ( GDK_WINDOW_IS_X11 ( clipboard_window ) ) ;
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
clipboard_manager = gdk_x11_get_xatom_by_name_for_display ( display , " CLIPBOARD_MANAGER " ) ;
save_targets = gdk_x11_get_xatom_by_name_for_display ( display , " SAVE_TARGETS " ) ;
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_push ( display ) ;
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
if ( XGetSelectionOwner ( display_x11 - > xdisplay , clipboard_manager ) ! = None )
{
Atom property_name = None ;
Atom * xatoms ;
int i ;
2010-12-15 07:05:05 +00:00
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
if ( n_targets > 0 )
2010-12-15 23:42:38 +00:00
{
property_name = gdk_x11_get_xatom_by_name_for_display ( display , " GDK_SELECTION " ) ;
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
xatoms = g_new ( Atom , n_targets ) ;
for ( i = 0 ; i < n_targets ; i + + )
xatoms [ i ] = gdk_x11_atom_to_xatom_for_display ( display , targets [ i ] ) ;
XChangeProperty ( display_x11 - > xdisplay , GDK_WINDOW_XID ( clipboard_window ) ,
property_name , XA_ATOM ,
32 , PropModeReplace , ( guchar * ) xatoms , n_targets ) ;
g_free ( xatoms ) ;
}
2010-12-15 07:05:05 +00:00
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
XConvertSelection ( display_x11 - > xdisplay ,
2010-12-15 07:05:05 +00:00
clipboard_manager , save_targets , property_name ,
GDK_WINDOW_XID ( clipboard_window ) , time_ ) ;
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
}
2010-12-15 07:05:05 +00:00
gdk_x11_display_error_trap_pop_ignored ( display ) ;
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
* movements . See gdk_x11_window_set_user_time ( ) .
*
* Returns : the timestamp of the last user interaction
*
* Since : 2.8
*/
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
2010-12-05 21:37:03 +00:00
static gboolean
gdk_x11_display_supports_shapes ( GdkDisplay * display )
2006-02-20 01:36:50 +00:00
{
2010-12-20 18:20:10 +00:00
return GDK_X11_DISPLAY ( display ) - > have_shapes ;
2006-02-20 01:36:50 +00:00
}
2010-12-05 21:37:03 +00:00
static gboolean
gdk_x11_display_supports_input_shapes ( GdkDisplay * display )
2006-02-20 01:36:50 +00:00
{
2010-12-20 18:20:10 +00:00
return GDK_X11_DISPLAY ( display ) - > have_input_shapes ;
2006-02-20 01:36:50 +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
*
* Since : 2.12
*/
2011-06-06 18:05:18 +00:00
const gchar *
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
* gdk_notify_startup_complete ( ) ) .
*
* Since : 3.0
* */
void
gdk_x11_display_set_startup_notification_id ( GdkDisplay * display ,
const gchar * startup_id )
{
2010-12-20 16:14:04 +00:00
GdkX11Display * display_x11 ;
2010-10-18 15:11:58 +00:00
gchar * time_str ;
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 ) ;
/* 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 ;
gchar * end ;
errno = 0 ;
/* Skip past the "_TIME" part */
time_str + = 5 ;
retval = strtoul ( time_str , & end , 0 ) ;
if ( end ! = time_str & & errno = = 0 )
display_x11 - > user_time = retval ;
}
/* 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 ) ) ;
}
2010-12-05 21:37:03 +00:00
static gboolean
gdk_x11_display_supports_composite ( GdkDisplay * display )
2007-06-01 12:16:12 +00:00
{
2010-12-20 18:20:10 +00:00
GdkX11Display * x11_display = GDK_X11_DISPLAY ( display ) ;
2007-06-01 12:16:12 +00:00
return x11_display - > have_xcomposite & &
x11_display - > have_xdamage & &
x11_display - > have_xfixes ;
}
2010-12-05 21:37:03 +00:00
static GList *
gdk_x11_display_list_devices ( GdkDisplay * display )
2010-05-25 22:38:44 +00:00
{
g_return_val_if_fail ( GDK_IS_DISPLAY ( display ) , NULL ) ;
2010-12-20 18:20:10 +00:00
return GDK_X11_DISPLAY ( display ) - > input_devices ;
2010-05-25 22:38:44 +00:00
}
/**
* gdk_x11_register_standard_event_type :
2014-01-09 20:47:04 +00:00
* @ display : ( type GdkX11Display ) : a # GdkDisplay
2010-05-25 22:38:44 +00:00
* @ event_base : first event type code to register
* @ n_events : number of event type codes to register
*
* Registers interest in receiving extension events with type codes
2014-02-04 23:21:13 +00:00
* between @ event_base and ` event_base + n_events - 1 ` .
2010-05-25 22:38:44 +00:00
* The registered events must have the window field in the same place
* as core X events ( this is not the case for e . g . XKB extension events ) .
*
* If an event type is registered , events of this type will go through
* global and window - specific filters ( see gdk_window_add_filter ( ) ) .
* Unregistered events will only go through global filters .
* GDK may register the events of some X extensions on its own .
*
* This function should only be needed in unusual circumstances , e . g .
* when filtering XInput extension events on the root window .
*
* Since : 2.4
* */
void
gdk_x11_register_standard_event_type ( GdkDisplay * display ,
gint event_base ,
gint n_events )
{
GdkEventTypeX11 * event_type ;
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-05-25 22:38:44 +00:00
event_type = g_new ( GdkEventTypeX11 , 1 ) ;
event_type - > base = event_base ;
event_type - > n_events = n_events ;
display_x11 - > event_types = g_slist_prepend ( display_x11 - > event_types , event_type ) ;
}
2010-09-18 22:19:27 +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 )
{
gchar buf [ 64 ] ;
gchar * msg ;
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 */
2010-09-21 04:30:46 +00:00
g_warning ( " %s \n " , 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
*
* See also gdk_error_trap_push ( ) to push a trap on all displays .
*
* Since : 3.0
*/
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 ) ;
}
static gint
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 ;
}
g_return_val_if_fail ( trap ! = NULL , Success ) ;
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
/**
* gdk_x11_display_set_window_scale :
* @ 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 .
*
* Since : 3.10
*/
void
gdk_x11_display_set_window_scale ( GdkDisplay * display ,
gint scale )
{
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 ) ;
# ifndef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
/* Without cairo support we can't support any scale but 1 */
scale = 1 ;
# endif
x11_screen = GDK_X11_SCREEN ( GDK_X11_DISPLAY ( display ) - > screen ) ;
2014-03-05 20:42:38 +00:00
if ( ! x11_screen - > fixed_window_scale )
{
x11_screen - > fixed_window_scale = TRUE ;
/* We treat screens with a window scale set differently when
* reading xsettings , so we need to reread */
need_reread_settings = TRUE ;
}
2013-08-20 09:15:08 +00:00
_gdk_x11_screen_set_window_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 .
*
* See gdk_error_trap_pop ( ) for the all - displays - at - once
* equivalent .
*
* Since : 3.0
*
2014-02-19 23:49:43 +00:00
* Returns : X error code or 0 on success
2010-09-18 22:19:27 +00:00
*/
gint
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 .
*
* See gdk_error_trap_pop_ignored ( ) for the all - displays - at - once
* equivalent .
*
* Since : 3.0
*/
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 :
* @ sm_client_id : the client id assigned by the session manager when the
* connection was opened , or % NULL to remove the property .
*
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
2010-12-17 06:48:12 +00:00
*
* Since : 2.24
2010-12-13 18:45:38 +00:00
*/
void
gdk_x11_set_sm_client_id ( const gchar * sm_client_id )
{
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 )
set_sm_client_id ( l - > data , sm_client_id ) ;
g_slist_free ( displays ) ;
}
2010-12-15 05:37:40 +00:00
static void
gdk_x11_display_event_data_copy ( GdkDisplay * display ,
const GdkEvent * src ,
GdkEvent * dst )
{
}
static void
gdk_x11_display_event_data_free ( GdkDisplay * display ,
GdkEvent * event )
{
}
2010-12-16 06:21:49 +00:00
static gint
pop_error_trap ( GdkDisplay * display ,
gboolean ignored )
{
if ( ignored )
{
gdk_x11_display_error_trap_pop_ignored ( display ) ;
return Success ;
}
else
{
return gdk_x11_display_error_trap_pop ( display ) ;
}
}
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 )
2010-12-21 04:32:48 +00:00
display_x11 - > keymap = g_object_new ( GDK_TYPE_X11_KEYMAP , NULL ) ;
2010-12-16 05:08:42 +00:00
display_x11 - > keymap - > display = display ;
return display_x11 - > keymap ;
}
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
2010-12-21 02:34:31 +00:00
display_class - > window_type = GDK_TYPE_X11_WINDOW ;
2010-12-05 21:37:03 +00:00
display_class - > get_name = gdk_x11_display_get_name ;
display_class - > get_default_screen = gdk_x11_display_get_default_screen ;
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-05 21:37:03 +00:00
display_class - > get_default_group = gdk_x11_display_get_default_group ;
display_class - > supports_selection_notification = gdk_x11_display_supports_selection_notification ;
display_class - > request_selection_notification = gdk_x11_display_request_selection_notification ;
display_class - > supports_clipboard_persistence = gdk_x11_display_supports_clipboard_persistence ;
display_class - > store_clipboard = gdk_x11_display_store_clipboard ;
display_class - > supports_shapes = gdk_x11_display_supports_shapes ;
display_class - > supports_input_shapes = gdk_x11_display_supports_input_shapes ;
display_class - > supports_composite = gdk_x11_display_supports_composite ;
display_class - > list_devices = gdk_x11_display_list_devices ;
2010-12-09 06:08:05 +00:00
display_class - > get_app_launch_context = _gdk_x11_display_get_app_launch_context ;
2010-12-13 17:36:35 +00:00
display_class - > get_cursor_for_type = _gdk_x11_display_get_cursor_for_type ;
display_class - > get_cursor_for_name = _gdk_x11_display_get_cursor_for_name ;
2013-08-07 10:18:38 +00:00
display_class - > get_cursor_for_surface = _gdk_x11_display_get_cursor_for_surface ;
2010-12-13 17:36:35 +00:00
display_class - > get_default_cursor_size = _gdk_x11_display_get_default_cursor_size ;
display_class - > get_maximal_cursor_size = _gdk_x11_display_get_maximal_cursor_size ;
display_class - > supports_cursor_alpha = _gdk_x11_display_supports_cursor_alpha ;
display_class - > supports_cursor_color = _gdk_x11_display_supports_cursor_color ;
2010-12-13 18:30:05 +00:00
display_class - > before_process_all_updates = _gdk_x11_display_before_process_all_updates ;
display_class - > after_process_all_updates = _gdk_x11_display_after_process_all_updates ;
2010-12-13 19:05:59 +00:00
display_class - > get_next_serial = gdk_x11_display_get_next_serial ;
2010-12-14 01:46:00 +00:00
display_class - > notify_startup_complete = gdk_x11_display_notify_startup_complete ;
2010-12-15 05:37:40 +00:00
display_class - > event_data_copy = gdk_x11_display_event_data_copy ;
display_class - > event_data_free = gdk_x11_display_event_data_free ;
2010-12-16 00:07:36 +00:00
display_class - > create_window_impl = _gdk_x11_display_create_window_impl ;
2010-12-16 05:08:42 +00:00
display_class - > get_keymap = gdk_x11_display_get_keymap ;
2010-12-16 06:21:49 +00:00
display_class - > push_error_trap = gdk_x11_display_error_trap_push ;
display_class - > pop_error_trap = pop_error_trap ;
2010-12-17 00:22:44 +00:00
display_class - > get_selection_owner = _gdk_x11_display_get_selection_owner ;
display_class - > set_selection_owner = _gdk_x11_display_set_selection_owner ;
2010-12-17 00:58:07 +00:00
display_class - > send_selection_notify = _gdk_x11_display_send_selection_notify ;
2010-12-17 01:10:11 +00:00
display_class - > get_selection_property = _gdk_x11_display_get_selection_property ;
2010-12-17 01:25:32 +00:00
display_class - > convert_selection = _gdk_x11_display_convert_selection ;
2010-12-17 04:44:50 +00:00
display_class - > text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list ;
display_class - > utf8_to_string_target = _gdk_x11_display_utf8_to_string_target ;
2013-05-01 16:11:26 +00:00
_gdk_x11_windowing_init ( ) ;
2010-12-05 21:37:03 +00:00
}