Skip to content

Commit c19e899

Browse files
carterprinceammen99
authored andcommitted
panel: middle click to close window (#210)
* panel: middle click to close window * fix spacing, remove tab * add option * remove include widget.hpp, fix whitespace * move to separate option group * uncrustify
1 parent b6ec8f7 commit c19e899

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

metadata/panel.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,12 @@ Set to -1 to only run it by clicking the button.
336336
</entry>
337337
</option>
338338
</group>
339+
<group>
340+
<_short>Window List</_short>
341+
<option name="middle_click_close" type="bool">
342+
<_short>Middle Click Closes Windows</_short>
343+
<default>false</default>
344+
</option>
345+
</group>
339346
</plugin>
340347
</wf-shell>

src/panel/widgets/window-list/toplevel.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <gdk/gdkwayland.h>
1212
#include <cmath>
1313

14-
1514
#include "toplevel.hpp"
1615
#include "gtk-utils.hpp"
1716
#include "panel.hpp"
@@ -44,6 +43,8 @@ class WayfireToplevel::impl
4443

4544
Glib::ustring app_id, title;
4645

46+
WfOption<bool> middle_click_close{"panel/middle_click_close"};
47+
4748
public:
4849
WayfireWindowList *window_list;
4950

@@ -182,14 +183,20 @@ class WayfireToplevel::impl
182183

183184
bool on_button_press_event(GdkEventButton *event)
184185
{
185-
if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3))
186-
{
187-
menu.popup(event->button, event->time);
188-
return true; // It has been handled.
189-
} else
186+
if (event->type == GDK_BUTTON_PRESS)
190187
{
191-
return false;
188+
if (event->button == 3)
189+
{
190+
menu.popup(event->button, event->time);
191+
return true; // It has been handled.
192+
} else if ((event->button == 2) && middle_click_close)
193+
{
194+
zwlr_foreign_toplevel_handle_v1_close(handle);
195+
return true;
196+
}
192197
}
198+
199+
return false;
193200
}
194201

195202
void on_menu_minimize()

0 commit comments

Comments
 (0)