summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/actions.c131
-rw-r--r--src/events.c2
-rw-r--r--src/manage.c26
-rw-r--r--src/manage.h1
5 files changed, 114 insertions, 63 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e92cc86..363527a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,20 @@
+2001-02-11 shawn <sabetts@diggin.lamenet.tmp>
+
+ * manage.h (set_state): Added prototype
+
+ * manage.c (send_configure): Now sends the window's x,y,width,height
+ coordinates.
+ (set_state): Added
+
+ * events.c (map_request): Calls set_state when mapping an unmapped
+ window.
+
+ * actions.c (maximize_transient): takes an rp_window as the
+ argument. Removed code to handle void *data. Incremental resizing
+ only happens if the maximum size isn't set. Removed actual X
+ maximization code.
+ (maximize): Moved meat to maximize_normal().
+
2001-02-10 Ryan Yeske <rcyeske@cut.hotdog.tmp>
* ratpoison.h: #include "messages.h"
diff --git a/src/actions.c b/src/actions.c
index 4aac6ca..b0b3d9a 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -354,16 +354,12 @@ generate_prefix (void *data)
}
-/* Maximize a transient window. The current window if data = 0, otherwise assume it is a
- pointer to a window that should be maximized */
+/* Set a transient window's x,y,width,height fields to maximize the
+ window. */
static void
-maximize_transient (void *data)
+maximize_transient (rp_window *win)
{
- int x, y, maxx, maxy;
- rp_window *win = (rp_window *)data;
-
- if (!win) win = rp_current_window;
- if (!win) return;
+ int maxx, maxy;
/* Honour the window's maximum size */
if (win->hints->flags & PMaxSize)
@@ -375,56 +371,42 @@ maximize_transient (void *data)
{
maxx = win->width;
maxy = win->height;
- }
- /* Make sure we maximize to the nearest Resize Increment specified
- by the window */
- if (win->hints->flags & PResizeInc)
- {
- int amount;
+ /* Make sure we maximize to the nearest Resize Increment specified
+ by the window */
+ if (win->hints->flags & PResizeInc)
+ {
+ int amount;
- amount = maxx - win->width;
- amount -= amount % win->hints->width_inc;
- PRINT_DEBUG ("amount x: %d\n", amount);
- maxx = amount + win->width;
+ amount = maxx - win->width;
+ amount -= amount % win->hints->width_inc;
+ PRINT_DEBUG ("amount x: %d\n", amount);
+ maxx = amount + win->width;
- amount = maxy - win->height;
- amount -= amount % win->hints->height_inc;
- PRINT_DEBUG ("amount y: %d\n", amount);
- maxy = amount + win->height;
+ amount = maxy - win->height;
+ amount -= amount % win->hints->height_inc;
+ PRINT_DEBUG ("amount y: %d\n", amount);
+ maxy = amount + win->height;
+ }
}
PRINT_DEBUG ("maxsize: %d %d\n", maxx, maxy);
- x = PADDING_LEFT - win->width / 2 + (win->scr->root_attr.width - PADDING_LEFT - PADDING_RIGHT) / 2;
- y = PADDING_TOP - win->height / 2 + (win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM) / 2;
-
- XMoveResizeWindow (dpy, win->w, x, y, maxx, maxy);
- XSync (dpy, False);
+ win->x = PADDING_LEFT - win->width / 2 + (win->scr->root_attr.width - PADDING_LEFT - PADDING_RIGHT) / 2;;
+ win->y = PADDING_TOP - win->height / 2 + (win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM) / 2;;
+ win->width = maxx;
+ win->height = maxy;
}
-/* Maximize the current window if data = 0, otherwise assume it is a
- pointer to a window that should be maximized */
-void
-maximize (void *data)
+/* set a good standard window's x,y,width,height fields to maximize the window. */
+static void
+maximize_normal (rp_window *win)
{
int maxx, maxy;
int off_x = 0;
int off_y = 0;
- rp_window *win = (rp_window *)data;
-
- if (!win) win = rp_current_window;
- if (!win) return;
-
- /* Handle maximizing transient windows differently */
- if (win->transient)
- {
- maximize_transient (data);
- return;
- }
-
/* Honour the window's maximum size */
if (win->hints->flags & PMaxSize)
{
@@ -439,27 +421,60 @@ maximize (void *data)
{
maxx = win->scr->root_attr.width - PADDING_LEFT - PADDING_RIGHT;
maxy = win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM;
- }
- /* Make sure we maximize to the nearest Resize Increment specified
- by the window */
- if (win->hints->flags & PResizeInc)
- {
- int amount;
+ /* Make sure we maximize to the nearest Resize Increment specified
+ by the window */
+ if (win->hints->flags & PResizeInc)
+ {
+ int amount;
- amount = maxx - win->width;
- amount -= amount % win->hints->width_inc;
- PRINT_DEBUG ("amount x: %d\n", amount);
- maxx = amount + win->width;
+ amount = maxx - win->width;
+ amount -= amount % win->hints->width_inc;
+ PRINT_DEBUG ("amount x: %d\n", amount);
+ maxx = amount + win->width;
- amount = maxy - win->height;
- amount -= amount % win->hints->height_inc;
- PRINT_DEBUG ("amount y: %d\n", amount);
- maxy = amount + win->height;
+ amount = maxy - win->height;
+ amount -= amount % win->hints->height_inc;
+ PRINT_DEBUG ("amount y: %d\n", amount);
+ maxy = amount + win->height;
+ }
}
PRINT_DEBUG ("maxsize: %d %d\n", maxx, maxy);
- XMoveResizeWindow (dpy, win->w, PADDING_LEFT + off_x, PADDING_TOP + off_y, maxx, maxy);
+ win->x = PADDING_LEFT + off_x;
+ win->y = PADDING_TOP + off_y;
+ win->width = maxx;
+ win->height = maxy;
+}
+
+
+/* Maximize the current window if data = 0, otherwise assume it is a
+ pointer to a window that should be maximized */
+void
+maximize (void *data)
+{
+ rp_window *win = (rp_window *)data;
+
+ if (!win) win = rp_current_window;
+ if (!win) return;
+
+ /* Handle maximizing transient windows differently */
+ if (win->transient)
+ {
+ maximize_transient (win);
+ }
+ else
+ {
+ maximize_normal (win);
+ }
+
+ /* Actually do the maximizing */
+ XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width, win->height);
+
+ /* I don't think this should be here, but it doesn't seem to hurt. */
+ send_configure (win);
+
XSync (dpy, False);
}
+
diff --git a/src/events.c b/src/events.c
index b95218c..a2edacd 100644
--- a/src/events.c
+++ b/src/events.c
@@ -119,7 +119,9 @@ map_request (XEvent *ev)
}
case STATE_MAPPED:
PRINT_DEBUG ("Mapped Window\n");
+ XMapWindow (dpy, win->w);
XMapRaised (dpy, win->w);
+ set_state (win, NormalState);
set_active_window (win);
}
}
diff --git a/src/manage.c b/src/manage.c
index fe04604..f37af49 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -142,11 +142,11 @@ send_configure (rp_window *win)
ce.type = ConfigureNotify;
ce.event = win->w;
ce.window = win->w;
- ce.x = PADDING_LEFT;
- ce.y = PADDING_TOP;
- ce.width = win->scr->root_attr.width - PADDING_LEFT - PADDING_RIGHT;
- ce.height = win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM;
- ce.border_width = 0;
+ ce.x = win->x;
+ ce.y = win->y;
+ ce.width = win->width;
+ ce.height = win->height;
+ ce.border_width = win->border;
ce.above = None;
ce.override_redirect = 0;
@@ -244,3 +244,19 @@ unmanaged_window (Window w)
return 0;
}
+/* Set the state of the window.
+
+ FIXME: This is sort of broken. We should really record the state in
+ win->state and mimic the X states NormalState, WithdrawnState,
+ IconicState */
+void
+set_state (rp_window *win, int state)
+{
+ long data[2];
+
+ data[0] = (long)state;
+ data[1] = (long)None;
+
+ XChangeProperty (dpy, win->w, wm_state, wm_state, 32,
+ PropModeReplace, (unsigned char *)data, 2);
+}
diff --git a/src/manage.h b/src/manage.h
index 2df31c7..6519392 100644
--- a/src/manage.h
+++ b/src/manage.h
@@ -30,5 +30,6 @@ int update_window_name (rp_window *win);
void update_normal_hints (rp_window *win);
void rename_current_window ();
void send_configure (rp_window *win);
+void set_state (rp_window *win, int state);
#endif /* _MANAGE_H */