1

I am trying to disable the GNOME app menu (the widget on the left, to the right of the "Activities" button in the top panel), so that clicks on it go through it to the underlying panel, so one would be able to drag the window from maximized state even by clicking this button. Is it possible?

Alternatively, a better approach would be to pass a left click on it to the underlying panel. i think this should be possible as well, yet I am not familiar with the API and how I should go about it, even though I'd prefer this option.

I tried, for a starter, setting Main.panel.statusArea.appMenu.container.enabled = false and similar things, but I couldn't guess the actual name. A link to the documentation on this would be great.

After that, i figured out I could enumerate all the members of various elements, like so:

for(var propertyName in this._appMenu.container) {
    log(propertyName);
}

Though, I still haven't figured out what the property would be or where should I look.

I'd like to add the code into an extension, so JavaScript code is preferred.

Thank you very much.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Valentin Radu
  • 629
  • 1
  • 11
  • 26

1 Answers1

1

The relevant events are the button-press-event and button-release-event I found in this documentation: https://people.gnome.org/~gcampagna/docs/Clutter-1.0/Clutter.Actor.html and https://developer.gnome.org/clutter/stable/clutter-Events.html

Once I subscribed to them using:

this._wmHandlerIDs.push(Main.panel.statusArea.appMenu.actor.connect(
  'button-press-event', Lang.bind(this, this._click)
));

this._wmHandlerIDs.push(Main.panel.statusArea.appMenu.actor.connect(
  'button-release-event', Lang.bind(this, this._clicked)
));

Main._handledClick = 1; // ignore first click on the panel
Main._cancelClick = 0; // indicates if the button is still held

I could then hack my way and make the app button behave as it would be a title bar:

_click: function (actor, event) {
    if (event.get_button() == 1) {
        Main._cancelClick = 0;
        if (event.get_click_count() == 1 && global.display.focus_window.get_maximized()) {
            Mainloop.timeout_add(100, function () {
                if (Main._handledClick == 1) {
                    Main._handledClick = 0;
                } else {
                    if (Main._cancelClick == 0) {
                        /* disable the following mice temporarly so
                        that this hack works; a better way would be 
                        nice; maybe that would also fix the mouse
                        button remaining stuck when dragging the
                        window */
                        Util.spawn(['xinput', '--disable', '12']);
                        Util.spawn(['xinput', '--disable', '15']);
                        Util.spawn(['xinput', '--disable', '16']);
                        Main.panel.statusArea.appMenu.hide();
                        Util.spawn(['xinput', '--enable', '12']);
                        Util.spawn(['xinput', '--enable', '15']);
                        Util.spawn(['xinput', '--enable', '16']);
                        Util.spawn(['xdotool', 'mousedown', '1']);
                        Mainloop.timeout_add(100, function () {
                            Main.panel.statusArea.appMenu.show();
                        });
                    }
                }
            });
        }
    } else if (event.get_button() == 2) {
        global.display.focus_window.delete(global.get_current_time());
        Mainloop.timeout_add(10, function () {
            Util.spawn(['xdotool', 'key', 'Escape']);
        });
    }
},

_clicked: function (actor, event) {
    if (event.get_button() == 1) {
        Main._cancelClick = 1;
        if (event.get_click_count() == 2) {
            if (global.display.focus_window.get_maximized()) {
                global.display.focus_window.unmaximize(MAXIMIZED);
            } else {
                global.display.focus_window.maximize(MAXIMIZED);
            }
        }
    }
},

These imports are needed I believe:

const Main           = imports.ui.main;
const Mainloop       = imports.mainloop;
const Meta           = imports.gi.Meta;
const MAXIMIZED      = Meta.MaximizeFlags.BOTH;

Maybe it helps someone shorten their hard struggle searching the documentation.

Valentin Radu
  • 629
  • 1
  • 11
  • 26