Rework to get rid of get_monitor_by_output
This commit is contained in:
@ -32,6 +32,7 @@ struct _GdkX11Monitor
|
||||
GdkMonitor parent;
|
||||
|
||||
XID output;
|
||||
char* name;
|
||||
guint add : 1;
|
||||
guint remove : 1;
|
||||
};
|
||||
|
||||
@ -469,14 +469,14 @@ check_is_composited (GdkDisplay *display,
|
||||
}
|
||||
|
||||
static GdkX11Monitor *
|
||||
find_monitor_by_output (GdkX11Display *x11_display, XID output)
|
||||
find_monitor_by_name (GdkX11Display *x11_display, char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < x11_display->monitors->len; i++)
|
||||
{
|
||||
GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
|
||||
if (monitor->output == output)
|
||||
if (strcmp(monitor->name, name) == 0)
|
||||
return monitor;
|
||||
}
|
||||
|
||||
@ -644,14 +644,22 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
|
||||
#undef EDID_LENGTH
|
||||
}
|
||||
|
||||
monitor = g_object_new (GDK_TYPE_X11_MONITOR,
|
||||
name = gdk_x11_get_xatom_name_for_display(display, rr_monitors[i].name);
|
||||
monitor = find_monitor_by_name (x11_display, name);
|
||||
if (monitor)
|
||||
monitor->remove = FALSE;
|
||||
else
|
||||
{
|
||||
monitor = g_object_new (gdk_x11_monitor_get_type (),
|
||||
"display", display,
|
||||
NULL);
|
||||
monitor->output = output;
|
||||
monitor->name = name;
|
||||
monitor->add = TRUE;
|
||||
g_ptr_array_add (x11_display->monitors, monitor);
|
||||
}
|
||||
|
||||
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
|
||||
name = gdk_x11_get_xatom_name_for_display(display, rr_monitors[i].name);
|
||||
|
||||
newgeo.x = rr_monitors[i].x / x11_screen->window_scale;
|
||||
newgeo.y = rr_monitors[i].y / x11_screen->window_scale;
|
||||
@ -833,7 +841,8 @@ init_randr13 (GdkScreen *screen, gboolean *changed)
|
||||
}
|
||||
}
|
||||
|
||||
monitor = find_monitor_by_output (x11_display, output);
|
||||
name = g_strndup (output_info->name, output_info->nameLen);
|
||||
monitor = find_monitor_by_name (x11_display, name);
|
||||
if (monitor)
|
||||
monitor->remove = FALSE;
|
||||
else
|
||||
@ -841,13 +850,13 @@ init_randr13 (GdkScreen *screen, gboolean *changed)
|
||||
monitor = g_object_new (gdk_x11_monitor_get_type (),
|
||||
"display", display,
|
||||
NULL);
|
||||
monitor->name = name;
|
||||
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;
|
||||
@ -974,15 +983,18 @@ init_no_multihead (GdkScreen *screen, gboolean *changed)
|
||||
monitor->remove = TRUE;
|
||||
}
|
||||
|
||||
monitor = find_monitor_by_output (x11_display, 0);
|
||||
if (monitor)
|
||||
if (x11_display->monitors->len > 0)
|
||||
{
|
||||
monitor = x11_display->monitors->pdata[0];
|
||||
monitor->remove = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
monitor = g_object_new (gdk_x11_monitor_get_type (),
|
||||
"display", x11_display,
|
||||
"display", display,
|
||||
NULL);
|
||||
monitor->output = 0;
|
||||
monitor->name = 0;
|
||||
monitor->add = TRUE;
|
||||
g_ptr_array_add (x11_display->monitors, monitor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user