2009-02-24 05:09:13 +00:00
|
|
|
|
/*
|
2002-04-25 22:29:14 +00:00
|
|
|
|
* gdkscreen-x11.c
|
2010-12-23 12:50:13 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright 2001 Sun Microsystems Inc.
|
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"
|
2004-03-06 03:38:59 +00:00
|
|
|
|
|
2010-10-15 02:05:51 +00:00
|
|
|
|
#include "gdkscreen-x11.h"
|
2002-04-25 22:29:14 +00:00
|
|
|
|
#include "gdkdisplay-x11.h"
|
2010-12-16 03:09:35 +00:00
|
|
|
|
#include "gdkprivate-x11.h"
|
2013-02-19 13:31:03 +00:00
|
|
|
|
#include "xsettings-client.h"
|
2016-04-03 04:12:39 +00:00
|
|
|
|
#include "gdkmonitor-x11.h"
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
2010-10-15 02:05:51 +00:00
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2005-11-10 12:09:42 +00:00
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
|
|
2016-04-28 03:08:25 +00:00
|
|
|
|
#ifdef HAVE_XFREE_XINERAMA
|
|
|
|
|
#include <X11/extensions/Xinerama.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-10-27 23:50:34 +00:00
|
|
|
|
#ifdef HAVE_RANDR
|
|
|
|
|
#include <X11/extensions/Xrandr.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-04-25 14:27:32 +00:00
|
|
|
|
#ifdef HAVE_XFIXES
|
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
static void gdk_x11_screen_dispose (GObject *object);
|
|
|
|
|
static void gdk_x11_screen_finalize (GObject *object);
|
|
|
|
|
static void init_randr_support (GdkX11Screen *screen);
|
2020-02-10 14:19:32 +00:00
|
|
|
|
static void process_monitors_change (GdkX11Screen *screen);
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
|
|
2002-09-25 19:16:46 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
WINDOW_MANAGER_CHANGED,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
|
|
2002-09-25 19:16:46 +00:00
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
2017-11-17 15:37:52 +00:00
|
|
|
|
G_DEFINE_TYPE (GdkX11Screen, gdk_x11_screen, G_TYPE_OBJECT)
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
typedef struct _NetWmSupportedAtoms NetWmSupportedAtoms;
|
|
|
|
|
|
|
|
|
|
struct _NetWmSupportedAtoms
|
|
|
|
|
{
|
|
|
|
|
Atom *atoms;
|
|
|
|
|
gulong n_atoms;
|
|
|
|
|
};
|
|
|
|
|
|
2006-04-04 14:02:03 +00:00
|
|
|
|
static void
|
2010-12-21 01:40:45 +00:00
|
|
|
|
gdk_x11_screen_init (GdkX11Screen *screen)
|
2006-04-04 14:02:03 +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-21 01:32:13 +00:00
|
|
|
|
gdk_x11_screen_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-21 01:32:13 +00:00
|
|
|
|
GdkX11Screen *x11_screen = GDK_X11_SCREEN (object);
|
2010-07-22 00:26:05 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 32; ++i)
|
|
|
|
|
{
|
2010-12-21 01:32:13 +00:00
|
|
|
|
if (x11_screen->subwindow_gcs[i])
|
2010-07-22 00:26:05 +00:00
|
|
|
|
{
|
2010-12-21 01:32:13 +00:00
|
|
|
|
XFreeGC (x11_screen->xdisplay, x11_screen->subwindow_gcs[i]);
|
|
|
|
|
x11_screen->subwindow_gcs[i] = 0;
|
2010-07-22 00:26:05 +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
|
|
|
|
|
2013-02-19 13:31:03 +00:00
|
|
|
|
_gdk_x11_xsettings_finish (x11_screen);
|
2002-11-25 22:52:36 +00:00
|
|
|
|
|
2013-06-29 23:23:23 +00:00
|
|
|
|
for (i = 0; i < x11_screen->nvisuals; i++)
|
|
|
|
|
g_object_run_dispose (G_OBJECT (x11_screen->visuals[i]));
|
|
|
|
|
|
2010-12-21 01:40:45 +00:00
|
|
|
|
G_OBJECT_CLASS (gdk_x11_screen_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
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->xdisplay = NULL;
|
|
|
|
|
x11_screen->xscreen = NULL;
|
|
|
|
|
x11_screen->xroot_window = None;
|
|
|
|
|
x11_screen->wmspec_check_window = None;
|
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-21 01:32:13 +00:00
|
|
|
|
gdk_x11_screen_finalize (GObject *object)
|
2002-04-25 22:29:14 +00:00
|
|
|
|
{
|
2010-12-21 01:32:13 +00:00
|
|
|
|
GdkX11Screen *x11_screen = GDK_X11_SCREEN (object);
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i;
|
2005-11-10 12:09:42 +00:00
|
|
|
|
|
|
|
|
|
/* Visual Part */
|
2010-12-21 01:32:13 +00:00
|
|
|
|
for (i = 0; i < x11_screen->nvisuals; i++)
|
|
|
|
|
g_object_unref (x11_screen->visuals[i]);
|
|
|
|
|
g_free (x11_screen->visuals);
|
2002-09-25 19:16:46 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
g_free (x11_screen->window_manager_name);
|
2002-09-25 19:16:46 +00:00
|
|
|
|
|
2010-12-21 01:40:45 +00:00
|
|
|
|
G_OBJECT_CLASS (gdk_x11_screen_parent_class)->finalize (object);
|
2002-04-25 22:29:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-13 18:27:05 +00:00
|
|
|
|
/**
|
2011-07-28 11:17:35 +00:00
|
|
|
|
* gdk_x11_screen_get_monitor_output:
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* @screen: a #GdkX11Screen
|
2009-11-27 23:39:15 +00:00
|
|
|
|
* @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
|
2007-12-13 18:27:05 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the XID of the specified output/monitor.
|
2009-11-27 23:39:15 +00:00
|
|
|
|
* If the X server does not support version 1.2 of the RANDR
|
2007-12-13 18:27:05 +00:00
|
|
|
|
* extension, 0 is returned.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the XID of the monitor
|
|
|
|
|
*/
|
|
|
|
|
XID
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_monitor_output (GdkX11Screen *x11_screen,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int monitor_num)
|
2007-12-13 18:27:05 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkX11Display *x11_display = GDK_X11_DISPLAY (x11_screen->display);
|
|
|
|
|
GdkX11Monitor *monitor;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
XID output;
|
2009-11-27 23:39:15 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (monitor_num >= 0, None);
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_return_val_if_fail (monitor_num < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)), None);
|
2009-11-27 23:39:15 +00:00
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), monitor_num);
|
|
|
|
|
output = monitor->output;
|
|
|
|
|
g_object_unref (monitor);
|
|
|
|
|
|
|
|
|
|
return output;
|
2002-04-25 22:29:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-12-18 19:02:55 +00:00
|
|
|
|
static int
|
2017-11-17 15:18:20 +00:00
|
|
|
|
get_current_desktop (GdkX11Screen *screen)
|
2011-12-18 19:02:55 +00:00
|
|
|
|
{
|
|
|
|
|
Display *display;
|
|
|
|
|
Window win;
|
|
|
|
|
Atom current_desktop, type;
|
|
|
|
|
int format;
|
|
|
|
|
unsigned long n_items, bytes_after;
|
|
|
|
|
unsigned char *data_return = NULL;
|
|
|
|
|
int workspace = 0;
|
|
|
|
|
|
2013-01-10 04:40:04 +00:00
|
|
|
|
if (!gdk_x11_screen_supports_net_wm_hint (screen,
|
2017-12-14 04:39:03 +00:00
|
|
|
|
g_intern_static_string ("_NET_CURRENT_DESKTOP")))
|
2013-01-10 04:40:04 +00:00
|
|
|
|
return workspace;
|
|
|
|
|
|
2017-11-01 23:41:45 +00:00
|
|
|
|
display = GDK_DISPLAY_XDISPLAY (GDK_SCREEN_DISPLAY (screen));
|
2017-11-01 19:51:14 +00:00
|
|
|
|
win = XRootWindow (display, gdk_x11_screen_get_screen_number (screen));
|
2011-12-18 19:02:55 +00:00
|
|
|
|
|
|
|
|
|
current_desktop = XInternAtom (display, "_NET_CURRENT_DESKTOP", True);
|
|
|
|
|
|
|
|
|
|
XGetWindowProperty (display,
|
|
|
|
|
win,
|
|
|
|
|
current_desktop,
|
|
|
|
|
0, G_MAXLONG,
|
|
|
|
|
False, XA_CARDINAL,
|
|
|
|
|
&type, &format, &n_items, &bytes_after,
|
|
|
|
|
&data_return);
|
|
|
|
|
|
|
|
|
|
if (type == XA_CARDINAL && format == 32 && n_items > 0)
|
2013-02-26 23:58:21 +00:00
|
|
|
|
workspace = ((long *) data_return)[0];
|
2011-12-18 19:02:55 +00:00
|
|
|
|
|
|
|
|
|
if (data_return)
|
|
|
|
|
XFree (data_return);
|
|
|
|
|
|
|
|
|
|
return workspace;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-12 22:38:12 +00:00
|
|
|
|
gboolean
|
|
|
|
|
_gdk_x11_screen_get_monitor_work_area (GdkX11Screen *x11_screen,
|
|
|
|
|
GdkMonitor *monitor,
|
|
|
|
|
GdkRectangle *area)
|
|
|
|
|
{
|
|
|
|
|
Display *xdisplay;
|
|
|
|
|
Atom net_workareas;
|
|
|
|
|
int current_desktop;
|
|
|
|
|
char *workareas_dn_name;
|
|
|
|
|
Atom workareas_dn;
|
|
|
|
|
int screen_number;
|
|
|
|
|
Window xroot;
|
|
|
|
|
int result;
|
|
|
|
|
Atom type;
|
|
|
|
|
int format;
|
|
|
|
|
gulong num;
|
|
|
|
|
gulong leftovers;
|
|
|
|
|
guchar *ret_workarea;
|
|
|
|
|
long *workareas;
|
|
|
|
|
GdkRectangle geometry;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen,
|
|
|
|
|
g_intern_static_string ("_GTK_WORKAREAS")))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
xdisplay = gdk_x11_display_get_xdisplay (x11_screen->display);
|
|
|
|
|
net_workareas = XInternAtom (xdisplay, "_GTK_WORKAREAS", False);
|
|
|
|
|
|
|
|
|
|
if (net_workareas == None)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
current_desktop = get_current_desktop (x11_screen);
|
|
|
|
|
workareas_dn_name = g_strdup_printf ("_GTK_WORKAREAS_D%d", current_desktop);
|
|
|
|
|
workareas_dn = XInternAtom (xdisplay, workareas_dn_name, True);
|
|
|
|
|
g_free (workareas_dn_name);
|
|
|
|
|
|
|
|
|
|
if (workareas_dn == None)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
screen_number = gdk_x11_screen_get_screen_number (x11_screen);
|
|
|
|
|
xroot = XRootWindow (xdisplay, screen_number);
|
|
|
|
|
|
|
|
|
|
gdk_x11_display_error_trap_push (x11_screen->display);
|
|
|
|
|
|
|
|
|
|
ret_workarea = NULL;
|
|
|
|
|
result = XGetWindowProperty (xdisplay,
|
|
|
|
|
xroot,
|
|
|
|
|
workareas_dn,
|
|
|
|
|
0,
|
|
|
|
|
G_MAXLONG,
|
|
|
|
|
False,
|
|
|
|
|
AnyPropertyType,
|
|
|
|
|
&type,
|
|
|
|
|
&format,
|
|
|
|
|
&num,
|
|
|
|
|
&leftovers,
|
|
|
|
|
&ret_workarea);
|
|
|
|
|
|
|
|
|
|
gdk_x11_display_error_trap_pop_ignored (x11_screen->display);
|
|
|
|
|
|
|
|
|
|
if (result != Success ||
|
|
|
|
|
type == None ||
|
|
|
|
|
format == 0 ||
|
|
|
|
|
leftovers ||
|
|
|
|
|
num % 4 != 0)
|
|
|
|
|
{
|
|
|
|
|
XFree (ret_workarea);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workareas = (long *) ret_workarea;
|
|
|
|
|
|
|
|
|
|
gdk_monitor_get_geometry (monitor, &geometry);
|
|
|
|
|
*area = geometry;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num / 4; i++)
|
|
|
|
|
{
|
|
|
|
|
GdkRectangle work_area;
|
|
|
|
|
|
|
|
|
|
work_area = (GdkRectangle) {
|
|
|
|
|
.x = workareas[0] / x11_screen->surface_scale,
|
|
|
|
|
.y = workareas[1] / x11_screen->surface_scale,
|
|
|
|
|
.width = workareas[2] / x11_screen->surface_scale,
|
|
|
|
|
.height = workareas[3] / x11_screen->surface_scale,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (gdk_rectangle_intersect (area, &work_area, &work_area))
|
|
|
|
|
*area = work_area;
|
|
|
|
|
|
|
|
|
|
workareas += 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XFree (ret_workarea);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_work_area (GdkX11Screen *x11_screen,
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkRectangle *area)
|
2011-12-18 19:02:55 +00:00
|
|
|
|
{
|
|
|
|
|
Atom workarea;
|
|
|
|
|
Atom type;
|
|
|
|
|
Window win;
|
|
|
|
|
int format;
|
|
|
|
|
gulong num;
|
|
|
|
|
gulong leftovers;
|
|
|
|
|
gulong max_len = 4 * 32;
|
2014-01-04 20:13:51 +00:00
|
|
|
|
guchar *ret_workarea = NULL;
|
2011-12-18 19:02:55 +00:00
|
|
|
|
long *workareas;
|
|
|
|
|
int result;
|
|
|
|
|
int desktop;
|
|
|
|
|
Display *display;
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
display = GDK_SCREEN_XDISPLAY (x11_screen);
|
2011-12-18 19:02:55 +00:00
|
|
|
|
workarea = XInternAtom (display, "_NET_WORKAREA", True);
|
|
|
|
|
|
|
|
|
|
/* Defaults in case of error */
|
|
|
|
|
area->x = 0;
|
|
|
|
|
area->y = 0;
|
2017-11-09 23:40:16 +00:00
|
|
|
|
area->width = WidthOfScreen (x11_screen->xscreen);
|
|
|
|
|
area->height = HeightOfScreen (x11_screen->xscreen);
|
2011-12-18 19:02:55 +00:00
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen,
|
2017-12-14 04:39:03 +00:00
|
|
|
|
g_intern_static_string ("_NET_WORKAREA")))
|
2013-01-10 04:40:04 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2011-12-18 19:02:55 +00:00
|
|
|
|
if (workarea == None)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
win = XRootWindow (display, gdk_x11_screen_get_screen_number (x11_screen));
|
2011-12-18 19:02:55 +00:00
|
|
|
|
result = XGetWindowProperty (display,
|
|
|
|
|
win,
|
|
|
|
|
workarea,
|
|
|
|
|
0,
|
|
|
|
|
max_len,
|
|
|
|
|
False,
|
|
|
|
|
AnyPropertyType,
|
|
|
|
|
&type,
|
|
|
|
|
&format,
|
|
|
|
|
&num,
|
|
|
|
|
&leftovers,
|
|
|
|
|
&ret_workarea);
|
|
|
|
|
if (result != Success ||
|
|
|
|
|
type == None ||
|
|
|
|
|
format == 0 ||
|
|
|
|
|
leftovers ||
|
|
|
|
|
num % 4 != 0)
|
2014-01-04 20:13:51 +00:00
|
|
|
|
goto out;
|
2011-12-18 19:02:55 +00:00
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
desktop = get_current_desktop (x11_screen);
|
2014-01-04 20:15:00 +00:00
|
|
|
|
if (desktop + 1 > num / 4) /* fvwm gets this wrong */
|
|
|
|
|
goto out;
|
2011-12-18 19:02:55 +00:00
|
|
|
|
|
|
|
|
|
workareas = (long *) ret_workarea;
|
|
|
|
|
area->x = workareas[desktop * 4];
|
|
|
|
|
area->y = workareas[desktop * 4 + 1];
|
|
|
|
|
area->width = workareas[desktop * 4 + 2];
|
|
|
|
|
area->height = workareas[desktop * 4 + 3];
|
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
|
area->x /= x11_screen->surface_scale;
|
|
|
|
|
area->y /= x11_screen->surface_scale;
|
|
|
|
|
area->width /= x11_screen->surface_scale;
|
|
|
|
|
area->height /= x11_screen->surface_scale;
|
2013-06-20 09:40:07 +00:00
|
|
|
|
|
2014-01-04 20:13:51 +00:00
|
|
|
|
out:
|
|
|
|
|
if (ret_workarea)
|
|
|
|
|
XFree (ret_workarea);
|
2011-12-18 19:02:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-02 22:28:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_x11_screen_get_xscreen:
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* @screen: a #GdkX11Screen
|
2002-05-02 22:28:50 +00:00
|
|
|
|
*
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* Returns the screen of a #GdkX11Screen.
|
2002-11-28 00:33:17 +00:00
|
|
|
|
*
|
2014-01-28 05:06:30 +00:00
|
|
|
|
* Returns: (transfer none): an Xlib Screen*
|
2002-05-02 22:28:50 +00:00
|
|
|
|
*/
|
2002-04-25 22:29:14 +00:00
|
|
|
|
Screen *
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_xscreen (GdkX11Screen *screen)
|
2002-04-25 22:29:14 +00:00
|
|
|
|
{
|
2017-11-17 15:18:20 +00:00
|
|
|
|
return screen->xscreen;
|
2002-04-25 22:29:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-02 22:28:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_x11_screen_get_screen_number:
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* @screen: a #GdkX11Screen
|
2002-05-02 22:28:50 +00:00
|
|
|
|
*
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* Returns the index of a #GdkX11Screen.
|
2002-11-28 00:33:17 +00:00
|
|
|
|
*
|
2011-12-16 04:08:07 +00:00
|
|
|
|
* Returns: the position of @screen among the screens
|
|
|
|
|
* of its display
|
2002-05-02 22:28:50 +00:00
|
|
|
|
*/
|
2002-04-25 22:29:14 +00:00
|
|
|
|
int
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_screen_number (GdkX11Screen *screen)
|
2002-04-25 22:29:14 +00:00
|
|
|
|
{
|
2017-11-17 15:18:20 +00:00
|
|
|
|
return screen->screen_num;
|
2002-04-25 22:29:14 +00:00
|
|
|
|
}
|
2002-05-03 19:03:03 +00:00
|
|
|
|
|
2020-05-17 03:35:14 +00:00
|
|
|
|
static void
|
|
|
|
|
notify_surface_monitor_change (GdkX11Display *display,
|
|
|
|
|
GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
GdkSurface *surface;
|
|
|
|
|
|
|
|
|
|
/* We iterate the surfaces via the hash table here because it's the only
|
|
|
|
|
* thing that contains all the surfaces.
|
|
|
|
|
*/
|
|
|
|
|
if (display->xid_ht == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, display->xid_ht);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&surface))
|
|
|
|
|
{
|
|
|
|
|
gdk_x11_surface_check_monitor (surface, monitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
static GdkX11Monitor *
|
2016-05-27 07:27:53 +00:00
|
|
|
|
find_monitor_by_output (GdkX11Display *x11_display, XID output)
|
2009-04-10 04:14:23 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
2009-04-10 04:14:23 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkX11Monitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (monitor->output == output)
|
|
|
|
|
return monitor;
|
2009-04-10 04:14:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
return NULL;
|
2009-04-10 04:14:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
static GdkSubpixelLayout
|
|
|
|
|
translate_subpixel_order (int subpixel)
|
2009-02-20 04:42:33 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
switch (subpixel)
|
|
|
|
|
{
|
|
|
|
|
case 1: return GDK_SUBPIXEL_LAYOUT_HORIZONTAL_RGB;
|
|
|
|
|
case 2: return GDK_SUBPIXEL_LAYOUT_HORIZONTAL_BGR;
|
|
|
|
|
case 3: return GDK_SUBPIXEL_LAYOUT_VERTICAL_RGB;
|
|
|
|
|
case 4: return GDK_SUBPIXEL_LAYOUT_VERTICAL_BGR;
|
|
|
|
|
case 5: return GDK_SUBPIXEL_LAYOUT_NONE;
|
|
|
|
|
default: return GDK_SUBPIXEL_LAYOUT_UNKNOWN;
|
|
|
|
|
}
|
2009-02-20 04:42:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 06:02:04 +00:00
|
|
|
|
static gboolean
|
2020-05-17 03:10:19 +00:00
|
|
|
|
init_randr15 (GdkX11Screen *x11_screen)
|
2015-02-02 06:02:04 +00:00
|
|
|
|
{
|
2016-02-20 15:19:13 +00:00
|
|
|
|
#ifdef HAVE_RANDR15
|
2017-11-17 15:18:20 +00:00
|
|
|
|
GdkDisplay *display = GDK_SCREEN_DISPLAY (x11_screen);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
|
2016-02-20 00:31:59 +00:00
|
|
|
|
XRRScreenResources *resources;
|
2016-02-20 15:19:13 +00:00
|
|
|
|
RROutput primary_output = None;
|
2016-02-20 00:31:59 +00:00
|
|
|
|
RROutput first_output = None;
|
2015-02-02 06:02:04 +00:00
|
|
|
|
int i;
|
2016-02-20 15:19:13 +00:00
|
|
|
|
XRRMonitorInfo *rr_monitors;
|
|
|
|
|
int num_rr_monitors;
|
2015-02-02 06:02:04 +00:00
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (!x11_display->have_randr15)
|
2015-02-02 06:02:04 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2016-02-20 00:31:59 +00:00
|
|
|
|
resources = XRRGetScreenResourcesCurrent (x11_screen->xdisplay,
|
|
|
|
|
x11_screen->xroot_window);
|
|
|
|
|
if (!resources)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2015-02-02 06:02:04 +00:00
|
|
|
|
rr_monitors = XRRGetMonitors (x11_screen->xdisplay,
|
|
|
|
|
x11_screen->xroot_window,
|
|
|
|
|
True,
|
|
|
|
|
&num_rr_monitors);
|
|
|
|
|
if (!rr_monitors)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkX11Monitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
monitor->add = FALSE;
|
|
|
|
|
monitor->remove = TRUE;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2016-02-20 00:31:59 +00:00
|
|
|
|
|
2015-02-02 06:02:04 +00:00
|
|
|
|
for (i = 0; i < num_rr_monitors; i++)
|
|
|
|
|
{
|
2016-02-20 15:19:13 +00:00
|
|
|
|
RROutput output = rr_monitors[i].outputs[0];
|
2016-03-04 19:34:03 +00:00
|
|
|
|
XRROutputInfo *output_info;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkX11Monitor *monitor;
|
|
|
|
|
GdkRectangle geometry;
|
|
|
|
|
GdkRectangle newgeo;
|
|
|
|
|
char *name;
|
2019-08-06 06:16:01 +00:00
|
|
|
|
char *manufacturer = NULL;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
int refresh_rate = 0;
|
2016-02-20 00:31:59 +00:00
|
|
|
|
|
2016-03-04 19:34:03 +00:00
|
|
|
|
gdk_x11_display_error_trap_push (display);
|
|
|
|
|
output_info = XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
|
|
|
|
|
if (gdk_x11_display_error_trap_pop (display))
|
|
|
|
|
continue;
|
|
|
|
|
|
2016-03-03 15:30:00 +00:00
|
|
|
|
if (output_info == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
2016-02-20 00:31:59 +00:00
|
|
|
|
if (output_info->connection == RR_Disconnected)
|
|
|
|
|
{
|
|
|
|
|
XRRFreeOutputInfo (output_info);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (first_output == None)
|
|
|
|
|
first_output = output;
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (output_info->crtc)
|
|
|
|
|
{
|
|
|
|
|
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < resources->nmode; j++)
|
|
|
|
|
{
|
|
|
|
|
XRRModeInfo *xmode = &resources->modes[j];
|
|
|
|
|
if (xmode->id == crtc->mode)
|
|
|
|
|
{
|
2016-07-25 12:32:24 +00:00
|
|
|
|
if (xmode->hTotal != 0 && xmode->vTotal != 0)
|
|
|
|
|
refresh_rate = (1000 * xmode->dotClock) / (xmode->hTotal * xmode->vTotal);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XRRFreeCrtcInfo (crtc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
monitor = find_monitor_by_output (x11_display, output);
|
|
|
|
|
if (monitor)
|
|
|
|
|
monitor->remove = FALSE;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
monitor = g_object_new (GDK_TYPE_X11_MONITOR,
|
|
|
|
|
"display", display,
|
|
|
|
|
NULL);
|
|
|
|
|
monitor->output = output;
|
|
|
|
|
monitor->add = TRUE;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_list_store_append (x11_display->monitors, monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2015-02-02 06:02:04 +00:00
|
|
|
|
|
2019-08-06 06:16:01 +00:00
|
|
|
|
/* Fetch minimal manufacturer information (PNP ID) from EDID */
|
|
|
|
|
{
|
|
|
|
|
#define EDID_LENGTH 128
|
|
|
|
|
Atom actual_type, edid_atom;
|
|
|
|
|
char tmp[3];
|
|
|
|
|
int actual_format;
|
|
|
|
|
unsigned char *prop;
|
|
|
|
|
unsigned long nbytes, bytes_left;
|
|
|
|
|
Display *disp = GDK_DISPLAY_XDISPLAY (x11_display);
|
|
|
|
|
|
|
|
|
|
edid_atom = XInternAtom (disp, RR_PROPERTY_RANDR_EDID, FALSE);
|
|
|
|
|
|
|
|
|
|
XRRGetOutputProperty (disp, output,
|
|
|
|
|
edid_atom,
|
|
|
|
|
0,
|
|
|
|
|
EDID_LENGTH,
|
|
|
|
|
FALSE,
|
|
|
|
|
FALSE,
|
|
|
|
|
AnyPropertyType,
|
|
|
|
|
&actual_type,
|
|
|
|
|
&actual_format,
|
|
|
|
|
&nbytes,
|
|
|
|
|
&bytes_left,
|
|
|
|
|
&prop);
|
|
|
|
|
|
|
|
|
|
// Check partial EDID header (whole header: 00 ff ff ff ff ff ff 00)
|
|
|
|
|
if (nbytes >= EDID_LENGTH && prop[0] == 0x00 && prop[1] == 0xff)
|
|
|
|
|
{
|
|
|
|
|
/* decode the Vendor ID from three 5 bit words packed into 2 bytes
|
|
|
|
|
* /--08--\/--09--\
|
|
|
|
|
* 7654321076543210
|
|
|
|
|
* |\---/\---/\---/
|
|
|
|
|
* R C1 C2 C3 */
|
|
|
|
|
tmp[0] = 'A' + ((prop[8] & 0x7c) / 4) - 1;
|
|
|
|
|
tmp[1] = 'A' + ((prop[8] & 0x3) * 8) + ((prop[9] & 0xe0) / 32) - 1;
|
|
|
|
|
tmp[2] = 'A' + (prop[9] & 0x1f) - 1;
|
|
|
|
|
|
|
|
|
|
manufacturer = g_strndup (tmp, sizeof (tmp));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XFree(prop);
|
|
|
|
|
#undef EDID_LENGTH
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
|
|
|
|
|
name = g_strndup (output_info->name, output_info->nameLen);
|
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
|
newgeo.x = rr_monitors[i].x / x11_screen->surface_scale;
|
|
|
|
|
newgeo.y = rr_monitors[i].y / x11_screen->surface_scale;
|
|
|
|
|
newgeo.width = rr_monitors[i].width / x11_screen->surface_scale;
|
|
|
|
|
newgeo.height = rr_monitors[i].height / x11_screen->surface_scale;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
2020-05-17 03:23:16 +00:00
|
|
|
|
gdk_monitor_set_geometry (GDK_MONITOR (monitor), &newgeo);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
gdk_monitor_set_physical_size (GDK_MONITOR (monitor),
|
|
|
|
|
rr_monitors[i].mwidth,
|
|
|
|
|
rr_monitors[i].mheight);
|
|
|
|
|
gdk_monitor_set_subpixel_layout (GDK_MONITOR (monitor),
|
|
|
|
|
translate_subpixel_order (output_info->subpixel_order));
|
|
|
|
|
gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh_rate);
|
2018-03-20 11:05:26 +00:00
|
|
|
|
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->surface_scale);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
gdk_monitor_set_model (GDK_MONITOR (monitor), name);
|
2019-06-20 15:09:28 +00:00
|
|
|
|
gdk_monitor_set_connector (GDK_MONITOR (monitor), name);
|
2019-08-06 06:16:01 +00:00
|
|
|
|
gdk_monitor_set_manufacturer (GDK_MONITOR (monitor), manufacturer);
|
|
|
|
|
g_free (manufacturer);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
g_free (name);
|
2016-02-20 00:31:59 +00:00
|
|
|
|
|
2015-02-02 06:02:04 +00:00
|
|
|
|
if (rr_monitors[i].primary)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
primary_output = monitor->output;
|
2015-05-22 10:56:23 +00:00
|
|
|
|
|
2016-02-20 00:31:59 +00:00
|
|
|
|
XRRFreeOutputInfo (output_info);
|
2015-02-02 06:02:04 +00:00
|
|
|
|
}
|
2016-02-20 15:19:13 +00:00
|
|
|
|
|
2015-02-02 06:02:04 +00:00
|
|
|
|
XRRFreeMonitors (rr_monitors);
|
2016-02-20 15:19:13 +00:00
|
|
|
|
XRRFreeScreenResources (resources);
|
2015-02-02 06:02:04 +00:00
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)) - 1; i >= 0; i--)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkX11Monitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
2020-05-17 03:47:07 +00:00
|
|
|
|
|
2020-05-17 03:35:14 +00:00
|
|
|
|
notify_surface_monitor_change (x11_display, GDK_MONITOR (monitor));
|
2020-05-17 03:47:07 +00:00
|
|
|
|
if (monitor->remove)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_list_store_remove (x11_display->monitors, i);
|
2020-05-17 03:47:07 +00:00
|
|
|
|
gdk_monitor_invalidate (GDK_MONITOR (monitor));
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2015-05-22 10:56:23 +00:00
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
x11_display->primary_monitor = 0;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
2015-05-22 10:56:23 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkX11Monitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (monitor->output == primary_output)
|
2015-05-22 10:56:23 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
x11_display->primary_monitor = i;
|
2015-05-22 10:56:23 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2016-02-20 00:31:59 +00:00
|
|
|
|
|
|
|
|
|
/* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */
|
|
|
|
|
if (primary_output == None &&
|
2016-04-03 04:12:39 +00:00
|
|
|
|
g_ascii_strncasecmp (gdk_monitor_get_model (GDK_MONITOR (monitor)), "LVDS", 4) == 0)
|
2016-02-20 00:31:59 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
x11_display->primary_monitor = i;
|
2016-02-20 00:31:59 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* No primary specified and no LVDS found */
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (monitor->output == first_output)
|
|
|
|
|
x11_display->primary_monitor = i;
|
2015-05-22 10:56:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
return g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)) > 0;
|
2015-02-02 06:02:04 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-02-20 15:19:13 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-13 18:12:57 +00:00
|
|
|
|
static gboolean
|
2020-05-17 03:10:19 +00:00
|
|
|
|
init_randr13 (GdkX11Screen *x11_screen)
|
2009-02-13 18:12:57 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_RANDR
|
2017-11-17 15:18:20 +00:00
|
|
|
|
GdkDisplay *display = GDK_SCREEN_DISPLAY (x11_screen);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
|
2009-02-13 18:12:57 +00:00
|
|
|
|
XRRScreenResources *resources;
|
2016-02-20 15:19:13 +00:00
|
|
|
|
RROutput primary_output = None;
|
2010-04-09 15:22:51 +00:00
|
|
|
|
RROutput first_output = None;
|
2009-02-13 18:12:57 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (!x11_display->have_randr13)
|
2009-02-13 18:12:57 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
resources = XRRGetScreenResourcesCurrent (x11_screen->xdisplay,
|
2016-02-20 15:19:13 +00:00
|
|
|
|
x11_screen->xroot_window);
|
2009-02-13 18:12:57 +00:00
|
|
|
|
if (!resources)
|
|
|
|
|
return FALSE;
|
2009-12-08 17:27:02 +00:00
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkX11Monitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
monitor->add = FALSE;
|
|
|
|
|
monitor->remove = TRUE;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2009-02-13 18:12:57 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < resources->noutput; ++i)
|
|
|
|
|
{
|
2016-02-20 15:19:13 +00:00
|
|
|
|
RROutput output = resources->outputs[i];
|
|
|
|
|
XRROutputInfo *output_info =
|
|
|
|
|
XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
|
2009-02-13 18:12:57 +00:00
|
|
|
|
|
2016-02-20 15:19:13 +00:00
|
|
|
|
if (output_info->connection == RR_Disconnected)
|
2009-05-30 04:05:35 +00:00
|
|
|
|
{
|
2016-02-20 15:19:13 +00:00
|
|
|
|
XRRFreeOutputInfo (output_info);
|
2009-05-30 04:05:35 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2009-02-18 23:12:26 +00:00
|
|
|
|
|
2016-02-20 15:19:13 +00:00
|
|
|
|
if (output_info->crtc)
|
2009-02-13 18:12:57 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkX11Monitor *monitor;
|
2016-02-20 15:19:13 +00:00
|
|
|
|
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
char *name;
|
|
|
|
|
GdkRectangle geometry;
|
|
|
|
|
GdkRectangle newgeo;
|
|
|
|
|
int j;
|
|
|
|
|
int refresh_rate = 0;
|
2009-02-13 18:12:57 +00:00
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
for (j = 0; j < resources->nmode; j++)
|
|
|
|
|
{
|
|
|
|
|
XRRModeInfo *xmode = &resources->modes[j];
|
|
|
|
|
if (xmode->id == crtc->mode)
|
|
|
|
|
{
|
2018-03-08 14:58:42 +00:00
|
|
|
|
if (xmode->hTotal != 0 && xmode->vTotal != 0)
|
|
|
|
|
refresh_rate = (1000 * xmode->dotClock) / (xmode->hTotal * xmode->vTotal);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-13 18:12:57 +00:00
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
monitor = find_monitor_by_output (x11_display, output);
|
|
|
|
|
if (monitor)
|
|
|
|
|
monitor->remove = FALSE;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
monitor = g_object_new (gdk_x11_monitor_get_type (),
|
|
|
|
|
"display", display,
|
|
|
|
|
NULL);
|
|
|
|
|
monitor->output = output;
|
|
|
|
|
monitor->add = TRUE;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_list_store_append (x11_display->monitors, monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
|
|
|
|
|
name = g_strndup (output_info->name, output_info->nameLen);
|
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
|
newgeo.x = crtc->x / x11_screen->surface_scale;
|
|
|
|
|
newgeo.y = crtc->y / x11_screen->surface_scale;
|
|
|
|
|
newgeo.width = crtc->width / x11_screen->surface_scale;
|
|
|
|
|
newgeo.height = crtc->height / x11_screen->surface_scale;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
2020-05-17 03:23:16 +00:00
|
|
|
|
gdk_monitor_set_geometry (GDK_MONITOR (monitor), &newgeo);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
gdk_monitor_set_physical_size (GDK_MONITOR (monitor),
|
|
|
|
|
output_info->mm_width,
|
|
|
|
|
output_info->mm_height);
|
|
|
|
|
gdk_monitor_set_subpixel_layout (GDK_MONITOR (monitor),
|
|
|
|
|
translate_subpixel_order (output_info->subpixel_order));
|
|
|
|
|
gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh_rate);
|
2018-03-20 11:05:26 +00:00
|
|
|
|
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->surface_scale);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
gdk_monitor_set_model (GDK_MONITOR (monitor), name);
|
|
|
|
|
|
|
|
|
|
g_free (name);
|
2009-02-13 18:12:57 +00:00
|
|
|
|
|
|
|
|
|
XRRFreeCrtcInfo (crtc);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-20 15:19:13 +00:00
|
|
|
|
XRRFreeOutputInfo (output_info);
|
2009-02-13 18:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-09 15:22:51 +00:00
|
|
|
|
if (resources->noutput > 0)
|
|
|
|
|
first_output = resources->outputs[0];
|
|
|
|
|
|
2009-02-13 18:12:57 +00:00
|
|
|
|
XRRFreeScreenResources (resources);
|
|
|
|
|
|
2016-09-09 16:54:13 +00:00
|
|
|
|
/* Which usable multihead data is not returned in non RandR 1.2+ X driver? */
|
2009-02-13 18:12:57 +00:00
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)) - 1; i >= 0; i--)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkX11Monitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
2020-05-17 03:47:07 +00:00
|
|
|
|
|
2020-05-17 03:35:14 +00:00
|
|
|
|
notify_surface_monitor_change (x11_display, GDK_MONITOR (monitor));
|
2020-05-17 03:47:07 +00:00
|
|
|
|
if (monitor->remove)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_list_store_remove (x11_display->monitors, i);
|
2020-05-17 03:47:07 +00:00
|
|
|
|
gdk_monitor_invalidate (GDK_MONITOR (monitor));
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2020-11-10 14:07:01 +00:00
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2010-04-09 13:05:38 +00:00
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
x11_display->primary_monitor = 0;
|
2010-12-21 01:32:13 +00:00
|
|
|
|
primary_output = XRRGetOutputPrimary (x11_screen->xdisplay,
|
|
|
|
|
x11_screen->xroot_window);
|
2010-04-09 13:05:38 +00:00
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
2010-04-09 13:05:38 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkX11Monitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (monitor->output == primary_output)
|
2016-02-20 15:19:13 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
x11_display->primary_monitor = i;
|
2016-02-20 15:19:13 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2010-04-09 13:05:38 +00:00
|
|
|
|
|
|
|
|
|
/* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */
|
|
|
|
|
if (primary_output == None &&
|
2016-04-03 04:12:39 +00:00
|
|
|
|
g_ascii_strncasecmp (gdk_monitor_get_model (GDK_MONITOR (monitor)), "LVDS", 4) == 0)
|
2016-02-20 15:19:13 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
x11_display->primary_monitor = i;
|
2016-02-20 15:19:13 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2010-04-09 15:22:51 +00:00
|
|
|
|
|
|
|
|
|
/* No primary specified and no LVDS found */
|
2016-04-03 04:12:39 +00:00
|
|
|
|
if (monitor->output == first_output)
|
|
|
|
|
x11_display->primary_monitor = i;
|
2010-04-09 13:05:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
return g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)) > 0;
|
2009-02-13 18:12:57 +00:00
|
|
|
|
#endif
|
2010-04-09 13:05:38 +00:00
|
|
|
|
|
2009-02-13 18:12:57 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
static void
|
2020-05-17 03:10:19 +00:00
|
|
|
|
init_no_multihead (GdkX11Screen *x11_screen)
|
2013-01-21 10:52:32 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkX11Display *x11_display = GDK_X11_DISPLAY (x11_screen->display);
|
|
|
|
|
GdkX11Monitor *monitor;
|
2016-09-09 12:53:18 +00:00
|
|
|
|
int width_mm, height_mm;
|
2016-11-03 23:33:13 +00:00
|
|
|
|
int width, height;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
int i;
|
2013-01-21 10:52:32 +00:00
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
2013-01-21 10:52:32 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
monitor->add = FALSE;
|
|
|
|
|
monitor->remove = TRUE;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_object_unref (monitor);
|
2013-01-21 10:52:32 +00:00
|
|
|
|
}
|
2009-02-24 05:09:13 +00:00
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
monitor = find_monitor_by_output (x11_display, 0);
|
|
|
|
|
if (monitor)
|
|
|
|
|
monitor->remove = FALSE;
|
|
|
|
|
else
|
2009-02-24 05:09:13 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
monitor = g_object_new (gdk_x11_monitor_get_type (),
|
|
|
|
|
"display", x11_display,
|
|
|
|
|
NULL);
|
|
|
|
|
monitor->output = 0;
|
|
|
|
|
monitor->add = TRUE;
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_list_store_append (x11_display->monitors, monitor);
|
2009-02-24 05:09:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-09 12:53:18 +00:00
|
|
|
|
width_mm = WidthMMOfScreen (x11_screen->xscreen);
|
|
|
|
|
height_mm = HeightMMOfScreen (x11_screen->xscreen);
|
2016-11-03 23:33:13 +00:00
|
|
|
|
width = WidthOfScreen (x11_screen->xscreen);
|
|
|
|
|
height = HeightOfScreen (x11_screen->xscreen);
|
2016-09-09 12:53:18 +00:00
|
|
|
|
|
2020-05-17 03:23:16 +00:00
|
|
|
|
gdk_monitor_set_geometry (GDK_MONITOR (monitor), &(GdkRectangle) { 0, 0, width, height });
|
2016-09-09 12:53:18 +00:00
|
|
|
|
gdk_monitor_set_physical_size (GDK_MONITOR (monitor), width_mm, height_mm);
|
2018-03-20 11:05:26 +00:00
|
|
|
|
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->surface_scale);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
|
|
|
|
x11_display->primary_monitor = 0;
|
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)) - 1; i >= 0; i--)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
2020-05-17 03:47:07 +00:00
|
|
|
|
|
2020-05-17 03:35:14 +00:00
|
|
|
|
notify_surface_monitor_change (x11_display, GDK_MONITOR (monitor));
|
2020-05-17 03:47:07 +00:00
|
|
|
|
if (monitor->remove)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_list_store_remove (x11_display->monitors, i);
|
2020-05-17 03:47:07 +00:00
|
|
|
|
gdk_monitor_invalidate (GDK_MONITOR (monitor));
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2020-05-12 17:46:40 +00:00
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2016-02-20 15:19:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 03:10:19 +00:00
|
|
|
|
static void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
init_multihead (GdkX11Screen *screen)
|
2016-02-20 15:19:13 +00:00
|
|
|
|
{
|
2020-05-17 03:10:19 +00:00
|
|
|
|
if (!init_randr15 (screen) &&
|
|
|
|
|
!init_randr13 (screen))
|
|
|
|
|
init_no_multihead (screen);
|
2007-12-13 18:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
GdkX11Screen *
|
2002-05-03 19:03:03 +00:00
|
|
|
|
_gdk_x11_screen_new (GdkDisplay *display,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int screen_number,
|
2016-11-03 22:40:54 +00:00
|
|
|
|
gboolean setup_display)
|
2002-05-03 19:03:03 +00:00
|
|
|
|
{
|
2010-12-21 01:32:13 +00:00
|
|
|
|
GdkX11Screen *x11_screen;
|
2010-12-20 18:20:10 +00:00
|
|
|
|
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
2013-06-20 09:40:07 +00:00
|
|
|
|
const char *scale_str;
|
2002-05-03 19:03:03 +00:00
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
x11_screen = g_object_new (GDK_TYPE_X11_SCREEN, NULL);
|
2002-05-03 19:03:03 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->display = display;
|
|
|
|
|
x11_screen->xdisplay = display_x11->xdisplay;
|
|
|
|
|
x11_screen->xscreen = ScreenOfDisplay (display_x11->xdisplay, screen_number);
|
|
|
|
|
x11_screen->screen_num = screen_number;
|
2017-11-13 21:39:54 +00:00
|
|
|
|
x11_screen->xroot_window = RootWindow (display_x11->xdisplay, screen_number);
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->wmspec_check_window = None;
|
2002-09-25 19:16:46 +00:00
|
|
|
|
/* we want this to be always non-null */
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->window_manager_name = g_strdup ("unknown");
|
2013-06-20 09:40:07 +00:00
|
|
|
|
|
|
|
|
|
scale_str = g_getenv ("GDK_SCALE");
|
|
|
|
|
if (scale_str)
|
|
|
|
|
{
|
2018-03-20 11:05:26 +00:00
|
|
|
|
x11_screen->fixed_surface_scale = TRUE;
|
|
|
|
|
x11_screen->surface_scale = atol (scale_str);
|
2018-04-07 08:05:38 +00:00
|
|
|
|
if (x11_screen->surface_scale <= 0)
|
2018-03-20 11:05:26 +00:00
|
|
|
|
x11_screen->surface_scale = 1;
|
2013-06-20 09:40:07 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2018-03-20 11:05:26 +00:00
|
|
|
|
x11_screen->surface_scale = 1;
|
2013-06-20 09:40:07 +00:00
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
init_randr_support (x11_screen);
|
|
|
|
|
init_multihead (x11_screen);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
_gdk_x11_screen_init_visuals (x11_screen, setup_display);
|
2013-11-22 17:33:02 +00:00
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
return x11_screen;
|
2002-05-03 19:03:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-27 20:45:40 +00:00
|
|
|
|
void
|
2018-03-20 11:05:26 +00:00
|
|
|
|
_gdk_x11_screen_set_surface_scale (GdkX11Screen *x11_screen,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int scale)
|
2013-06-27 20:45:40 +00:00
|
|
|
|
{
|
2016-04-03 04:12:39 +00:00
|
|
|
|
GdkX11Display *x11_display = GDK_X11_DISPLAY (x11_screen->display);
|
2013-06-27 20:45:40 +00:00
|
|
|
|
GList *toplevels, *l;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
int i;
|
2013-06-27 20:45:40 +00:00
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
|
if (x11_screen->surface_scale == scale)
|
2013-06-27 20:45:40 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
|
x11_screen->surface_scale = scale;
|
2013-06-27 20:45:40 +00:00
|
|
|
|
|
2017-11-05 23:36:49 +00:00
|
|
|
|
toplevels = gdk_x11_display_get_toplevel_windows (x11_screen->display);
|
2013-06-27 20:45:40 +00:00
|
|
|
|
|
|
|
|
|
for (l = toplevels; l != NULL; l = l->next)
|
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
GdkSurface *surface = l->data;
|
2013-06-27 20:45:40 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
_gdk_x11_surface_set_surface_scale (surface, scale);
|
2013-06-27 20:45:40 +00:00
|
|
|
|
}
|
2013-08-03 14:51:28 +00:00
|
|
|
|
|
2020-05-12 17:46:40 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2020-05-12 17:46:40 +00:00
|
|
|
|
GdkMonitor *monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), i);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
|
|
|
|
gdk_monitor_set_scale_factor (monitor, scale);
|
2020-05-12 17:46:40 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (monitor);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
2020-02-10 14:19:32 +00:00
|
|
|
|
|
|
|
|
|
/* We re-read the monitor sizes so we can apply the new scale */
|
|
|
|
|
process_monitors_change (x11_screen);
|
2013-06-27 20:45:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-04 15:58:19 +00:00
|
|
|
|
static void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
init_randr_support (GdkX11Screen *x11_screen)
|
2002-10-04 15:58:19 +00:00
|
|
|
|
{
|
2013-02-15 17:20:18 +00:00
|
|
|
|
/* NB: This is also needed for XSettings, so don't remove. */
|
2017-11-17 15:18:20 +00:00
|
|
|
|
XSelectInput (GDK_SCREEN_XDISPLAY (x11_screen),
|
2010-12-23 12:50:13 +00:00
|
|
|
|
x11_screen->xroot_window,
|
|
|
|
|
StructureNotifyMask);
|
2007-12-13 18:27:05 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_RANDR
|
2017-11-17 15:18:20 +00:00
|
|
|
|
if (!GDK_X11_DISPLAY (GDK_SCREEN_DISPLAY (x11_screen))->have_randr12)
|
2010-12-23 12:50:13 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
XRRSelectInput (GDK_SCREEN_XDISPLAY (x11_screen),
|
2010-12-23 12:50:13 +00:00
|
|
|
|
x11_screen->xroot_window,
|
|
|
|
|
RRScreenChangeNotifyMask
|
|
|
|
|
| RRCrtcChangeNotifyMask
|
|
|
|
|
| RROutputPropertyNotifyMask);
|
2007-12-13 18:27:05 +00:00
|
|
|
|
#endif
|
2002-10-04 15:58:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-02-24 05:09:13 +00:00
|
|
|
|
static void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
process_monitors_change (GdkX11Screen *screen)
|
2009-02-24 05:09:13 +00:00
|
|
|
|
{
|
2017-11-01 02:26:39 +00:00
|
|
|
|
init_multihead (screen);
|
2009-02-24 05:09:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-04 15:58:19 +00:00
|
|
|
|
void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
_gdk_x11_screen_size_changed (GdkX11Screen *screen,
|
2017-12-12 23:39:32 +00:00
|
|
|
|
const XEvent *event)
|
2002-10-04 15:58:19 +00:00
|
|
|
|
{
|
2010-06-03 17:43:42 +00:00
|
|
|
|
#ifdef HAVE_RANDR
|
2010-12-20 16:14:04 +00:00
|
|
|
|
GdkX11Display *display_x11;
|
2008-10-22 14:55:56 +00:00
|
|
|
|
|
2017-11-01 23:41:45 +00:00
|
|
|
|
display_x11 = GDK_X11_DISPLAY (GDK_SCREEN_DISPLAY (screen));
|
2009-02-24 05:09:13 +00:00
|
|
|
|
|
|
|
|
|
if (display_x11->have_randr13 && event->type == ConfigureNotify)
|
2011-02-24 18:44:16 +00:00
|
|
|
|
return;
|
2009-02-24 05:09:13 +00:00
|
|
|
|
|
2017-12-12 23:39:32 +00:00
|
|
|
|
XRRUpdateConfiguration ((XEvent *) event);
|
2002-10-04 15:58:19 +00:00
|
|
|
|
#else
|
2016-09-09 12:53:18 +00:00
|
|
|
|
if (event->type != ConfigureNotify)
|
2002-10-04 15:58:19 +00:00
|
|
|
|
return;
|
|
|
|
|
#endif
|
2008-10-22 14:55:56 +00:00
|
|
|
|
|
2009-02-24 05:09:13 +00:00
|
|
|
|
process_monitors_change (screen);
|
2007-12-13 18:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 04:12:39 +00:00
|
|
|
|
void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
_gdk_x11_screen_get_edge_monitors (GdkX11Screen *x11_screen,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *top,
|
|
|
|
|
int *bottom,
|
|
|
|
|
int *left,
|
|
|
|
|
int *right)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2017-03-23 16:15:00 +00:00
|
|
|
|
#ifdef HAVE_XFREE_XINERAMA
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int top_most_pos = HeightOfScreen (x11_screen->xscreen);
|
|
|
|
|
int left_most_pos = WidthOfScreen (x11_screen->xscreen);
|
|
|
|
|
int bottom_most_pos = 0;
|
|
|
|
|
int right_most_pos = 0;
|
|
|
|
|
int i;
|
2016-04-28 03:08:25 +00:00
|
|
|
|
XineramaScreenInfo *x_monitors;
|
|
|
|
|
int x_n_monitors;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
*top = *bottom = *left = *right = -1;
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_XFREE_XINERAMA
|
|
|
|
|
if (!XineramaIsActive (x11_screen->xdisplay))
|
|
|
|
|
return;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
2016-04-28 03:08:25 +00:00
|
|
|
|
x_monitors = XineramaQueryScreens (x11_screen->xdisplay, &x_n_monitors);
|
|
|
|
|
if (x_n_monitors <= 0 || x_monitors == NULL)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2016-04-28 03:08:25 +00:00
|
|
|
|
if (x_monitors)
|
|
|
|
|
XFree (x_monitors);
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
2016-04-28 03:08:25 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2016-04-03 04:12:39 +00:00
|
|
|
|
|
2016-04-28 03:08:25 +00:00
|
|
|
|
for (i = 0; i < x_n_monitors; i++)
|
|
|
|
|
{
|
|
|
|
|
if (left && left_most_pos > x_monitors[i].x_org)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2016-04-28 03:08:25 +00:00
|
|
|
|
left_most_pos = x_monitors[i].x_org;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
*left = i;
|
|
|
|
|
}
|
2016-04-28 03:08:25 +00:00
|
|
|
|
if (right && right_most_pos < x_monitors[i].x_org + x_monitors[i].width)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2016-04-28 03:08:25 +00:00
|
|
|
|
right_most_pos = x_monitors[i].x_org + x_monitors[i].width;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
*right = i;
|
|
|
|
|
}
|
2016-04-28 03:08:25 +00:00
|
|
|
|
if (top && top_most_pos > x_monitors[i].y_org)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2016-04-28 03:08:25 +00:00
|
|
|
|
top_most_pos = x_monitors[i].y_org;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
*top = i;
|
|
|
|
|
}
|
2016-04-28 03:08:25 +00:00
|
|
|
|
if (bottom && bottom_most_pos < x_monitors[i].y_org + x_monitors[i].height)
|
2016-04-03 04:12:39 +00:00
|
|
|
|
{
|
2016-04-28 03:08:25 +00:00
|
|
|
|
bottom_most_pos = x_monitors[i].y_org + x_monitors[i].height;
|
2016-04-03 04:12:39 +00:00
|
|
|
|
*bottom = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-28 03:08:25 +00:00
|
|
|
|
|
|
|
|
|
XFree (x_monitors);
|
|
|
|
|
#endif
|
2016-04-03 04:12:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-25 19:16:46 +00:00
|
|
|
|
void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
_gdk_x11_screen_window_manager_changed (GdkX11Screen *screen)
|
2002-09-25 19:16:46 +00:00
|
|
|
|
{
|
2003-02-28 01:45:51 +00:00
|
|
|
|
g_signal_emit (screen, signals[WINDOW_MANAGER_CHANGED], 0);
|
2002-09-25 19:16:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-30 20:44:18 +00:00
|
|
|
|
gboolean
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_setting (GdkX11Screen *x11_screen,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *name,
|
2010-12-06 21:05:13 +00:00
|
|
|
|
GValue *value)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2013-02-16 23:30:06 +00:00
|
|
|
|
const GValue *setting;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2013-02-19 18:55:02 +00:00
|
|
|
|
if (x11_screen->xsettings == NULL)
|
|
|
|
|
goto out;
|
2013-02-19 13:31:03 +00:00
|
|
|
|
setting = g_hash_table_lookup (x11_screen->xsettings, name);
|
2013-02-09 23:02:53 +00:00
|
|
|
|
if (setting == NULL)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2015-09-08 23:29:32 +00:00
|
|
|
|
if (!g_value_transform (setting, value))
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2013-02-16 23:30:06 +00:00
|
|
|
|
g_warning ("Cannot transform xsetting %s of type %s to type %s\n",
|
|
|
|
|
name,
|
|
|
|
|
g_type_name (G_VALUE_TYPE (setting)),
|
|
|
|
|
g_type_name (G_VALUE_TYPE (value)));
|
|
|
|
|
goto out;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 23:30:06 +00:00
|
|
|
|
return TRUE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
out:
|
2017-11-17 15:18:20 +00:00
|
|
|
|
return _gdk_x11_screen_get_xft_setting (x11_screen, name, value);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cleanup_atoms(gpointer data)
|
|
|
|
|
{
|
|
|
|
|
NetWmSupportedAtoms *supported_atoms = data;
|
|
|
|
|
if (supported_atoms->atoms)
|
|
|
|
|
XFree (supported_atoms->atoms);
|
|
|
|
|
g_free (supported_atoms);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-09 05:54:08 +00:00
|
|
|
|
static Window
|
|
|
|
|
get_net_supporting_wm_check (GdkX11Screen *screen,
|
|
|
|
|
Window window)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
Atom type;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int format;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gulong n_items;
|
|
|
|
|
gulong bytes_after;
|
|
|
|
|
guchar *data;
|
2012-01-09 05:54:08 +00:00
|
|
|
|
Window value;
|
|
|
|
|
|
|
|
|
|
display = screen->display;
|
|
|
|
|
type = None;
|
|
|
|
|
data = NULL;
|
|
|
|
|
value = None;
|
|
|
|
|
|
|
|
|
|
gdk_x11_display_error_trap_push (display);
|
|
|
|
|
XGetWindowProperty (screen->xdisplay, window,
|
|
|
|
|
gdk_x11_get_xatom_by_name_for_display (display, "_NET_SUPPORTING_WM_CHECK"),
|
|
|
|
|
0, G_MAXLONG, False, XA_WINDOW, &type, &format,
|
|
|
|
|
&n_items, &bytes_after, &data);
|
|
|
|
|
gdk_x11_display_error_trap_pop_ignored (display);
|
|
|
|
|
|
|
|
|
|
if (type == XA_WINDOW)
|
|
|
|
|
value = *(Window *)data;
|
|
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
|
XFree (data);
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-11-17 15:18:20 +00:00
|
|
|
|
fetch_net_wm_check_window (GdkX11Screen *x11_screen)
|
2012-01-09 05:54:08 +00:00
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
Window window;
|
2020-07-31 14:54:41 +00:00
|
|
|
|
guint64 now;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int error;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
display = x11_screen->display;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
|
g_return_if_fail (GDK_X11_DISPLAY (display)->trusted_client);
|
2012-01-09 05:54:08 +00:00
|
|
|
|
|
|
|
|
|
if (x11_screen->wmspec_check_window != None)
|
|
|
|
|
return; /* already have it */
|
|
|
|
|
|
2020-07-31 14:54:41 +00:00
|
|
|
|
now = g_get_monotonic_time ();
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-07-31 14:54:41 +00:00
|
|
|
|
if ((now - x11_screen->last_wmspec_check_time) / 1e6 < 15)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
return; /* we've checked recently */
|
|
|
|
|
|
2012-01-09 05:54:08 +00:00
|
|
|
|
window = get_net_supporting_wm_check (x11_screen, x11_screen->xroot_window);
|
|
|
|
|
if (window == None)
|
|
|
|
|
return;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2012-01-09 05:54:08 +00:00
|
|
|
|
if (window != get_net_supporting_wm_check (x11_screen, window))
|
|
|
|
|
return;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-15 07:05:05 +00:00
|
|
|
|
gdk_x11_display_error_trap_push (display);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
/* Find out if this WM goes away, so we can reset everything. */
|
2012-01-09 05:54:08 +00:00
|
|
|
|
XSelectInput (x11_screen->xdisplay, window, StructureNotifyMask);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-15 07:05:05 +00:00
|
|
|
|
error = gdk_x11_display_error_trap_pop (display);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
if (!error)
|
|
|
|
|
{
|
2012-01-09 05:54:08 +00:00
|
|
|
|
/* We check the window property again because after XGetWindowProperty()
|
|
|
|
|
* and before XSelectInput() the window may have been recycled in such a
|
|
|
|
|
* way that XSelectInput() doesn't fail but the window is no longer what
|
|
|
|
|
* we want.
|
|
|
|
|
*/
|
|
|
|
|
if (window != get_net_supporting_wm_check (x11_screen, window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
x11_screen->wmspec_check_window = window;
|
2020-07-31 14:54:41 +00:00
|
|
|
|
x11_screen->last_wmspec_check_time = now;
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->need_refetch_net_supported = TRUE;
|
|
|
|
|
x11_screen->need_refetch_wm_name = TRUE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
/* Careful, reentrancy */
|
2017-11-17 15:18:20 +00:00
|
|
|
|
_gdk_x11_screen_window_manager_changed (x11_screen);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_x11_screen_supports_net_wm_hint:
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* @screen: the relevant #GdkX11Screen.
|
2020-02-23 00:33:56 +00:00
|
|
|
|
* @property_name: name of the WM property
|
2010-05-25 22:38:44 +00:00
|
|
|
|
*
|
|
|
|
|
* This function is specific to the X11 backend of GDK, and indicates
|
|
|
|
|
* whether the window manager supports a certain hint from the
|
2014-02-03 21:56:15 +00:00
|
|
|
|
* [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
|
2010-05-25 22:38:44 +00:00
|
|
|
|
*
|
|
|
|
|
* When using this function, keep in mind that the window manager
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* can change over time; so you shouldn’t use this function in
|
2010-05-25 22:38:44 +00:00
|
|
|
|
* a way that impacts persistent application state. A common bug
|
|
|
|
|
* is that your application can start up before the window manager
|
|
|
|
|
* does when the user logs in, and before the window manager starts
|
|
|
|
|
* gdk_x11_screen_supports_net_wm_hint() will return %FALSE for every property.
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* You can monitor the window_manager_changed signal on #GdkX11Screen to detect
|
2010-05-25 22:38:44 +00:00
|
|
|
|
* a window manager change.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the window manager supports @property
|
2010-05-25 22:38:44 +00:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_supports_net_wm_hint (GdkX11Screen *x11_screen,
|
2020-02-23 00:33:56 +00:00
|
|
|
|
const char *property_name)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
|
|
|
|
gulong i;
|
|
|
|
|
NetWmSupportedAtoms *supported_atoms;
|
|
|
|
|
GdkDisplay *display;
|
2013-06-23 19:22:13 +00:00
|
|
|
|
Atom atom;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
display = x11_screen->display;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
|
if (!G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
|
2010-05-25 22:38:44 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
supported_atoms = g_object_get_data (G_OBJECT (x11_screen), "gdk-net-wm-supported-atoms");
|
2010-05-25 22:38:44 +00:00
|
|
|
|
if (!supported_atoms)
|
|
|
|
|
{
|
|
|
|
|
supported_atoms = g_new0 (NetWmSupportedAtoms, 1);
|
2017-11-17 15:18:20 +00:00
|
|
|
|
g_object_set_data_full (G_OBJECT (x11_screen), "gdk-net-wm-supported-atoms", supported_atoms, cleanup_atoms);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
fetch_net_wm_check_window (x11_screen);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
if (x11_screen->wmspec_check_window == None)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
if (x11_screen->need_refetch_net_supported)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
|
|
|
|
/* WM has changed since we last got the supported list,
|
|
|
|
|
* refetch it.
|
|
|
|
|
*/
|
|
|
|
|
Atom type;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int format;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gulong bytes_after;
|
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->need_refetch_net_supported = FALSE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
if (supported_atoms->atoms)
|
|
|
|
|
XFree (supported_atoms->atoms);
|
|
|
|
|
|
|
|
|
|
supported_atoms->atoms = NULL;
|
|
|
|
|
supported_atoms->n_atoms = 0;
|
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), x11_screen->xroot_window,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_x11_get_xatom_by_name_for_display (display, "_NET_SUPPORTED"),
|
|
|
|
|
0, G_MAXLONG, False, XA_ATOM, &type, &format,
|
|
|
|
|
&supported_atoms->n_atoms, &bytes_after,
|
|
|
|
|
(guchar **)&supported_atoms->atoms);
|
|
|
|
|
|
|
|
|
|
if (type != XA_ATOM)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (supported_atoms->atoms == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2020-02-23 00:33:56 +00:00
|
|
|
|
atom = gdk_x11_get_xatom_by_name_for_display (display, property_name);
|
2013-06-23 19:22:13 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < supported_atoms->n_atoms; i++)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2013-06-23 19:22:13 +00:00
|
|
|
|
if (supported_atoms->atoms[i] == atom)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_x11_screen_get_window_manager_name:
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* @screen: a #GdkX11Screen
|
2010-05-25 22:38:44 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the name of the window manager for @screen.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the name of the window manager screen @screen, or
|
2010-05-25 22:38:44 +00:00
|
|
|
|
* "unknown" if the window manager is unknown. The string is owned by GDK
|
|
|
|
|
* and should not be freed.
|
|
|
|
|
**/
|
|
|
|
|
const char*
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_window_manager_name (GdkX11Screen *x11_screen)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2010-12-15 07:05:05 +00:00
|
|
|
|
GdkDisplay *display;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
display = x11_screen->display;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
|
if (!G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
|
2010-12-21 01:32:13 +00:00
|
|
|
|
return x11_screen->window_manager_name;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
fetch_net_wm_check_window (x11_screen);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
if (x11_screen->need_refetch_wm_name)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
|
|
|
|
/* Get the name of the window manager */
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->need_refetch_wm_name = FALSE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
g_free (x11_screen->window_manager_name);
|
|
|
|
|
x11_screen->window_manager_name = g_strdup ("unknown");
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
if (x11_screen->wmspec_check_window != None)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
|
|
|
|
Atom type;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int format;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gulong n_items;
|
|
|
|
|
gulong bytes_after;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *name;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
|
2010-12-15 07:05:05 +00:00
|
|
|
|
gdk_x11_display_error_trap_push (display);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-15 07:05:05 +00:00
|
|
|
|
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
|
2010-12-21 01:32:13 +00:00
|
|
|
|
x11_screen->wmspec_check_window,
|
2010-12-15 07:05:05 +00:00
|
|
|
|
gdk_x11_get_xatom_by_name_for_display (display,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
"_NET_WM_NAME"),
|
|
|
|
|
0, G_MAXLONG, False,
|
2010-12-15 07:05:05 +00:00
|
|
|
|
gdk_x11_get_xatom_by_name_for_display (display,
|
2010-05-25 22:38:44 +00:00
|
|
|
|
"UTF8_STRING"),
|
|
|
|
|
&type, &format,
|
|
|
|
|
&n_items, &bytes_after,
|
|
|
|
|
(guchar **)&name);
|
|
|
|
|
|
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 (name != NULL)
|
|
|
|
|
{
|
2010-12-21 01:32:13 +00:00
|
|
|
|
g_free (x11_screen->window_manager_name);
|
|
|
|
|
x11_screen->window_manager_name = g_strdup (name);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
XFree (name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-17 15:18:20 +00:00
|
|
|
|
return x11_screen->window_manager_name;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2010-12-06 21:05:13 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2010-12-21 01:40:45 +00:00
|
|
|
|
gdk_x11_screen_class_init (GdkX11ScreenClass *klass)
|
2010-12-06 21:05:13 +00:00
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2010-12-21 01:32:13 +00:00
|
|
|
|
object_class->dispose = gdk_x11_screen_dispose;
|
|
|
|
|
object_class->finalize = gdk_x11_screen_finalize;
|
|
|
|
|
|
2010-12-06 21:05:13 +00:00
|
|
|
|
signals[WINDOW_MANAGER_CHANGED] =
|
2012-02-21 16:32:37 +00:00
|
|
|
|
g_signal_new (g_intern_static_string ("window-manager-changed"),
|
2010-12-06 21:05:13 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2010-12-21 01:32:13 +00:00
|
|
|
|
G_STRUCT_OFFSET (GdkX11ScreenClass, window_manager_changed),
|
2010-12-06 21:05:13 +00:00
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2010-12-06 21:05:13 +00:00
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
0);
|
|
|
|
|
}
|
2013-08-24 04:51:01 +00:00
|
|
|
|
|
|
|
|
|
static guint32
|
2017-11-17 15:18:20 +00:00
|
|
|
|
get_netwm_cardinal_property (GdkX11Screen *x11_screen,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *name)
|
2013-08-24 04:51:01 +00:00
|
|
|
|
{
|
|
|
|
|
guint32 prop = 0;
|
|
|
|
|
Atom type;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int format;
|
2013-08-24 04:51:01 +00:00
|
|
|
|
gulong nitems;
|
|
|
|
|
gulong bytes_after;
|
|
|
|
|
guchar *data;
|
|
|
|
|
|
2020-02-23 00:33:56 +00:00
|
|
|
|
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, name))
|
2013-08-24 04:51:01 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
XGetWindowProperty (x11_screen->xdisplay,
|
|
|
|
|
x11_screen->xroot_window,
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_get_xatom_by_name_for_display (GDK_SCREEN_DISPLAY (x11_screen), name),
|
2013-08-24 04:51:01 +00:00
|
|
|
|
0, G_MAXLONG,
|
|
|
|
|
False, XA_CARDINAL, &type, &format, &nitems,
|
|
|
|
|
&bytes_after, &data);
|
|
|
|
|
if (type == XA_CARDINAL)
|
|
|
|
|
{
|
|
|
|
|
prop = *(gulong *)data;
|
|
|
|
|
XFree (data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_x11_screen_get_number_of_desktops:
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* @screen: a #GdkX11Screen
|
2013-08-24 04:51:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the number of workspaces for @screen when running under a
|
|
|
|
|
* window manager that supports multiple workspaces, as described
|
2014-02-03 21:56:15 +00:00
|
|
|
|
* in the
|
|
|
|
|
* [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
|
2013-08-24 04:51:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the number of workspaces, or 0 if workspaces are not supported
|
|
|
|
|
*/
|
|
|
|
|
guint32
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_number_of_desktops (GdkX11Screen *screen)
|
2013-08-24 04:51:01 +00:00
|
|
|
|
{
|
|
|
|
|
return get_netwm_cardinal_property (screen, "_NET_NUMBER_OF_DESKTOPS");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_x11_screen_get_current_desktop:
|
2017-11-17 15:37:52 +00:00
|
|
|
|
* @screen: a #GdkX11Screen
|
2013-08-24 04:51:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the current workspace for @screen when running under a
|
|
|
|
|
* window manager that supports multiple workspaces, as described
|
2014-02-03 21:56:15 +00:00
|
|
|
|
* in the
|
|
|
|
|
* [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec) specification.
|
2013-08-24 04:51:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the current workspace, or 0 if workspaces are not supported
|
|
|
|
|
*/
|
|
|
|
|
guint32
|
2017-11-17 15:18:20 +00:00
|
|
|
|
gdk_x11_screen_get_current_desktop (GdkX11Screen *screen)
|
2013-08-24 04:51:01 +00:00
|
|
|
|
{
|
|
|
|
|
return get_netwm_cardinal_property (screen, "_NET_CURRENT_DESKTOP");
|
|
|
|
|
}
|