Commit c7c71137 authored by Jonas Ådahl's avatar Jonas Ådahl
Browse files

gdk/monitor: Remove gdk_monitor_work_area and GdkMonitor::work-area

It's not a portable API, so remove it. The corresponding backend
specific functions are still available, if they were implemented, e.g.
gdk_macos_monitor_get_workarea() and gdk_x11_monitor_get_workarea().
parent ec346750
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -48,9 +48,6 @@ struct _GdkMonitor {
struct _GdkMonitorClass {
GObjectClass parent_class;
void (* get_workarea) (GdkMonitor *monitor,
GdkRectangle *geometry);
};
GdkMonitor * gdk_monitor_new (GdkDisplay *display);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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];
......
......@@ -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
......
......@@ -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__ */
......@@ -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);
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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;
}
......@@ -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;
......
......@@ -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__ */
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment