2002-04-25 22:29:14 +00:00
|
|
|
|
/*
|
|
|
|
|
* gdkscreen.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2001 Sun Microsystems Inc.
|
|
|
|
|
*
|
|
|
|
|
* Erwann Chenede <erwann.chenede@sun.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2002-04-25 22:29:14 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
|
|
2012-10-05 14:46:36 +00:00
|
|
|
|
#include "gdkinternals.h"
|
2010-12-11 05:14:53 +00:00
|
|
|
|
#include "gdkscreenprivate.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
|
#include "gdkrectangle.h"
|
|
|
|
|
#include "gdkwindow.h"
|
2005-08-26 18:49:52 +00:00
|
|
|
|
#include "gdkintl.h"
|
2010-07-09 00:34:45 +00:00
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
2010-11-15 02:51:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gdkscreen
|
|
|
|
|
* @Short_description: Object representing a physical screen
|
|
|
|
|
* @Title: GdkScreen
|
|
|
|
|
*
|
2011-02-09 06:32:24 +00:00
|
|
|
|
* #GdkScreen objects are the GDK representation of the screen on
|
|
|
|
|
* which windows can be displayed and on which the pointer moves.
|
|
|
|
|
* X originally identified screens with physical screens, but
|
|
|
|
|
* nowadays it is more common to have a single #GdkScreen which
|
|
|
|
|
* combines several physical monitors (see gdk_screen_get_n_monitors()).
|
2010-11-15 02:51:30 +00:00
|
|
|
|
*
|
2011-02-09 06:32:24 +00:00
|
|
|
|
* GdkScreen is used throughout GDK and GTK+ to specify which screen
|
2016-11-03 23:02:37 +00:00
|
|
|
|
* the top level windows are to be displayed on.
|
2010-11-15 02:51:30 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2005-08-26 18:49:52 +00:00
|
|
|
|
static void gdk_screen_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gdk_screen_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_RESOLUTION
|
|
|
|
|
};
|
2002-10-04 15:58:19 +00:00
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
SIZE_CHANGED,
|
2007-12-13 18:27:05 +00:00
|
|
|
|
MONITORS_CHANGED,
|
2002-10-04 15:58:19 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2006-05-14 03:58:06 +00:00
|
|
|
|
G_DEFINE_TYPE (GdkScreen, gdk_screen, G_TYPE_OBJECT)
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
2002-10-04 16:08:19 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_screen_class_init (GdkScreenClass *klass)
|
2002-10-04 15:58:19 +00:00
|
|
|
|
{
|
2004-02-18 00:59:14 +00:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2005-08-26 18:49:52 +00:00
|
|
|
|
object_class->set_property = gdk_screen_set_property;
|
|
|
|
|
object_class->get_property = gdk_screen_get_property;
|
2016-04-02 14:18:16 +00:00
|
|
|
|
|
2005-08-26 18:49:52 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_RESOLUTION,
|
|
|
|
|
g_param_spec_double ("resolution",
|
|
|
|
|
P_("Font resolution"),
|
|
|
|
|
P_("The resolution for fonts on the screen"),
|
2014-07-04 06:01:53 +00:00
|
|
|
|
-1.0,
|
|
|
|
|
10000.0,
|
2005-08-26 18:49:52 +00:00
|
|
|
|
-1.0,
|
2005-09-01 05:11:46 +00:00
|
|
|
|
G_PARAM_READWRITE|G_PARAM_STATIC_NAME|
|
|
|
|
|
G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
|
2005-08-26 18:49:52 +00:00
|
|
|
|
|
2007-12-13 18:27:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* GdkScreen::monitors-changed:
|
|
|
|
|
* @screen: the object on which the signal is emitted
|
|
|
|
|
*
|
2008-08-11 09:15:37 +00:00
|
|
|
|
* The ::monitors-changed signal is emitted when the number, size
|
2007-12-13 18:27:05 +00:00
|
|
|
|
* or position of the monitors attached to the screen change.
|
|
|
|
|
*
|
2009-10-24 10:26:46 +00:00
|
|
|
|
* Only for X11 and OS X for now. A future implementation for Win32
|
|
|
|
|
* may be a possibility.
|
2007-12-13 18:27:05 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.14
|
|
|
|
|
*/
|
|
|
|
|
signals[MONITORS_CHANGED] =
|
2008-08-11 09:15:37 +00:00
|
|
|
|
g_signal_new (g_intern_static_string ("monitors-changed"),
|
2007-12-13 18:27:05 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GdkScreenClass, monitors_changed),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
0);
|
2002-10-04 15:58:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-24 03:29:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_screen_init (GdkScreen *screen)
|
|
|
|
|
{
|
2008-10-21 21:42:39 +00:00
|
|
|
|
screen->resolution = -1.;
|
2005-08-24 03:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
|
void
|
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_screen_close (GdkScreen *screen)
|
2002-04-25 22:29:14 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_SCREEN (screen));
|
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
|
|
|
|
|
|
|
|
|
if (!screen->closed)
|
|
|
|
|
{
|
|
|
|
|
screen->closed = TRUE;
|
|
|
|
|
g_object_run_dispose (G_OBJECT (screen));
|
|
|
|
|
}
|
2002-04-25 22:29:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-24 03:29:06 +00:00
|
|
|
|
/**
|
2005-08-26 18:49:52 +00:00
|
|
|
|
* gdk_screen_set_resolution:
|
2005-08-24 03:29:06 +00:00
|
|
|
|
* @screen: a #GdkScreen
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* @dpi: the resolution in “dots per inch”. (Physical inches aren’t actually
|
2005-08-24 03:29:06 +00:00
|
|
|
|
* involved; the terminology is conventional.)
|
|
|
|
|
|
|
|
|
|
* Sets the resolution for font handling on the screen. This is a
|
|
|
|
|
* scale factor between points specified in a #PangoFontDescription
|
|
|
|
|
* and cairo units. The default value is 96, meaning that a 10 point
|
|
|
|
|
* font will be 13 units high. (10 * 96. / 72. = 13.3).
|
|
|
|
|
*
|
2005-08-26 18:49:52 +00:00
|
|
|
|
* Since: 2.10
|
2005-08-24 03:29:06 +00:00
|
|
|
|
**/
|
|
|
|
|
void
|
2005-08-26 18:49:52 +00:00
|
|
|
|
gdk_screen_set_resolution (GdkScreen *screen,
|
|
|
|
|
gdouble dpi)
|
2005-08-24 03:29:06 +00:00
|
|
|
|
{
|
2008-10-21 21:42:39 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SCREEN (screen));
|
2005-08-24 03:29:06 +00:00
|
|
|
|
|
2014-07-11 20:42:38 +00:00
|
|
|
|
if (dpi < 0)
|
|
|
|
|
dpi = -1.0;
|
|
|
|
|
|
|
|
|
|
screen->resolution_set = TRUE;
|
|
|
|
|
|
|
|
|
|
if (screen->resolution != dpi)
|
|
|
|
|
{
|
|
|
|
|
screen->resolution = dpi;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (screen), "resolution");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Just like gdk_screen_set_resolution(), but doesn't change
|
|
|
|
|
* screen->resolution. This is us to allow us to distinguish
|
|
|
|
|
* resolution changes that the backend picks up from resolution
|
|
|
|
|
* changes made through the public API - perhaps using
|
|
|
|
|
* g_object_set(<GtkSetting>, "gtk-xft-dpi", ...);
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_gdk_screen_set_resolution (GdkScreen *screen,
|
|
|
|
|
gdouble dpi)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_SCREEN (screen));
|
|
|
|
|
|
2008-10-21 21:42:39 +00:00
|
|
|
|
if (dpi < 0)
|
|
|
|
|
dpi = -1.0;
|
2005-08-26 18:49:52 +00:00
|
|
|
|
|
2008-10-21 21:42:39 +00:00
|
|
|
|
if (screen->resolution != dpi)
|
|
|
|
|
{
|
|
|
|
|
screen->resolution = dpi;
|
2005-08-26 18:49:52 +00:00
|
|
|
|
|
2008-10-21 21:42:39 +00:00
|
|
|
|
g_object_notify (G_OBJECT (screen), "resolution");
|
|
|
|
|
}
|
2005-08-24 03:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2005-08-26 18:49:52 +00:00
|
|
|
|
* gdk_screen_get_resolution:
|
2005-08-24 03:29:06 +00:00
|
|
|
|
* @screen: a #GdkScreen
|
|
|
|
|
*
|
|
|
|
|
* Gets the resolution for font handling on the screen; see
|
2005-08-26 18:49:52 +00:00
|
|
|
|
* gdk_screen_set_resolution() for full details.
|
2005-08-24 03:29:06 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the current resolution, or -1 if no resolution
|
2005-08-24 03:29:06 +00:00
|
|
|
|
* has been set.
|
2005-08-26 18:49:52 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
2005-08-24 03:29:06 +00:00
|
|
|
|
**/
|
|
|
|
|
gdouble
|
2005-08-26 18:49:52 +00:00
|
|
|
|
gdk_screen_get_resolution (GdkScreen *screen)
|
2005-08-24 03:29:06 +00:00
|
|
|
|
{
|
2008-10-21 21:42:39 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1.0);
|
2005-08-24 03:29:06 +00:00
|
|
|
|
|
2008-10-21 21:42:39 +00:00
|
|
|
|
return screen->resolution;
|
2005-08-24 03:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-26 18:49:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_screen_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GdkScreen *screen = GDK_SCREEN (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_RESOLUTION:
|
|
|
|
|
g_value_set_double (value, gdk_screen_get_resolution (screen));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_screen_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GdkScreen *screen = GDK_SCREEN (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_RESOLUTION:
|
|
|
|
|
gdk_screen_set_resolution (screen, g_value_get_double (value));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-06 21:05:13 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_screen_get_display:
|
|
|
|
|
* @screen: a #GdkScreen
|
|
|
|
|
*
|
|
|
|
|
* Gets the display to which the @screen belongs.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the display to which @screen belongs
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.2
|
|
|
|
|
**/
|
|
|
|
|
GdkDisplay *
|
|
|
|
|
gdk_screen_get_display (GdkScreen *screen)
|
|
|
|
|
{
|
2012-02-21 16:19:35 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
|
|
|
|
|
|
|
|
|
return GDK_SCREEN_GET_CLASS (screen)->get_display (screen);
|
2010-12-06 21:05:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_screen_get_root_window:
|
|
|
|
|
* @screen: a #GdkScreen
|
|
|
|
|
*
|
|
|
|
|
* Gets the root window of @screen.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the root window
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.2
|
|
|
|
|
**/
|
|
|
|
|
GdkWindow *
|
|
|
|
|
gdk_screen_get_root_window (GdkScreen *screen)
|
|
|
|
|
{
|
2012-02-21 16:19:35 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
|
|
|
|
|
|
|
|
|
return GDK_SCREEN_GET_CLASS (screen)->get_root_window (screen);
|
2010-12-06 21:05:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_screen_get_setting:
|
|
|
|
|
* @screen: the #GdkScreen where the setting is located
|
|
|
|
|
* @name: the name of the setting
|
|
|
|
|
* @value: location to store the value of the setting
|
|
|
|
|
*
|
|
|
|
|
* Retrieves a desktop-wide setting such as double-click time
|
|
|
|
|
* for the #GdkScreen @screen.
|
|
|
|
|
*
|
|
|
|
|
* FIXME needs a list of valid settings here, or a link to
|
|
|
|
|
* more information.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the setting existed and a value was stored
|
|
|
|
|
* in @value, %FALSE otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.2
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_screen_get_setting (GdkScreen *screen,
|
|
|
|
|
const gchar *name,
|
|
|
|
|
GValue *value)
|
|
|
|
|
{
|
2012-02-21 16:19:35 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
|
|
|
|
|
g_return_val_if_fail (name != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
return GDK_SCREEN_GET_CLASS (screen)->get_setting (screen, name, value);
|
2010-12-06 21:05:13 +00:00
|
|
|
|
}
|