summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/place.c
diff options
context:
space:
mode:
authorracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-16 09:57:44 +0000
committerracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-16 09:57:44 +0000
commitace34eeb6102cba342d16490178a92443d06b34c (patch)
tree0a796e3c5e4172b594c4bf4befafa179e49a62a9 /beryl-plugins/src/place.c
parent225a6d96223c1b18224f7faf765dcfc7df4ea9c4 (diff)
downloadmarex-dev-ace34eeb6102cba342d16490178a92443d06b34c.tar.gz
marex-dev-ace34eeb6102cba342d16490178a92443d06b34c.tar.bz2
Cleanup, removal of obscure block comments, tests for && 0 and moving some 1 line functions to preprocessor macros, this code is horrible
git-svn-id: file:///beryl/trunk@1796 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/place.c')
-rw-r--r--beryl-plugins/src/place.c129
1 files changed, 19 insertions, 110 deletions
diff --git a/beryl-plugins/src/place.c b/beryl-plugins/src/place.c
index b9dcf97..2dfcff4 100644
--- a/beryl-plugins/src/place.c
+++ b/beryl-plugins/src/place.c
@@ -31,6 +31,9 @@
#define PLACE_WORKAROUND_DEFAULT TRUE
#define RECTANGLE_FROM_WINDOW(w) {w->attrib.x,w->attrib.y,w->attrib.width,w->attrib.height}
+#define GET_WINDOW_HEIGHT(w) (window->serverHeight + window->serverBorderWidth * 2)
+#define GET_WINDOW_WIDTH(w) (window->serverHeight + window->serverBorderWidth * 2)
+
static int displayPrivateIndex;
typedef struct _PlaceDisplay {
@@ -92,14 +95,6 @@ placeSetScreenOption(CompScreen * screen,
case PLACE_SCREEN_OPTION_WORKAROUND:
if (compSetBoolOption(o, value))
return TRUE;
- /*case PLACE_SCREEN_OPTION_CENTER_INITIATE:
- if (addScreenBinding (screen, &value->bind))
- {
- removeScreenBinding (screen, &o->value.bind);
-
- if (compSetBindingOption (o, value))
- return TRUE;
- } */
break;
case PLACE_SCREEN_OPTION_MODE:
if (compSetStringOption (o,value))
@@ -246,21 +241,14 @@ get_workarea_of_current_output_device(CompScreen * s, XRectangle * area)
screenGetOutputDevWorkArea(s, head, area);
}
-static int get_window_width(CompWindow * window)
-{
- return window->serverWidth + window->serverBorderWidth * 2;
-}
-static int get_window_height(CompWindow * window)
-{
- return window->serverHeight + window->serverBorderWidth * 2;
-}
+
static void placeCentered(CompWindow *window, int *x, int *y){
*x = window->screen->workArea.x + (window->screen->workArea.width
- - get_window_width(window)) /2;
+ - GET_WINDOW_WIDTH(window)) /2;
*y = window->screen->workArea.y + (window->screen->workArea.height
- - get_window_height(window)) /2;
+ - GET_WINDOW_HEIGHT(window)) /2;
}
@@ -332,9 +320,9 @@ find_next_cascade(CompWindow * window,
/* Find first cascade position that's not used. */
- window_width = get_window_width(window) + window->input.left +
+ window_width = GET_WINDOW_WIDTH(window) + window->input.left +
window->input.right;
- window_height = get_window_height(window) + window->input.top +
+ window_height = GET_WINDOW_HEIGHT(window) + window->input.top +
window->input.bottom;
cascade_stage = 0;
@@ -531,12 +519,6 @@ avoid_being_obscured_as_second_modal_dialog(CompWindow * window,
findWindowAtDisplay(window->screen->display,
window->screen->display->activeWindow);
- if (focus_window && (window->state & CompWindowStateModalMask) && 0 /* window->denied_focus_and_not_transient &&
- window_same_application (window, focus_window) &&
- window_intersect (window, focus_window) */
- ) {
- find_most_freespace(window, focus_window, *x, *y, x, y);
- }
}
static gboolean
@@ -751,17 +733,6 @@ find_first_fit(CompWindow * window,
return retval;
}
-/*static void
- placeCenterWindow (CompWindow *w)
- {
- int dx, dy;
-
- dx = ((w->screen->width - w->width) / 2) - w->attrib.x;
- dy = ((w->screen->height - w->height) / 2) - w->attrib.y;
-
- moveWindow (w, dx, dy, TRUE, FALSE);
- syncWindowPosition (w);
- }*/
static void
placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
@@ -777,8 +748,8 @@ placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
PLACE_SCREEN(window->screen);
- window_width = get_window_width(window);
- window_height = get_window_height(window);
+ window_width = GET_WINDOW_WIDTH(window);
+ window_height = GET_WINDOW_HEIGHT(window);
get_workarea_of_current_output_device(window->screen, &work_area);
@@ -904,22 +875,16 @@ placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
x = parent->attrib.x;
y = parent->attrib.y;
- w = get_window_width(parent);
+ w = GET_WINDOW_WIDTH(parent);
/* center of parent */
- x = x + w / 2;
-
- /* center of child over center of parent */
- x -= window_width / 2;
+ x = x + w / 2 - window_width / 2;
/* "visually" center window over parent, leaving twice as
* much space below as on top.
*/
- y += (get_window_height(parent) -
- window_height) / 3;
-
- /* put top of child's frame, not top of child's client */
- y += window->input.top;
+ y += (GET_WINDOW_HEIGHT(parent) -
+ window_height) / 3 += window->input.top;
/* clip to screen if parent is visible in current viewport */
if (parent->attrib.x < parent->screen->width &&
@@ -985,9 +950,9 @@ placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
continue;
if (wi->attrib.x >= work_area.x + work_area.width ||
- wi->attrib.x + get_window_width(wi) <= work_area.x ||
+ wi->attrib.x + GET_WINDOW_WIDTH(wi) <= work_area.x ||
wi->attrib.y >= work_area.y + work_area.height ||
- wi->attrib.y + get_window_height(wi) <= work_area.y)
+ wi->attrib.y + GET_WINDOW_HEIGHT(wi) <= work_area.y)
continue;
if (wi->attrib.override_redirect)
@@ -1023,27 +988,7 @@ placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
placeIntelligent(window, &x, &y);
}
- /* Maximize windows if they are too big for their work area (bit of
- * a hack here). Assume undecorated windows probably don't intend to
- * be maximized.
- *
- if (window->has_maximize_func &&
- window->decorated &&
- !window->fullscreen)
- {
- XRectangle workarea;
- XRectangle outer;
-
- workarea = s->workArea;
- getOuterRectOfWindow (window, &outer);
-
- if (outer.width >= workarea.width &&
- outer.height >= workarea.height)
- {
- window->maximize_after_placement = TRUE;
- }
- }
- */
+
done_check_denied_focus:
/* If the window is being denied focus and isn't a transient of the
@@ -1121,8 +1066,7 @@ placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
work_area.x + work_area.width)
x -= work_area.width;
- /*while (x - window->input.left < work_area.x)
- x += work_area.width; */
+
if (x - window->input.left < work_area.x)
x = work_area.x + window->input.left;
}
@@ -1158,42 +1102,7 @@ placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
*new_y = y;
}
-/*static void
- placeHandleEvent (CompDisplay *d, XEvent *event)
- {
- CompScreen *s;
- CompWindow *w;
-
- PLACE_DISPLAY (d);
-
- switch (event->type) {
- case KeyPress:
- case KeyRelease:
- case ButtonPress:
- case ButtonRelease:
- s = findScreenAtDisplay (d, event->xbutton.root);
-
- if (s)
- {
- PLACE_SCREEN (s);
-
- if (eventMatches(d, event, &ps->opt[PLACE_SCREEN_OPTION_CENTER_INITIATE]))
- {
- w = findWindowAtScreen (s, d->activeWindow);
- if (w) placeCenterWindow (w);
- }
- }
- break;
-
- default:
- break;
- }
-
- UNWRAP (pd, d, handleEvent);
- (*d->handleEvent) (d, event);
- WRAP (pd, d, handleEvent, placeHandleEvent);
-
- }*/
+
static Bool
placeDamageWindowRect(CompWindow * w, Bool initial, BoxPtr rect)