summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--src/events.c36
-rw-r--r--src/manage.c42
3 files changed, 56 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index ad596b5..c1ce77e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-02-14 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/manage.c (maximize_transient): correctly detect when the
+ window is bigger than its frame.
+ (maximize): ignore the structure events generated by the maximize
+ (force_maximize): likewise
+ (unhide_window): likewise
+ (unhide_window_below): likewise
+
+ * src/events.c (configure_notify): Clear up ambiguous debugging
+ output.
+ (configure_request): initialize the changes structure to the
+ window's current attributes.
+
2002-02-07 Shawn Betts <sabetts@vcn.bc.ca>
* src/split.h (find_last_frame): prototype now correctly reflects
diff --git a/src/events.c b/src/events.c
index 6151db0..ad3d21d 100644
--- a/src/events.c
+++ b/src/events.c
@@ -226,8 +226,6 @@ configure_notify (XConfigureEvent *e)
win = find_window (e->window);
- PRINT_DEBUG("event=%ld window=%ld\n", e->event, e->window);
-
if (win && win->state == NormalState)
{
if (win->height != e->height
@@ -243,8 +241,8 @@ configure_notify (XConfigureEvent *e)
know the real size of the window to increment properly. So,
update the structure before calling maximize. */
- PRINT_DEBUG ("x=%d y=%d width=%d height=%d\n", e->x, e->y, e->width, e->height);
- PRINT_DEBUG ("x=%d y=%d width=%d height=%d\n", win->x, win->y, win->width, win->height);
+ PRINT_DEBUG ("Notify geom: x=%d y=%d width=%d height=%d\n", e->x, e->y, e->width, e->height);
+ PRINT_DEBUG ("Current geom: x=%d y=%d width=%d height=%d\n", win->x, win->y, win->width, win->height);
win->x = e->x;
win->y = e->y;
@@ -261,7 +259,6 @@ configure_notify (XConfigureEvent *e)
static void
configure_request (XConfigureRequestEvent *e)
{
- int border;
XWindowChanges changes;
rp_window *win;
@@ -269,8 +266,12 @@ configure_request (XConfigureRequestEvent *e)
if (win)
{
- /* Initialize border variable. */
- border = win->border;
+ /* Initialize the XWindowChanges structure. */
+ changes.x = win->x;
+ changes.y = win->y;
+ changes.width = win->width;
+ changes.height = win->height;
+ changes.border_width = win->border;
if (e->value_mask & CWStackMode)
{
@@ -308,7 +309,6 @@ configure_request (XConfigureRequestEvent *e)
if (e->value_mask & CWBorderWidth)
{
changes.border_width = e->border_width;
- border = e->border_width;
PRINT_DEBUG("request CWBorderWidth %d\n", e->border_width);
}
@@ -317,40 +317,24 @@ configure_request (XConfigureRequestEvent *e)
changes.width = e->width;
PRINT_DEBUG("request CWWidth %d\n", e->width);
}
- else
- {
- changes.width = win->width;
- }
if (e->value_mask & CWHeight)
{
changes.height = e->height;
PRINT_DEBUG("request CWHeight %d\n", e->height);
}
- else
- {
- changes.height = win->height;
- }
if (e->value_mask & CWX)
{
- changes.x = e->x + border;
+ changes.x = e->x;
PRINT_DEBUG("request CWX %d\n", e->x);
}
- else
- {
- changes.x = win->x;
- }
if (e->value_mask & CWY)
{
- changes.y = e->y + border;
+ changes.y = e->y;
PRINT_DEBUG("request CWY %d\n", e->y);
}
- else
- {
- changes.y = win->y;
- }
if (e->value_mask & (CWX|CWY|CWBorderWidth|CWWidth|CWHeight))
{
diff --git a/src/manage.c b/src/manage.c
index 7c5c148..1d941b2 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -472,8 +472,8 @@ maximize_transient (rp_window *win)
PRINT_DEBUG ("frame width=%d height=%d\n",
frame->width, frame->height);
- if (maxx > frame->width) maxx = frame->width - win->border * 2;
- if (maxy > frame->height) maxy = frame->height - win->border * 2;
+ if (maxx + win->border * 2 > frame->width) maxx = frame->width - win->border * 2;
+ if (maxy + win->border * 2 > frame->height) maxy = frame->height - win->border * 2;
}
/* Make sure we maximize to the nearest Resize Increment specified
@@ -577,20 +577,24 @@ maximize (rp_window *win)
/* Handle maximizing transient windows differently. */
if (win->transient)
- {
- maximize_transient (win);
- }
+ maximize_transient (win);
else
- {
- maximize_normal (win);
- }
+ maximize_normal (win);
/* Reposition the window. */
move_window (win);
- /* Actually do the maximizing */
+ PRINT_DEBUG ("Resizing window '%s' to x:%d y:%d w:%d h:%d\n", window_name (win),
+ win->x, win->y, win->width, win->height);
+
+
+ /* Actually do the maximizing, and ignore the event created by the
+ maximizing. */
+ XSelectInput (dpy, win->w, WIN_EVENTS&~(StructureNotifyMask));
XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width, win->height);
XSetWindowBorderWidth (dpy, win->w, win->border);
+ XSelectInput (dpy, win->w, WIN_EVENTS);
+
XSync (dpy, False);
}
@@ -607,6 +611,13 @@ force_maximize (rp_window *win)
/* Reposition the window. */
move_window (win);
+ /* Don't listen to the events caused by the maximize. */
+ XSelectInput (dpy, win->w, WIN_EVENTS&~(StructureNotifyMask));
+
+ /* This little dance is to force a maximize event. If the window is
+ already "maximized" X11 will optimize away the event since to
+ geometry changes were made. This initial resize solves the
+ problem. */
if (win->hints->flags & PResizeInc)
{
XMoveResizeWindow (dpy, win->w, win->x, win->y,
@@ -618,8 +629,11 @@ force_maximize (rp_window *win)
XResizeWindow (dpy, win->w, win->width + 1, win->height + 1);
}
+ /* Resize the window to its proper maximum size. */
XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width, win->height);
XSetWindowBorderWidth (dpy, win->w, win->border);
+
+ XSelectInput (dpy, win->w, WIN_EVENTS);
XSync (dpy, False);
}
@@ -680,12 +694,17 @@ unhide_window (rp_window *win)
{
if (win == NULL) return;
- /* Always raise the window. */
+ /* Always raise the window. But ignore notify event. */
+ XSelectInput(dpy, win->w, WIN_EVENTS&~(StructureNotifyMask));
XRaiseWindow (dpy, win->w);
+ XSelectInput (dpy, win->w, WIN_EVENTS);
if (win->state != IconicState) return;
+ /* Ignore the notify event. */
+ XSelectInput(dpy, win->w, WIN_EVENTS&~(StructureNotifyMask));
XMapWindow (dpy, win->w);
+ XSelectInput (dpy, win->w, WIN_EVENTS);
set_state (win, NormalState);
}
@@ -702,7 +721,10 @@ unhide_window_below (rp_window *win)
if (win->state != IconicState) return;
+ /* Ignore the event caused by the window mapping. */
+ XSelectInput(dpy, win->w, WIN_EVENTS&~(StructureNotifyMask));
XMapWindow (dpy, win->w);
+ XSelectInput (dpy, win->w, WIN_EVENTS);
set_state (win, NormalState);
}