4

Before I get screamed at for duplicating a question. Ive read windows 7-like snap window maximize and vertical feature and http://www.omgubuntu.co.uk/2009/11/get-aero-snap-in-ubuntu/

There are two problems with this solution that I am trying to get around.

  1. It's not sensitive to dragging a window
  2. It's not intelligent for Twin-view monitors.

The first problem is the more pressing. I have the compiz settings with wmctrl, but this is not sensitive to dragging windows if I have a window with the focus and place my mouse in the panel I get the window maximized, even though I'm not dragging the window. A good solution would be sensitive to the state of the mouse, clicked, right clicked, middle clicked. An ideal solution would be sensitive to dragging a window or not.

Second is a minor annoyance to me at least. With the commands as they are listed are equivalent to maximizing the windows since I have a Twinview monitors setup.

Is there any way to add these sensitivities to the commands?

Andrew Redd
  • 2,157

3 Answers3

1

I wanted this feature on my Ubuntu when i switched from windows7. I use the grid component on Compiz, mapped on numeric keyboard, this is really efficient and I know prefer this way to organize windows on my desktop.

teo96
  • 1,169
0

After fiddling with things for a while a got a solution that works with mouse genstures, following the suggestion from this post.

I created two scripts one for docking left and one for docking right.

dockleft:

#! /usr/bin/env bash
WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x' `
HALF=$(($WIDTH/2))
QUARTER=$(($WIDTH/4)) 
winid=`xdpyinfo | grep focus | grep -E -o 0x[0-9a-f]+`
x=`xwininfo -id $winid | grep "Absolute upper-left X" | cut -f 2 -d ':'`
y=`xwininfo -id $winid | grep "Absolute upper-left Y" | cut -f 2 -d ':'`

if [ $x -lt $HALF ]; then
  wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$QUARTER,-1
else
  wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$QUARTER,-1
fi

dockright:

#! /usr/bin/env bash
WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x' `
HALF=$(($WIDTH/2))
QUARTER=$(($WIDTH/4)) 
THREEQUARTERS=$(($WIDTH*3/4))
winid=`xdpyinfo | grep focus | grep -E -o 0x[0-9a-f]+`
x=`xwininfo -id $winid | grep "Absolute upper-left X" | cut -f 2 -d ':'`
y=`xwininfo -id $winid | grep "Absolute upper-left Y" | cut -f 2 -d ':'`

if [ $x -lt $HALF ]; then
  wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$QUARTER,0,$QUARTER,-1
else
  wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$THREEQUARTERS,0,$QUARTER,-1
fi

Then I used easystroke to assign mouse gestures for dock left, dock right and maximize. This does not perfectly emulate the windows version but at least I won't be maximizing my windows automatically. This way I can also assign the scripts to hotkeys for added convenience.

NOTE: This is for my Twinview dual monitor setup which takes into account that I want the window docked on the side of the monitor not the 'desktop' which appear to ubuntu as a very wide single monitor.

This will probably be sufficient for me but if there is a better solution out there I would really like to hear it.

Andrew Redd
  • 2,157
0

Andrew, I see you already answered with the EasyStroke alternative, but I'll put MY way to do it here, just for registering an alternative.

In fact, I kept with the original Compiz alternative, but instead, modified the scripts so they'd work immediately with the window dragging itself, not by waiting a button release. I guess it's a question of personal taste, but like you, I also prefer Win7's way of maximizing on edge touching.

For the left and right scripts, I just commented out the loop that waits for the button release:

#while (/usr/bin/X11/xinput --query-state $MOUSE | grep down)
#do 
#   echo 'button pressed'
#done

and nothing more. Well, I also added the keyboard shortcuts for them, but that's just a Compiz bonus. ;-) Congrats for such a good question.

P.S.: My edit is on the mouse-click-detection version, available on http://ubuntuforums.org/showpost.php?p=9207510&postcount=60.