mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 13:30:19 +00:00
Change the fullscreen-on-monitor api
Use GdkMonitor here, since that is our primary monitor object now, and GdkScreen is going away.
This commit is contained in:
parent
f2655b055d
commit
606345cbaa
@ -6769,13 +6769,13 @@ gdk_window_fullscreen (GdkWindow *window)
|
||||
* Since: UNRELEASED
|
||||
**/
|
||||
void
|
||||
gdk_window_fullscreen_on_monitor (GdkWindow *window,
|
||||
gint monitor)
|
||||
gdk_window_fullscreen_on_monitor (GdkWindow *window,
|
||||
GdkMonitor *monitor)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
|
||||
g_return_if_fail (monitor >= 0);
|
||||
g_return_if_fail (monitor < gdk_display_get_n_monitors (display));
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
g_return_if_fail (GDK_IS_MONITOR (monitor));
|
||||
g_return_if_fail (gdk_monitor_get_display (monitor) == gdk_window_get_display (window));
|
||||
g_return_if_fail (gdk_monitor_is_valid (monitor));
|
||||
|
||||
if (GDK_WINDOW_IMPL_GET_CLASS (window->impl)->fullscreen_on_monitor != NULL)
|
||||
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->fullscreen_on_monitor (window, monitor);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <gdk/gdkdrawingcontext.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
#include <gdk/gdkframeclock.h>
|
||||
#include <gdk/gdkmonitor.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -777,7 +778,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gdk_window_fullscreen (GdkWindow *window);
|
||||
GDK_AVAILABLE_IN_3_18
|
||||
void gdk_window_fullscreen_on_monitor (GdkWindow *window,
|
||||
gint monitor);
|
||||
GdkMonitor *monitor);
|
||||
GDK_AVAILABLE_IN_3_8
|
||||
void gdk_window_set_fullscreen_mode (GdkWindow *window,
|
||||
GdkFullscreenMode mode);
|
||||
|
@ -185,7 +185,8 @@ struct _GdkWindowImplClass
|
||||
void (* maximize) (GdkWindow *window);
|
||||
void (* unmaximize) (GdkWindow *window);
|
||||
void (* fullscreen) (GdkWindow *window);
|
||||
void (* fullscreen_on_monitor) (GdkWindow *window, gint monitor);
|
||||
void (* fullscreen_on_monitor) (GdkWindow *window,
|
||||
GdkMonitor *monitor);
|
||||
void (* apply_fullscreen_mode) (GdkWindow *window);
|
||||
void (* unfullscreen) (GdkWindow *window);
|
||||
void (* set_keep_above) (GdkWindow *window,
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkmonitor-wayland.h"
|
||||
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -168,7 +169,7 @@ struct _GdkWindowImplWayland
|
||||
int margin_bottom;
|
||||
gboolean margin_dirty;
|
||||
|
||||
int initial_fullscreen_monitor;
|
||||
struct wl_output *initial_fullscreen_output;
|
||||
|
||||
cairo_region_t *opaque_region;
|
||||
gboolean opaque_region_dirty;
|
||||
@ -249,7 +250,7 @@ static void
|
||||
_gdk_window_impl_wayland_init (GdkWindowImplWayland *impl)
|
||||
{
|
||||
impl->scale = 1;
|
||||
impl->initial_fullscreen_monitor = -1;
|
||||
impl->initial_fullscreen_output = NULL;
|
||||
impl->saved_width = -1;
|
||||
impl->saved_height = -1;
|
||||
}
|
||||
@ -1490,11 +1491,6 @@ gdk_wayland_window_create_xdg_toplevel (GdkWindow *window)
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
const gchar *app_id;
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
struct wl_output *fullscreen_output = NULL;
|
||||
if (impl->initial_fullscreen_monitor >= 0 &&
|
||||
impl->initial_fullscreen_monitor < gdk_display_get_n_monitors (display))
|
||||
fullscreen_output = _gdk_wayland_screen_get_wl_output (gdk_display_get_default_screen (gdk_window_get_display (window)), impl->initial_fullscreen_monitor);
|
||||
|
||||
impl->display_server.xdg_surface =
|
||||
zxdg_shell_v6_get_xdg_surface (display_wayland->xdg_shell,
|
||||
@ -1517,7 +1513,9 @@ gdk_wayland_window_create_xdg_toplevel (GdkWindow *window)
|
||||
zxdg_toplevel_v6_set_maximized (impl->display_server.xdg_toplevel);
|
||||
if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
|
||||
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel,
|
||||
fullscreen_output);
|
||||
impl->initial_fullscreen_output);
|
||||
|
||||
impl->initial_fullscreen_output = NULL;
|
||||
|
||||
app_id = g_get_prgname ();
|
||||
if (app_id == NULL)
|
||||
@ -3316,13 +3314,12 @@ gdk_wayland_window_unmaximize (GdkWindow *window)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_window_fullscreen_on_monitor (GdkWindow *window, gint monitor)
|
||||
gdk_wayland_window_fullscreen_on_monitor (GdkWindow *window,
|
||||
GdkMonitor *monitor)
|
||||
{
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
GdkScreen *screen = gdk_display_get_default_screen (display);
|
||||
struct wl_output *fullscreen_output =
|
||||
_gdk_wayland_screen_get_wl_output (screen, monitor);
|
||||
struct wl_output *output = ((GdkWaylandMonitor *)monitor)->output;
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (window))
|
||||
return;
|
||||
@ -3330,13 +3327,12 @@ gdk_wayland_window_fullscreen_on_monitor (GdkWindow *window, gint monitor)
|
||||
_gdk_wayland_window_save_size (window);
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
{
|
||||
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel,
|
||||
fullscreen_output);
|
||||
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel, output);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
||||
impl->initial_fullscreen_monitor = monitor;
|
||||
impl->initial_fullscreen_output = output;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3348,7 +3344,7 @@ gdk_wayland_window_fullscreen (GdkWindow *window)
|
||||
if (GDK_WINDOW_DESTROYED (window))
|
||||
return;
|
||||
|
||||
impl->initial_fullscreen_monitor = -1;
|
||||
impl->initial_fullscreen_output = NULL;
|
||||
|
||||
_gdk_wayland_window_save_size (window);
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
@ -3365,7 +3361,7 @@ gdk_wayland_window_unfullscreen (GdkWindow *window)
|
||||
if (GDK_WINDOW_DESTROYED (window))
|
||||
return;
|
||||
|
||||
impl->initial_fullscreen_monitor = -1;
|
||||
impl->initial_fullscreen_output = NULL;
|
||||
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
zxdg_toplevel_v6_unset_fullscreen (impl->display_server.xdg_toplevel);
|
||||
|
@ -3671,19 +3671,17 @@ gdk_x11_window_fullscreen (GdkWindow *window)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_window_fullscreen_on_monitor (GdkWindow *window,
|
||||
gint monitor)
|
||||
gdk_x11_window_fullscreen_on_monitor (GdkWindow *window,
|
||||
GdkMonitor *monitor)
|
||||
{
|
||||
GdkMonitor *m;
|
||||
GdkRectangle monitor_geom;
|
||||
GdkRectangle geom;
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (window) ||
|
||||
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
|
||||
return;
|
||||
|
||||
m = gdk_display_get_monitor (gdk_window_get_display (window), monitor);
|
||||
gdk_monitor_get_geometry (m, &monitor_geom);
|
||||
gdk_window_move (window, monitor_geom.x, monitor_geom.y);
|
||||
gdk_monitor_get_geometry (monitor, &geom);
|
||||
gdk_window_move (window, geom.x, geom.y);
|
||||
|
||||
gdk_window_set_fullscreen_mode (window, GDK_FULLSCREEN_ON_CURRENT_MONITOR);
|
||||
gdk_x11_window_fullscreen (window);
|
||||
|
@ -215,7 +215,7 @@ struct _GtkWindowPrivate
|
||||
GtkWidget *titlebar;
|
||||
GtkWidget *popup_menu;
|
||||
|
||||
gint initial_fullscreen_monitor;
|
||||
GdkMonitor *initial_fullscreen_monitor;
|
||||
guint edge_constraints;
|
||||
|
||||
/* The following flags are initially TRUE (before a window is mapped).
|
||||
@ -1897,7 +1897,7 @@ gtk_window_init (GtkWindow *window)
|
||||
priv->initial_timestamp = GDK_CURRENT_TIME;
|
||||
priv->mnemonics_visible = TRUE;
|
||||
priv->focus_visible = TRUE;
|
||||
priv->initial_fullscreen_monitor = -1;
|
||||
priv->initial_fullscreen_monitor = NULL;
|
||||
|
||||
g_object_ref_sink (window);
|
||||
priv->has_user_ref_count = TRUE;
|
||||
@ -6145,7 +6145,6 @@ gtk_window_map (GtkWidget *widget)
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
GtkWindowPrivate *priv = window->priv;
|
||||
GdkWindow *gdk_window;
|
||||
GdkDisplay *display;
|
||||
|
||||
if (!_gtk_widget_is_toplevel (widget))
|
||||
{
|
||||
@ -6153,10 +6152,6 @@ gtk_window_map (GtkWidget *widget)
|
||||
return;
|
||||
}
|
||||
|
||||
display = gtk_widget_get_display (widget);
|
||||
if (priv->initial_fullscreen_monitor > gdk_display_get_n_monitors (display))
|
||||
priv->initial_fullscreen_monitor = -1;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_window_parent_class)->map (widget);
|
||||
|
||||
child = gtk_bin_get_child (&(window->bin));
|
||||
@ -6187,11 +6182,10 @@ gtk_window_map (GtkWidget *widget)
|
||||
|
||||
if (priv->fullscreen_initially)
|
||||
{
|
||||
if (priv->initial_fullscreen_monitor < 0)
|
||||
gdk_window_fullscreen (gdk_window);
|
||||
if (priv->initial_fullscreen_monitor)
|
||||
gdk_window_fullscreen_on_monitor (gdk_window, priv->initial_fullscreen_monitor);
|
||||
else
|
||||
gdk_window_fullscreen_on_monitor (gdk_window,
|
||||
priv->initial_fullscreen_monitor);
|
||||
gdk_window_fullscreen (gdk_window);
|
||||
}
|
||||
else
|
||||
gdk_window_unfullscreen (gdk_window);
|
||||
@ -9581,10 +9575,22 @@ gtk_window_fullscreen (GtkWindow *window)
|
||||
gdk_window_fullscreen (toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
unset_fullscreen_monitor (GtkWindow *window)
|
||||
{
|
||||
GtkWindowPrivate *priv = window->priv;
|
||||
|
||||
if (priv->initial_fullscreen_monitor)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (priv->initial_fullscreen_monitor, unset_fullscreen_monitor, window);
|
||||
g_object_unref (priv->initial_fullscreen_monitor);
|
||||
priv->initial_fullscreen_monitor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_fullscreen_on_monitor:
|
||||
* @window: a #GtkWindow
|
||||
* @screen: a #GdkScreen to draw to
|
||||
* @monitor: which monitor to go fullscreen on
|
||||
*
|
||||
* Asks to place @window in the fullscreen state. Note that you shouldn't assume
|
||||
@ -9592,28 +9598,30 @@ gtk_window_fullscreen (GtkWindow *window)
|
||||
*
|
||||
* You can track the fullscreen state via the "window-state-event" signal
|
||||
* on #GtkWidget.
|
||||
*
|
||||
* Since: 3.18
|
||||
*/
|
||||
void
|
||||
gtk_window_fullscreen_on_monitor (GtkWindow *window,
|
||||
GdkScreen *screen,
|
||||
gint monitor)
|
||||
gtk_window_fullscreen_on_monitor (GtkWindow *window,
|
||||
GdkMonitor *monitor)
|
||||
{
|
||||
GtkWindowPrivate *priv;
|
||||
GtkWidget *widget;
|
||||
GdkWindow *toplevel;
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
g_return_if_fail (gdk_display_get_monitor (gdk_screen_get_display (screen), monitor) != NULL);
|
||||
g_return_if_fail (GDK_IS_MONITOR (monitor));
|
||||
g_return_if_fail (gdk_monitor_is_valid (monitor));
|
||||
|
||||
priv = window->priv;
|
||||
widget = GTK_WIDGET (window);
|
||||
|
||||
gtk_window_set_display (window, gdk_screen_get_display (screen));
|
||||
gtk_window_set_display (window, gdk_monitor_get_display (monitor));
|
||||
|
||||
unset_fullscreen_monitor (window);
|
||||
priv->initial_fullscreen_monitor = monitor;
|
||||
g_signal_connect_swapped (priv->initial_fullscreen_monitor, "invalidate",
|
||||
G_CALLBACK (unset_fullscreen_monitor), window);
|
||||
g_object_ref (priv->initial_fullscreen_monitor);
|
||||
|
||||
priv->fullscreen_initially = TRUE;
|
||||
|
||||
toplevel = _gtk_widget_get_window (widget);
|
||||
@ -9646,7 +9654,7 @@ gtk_window_unfullscreen (GtkWindow *window)
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
window->priv->initial_fullscreen_monitor = -1;
|
||||
unset_fullscreen_monitor (window);
|
||||
window->priv->fullscreen_initially = FALSE;
|
||||
|
||||
toplevel = _gtk_widget_get_window (GTK_WIDGET (window));
|
||||
@ -9953,8 +9961,8 @@ gtk_window_set_display (GtkWindow *window,
|
||||
return;
|
||||
|
||||
/* reset initial_fullscreen_monitor since they are relative to the screen */
|
||||
priv->initial_fullscreen_monitor = -1;
|
||||
|
||||
unset_fullscreen_monitor (window);
|
||||
|
||||
widget = GTK_WIDGET (window);
|
||||
|
||||
previous_display = priv->display;
|
||||
|
@ -363,9 +363,8 @@ void gtk_window_fullscreen (GtkWindow *window);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_unfullscreen (GtkWindow *window);
|
||||
GDK_AVAILABLE_IN_3_18
|
||||
void gtk_window_fullscreen_on_monitor(GtkWindow *window,
|
||||
GdkScreen *screen,
|
||||
gint monitor);
|
||||
void gtk_window_fullscreen_on_monitor (GtkWindow *window,
|
||||
GdkMonitor *monitor);
|
||||
GDK_AVAILABLE_IN_3_10
|
||||
void gtk_window_close (GtkWindow *window);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
Loading…
Reference in New Issue
Block a user