wayland: Stop using ::monitors-changed

Instead of connecting to this signal for every single window,
walk the window tree from the root window.
This commit is contained in:
Matthias Clasen 2017-10-31 21:48:58 -04:00
parent 67cea50383
commit e424dcb049
3 changed files with 20 additions and 31 deletions

View File

@ -290,4 +290,7 @@ void gdk_wayland_window_inhibit_shortcuts (GdkWindow *window,
void gdk_wayland_window_restore_shortcuts (GdkWindow *window,
GdkSeat *gdk_seat);
void window_update_scale (GdkWindow *window);
#endif /* __GDK_PRIVATE_WAYLAND_H__ */

View File

@ -698,8 +698,7 @@ output_handle_geometry (void *data,
if (GDK_MONITOR (monitor)->geometry.width != 0 && monitor->version < OUTPUT_VERSION_WITH_DONE)
{
GdkDisplay *display = GDK_MONITOR (monitor)->display;
GdkWaylandScreen *screen = GDK_WAYLAND_SCREEN (gdk_display_get_default_screen (display));
g_signal_emit_by_name (screen, "monitors-changed");
window_update_scale (gdk_display_get_root_window (display));
}
}
@ -709,7 +708,6 @@ output_handle_done (void *data,
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)data;
GdkDisplay *display = gdk_monitor_get_display (GDK_MONITOR (monitor));
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (gdk_display_get_default_screen (display));
GDK_NOTE (MISC,
g_message ("handle done output %d", monitor->id));
@ -721,7 +719,7 @@ output_handle_done (void *data,
gdk_display_monitor_added (display, GDK_MONITOR (monitor));
}
g_signal_emit_by_name (screen_wayland, "monitors-changed");
window_update_scale (gdk_display_get_root_window (display));
}
static void
@ -748,10 +746,7 @@ output_handle_scale (void *data,
gdk_monitor_set_size (GDK_MONITOR (monitor), width / scale, height / scale);
if (GDK_MONITOR (monitor)->geometry.width != 0 && monitor->version < OUTPUT_VERSION_WITH_DONE)
{
GdkScreen *screen = gdk_display_get_default_screen (GDK_MONITOR (monitor)->display);
g_signal_emit_by_name (screen, "monitors-changed");
}
window_update_scale (gdk_display_get_root_window (GDK_MONITOR (monitor)->display));
}
static void
@ -777,10 +772,7 @@ output_handle_mode (void *data,
gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh);
if (width != 0 && monitor->version < OUTPUT_VERSION_WITH_DONE)
{
GdkScreen *screen = gdk_display_get_default_screen (GDK_MONITOR (monitor)->display);
g_signal_emit_by_name (screen, "monitors-changed");
}
window_update_scale (gdk_display_get_root_window (GDK_MONITOR (monitor)->display));
}
static const struct wl_output_listener output_listener =
@ -879,8 +871,8 @@ _gdk_wayland_screen_remove_output (GdkScreen *screen,
g_object_ref (monitor);
g_ptr_array_remove (display_wayland->monitors, monitor);
gdk_display_monitor_removed (GDK_DISPLAY (display_wayland), GDK_MONITOR (monitor));
window_update_scale (gdk_display_get_root_window (GDK_MONITOR (monitor)->display));
g_object_unref (monitor);
g_signal_emit_by_name (screen_wayland, "monitors-changed");
}
}

View File

@ -614,14 +614,14 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
g_signal_emit (impl, signals[COMMITTED], 0);
}
static void
void
window_update_scale (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
guint32 scale;
GSList *l;
GList *children, *c;
if (display_wayland->compositor_version < WL_SURFACE_HAS_BUFFER_SCALE)
{
@ -639,16 +639,16 @@ window_update_scale (GdkWindow *window)
/* Notify app that scale changed */
gdk_wayland_window_maybe_configure (window, window->width, window->height, scale);
}
static void
on_monitors_changed (GdkScreen *screen,
GdkWindow *window)
{
window_update_scale (window);
children = gdk_window_get_children (window);
for (c = children; c; c = c->next)
{
GdkWindow *child = c->data;
window_update_scale (child);
}
g_list_free (children);
}
static void gdk_wayland_window_create_surface (GdkWindow *window);
void
@ -702,14 +702,8 @@ _gdk_wayland_display_create_window_impl (GdkDisplay *display,
gdk_wayland_window_create_surface (window);
frame_clock = gdk_window_get_frame_clock (window);
g_signal_connect (frame_clock, "before-paint",
G_CALLBACK (on_frame_clock_before_paint), window);
g_signal_connect (frame_clock, "after-paint",
G_CALLBACK (on_frame_clock_after_paint), window);
g_signal_connect (gdk_display_get_default_screen (display), "monitors-changed",
G_CALLBACK (on_monitors_changed), window);
g_signal_connect (frame_clock, "before-paint", G_CALLBACK (on_frame_clock_before_paint), window);
g_signal_connect (frame_clock, "after-paint", G_CALLBACK (on_frame_clock_after_paint), window);
}
static void