mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
gdk: Implement fullscreen on selected monitor on macos
The feature was apparently missing, as monitors were always fullscreened at the surface best monitor. Keep using best monitor if the selected monitor is not specified, otherwise move the window to the selected monitor before going fullscreen.
This commit is contained in:
parent
0b57bd5a53
commit
0ca569baab
@ -176,6 +176,7 @@ void _gdk_macos_display_set_drop (GdkMacosDisp
|
||||
GdkDrop *drop);
|
||||
void _gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface,
|
||||
GdkMonitor *monitor,
|
||||
int *x,
|
||||
int *y);
|
||||
|
||||
|
@ -82,6 +82,7 @@ has_surface_at_origin (const GList *surfaces,
|
||||
static void
|
||||
_gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface,
|
||||
GdkMonitor *selected_monitor,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
@ -95,7 +96,11 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (surface));
|
||||
|
||||
mouse = [NSEvent mouseLocation];
|
||||
monitor = _gdk_macos_display_get_monitor_at_display_coords (self, mouse.x, mouse.y);
|
||||
if (!selected_monitor)
|
||||
monitor = _gdk_macos_display_get_monitor_at_display_coords (self, mouse.x, mouse.y);
|
||||
else
|
||||
monitor = selected_monitor;
|
||||
|
||||
gdk_macos_monitor_get_workarea (monitor, &workarea);
|
||||
|
||||
/* First place at top-left of current monitor */
|
||||
@ -104,7 +109,7 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||
surface_rect.x = workarea.x + ((workarea.width - surface_rect.width) / 2);
|
||||
surface_rect.y = workarea.y + ((workarea.height - surface_rect.height) / 2);
|
||||
|
||||
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (surface->best_monitor), &surface_rect);
|
||||
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (selected_monitor ? selected_monitor : surface->best_monitor), &surface_rect);
|
||||
|
||||
*x = surface_rect.x;
|
||||
*y = surface_rect.y;
|
||||
@ -138,6 +143,7 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||
void
|
||||
_gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface,
|
||||
GdkMonitor *monitor,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
@ -151,5 +157,5 @@ _gdk_macos_display_position_surface (GdkMacosDisplay *self,
|
||||
if (transient_for != NULL)
|
||||
_gdk_macos_display_position_toplevel_with_parent (self, surface, GDK_MACOS_SURFACE (transient_for), x, y);
|
||||
else
|
||||
_gdk_macos_display_position_toplevel (self, surface, x, y);
|
||||
_gdk_macos_display_position_toplevel (self, surface, monitor, x, y);
|
||||
}
|
||||
|
@ -261,7 +261,30 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
if (gdk_toplevel_layout_get_fullscreen (layout, &fullscreen))
|
||||
{
|
||||
if (fullscreen)
|
||||
_gdk_macos_toplevel_surface_fullscreen (self);
|
||||
{
|
||||
GdkMonitor *fullscreen_monitor =
|
||||
gdk_toplevel_layout_get_fullscreen_monitor (layout);
|
||||
|
||||
if (fullscreen_monitor)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
|
||||
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (display),
|
||||
GDK_MACOS_SURFACE (self),
|
||||
fullscreen_monitor,
|
||||
&x, &y);
|
||||
|
||||
GDK_DEBUG (MISC, "Moving toplevel \"%s\" to %d,%d",
|
||||
GDK_MACOS_SURFACE (self)->title ?
|
||||
GDK_MACOS_SURFACE (self)->title :
|
||||
"untitled",
|
||||
x, y);
|
||||
|
||||
_gdk_macos_surface_move (GDK_MACOS_SURFACE (self), x, y);
|
||||
}
|
||||
|
||||
_gdk_macos_toplevel_surface_fullscreen (self);
|
||||
}
|
||||
else
|
||||
_gdk_macos_toplevel_surface_unfullscreen (self);
|
||||
}
|
||||
@ -274,6 +297,7 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
|
||||
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (display),
|
||||
GDK_MACOS_SURFACE (self),
|
||||
gdk_toplevel_layout_get_fullscreen_monitor (layout),
|
||||
&x, &y);
|
||||
|
||||
GDK_DEBUG (MISC, "Placing new toplevel \"%s\" at %d,%d",
|
||||
@ -657,6 +681,7 @@ _gdk_macos_toplevel_surface_attach_to_parent (GdkMacosToplevelSurface *self)
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
|
||||
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (surface->display),
|
||||
GDK_MACOS_SURFACE (surface),
|
||||
NULL,
|
||||
&x, &y);
|
||||
_gdk_macos_surface_move (GDK_MACOS_SURFACE (surface), x, y);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user