Move the resizepopup to a compositor-side feature
This is the last big feature that requires X11 on Wayland, so let's just trash it and make GNOME Shell reimplement it.
This commit is contained in:
parent
57af975154
commit
2dd1f37820
@ -198,8 +198,6 @@ libmutter_la_SOURCES = \
|
|||||||
ui/ui.h \
|
ui/ui.h \
|
||||||
ui/frames.c \
|
ui/frames.c \
|
||||||
ui/frames.h \
|
ui/frames.h \
|
||||||
ui/resizepopup.c \
|
|
||||||
ui/resizepopup.h \
|
|
||||||
ui/theme.c \
|
ui/theme.c \
|
||||||
meta/theme.h \
|
meta/theme.h \
|
||||||
ui/theme-private.h \
|
ui/theme-private.h \
|
||||||
|
@ -478,6 +478,12 @@ gboolean meta_display_show_restart_message (MetaDisplay *display,
|
|||||||
const char *message);
|
const char *message);
|
||||||
gboolean meta_display_request_restart (MetaDisplay *display);
|
gboolean meta_display_request_restart (MetaDisplay *display);
|
||||||
|
|
||||||
|
gboolean meta_display_show_resize_popup (MetaDisplay *display,
|
||||||
|
gboolean show,
|
||||||
|
MetaRectangle *rect,
|
||||||
|
int display_w,
|
||||||
|
int display_h);
|
||||||
|
|
||||||
void meta_restart_init (void);
|
void meta_restart_init (void);
|
||||||
void meta_restart_finish (void);
|
void meta_restart_finish (void);
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ enum
|
|||||||
GRAB_OP_END,
|
GRAB_OP_END,
|
||||||
SHOW_RESTART_MESSAGE,
|
SHOW_RESTART_MESSAGE,
|
||||||
RESTART,
|
RESTART,
|
||||||
|
SHOW_RESIZE_POPUP,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -329,6 +330,16 @@ meta_display_class_init (MetaDisplayClass *klass)
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_TYPE_BOOLEAN, 0);
|
G_TYPE_BOOLEAN, 0);
|
||||||
|
|
||||||
|
display_signals[SHOW_RESIZE_POPUP] =
|
||||||
|
g_signal_new ("show-resize-popup",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
g_signal_accumulator_true_handled,
|
||||||
|
NULL, NULL,
|
||||||
|
G_TYPE_BOOLEAN, 4,
|
||||||
|
G_TYPE_BOOLEAN, META_TYPE_RECTANGLE, G_TYPE_INT, G_TYPE_INT);
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
g_object_class_install_property (object_class,
|
||||||
PROP_FOCUS_WINDOW,
|
PROP_FOCUS_WINDOW,
|
||||||
g_param_spec_object ("focus-window",
|
g_param_spec_object ("focus-window",
|
||||||
@ -3018,6 +3029,22 @@ meta_display_request_restart (MetaDisplay *display)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_display_show_resize_popup (MetaDisplay *display,
|
||||||
|
gboolean show,
|
||||||
|
MetaRectangle *rect,
|
||||||
|
int display_w,
|
||||||
|
int display_h)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
g_signal_emit (display,
|
||||||
|
display_signals[SHOW_RESIZE_POPUP], 0,
|
||||||
|
show, rect, display_w, display_h, &result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_display_is_pointer_emulating_sequence:
|
* meta_display_is_pointer_emulating_sequence:
|
||||||
* @display: the display
|
* @display: the display
|
||||||
|
@ -1,238 +0,0 @@
|
|||||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
||||||
|
|
||||||
/* Metacity resizing-terminal-window feedback */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2001 Havoc Pennington
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
#include "resizepopup.h"
|
|
||||||
#include "util-private.h"
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
|
|
||||||
struct _MetaResizePopup
|
|
||||||
{
|
|
||||||
GtkWidget *size_window;
|
|
||||||
GtkWidget *size_label;
|
|
||||||
Display *display;
|
|
||||||
int screen_number;
|
|
||||||
|
|
||||||
int vertical_size;
|
|
||||||
int horizontal_size;
|
|
||||||
|
|
||||||
gboolean showing;
|
|
||||||
|
|
||||||
MetaRectangle rect;
|
|
||||||
};
|
|
||||||
|
|
||||||
MetaResizePopup*
|
|
||||||
meta_ui_resize_popup_new (Display *display,
|
|
||||||
int screen_number)
|
|
||||||
{
|
|
||||||
MetaResizePopup *popup;
|
|
||||||
|
|
||||||
popup = g_new0 (MetaResizePopup, 1);
|
|
||||||
|
|
||||||
popup->display = display;
|
|
||||||
popup->screen_number = screen_number;
|
|
||||||
|
|
||||||
return popup;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_ui_resize_popup_free (MetaResizePopup *popup)
|
|
||||||
{
|
|
||||||
g_return_if_fail (popup != NULL);
|
|
||||||
|
|
||||||
if (popup->size_window)
|
|
||||||
gtk_widget_destroy (popup->size_window);
|
|
||||||
|
|
||||||
g_free (popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
size_window_draw (GtkWidget *widget,
|
|
||||||
cairo_t *cr,
|
|
||||||
MetaResizePopup *popup)
|
|
||||||
{
|
|
||||||
GtkStyleContext *context;
|
|
||||||
gint width, height;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
|
||||||
width = gtk_widget_get_allocated_width (widget);
|
|
||||||
height = gtk_widget_get_allocated_height (widget);
|
|
||||||
|
|
||||||
gtk_render_background (context, cr, 0, 0, width, height);
|
|
||||||
gtk_render_frame (context, cr, 0, 0, width, height);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ensure_size_window (MetaResizePopup *popup)
|
|
||||||
{
|
|
||||||
GdkVisual *visual;
|
|
||||||
GdkScreen *screen;
|
|
||||||
|
|
||||||
if (popup->size_window)
|
|
||||||
return;
|
|
||||||
|
|
||||||
popup->size_window = gtk_window_new (GTK_WINDOW_POPUP);
|
|
||||||
screen = gdk_display_get_screen (gdk_x11_lookup_xdisplay (popup->display),
|
|
||||||
popup->screen_number);
|
|
||||||
visual = gdk_screen_get_rgba_visual (screen);
|
|
||||||
|
|
||||||
gtk_window_set_screen (GTK_WINDOW (popup->size_window), screen);
|
|
||||||
if (visual != NULL)
|
|
||||||
gtk_widget_set_visual (popup->size_window, visual);
|
|
||||||
|
|
||||||
gtk_window_set_type_hint (GTK_WINDOW (popup->size_window),
|
|
||||||
GDK_WINDOW_TYPE_HINT_TOOLTIP);
|
|
||||||
gtk_window_set_resizable (GTK_WINDOW (popup->size_window), FALSE);
|
|
||||||
|
|
||||||
gtk_widget_set_app_paintable (popup->size_window, TRUE);
|
|
||||||
gtk_style_context_add_class (gtk_widget_get_style_context (popup->size_window),
|
|
||||||
GTK_STYLE_CLASS_TOOLTIP);
|
|
||||||
g_signal_connect (popup->size_window, "draw",
|
|
||||||
G_CALLBACK (size_window_draw), popup);
|
|
||||||
|
|
||||||
popup->size_label = gtk_label_new ("");
|
|
||||||
g_object_set (popup->size_label, "margin", 6, NULL);
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (popup->size_window), popup->size_label);
|
|
||||||
|
|
||||||
gtk_widget_show (popup->size_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
update_size_window (MetaResizePopup *popup)
|
|
||||||
{
|
|
||||||
char *str;
|
|
||||||
int x, y;
|
|
||||||
int width, height;
|
|
||||||
|
|
||||||
g_return_if_fail (popup->size_window != NULL);
|
|
||||||
|
|
||||||
/* Translators: This represents the size of a window. The first number is
|
|
||||||
* the width of the window and the second is the height.
|
|
||||||
*/
|
|
||||||
str = g_strdup_printf (_("%d x %d"),
|
|
||||||
popup->horizontal_size,
|
|
||||||
popup->vertical_size);
|
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (popup->size_label), str);
|
|
||||||
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
gtk_window_get_size (GTK_WINDOW (popup->size_window), &width, &height);
|
|
||||||
|
|
||||||
x = popup->rect.x + (popup->rect.width - width) / 2;
|
|
||||||
y = popup->rect.y + (popup->rect.height - height) / 2;
|
|
||||||
|
|
||||||
if (gtk_widget_get_realized (popup->size_window))
|
|
||||||
{
|
|
||||||
/* using move_resize to avoid jumpiness */
|
|
||||||
gdk_window_move_resize (gtk_widget_get_window (popup->size_window),
|
|
||||||
x, y,
|
|
||||||
width, height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_window_move (GTK_WINDOW (popup->size_window),
|
|
||||||
x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
sync_showing (MetaResizePopup *popup)
|
|
||||||
{
|
|
||||||
if (popup->showing)
|
|
||||||
{
|
|
||||||
if (popup->size_window)
|
|
||||||
gtk_widget_show (popup->size_window);
|
|
||||||
|
|
||||||
if (popup->size_window && gtk_widget_get_realized (popup->size_window))
|
|
||||||
gdk_window_raise (gtk_widget_get_window (popup->size_window));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (popup->size_window)
|
|
||||||
gtk_widget_hide (popup->size_window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_ui_resize_popup_set (MetaResizePopup *popup,
|
|
||||||
MetaRectangle rect,
|
|
||||||
int base_width,
|
|
||||||
int base_height,
|
|
||||||
int width_inc,
|
|
||||||
int height_inc)
|
|
||||||
{
|
|
||||||
gboolean need_update_size;
|
|
||||||
int display_w, display_h;
|
|
||||||
|
|
||||||
g_return_if_fail (popup != NULL);
|
|
||||||
|
|
||||||
need_update_size = FALSE;
|
|
||||||
|
|
||||||
display_w = rect.width - base_width;
|
|
||||||
if (width_inc > 0)
|
|
||||||
display_w /= width_inc;
|
|
||||||
|
|
||||||
display_h = rect.height - base_height;
|
|
||||||
if (height_inc > 0)
|
|
||||||
display_h /= height_inc;
|
|
||||||
|
|
||||||
if (!meta_rectangle_equal(&popup->rect, &rect) ||
|
|
||||||
display_w != popup->horizontal_size ||
|
|
||||||
display_h != popup->vertical_size)
|
|
||||||
need_update_size = TRUE;
|
|
||||||
|
|
||||||
popup->rect = rect;
|
|
||||||
popup->vertical_size = display_h;
|
|
||||||
popup->horizontal_size = display_w;
|
|
||||||
|
|
||||||
if (need_update_size)
|
|
||||||
{
|
|
||||||
ensure_size_window (popup);
|
|
||||||
update_size_window (popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_showing (popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_ui_resize_popup_set_showing (MetaResizePopup *popup,
|
|
||||||
gboolean showing)
|
|
||||||
{
|
|
||||||
g_return_if_fail (popup != NULL);
|
|
||||||
|
|
||||||
if (showing == popup->showing)
|
|
||||||
return;
|
|
||||||
|
|
||||||
popup->showing = !!showing;
|
|
||||||
|
|
||||||
if (popup->showing)
|
|
||||||
{
|
|
||||||
ensure_size_window (popup);
|
|
||||||
update_size_window (popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_showing (popup);
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
||||||
|
|
||||||
/* Mutter resizing-terminal-window feedback */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2001 Havoc Pennington
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef META_RESIZEPOPUP_H
|
|
||||||
#define META_RESIZEPOPUP_H
|
|
||||||
|
|
||||||
/* Don't include gtk.h or gdk.h here */
|
|
||||||
#include <meta/boxes.h>
|
|
||||||
#include <meta/common.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
||||||
|
|
||||||
typedef struct _MetaResizePopup MetaResizePopup;
|
|
||||||
|
|
||||||
MetaResizePopup* meta_ui_resize_popup_new (Display *display,
|
|
||||||
int screen_number);
|
|
||||||
void meta_ui_resize_popup_free (MetaResizePopup *popup);
|
|
||||||
void meta_ui_resize_popup_set (MetaResizePopup *popup,
|
|
||||||
MetaRectangle rect,
|
|
||||||
int base_width,
|
|
||||||
int base_height,
|
|
||||||
int width_inc,
|
|
||||||
int height_inc);
|
|
||||||
void meta_ui_resize_popup_set_showing (MetaResizePopup *popup,
|
|
||||||
gboolean showing);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include "window-private.h"
|
#include "window-private.h"
|
||||||
#include "x11/iconcache.h"
|
#include "x11/iconcache.h"
|
||||||
#include "ui/resizepopup.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ struct _MetaWindowX11Private
|
|||||||
/* Requested geometry */
|
/* Requested geometry */
|
||||||
int border_width;
|
int border_width;
|
||||||
|
|
||||||
MetaResizePopup *grab_resize_popup;
|
gboolean showing_resize_popup;
|
||||||
|
|
||||||
/* These are in server coordinates. If we have a frame, it's
|
/* These are in server coordinates. If we have a frame, it's
|
||||||
* relative to the frame. */
|
* relative to the frame. */
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include "window-private.h"
|
#include "window-private.h"
|
||||||
#include "window-props.h"
|
#include "window-props.h"
|
||||||
#include "xprops.h"
|
#include "xprops.h"
|
||||||
#include "resizepopup.h"
|
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "workspace-private.h"
|
#include "workspace-private.h"
|
||||||
|
|
||||||
@ -831,18 +830,28 @@ meta_window_refresh_resize_popup (MetaWindow *window)
|
|||||||
{
|
{
|
||||||
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
||||||
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
||||||
MetaRectangle rect;
|
|
||||||
|
|
||||||
meta_window_get_client_root_coords (window, &rect);
|
if (priv->showing_resize_popup)
|
||||||
|
{
|
||||||
|
MetaRectangle rect;
|
||||||
|
int display_w, display_h;
|
||||||
|
|
||||||
meta_ui_resize_popup_set (priv->grab_resize_popup,
|
meta_window_get_client_root_coords (window, &rect);
|
||||||
rect,
|
|
||||||
window->size_hints.base_width,
|
|
||||||
window->size_hints.base_height,
|
|
||||||
window->size_hints.width_inc,
|
|
||||||
window->size_hints.height_inc);
|
|
||||||
|
|
||||||
meta_ui_resize_popup_set_showing (priv->grab_resize_popup, TRUE);
|
display_w = (rect.width - window->size_hints.base_width);
|
||||||
|
if (window->size_hints.width_inc > 0)
|
||||||
|
display_w /= window->size_hints.width_inc;
|
||||||
|
|
||||||
|
display_h = (rect.height - window->size_hints.base_height);
|
||||||
|
if (window->size_hints.height_inc > 0)
|
||||||
|
display_h /= window->size_hints.height_inc;
|
||||||
|
|
||||||
|
meta_display_show_resize_popup (window->display, TRUE, &rect, display_w, display_h);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta_display_show_resize_popup (window->display, FALSE, NULL, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -859,8 +868,7 @@ meta_window_x11_grab_op_began (MetaWindow *window,
|
|||||||
|
|
||||||
if (window->size_hints.width_inc > 1 || window->size_hints.height_inc > 1)
|
if (window->size_hints.width_inc > 1 || window->size_hints.height_inc > 1)
|
||||||
{
|
{
|
||||||
priv->grab_resize_popup = meta_ui_resize_popup_new (window->display->xdisplay,
|
priv->showing_resize_popup = TRUE;
|
||||||
window->screen->number);
|
|
||||||
meta_window_refresh_resize_popup (window);
|
meta_window_refresh_resize_popup (window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -875,10 +883,10 @@ meta_window_x11_grab_op_ended (MetaWindow *window,
|
|||||||
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
||||||
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
||||||
|
|
||||||
if (priv->grab_resize_popup)
|
if (priv->showing_resize_popup)
|
||||||
{
|
{
|
||||||
meta_ui_resize_popup_free (priv->grab_resize_popup);
|
priv->showing_resize_popup = FALSE;
|
||||||
priv->grab_resize_popup = NULL;
|
meta_window_refresh_resize_popup (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
META_WINDOW_CLASS (meta_window_x11_parent_class)->grab_op_ended (window, op);
|
META_WINDOW_CLASS (meta_window_x11_parent_class)->grab_op_ended (window, op);
|
||||||
@ -1264,7 +1272,7 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
|
|||||||
if (need_configure_notify)
|
if (need_configure_notify)
|
||||||
send_configure_notify (window);
|
send_configure_notify (window);
|
||||||
|
|
||||||
if (priv->grab_resize_popup)
|
if (priv->showing_resize_popup)
|
||||||
meta_window_refresh_resize_popup (window);
|
meta_window_refresh_resize_popup (window);
|
||||||
|
|
||||||
if (frame_shape_changed)
|
if (frame_shape_changed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user