forked from AuroraMiddleware/gtk
display: Remove unneeded getters
Applications can use the listmodel instead.
This commit is contained in:
parent
9a30019268
commit
4c7914dc49
@ -92,8 +92,6 @@ gdk_display_get_app_launch_context
|
||||
gdk_display_notify_startup_complete
|
||||
gdk_display_get_default_seat
|
||||
gdk_display_list_seats
|
||||
gdk_display_get_n_monitors
|
||||
gdk_display_get_monitor
|
||||
gdk_display_get_monitors
|
||||
gdk_display_get_monitor_at_surface
|
||||
gdk_display_get_clipboard
|
||||
|
@ -319,24 +319,6 @@ gdk_broadway_display_hide_keyboard (GdkBroadwayDisplay *display)
|
||||
_gdk_broadway_server_set_show_keyboard (display->server, FALSE);
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_broadway_display_get_n_monitors (GdkDisplay *display)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static GdkMonitor *
|
||||
gdk_broadway_display_get_monitor (GdkDisplay *display,
|
||||
int monitor_num)
|
||||
{
|
||||
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
|
||||
if (monitor_num == 0)
|
||||
return broadway_display->monitor;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
gdk_broadway_display_get_monitors (GdkDisplay *display)
|
||||
{
|
||||
@ -447,8 +429,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
|
||||
display_class->create_surface = _gdk_broadway_display_create_surface;
|
||||
display_class->get_keymap = _gdk_broadway_display_get_keymap;
|
||||
|
||||
display_class->get_n_monitors = gdk_broadway_display_get_n_monitors;
|
||||
display_class->get_monitor = gdk_broadway_display_get_monitor;
|
||||
display_class->get_monitors = gdk_broadway_display_get_monitors;
|
||||
display_class->get_setting = gdk_broadway_display_get_setting;
|
||||
}
|
||||
|
@ -776,7 +776,6 @@ gdk_broadway_surface_maximize (GdkSurface *surface)
|
||||
{
|
||||
GdkBroadwaySurface *impl;
|
||||
GdkDisplay *display;
|
||||
GdkMonitor *monitor;
|
||||
GdkRectangle geom;
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (surface))
|
||||
@ -797,8 +796,7 @@ gdk_broadway_surface_maximize (GdkSurface *surface)
|
||||
impl->pre_maximize_height = surface->height;
|
||||
|
||||
display = gdk_surface_get_display (surface);
|
||||
monitor = gdk_display_get_monitor (display, 0);
|
||||
gdk_monitor_get_geometry (monitor, &geom);
|
||||
gdk_monitor_get_geometry (GDK_BROADWAY_DISPLAY (display)->monitor, &geom);
|
||||
|
||||
gdk_broadway_surface_move_resize (surface,
|
||||
geom.x, geom.y,
|
||||
|
@ -1494,47 +1494,6 @@ gdk_display_list_seats (GdkDisplay *display)
|
||||
return g_list_copy (display->seats);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_get_n_monitors:
|
||||
* @display: a #GdkDisplay
|
||||
*
|
||||
* Gets the number of monitors that belong to @display.
|
||||
*
|
||||
* The returned number is valid until the next emission of the
|
||||
* #GdkDisplay::monitor-added or #GdkDisplay::monitor-removed signal.
|
||||
*
|
||||
* Returns: the number of monitors
|
||||
*/
|
||||
int
|
||||
gdk_display_get_n_monitors (GdkDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
|
||||
|
||||
if (GDK_DISPLAY_GET_CLASS (display)->get_n_monitors == NULL)
|
||||
return 1;
|
||||
|
||||
return GDK_DISPLAY_GET_CLASS (display)->get_n_monitors (display);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_get_monitor:
|
||||
* @display: a #GdkDisplay
|
||||
* @monitor_num: number of the monitor
|
||||
*
|
||||
* Gets a monitor associated with this display.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the #GdkMonitor, or %NULL if
|
||||
* @monitor_num is not a valid monitor number
|
||||
*/
|
||||
GdkMonitor *
|
||||
gdk_display_get_monitor (GdkDisplay *display,
|
||||
gint monitor_num)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
|
||||
return GDK_DISPLAY_GET_CLASS (display)->get_monitor (display, monitor_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_get_monitors:
|
||||
* @display: a #GdkDisplay
|
||||
@ -1573,7 +1532,8 @@ gdk_display_get_monitor_at_surface (GdkDisplay *display,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
GdkRectangle win;
|
||||
int n_monitors, i;
|
||||
GListModel *monitors;
|
||||
guint i;
|
||||
int area = 0;
|
||||
GdkMonitor *best = NULL;
|
||||
GdkDisplayClass *class;
|
||||
@ -1593,14 +1553,14 @@ gdk_display_get_monitor_at_surface (GdkDisplay *display,
|
||||
gdk_surface_get_geometry (surface, &win.x, &win.y, &win.width, &win.height);
|
||||
gdk_surface_get_origin (surface, &win.x, &win.y);
|
||||
|
||||
n_monitors = gdk_display_get_n_monitors (display);
|
||||
for (i = 0; i < n_monitors; i++)
|
||||
monitors = gdk_display_get_monitors (display);
|
||||
for (i = 0; i < g_list_model_get_n_items (monitors); i++)
|
||||
{
|
||||
GdkMonitor *monitor;
|
||||
GdkRectangle mon, intersect;
|
||||
int overlap;
|
||||
|
||||
monitor = gdk_display_get_monitor (display, i);
|
||||
monitor = g_list_model_get_item (monitors, i);
|
||||
gdk_monitor_get_geometry (monitor, &mon);
|
||||
gdk_rectangle_intersect (&win, &mon, &intersect);
|
||||
overlap = intersect.width *intersect.height;
|
||||
@ -1609,6 +1569,7 @@ gdk_display_get_monitor_at_surface (GdkDisplay *display,
|
||||
area = overlap;
|
||||
best = monitor;
|
||||
}
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
return best;
|
||||
|
@ -106,11 +106,6 @@ GdkSeat * gdk_display_get_default_seat (GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GList * gdk_display_list_seats (GdkDisplay *display);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gdk_display_get_n_monitors (GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkMonitor * gdk_display_get_monitor (GdkDisplay *display,
|
||||
int monitor_num);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GListModel * gdk_display_get_monitors (GdkDisplay *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -155,9 +155,6 @@ struct _GdkDisplayClass
|
||||
|
||||
GdkSeat * (*get_default_seat) (GdkDisplay *display);
|
||||
|
||||
int (*get_n_monitors) (GdkDisplay *display);
|
||||
GdkMonitor * (*get_monitor) (GdkDisplay *display,
|
||||
int index);
|
||||
GListModel * (*get_monitors) (GdkDisplay *self);
|
||||
GdkMonitor * (*get_monitor_at_surface) (GdkDisplay *display,
|
||||
GdkSurface *surface);
|
||||
|
@ -31,10 +31,9 @@
|
||||
* @Short_description: Object representing an output
|
||||
*
|
||||
* GdkMonitor objects represent the individual outputs that are
|
||||
* associated with a #GdkDisplay. GdkDisplay has APIs to enumerate
|
||||
* monitors with gdk_display_get_n_monitors() and gdk_display_get_monitor(), and
|
||||
* to find particular monitors with gdk_display_get_primary_monitor() or
|
||||
* gdk_display_get_monitor_at_surface().
|
||||
* associated with a #GdkDisplay. GdkDisplay keeps a #GListModel to enumerate
|
||||
* and monitor monitors with gdk_display_get_monitors().
|
||||
* You can use gdk_display_get_monitor_at_surface() to find a particular monitor.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -148,11 +148,13 @@ get_monitor_for_rect (GdkDisplay *display,
|
||||
GdkMonitor *monitor;
|
||||
GdkRectangle workarea;
|
||||
GdkRectangle intersection;
|
||||
gint i;
|
||||
GListModel *monitors;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < gdk_display_get_n_monitors (display); i++)
|
||||
monitors = gdk_display_get_monitors (display);
|
||||
for (i = 0; i < g_list_model_get_n_items (monitors); i++)
|
||||
{
|
||||
monitor = gdk_display_get_monitor (display, i);
|
||||
monitor = g_list_model_get_item (monitors, i);
|
||||
gdk_monitor_get_workarea (monitor, &workarea);
|
||||
|
||||
if (gdk_rectangle_intersect (&workarea, rect, &intersection))
|
||||
@ -163,6 +165,7 @@ get_monitor_for_rect (GdkDisplay *display,
|
||||
best_monitor = monitor;
|
||||
}
|
||||
}
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
return best_monitor;
|
||||
|
@ -952,31 +952,6 @@ _gdk_wayland_display_get_keymap (GdkDisplay *display)
|
||||
return tmp_keymap;
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_wayland_display_get_n_monitors (GdkDisplay *display)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
return g_list_model_get_n_items (G_LIST_MODEL (display_wayland->monitors));
|
||||
}
|
||||
|
||||
static GdkMonitor *
|
||||
gdk_wayland_display_get_monitor (GdkDisplay *display,
|
||||
int monitor_num)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
gpointer monitor;
|
||||
|
||||
if (monitor_num < 0)
|
||||
return NULL;
|
||||
|
||||
monitor = g_list_model_get_item (G_LIST_MODEL (display_wayland->monitors), monitor_num);
|
||||
if (monitor)
|
||||
g_object_unref (monitor);
|
||||
|
||||
return monitor;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
gdk_wayland_display_get_monitors (GdkDisplay *display)
|
||||
{
|
||||
@ -1052,8 +1027,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
|
||||
|
||||
display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current;
|
||||
|
||||
display_class->get_n_monitors = gdk_wayland_display_get_n_monitors;
|
||||
display_class->get_monitor = gdk_wayland_display_get_monitor;
|
||||
display_class->get_monitors = gdk_wayland_display_get_monitors;
|
||||
display_class->get_monitor_at_surface = gdk_wayland_display_get_monitor_at_surface;
|
||||
display_class->get_setting = gdk_wayland_display_get_setting;
|
||||
|
@ -744,9 +744,15 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
|
||||
g_object_ref (surface);
|
||||
|
||||
/* More likely to be right than just assuming 1 */
|
||||
if (display_wayland->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE &&
|
||||
gdk_display_get_n_monitors (display) > 0)
|
||||
impl->scale = gdk_monitor_get_scale_factor (gdk_display_get_monitor (display, 0));
|
||||
if (display_wayland->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE)
|
||||
{
|
||||
GdkMonitor *monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
|
||||
if (monitor)
|
||||
{
|
||||
impl->scale = gdk_monitor_get_scale_factor (monitor);
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
}
|
||||
|
||||
gdk_wayland_surface_set_title (surface, get_default_title ());
|
||||
|
||||
|
@ -949,35 +949,17 @@ gdk_win32_display_notify_startup_complete (GdkDisplay *display,
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_win32_display_get_n_monitors (GdkDisplay *display)
|
||||
{
|
||||
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
|
||||
|
||||
return g_list_model_get_n_items (win32_display->monitors);
|
||||
}
|
||||
|
||||
|
||||
static GdkMonitor *
|
||||
gdk_win32_display_get_monitor (GdkDisplay *display,
|
||||
int monitor_num)
|
||||
{
|
||||
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
|
||||
GdkMonitor *monitor;
|
||||
|
||||
monitor = g_list_model_get_item (win32_display->monitors, monitor_num);
|
||||
if (monitor == NULL)
|
||||
return NULL;
|
||||
|
||||
g_object_unref (monitor);
|
||||
return monitor;
|
||||
}
|
||||
|
||||
GdkMonitor *
|
||||
gdk_win32_display_get_primary_monitor (GdkDisplay *display)
|
||||
{
|
||||
/* We arrange for the first monitor in the array to also be the primiary monitor */
|
||||
return gdk_win32_display_get_monitor (display, 0);
|
||||
GdkWin32Display *self = GDK_WIN32_DISPLAY (display);
|
||||
GdkMonitor *result;
|
||||
|
||||
/* We arrange for the first monitor in the array to also be the primary monitor */
|
||||
result = g_list_model_get_item (self->monitors, 0);
|
||||
g_object_unref (result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
@ -1110,8 +1092,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
|
||||
display_class->get_keymap = _gdk_win32_display_get_keymap;
|
||||
display_class->make_gl_context_current = _gdk_win32_display_make_gl_context_current;
|
||||
|
||||
display_class->get_n_monitors = gdk_win32_display_get_n_monitors;
|
||||
display_class->get_monitor = gdk_win32_display_get_monitor;
|
||||
display_class->get_monitors = gdk_win32_display_get_monitors;
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
|
@ -46,23 +46,22 @@ G_DEFINE_TYPE (GdkWin32Screen, gdk_win32_screen, G_TYPE_OBJECT)
|
||||
static void
|
||||
init_root_window_size (GdkWin32Screen *screen)
|
||||
{
|
||||
GdkRectangle result;
|
||||
GdkRectangle result = { 0, };
|
||||
int i;
|
||||
GdkDisplay *display = _gdk_display;
|
||||
int monitor_count;
|
||||
GListModel *monitors;
|
||||
GdkMonitor *monitor;
|
||||
|
||||
monitor_count = gdk_display_get_n_monitors (display);
|
||||
monitor = gdk_display_get_monitor (display, 0);
|
||||
gdk_monitor_get_geometry (monitor, &result);
|
||||
monitors = gdk_display_get_monitors (display);
|
||||
|
||||
for (i = 1; i < monitor_count; i++)
|
||||
for (i = 1; i < g_list_model_get_n_items (monitors); i++)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
|
||||
monitor = gdk_display_get_monitor (display, i);
|
||||
monitor = g_list_model_get_item (monitors, i);
|
||||
gdk_monitor_get_geometry (monitor, &rect);
|
||||
gdk_rectangle_union (&result, &rect, &result);
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
screen->width = result.width;
|
||||
|
@ -2051,21 +2051,22 @@ static void
|
||||
calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
gint n_monitors, monitor_idx, other_monitor_idx;
|
||||
GListModel *monitors;
|
||||
gint monitor_idx, other_monitor_idx;
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (context->window);
|
||||
#if defined(MORE_AEROSNAP_DEBUGGING)
|
||||
gint i;
|
||||
#endif
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
n_monitors = gdk_display_get_n_monitors (display);
|
||||
monitors = gdk_display_get_monitors (display);
|
||||
|
||||
#define _M_UP 0
|
||||
#define _M_DOWN 1
|
||||
#define _M_LEFT 2
|
||||
#define _M_RIGHT 3
|
||||
|
||||
for (monitor_idx = 0; monitor_idx < n_monitors; monitor_idx++)
|
||||
for (monitor_idx = 0; monitor_idx < g_list_model_get_n_items (monitors); monitor_idx++)
|
||||
{
|
||||
GdkRectangle wa;
|
||||
GdkRectangle geometry;
|
||||
@ -2076,12 +2077,13 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
|
||||
gint thickness, trigger_thickness;
|
||||
GdkMonitor *monitor;
|
||||
|
||||
monitor = gdk_display_get_monitor (display, monitor_idx);
|
||||
monitor = g_list_model_get_item (monitors, monitor_idx);
|
||||
g_object_unref (monitors);
|
||||
gdk_monitor_get_workarea (monitor, &wa);
|
||||
gdk_monitor_get_geometry (monitor, &geometry);
|
||||
|
||||
for (other_monitor_idx = 0;
|
||||
other_monitor_idx < n_monitors &&
|
||||
other_monitor_idx < g_list_model_get_n_items (monitors) &&
|
||||
(move_edge[_M_UP] || move_edge[_M_LEFT] ||
|
||||
move_edge[_M_RIGHT] || resize_edge[_M_DOWN]);
|
||||
other_monitor_idx++)
|
||||
@ -2092,7 +2094,8 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
|
||||
if (other_monitor_idx == monitor_idx)
|
||||
continue;
|
||||
|
||||
other_monitor = gdk_display_get_monitor (display, other_monitor_idx);
|
||||
other_monitor = g_list_model_get_item (monitors, other_monitor_idx);
|
||||
g_object_unref (other_monitor);
|
||||
gdk_monitor_get_workarea (other_monitor, &other_wa);
|
||||
|
||||
/* An edge triggers AeroSnap only if there are no
|
||||
@ -2472,6 +2475,7 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
|
||||
{
|
||||
GdkWin32Surface *impl;
|
||||
GdkDisplay *display;
|
||||
GListModel *monitors;
|
||||
gint n_monitors;
|
||||
GdkSurfaceState surface_state = gdk_toplevel_get_state (GDK_TOPLEVEL (window));
|
||||
gboolean minimized = surface_state & GDK_SURFACE_STATE_MINIMIZED;
|
||||
@ -2481,7 +2485,8 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
display = gdk_surface_get_display (window);
|
||||
n_monitors = gdk_display_get_n_monitors (display);
|
||||
monitors = gdk_display_get_monitors (display);
|
||||
n_monitors = g_list_model_get_n_items (monitors);
|
||||
monitor = gdk_display_get_monitor_at_surface (display, window);
|
||||
|
||||
if (minimized && maximized)
|
||||
@ -2527,10 +2532,15 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
|
||||
}
|
||||
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFLEFT)
|
||||
{
|
||||
GdkMonitor *other;
|
||||
|
||||
unsnap (window, monitor);
|
||||
snap_right (window,
|
||||
monitor,
|
||||
(gdk_win32_display_get_primary_monitor (monitor->display) == monitor) ? monitor : gdk_display_get_monitor (display, n_monitors - 1));
|
||||
if (gdk_win32_display_get_primary_monitor (monitor->display) == monitor)
|
||||
other = g_object_ref (monitor);
|
||||
else
|
||||
other = g_list_model_get_item (monitors, n_monitors - 1);
|
||||
snap_right (window, monitor, other);
|
||||
g_object_unref (other);
|
||||
}
|
||||
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT)
|
||||
{
|
||||
@ -2553,24 +2563,21 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
|
||||
}
|
||||
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT)
|
||||
{
|
||||
GdkMonitor *other;
|
||||
gint i;
|
||||
|
||||
unsnap (window, monitor);
|
||||
if (n_monitors == 1 ||
|
||||
monitor == gdk_display_get_monitor (display, n_monitors - 1))
|
||||
{
|
||||
snap_left (window, monitor, monitor);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < n_monitors; i++)
|
||||
{
|
||||
if (monitor == gdk_display_get_monitor (display, i))
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < n_monitors; i++)
|
||||
{
|
||||
other = g_list_model_get_item (monitors, i);
|
||||
g_object_unref (other);
|
||||
if (monitor == other)
|
||||
break;
|
||||
}
|
||||
|
||||
snap_left (window, monitor, gdk_display_get_monitor (display, i + 1));
|
||||
}
|
||||
other = g_list_model_get_item (monitors, (i + 1) % n_monitors);
|
||||
snap_left (window, monitor, other);
|
||||
g_object_unref (other);
|
||||
}
|
||||
break;
|
||||
case GDK_WIN32_AEROSNAP_COMBO_SHIFTUP:
|
||||
@ -3119,18 +3126,19 @@ get_monitor_at_point (GdkDisplay *display,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
GListModel *monitors;
|
||||
GdkMonitor *nearest = NULL;
|
||||
int nearest_dist = G_MAXINT;
|
||||
int n_monitors, i;
|
||||
guint i;
|
||||
|
||||
n_monitors = gdk_display_get_n_monitors (display);
|
||||
for (i = 0; i < n_monitors; i++)
|
||||
monitors = gdk_display_get_monitors (display);
|
||||
for (i = 0; i < g_list_model_get_n_items (monitors); i++)
|
||||
{
|
||||
GdkMonitor *monitor;
|
||||
GdkRectangle geometry;
|
||||
int dist_x, dist_y, dist;
|
||||
|
||||
monitor = gdk_display_get_monitor (display, i);
|
||||
monitor = g_list_model_get_item (monitors, i);
|
||||
gdk_monitor_get_geometry (monitor, &geometry);
|
||||
|
||||
if (x < geometry.x)
|
||||
@ -3175,6 +3183,8 @@ get_monitor_at_point (GdkDisplay *display,
|
||||
nearest = monitor;
|
||||
}
|
||||
|
||||
g_object_unref (monitor);
|
||||
|
||||
if (nearest_dist == 0)
|
||||
break;
|
||||
}
|
||||
|
@ -2831,34 +2831,6 @@ gdk_x11_display_get_default_seat (GdkDisplay *display)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_x11_display_get_n_monitors (GdkDisplay *display)
|
||||
{
|
||||
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
|
||||
|
||||
return g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors));
|
||||
}
|
||||
|
||||
|
||||
static GdkMonitor *
|
||||
gdk_x11_display_get_monitor (GdkDisplay *display,
|
||||
int monitor_num)
|
||||
{
|
||||
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
|
||||
GdkMonitor *monitor;
|
||||
|
||||
if (monitor_num < 0)
|
||||
return NULL;
|
||||
|
||||
monitor = g_list_model_get_item (G_LIST_MODEL (x11_display->monitors), monitor_num);
|
||||
if (monitor)
|
||||
g_object_unref (monitor);
|
||||
|
||||
return monitor;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
gdk_x11_display_get_monitors (GdkDisplay *display)
|
||||
{
|
||||
@ -2987,8 +2959,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
|
||||
|
||||
display_class->get_default_seat = gdk_x11_display_get_default_seat;
|
||||
|
||||
display_class->get_n_monitors = gdk_x11_display_get_n_monitors;
|
||||
display_class->get_monitor = gdk_x11_display_get_monitor;
|
||||
display_class->get_monitors = gdk_x11_display_get_monitors;
|
||||
display_class->get_setting = gdk_x11_display_get_setting;
|
||||
display_class->set_cursor_theme = gdk_x11_display_set_cursor_theme;
|
||||
|
@ -1605,13 +1605,15 @@ void
|
||||
gdk_x11_surface_enter_leave_monitors (GdkSurface *surface)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
int n_monitors, i;
|
||||
GListModel *monitors;
|
||||
guint i;
|
||||
|
||||
n_monitors = gdk_display_get_n_monitors (display);
|
||||
for (i = 0; i < n_monitors; i++)
|
||||
monitors = gdk_display_get_monitors (display);
|
||||
for (i = 0; i < g_list_model_get_n_items (monitors); i++)
|
||||
{
|
||||
GdkMonitor *monitor = gdk_display_get_monitor (display, i);
|
||||
GdkMonitor *monitor = g_list_model_get_item (monitors, i);
|
||||
gdk_x11_surface_check_monitor (surface, monitor);
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6592,9 +6592,13 @@ gtk_widget_get_scale_factor (GtkWidget *widget)
|
||||
display = _gtk_widget_get_display (widget);
|
||||
if (display)
|
||||
{
|
||||
monitor = gdk_display_get_monitor (display, 0);
|
||||
monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
|
||||
if (monitor)
|
||||
return gdk_monitor_get_scale_factor (monitor);
|
||||
{
|
||||
int result = gdk_monitor_get_scale_factor (monitor);
|
||||
g_object_unref (monitor);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -4101,11 +4101,24 @@ gtk_window_guess_default_size (GtkWindow *window,
|
||||
surface = priv->surface;
|
||||
|
||||
if (surface)
|
||||
monitor = gdk_display_get_monitor_at_surface (display, surface);
|
||||
{
|
||||
monitor = gdk_display_get_monitor_at_surface (display, surface);
|
||||
gdk_monitor_get_workarea (monitor, &workarea);
|
||||
}
|
||||
else
|
||||
monitor = gdk_display_get_monitor (display, 0);
|
||||
|
||||
gdk_monitor_get_workarea (monitor, &workarea);
|
||||
{
|
||||
monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
|
||||
if (monitor)
|
||||
{
|
||||
gdk_monitor_get_workarea (monitor, &workarea);
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
else
|
||||
{
|
||||
workarea.width = G_MAXINT;
|
||||
workarea.height = G_MAXINT;
|
||||
}
|
||||
}
|
||||
|
||||
*width = workarea.width;
|
||||
*height = workarea.height;
|
||||
|
@ -176,9 +176,6 @@ main(int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GtkWidget *da;
|
||||
GdkDisplay *display;
|
||||
GdkMonitor *monitor;
|
||||
GdkRectangle monitor_bounds;
|
||||
gboolean done = FALSE;
|
||||
|
||||
GOptionContext *context = g_option_context_new (NULL);
|
||||
@ -212,10 +209,6 @@ main(int argc, char **argv)
|
||||
G_CALLBACK (on_map), NULL);
|
||||
on_frame (0.);
|
||||
|
||||
display = gtk_widget_get_display (window);
|
||||
monitor = gdk_display_get_monitor (display, 0);
|
||||
gdk_monitor_get_geometry (monitor, &monitor_bounds);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
while (!done)
|
||||
|
Loading…
Reference in New Issue
Block a user