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,159
  • This is interesting, can you bind it to mouse gestures, or preferably emulate the docking behavior of aero, where dragging is required for docking? – Andrew Redd Dec 28 '10 at 22:57
  • Never tried to bind it to mouse gesture because I am a keyboard shortcut addict, i'll try soon and come back – teo96 Dec 29 '10 at 19:54
  • No mouse gesture binding possibilities with the Grid component, sorry. – teo96 Dec 29 '10 at 20:09
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
  • Something that I just realized is that with the middle click for the easystroke the focus is given to the window under the mouse. Very useful, but could also be problematic. screws with my desktop background if I'm not careful. – Andrew Redd Dec 28 '10 at 23:30
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.

  • This looks nice and I'll try it out when I get back to my desktop at work. The one issue that I can foresee with this is that the same problem will occur with the twinview screens. The script, and it might be a limitation in compiz is that it does not recognize monitors, only the desktop. Therefore the snapping to the side is the same as maximizing. Is there an extension or perhaps an alternative that can have compiz activate in specifiable regions so that one can indicate the break in the monitors? I will hand it to you that this certainly is better than the original method. Thank you. – Andrew Redd Dec 29 '10 at 01:24