[gnome-applets/gnome-3-36] window-buttons: check if requested action is supported



commit b2674bce9b460392980f8a7033a52b65f56d9058
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Mar 25 23:18:35 2020 +0200

    window-buttons: check if requested action is supported
    
    https://gitlab.gnome.org/GNOME/gnome-applets/-/issues/15

 window-buttons/windowbuttons.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/window-buttons/windowbuttons.c b/window-buttons/windowbuttons.c
index 083a4a9a8..1fae6552f 100755
--- a/window-buttons/windowbuttons.c
+++ b/window-buttons/windowbuttons.c
@@ -463,26 +463,33 @@ static gboolean button_release (GtkWidget *event_box, GdkEventButton *event, WBA
        imgh = gdk_pixbuf_get_height(imgpb);
 
        if (!(event->x<0 || event->y<0 || event->x>imgw || event->y>imgh)) {
+               WnckWindowActions actions;
+
                if (wbapplet->prefs->only_maximized) {
                        controlledwindow = wbapplet->umaxedwindow;
                } else {
                        controlledwindow = wbapplet->activewindow;
                }
 
+               actions = wnck_window_get_actions (controlledwindow);
+
                switch (i) {
                        case WB_BUTTON_MINIMIZE:
-                               wnck_window_minimize(controlledwindow);
+                               if ((actions & WNCK_WINDOW_ACTION_MINIMIZE) == WNCK_WINDOW_ACTION_MINIMIZE)
+                                       wnck_window_minimize (controlledwindow);
                                break;
                        case WB_BUTTON_UMAXIMIZE:
-                               if (wnck_window_is_maximized(controlledwindow)) {
+                               if (wnck_window_is_maximized (controlledwindow) &&
+                                   (actions & WNCK_WINDOW_ACTION_UNMAXIMIZE) == 
WNCK_WINDOW_ACTION_UNMAXIMIZE) {
                                        wnck_window_unmaximize(controlledwindow);
                                        wnck_window_activate(controlledwindow, gtk_get_current_event_time()); 
// make unmaximized window active
-                               } else {
+                               } else if ((actions & WNCK_WINDOW_ACTION_MAXIMIZE) == 
WNCK_WINDOW_ACTION_MAXIMIZE) {
                                        wnck_window_maximize(controlledwindow);
                                }
                                break;
                        case WB_BUTTON_CLOSE:
-                               wnck_window_close(controlledwindow, GDK_CURRENT_TIME);
+                               if ((actions & WNCK_WINDOW_ACTION_CLOSE) == WNCK_WINDOW_ACTION_CLOSE)
+                                       wnck_window_close (controlledwindow, GDK_CURRENT_TIME);
                                break;
                }
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]