diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index d6d5d19eb6..9b5973fb62 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -1126,7 +1126,6 @@ GDK_TYPE_GL_PROFILE GdkMonitor gdk_monitor_get_display gdk_monitor_get_geometry -gdk_monitor_get_workarea gdk_monitor_get_width_mm gdk_monitor_get_height_mm gdk_monitor_get_manufacturer diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c index 87a0642630..ca68c5fbcd 100644 --- a/gdk/broadway/gdksurface-broadway.c +++ b/gdk/broadway/gdksurface-broadway.c @@ -556,12 +556,20 @@ gdk_broadway_surface_layout_popup (GdkSurface *surface, int height, GdkPopupLayout *layout) { + GdkMonitor *monitor; + GdkRectangle bounds; GdkRectangle final_rect; int x, y; + monitor = gdk_surface_get_layout_monitor (surface, layout, + gdk_monitor_get_geometry); + gdk_monitor_get_geometry (monitor, &bounds); + gdk_surface_layout_popup_helper (surface, width, height, + monitor, + &bounds, layout, &final_rect); diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c index 5157caea0a..46edc8a5c4 100644 --- a/gdk/gdkmonitor.c +++ b/gdk/gdkmonitor.c @@ -51,7 +51,6 @@ enum { PROP_CONNECTOR, PROP_SCALE_FACTOR, PROP_GEOMETRY, - PROP_WORKAREA, PROP_WIDTH_MM, PROP_HEIGHT_MM, PROP_REFRESH_RATE, @@ -112,14 +111,6 @@ gdk_monitor_get_property (GObject *object, g_value_set_boxed (value, &monitor->geometry); break; - case PROP_WORKAREA: - { - GdkRectangle workarea; - gdk_monitor_get_workarea (monitor, &workarea); - g_value_set_boxed (value, &workarea); - } - break; - case PROP_WIDTH_MM: g_value_set_int (value, monitor->width_mm); break; @@ -222,12 +213,6 @@ gdk_monitor_class_init (GdkMonitorClass *class) "The geometry of the monitor", GDK_TYPE_RECTANGLE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - props[PROP_WORKAREA] = - g_param_spec_boxed ("workarea", - "Workarea", - "The workarea of the monitor", - GDK_TYPE_RECTANGLE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); props[PROP_WIDTH_MM] = g_param_spec_int ("width-mm", "Physical width", @@ -316,38 +301,6 @@ gdk_monitor_get_geometry (GdkMonitor *monitor, *geometry = monitor->geometry; } -/** - * gdk_monitor_get_workarea: - * @monitor: a #GdkMonitor - * @workarea: (out): a #GdkRectangle to be filled with - * the monitor workarea - * - * Retrieves the size and position of the “work area” on a monitor - * within the display coordinate space. The returned geometry is in - * ”application pixels”, not in ”device pixels” (see - * gdk_monitor_get_scale_factor()). - * - * The work area should be considered when positioning menus and - * similar popups, to avoid placing them below panels, docks or other - * desktop components. - * - * Note that not all backends may have a concept of workarea. This - * function will return the monitor geometry if a workarea is not - * available, or does not apply. - */ -void -gdk_monitor_get_workarea (GdkMonitor *monitor, - GdkRectangle *workarea) -{ - g_return_if_fail (GDK_IS_MONITOR (monitor)); - g_return_if_fail (workarea != NULL); - - if (GDK_MONITOR_GET_CLASS (monitor)->get_workarea) - GDK_MONITOR_GET_CLASS (monitor)->get_workarea (monitor, workarea); - else - *workarea = monitor->geometry; -} - /** * gdk_monitor_get_width_mm: * @monitor: a #GdkMonitor diff --git a/gdk/gdkmonitor.h b/gdk/gdkmonitor.h index 58592a5c32..31f1cd148c 100644 --- a/gdk/gdkmonitor.h +++ b/gdk/gdkmonitor.h @@ -69,9 +69,6 @@ GDK_AVAILABLE_IN_ALL void gdk_monitor_get_geometry (GdkMonitor *monitor, GdkRectangle *geometry); GDK_AVAILABLE_IN_ALL -void gdk_monitor_get_workarea (GdkMonitor *monitor, - GdkRectangle *workarea); -GDK_AVAILABLE_IN_ALL int gdk_monitor_get_width_mm (GdkMonitor *monitor); GDK_AVAILABLE_IN_ALL int gdk_monitor_get_height_mm (GdkMonitor *monitor); diff --git a/gdk/gdkmonitorprivate.h b/gdk/gdkmonitorprivate.h index cbed437740..36c591a8f2 100644 --- a/gdk/gdkmonitorprivate.h +++ b/gdk/gdkmonitorprivate.h @@ -48,9 +48,6 @@ struct _GdkMonitor { struct _GdkMonitorClass { GObjectClass parent_class; - - void (* get_workarea) (GdkMonitor *monitor, - GdkRectangle *geometry); }; GdkMonitor * gdk_monitor_new (GdkDisplay *display); diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 5c3b16170d..62fc8196f6 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -137,8 +137,10 @@ get_display_for_surface (GdkSurface *primary, } static GdkMonitor * -get_monitor_for_rect (GdkDisplay *display, - const GdkRectangle *rect) +get_monitor_for_rect (GdkDisplay *display, + const GdkRectangle *rect, + void (*get_bounds) (GdkMonitor *monitor, + GdkRectangle *bounds)) { int biggest_area = G_MININT; GdkMonitor *best_monitor = NULL; @@ -152,7 +154,7 @@ get_monitor_for_rect (GdkDisplay *display, for (i = 0; i < g_list_model_get_n_items (monitors); i++) { monitor = g_list_model_get_item (monitors, i); - gdk_monitor_get_workarea (monitor, &workarea); + get_bounds (monitor, &workarea); if (gdk_rectangle_intersect (&workarea, rect, &intersection)) { @@ -247,16 +249,35 @@ maybe_flip_position (int bounds_pos, return primary; } +GdkMonitor * +gdk_surface_get_layout_monitor (GdkSurface *surface, + GdkPopupLayout *layout, + void (*get_bounds) (GdkMonitor *monitor, + GdkRectangle *bounds)) +{ + GdkDisplay *display; + GdkRectangle root_rect; + + root_rect = *gdk_popup_layout_get_anchor_rect (layout); + gdk_surface_get_root_coords (surface->parent, + root_rect.x, + root_rect.y, + &root_rect.x, + &root_rect.y); + + display = get_display_for_surface (surface, surface->transient_for); + return get_monitor_for_rect (display, &root_rect, get_bounds); +} + void gdk_surface_layout_popup_helper (GdkSurface *surface, int width, int height, + GdkMonitor *monitor, + GdkRectangle *bounds, GdkPopupLayout *layout, GdkRectangle *out_final_rect) { - GdkDisplay *display; - GdkMonitor *monitor; - GdkRectangle bounds; GdkRectangle root_rect; GdkGravity rect_anchor; GdkGravity surface_anchor; @@ -277,10 +298,6 @@ gdk_surface_layout_popup_helper (GdkSurface *surface, &root_rect.x, &root_rect.y); - display = get_display_for_surface (surface, surface->transient_for); - monitor = get_monitor_for_rect (display, &root_rect); - gdk_monitor_get_workarea (monitor, &bounds); - rect_anchor = gdk_popup_layout_get_rect_anchor (layout); surface_anchor = gdk_popup_layout_get_surface_anchor (layout); gdk_popup_layout_get_offset (layout, &rect_anchor_dx, &rect_anchor_dy); @@ -288,8 +305,8 @@ gdk_surface_layout_popup_helper (GdkSurface *surface, final_rect.width = width - surface->shadow_left - surface->shadow_right; final_rect.height = height - surface->shadow_top - surface->shadow_bottom; - final_rect.x = maybe_flip_position (bounds.x, - bounds.width, + final_rect.x = maybe_flip_position (bounds->x, + bounds->width, root_rect.x, root_rect.width, final_rect.width, @@ -298,8 +315,8 @@ gdk_surface_layout_popup_helper (GdkSurface *surface, rect_anchor_dx, anchor_hints & GDK_ANCHOR_FLIP_X, &flipped_x); - final_rect.y = maybe_flip_position (bounds.y, - bounds.height, + final_rect.y = maybe_flip_position (bounds->y, + bounds->height, root_rect.y, root_rect.height, final_rect.height, @@ -311,44 +328,44 @@ gdk_surface_layout_popup_helper (GdkSurface *surface, if (anchor_hints & GDK_ANCHOR_SLIDE_X) { - if (final_rect.x + final_rect.width > bounds.x + bounds.width) - final_rect.x = bounds.x + bounds.width - final_rect.width; + if (final_rect.x + final_rect.width > bounds->x + bounds->width) + final_rect.x = bounds->x + bounds->width - final_rect.width; - if (final_rect.x < bounds.x) - final_rect.x = bounds.x; + if (final_rect.x < bounds->x) + final_rect.x = bounds->x; } if (anchor_hints & GDK_ANCHOR_SLIDE_Y) { - if (final_rect.y + final_rect.height > bounds.y + bounds.height) - final_rect.y = bounds.y + bounds.height - final_rect.height; + if (final_rect.y + final_rect.height > bounds->y + bounds->height) + final_rect.y = bounds->y + bounds->height - final_rect.height; - if (final_rect.y < bounds.y) - final_rect.y = bounds.y; + if (final_rect.y < bounds->y) + final_rect.y = bounds->y; } if (anchor_hints & GDK_ANCHOR_RESIZE_X) { - if (final_rect.x < bounds.x) + if (final_rect.x < bounds->x) { - final_rect.width -= bounds.x - final_rect.x; - final_rect.x = bounds.x; + final_rect.width -= bounds->x - final_rect.x; + final_rect.x = bounds->x; } - if (final_rect.x + final_rect.width > bounds.x + bounds.width) - final_rect.width = bounds.x + bounds.width - final_rect.x; + if (final_rect.x + final_rect.width > bounds->x + bounds->width) + final_rect.width = bounds->x + bounds->width - final_rect.x; } if (anchor_hints & GDK_ANCHOR_RESIZE_Y) { - if (final_rect.y < bounds.y) + if (final_rect.y < bounds->y) { - final_rect.height -= bounds.y - final_rect.y; - final_rect.y = bounds.y; + final_rect.height -= bounds->y - final_rect.y; + final_rect.y = bounds->y; } - if (final_rect.y + final_rect.height > bounds.y + bounds.height) - final_rect.height = bounds.y + bounds.height - final_rect.y; + if (final_rect.y + final_rect.height > bounds->y + bounds->height) + final_rect.height = bounds->y + bounds->height - final_rect.y; } final_rect.x -= surface->shadow_left; diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h index 55febf1dce..c9410f506e 100644 --- a/gdk/gdksurfaceprivate.h +++ b/gdk/gdksurfaceprivate.h @@ -174,9 +174,16 @@ struct _GdkSurfaceClass void gdk_surface_set_state (GdkSurface *surface, GdkSurfaceState new_state); +GdkMonitor * gdk_surface_get_layout_monitor (GdkSurface *surface, + GdkPopupLayout *layout, + void (*get_bounds) (GdkMonitor *monitor, + GdkRectangle *bounds)); + void gdk_surface_layout_popup_helper (GdkSurface *surface, int width, int height, + GdkMonitor *monitor, + GdkRectangle *bounds, GdkPopupLayout *layout, GdkRectangle *out_final_rect); diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c index f226e9443c..fba5d9b094 100644 --- a/gdk/macos/GdkMacosWindow.c +++ b/gdk/macos/GdkMacosWindow.c @@ -352,8 +352,8 @@ monitor = _gdk_macos_display_get_monitor_at_display_coords ([self gdkDisplay], currentLocation.x, currentLocation.y); - gdk_monitor_get_geometry (monitor, &geometry); - gdk_monitor_get_workarea (monitor, &workarea); + gdk_macos_monitor_get_geometry (monitor, &geometry); + gdk_macos_monitor_get_workarea (monitor, &workarea); _edge_snapping_set_monitor (&self->snapping, &geometry, &workarea); /* Convert origins to GDK coordinates */ @@ -424,7 +424,7 @@ monitor = _gdk_macos_surface_get_best_monitor ([self gdkSurface]); gdk_monitor_get_geometry (monitor, &geometry); - gdk_monitor_get_workarea (monitor, &workarea); + gdk_macos_monitor_get_workarea (monitor, &workarea); initialMoveLocation = [NSEvent mouseLocation]; diff --git a/gdk/macos/gdkmacosmonitor.c b/gdk/macos/gdkmacosmonitor.c index 91a85a0dfa..fdeadadcea 100644 --- a/gdk/macos/gdkmacosmonitor.c +++ b/gdk/macos/gdkmacosmonitor.c @@ -41,7 +41,18 @@ struct _GdkMacosMonitorClass G_DEFINE_TYPE (GdkMacosMonitor, gdk_macos_monitor, GDK_TYPE_MONITOR) -static void +/** + * gdk_macos_monitor_get_workarea: + * @monitor: a #GdkMonitor + * @workarea: (out): a #GdkRectangle to be filled with + * the monitor workarea + * + * Retrieves the size and position of the “work area” on a monitor + * within the display coordinate space. The returned geometry is in + * ”application pixels”, not in ”device pixels” (see + * gdk_monitor_get_scale_factor()). + */ +void gdk_macos_monitor_get_workarea (GdkMonitor *monitor, GdkRectangle *geometry) { @@ -71,9 +82,6 @@ gdk_macos_monitor_get_workarea (GdkMonitor *monitor, static void gdk_macos_monitor_class_init (GdkMacosMonitorClass *klass) { - GdkMonitorClass *monitor_class = GDK_MONITOR_CLASS (klass); - - monitor_class->get_workarea = gdk_macos_monitor_get_workarea; } static void diff --git a/gdk/macos/gdkmacosmonitor.h b/gdk/macos/gdkmacosmonitor.h index 64b91f887e..7be6e5ea28 100644 --- a/gdk/macos/gdkmacosmonitor.h +++ b/gdk/macos/gdkmacosmonitor.h @@ -38,6 +38,9 @@ typedef struct _GdkMacosMonitorClass GdkMacosMonitorClass; GDK_AVAILABLE_IN_ALL GType gdk_macos_monitor_get_type (void); +void gdk_macos_monitor_get_workarea (GdkMonitor *monitor, + GdkRectangle *geometry); + G_END_DECLS #endif /* __GDK_MACOS_MONITOR_H__ */ diff --git a/gdk/macos/gdkmacospopupsurface.c b/gdk/macos/gdkmacospopupsurface.c index 520a717dfc..37bee532ca 100644 --- a/gdk/macos/gdkmacospopupsurface.c +++ b/gdk/macos/gdkmacospopupsurface.c @@ -45,6 +45,8 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self, int height, GdkPopupLayout *layout) { + GdkMonitor *monitor; + GdkRectangle bounds; GdkRectangle final_rect; int x, y; @@ -58,9 +60,15 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self, self->layout = gdk_popup_layout_ref (layout); } + monitor = gdk_surface_get_layout_monitor (surface, layout, + gdk_macos_monitor_get_workarea); + gdk_macos_monitor_get_workarea (monitor, &bounds); + gdk_surface_layout_popup_helper (GDK_SURFACE (self), width, height, + monitor, + &bounds, layout, &final_rect); diff --git a/gdk/macos/gdkmacostoplevelsurface.c b/gdk/macos/gdkmacostoplevelsurface.c index 8407636774..a399150fe0 100644 --- a/gdk/macos/gdkmacostoplevelsurface.c +++ b/gdk/macos/gdkmacostoplevelsurface.c @@ -173,7 +173,7 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel, { GdkRectangle visible; - gdk_monitor_get_workarea (monitor, &visible); + gdk_macos_monitor_get_workarea (monitor, &visible); if (x < visible.x) x = visible.x; diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 27e094d535..9b196bf3da 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -227,8 +227,8 @@ _gdk_win32_display_init_monitors (GdkWin32Display *win32_display) primary_to_move = w32_ex_monitor; gdk_monitor_get_geometry (m, &geometry); - gdk_monitor_get_workarea (m, &workarea); - gdk_monitor_get_workarea (ex_monitor, &ex_workarea); + gdk_win32_monitor_get_workarea (m, &workarea); + gdk_win32_monitor_get_workarea (ex_monitor, &ex_workarea); if (memcmp (&workarea, &ex_workarea, sizeof (GdkRectangle)) != 0) { diff --git a/gdk/win32/gdkmonitor-win32.c b/gdk/win32/gdkmonitor-win32.c index 9452f0f33b..0f02bef14f 100644 --- a/gdk/win32/gdkmonitor-win32.c +++ b/gdk/win32/gdkmonitor-win32.c @@ -851,7 +851,18 @@ _gdk_win32_monitor_compare (GdkWin32Monitor *a, return a == b ? 0 : a < b ? -1 : 1; } -static void +/** + * gdk_win32_monitor_get_workarea: + * @monitor: a #GdkMonitor + * @workarea: (out): a #GdkRectangle to be filled with + * the monitor workarea + * + * Retrieves the size and position of the “work area” on a monitor + * within the display coordinate space. The returned geometry is in + * ”application pixels”, not in ”device pixels” (see + * gdk_monitor_get_scale_factor()). + */ +void gdk_win32_monitor_get_workarea (GdkMonitor *monitor, GdkRectangle *dest) { @@ -869,6 +880,4 @@ static void gdk_win32_monitor_class_init (GdkWin32MonitorClass *class) { G_OBJECT_CLASS (class)->finalize = gdk_win32_monitor_finalize; - - GDK_MONITOR_CLASS (class)->get_workarea = gdk_win32_monitor_get_workarea; } diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index ad96754187..4ae96c7c62 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -1293,12 +1293,20 @@ gdk_win32_surface_layout_popup (GdkSurface *surface, int height, GdkPopupLayout *layout) { + GdkMonitor *monitor; + GdkRectangle bounds; GdkRectangle final_rect; int x, y; + monitor = gdk_surface_get_layout_monitor (surface, layout, + gdk_win32_monitor_get_workarea); + gdk_win32_monitor_get_workarea (monitor, &bounds); + gdk_surface_layout_popup_helper (surface, width, height, + monitor, + &bounds, layout, &final_rect); @@ -2078,7 +2086,7 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context) monitor = g_list_model_get_item (monitors, monitor_idx); g_object_unref (monitors); - gdk_monitor_get_workarea (monitor, &wa); + gdk_win32_monitor_get_workarea (monitor, &wa); gdk_monitor_get_geometry (monitor, &geometry); for (other_monitor_idx = 0; @@ -2095,7 +2103,7 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context) other_monitor = g_list_model_get_item (monitors, other_monitor_idx); g_object_unref (other_monitor); - gdk_monitor_get_workarea (other_monitor, &other_wa); + gdk_win32_monitor_get_workarea (other_monitor, &other_wa); /* An edge triggers AeroSnap only if there are no * monitors beyond that edge. @@ -2239,7 +2247,7 @@ unsnap (GdkSurface *window, if (impl->snap_stash == NULL) return; - gdk_monitor_get_workarea (monitor, &rect); + gdk_win32_monitor_get_workarea (monitor, &rect); GDK_NOTE (MISC, g_print ("Monitor work area %d x %d @ %d : %d\n", rect.width, rect.height, rect.x, rect.y)); @@ -2416,7 +2424,7 @@ snap_left (GdkSurface *window, impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFLEFT; - gdk_monitor_get_workarea (snap_monitor, &rect); + gdk_win32_monitor_get_workarea (snap_monitor, &rect); stash_window (window, impl); @@ -2444,7 +2452,7 @@ snap_right (GdkSurface *window, impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT; - gdk_monitor_get_workarea (snap_monitor, &rect); + gdk_win32_monitor_get_workarea (snap_monitor, &rect); stash_window (window, impl); @@ -3207,7 +3215,7 @@ start_indicator (GdkSurface *window, display = gdk_surface_get_display (window); monitor = get_monitor_at_point (display, x, y); - gdk_monitor_get_workarea (monitor, &workarea); + gdk_win32_monitor_get_workarea (monitor, &workarea); maxysize = GetSystemMetrics (SM_CYVIRTUALSCREEN) / impl->surface_scale; start_size.x = start_size.y = 0; diff --git a/gdk/win32/gdkwin32monitor.h b/gdk/win32/gdkwin32monitor.h index 873ab8026e..cbbf246f3e 100644 --- a/gdk/win32/gdkwin32monitor.h +++ b/gdk/win32/gdkwin32monitor.h @@ -45,6 +45,9 @@ typedef struct _GdkWin32MonitorClass GdkWin32MonitorClass; GDK_AVAILABLE_IN_ALL GType gdk_win32_monitor_get_type (void) G_GNUC_CONST; +void gdk_win32_monitor_get_workarea (GdkMonitor *monitor, + GdkRectangle *workarea); + G_END_DECLS #endif /* __GDK_WIN32_MONITOR_H__ */ diff --git a/gdk/x11/gdkmonitor-x11.c b/gdk/x11/gdkmonitor-x11.c index 2cb57501ed..8d7a4e5807 100644 --- a/gdk/x11/gdkmonitor-x11.c +++ b/gdk/x11/gdkmonitor-x11.c @@ -61,7 +61,18 @@ gdk_monitor_has_fullscreen_window (GdkMonitor *monitor) return has_fullscreen; } -static void +/** + * gdk_x11_monitor_get_workarea: + * @monitor: a #GdkMonitor + * @workarea: (out): a #GdkRectangle to be filled with + * the monitor workarea + * + * Retrieves the size and position of the “work area” on a monitor + * within the display coordinate space. The returned geometry is in + * ”application pixels”, not in ”device pixels” (see + * gdk_monitor_get_scale_factor()). + */ +void gdk_x11_monitor_get_workarea (GdkMonitor *monitor, GdkRectangle *dest) { @@ -101,7 +112,6 @@ gdk_x11_monitor_init (GdkX11Monitor *monitor) static void gdk_x11_monitor_class_init (GdkX11MonitorClass *class) { - GDK_MONITOR_CLASS (class)->get_workarea = gdk_x11_monitor_get_workarea; } XID diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index 6a96389040..bfc0b2c80f 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -584,7 +584,6 @@ init_randr15 (GdkX11Screen *x11_screen) newgeo.height = rr_monitors[i].height / x11_screen->surface_scale; 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, rr_monitors[i].mheight); @@ -734,7 +733,6 @@ init_randr13 (GdkX11Screen *x11_screen) newgeo.height = crtc->height / x11_screen->surface_scale; 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, output_info->mm_height); @@ -842,7 +840,6 @@ init_no_multihead (GdkX11Screen *x11_screen) height = HeightOfScreen (x11_screen->xscreen); 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); diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 95f340bc70..385a5c0ccd 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -1534,12 +1534,20 @@ gdk_x11_surface_layout_popup (GdkSurface *surface, int height, GdkPopupLayout *layout) { + GdkMonitor *monitor; + GdkRectangle bounds; GdkRectangle final_rect; int x, y; + monitor = gdk_surface_get_layout_monitor (surface, layout, + gdk_x11_monitor_get_workarea); + gdk_x11_monitor_get_workarea (monitor, &bounds); + gdk_surface_layout_popup_helper (surface, width, height, + monitor, + &bounds, layout, &final_rect); diff --git a/gdk/x11/gdkx11monitor.h b/gdk/x11/gdkx11monitor.h index cd0a8d9565..ddfa8a3f61 100644 --- a/gdk/x11/gdkx11monitor.h +++ b/gdk/x11/gdkx11monitor.h @@ -43,6 +43,10 @@ GType gdk_x11_monitor_get_type (void) G_GNUC_CONST; GDK_AVAILABLE_IN_ALL XID gdk_x11_monitor_get_output (GdkMonitor *monitor); +GDK_AVAILABLE_IN_ALL +void gdk_x11_monitor_get_workarea (GdkMonitor *monitor, + GdkRectangle *workarea); + G_END_DECLS #endif /* __GDK_X11_MONITOR_H__ */ diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index afd7f12c40..80dde36493 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4023,7 +4023,7 @@ gtk_window_guess_default_size (GtkWindow *window, GdkSurface *surface; GdkDisplay *display; GdkMonitor *monitor; - GdkRectangle workarea; + GdkRectangle geometry; int minimum, natural; widget = GTK_WIDGET (window); @@ -4033,25 +4033,25 @@ gtk_window_guess_default_size (GtkWindow *window, if (surface) { monitor = gdk_display_get_monitor_at_surface (display, surface); - gdk_monitor_get_workarea (monitor, &workarea); + gdk_monitor_get_geometry (monitor, &geometry); } else { monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0); if (monitor) { - gdk_monitor_get_workarea (monitor, &workarea); + gdk_monitor_get_geometry (monitor, &geometry); g_object_unref (monitor); } else { - workarea.width = G_MAXINT; - workarea.height = G_MAXINT; + geometry.width = G_MAXINT; + geometry.height = G_MAXINT; } } - *width = workarea.width; - *height = workarea.height; + *width = geometry.width; + *height = geometry.height; if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT) { diff --git a/testsuite/gtk/defaultvalue.c b/testsuite/gtk/defaultvalue.c index d1bb4739bc..4947dac52f 100644 --- a/testsuite/gtk/defaultvalue.c +++ b/testsuite/gtk/defaultvalue.c @@ -200,8 +200,7 @@ test_type (gconstpointer data) continue; if (g_type_is_a (type, GDK_TYPE_MONITOR) && - (strcmp (pspec->name, "geometry") == 0 || - strcmp (pspec->name, "workarea") == 0)) + (strcmp (pspec->name, "geometry") == 0)) continue; if (g_type_is_a (type, GTK_TYPE_ABOUT_DIALOG) &&