Merge branch 'wip/fl/fullscreen-selected-monitor-macos' into 'main'
gdk: Implement fullscreen on selected monitor on macos See merge request GNOME/gtk!7384
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user