Snap windows to edge with the mouse

hi all, 

As said in the subject this is about snapping windows to the left/right
edge of the screen with the mouse.
I have developed an extension (put window) which allows you to move and
resize windows using /apps/metacity/window_keybindings. I use a a resize
function that looks like to manipulate the windows:

_resize = function(win, x, y, width, height) {
    win.resize(true, width, height, true);
    win.move(true, x, y);

Where win is a reference to global.display.focus_window.

After a window was snapped to an edge with the mouse it is not possible
to move or resize it with the above code. 
Ok thats not absolutely true. After snapping a window to the right edge
open lg an try the following code. It manipulates the window but not in
the expected way: 

  * changes the height and the y position of the window. 

 global.display.focus_window.resize(true, 400, 400, true);
  * changes the height
  * win.width will not changed because it is maximized horizontal 

 global.display.focus_window.move(true, 200, 200);
  * changes win.y correctly
  * win.x will not changed because it is maximized horizontal

If you call unmaximize the window is restored to the snapped position.
(both statements have this effect)

This behaviour is not expected but i don't thing it is a bug. I thing
this just happens because i use it the wrong way. 

Another thing i have noticed is that the window changes a little bit
(take right edge again): 
1) the round edge on the left top and bottom corner disappear. 
 * really nice!. If you just "vertical maximize" the window 
   the corners are not changed. 
 * I guess this is done by the snap function. But how? 

2) Resizing
 + "global.display.focus_window.resizeable" returnes true
 + It is possible to resize the window with the keyboard
   +mouse combination (for me its <Super>Mouse_3
 - It is not possible to enter the "resize mode" (right click the header
   -> resize, keyboardbinding)

When I started to develop my extension i used the "snap feature" very
frequently and run into this problem. I checked the gnome-shell and
metacity sources but haven't found anything that really helped me. Now
some other people are using this extension too and a bug is a bug :).

Can someone give me a hint where i can find the "snap function"? 
Or even better, how i can check if a window is snapped and how to
"unsnap" it?

kind regards

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]