monitor: Add gdk_monitor_set_geometry()

Make it replace gdk_monitor_set_size() and gdk_monitor_set_position()
which used to be called in pairs anyway.
This commit is contained in:
Benjamin Otte 2020-05-17 05:23:16 +02:00
parent 33a4442988
commit e81a1db48c
7 changed files with 21 additions and 65 deletions

View File

@ -64,7 +64,7 @@ gdk_broadway_display_init (GdkBroadwayDisplay *display)
gdk_monitor_set_manufacturer (display->monitor, "browser");
gdk_monitor_set_model (display->monitor, "0");
display->scale_factor = 1;
gdk_monitor_set_size (display->monitor, 1024, 768);
gdk_monitor_set_geometry (display->monitor, &(GdkRectangle) { 0, 0, 1024, 768 });
gdk_monitor_set_physical_size (display->monitor, 1024 * 25.4 / 96, 768 * 25.4 / 96);
gdk_monitor_set_scale_factor (display->monitor, 1);
}
@ -97,7 +97,7 @@ _gdk_broadway_display_size_changed (GdkDisplay *display,
broadway_display->scale_factor = msg->scale;
gdk_monitor_set_size (monitor, msg->width, msg->height);
gdk_monitor_set_geometry (monitor, &(GdkRectangle) { 0, 0, msg->width, msg->height });
gdk_monitor_set_scale_factor (monitor, msg->scale);
gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96);

View File

@ -531,47 +531,14 @@ gdk_monitor_set_connector (GdkMonitor *monitor,
}
void
gdk_monitor_set_position (GdkMonitor *monitor,
int x,
int y)
gdk_monitor_set_geometry (GdkMonitor *monitor,
const GdkRectangle *geometry)
{
g_object_freeze_notify (G_OBJECT (monitor));
if (gdk_rectangle_equal (&monitor->geometry, geometry))
return;
if (monitor->geometry.x != x)
{
monitor->geometry.x = x;
g_object_notify (G_OBJECT (monitor), "geometry");
}
if (monitor->geometry.y != y)
{
monitor->geometry.y = y;
g_object_notify (G_OBJECT (monitor), "geometry");
}
g_object_thaw_notify (G_OBJECT (monitor));
}
void
gdk_monitor_set_size (GdkMonitor *monitor,
int width,
int height)
{
g_object_freeze_notify (G_OBJECT (monitor));
if (monitor->geometry.width != width)
{
monitor->geometry.width = width;
g_object_notify (G_OBJECT (monitor), "geometry");
}
if (monitor->geometry.height != height)
{
monitor->geometry.height = height;
g_object_notify (G_OBJECT (monitor), "geometry");
}
g_object_thaw_notify (G_OBJECT (monitor));
monitor->geometry = *geometry;
g_object_notify (G_OBJECT (monitor), "geometry");
}
void

View File

@ -61,12 +61,8 @@ void gdk_monitor_set_model (GdkMonitor *monitor,
const char *model);
void gdk_monitor_set_connector (GdkMonitor *monitor,
const char *connector);
void gdk_monitor_set_position (GdkMonitor *monitor,
int x,
int y);
void gdk_monitor_set_size (GdkMonitor *monitor,
int width,
int height);
void gdk_monitor_set_geometry (GdkMonitor *monitor,
const GdkRectangle *geometry);
void gdk_monitor_set_physical_size (GdkMonitor *monitor,
int width_mm,
int height_mm);

View File

@ -2274,8 +2274,10 @@ apply_monitor_change (GdkWaylandMonitor *monitor)
monitor->x, monitor->y,
monitor->width, monitor->height));
gdk_monitor_set_position (GDK_MONITOR (monitor), monitor->x, monitor->y);
gdk_monitor_set_size (GDK_MONITOR (monitor), monitor->width, monitor->height);
gdk_monitor_set_geometry (GDK_MONITOR (monitor),
&(GdkRectangle) {
monitor->x, monitor->y,
monitor->width, monitor->height });
gdk_monitor_set_connector (GDK_MONITOR (monitor), monitor->name);
monitor->wl_output_done = FALSE;
monitor->xdg_output_done = FALSE;

View File

@ -208,7 +208,7 @@ _gdk_win32_display_init_monitors (GdkWin32Display *win32_display)
GdkMonitor *m;
GdkWin32Monitor *w32_ex_monitor;
GdkMonitor *ex_monitor;
GdkRectangle geometry, ex_geometry;
GdkRectangle geometry;
GdkRectangle workarea, ex_workarea;
w32_m = GDK_WIN32_MONITOR (g_ptr_array_index (new_monitors, i));
@ -228,7 +228,6 @@ _gdk_win32_display_init_monitors (GdkWin32Display *win32_display)
primary_to_move = w32_ex_monitor;
gdk_monitor_get_geometry (m, &geometry);
gdk_monitor_get_geometry (ex_monitor, &ex_geometry);
gdk_monitor_get_workarea (m, &workarea);
gdk_monitor_get_workarea (ex_monitor, &ex_workarea);
@ -237,11 +236,7 @@ _gdk_win32_display_init_monitors (GdkWin32Display *win32_display)
w32_ex_monitor->work_rect = workarea;
}
if (memcmp (&geometry, &ex_geometry, sizeof (GdkRectangle)) != 0)
{
gdk_monitor_set_size (ex_monitor, geometry.width, geometry.height);
gdk_monitor_set_position (ex_monitor, geometry.x, geometry.y);
}
gdk_monitor_set_geometry (ex_monitor, &geometry);
if (gdk_monitor_get_width_mm (m) != gdk_monitor_get_width_mm (ex_monitor) ||
gdk_monitor_get_height_mm (m) != gdk_monitor_get_height_mm (ex_monitor))

View File

@ -710,8 +710,7 @@ enum_monitor (HMONITOR hmonitor,
rect.y = monitor_info.rcMonitor.top / scale;
rect.width = (monitor_info.rcMonitor.right - monitor_info.rcMonitor.left) / scale;
rect.height = (monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top) / scale;
gdk_monitor_set_position (mon, rect.x, rect.y);
gdk_monitor_set_size (mon, rect.width, rect.height);
gdk_monitor_set_geometry (mon, &rect);
if (monitor_info.dwFlags & MONITORINFOF_PRIMARY && i != 0)
{
@ -819,7 +818,7 @@ _gdk_win32_display_get_monitor_list (GdkWin32Display *win32_display)
gdk_monitor_get_geometry (GDK_MONITOR (m), &rect);
rect.x += _gdk_offset_x;
rect.y += _gdk_offset_y;
gdk_monitor_set_position (GDK_MONITOR (m), rect.x, rect.y);
gdk_monitor_set_geometry (GDK_MONITOR (m), &rect);
m->work_rect.x += _gdk_offset_x;
m->work_rect.y += _gdk_offset_y;

View File

@ -563,8 +563,7 @@ init_randr15 (GdkX11Screen *x11_screen)
newgeo.width = rr_monitors[i].width / x11_screen->surface_scale;
newgeo.height = rr_monitors[i].height / x11_screen->surface_scale;
gdk_monitor_set_position (GDK_MONITOR (monitor), newgeo.x, newgeo.y);
gdk_monitor_set_size (GDK_MONITOR (monitor), newgeo.width, newgeo.height);
gdk_monitor_set_geometry (GDK_MONITOR (monitor), &newgeo);
g_object_notify (G_OBJECT (monitor), "workarea");
gdk_monitor_set_physical_size (GDK_MONITOR (monitor),
rr_monitors[i].mwidth,
@ -716,8 +715,7 @@ init_randr13 (GdkX11Screen *x11_screen)
newgeo.width = crtc->width / x11_screen->surface_scale;
newgeo.height = crtc->height / x11_screen->surface_scale;
gdk_monitor_set_position (GDK_MONITOR (monitor), newgeo.x, newgeo.y);
gdk_monitor_set_size (GDK_MONITOR (monitor), newgeo.width, newgeo.height);
gdk_monitor_set_geometry (GDK_MONITOR (monitor), &newgeo);
g_object_notify (G_OBJECT (monitor), "workarea");
gdk_monitor_set_physical_size (GDK_MONITOR (monitor),
output_info->mm_width,
@ -827,8 +825,7 @@ init_no_multihead (GdkX11Screen *x11_screen)
width = WidthOfScreen (x11_screen->xscreen);
height = HeightOfScreen (x11_screen->xscreen);
gdk_monitor_set_position (GDK_MONITOR (monitor), 0, 0);
gdk_monitor_set_size (GDK_MONITOR (monitor), width, height);
gdk_monitor_set_geometry (GDK_MONITOR (monitor), &(GdkRectangle) { 0, 0, width, height });
g_object_notify (G_OBJECT (monitor), "workarea");
gdk_monitor_set_physical_size (GDK_MONITOR (monitor), width_mm, height_mm);
gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->surface_scale);