All pastes #715787 Raw Edit

Untitled

public text v1 · immutable
#715787 ·published 2007-09-26 13:58 UTC
rendered paste body
diff --git a/plugins/resize.c b/plugins/resize.c
index c514ad2..42b3216 100644
--- a/plugins/resize.c
+++ b/plugins/resize.c
@@ -93,12 +93,17 @@ typedef struct _ResizeDisplay {
     int		 mode;
     XRectangle	 savedGeometry;
     XRectangle	 geometry;
+    XRectangle	 lastGeometry;
 
     int		 releaseButton;
     unsigned int mask;
     int		 pointerDx;
     int		 pointerDy;
     KeyCode	 key[NUM_KEYS];
+
+    Window       resizeWindow;
+    Window       resizedWindow;
+    CompScreen   *screen;
 } ResizeDisplay;
 
 typedef struct _ResizeScreen {
@@ -298,12 +303,14 @@ resizeFinishResizing (CompDisplay *d)
 {
     RESIZE_DISPLAY (d);
 
+    /*
     (*rd->w->screen->windowUngrabNotify) (rd->w);
 
     XDeleteProperty (d->display,
 		     rd->w->id,
 		     rd->resizeInformationAtom);
-
+*/
+    rd->resizedWindow = None;
     rd->w = NULL;
 }
 
@@ -328,6 +335,8 @@ resizeInitiate (CompDisplay     *d,
 	int          x, y;
 	int	     button;
 	int	     i;
+	
+	XSetWindowAttributes attr;
 
 	RESIZE_SCREEN (w->screen);
 
@@ -340,6 +349,27 @@ resizeInitiate (CompDisplay     *d,
 
 	mask = getIntOptionNamed (option, nOption, "direction", 0);
 
+	attr.override_redirect = TRUE;
+        attr.event_mask        = PropertyChangeMask;
+
+	
+	
+	rd->resizeWindow = XCreateWindow (d->display, w->screen->root, 0, 0,
+					  w->screen->width / 2, w->screen->height,
+					  0, CopyFromParent, CopyFromParent,
+					  CopyFromParent,
+					  CWOverrideRedirect | CWEventMask,
+					  &attr);
+
+	rd->resizedWindow = w->id;
+
+	rd->screen = w->screen;
+	
+	XMapWindow (d->display, rd->resizeWindow);
+
+	XReparentWindow (d->display, w->id, rd->resizeWindow, 0, 0);
+ 
+
 	/* Initiate the resize in the direction suggested by the
 	 * quarter of the window the mouse is in, eg drag in top left
 	 * will resize up and to the left.  Keyboard resize starts out
@@ -481,13 +511,23 @@ resizeTerminate (CompDisplay	 *d,
 {
     RESIZE_DISPLAY (d);
 
+    printf("Terminate 1\n");
+
     if (rd->w)
     {
 	CompWindow     *w = rd->w;
 	XWindowChanges xwc;
 	unsigned int   mask = 0;
 
-	RESIZE_SCREEN (w->screen);
+	RESIZE_SCREEN (rd->screen);
+
+	printf("Term Resize id 0x%X and 0x%X\n",w->id,rd->resizeWindow);
+
+	XReparentWindow (d->display, rd->resizedWindow, rd->screen->root, 0, 0);
+	XUnmapWindow (d->display, rd->resizeWindow);
+	XDestroyWindow (d->display, rd->resizeWindow);
+
+	printf("Terminate\n");
 
 	if (rd->mode == RESIZE_MODE_NORMAL)
 	{
@@ -551,7 +591,7 @@ resizeTerminate (CompDisplay	 *d,
 
 	if (rs->grabIndex)
 	{
-	    removeScreenGrab (w->screen, rs->grabIndex, NULL);
+	    removeScreenGrab (rd->screen, rs->grabIndex, NULL);
 	    rs->grabIndex = 0;
 	}
 
@@ -568,9 +608,11 @@ resizeUpdateWindowSize (CompDisplay *d)
 {
     RESIZE_DISPLAY (d);
 
-    if (rd->w->syncWait)
-	return;
+    if (rd->lastGeometry.width != rd->geometry.width || rd->lastGeometry.width != rd->geometry.height)
+    XResizeWindow (d->display, rd->resizedWindow, rd->geometry.width,rd->geometry.height);
 
+    rd->lastGeometry = rd->geometry;
+    /*
     if (rd->w->serverWidth  != rd->geometry.width ||
 	rd->w->serverHeight != rd->geometry.height)
     {
@@ -587,7 +629,9 @@ resizeUpdateWindowSize (CompDisplay *d)
 			  CWX | CWY | CWWidth | CWHeight,
 			  &xwc);
     }
+    */
 }
+    
 
 static void
 resizeHandleKeyEvent (CompScreen *s,
@@ -743,6 +787,7 @@ resizeHandleMotionEvent (CompScreen *s,
 	    rd->pointerDy += yRoot - lastPointerY;
 	}
 
+	
 	if (rd->mask & ResizeLeftMask)
 	    w -= rd->pointerDx;
 	else if (rd->mask & ResizeRightMask)
@@ -752,14 +797,15 @@ resizeHandleMotionEvent (CompScreen *s,
 	    h -= rd->pointerDy;
 	else if (rd->mask & ResizeDownMask)
 	    h += rd->pointerDy;
-
+/*
 	if (rd->w->state & CompWindowStateMaximizedVertMask)
 	    h = rd->w->serverHeight;
 
 	if (rd->w->state & CompWindowStateMaximizedHorzMask)
 	    w = rd->w->serverWidth;
+*/
 
-	constrainNewWindowSize (rd->w, w, h, &w, &h);
+//	constrainNewWindowSize (rd->w, w, h, &w, &h);
 
 	if (rd->mode != RESIZE_MODE_NORMAL)
 	{
@@ -795,7 +841,7 @@ resizeHandleMotionEvent (CompScreen *s,
 	}
 
 	resizeUpdateWindowProperty (s->display);
-	resizeSendResizeNotify (s->display);
+	//resizeSendResizeNotify (s->display);
     }
 }
 
@@ -948,10 +994,12 @@ resizeHandleEvent (CompDisplay *d,
 	{
 	    int option;
 
+	    /*
 	    option = RESIZE_DISPLAY_OPTION_INITIATE_BUTTON;
 	    resizeTerminate (d, &rd->opt[option].value.action, 0, NULL, 0);
 	    option = RESIZE_DISPLAY_OPTION_INITIATE_KEY;
 	    resizeTerminate (d, &rd->opt[option].value.action, 0, NULL, 0);
+	    */
 	}
     default:
 	break;