From 6466fd3aaab49d2528800a7960367a496d0ef2b2 Mon Sep 17 00:00:00 2001 From: William Wold Date: Fri, 16 Oct 2020 10:51:15 -0700 Subject: Suppress applet's default context menu for window buttons --- applets/wncklet/wayland-backend.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'applets') diff --git a/applets/wncklet/wayland-backend.c b/applets/wncklet/wayland-backend.c index e15c28d9..658eb6d3 100644 --- a/applets/wncklet/wayland-backend.c +++ b/applets/wncklet/wayland-backend.c @@ -314,6 +314,21 @@ toplevel_task_handle_clicked (GtkButton *button, ToplevelTask *task) } } +static gboolean on_toplevel_button_press (GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + /* Assume event is a button press */ + if (((GdkEventButton*)event)->button == GDK_BUTTON_SECONDARY) + { + /* Returning true for secondary clicks suppresses the applet's default context menu, + * which we do not want to show up for task buttons */ + return TRUE; + } + else + { + return FALSE; + } +} + static ToplevelTask * toplevel_task_new (TasklistManager *tasklist, struct zwlr_foreign_toplevel_handle_v1 *toplevel) { @@ -338,6 +353,12 @@ toplevel_task_new (TasklistManager *tasklist, struct zwlr_foreign_toplevel_handl toplevel_task_key, task, (GDestroyNotify)toplevel_task_disconnected_from_widget); + + g_signal_connect (G_OBJECT (task->button), + "button-press-event", + G_CALLBACK (on_toplevel_button_press), + task); + return task; } -- cgit v1.2.1