gtk2/gdk/x11/gdkscreen-x11.c

1360 lines
39 KiB
C
Raw Normal View History

/*
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
* gdkscreen-x11.c
*
* Copyright 2001 Sun Microsystems Inc.
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
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/>.
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
*/
#include "config.h"
#include "gdkscreen-x11.h"
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
#include "gdkdisplay-x11.h"
#include "gdkprivate-x11.h"
#include "xsettings-client.h"
2016-04-03 04:12:39 +00:00
#include "gdkmonitor-x11.h"
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
#include <glib.h>
#include <stdlib.h>
#include <string.h>
Applied patch from maemo-gtk that addresses many issues wrt display 2005-11-10 Michael Natterer <mitch@imendio.com> Applied patch from maemo-gtk that addresses many issues wrt display migration and display closing (bug #85715). * gdk/gdkdisplay.c (gdk_display_dispose): don't just set the default display to NULL when it's closed. Instead set the most recently opened display as new default (if one exists). * gdk/gdkpango.c (on_renderer_display_closed): fixed signature of this callback. * gdk/gdkscreen.c (gdk_screen_dispose): check if the GCs still exist before unrefing them. * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): if the screen is closed, allow destruction of the root window. * gdk/x11/gdkdisplay-x11.c: moved some stuff from finalize() to dispose(), free stuff that was leaked before. * gdk/x11/gdkevents-x11.c (_gdk_x11_events_uninit_screen): check if the xsettings_client still exists before destroying it. * gdk/x11/gdkkeys-x11.c: added finalization and free the allocated X resources. * gdk/x11/gdkpixmap-x11.c: moved stuff from finalize() to new dispose() implementation. * gdk/x11/gdkscreen-x11.c: moved stuff from finalize() to dispose() and check if it still exists before unrefing it. Set their pointers to NULL/None *after* upchaining in dispose(), because X11 implementations of members of the parent class still need them for their own destruction. * gdk/x11/gdkvisual-x11.c: removed finalize() implementation which was g_error()ing when finalizing a visual. * gtk/gtkclipboard.c (gtk_clipboard_finalize): don't use get_clipboard_widget() because it would create the widget if it doesn't exist. Use g_object_get_data() directly instead. * gtk/gtktextdisplay.c (on_renderer_display_closed): fixed signature of this callback.
2005-11-10 12:09:42 +00:00
#include <X11/Xatom.h>
#ifdef HAVE_XFREE_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#ifdef HAVE_RANDR
#include <X11/extensions/Xrandr.h>
#endif
Create 'composited' label. Tue Apr 25 10:25:28 2006 Søren Sandmann <sandmann@redhat.com> * tests/testgtk.c (create_alpha_window): Create 'composited' label. * tests/testgtk.c (on_composited_changed): New function, change the label to say whether the screen is composited or not. * gtk/gtkwindow.c (gtk_window_on_composited_changed): When composited status change, invalidate the window and propagate the signal;. * gtk/gtkwindow.c (gtk_window_map): Set the appropriate type hint if reset_type_hint is TRUE. * gtk/gtkwindow.c (gtk_window_set_type_hint): If hint is one of the old hints, store a shadow copy in the public window->type_hint bitfield, otherwise set this field to normal. Set the private field to the type hint. * gtk/gtkwindow.c (gtk_window_init): Initialize priv->type_hint. * gtk/gtkwindow.c (struct _GtkWindowPrivate): New field "reset_type_hint" indicating whether the type hint needs to be reset. New field type_hint containing a GdkWindowTypeHint. * gtk/gtkwidget.c (propagate_composited_changed): New function to propagate changes in composited status. (gtk_widget_class_init): Add composited_changed signal. * gtk/gtkwidget.h (struct _GtkWidgetClass): New signal composited-changed. * gtk/gtkwidget.c (gtk_widget_is_composited): New function. * gtk/gtktooltips.c (gtk_tooltips_draw_tips): Set transient for. * gtk/gtktooltips.c (gtk_tooltips_force_window): Set the type hint * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Compute whether the item belongs to a menubar. Set the type_hint appropriately depending on the outcome. * gtk/gtkmenu.c (gtk_menu_position): Set the default type hint here. * gtk/gtkmenu.c (gtk_menu_attach_to_widget): connect to hierarchy changed on the attach widget. * gtk/gtkmenu.c (attach_widget_hierarchy_changed): New function to set the transient_for property for menus. * gtk/gtkdnd.c (set_icon_stock_pixbuf): Set the appropriate type hint. * gtk/gtkcombo.c (gtk_combo_popup_list): Make the popup window transient for the toplevel. * gtk/gtkcombobox.c (gtk_combo_box_set_popup_widget): Set transient-for, for the popup window. * gdk/x11/gdkwindow-x11.c (gdk_window_get_type_hint): Support for new window types. * gdk/x11/gdkwindow-x11.c (gdk_window_set_type_hint): Add support for new window types. * gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_process_owner_change): New function called whenever the compositing manager comes and goes. * gdk/x11/gdkscreen-x11.c (gdk_screen_is_composited): New function. * gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_request_cm_notification, make_cm_atom, check_is_composited): New functions * gdk/x11/gdkevents-x11.c (gdk_event_translate): Call _gdk_x11_screen_process_owner_change when an XFixesSelectionNotifyEvent is received. * gdk/x11/gdkdisplay-x11.c (gdk_display_open): Call _gdk_x11_screen_request_cm_notification() on all screens. * gdk/quartz/gdkscreen-quartz.c (gdk_screen_is_composited): Dummy implementation. * gdk/gdkscreen.c (gdk_screen_class_init): New signal, 'composited-changed'. * gdk/gdkwindow.h: Add new EWMH window types. * gdk/win32/gdkscreen-win32.c (gdk_screen_is_composited)
2006-04-25 14:27:32 +00:00
#ifdef HAVE_XFIXES
#include <X11/extensions/Xfixes.h>
#endif
static void gdk_x11_screen_dispose (GObject *object);
static void gdk_x11_screen_finalize (GObject *object);
static void init_randr_support (GdkScreen *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
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
static guint signals[LAST_SIGNAL] = { 0 };
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
2010-12-21 01:40:45 +00:00
G_DEFINE_TYPE (GdkX11Screen, gdk_x11_screen, GDK_TYPE_SCREEN)
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
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;
};
static void
2010-12-21 01:40:45 +00:00
gdk_x11_screen_init (GdkX11Screen *screen)
{
}
static GdkDisplay *
gdk_x11_screen_get_display (GdkScreen *screen)
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
{
return GDK_X11_SCREEN (screen)->display;
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
}
GdkWindow *
gdk_x11_screen_get_root_window (GdkScreen *screen)
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
{
return GDK_X11_SCREEN (screen)->root_window;
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
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
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
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (object);
int i;
for (i = 0; i < 32; ++i)
{
if (x11_screen->subwindow_gcs[i])
{
XFreeGC (x11_screen->xdisplay, x11_screen->subwindow_gcs[i]);
x11_screen->subwindow_gcs[i] = 0;
}
}
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
_gdk_x11_xsettings_finish (x11_screen);
if (x11_screen->root_window)
_gdk_window_destroy (x11_screen->root_window, TRUE);
Applied patch from maemo-gtk that addresses many issues wrt display 2005-11-10 Michael Natterer <mitch@imendio.com> Applied patch from maemo-gtk that addresses many issues wrt display migration and display closing (bug #85715). * gdk/gdkdisplay.c (gdk_display_dispose): don't just set the default display to NULL when it's closed. Instead set the most recently opened display as new default (if one exists). * gdk/gdkpango.c (on_renderer_display_closed): fixed signature of this callback. * gdk/gdkscreen.c (gdk_screen_dispose): check if the GCs still exist before unrefing them. * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): if the screen is closed, allow destruction of the root window. * gdk/x11/gdkdisplay-x11.c: moved some stuff from finalize() to dispose(), free stuff that was leaked before. * gdk/x11/gdkevents-x11.c (_gdk_x11_events_uninit_screen): check if the xsettings_client still exists before destroying it. * gdk/x11/gdkkeys-x11.c: added finalization and free the allocated X resources. * gdk/x11/gdkpixmap-x11.c: moved stuff from finalize() to new dispose() implementation. * gdk/x11/gdkscreen-x11.c: moved stuff from finalize() to dispose() and check if it still exists before unrefing it. Set their pointers to NULL/None *after* upchaining in dispose(), because X11 implementations of members of the parent class still need them for their own destruction. * gdk/x11/gdkvisual-x11.c: removed finalize() implementation which was g_error()ing when finalizing a visual. * gtk/gtkclipboard.c (gtk_clipboard_finalize): don't use get_clipboard_widget() because it would create the widget if it doesn't exist. Use g_object_get_data() directly instead. * gtk/gtktextdisplay.c (on_renderer_display_closed): fixed signature of this callback.
2005-11-10 12:09:42 +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
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
}
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
static void
gdk_x11_screen_finalize (GObject *object)
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (object);
Applied patch from maemo-gtk that addresses many issues wrt display 2005-11-10 Michael Natterer <mitch@imendio.com> Applied patch from maemo-gtk that addresses many issues wrt display migration and display closing (bug #85715). * gdk/gdkdisplay.c (gdk_display_dispose): don't just set the default display to NULL when it's closed. Instead set the most recently opened display as new default (if one exists). * gdk/gdkpango.c (on_renderer_display_closed): fixed signature of this callback. * gdk/gdkscreen.c (gdk_screen_dispose): check if the GCs still exist before unrefing them. * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): if the screen is closed, allow destruction of the root window. * gdk/x11/gdkdisplay-x11.c: moved some stuff from finalize() to dispose(), free stuff that was leaked before. * gdk/x11/gdkevents-x11.c (_gdk_x11_events_uninit_screen): check if the xsettings_client still exists before destroying it. * gdk/x11/gdkkeys-x11.c: added finalization and free the allocated X resources. * gdk/x11/gdkpixmap-x11.c: moved stuff from finalize() to new dispose() implementation. * gdk/x11/gdkscreen-x11.c: moved stuff from finalize() to dispose() and check if it still exists before unrefing it. Set their pointers to NULL/None *after* upchaining in dispose(), because X11 implementations of members of the parent class still need them for their own destruction. * gdk/x11/gdkvisual-x11.c: removed finalize() implementation which was g_error()ing when finalizing a visual. * gtk/gtkclipboard.c (gtk_clipboard_finalize): don't use get_clipboard_widget() because it would create the widget if it doesn't exist. Use g_object_get_data() directly instead. * gtk/gtktextdisplay.c (on_renderer_display_closed): fixed signature of this callback.
2005-11-10 12:09:42 +00:00
gint i;
if (x11_screen->root_window)
g_object_unref (x11_screen->root_window);
Add GdkPangoRenderer, a subclass of PangoRenderer targeting GDK drawables. Sat Nov 20 15:13:51 2004 Owen Taylor <otaylor@redhat.com> * gdk/gdkpango.[ch]: Add GdkPangoRenderer, a subclass of PangoRenderer targeting GDK drawables. Use to implement the old gdk_draw_layout() and friends. * gdk/gdkdraw.c gdk/gdkdrawable.h gdk/gdkwindow.c gdk/gdkpixmap.c: Add gdk_draw_glyphs_transformed() gdk_draw_trapezoids() and the corresponding members of GdkDrawableClass. Add a fallback implementation of gdk_draw_trapezoids() in terms of pixbufs. * gdk/gdkwindowing.h gdk/x11/gdkg-x11.h: Add _gdk_windowing_gc_get_foreground() to enable the fallback trapezoid implementation. * gdk/x11/gdkdrawable-x11.c gdk/x11/gdkdisplay-x11.h: Implement draw_glyph_transformed, draw_trapezoids. * gdk/x11/gdkdrawable-x11.[ch]: Add _gdk_x11_drawable_draw_xtrapezoids, _gdk_x11_drawable_draw_xft_glyphs for use of GdkX11Renderer. * gdk/x11/gdkgc-x11.c gdk/x11/gdkprivate-x11.h: Implement GDK_TILED, GDK_STIPPLED, GDK_OPAQUE_STIPPLED in the RENDER codepath. * gdk/gdkpango-x11.c: Add GdkX11Renderer... a subclass of PangoXftRenderer that does tiles/stipples and fallback rendering of trapezoids without the RENDER extension. * gdk/gdkpango-x11.c gdk/x11/gdkscreen-x11.[ch] _gdk_x11_renderer_get: Add _gdk_x11_renderer_get() to get a singleton GdkX11Renderer for the screen. * gdk/x11/gdkdrawable-x11.c (get_impl_drawable): Fix a None/NULL confusion. * gtk/gtklabel.[ch] gtk/gtk.symbols: Add gtk_label_set/get_angle(), and an ::angle property. * gtk/gtklabel.c: Remove #if 0'd dead code gtk_label_paint_word(). * gtk/gtktextdisplay.c: Switch to using a GtkTextRenderer subclass of GdkPangoRenderer for drawing. * gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Switch to using gtk_attr_shape_new_with_data() to store backreferences to embedded pixmaps and widgets. Leave line_display->shaped_objects around for backwords compatibility. * gdk/gdkpango.[ch] (gdk_pango_context_set_colormap): Describe as deprecated, remove implementation. * gtk/gtkwidget.c (gtk_widget_create_pango_context): Remove call to gdk_pango_context_set_colormap. * demos/gtk-demo/Makefile.am demos/gtk-demo/rotated_text.c: Add a demo showing drawing rotated text. * tests/testgtk.c: Add a rotated-label test, and also a rotated drawing test (differs from demos/gtk-demo/rotated_text by also using a tile)
2004-11-21 16:24:01 +00:00
Applied patch from maemo-gtk that addresses many issues wrt display 2005-11-10 Michael Natterer <mitch@imendio.com> Applied patch from maemo-gtk that addresses many issues wrt display migration and display closing (bug #85715). * gdk/gdkdisplay.c (gdk_display_dispose): don't just set the default display to NULL when it's closed. Instead set the most recently opened display as new default (if one exists). * gdk/gdkpango.c (on_renderer_display_closed): fixed signature of this callback. * gdk/gdkscreen.c (gdk_screen_dispose): check if the GCs still exist before unrefing them. * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): if the screen is closed, allow destruction of the root window. * gdk/x11/gdkdisplay-x11.c: moved some stuff from finalize() to dispose(), free stuff that was leaked before. * gdk/x11/gdkevents-x11.c (_gdk_x11_events_uninit_screen): check if the xsettings_client still exists before destroying it. * gdk/x11/gdkkeys-x11.c: added finalization and free the allocated X resources. * gdk/x11/gdkpixmap-x11.c: moved stuff from finalize() to new dispose() implementation. * gdk/x11/gdkscreen-x11.c: moved stuff from finalize() to dispose() and check if it still exists before unrefing it. Set their pointers to NULL/None *after* upchaining in dispose(), because X11 implementations of members of the parent class still need them for their own destruction. * gdk/x11/gdkvisual-x11.c: removed finalize() implementation which was g_error()ing when finalizing a visual. * gtk/gtkclipboard.c (gtk_clipboard_finalize): don't use get_clipboard_widget() because it would create the widget if it doesn't exist. Use g_object_get_data() directly instead. * gtk/gtktextdisplay.c (on_renderer_display_closed): fixed signature of this callback.
2005-11-10 12:09:42 +00:00
/* Visual Part */
for (i = 0; i < x11_screen->nvisuals; i++)
g_object_unref (x11_screen->visuals[i]);
g_free (x11_screen->visuals);
g_free (x11_screen->window_manager_name);
2010-12-21 01:40:45 +00:00
G_OBJECT_CLASS (gdk_x11_screen_parent_class)->finalize (object);
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
}
/**
* gdk_x11_screen_get_monitor_output:
* @screen: (type GdkX11Screen): a #GdkScreen
* @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
*
* Gets the XID of the specified output/monitor.
* If the X server does not support version 1.2 of the RANDR
* extension, 0 is returned.
*
* Returns: the XID of the monitor
*
* Since: 2.14
*/
XID
gdk_x11_screen_get_monitor_output (GdkScreen *screen,
gint monitor_num)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
2016-04-03 04:12:39 +00:00
GdkX11Display *x11_display = GDK_X11_DISPLAY (x11_screen->display);
GdkX11Monitor *monitor;
g_return_val_if_fail (GDK_IS_SCREEN (screen), None);
g_return_val_if_fail (monitor_num >= 0, None);
2016-04-03 04:12:39 +00:00
g_return_val_if_fail (monitor_num < x11_display->monitors->len, None);
2016-04-03 04:12:39 +00:00
monitor = x11_display->monitors->pdata[monitor_num];
return monitor->output;
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
}
static int
get_current_desktop (GdkScreen *screen)
{
Display *display;
Window win;
Atom current_desktop, type;
int format;
unsigned long n_items, bytes_after;
unsigned char *data_return = NULL;
int workspace = 0;
if (!gdk_x11_screen_supports_net_wm_hint (screen,
gdk_atom_intern_static_string ("_NET_CURRENT_DESKTOP")))
return workspace;
display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
2017-11-01 19:51:14 +00:00
win = XRootWindow (display, gdk_x11_screen_get_screen_number (screen));
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)
workspace = ((long *) data_return)[0];
if (data_return)
XFree (data_return);
return workspace;
}
2016-04-03 04:12:39 +00:00
void
gdk_x11_screen_get_work_area (GdkScreen *screen,
GdkRectangle *area)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
GdkWindow *root_window;
Atom workarea;
Atom type;
Window win;
int format;
gulong num;
gulong leftovers;
gulong max_len = 4 * 32;
guchar *ret_workarea = NULL;
long *workareas;
int result;
int desktop;
Display *display;
display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
root_window = gdk_display_get_root_window (gdk_screen_get_display (screen));
workarea = XInternAtom (display, "_NET_WORKAREA", True);
/* Defaults in case of error */
area->x = 0;
area->y = 0;
area->width = gdk_window_get_width (root_window);
area->height = gdk_window_get_height (root_window);
if (!gdk_x11_screen_supports_net_wm_hint (screen,
gdk_atom_intern_static_string ("_NET_WORKAREA")))
return;
if (workarea == None)
return;
2017-11-01 19:51:14 +00:00
win = XRootWindow (display, gdk_x11_screen_get_screen_number (screen));
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)
goto out;
desktop = get_current_desktop (screen);
if (desktop + 1 > num / 4) /* fvwm gets this wrong */
goto out;
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];
area->x /= x11_screen->window_scale;
area->y /= x11_screen->window_scale;
area->width /= x11_screen->window_scale;
area->height /= x11_screen->window_scale;
out:
if (ret_workarea)
XFree (ret_workarea);
}
2002-05-02 22:28:50 +00:00
/**
* gdk_x11_screen_get_xscreen:
2011-12-16 04:08:07 +00:00
* @screen: (type GdkX11Screen): a #GdkScreen
2002-05-02 22:28:50 +00:00
*
* Returns the screen of a #GdkScreen.
2002-11-28 00:33:17 +00:00
*
* Returns: (transfer none): an Xlib Screen*
2011-12-16 04:08:07 +00:00
*
2002-11-28 00:33:17 +00:00
* Since: 2.2
2002-05-02 22:28:50 +00:00
*/
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
Screen *
gdk_x11_screen_get_xscreen (GdkScreen *screen)
{
return GDK_X11_SCREEN (screen)->xscreen;
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
}
2002-05-02 22:28:50 +00:00
/**
* gdk_x11_screen_get_screen_number:
2011-12-16 04:08:07 +00:00
* @screen: (type GdkX11Screen): a #GdkScreen
2002-05-02 22:28:50 +00:00
*
* Returns the index of a #GdkScreen.
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-11-28 00:33:17 +00:00
* Since: 2.2
2002-05-02 22:28:50 +00:00
*/
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
int
gdk_x11_screen_get_screen_number (GdkScreen *screen)
{
return GDK_X11_SCREEN (screen)->screen_num;
Start of integration of Erwann Chenede's multihead work from the Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
2002-04-25 22:29:14 +00:00
}
2016-04-03 04:12:39 +00:00
static GdkX11Monitor *
find_monitor_by_output (GdkX11Display *x11_display, XID output)
{
int i;
2016-04-03 04:12:39 +00:00
for (i = 0; i < x11_display->monitors->len; i++)
{
2016-04-03 04:12:39 +00:00
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
if (monitor->output == output)
return monitor;
}
2016-04-03 04:12:39 +00:00
return NULL;
}
2016-04-03 04:12:39 +00:00
static GdkSubpixelLayout
translate_subpixel_order (int subpixel)
{
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;
}
}
static gboolean
2016-04-03 04:12:39 +00:00
init_randr15 (GdkScreen *screen, gboolean *changed)
{
#ifdef HAVE_RANDR15
GdkDisplay *display = gdk_screen_get_display (screen);
2016-04-03 04:12:39 +00:00
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
XRRScreenResources *resources;
RROutput primary_output = None;
RROutput first_output = None;
int i;
XRRMonitorInfo *rr_monitors;
int num_rr_monitors;
2016-04-03 04:12:39 +00:00
int old_primary;
2016-04-03 04:12:39 +00:00
if (!x11_display->have_randr15)
return FALSE;
resources = XRRGetScreenResourcesCurrent (x11_screen->xdisplay,
x11_screen->xroot_window);
if (!resources)
return FALSE;
rr_monitors = XRRGetMonitors (x11_screen->xdisplay,
x11_screen->xroot_window,
True,
&num_rr_monitors);
if (!rr_monitors)
return FALSE;
2016-04-03 04:12:39 +00:00
for (i = 0; i < x11_display->monitors->len; i++)
{
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
monitor->add = FALSE;
monitor->remove = TRUE;
}
for (i = 0; i < num_rr_monitors; i++)
{
RROutput output = rr_monitors[i].outputs[0];
XRROutputInfo *output_info;
2016-04-03 04:12:39 +00:00
GdkX11Monitor *monitor;
GdkRectangle geometry;
GdkRectangle newgeo;
char *name;
int refresh_rate = 0;
gdk_x11_display_error_trap_push (display);
output_info = XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
if (gdk_x11_display_error_trap_pop (display))
continue;
if (output_info == NULL)
continue;
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)
{
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;
g_ptr_array_add (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);
newgeo.x = rr_monitors[i].x / x11_screen->window_scale;
newgeo.y = rr_monitors[i].y / x11_screen->window_scale;
newgeo.width = rr_monitors[i].width / x11_screen->window_scale;
newgeo.height = rr_monitors[i].height / x11_screen->window_scale;
if (newgeo.x != geometry.x ||
newgeo.y != geometry.y ||
newgeo.width != geometry.width ||
newgeo.height != geometry.height ||
rr_monitors[i].mwidth != gdk_monitor_get_width_mm (GDK_MONITOR (monitor)) ||
rr_monitors[i].mheight != gdk_monitor_get_height_mm (GDK_MONITOR (monitor)) ||
g_strcmp0 (name, gdk_monitor_get_model (GDK_MONITOR (monitor))))
*changed = TRUE;
gdk_monitor_set_position (GDK_MONITOR (monitor), newgeo.x, newgeo.y);
gdk_monitor_set_size (GDK_MONITOR (monitor), newgeo.width, newgeo.height);
g_object_notify (G_OBJECT (monitor), "workarea");
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);
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->window_scale);
gdk_monitor_set_model (GDK_MONITOR (monitor), name);
g_free (name);
if (rr_monitors[i].primary)
2016-04-03 04:12:39 +00:00
primary_output = monitor->output;
XRRFreeOutputInfo (output_info);
}
XRRFreeMonitors (rr_monitors);
XRRFreeScreenResources (resources);
2016-04-03 04:12:39 +00:00
for (i = x11_display->monitors->len - 1; i >= 0; i--)
{
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
if (monitor->add)
{
gdk_display_monitor_added (display, GDK_MONITOR (monitor));
*changed = TRUE;
}
else if (monitor->remove)
{
g_object_ref (monitor);
g_ptr_array_remove (x11_display->monitors, monitor);
gdk_display_monitor_removed (display, GDK_MONITOR (monitor));
g_object_unref (monitor);
*changed = TRUE;
}
}
2016-04-03 04:12:39 +00:00
old_primary = x11_display->primary_monitor;
x11_display->primary_monitor = 0;
for (i = 0; i < x11_display->monitors->len; ++i)
{
2016-04-03 04:12:39 +00:00
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
if (monitor->output == primary_output)
{
2016-04-03 04:12:39 +00:00
x11_display->primary_monitor = i;
break;
}
/* 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-04-03 04:12:39 +00:00
x11_display->primary_monitor = i;
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;
}
2016-04-03 04:12:39 +00:00
if (x11_display->primary_monitor != old_primary)
*changed = TRUE;
return x11_display->monitors->len > 0;
#endif
return FALSE;
}
static gboolean
2016-04-03 04:12:39 +00:00
init_randr13 (GdkScreen *screen, gboolean *changed)
{
#ifdef HAVE_RANDR
GdkDisplay *display = gdk_screen_get_display (screen);
2016-04-03 04:12:39 +00:00
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
XRRScreenResources *resources;
RROutput primary_output = None;
RROutput first_output = None;
int i;
2016-04-03 04:12:39 +00:00
int old_primary;
2016-04-03 04:12:39 +00:00
if (!x11_display->have_randr13)
return FALSE;
resources = XRRGetScreenResourcesCurrent (x11_screen->xdisplay,
x11_screen->xroot_window);
if (!resources)
return FALSE;
2016-04-03 04:12:39 +00:00
for (i = 0; i < x11_display->monitors->len; i++)
{
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
monitor->add = FALSE;
monitor->remove = TRUE;
}
for (i = 0; i < resources->noutput; ++i)
{
RROutput output = resources->outputs[i];
XRROutputInfo *output_info =
XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
if (output_info->connection == RR_Disconnected)
2009-05-30 04:05:35 +00:00
{
XRRFreeOutputInfo (output_info);
2009-05-30 04:05:35 +00:00
continue;
}
if (output_info->crtc)
{
2016-04-03 04:12:39 +00:00
GdkX11Monitor *monitor;
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;
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)
{
refresh_rate = (1000 * xmode->dotClock) / (xmode->hTotal *xmode->vTotal);
break;
}
}
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;
g_ptr_array_add (x11_display->monitors, monitor);
}
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
name = g_strndup (output_info->name, output_info->nameLen);
newgeo.x = crtc->x / x11_screen->window_scale;
newgeo.y = crtc->y / x11_screen->window_scale;
newgeo.width = crtc->width / x11_screen->window_scale;
newgeo.height = crtc->height / x11_screen->window_scale;
if (newgeo.x != geometry.x ||
newgeo.y != geometry.y ||
newgeo.width != geometry.width ||
newgeo.height != geometry.height ||
output_info->mm_width != gdk_monitor_get_width_mm (GDK_MONITOR (monitor)) ||
output_info->mm_height != gdk_monitor_get_height_mm (GDK_MONITOR (monitor)) ||
g_strcmp0 (name, gdk_monitor_get_model (GDK_MONITOR (monitor))) != 0)
*changed = TRUE;
gdk_monitor_set_position (GDK_MONITOR (monitor), newgeo.x, newgeo.y);
gdk_monitor_set_size (GDK_MONITOR (monitor), newgeo.width, newgeo.height);
g_object_notify (G_OBJECT (monitor), "workarea");
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);
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->window_scale);
gdk_monitor_set_model (GDK_MONITOR (monitor), name);
g_free (name);
XRRFreeCrtcInfo (crtc);
}
XRRFreeOutputInfo (output_info);
}
if (resources->noutput > 0)
first_output = resources->outputs[0];
XRRFreeScreenResources (resources);
/* Which usable multihead data is not returned in non RandR 1.2+ X driver? */
2016-04-03 04:12:39 +00:00
for (i = x11_display->monitors->len - 1; i >= 0; i--)
{
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
if (monitor->add)
{
gdk_display_monitor_added (display, GDK_MONITOR (monitor));
*changed = TRUE;
}
else if (monitor->remove)
{
g_object_ref (monitor);
g_ptr_array_remove (x11_display->monitors, monitor);
gdk_display_monitor_removed (display, GDK_MONITOR (monitor));
g_object_unref (monitor);
*changed = TRUE;
}
}
2016-04-03 04:12:39 +00:00
old_primary = x11_display->primary_monitor;
x11_display->primary_monitor = 0;
primary_output = XRRGetOutputPrimary (x11_screen->xdisplay,
x11_screen->xroot_window);
2016-04-03 04:12:39 +00:00
for (i = 0; i < x11_display->monitors->len; ++i)
{
2016-04-03 04:12:39 +00:00
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
if (monitor->output == primary_output)
{
2016-04-03 04:12:39 +00:00
x11_display->primary_monitor = i;
break;
}
/* 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-04-03 04:12:39 +00:00
x11_display->primary_monitor = i;
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;
}
2016-04-03 04:12:39 +00:00
if (x11_display->primary_monitor != old_primary)
*changed = TRUE;
return x11_display->monitors->len > 0;
#endif
return FALSE;
}
2016-04-03 04:12:39 +00:00
static void
init_no_multihead (GdkScreen *screen, gboolean *changed)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
2016-04-03 04:12:39 +00:00
GdkX11Display *x11_display = GDK_X11_DISPLAY (x11_screen->display);
GdkX11Monitor *monitor;
GdkRectangle geometry;
int width_mm, height_mm;
int width, height;
2016-04-03 04:12:39 +00:00
int i;
2016-04-03 04:12:39 +00:00
for (i = 0; i < x11_display->monitors->len; i++)
{
2016-04-03 04:12:39 +00:00
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
monitor->add = FALSE;
monitor->remove = TRUE;
}
2016-04-03 04:12:39 +00:00
monitor = find_monitor_by_output (x11_display, 0);
if (monitor)
monitor->remove = FALSE;
else
{
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;
g_ptr_array_add (x11_display->monitors, monitor);
}
width_mm = WidthMMOfScreen (x11_screen->xscreen);
height_mm = HeightMMOfScreen (x11_screen->xscreen);
width = WidthOfScreen (x11_screen->xscreen);
height = HeightOfScreen (x11_screen->xscreen);
2016-04-03 04:12:39 +00:00
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
if (0 != geometry.x ||
0 != geometry.y ||
width != geometry.width ||
height != geometry.height ||
width_mm != gdk_monitor_get_width_mm (GDK_MONITOR (monitor)) ||
height_mm != gdk_monitor_get_height_mm (GDK_MONITOR (monitor)))
2016-04-03 04:12:39 +00:00
*changed = TRUE;
gdk_monitor_set_position (GDK_MONITOR (monitor), 0, 0);
gdk_monitor_set_size (GDK_MONITOR (monitor), width, height);
2016-04-03 04:12:39 +00:00
g_object_notify (G_OBJECT (monitor), "workarea");
gdk_monitor_set_physical_size (GDK_MONITOR (monitor), width_mm, height_mm);
2016-04-03 04:12:39 +00:00
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->window_scale);
if (x11_display->primary_monitor != 0)
*changed = TRUE;
x11_display->primary_monitor = 0;
for (i = x11_display->monitors->len - 1; i >= 0; i--)
{
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
if (monitor->add)
{
gdk_display_monitor_added (GDK_DISPLAY (x11_display), GDK_MONITOR (monitor));
*changed = TRUE;
}
else if (monitor->remove)
{
g_object_ref (monitor);
g_ptr_array_remove (x11_display->monitors, monitor);
gdk_display_monitor_removed (GDK_DISPLAY (x11_display), GDK_MONITOR (monitor));
g_object_unref (monitor);
*changed = TRUE;
}
}
}
2016-04-03 04:12:39 +00:00
static gboolean
init_multihead (GdkScreen *screen)
{
2016-04-03 04:12:39 +00:00
gboolean any_changed = FALSE;
2016-04-03 04:12:39 +00:00
if (!init_randr15 (screen, &any_changed) &&
!init_randr13 (screen, &any_changed))
init_no_multihead (screen, &any_changed);
2016-04-03 04:12:39 +00:00
return any_changed;
}
GdkScreen *
_gdk_x11_screen_new (GdkDisplay *display,
gint screen_number,
gboolean setup_display)
{
GdkScreen *screen;
GdkX11Screen *x11_screen;
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
const char *scale_str;
screen = g_object_new (GDK_TYPE_X11_SCREEN, NULL);
x11_screen = GDK_X11_SCREEN (screen);
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;
x11_screen->xroot_window = RootWindow (display_x11->xdisplay,screen_number);
x11_screen->wmspec_check_window = None;
/* we want this to be always non-null */
x11_screen->window_manager_name = g_strdup ("unknown");
scale_str = g_getenv ("GDK_SCALE");
if (scale_str)
{
x11_screen->fixed_window_scale = TRUE;
x11_screen->window_scale = atol (scale_str);
if (x11_screen->window_scale == 0)
x11_screen->window_scale = 1;
}
else
x11_screen->window_scale = 1;
init_randr_support (screen);
2016-04-03 04:12:39 +00:00
init_multihead (screen);
_gdk_x11_screen_init_visuals (screen, setup_display);
_gdk_x11_screen_init_root_window (screen);
return screen;
}
void
_gdk_x11_screen_set_window_scale (GdkX11Screen *x11_screen,
2014-07-10 22:35:54 +00:00
gint scale)
{
2016-04-03 04:12:39 +00:00
GdkX11Display *x11_display = GDK_X11_DISPLAY (x11_screen->display);
GList *toplevels, *l;
GdkWindow *root;
2016-04-03 04:12:39 +00:00
int i;
if (x11_screen->window_scale == scale)
return;
x11_screen->window_scale = scale;
root = x11_screen->root_window;
GDK_WINDOW_IMPL_X11 (root->impl)->window_scale = scale;
toplevels = gdk_display_get_toplevel_windows (x11_screen->display);
for (l = toplevels; l != NULL; l = l->next)
{
GdkWindow *window = l->data;
_gdk_x11_window_set_window_scale (window, scale);
}
g_list_free (toplevels);
2016-04-03 04:12:39 +00:00
for (i = 0; i < x11_display->monitors->len; i++)
{
GdkMonitor *monitor = GDK_MONITOR (x11_display->monitors->pdata[i]);
gdk_monitor_set_scale_factor (monitor, scale);
}
}
static void
init_randr_support (GdkScreen *screen)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
/* NB: This is also needed for XSettings, so don't remove. */
XSelectInput (GDK_SCREEN_XDISPLAY (screen),
x11_screen->xroot_window,
StructureNotifyMask);
#ifdef HAVE_RANDR
if (!GDK_X11_DISPLAY (gdk_screen_get_display (screen))->have_randr12)
return;
XRRSelectInput (GDK_SCREEN_XDISPLAY (screen),
x11_screen->xroot_window,
RRScreenChangeNotifyMask
| RRCrtcChangeNotifyMask
| RROutputPropertyNotifyMask);
#endif
}
static void
process_monitors_change (GdkScreen *screen)
{
init_multihead (screen);
}
void
_gdk_x11_screen_size_changed (GdkScreen *screen,
XEvent *event)
{
#ifdef HAVE_RANDR
GdkX11Display *display_x11;
display_x11 = GDK_X11_DISPLAY (gdk_screen_get_display (screen));
if (display_x11->have_randr13 && event->type == ConfigureNotify)
return;
XRRUpdateConfiguration (event);
#else
if (event->type != ConfigureNotify)
return;
#endif
process_monitors_change (screen);
}
2016-04-03 04:12:39 +00:00
void
_gdk_x11_screen_get_edge_monitors (GdkScreen *screen,
gint *top,
gint *bottom,
gint *left,
gint *right)
{
2017-03-23 16:15:00 +00:00
#ifdef HAVE_XFREE_XINERAMA
2016-04-03 04:12:39 +00:00
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
GdkWindow *root_window = gdk_display_get_root_window (gdk_screen_get_display (screen));
gint top_most_pos = gdk_window_get_height (root_window);
gint left_most_pos = gdk_window_get_width (root_window);
2016-04-03 04:12:39 +00:00
gint bottom_most_pos = 0;
gint right_most_pos = 0;
gint i;
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
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
{
if (x_monitors)
XFree (x_monitors);
2016-04-03 04:12:39 +00:00
return;
}
2016-04-03 04:12:39 +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
{
left_most_pos = x_monitors[i].x_org;
2016-04-03 04:12:39 +00:00
*left = i;
}
if (right && right_most_pos < x_monitors[i].x_org + x_monitors[i].width)
2016-04-03 04:12:39 +00:00
{
right_most_pos = x_monitors[i].x_org + x_monitors[i].width;
2016-04-03 04:12:39 +00:00
*right = i;
}
if (top && top_most_pos > x_monitors[i].y_org)
2016-04-03 04:12:39 +00:00
{
top_most_pos = x_monitors[i].y_org;
2016-04-03 04:12:39 +00:00
*top = i;
}
if (bottom && bottom_most_pos < x_monitors[i].y_org + x_monitors[i].height)
2016-04-03 04:12:39 +00:00
{
bottom_most_pos = x_monitors[i].y_org + x_monitors[i].height;
2016-04-03 04:12:39 +00:00
*bottom = i;
}
}
XFree (x_monitors);
#endif
2016-04-03 04:12:39 +00:00
}
void
_gdk_x11_screen_window_manager_changed (GdkScreen *screen)
{
g_signal_emit (screen, signals[WINDOW_MANAGER_CHANGED], 0);
}
gboolean
gdk_x11_screen_get_setting (GdkScreen *screen,
const gchar *name,
GValue *value)
2010-05-25 22:38:44 +00:00
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
const GValue *setting;
2010-05-25 22:38:44 +00:00
if (x11_screen->xsettings == NULL)
goto out;
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;
if (!g_value_transform (setting, value))
2010-05-25 22:38:44 +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
}
return TRUE;
2010-05-25 22:38:44 +00:00
out:
return _gdk_x11_get_xft_setting (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);
}
static Window
get_net_supporting_wm_check (GdkX11Screen *screen,
Window window)
2010-05-25 22:38:44 +00:00
{
GdkDisplay *display;
Atom type;
gint format;
gulong n_items;
gulong bytes_after;
guchar *data;
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
fetch_net_wm_check_window (GdkScreen *screen)
{
GdkX11Screen *x11_screen;
GdkDisplay *display;
Window window;
2010-05-25 22:38:44 +00:00
GTimeVal tv;
gint error;
x11_screen = GDK_X11_SCREEN (screen);
display = x11_screen->display;
2010-05-25 22:38:44 +00:00
g_return_if_fail (GDK_X11_DISPLAY (display)->trusted_client);
if (x11_screen->wmspec_check_window != None)
return; /* already have it */
2010-05-25 22:38:44 +00:00
g_get_current_time (&tv);
if (ABS (tv.tv_sec - x11_screen->last_wmspec_check_time) < 15)
2010-05-25 22:38:44 +00:00
return; /* we've checked recently */
window = get_net_supporting_wm_check (x11_screen, x11_screen->xroot_window);
if (window == None)
return;
2010-05-25 22:38:44 +00:00
if (window != get_net_supporting_wm_check (x11_screen, window))
return;
2010-05-25 22:38:44 +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. */
XSelectInput (x11_screen->xdisplay, window, StructureNotifyMask);
2010-05-25 22:38:44 +00:00
error = gdk_x11_display_error_trap_pop (display);
2010-05-25 22:38:44 +00:00
if (!error)
{
/* 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;
x11_screen->last_wmspec_check_time = tv.tv_sec;
x11_screen->need_refetch_net_supported = TRUE;
x11_screen->need_refetch_wm_name = TRUE;
2010-05-25 22:38:44 +00:00
/* Careful, reentrancy */
_gdk_x11_screen_window_manager_changed (screen);
2010-05-25 22:38:44 +00:00
}
}
/**
* gdk_x11_screen_supports_net_wm_hint:
* @screen: (type GdkX11Screen): the relevant #GdkScreen.
2010-05-25 22:38:44 +00:00
* @property: a property atom.
*
* 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 shouldnt 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.
* You can monitor the window_manager_changed signal on #GdkScreen to detect
* a window manager change.
*
* Returns: %TRUE if the window manager supports @property
2010-05-25 22:38:44 +00:00
*
* Since: 2.2
**/
gboolean
gdk_x11_screen_supports_net_wm_hint (GdkScreen *screen,
GdkAtom property)
{
gulong i;
GdkX11Screen *x11_screen;
2010-05-25 22:38:44 +00:00
NetWmSupportedAtoms *supported_atoms;
GdkDisplay *display;
Atom atom;
2010-05-25 22:38:44 +00:00
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
x11_screen = GDK_X11_SCREEN (screen);
display = x11_screen->display;
2010-05-25 22:38:44 +00:00
if (!G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
2010-05-25 22:38:44 +00:00
return FALSE;
supported_atoms = g_object_get_data (G_OBJECT (screen), "gdk-net-wm-supported-atoms");
if (!supported_atoms)
{
supported_atoms = g_new0 (NetWmSupportedAtoms, 1);
g_object_set_data_full (G_OBJECT (screen), "gdk-net-wm-supported-atoms", supported_atoms, cleanup_atoms);
}
fetch_net_wm_check_window (screen);
if (x11_screen->wmspec_check_window == None)
2010-05-25 22:38:44 +00:00
return FALSE;
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;
gint format;
gulong bytes_after;
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;
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;
atom = gdk_x11_atom_to_xatom_for_display (display, property);
for (i = 0; i < supported_atoms->n_atoms; i++)
2010-05-25 22:38:44 +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:
* @screen: (type GdkX11Screen): a #GdkScreen
2010-05-25 22:38:44 +00:00
*
* Returns the name of the window manager for @screen.
*
* 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.
*
* Since: 2.2
**/
const char*
gdk_x11_screen_get_window_manager_name (GdkScreen *screen)
{
GdkX11Screen *x11_screen;
GdkDisplay *display;
2010-05-25 22:38:44 +00:00
x11_screen = GDK_X11_SCREEN (screen);
display = x11_screen->display;
2010-05-25 22:38:44 +00:00
if (!G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
return x11_screen->window_manager_name;
2010-05-25 22:38:44 +00:00
fetch_net_wm_check_window (screen);
if (x11_screen->need_refetch_wm_name)
2010-05-25 22:38:44 +00:00
{
/* Get the name of the window manager */
x11_screen->need_refetch_wm_name = FALSE;
2010-05-25 22:38:44 +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
if (x11_screen->wmspec_check_window != None)
2010-05-25 22:38:44 +00:00
{
Atom type;
gint format;
gulong n_items;
gulong bytes_after;
gchar *name;
name = NULL;
gdk_x11_display_error_trap_push (display);
2010-05-25 22:38:44 +00:00
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
x11_screen->wmspec_check_window,
gdk_x11_get_xatom_by_name_for_display (display,
2010-05-25 22:38:44 +00:00
"_NET_WM_NAME"),
0, G_MAXLONG, False,
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);
gdk_x11_display_error_trap_pop_ignored (display);
2010-05-25 22:38:44 +00:00
if (name != NULL)
{
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);
}
}
}
return GDK_X11_SCREEN (screen)->window_manager_name;
2010-05-25 22:38:44 +00:00
}
static void
2010-12-21 01:40:45 +00:00
gdk_x11_screen_class_init (GdkX11ScreenClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
object_class->dispose = gdk_x11_screen_dispose;
object_class->finalize = gdk_x11_screen_finalize;
screen_class->get_display = gdk_x11_screen_get_display;
signals[WINDOW_MANAGER_CHANGED] =
g_signal_new (g_intern_static_string ("window-manager-changed"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkX11ScreenClass, window_manager_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
}
static guint32
get_netwm_cardinal_property (GdkScreen *screen,
const gchar *name)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
GdkAtom atom;
guint32 prop = 0;
Atom type;
gint format;
gulong nitems;
gulong bytes_after;
guchar *data;
atom = gdk_atom_intern_static_string (name);
if (!gdk_x11_screen_supports_net_wm_hint (screen, atom))
return 0;
XGetWindowProperty (x11_screen->xdisplay,
x11_screen->xroot_window,
gdk_x11_get_xatom_by_name_for_display (GDK_SCREEN_DISPLAY (screen), name),
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:
* @screen: (type GdkX11Screen): a #GdkScreen
*
* 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.
*
* Returns: the number of workspaces, or 0 if workspaces are not supported
*
* Since: 3.10
*/
guint32
gdk_x11_screen_get_number_of_desktops (GdkScreen *screen)
{
return get_netwm_cardinal_property (screen, "_NET_NUMBER_OF_DESKTOPS");
}
/**
* gdk_x11_screen_get_current_desktop:
* @screen: (type GdkX11Screen): a #GdkScreen
*
* 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.
*
* Returns: the current workspace, or 0 if workspaces are not supported
*
* Since: 3.10
*/
guint32
gdk_x11_screen_get_current_desktop (GdkScreen *screen)
{
return get_netwm_cardinal_property (screen, "_NET_CURRENT_DESKTOP");
}