summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/move.c
diff options
context:
space:
mode:
authormaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-31 11:40:47 +0000
committermaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-31 11:40:47 +0000
commit326d6635856679f0bf1a0795592fd1e309295b6c (patch)
treed78cbc00b41606ec62e4ee47164ddd3ab8ff9f5f /beryl-plugins/src/move.c
parentbfbee4ed9e70188486a5d9a9f4a92ec86a49a826 (diff)
downloadmarex-dev-326d6635856679f0bf1a0795592fd1e309295b6c.tar.gz
marex-dev-326d6635856679f0bf1a0795592fd1e309295b6c.tar.bz2
beryl-plugins (move):
- bring back "constrain to bottom" option - (hopefully) fix constraining for mixed resolutions git-svn-id: file:///beryl/trunk@2187 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/move.c')
-rw-r--r--beryl-plugins/src/move.c107
1 files changed, 58 insertions, 49 deletions
diff --git a/beryl-plugins/src/move.c b/beryl-plugins/src/move.c
index 4af97c3..fd3acc6 100644
--- a/beryl-plugins/src/move.c
+++ b/beryl-plugins/src/move.c
@@ -41,7 +41,9 @@
#define MOVE_OPACITY_MIN 1
#define MOVE_OPACITY_MAX 100
-#define MOVE_CONSTRAIN_Y_DEFAULT TRUE
+#define MOVE_CONSTRAIN_Y_TOP_DEFAULT TRUE
+#define MOVE_CONSTRAIN_Y_BOTTOM_DEFAULT FALSE
+
#define MOVE_SNAPOFF_MAXIMIZED_DEFAULT TRUE
#define MOVE_OPACIFY_MIN_OPACITY_DEFAULT 80
@@ -81,12 +83,13 @@ static int displayPrivateIndex;
#define MOVE_DISPLAY_OPTION_INITIATE 0
#define MOVE_DISPLAY_OPTION_OPACITY 1
-#define MOVE_DISPLAY_OPTION_CONSTRAIN_Y 2
-#define MOVE_DISPLAY_OPTION_SNAPOFF_MAXIMIZED 3
-#define MOVE_DISPLAY_OPTION_OPACIFY_MIN_OPACITY 4
-#define MOVE_DISPLAY_OPTION_SNAPOFF_DISTANCE 5
-#define MOVE_DISPLAY_OPTION_SNAPBACK_DISTANCE 6
-#define MOVE_DISPLAY_OPTION_NUM 7
+#define MOVE_DISPLAY_OPTION_CONSTRAIN_Y_TOP 2
+#define MOVE_DISPLAY_OPTION_CONSTRAIN_Y_BOTTOM 3
+#define MOVE_DISPLAY_OPTION_SNAPOFF_MAXIMIZED 4
+#define MOVE_DISPLAY_OPTION_OPACIFY_MIN_OPACITY 5
+#define MOVE_DISPLAY_OPTION_SNAPOFF_DISTANCE 6
+#define MOVE_DISPLAY_OPTION_SNAPBACK_DISTANCE 7
+#define MOVE_DISPLAY_OPTION_NUM 8
typedef struct _MoveDisplay
{
@@ -263,29 +266,24 @@ moveTerminate(CompDisplay * d,
return FALSE;
}
-/* creates a region containing top and bottom struts. only struts that are
- outside the screen workarea are considered. */
static Region
moveGetYConstrainRegion (CompScreen *s)
{
CompWindow *w;
Region region;
REGION r;
+ int i;
region = XCreateRegion ();
if (!region)
return NULL;
+ for (i = 0;i < s->nOutputDev; i++)
+ XUnionRegion (&s->outputDev[i].region, region, region);
+
r.rects = &r.extents;
r.numRects = r.size = 1;
- r.extents.x1 = MINSHORT;
- r.extents.y1 = 0;
- r.extents.x2 = MAXSHORT;
- r.extents.y2 = s->height;
-
- XUnionRegion (&r, region, region);
-
for (w = s->windows; w; w = w->next)
{
if (!w->mapNum)
@@ -298,16 +296,14 @@ moveGetYConstrainRegion (CompScreen *s)
r.extents.x2 = r.extents.x1 + w->struts->top.width;
r.extents.y2 = r.extents.y1 + w->struts->top.height;
- if (r.extents.y2 <= s->workArea.y)
- XSubtractRegion (region, &r, region);
+ XSubtractRegion (region, &r, region);
r.extents.x1 = w->struts->bottom.x;
r.extents.y1 = w->struts->bottom.y;
r.extents.x2 = r.extents.x1 + w->struts->bottom.width;
r.extents.y2 = r.extents.y1 + w->struts->bottom.height;
- if (r.extents.y1 >= (s->workArea.y + s->workArea.height))
- XSubtractRegion (region, &r, region);
+ XSubtractRegion (region, &r, region);
}
}
@@ -345,13 +341,17 @@ static void moveHandleMotionEvent(CompScreen * s, int xRoot, int yRoot)
{
XRectangle workArea;
int min, max;
+ Bool constrainTop =
+ md->opt[MOVE_DISPLAY_OPTION_CONSTRAIN_Y_TOP].value.b;
+ Bool constrainBottom =
+ md->opt[MOVE_DISPLAY_OPTION_CONSTRAIN_Y_BOTTOM].value.b;
dx = md->x;
dy = md->y;
screenGetOutputDevWorkArea(s, outputDeviceForWindow(w), &workArea);
- if (!w->shaded && md->opt[MOVE_DISPLAY_OPTION_CONSTRAIN_Y].value.b)
+ if (constrainTop || constrainBottom)
{
if (!md->region)
md->region = moveGetYConstrainRegion (s);
@@ -361,41 +361,37 @@ static void moveHandleMotionEvent(CompScreen * s, int xRoot, int yRoot)
region */
if (md->region)
{
- int x, y, width, height;
+ int y, height;
int status;
- x = w->attrib.x + dx - w->input.left;
- y = w->attrib.y + dy - w->input.top;
- width = w->width + w->input.left + w->input.right;
- height = w->input.top ? w->input.top : 1;
+ if (constrainTop)
+ {
+ y = w->attrib.y + dy - w->input.top;
+ height = w->input.top ? w->input.top : 1;
+ if (constrainBottom)
+ height += w->height + w->input.bottom;
+ }
+ else if (constrainBottom)
+ {
+ y = w->attrib.y + dy + w->height;
+ height = w->input.bottom ? w->input.bottom : 1;
+ }
- status = XRectInRegion (md->region, x, y, width, height);
+ status = XRectInRegion (md->region, xRoot, y, 1, height);
/* only constrain movement if previous position was valid */
if (md->status == RectangleIn)
{
- int xStatus = status;
-
- while (dx && xStatus != RectangleIn)
- {
- xStatus = XRectInRegion (md->region,
- x, y - dy, width, height);
-
- if (xStatus != RectangleIn)
- dx += (dx < 0) ? 1 : -1;
-
- x = w->attrib.x + dx - w->input.left;
- }
-
while (dy && status != RectangleIn)
{
status = XRectInRegion (md->region,
- x, y, width, height);
+ xRoot, y, 1, height);
if (status != RectangleIn)
dy += (dy < 0) ? 1 : -1;
- y = w->attrib.y + dy - w->input.top;
+ y = w->attrib.y + dy +
+ (constrainTop ? (-w->input.top) : w->height);
}
}
else
@@ -735,17 +731,29 @@ static void moveDisplayInitOptions(MoveDisplay * md)
o->rest.i.min = MOVE_OPACITY_MIN;
o->rest.i.max = MOVE_OPACITY_MAX;
- o = &md->opt[MOVE_DISPLAY_OPTION_CONSTRAIN_Y];
+ o = &md->opt[MOVE_DISPLAY_OPTION_CONSTRAIN_Y_TOP];
+ o->advanced = False;
+ o->name = "constrain_y_top";
+ o->group = N_("Misc. options");
+ o->subGroup = N_("Movement constraints");
+ o->displayHints = "";
+ o->shortDesc = N_("Constrain Y to top of screen");
+ o->longDesc =
+ N_("Prevent windows from moving over the top of the screen");
+ o->type = CompOptionTypeBool;
+ o->value.b = MOVE_CONSTRAIN_Y_TOP_DEFAULT;
+
+ o = &md->opt[MOVE_DISPLAY_OPTION_CONSTRAIN_Y_BOTTOM];
o->advanced = False;
- o->name = "constrain_y";
+ o->name = "constrain_y_bottom";
o->group = N_("Misc. options");
- o->subGroup = N_("");
+ o->subGroup = N_("Movement constraints");
o->displayHints = "";
- o->shortDesc = N_("Constrain Y to screen area");
+ o->shortDesc = N_("Constrain Y to bottom");
o->longDesc =
- N_("Prevent windows from moving out of the screen vertically");
+ N_("Prevent windows from moving past the bottom of the screen");
o->type = CompOptionTypeBool;
- o->value.b = MOVE_CONSTRAIN_Y_DEFAULT;
+ o->value.b = MOVE_CONSTRAIN_Y_BOTTOM_DEFAULT;
o = &md->opt[MOVE_DISPLAY_OPTION_SNAPOFF_MAXIMIZED];
o->advanced = False;
@@ -844,7 +852,8 @@ moveSetDisplayOption(CompDisplay * display,
if (compSetIntOption(o, value))
return TRUE;
break;
- case MOVE_DISPLAY_OPTION_CONSTRAIN_Y:
+ case MOVE_DISPLAY_OPTION_CONSTRAIN_Y_TOP:
+ case MOVE_DISPLAY_OPTION_CONSTRAIN_Y_BOTTOM:
case MOVE_DISPLAY_OPTION_SNAPOFF_MAXIMIZED:
if (compSetBoolOption(o, value))
return TRUE;