lxpanel taskbar middle click to close applications

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
tiliqua

lxpanel taskbar middle click to close applications

Post by tiliqua »

Hi, 1st post :)

I'm running Mint 12 LXDE on a 9" netbook. To save a bit of vertical space I remove window decorations from maximised windows. I got a bit tired of right-clicking and selecting "close" on the LXPanel task bar/window list icons to exit an application (or Alt-F4) and really like the middle-click to close functionality of the Cinnamon panel I run on another computer. So I decided to mess around in the LXPanel source and I got middle-click to close working in the LXPanel taskbar plugin! (note I'm not a C coder, I just know how to G----- err I mean Duck Duck Go).

Save the following as 'taskbar-middleclicktoclose.patch'

Code: Select all

diff --git a/src/plugins/taskbar.c b/src/plugins/taskbar.c
index ea822d9..f8313ea 100644
--- a/src/plugins/taskbar.c
+++ b/src/plugins/taskbar.c
@@ -1112,11 +1112,8 @@ static gboolean taskbar_task_control_event(GtkWidget * widget, GdkEventButton *
         }
         else if (event->button == 2)
         {
-            /* Middle button.  Toggle the shaded state of the window. */
-            Xclimsg(tk->win, a_NET_WM_STATE,
-                2,		/* a_NET_WM_STATE_TOGGLE */
-                a_NET_WM_STATE_SHADED,
-                0, 0, 0);
+            /* Middle button.  Close the application. */
+            Xclimsgwm(tk->win, a_WM_PROTOCOLS, a_WM_DELETE_WINDOW);
         }
         else if (event->button == 3)
         {
Then cd to the directory you saved the patch to, download lxpanel, apply the patch and build.

Code: Select all

#install dependencies
sudo apt-get install automake build-essential libltdl-dev libtool libasound2-dev libwnck-dev intltool libmenu-cache1 libmenu-cache1-dev libgtk2.0-dev git

#Get LXPanel
git clone git://lxde.git.sourceforge.net/gitroot/lxde/lxpanel

#Apply the patch 
git apply ../taskbar-middleclicktoclose.patch

#Build and install
./autogen.sh
./configure --enable-man #ignore enable-man error...
make
sudo make install

#log out and in again.
Note: this will install the entire lxpanel manually to /usr/local and won't be managed by the package manager. I don't know anything about building deb packages so didn't try to install it "properly". To uninstall: sudo rm -rf `locate lxpanel|grep /usr/local`

Thanks to vlad2005's post on compiling lxpanel which got me started.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
tiliqua

Re: lxpanel taskbar middle click to close applications

Post by tiliqua »

After all that, I just found someone has also done exactly the same... Oh well, guess I'm not as good at Duck Duck Going as I thought...
http://sashoalm.blogspot.com.au/2010/01 ... -when.html
tiliqua

Re: lxpanel taskbar middle click to close applications

Post by tiliqua »

Since there's no Mint 13 LXDE I'm using lubuntu 12.04 now, but I thought I'd update this post anyway as I've figured out how to make and install as a deb. Save as a shell script, make it executable and run as root.

Code: Select all

cd /tmp
rm -rf lxpanel*
apt-get source lxpanel
apt-get build-dep lxpanel
cd lxpanel*
cat > ../lxpanel-middleclick-to-close.patch <<EOF
--- a/src/plugins/taskbar.c
+++ b/src/plugins/taskbar.c
@@ -1112,11 +1112,8 @@
         }
         else if (event->button == 2)
         {
-            /* Middle button.  Toggle the shaded state of the window. */
-            Xclimsg(tk->win, a_NET_WM_STATE,
-                2,		/* a_NET_WM_STATE_TOGGLE */
-                a_NET_WM_STATE_SHADED,
-                0, 0, 0);
+            /* Middle button.  Close the application. */
+            Xclimsgwm(tk->win, a_WM_PROTOCOLS, a_WM_DELETE_WINDOW);
         }
         else if (event->button == 3)
         {
EOF
patch -p1 < ../lxpanel-middleclick-to-close.patch
dpkg-buildpackage -us -uc -b
cd ..
rm lxpanel*dbg*.deb
dpkg -i lxpanel*.deb
rm -rf lxpanel*
Locked

Return to “Software & Applications”