summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2023-01-17 16:27:17 +0800
committerzhuyaliang <zhuyaliang@[email protected]>2023-01-31 20:28:34 +0800
commitb0ac9b77ddb27324565e72b661d541249289d319 (patch)
tree67be9b56e84178e6b3d85e5be9acced7adae807a
parentdcd5d21e4c53f1670b33cec78c96bdd3da87037d (diff)
downloadmarco-remove-image-menu.tar.bz2
marco-remove-image-menu.tar.xz
Replace deprecated API and remove compilation warningsremove-image-menu
-rw-r--r--src/core/keybindings.c4
-rw-r--r--src/core/screen.c2
-rw-r--r--src/ui/menu.c120
-rw-r--r--src/ui/menu.h6
-rw-r--r--src/ui/ui.c5
5 files changed, 68 insertions, 69 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 2f782fa3..25347e75 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -198,7 +198,7 @@ reload_modmap (MetaDisplay *display)
{
if (syms[j] != 0)
{
- const char *str;
+ const char *str G_GNUC_UNUSED;
str = XKeysymToString (syms[j]);
meta_topic (META_DEBUG_KEYBINDINGS,
@@ -1284,7 +1284,7 @@ meta_display_process_key_event (MetaDisplay *display,
KeySym keysym;
gboolean keep_grab;
gboolean all_keys_grabbed;
- const char *str;
+ const char *str G_GNUC_UNUSED;
MetaScreen *screen;
XAllowEvents (display->xdisplay,
diff --git a/src/core/screen.c b/src/core/screen.c
index 99932393..316a567a 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -2739,7 +2739,7 @@ meta_screen_sn_event (SnMonitorEvent *event,
{
case SN_MONITOR_EVENT_INITIATED:
{
- const char *wmclass;
+ const char *wmclass G_GNUC_UNUSED;
wmclass = sn_startup_sequence_get_wmclass (sequence);
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 34e4b5d9..01b3e1c7 100644
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
@@ -40,7 +40,6 @@ typedef struct _MenuData MenuData;
typedef enum {
MENU_ITEM_SEPARATOR = 0,
MENU_ITEM_NORMAL,
- MENU_ITEM_IMAGE,
MENU_ITEM_CHECKBOX,
MENU_ITEM_RADIOBUTTON,
MENU_ITEM_WORKSPACE_LIST,
@@ -49,7 +48,6 @@ typedef enum {
struct _MenuItem {
MetaMenuOp op;
MetaMenuItemType type;
- const char* stock_id;
const gboolean checked;
const char* label;
};
@@ -63,66 +61,44 @@ static void activate_cb(GtkWidget* menuitem, gpointer data);
static MenuItem menuitems[] = {
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_MINIMIZE, MENU_ITEM_IMAGE, MARCO_STOCK_MINIMIZE, FALSE, N_("Mi_nimize")},
+ {META_MENU_OP_MINIMIZE, MENU_ITEM_NORMAL, FALSE, N_("Mi_nimize")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_MAXIMIZE, MENU_ITEM_IMAGE, MARCO_STOCK_MAXIMIZE, FALSE, N_("Ma_ximize")},
+ {META_MENU_OP_MAXIMIZE, MENU_ITEM_NORMAL, FALSE, N_("Ma_ximize")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_UNMAXIMIZE, MENU_ITEM_IMAGE, MARCO_STOCK_RESTORE, FALSE, N_("Unma_ximize")},
+ {META_MENU_OP_UNMAXIMIZE, MENU_ITEM_NORMAL, FALSE, N_("Unma_ximize")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_SHADE, MENU_ITEM_NORMAL, NULL, FALSE, N_("Roll _Up")},
+ {META_MENU_OP_SHADE, MENU_ITEM_NORMAL, FALSE, N_("Roll _Up")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_UNSHADE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Unroll")},
+ {META_MENU_OP_UNSHADE, MENU_ITEM_NORMAL, FALSE, N_("_Unroll")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_MOVE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Move") },
+ {META_MENU_OP_MOVE, MENU_ITEM_NORMAL, FALSE, N_("_Move") },
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_RESIZE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Resize")},
+ {META_MENU_OP_RESIZE, MENU_ITEM_NORMAL, FALSE, N_("_Resize")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_RECOVER, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move Titlebar On_screen")},
- {META_MENU_OP_WORKSPACES, MENU_ITEM_SEPARATOR, NULL, FALSE, NULL}, /* separator */
+ {META_MENU_OP_RECOVER, MENU_ITEM_NORMAL, FALSE, N_("Move Titlebar On_screen")},
+ {META_MENU_OP_WORKSPACES, MENU_ITEM_SEPARATOR, FALSE, NULL}, /* separator */
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_ABOVE, MENU_ITEM_CHECKBOX, NULL, FALSE, N_("Always on _Top")},
+ {META_MENU_OP_ABOVE, MENU_ITEM_CHECKBOX, FALSE, N_("Always on _Top")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_UNABOVE, MENU_ITEM_CHECKBOX, NULL, TRUE, N_("Always on _Top")},
+ {META_MENU_OP_UNABOVE, MENU_ITEM_CHECKBOX, TRUE, N_("Always on _Top")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_STICK, MENU_ITEM_RADIOBUTTON, NULL, FALSE, N_("_Always on Visible Workspace")},
+ {META_MENU_OP_STICK, MENU_ITEM_RADIOBUTTON, FALSE, N_("_Always on Visible Workspace")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_UNSTICK, MENU_ITEM_RADIOBUTTON, NULL, FALSE, N_("_Only on This Workspace")},
+ {META_MENU_OP_UNSTICK, MENU_ITEM_RADIOBUTTON, FALSE, N_("_Only on This Workspace")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_MOVE_LEFT, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Left")},
+ {META_MENU_OP_MOVE_LEFT, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace _Left")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_MOVE_RIGHT, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace R_ight")},
+ {META_MENU_OP_MOVE_RIGHT, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace R_ight")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_MOVE_UP, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Up")},
+ {META_MENU_OP_MOVE_UP, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace _Up")},
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_MOVE_DOWN, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Down")},
- {0, MENU_ITEM_WORKSPACE_LIST, NULL, FALSE, NULL},
- {0, MENU_ITEM_SEPARATOR, NULL, FALSE, NULL}, /* separator */
+ {META_MENU_OP_MOVE_DOWN, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace _Down")},
+ {0, MENU_ITEM_WORKSPACE_LIST, FALSE, NULL},
+ {0, MENU_ITEM_SEPARATOR, FALSE, NULL}, /* separator */
/* Translators: Translate this string the same way as you do in libwnck! */
- {META_MENU_OP_DELETE, MENU_ITEM_IMAGE, MARCO_STOCK_DELETE, FALSE, N_("_Close")}
+ {META_MENU_OP_DELETE, MENU_ITEM_NORMAL, FALSE, N_("_Close")}
};
-static void popup_position_func(GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer user_data)
-{
- GtkRequisition req;
- GdkPoint* pos;
-
- pos = user_data;
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
-
- *x = pos->x;
- *y = pos->y;
-
- if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
- {
- *x = MAX (0, *x - req.width);
- }
-
- /* Ensure onscreen */
- *x = CLAMP (*x, 0, MAX(0, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - req.width));
- *y = CLAMP (*y, 0, MAX(0, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - req.height));
-}
-
static void menu_closed(GtkMenu* widget, gpointer data)
{
MetaWindowMenu *menu;
@@ -267,15 +243,6 @@ static GtkWidget* menu_item_new(MenuItem* menuitem, int workspace_id)
{
mi = gtk_menu_item_new ();
}
- else if (menuitem->type == MENU_ITEM_IMAGE)
- {
- GtkWidget* image = gtk_image_new_from_icon_name(menuitem->stock_id, GTK_ICON_SIZE_MENU);
-
- mi = gtk_image_menu_item_new();
-
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi), image);
- gtk_widget_show(image);
- }
else if (menuitem->type == MENU_ITEM_CHECKBOX)
{
mi = gtk_check_menu_item_new ();
@@ -382,7 +349,7 @@ meta_window_menu_new (MetaFrames *frames,
MenuItem to_another_workspace = {
0, MENU_ITEM_NORMAL,
- NULL, FALSE,
+ FALSE,
N_("Move to Another _Workspace")
};
@@ -489,8 +456,43 @@ meta_window_menu_new (MetaFrames *frames,
return menu;
}
+static GdkEvent *
+menu_popup_event (gint root_x, gint root_y, guint button, guint32 timestamp,
+ GdkWindow *window)
+{
+ GdkEvent *event;
+ GdkSeat *seat;
+ GdkDevice *device;
+
+ event = gtk_get_current_event ();
+
+ if (event != NULL)
+ event = gdk_event_copy (event);
+ else
+ {
+ /* Create fake event since menu can be show without any events */
+
+ seat = gdk_display_get_default_seat (gdk_window_get_display (window));
+ device = gdk_seat_get_pointer (seat);
+
+ event = gdk_event_new (GDK_BUTTON_PRESS);
+ event->button.window = g_object_ref (window);
+ event->button.time = timestamp;
+ event->button.x = event->button.x_root = root_x;
+ event->button.y = event->button.y_root = root_y;
+ event->button.button = button;
+ event->button.device = device;
+ gdk_event_set_device (event, device);
+ }
+
+ return event;
+}
+
void meta_window_menu_popup(MetaWindowMenu* menu, int root_x, int root_y, int button, guint32 timestamp)
{
+ GdkWindow *window;
+ GdkEvent *event;
+ GdkRectangle rect;
GdkPoint* pt = g_new(GdkPoint, 1);
gint scale;
@@ -500,7 +502,15 @@ void meta_window_menu_popup(MetaWindowMenu* menu, int root_x, int root_y, int bu
pt->x = root_x / scale;
pt->y = root_y / scale;
- gtk_menu_popup(GTK_MENU (menu->menu), NULL, NULL, popup_position_func, pt, button, timestamp);
+ window = gdk_screen_get_root_window (gdk_screen_get_default ());
+ rect.x = root_x;
+ rect.y = root_y;
+ rect.width = 1;
+ rect.height = 1;
+ event = menu_popup_event (root_x, root_y, button, timestamp, window);
+ gtk_menu_popup_at_rect (GTK_MENU (menu->menu), window, &rect,
+ GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_SOUTH_WEST, event);
+ gdk_event_free (event);
if (!gtk_widget_get_visible (menu->menu))
meta_warning("GtkMenu failed to grab the pointer\n");
diff --git a/src/ui/menu.h b/src/ui/menu.h
index 7af4ad8e..83a92c06 100644
--- a/src/ui/menu.h
+++ b/src/ui/menu.h
@@ -25,12 +25,6 @@
#include <gtk/gtk.h>
#include "frames.h"
-/* Stock icons */
-#define MARCO_STOCK_DELETE "window-close"
-#define MARCO_STOCK_RESTORE "view-restore"
-#define MARCO_STOCK_MINIMIZE "go-down"
-#define MARCO_STOCK_MAXIMIZE "view-fullscreen"
-
struct _MetaWindowMenu {
MetaFrames* frames;
Window client_xwindow;
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 9976c701..ef1901b9 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -992,11 +992,6 @@ meta_ui_window_is_widget (MetaUI *ui,
/* stock icon code Copyright (C) 2002 Jorn Baayen <[email protected]> */
-typedef struct {
- char* stock_id;
- const guint8* icon_data;
-} MetaStockIcon;
-
int meta_ui_get_drag_threshold(MetaUI* ui)
{
int threshold = 8;