summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/wobbly.c
diff options
context:
space:
mode:
authormaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-31 11:54:29 +0000
committermaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-31 11:54:29 +0000
commit5719745c778d69085e0961ace74b6af308b66955 (patch)
tree1f38a40731100379ec44e57ab046a6efcec247a1 /beryl-plugins/src/wobbly.c
parent9e5889c90199b18faf07c2013c42c3cfd8d40976 (diff)
downloadmarex-dev-5719745c778d69085e0961ace74b6af308b66955.tar.gz
marex-dev-5719745c778d69085e0961ace74b6af308b66955.tar.bz2
beryl-plugins (wobbly):
snap to struts instead of workarea (David Reveman) git-svn-id: file:///beryl/trunk@2190 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/wobbly.c')
-rw-r--r--beryl-plugins/src/wobbly.c321
1 files changed, 109 insertions, 212 deletions
diff --git a/beryl-plugins/src/wobbly.c b/beryl-plugins/src/wobbly.c
index 9b5dbb5..bcc5af7 100644
--- a/beryl-plugins/src/wobbly.c
+++ b/beryl-plugins/src/wobbly.c
@@ -958,13 +958,18 @@ static CompOption *wobblyGetScreenOptions(CompScreen * screen, int *count)
}
}
+#define SNAP_WINDOW_TYPE (CompWindowTypeNormalMask | \
+ CompWindowTypeToolbarMask | \
+ CompWindowTypeMenuMask | \
+ CompWindowTypeUtilMask)
+
static void findNextWestEdge(CompWindow * w, Object * object)
{
int v, v1, v2;
int s, start;
int e, end;
int x;
- int i;
+ int output;
start = -65535.0f;
end = 65535.0f;
@@ -974,64 +979,33 @@ static void findNextWestEdge(CompWindow * w, Object * object)
x = object->position.x + w->output.left - w->input.left;
- if (x >= w->screen->workArea.x)
+ output = outputDeviceForPoint (w->screen, x, object->position.y);
+
+ if (x >= w->screen->outputDev[output].region.extents.x1)
{
CompWindow *p;
- if (w->screen->nOutputDev > 1)
- {
- for (i = 1; i <= w->screen->nOutputDev; i++)
- {
- XRectangle workArea;
-
- screenGetOutputDevWorkArea(w->screen, i, &workArea);
- s = workArea.y;
- e = workArea.y + workArea.height;
-
- if (s > object->position.y)
- {
- if (s < end)
- end = s;
- }
- else if (e < object->position.y)
- {
- if (e > start)
- start = e;
- }
- else
- {
- if (s > start)
- start = s;
-
- if (e < end)
- end = e;
-
- v = workArea.x;
- if (v <= x)
- {
- if (v > v1)
- v1 = v;
- }
- else
- {
- if (v < v2)
- v2 = v;
- }
- }
- }
- }
- else
- {
- v1 = w->screen->workArea.x;
- }
+ v1 = w->screen->outputDev[output].region.extents.x1;
for (p = w->screen->windows; p; p = p->next)
{
- if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+ if (w == p)
continue;
- s = p->attrib.y - p->output.top;
- e = p->attrib.y + p->height + p->output.bottom;
+ if (p->mapNum && p->struts)
+ {
+ s = p->struts->left.y - w->output.top;
+ e = p->struts->left.y + p->struts->left.height +
+ w->output.bottom;
+ }
+ else if (!p->invisible && (p->type & SNAP_WINDOW_TYPE))
+ {
+ s = p->attrib.y - p->output.top - w->output.top;
+ e = p->attrib.y + p->height + p->output.bottom +
+ w->output.bottom;
+ }
+ else
+ continue;
if (s > object->position.y)
{
@@ -1051,7 +1025,11 @@ static void findNextWestEdge(CompWindow * w, Object * object)
if (e < end)
end = e;
- v = p->attrib.x + p->width + p->input.right;
+ if (p->mapNum && p->struts)
+ v = p->struts->left.x + p->struts->left.width;
+ else
+ v = p->attrib.x + p->width + p->input.right;
+
if (v <= x)
{
if (v > v1)
@@ -1067,7 +1045,7 @@ static void findNextWestEdge(CompWindow * w, Object * object)
}
else
{
- v2 = w->screen->workArea.x;
+ v2 = w->screen->outputDev[output].region.extents.x2;
}
v1 = v1 - w->output.left + w->input.left;
@@ -1094,7 +1072,7 @@ static void findNextEastEdge(CompWindow * w, Object * object)
int s, start;
int e, end;
int x;
- int i;
+ int output;
start = -65535.0f;
end = 65535.0f;
@@ -1104,64 +1082,33 @@ static void findNextEastEdge(CompWindow * w, Object * object)
x = object->position.x - w->output.right + w->input.right;
- if (x <= w->screen->workArea.x + w->screen->workArea.width)
+ output = outputDeviceForPoint (w->screen, x, object->position.y);
+
+ if (x <= w->screen->outputDev[output].region.extents.x2)
{
CompWindow *p;
- if (w->screen->nOutputDev > 1)
- {
- for (i = 1; i <= w->screen->nOutputDev; i++)
- {
- XRectangle workArea;
-
- screenGetOutputDevWorkArea(w->screen, i, &workArea);
- s = workArea.y;
- e = workArea.y + workArea.height;
-
- if (s > object->position.y)
- {
- if (s < end)
- end = s;
- }
- else if (e < object->position.y)
- {
- if (e > start)
- start = e;
- }
- else
- {
- if (s > start)
- start = s;
-
- if (e < end)
- end = e;
-
- v = workArea.x + workArea.width;
- if (v >= x)
- {
- if (v < v1)
- v1 = v;
- }
- else
- {
- if (v > v2)
- v2 = v;
- }
- }
- }
- }
- else
- {
- v1 = w->screen->workArea.x + w->screen->workArea.width;
- }
+ v1 = w->screen->outputDev[output].region.extents.x2;
for (p = w->screen->windows; p; p = p->next)
{
- if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+ if (w == p)
continue;
- s = p->attrib.y - p->output.top;
- e = p->attrib.y + p->height + p->output.bottom;
+ if (p->mapNum && p->struts)
+ {
+ s = p->struts->right.y - w->output.top;
+ e = p->struts->right.y + p->struts->right.height +
+ w->output.bottom;
+ }
+ else if (!p->invisible && (p->type & SNAP_WINDOW_TYPE))
+ {
+ s = p->attrib.y - p->output.top - w->output.top;
+ e = p->attrib.y + p->height + p->output.bottom +
+ w->output.bottom;
+ }
+ else
+ continue;
if (s > object->position.y)
{
@@ -1181,7 +1128,11 @@ static void findNextEastEdge(CompWindow * w, Object * object)
if (e < end)
end = e;
- v = p->attrib.x - p->input.left;
+ if (p->mapNum && p->struts)
+ v = p->struts->right.x;
+ else
+ v = p->attrib.x - p->input.left;
+
if (v >= x)
{
if (v < v1)
@@ -1197,7 +1148,7 @@ static void findNextEastEdge(CompWindow * w, Object * object)
}
else
{
- v2 = w->screen->workArea.x + w->screen->workArea.width;
+ v2 = w->screen->outputDev[output].region.extents.x2;
}
v1 = v1 + w->output.right - w->input.right;
@@ -1224,7 +1175,7 @@ static void findNextNorthEdge(CompWindow * w, Object * object)
int s, start;
int e, end;
int y;
- int i;
+ int output;
start = -65535.0f;
end = 65535.0f;
@@ -1234,64 +1185,33 @@ static void findNextNorthEdge(CompWindow * w, Object * object)
y = object->position.y + w->output.top - w->input.top;
- if (y >= w->screen->workArea.y)
+ output = outputDeviceForPoint (w->screen, object->position.x, y);
+
+ if (y >= w->screen->outputDev[output].region.extents.y1)
{
CompWindow *p;
- if (w->screen->nOutputDev > 1)
- {
- for (i = 1; i <= w->screen->nOutputDev; i++)
- {
- XRectangle workArea;
-
- screenGetOutputDevWorkArea(w->screen, i, &workArea);
- s = workArea.x;
- e = workArea.x + workArea.width;
-
- if (s > object->position.x)
- {
- if (s < end)
- end = s;
- }
- else if (e < object->position.x)
- {
- if (e > start)
- start = e;
- }
- else
- {
- if (s > start)
- start = s;
-
- if (e < end)
- end = e;
-
- v = workArea.y;
- if (v <= y)
- {
- if (v > v1)
- v1 = v;
- }
- else
- {
- if (v < v2)
- v2 = v;
- }
- }
- }
- }
- else
- {
- v1 = w->screen->workArea.y;
- }
+ v1 = w->screen->outputDev[output].region.extents.y1;
for (p = w->screen->windows; p; p = p->next)
{
- if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+ if (w == p)
continue;
- s = p->attrib.x - p->output.left;
- e = p->attrib.x + p->width + p->output.right;
+ if (p->mapNum && p->struts)
+ {
+ s = p->struts->top.x - w->output.left;
+ e = p->struts->top.x + p->struts->top.width +
+ w->output.right;
+ }
+ else if (!p->invisible && (p->type & SNAP_WINDOW_TYPE))
+ {
+ s = p->attrib.x - p->output.left - w->output.left;
+ e = p->attrib.x + p->width + p->output.right +
+ w->output.right;
+ }
+ else
+ continue;
if (s > object->position.x)
{
@@ -1311,7 +1231,11 @@ static void findNextNorthEdge(CompWindow * w, Object * object)
if (e < end)
end = e;
- v = p->attrib.y + p->height + p->input.bottom;
+ if (p->mapNum && p->struts)
+ v = p->struts->top.y + p->struts->top.height;
+ else
+ v = p->attrib.y + p->height + p->input.bottom;
+
if (v <= y)
{
if (v > v1)
@@ -1327,7 +1251,7 @@ static void findNextNorthEdge(CompWindow * w, Object * object)
}
else
{
- v2 = w->screen->workArea.y;
+ v2 = w->screen->outputDev[output].region.extents.y1;
}
v1 = v1 - w->output.top + w->input.top;
@@ -1354,7 +1278,7 @@ static void findNextSouthEdge(CompWindow * w, Object * object)
int s, start;
int e, end;
int y;
- int i;
+ int output;
start = -65535.0f;
end = 65535.0f;
@@ -1364,64 +1288,33 @@ static void findNextSouthEdge(CompWindow * w, Object * object)
y = object->position.y - w->output.bottom + w->input.bottom;
- if (y <= w->screen->workArea.y + w->screen->workArea.height)
+ output = outputDeviceForPoint (w->screen, object->position.x, y);
+
+ if (y <= w->screen->outputDev[output].region.extents.y2)
{
CompWindow *p;
- if (w->screen->nOutputDev > 1)
- {
- for (i = 1; i <= w->screen->nOutputDev; i++)
- {
- XRectangle workArea;
-
- screenGetOutputDevWorkArea(w->screen, i, &workArea);
- s = workArea.x;
- e = workArea.x + workArea.width;
-
- if (s > object->position.x)
- {
- if (s < end)
- end = s;
- }
- else if (e < object->position.x)
- {
- if (e > start)
- start = e;
- }
- else
- {
- if (s > start)
- start = s;
-
- if (e < end)
- end = e;
-
- v = workArea.y + workArea.height;
- if (v >= y)
- {
- if (v < v1)
- v1 = v;
- }
- else
- {
- if (v > v2)
- v2 = v;
- }
- }
- }
- }
- else
- {
- v1 = w->screen->workArea.y + w->screen->workArea.height;
- }
+ v1 = w->screen->outputDev[output].region.extents.y2;
for (p = w->screen->windows; p; p = p->next)
{
- if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+ if (w == p)
continue;
- s = p->attrib.x - p->output.left;
- e = p->attrib.x + p->width + p->output.right;
+ if (p->mapNum && p->struts)
+ {
+ s = p->struts->bottom.x - w->output.left;
+ e = p->struts->bottom.x + p->struts->bottom.width +
+ w->output.right;
+ }
+ else if (!p->invisible && (p->type & SNAP_WINDOW_TYPE))
+ {
+ s = p->attrib.x - p->output.left - w->output.left;
+ e = p->attrib.x + p->width + p->output.right +
+ w->output.right;
+ }
+ else
+ continue;
if (s > object->position.x)
{
@@ -1441,7 +1334,11 @@ static void findNextSouthEdge(CompWindow * w, Object * object)
if (e < end)
end = e;
- v = p->attrib.y - p->input.top;
+ if (p->mapNum && p->struts)
+ v = p->struts->bottom.y;
+ else
+ v = p->attrib.y - p->input.top;
+
if (v >= y)
{
if (v < v1)
@@ -1457,7 +1354,7 @@ static void findNextSouthEdge(CompWindow * w, Object * object)
}
else
{
- v2 = w->screen->workArea.y + w->screen->workArea.height;
+ v2 = w->screen->outputDev[output].region.extents.y2;
}
v1 = v1 + w->output.bottom - w->input.bottom;