Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panel: middle click to close window #210

Merged
merged 6 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions metadata/panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,12 @@ Set to -1 to only run it by clicking the button.
</entry>
</option>
</group>
<group>
<_short>Window List</_short>
<option name="middle_click_close" type="bool">
<_short>Middle Click Closes Windows</_short>
<default>false</default>
</option>
</group>
</plugin>
</wf-shell>
21 changes: 14 additions & 7 deletions src/panel/widgets/window-list/toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <gdk/gdkwayland.h>
#include <cmath>


#include "toplevel.hpp"
#include "gtk-utils.hpp"
#include "panel.hpp"
Expand Down Expand Up @@ -44,6 +43,8 @@ class WayfireToplevel::impl

Glib::ustring app_id, title;

WfOption<bool> middle_click_close{"panel/middle_click_close"};

public:
WayfireWindowList *window_list;

Expand Down Expand Up @@ -182,14 +183,20 @@ class WayfireToplevel::impl

bool on_button_press_event(GdkEventButton *event)
{
if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3))
{
menu.popup(event->button, event->time);
return true; // It has been handled.
} else
if (event->type == GDK_BUTTON_PRESS)
{
return false;
if (event->button == 3)
{
menu.popup(event->button, event->time);
return true; // It has been handled.
} else if ((event->button == 2) && middle_click_close)
{
zwlr_foreign_toplevel_handle_v1_close(handle);
return true;
}
}

return false;
}

void on_menu_minimize()
Expand Down
Loading