Re: [compiz] [PATCH] Resize improvements (Multiple resize modes, better aspect ratio constraining)

2007-04-27 Thread Danny Baumann
Hi,

 0002-Do-not-make-constrainNewWindowSize-depend-on-the-act.patch
 This one updates constrainNewWindowSize so that it returns TRUE if the
 new calculated size does not match the old, passed size rather than the
 window's server size.

I just noticed that this patch has some implications on existing usages
of constrainNewWindowSize which cause these to not work properly. Please
find attached a patch which extends the mentioned patch by fixing those
existing usages of this function.
We still need this patch, however, because otherwise we can't know if
any constraining was done by constrainNewWindowSize when called using
outline resize mode as in this mode, w-serverWidth/Height will be
constant all the time. I also believe making the return value depend on
the information if there was actual constraining done makes a cleaner
API.

Regards,

Danny
diff --git a/src/window.c b/src/window.c
index fbae40e..6e18579 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3435,13 +3435,23 @@ addWindowSizeChanges (CompWindow *w,
 	xwc-width  = oldWidth;
 	xwc-height = oldHeight;
 
-	if (constrainNewWindowSize (w, width, height, width, height))
+	constrainNewWindowSize (w, width, height, width, height);
+
+	if (width != w-serverWidth)
+	{
+		mask |= CWWidth;
+		xwc-width = width;
+	}
+	else
+		mask = ~CWWidth;
+
+	if (height != w-serverHeight)
 	{
-		xwc-width  = width;
+		mask |= CWHeight;
 		xwc-height = height;
 	}
 	else
-		mask = ~(CWWidth | CWHeight);
+		mask = ~CWHeight;
 
 	if (w-state  CompWindowStateMaximizedVertMask)
 	{
@@ -3528,17 +3538,29 @@ moveResizeWindow (CompWindow *w,
 {
 	int width, height;
 
-	if (constrainNewWindowSize (w,
-xwc-width, xwc-height,
-width, height))
+	if (!constrainNewWindowSize (w,
+	 			 xwc-width, xwc-height,
+	 			 width, height))
 	{
-	xwcm |= (CWWidth | CWHeight);
+	width  = xwc-width;
+	height = xwc-height;
+	}
 
+	if (width != w-serverWidth)
+	{
+	xwcm |= CWWidth;
 	xwc-width = width;
+	}
+ 	else
+	xwcm = ~CWWidth;
+
+	if (height != w-serverHeight)
+	{
+	xwcm |= CWHeight;
 	xwc-height = height;
 	}
 	else
-	xwcm = ~(CWWidth | CWHeight);
+	xwcm = ~CWHeight;
 }
 
 if (xwcm  (CWX | CWWidth))
@@ -4033,6 +4055,8 @@ constrainNewWindowSize (CompWindow *w,
 {
 CompDisplay  *d = w-screen-display;
 const XSizeHints *hints = w-sizeHints;
+int  oldWidth = width;
+int  oldHeight = height;
 int		 min_width = 0;
 int		 min_height = 0;
 int		 base_width = 0;
@@ -4164,7 +4188,7 @@ constrainNewWindowSize (CompWindow *w,
 #undef FLOOR64
 #undef FLOOR
 
-if (width != w-serverWidth || height != w-serverHeight)
+if (width != oldWidth || height != oldHeight)
 {
 	*newWidth  = width;
 	*newHeight = height;
___
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz


Re: [compiz] [PATCH] Resize improvements (Multiple resize modes, better aspect ratio constraining)

2007-04-25 Thread David Reveman
On Mon, 2007-04-23 at 17:54 +0200, Danny Baumann wrote:
 Hi,
 
  0001-Added-options-for-additional-resize-modes.patch - I think I'll just
  leave this patch out and add these options once we converted the resize
  plugin to use the new metadata system.
 
 Yes, that's ok as it has the same effect ;-)

I've done this. The description for this option mentions that it's the
default resize mode because I think it makes a lot of sense to add match
options that defines what resize mode to use for a specific window. This
allow the user to more dynamically choose which resize mode should be
used. It might also make sense to add specific actions for each resize
mode so the user can set up shortcuts that will always initiate a
specific resize mode.

 
  0002-Added-painting-code-for-additional-resize-modes.patch - I think we
  want the paintWindow function to paint it's own instance of the window
  like switcher and scale plugins are doing instead of transforming the
  core instance. The outline drawing is OK.
 
 No big deal, will change that (although I still think that for things
 like resizing/minimization we should go with modifying the core instance
 because I don't see why we should add a second fake window instance -
 but we discussed this earlier ;-) ).
 
  0003-Update-resize-logic-to-reflect-additional-resize-mod.patch - I see
  a lot of calls to damageScreen in this patch when damageScreenRegion
  should be used in all those cases to avoid redrawing more than we need.
  Motion events shouldn't cause the window to be move when resizing in
  stretch-mode and rightEdge, bottomEdge variables can be removed once
  that's changed.
 
 So you mean the window should just be translated in stretch mode? That
 makes a lot of sense, right. You're also right about the damageScreen
 calls (I don't think the difference will be huge as these calls are
 executed very rarely, but I get your point).

Let's add one resize mode at a time, starting with the outline mode and
what's necessary to make that work properly. We'll look at the stretch
mode once that's done. Can you provide a patch against head that only
adds the outline mode?

 
  0004-Added-proper-constraining-code.patch - I hope we can avoid
  including all this code and instead improve the core constraint function
  to solve any problems that currently exist. Can you provide some details
  on how the constraining is not currently working properly in the resize
  plugin so we can discuss how to best solve that?
 
 The main point the current constraining code is lacking are the
 following:
 
 1) ability to apply only a subset of all the constraints (e.g. only
 applying minimum/maximum size constraints) - no big deal with passing a
 bit mask to constrainNewWindowSize

ok, let's fix that. btw, why do we need to only apply a subset of the
constraints?

 
 2) abilitity to resize windows with aspect ratio hint set to other
 directions than the lower right 
 The code in the patch (which was taken from Metacity) takes the resize
 direction into account in order to compute the best possible window size
 depending on the resize direction. The problem that I see here is: how
 to pass the direction of resizing to constrainNewWindowSize properly?
 Perhaps we could pass it using an enum and assume some default behaviour
 when there is no clear direction (e.g. when called from
 addWindowSizeChanges).

Sounds good to me.

 
  0005-Warp-pointer-if-resizing-hit-constraints-to-avoid-mo.patch - I had
  something similar to this in the resize plugin before but removed it as
  it can't be done properly, it will always look bad as the cursor can
  never be constrained perfectly. I'd like to avoid this completely.
 
 Ok.
 
  0006-Added-screen-damages-which-were-missing-if-the-resiz.patch - Again,
  damageScreen should never have to be called. You want to use
  damageScreenRegion.
 
 Right, will update this.
 
  0007-Avoid-resizing-windows-to-negative-sizes.patch - The constrain size
  code should be fixed to take care of this if it doesn't already.
 
 It does, but there is some weird effect when only one coordinate is
 negative. In my testing, the size (-1|700) became something like (20|
 20). I will have a look into this if there is a more appropriate
 solution than that patch.

ok, good.

 
  0008-Avoid-window-flashing-back-to-its-old-size-for-a-sho.patch - Does
  this have to be a special case? Can't we have the final size change
  always be the indication that the resizing is done (not only for stretch
  mode)?
 
 I'm not sure if I completely got your question, but the problem is as
 follows: 
 -  resize done 
 - configureXWindow is called 
 - server information is updated 
 - ... (server processing) 
 - (drawing during that time using the not updated w-attrib
 coordinates) 
 - server processing finished, resizeWindow is called, w-attrib is
 updated

Yes, the resize should finish once server and client processing is done
and the window can be rendered at the new size. Not doing this for

Re: [compiz] [PATCH] Resize improvements (Multiple resize modes, better aspect ratio constraining)

2007-04-23 Thread David Reveman
On Wed, 2007-04-18 at 10:45 +0200, Danny Baumann wrote:
 Hi,
 
  I have ported various improvements of Beryl's resize to Compiz:
  
  - multiple resize modes (aside to the standard normal mode those are
  Stretch, Outline and Filled Outline)
  - better aspect ratio constraining (you now also can resize aspect
  constrained windows from other edges than the lower right)
  - avoiding of mouse pointer desynchronization when the resizing hit
  constraints.
  
  While porting this, I cleaned up the code and fixed some performance
  problems, so the code is supposed to work without problems.
  
  If you want to use the new options and are using gconf, you have to do
  'make compiz.schemas.in' in your plugin directory to update the schema
  file.
  
  Please tell me what you think of that patch and if you experience any
  problems while using it.
 
 I've splitted up the patch into several smaller ones, adapted them for
 latest API changes and fixed some minor bugs which I got reported.
 
 Some more feedback would still be nice :-)
 
 David, are there any objections against including this code?
 
 Regards,

0001-Added-options-for-additional-resize-modes.patch - I think I'll just
leave this patch out and add these options once we converted the resize
plugin to use the new metadata system.

0002-Added-painting-code-for-additional-resize-modes.patch - I think we
want the paintWindow function to paint it's own instance of the window
like switcher and scale plugins are doing instead of transforming the
core instance. The outline drawing is OK.

0003-Update-resize-logic-to-reflect-additional-resize-mod.patch - I see
a lot of calls to damageScreen in this patch when damageScreenRegion
should be used in all those cases to avoid redrawing more than we need.
Motion events shouldn't cause the window to be move when resizing in
stretch-mode and rightEdge, bottomEdge variables can be removed once
that's changed.

0004-Added-proper-constraining-code.patch - I hope we can avoid
including all this code and instead improve the core constraint function
to solve any problems that currently exist. Can you provide some details
on how the constraining is not currently working properly in the resize
plugin so we can discuss how to best solve that?

0005-Warp-pointer-if-resizing-hit-constraints-to-avoid-mo.patch - I had
something similar to this in the resize plugin before but removed it as
it can't be done properly, it will always look bad as the cursor can
never be constrained perfectly. I'd like to avoid this completely.

0006-Added-screen-damages-which-were-missing-if-the-resiz.patch - Again,
damageScreen should never have to be called. You want to use
damageScreenRegion.

0007-Avoid-resizing-windows-to-negative-sizes.patch - The constrain size
code should be fixed to take care of this if it doesn't already.

0008-Avoid-window-flashing-back-to-its-old-size-for-a-sho.patch - Does
this have to be a special case? Can't we have the final size change
always be the indication that the resizing is done (not only for stretch
mode)?

- David

___
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz


Re: [compiz] [PATCH] Resize improvements (Multiple resize modes, better aspect ratio constraining)

2007-04-19 Thread Matt Russell
I think on some hardware resizing is much slower than to others. For
example, with an Nvidia Geforce 6800 resizing is painfully slow (driver
bug?) but with an old Radeon 9600 with the OSS drivers, resizing is as
fluid as Metacity.

I hope this issue is resolved soon, though I'm not sure what is causing
it...

Regards,
Matt

On Wed, 2007-04-18 at 16:44 +0200, Anders Storsveen wrote:
 how can vista resizing and redrawing be so fast, while compiz and  
 osx' resizing is slow? as I understand it, vista also uses  
 composition in their aero-glass stuff too.
 
 Den 18. apr. 2007 kl. 10.45 skrev Danny Baumann:
 
  Hi,
 
  I have ported various improvements of Beryl's resize to Compiz:
 
  - multiple resize modes (aside to the standard normal mode those  
  are
  Stretch, Outline and Filled Outline)
  - better aspect ratio constraining (you now also can resize aspect
  constrained windows from other edges than the lower right)
  - avoiding of mouse pointer desynchronization when the resizing hit
  constraints.
 
  While porting this, I cleaned up the code and fixed some performance
  problems, so the code is supposed to work without problems.
 
  If you want to use the new options and are using gconf, you have  
  to do
  'make compiz.schemas.in' in your plugin directory to update the  
  schema
  file.
 
  Please tell me what you think of that patch and if you experience any
  problems while using it.
 
  I've splitted up the patch into several smaller ones, adapted them for
  latest API changes and fixed some minor bugs which I got reported.
 
  Some more feedback would still be nice :-)
 
  David, are there any objections against including this code?
 
  Regards,
 
  Danny
  0001-Added-options-for-additional-resize-modes.patch
  0002-Added-painting-code-for-additional-resize-modes.patch
  0003-Update-resize-logic-to-reflect-additional-resize-mod.patch
  0004-Added-proper-constraining-code.patch
  0005-Warp-pointer-if-resizing-hit-constraints-to-avoid-mo.patch
  0006-Added-screen-damages-which-were-missing-if-the-resiz.patch
  0007-Avoid-resizing-windows-to-negative-sizes.patch
  0008-Avoid-window-flashing-back-to-its-old-size-for-a-sho.patch
  ___
  compiz mailing list
  compiz@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/compiz
 
 ___
 compiz mailing list
 compiz@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/compiz

___
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz


Re: [compiz] [PATCH] Resize improvements (Multiple resize modes, better aspect ratio constraining)

2007-04-19 Thread David Reveman
On Wed, 2007-04-18 at 10:45 +0200, Danny Baumann wrote:
 Hi,
 
  I have ported various improvements of Beryl's resize to Compiz:
  
  - multiple resize modes (aside to the standard normal mode those are
  Stretch, Outline and Filled Outline)
  - better aspect ratio constraining (you now also can resize aspect
  constrained windows from other edges than the lower right)
  - avoiding of mouse pointer desynchronization when the resizing hit
  constraints.
  
  While porting this, I cleaned up the code and fixed some performance
  problems, so the code is supposed to work without problems.
  
  If you want to use the new options and are using gconf, you have to do
  'make compiz.schemas.in' in your plugin directory to update the schema
  file.
  
  Please tell me what you think of that patch and if you experience any
  problems while using it.
 
 I've splitted up the patch into several smaller ones, adapted them for
 latest API changes and fixed some minor bugs which I got reported.
 
 Some more feedback would still be nice :-)
 
 David, are there any objections against including this code?

There's a few things, I'll get back to you as soon looked at all these
patches more closely. btw, has the copyright holder of the code in the
Added-proper-constraining-code patch agreed to let us MIT license that
code?

- David

___
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz


[compiz] [PATCH] Resize improvements (Multiple resize modes, better aspect ratio constraining)

2007-04-12 Thread Danny Baumann
Hi,

I have ported various improvements of Beryl's resize to Compiz:

- multiple resize modes (aside to the standard normal mode those are
Stretch, Outline and Filled Outline)
- better aspect ratio constraining (you now also can resize aspect
constrained windows from other edges than the lower right)
- avoiding of mouse pointer desynchronization when the resizing hit
constraints.

While porting this, I cleaned up the code and fixed some performance
problems, so the code is supposed to work without problems.

If you want to use the new options and are using gconf, you have to do
'make compiz.schemas.in' in your plugin directory to update the schema
file.

Please tell me what you think of that patch and if you experience any
problems while using it.

Thanks for your feedback!

Regards,

Danny
diff --git a/plugins/resize.c b/plugins/resize.c
index b9eb42b..928fb23 100644
--- a/plugins/resize.c
+++ b/plugins/resize.c
@@ -42,6 +42,16 @@
 #define RESIZE_INITIATE_KEY_DEFAULT   F8
 #define RESIZE_INITIATE_KEY_MODIFIERS_DEFAULT CompAltMask
 
+#define RESIZE_BORDER_COLOR_RED   0x2fff
+#define RESIZE_BORDER_COLOR_GREEN 0x2fff
+#define RESIZE_BORDER_COLOR_BLUE  0x4fff
+#define RESIZE_BORDER_COLOR_ALPHA 0x9fff
+
+#define RESIZE_FILL_COLOR_RED   0x2fff
+#define RESIZE_FILL_COLOR_GREEN 0x2fff
+#define RESIZE_FILL_COLOR_BLUE  0x4fff
+#define RESIZE_FILL_COLOR_ALPHA 0x4fff
+
 struct _ResizeKeys {
 char	 *name;
 int		 dx;
@@ -60,8 +70,28 @@ struct _ResizeKeys {
 #define MIN_KEY_WIDTH_INC  24
 #define MIN_KEY_HEIGHT_INC 24
 
-#define RESIZE_DISPLAY_OPTION_INITIATE 0
-#define RESIZE_DISPLAY_OPTION_NUM  1
+#define RESIZE_DISPLAY_OPTION_INITIATE 0
+#define RESIZE_DISPLAY_OPTION_MODE 1
+#define RESIZE_DISPLAY_OPTION_BORDER_COLOR 2
+#define RESIZE_DISPLAY_OPTION_FILL_COLOR   3
+#define RESIZE_DISPLAY_OPTION_NUM  4
+
+typedef enum _ResizeMode {
+ResizeModeNormal = 0,
+ResizeModeStretch,
+ResizeModeOutline,
+ResizeModeFilledOutline
+} ResizeMode;
+
+char * resizeModes[] = {
+N_(Normal),
+N_(Stretch),
+N_(Outline),
+N_(Filled Outline)
+};
+
+#define RESIZE_MODE_DEFAULT ResizeModeNormal
+#define NUM_RESIZE_MODES(sizeof (resizeModes) / sizeof (resizeModes[0]))
 
 static int displayPrivateIndex;
 
@@ -75,16 +105,31 @@ typedef struct _ResizeDisplay {
 XWindowAttributes savedAttrib;
 int		  releaseButton;
 unsigned int  mask;
-int		  width;
-int		  height;
-int		  ucWidth;	/* unconstrained width */
-int		  ucHeight;	/* unconstrained height */
+
+int   currentX;
+int   currentY;
+int   currentWidth;
+int   currentHeight;
+
+/* offsets between pointer and upper left 
+   window edge on resize start */
+int   xDelta;
+int   yDelta;
+
+int   rightEdge;
+int   bottomEdge;
+
+ResizeModeresizeMode;
+
 KeyCode	  key[NUM_KEYS];
 } ResizeDisplay;
 
 typedef struct _ResizeScreen {
 int grabIndex;
 
+PaintWindowProc paintWindow;
+PaintScreenProc paintScreen;
+
 Cursor leftCursor;
 Cursor rightCursor;
 Cursor upCursor;
@@ -111,6 +156,38 @@ typedef struct _ResizeScreen {
 
 #define NUM_OPTIONS(d) (sizeof ((d)-opt) / sizeof (CompOption))
 
+static void
+resizeUpdateRealWindowSize (CompDisplay *d)
+{
+RESIZE_DISPLAY (d);
+XWindowChanges xwc;
+
+if (!rd-w)
+	return;
+
+if (rd-w-state  CompWindowStateMaximizedVertMask)
+	rd-currentHeight = rd-w-serverHeight;
+
+if (rd-w-state  CompWindowStateMaximizedHorzMask)
+	rd-currentWidth = rd-w-serverWidth;
+
+if (rd-currentWidth  == rd-w-serverWidth 
+	rd-currentHeight == rd-w-serverHeight)
+	return;
+
+if (rd-w-syncWait)
+	return;
+
+xwc.x = rd-currentX;
+xwc.y = rd-currentY;
+xwc.width = rd-currentWidth;
+xwc.height = rd-currentHeight;
+
+sendSyncRequest (rd-w);
+
+configureXWindow (rd-w, CWX | CWY | CWWidth | CWHeight, xwc);
+}
+
 static Bool
 resizeInitiate (CompDisplay *d,
 		CompAction  *action,
@@ -186,12 +263,19 @@ resizeInitiate (CompDisplay *d,
 
 	rd-w	= w;
 	rd-mask= mask;
-	rd-ucWidth = w-attrib.width;
-	rd-ucHeight= w-attrib.height;
-	rd-width   = w-attrib.width;
-	rd-height  = w-attrib.height;
 	rd-savedAttrib = w-attrib;
 
+ 	rd-currentX  = w-attrib.x;
+ 	rd-currentY  = w-attrib.y;
+  	rd-currentWidth  = w-attrib.width;
+ 	rd-currentHeight = w-attrib.height;
+
+ 	rd-rightEdge  = rd-currentX + rd-currentWidth;
+ 	rd-bottomEdge = rd-currentY + rd-currentHeight;
+
+ 	rd-xDelta = 0;
+	rd-yDelta = 0;
+
 	lastPointerX = x;
 	lastPointerY = y;
 
@@ -250,6 +334,17 @@ resizeInitiate (CompDisplay *d,
 
 		warpPointer (d, xRoot - pointerX, yRoot - pointerY);
 	}
+
+ 	rd-xDelta = (x - rd-currentX);
+ 	if (rd-mask  ResizeRightMask)
+ 		rd-xDelta = rd-w-serverWidth - rd-xDelta;
+
+