2016-04-01 03:10:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* gdkmonitor.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2016 Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Matthias Clasen <mclasen@redhat.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
|
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include "gdkmonitorprivate.h"
|
|
|
|
|
#include "gdkdisplay.h"
|
|
|
|
|
#include "gdkenumtypes.h"
|
|
|
|
|
|
2017-12-26 16:19:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* GdkMonitor:
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* `GdkMonitor` objects represent the individual outputs that are
|
|
|
|
|
* associated with a `GdkDisplay`.
|
|
|
|
|
*
|
|
|
|
|
* `GdkDisplay` keeps a `GListModel` to enumerate and monitor
|
|
|
|
|
* monitors with [method@Gdk.Display.get_monitors]. You can use
|
|
|
|
|
* [method@Gdk.Display.get_monitor_at_surface] to find a particular
|
|
|
|
|
* monitor.
|
2017-12-26 16:19:24 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2016-04-01 03:10:04 +00:00
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_DISPLAY,
|
|
|
|
|
PROP_MANUFACTURER,
|
|
|
|
|
PROP_MODEL,
|
2019-06-20 13:52:41 +00:00
|
|
|
|
PROP_CONNECTOR,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
PROP_SCALE_FACTOR,
|
|
|
|
|
PROP_GEOMETRY,
|
|
|
|
|
PROP_WIDTH_MM,
|
|
|
|
|
PROP_HEIGHT_MM,
|
|
|
|
|
PROP_REFRESH_RATE,
|
|
|
|
|
PROP_SUBPIXEL_LAYOUT,
|
2017-11-01 18:02:08 +00:00
|
|
|
|
PROP_VALID,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static GParamSpec *props[LAST_PROP] = { NULL, };
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
INVALIDATE,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GdkMonitor, gdk_monitor, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_monitor_init (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
monitor->scale_factor = 1;
|
2017-11-01 18:02:08 +00:00
|
|
|
|
monitor->valid = TRUE;
|
2016-04-01 03:10:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_monitor_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GdkMonitor *monitor = GDK_MONITOR (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
|
g_value_set_object (value, monitor->display);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_MANUFACTURER:
|
|
|
|
|
g_value_set_string (value, monitor->manufacturer);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_MODEL:
|
|
|
|
|
g_value_set_string (value, monitor->model);
|
|
|
|
|
break;
|
|
|
|
|
|
2019-06-20 13:52:41 +00:00
|
|
|
|
case PROP_CONNECTOR:
|
|
|
|
|
g_value_set_string (value, monitor->connector);
|
|
|
|
|
break;
|
|
|
|
|
|
2016-04-01 03:10:04 +00:00
|
|
|
|
case PROP_SCALE_FACTOR:
|
|
|
|
|
g_value_set_int (value, monitor->scale_factor);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_GEOMETRY:
|
|
|
|
|
g_value_set_boxed (value, &monitor->geometry);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_WIDTH_MM:
|
|
|
|
|
g_value_set_int (value, monitor->width_mm);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_HEIGHT_MM:
|
|
|
|
|
g_value_set_int (value, monitor->height_mm);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_REFRESH_RATE:
|
2016-05-02 16:40:24 +00:00
|
|
|
|
g_value_set_int (value, monitor->refresh_rate);
|
2016-04-01 03:10:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_SUBPIXEL_LAYOUT:
|
|
|
|
|
g_value_set_enum (value, monitor->subpixel_layout);
|
|
|
|
|
break;
|
|
|
|
|
|
2017-11-01 18:02:08 +00:00
|
|
|
|
case PROP_VALID:
|
|
|
|
|
g_value_set_boolean (value, monitor->valid);
|
|
|
|
|
break;
|
|
|
|
|
|
2016-04-01 03:10:04 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_monitor_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GdkMonitor *monitor = GDK_MONITOR (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
|
monitor->display = g_value_get_object (value);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_monitor_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GdkMonitor *monitor = GDK_MONITOR (object);
|
|
|
|
|
|
2019-06-20 13:52:41 +00:00
|
|
|
|
g_free (monitor->connector);
|
2016-04-01 03:10:04 +00:00
|
|
|
|
g_free (monitor->manufacturer);
|
|
|
|
|
g_free (monitor->model);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_monitor_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_monitor_class_init (GdkMonitorClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gdk_monitor_finalize;
|
|
|
|
|
object_class->get_property = gdk_monitor_get_property;
|
|
|
|
|
object_class->set_property = gdk_monitor_set_property;
|
|
|
|
|
|
2021-02-21 05:13:57 +00:00
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:display: (attributes org.gtk.Property.get=gdk_monitor_get_display)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The `GdkDisplay` of the monitor.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_DISPLAY] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_object ("display", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
GDK_TYPE_DISPLAY,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:manufacturer: (attributes org.gtk.Property.get=gdk_monitor_get_manufacturer)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The manufacturer name.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_MANUFACTURER] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_string ("manufacturer", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
NULL,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:model: (attributes org.gtk.Property.get=gdk_monitor_get_model)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The model name.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_MODEL] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_string ("model", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
NULL,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:connector: (attributes org.gtk.Property.get=gdk_monitor_get_connector)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The connector name.
|
|
|
|
|
*/
|
2019-06-20 13:52:41 +00:00
|
|
|
|
props[PROP_CONNECTOR] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_string ("connector", NULL, NULL,
|
2019-06-20 13:52:41 +00:00
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:scale-factor: (attributes org.gtk.Property.get=gdk_monitor_get_scale_factor)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The scale factor.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_SCALE_FACTOR] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("scale-factor", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
0, G_MAXINT,
|
|
|
|
|
1,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:geometry: (attributes org.gtk.Property.get=gdk_monitor_get_geometry)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The geometry of the monitor.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_GEOMETRY] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boxed ("geometry", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
GDK_TYPE_RECTANGLE,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:width-mm: (attributes org.gtk.Property.get=gdk_monitor_get_width_mm)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The width of the monitor, in millimeters.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_WIDTH_MM] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("width-mm", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
0, G_MAXINT,
|
|
|
|
|
0,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:height-mm: (attributes org.gtk.Property.get=gdk_monitor_get_height_mm)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The height of the monitor, in millimeters.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_HEIGHT_MM] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("height-mm", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
0, G_MAXINT,
|
|
|
|
|
0,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:refresh-rate: (attributes org.gtk.Property.get=gdk_monitor_get_refresh_rate)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The refresh rate, in milli-Hertz.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_REFRESH_RATE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("refresh-rate", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
0, G_MAXINT,
|
|
|
|
|
0,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:subpixel-layout: (attributes org.gtk.Property.get=gdk_monitor_get_subpixel_layout)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The subpixel layout.
|
|
|
|
|
*/
|
2016-04-01 03:10:04 +00:00
|
|
|
|
props[PROP_SUBPIXEL_LAYOUT] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_enum ("subpixel-layout", NULL, NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
GDK_TYPE_SUBPIXEL_LAYOUT,
|
|
|
|
|
GDK_SUBPIXEL_LAYOUT_UNKNOWN,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* GdkMonitor:valid: (attributes org.gtk.Property.get=gdk_monitor_is_valid)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the object is still valid.
|
2021-05-12 17:53:56 +00:00
|
|
|
|
*/
|
2017-11-01 18:02:08 +00:00
|
|
|
|
props[PROP_VALID] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("valid", NULL, NULL,
|
2017-11-01 18:02:08 +00:00
|
|
|
|
TRUE,
|
2017-11-18 02:38:08 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
2016-04-01 03:10:04 +00:00
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, LAST_PROP, props);
|
|
|
|
|
|
2017-12-26 16:19:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* GdkMonitor::invalidate:
|
|
|
|
|
* @monitor: the object on which this signal was emitted
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Emitted when the output represented by @monitor gets disconnected.
|
2017-12-26 16:19:24 +00:00
|
|
|
|
*/
|
2017-11-18 02:38:08 +00:00
|
|
|
|
signals[INVALIDATE] = g_signal_new (g_intern_static_string ("invalidate"),
|
2016-04-01 03:10:04 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
0,
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:48:33 +00:00
|
|
|
|
NULL,
|
2016-04-01 03:10:04 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_display: (attributes org.gtk.Method.get_property=display)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the display that this monitor belongs to.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the display
|
|
|
|
|
*/
|
|
|
|
|
GdkDisplay *
|
|
|
|
|
gdk_monitor_get_display (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
|
|
|
|
|
|
|
|
|
|
return monitor->display;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_geometry: (attributes org.gtk.Method.get_property=geometry)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
|
|
|
|
* @geometry: (out): a `GdkRectangle` to be filled with the monitor geometry
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Retrieves the size and position of the monitor within the
|
|
|
|
|
* display coordinate space.
|
|
|
|
|
*
|
|
|
|
|
* The returned geometry is in ”application pixels”, not in
|
|
|
|
|
* ”device pixels” (see [method@Gdk.Monitor.get_scale_factor]).
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_get_geometry (GdkMonitor *monitor,
|
|
|
|
|
GdkRectangle *geometry)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_MONITOR (monitor));
|
|
|
|
|
g_return_if_fail (geometry != NULL);
|
|
|
|
|
|
|
|
|
|
*geometry = monitor->geometry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_width_mm: (attributes org.gtk.Method.get_property=width-mm)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the width in millimeters of the monitor.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the physical width of the monitor
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
gdk_monitor_get_width_mm (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), 0);
|
|
|
|
|
|
|
|
|
|
return monitor->width_mm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_height_mm: (attributes org.gtk.Method.get_property=height-mm)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the height in millimeters of the monitor.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the physical height of the monitor
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
gdk_monitor_get_height_mm (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), 0);
|
|
|
|
|
|
|
|
|
|
return monitor->height_mm;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-20 13:52:41 +00:00
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_connector: (attributes org.gtk.Method.get_property=connector)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2019-06-20 13:52:41 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the name of the monitor's connector, if available.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none) (nullable): the name of the connector
|
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
gdk_monitor_get_connector (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
|
|
|
|
|
|
|
|
|
|
return monitor->connector;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-01 03:10:04 +00:00
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_manufacturer: (attributes org.gtk.Method.get_property=manufacturer)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Gets the name or PNP ID of the monitor's manufacturer.
|
2019-08-06 06:16:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Note that this value might also vary depending on actual
|
|
|
|
|
* display backend.
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* The PNP ID registry is located at
|
|
|
|
|
* [https://uefi.org/pnp_id_list](https://uefi.org/pnp_id_list).
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Returns: (transfer none) (nullable): the name of the manufacturer
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
gdk_monitor_get_manufacturer (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
|
|
|
|
|
|
|
|
|
|
return monitor->manufacturer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_model: (attributes org.gtk.Method.get_property=model)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
2020-03-03 09:51:48 +00:00
|
|
|
|
* Gets the string identifying the monitor model, if available.
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Returns: (transfer none) (nullable): the monitor model
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
gdk_monitor_get_model (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
|
|
|
|
|
|
|
|
|
|
return monitor->model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-05-12 17:53:56 +00:00
|
|
|
|
* gdk_monitor_get_scale_factor: (attributes org.gtk.Method.get_property=scale-factor)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the internal scale factor that maps from monitor coordinates
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* to device pixels.
|
|
|
|
|
*
|
|
|
|
|
* On traditional systems this is 1, but on very high density outputs
|
|
|
|
|
* it can be a higher value (often 2).
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* This can be used if you want to create pixel based data for a
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* particular monitor, but most of the time you’re drawing to a surface
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* where it is better to use [method@Gdk.Surface.get_scale_factor] instead.
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the scale factor
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
gdk_monitor_get_scale_factor (GdkMonitor *monitor)
|
|
|
|
|
{
|
2017-03-19 13:24:02 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), 1);
|
2016-04-01 03:10:04 +00:00
|
|
|
|
|
|
|
|
|
return monitor->scale_factor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_refresh_rate: (attributes org.gtk.Method.get_property=refresh-rate)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the refresh rate of the monitor, if available.
|
|
|
|
|
*
|
|
|
|
|
* The value is in milli-Hertz, so a refresh rate of 60Hz
|
|
|
|
|
* is returned as 60000.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the refresh rate in milli-Hertz, or 0
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
gdk_monitor_get_refresh_rate (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), 0);
|
|
|
|
|
|
|
|
|
|
return monitor->refresh_rate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_get_subpixel_layout: (attributes org.gtk.Method.get_property=subpixel-layout)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets information about the layout of red, green and blue
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* primaries for pixels.
|
2016-04-01 03:10:04 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the subpixel layout
|
|
|
|
|
*/
|
|
|
|
|
GdkSubpixelLayout
|
|
|
|
|
gdk_monitor_get_subpixel_layout (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), GDK_SUBPIXEL_LAYOUT_UNKNOWN);
|
|
|
|
|
|
|
|
|
|
return monitor->subpixel_layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkMonitor *
|
|
|
|
|
gdk_monitor_new (GdkDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
return GDK_MONITOR (g_object_new (GDK_TYPE_MONITOR,
|
|
|
|
|
"display", display,
|
|
|
|
|
NULL));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_set_manufacturer (GdkMonitor *monitor,
|
|
|
|
|
const char *manufacturer)
|
|
|
|
|
{
|
|
|
|
|
g_free (monitor->manufacturer);
|
|
|
|
|
monitor->manufacturer = g_strdup (manufacturer);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "manufacturer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_set_model (GdkMonitor *monitor,
|
|
|
|
|
const char *model)
|
|
|
|
|
{
|
|
|
|
|
g_free (monitor->model);
|
|
|
|
|
monitor->model = g_strdup (model);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "model");
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-20 13:52:41 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_monitor_set_connector (GdkMonitor *monitor,
|
|
|
|
|
const char *connector)
|
|
|
|
|
{
|
|
|
|
|
g_free (monitor->connector);
|
|
|
|
|
monitor->connector = g_strdup (connector);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "connector");
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-01 03:10:04 +00:00
|
|
|
|
void
|
2020-05-17 03:23:16 +00:00
|
|
|
|
gdk_monitor_set_geometry (GdkMonitor *monitor,
|
|
|
|
|
const GdkRectangle *geometry)
|
2016-04-01 03:10:04 +00:00
|
|
|
|
{
|
2020-05-17 03:23:16 +00:00
|
|
|
|
if (gdk_rectangle_equal (&monitor->geometry, geometry))
|
|
|
|
|
return;
|
2016-04-01 03:10:04 +00:00
|
|
|
|
|
2020-05-17 03:23:16 +00:00
|
|
|
|
monitor->geometry = *geometry;
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "geometry");
|
2016-04-01 03:10:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_set_physical_size (GdkMonitor *monitor,
|
|
|
|
|
int width_mm,
|
|
|
|
|
int height_mm)
|
|
|
|
|
{
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (monitor));
|
|
|
|
|
|
|
|
|
|
if (monitor->width_mm != width_mm)
|
|
|
|
|
{
|
|
|
|
|
monitor->width_mm = width_mm;
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "width-mm");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (monitor->height_mm != height_mm)
|
|
|
|
|
{
|
|
|
|
|
monitor->height_mm = height_mm;
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "height-mm");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (monitor));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_set_scale_factor (GdkMonitor *monitor,
|
|
|
|
|
int scale_factor)
|
|
|
|
|
{
|
|
|
|
|
if (monitor->scale_factor == scale_factor)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
monitor->scale_factor = scale_factor;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "scale-factor");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_set_refresh_rate (GdkMonitor *monitor,
|
|
|
|
|
int refresh_rate)
|
|
|
|
|
{
|
|
|
|
|
if (monitor->refresh_rate == refresh_rate)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
monitor->refresh_rate = refresh_rate;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "refresh-rate");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
|
|
|
|
|
GdkSubpixelLayout subpixel_layout)
|
|
|
|
|
{
|
|
|
|
|
if (monitor->subpixel_layout == subpixel_layout)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
monitor->subpixel_layout = subpixel_layout;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "subpixel-layout");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdk_monitor_invalidate (GdkMonitor *monitor)
|
|
|
|
|
{
|
2017-11-01 18:02:08 +00:00
|
|
|
|
monitor->valid = FALSE;
|
|
|
|
|
g_object_notify (G_OBJECT (monitor), "valid");
|
2016-04-01 03:10:04 +00:00
|
|
|
|
g_signal_emit (monitor, signals[INVALIDATE], 0);
|
|
|
|
|
}
|
2017-11-01 18:02:08 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:05:11 +00:00
|
|
|
|
* gdk_monitor_is_valid: (attributes org.gtk.Method.get_property=valid)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @monitor: a `GdkMonitor`
|
2017-11-01 18:02:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns %TRUE if the @monitor object corresponds to a
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* physical monitor.
|
|
|
|
|
*
|
|
|
|
|
* The @monitor becomes invalid when the physical monitor
|
|
|
|
|
* is unplugged or removed.
|
2017-11-01 18:02:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the object corresponds to a physical monitor
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_monitor_is_valid (GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), FALSE);
|
|
|
|
|
|
|
|
|
|
return monitor->valid;
|
|
|
|
|
}
|