You are not logged in.

#1 2013-04-04 19:28:43

endor43
Member
Registered: 2012-11-04
Posts: 21

Openbox script-drag titlebar to unmaximize, help with last step?

Hey all,

I really missed the feature in other WM's where one could drag a maximized window out of maximize and have it restore to the original size. I have written a small shell script to get the size of the current window and then implemented it in rc.xml. The only little issue is that, for some reason, when restoring from the values originally saved, the window comes out of the "maximized" state but retains the maximized dimensions. In other words, I can drag it out of "maximized' but it stays big, and does not go back to the original saved size. Any thoughts?

getdimcur.sh

#!/bin/bash

activew="$(xwininfo -id $(xdotool getactivewindow)|awk '/Width/ {print $2}')"
activeh="$(xwininfo -id $(xdotool getactivewindow)|awk '/Height/ {print $2}')"

echo -en "$activew $activeh" > /home/ts/scripts/curwin/curwindim

rc.xml snippet

    <context name="Titlebar">
      <mousebind button="Left" action="DoubleClick">
	
				<action name="Execute">
				<command>bash /home/ts/scripts/curwin/getdimcur.sh</command>
				</action>
				<action name="Execute">
				<command>wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz</command>
				</action>
      </mousebind>

	<mousebind button="Left" action="Drag">
		<action name="if">
          		<maximized>yes</maximized>
         		<then>	
				<action name="Execute">
				<command>wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz</command>
				</action>
				<action name="Execute">
				<command>bash /home/ts/scripts/curwin/restorewin.sh/</command>
				</action>
				
			</then>
		</action>
		<action name="Move"/>
	</mousebind>

    </context>

restorewin.sh

xdotool getactivewindow windowsize $(cat /home/ts/scripts/curwin/curwindim|awk '{print $1}') $(cat /home/ts/scripts/curwin/curwindim|awk '{print $2}')

Testing these commands in terminal individually is successful, so what am I missing?

Thank you.

Offline

#2 2014-01-04 23:33:02

raimar
Member
From: Braunschweig
Registered: 2014-01-04
Posts: 7

Re: Openbox script-drag titlebar to unmaximize, help with last step?

I have solved moving a window by dragging the title bar with the following openbox configuration, which is located in ~/.config/openbox/lxde-rc.xml on my machine:

[...]
<context name="Titlebar">
[...]
      <mousebind button="Left" action="Drag">
        <action name="if">
          <maximized>yes</maximized>
            <then>	
              <action name="Unmaximize"/>
              <action name="MoveResizeTo">
                <y>0</y>
              </action>
            </then>
	</action>
        <action name="Move"/>
      </mousebind>
      <mousebind button="Left" action="DoubleClick">
        <action name="ToggleMaximizeFull"/>
      </mousebind>
[...]
</context>
[...]
  • After holding down the left mouse button on the title bar and moving the mouse, the window is unmaximized and moved to the top of the desktop with the actions Unmaximize and MoveResizeTo. Unmaximizing and moving to the top is only done, if the window is maximized. Then in each case the action Move starts the modus for moving the window with the mouse. This configuration simulates nearly the same behavior as in Windows 7 while dragged the title bar with the left mouse button.

  • After a left double click on the title bar, the action ToggleMaximizeFull switches the window state once between maximized and unmaximized.

See also http://openbox.org/wiki/Help:Actions

Last edited by raimar (2014-01-04 23:48:06)

Offline

#3 2019-08-17 19:02:35

juniorjpdj
Member
Registered: 2015-03-07
Posts: 4

Re: Openbox script-drag titlebar to unmaximize, help with last step?

raimar wrote:

I have solved moving a window by dragging the title bar with the following openbox configuration, which is located in ~/.config/openbox/lxde-rc.xml on my machine:

[...]
<context name="Titlebar">
[...]
      <mousebind button="Left" action="Drag">
        <action name="if">
          <maximized>yes</maximized>
            <then>	
              <action name="Unmaximize"/>
              <action name="MoveResizeTo">
                <y>0</y>
              </action>
            </then>
	</action>
        <action name="Move"/>
      </mousebind>
      <mousebind button="Left" action="DoubleClick">
        <action name="ToggleMaximizeFull"/>
      </mousebind>
[...]
</context>
[...]
  • After holding down the left mouse button on the title bar and moving the mouse, the window is unmaximized and moved to the top of the desktop with the actions Unmaximize and MoveResizeTo. Unmaximizing and moving to the top is only done, if the window is maximized. Then in each case the action Move starts the modus for moving the window with the mouse. This configuration simulates nearly the same behavior as in Windows 7 while dragged the title bar with the left mouse button.

  • After a left double click on the title bar, the action ToggleMaximizeFull switches the window state once between maximized and unmaximized.

See also http://openbox.org/wiki/Help:Actions

Sorry for digging, but it was very helpful and I've a question.
How to make window resize to size from before maximizing? When I applied this I'm able to move this window, but it's still in size of maximized window.

Offline

#4 2019-08-17 21:07:10

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Openbox script-drag titlebar to unmaximize, help with last step?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB