From 3d2c6eb3ca2d5874ca7c535c37ba9e167245a6ab Mon Sep 17 00:00:00 2001 From: sabetts Date: Wed, 28 Feb 2001 05:30:55 +0000 Subject: * actions.c: "maximize" user command calls cmd_maximize * manage.c (force_maximize): moved from actions.c (maximize): likewise (maximize_normal): likewise (maximize_transient): likewise * actions.c (cmd_maximize): New function --- src/ChangeLog | 9 ++++ src/actions.c | 144 ++-------------------------------------------------------- src/actions.h | 3 +- src/manage.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/manage.h | 3 ++ 5 files changed, 156 insertions(+), 142 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index d51b88b..6e7be47 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2001-02-27 shawn + * actions.c: "maximize" user command calls cmd_maximize + + * manage.c (force_maximize): moved from actions.c + (maximize): likewise + (maximize_normal): likewise + (maximize_transient): likewise + + * actions.c (cmd_maximize): New function + * main.c (handler): Prepends error message with "ERROR: ". Displays error in message bar. Returns 0. diff --git a/src/actions.c b/src/actions.c index 40ea996..681504e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -145,7 +145,7 @@ user_command user_commands[] = {"windows", cmd_windows, arg_VOID}, {"title", cmd_rename, arg_STRING}, {"clock", cmd_clock, arg_VOID}, - {"maximize", force_maximize, arg_VOID}, + {"maximize", cmd_maximize, arg_VOID}, {"newwm", cmd_newwm, arg_STRING}, {"generate", cmd_generate, arg_STRING}, /* rename to stuff */ {"version", cmd_version, arg_VOID}, @@ -684,145 +684,9 @@ cmd_abort (void *data) /* XSync (dpy, False); */ /* } */ -/* Set a transient window's x,y,width,height fields to maximize the - window. */ -static void -maximize_transient (rp_window *win) -{ - int maxx, maxy; - - /* Honour the window's maximum size */ - if (win->hints->flags & PMaxSize) - { - maxx = win->hints->max_width; - maxy = win->hints->max_height; - } - else - { - 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; - - 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; - } - } - - PRINT_DEBUG ("maxsize: %d %d\n", maxx, maxy); - - 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; -} - -/* 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; - - /* Honour the window's maximum size */ - if (win->hints->flags & PMaxSize) - { - maxx = win->hints->max_width; - maxy = win->hints->max_height; - - /* centre the non-maximized window */ -/* off_x = ((win->scr->root_attr.width - PADDING_LEFT - PADDING_RIGHT) - win->hints->max_width) / 2; */ -/* off_y = ((win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM) - win->hints->max_height) / 2; */ - } - else - { - 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; - - 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; - } - } - - PRINT_DEBUG ("maxsize: %d %d\n", 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 */ +/* Maximize the current window. */ void -maximize (void *data) +cmd_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); -} - -/* Maximize the current window but don't treat transient windows - differently. */ -void -force_maximize (void *data) -{ - rp_window *win = (rp_window *)data; - - if (!win) win = rp_current_window; - if (!win) return; - - maximize_normal(win); - - /* Actually do the maximizing */ - XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width+1, win->height+1); - XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width, win->height); - - XSync (dpy, False); + force_maximize (rp_current_window); } diff --git a/src/actions.h b/src/actions.h index 45c856b..7014fa8 100644 --- a/src/actions.h +++ b/src/actions.h @@ -40,8 +40,6 @@ user_command void bye(void *dummy); void spawn(void *data); void command (char *data); -void maximize (void *data); -void force_maximize (void *data); void cmd_newwm(void *which); void cmd_generate (void *data); @@ -62,6 +60,7 @@ void cmd_version (void *data); void cmd_unimplemented (void *data); void cmd_bind (void* data); void cmd_source (void* data); +void cmd_maximize (void *data); /* void cmd_xterm (void *data); */ diff --git a/src/manage.c b/src/manage.c index ebdae08..aaed647 100644 --- a/src/manage.c +++ b/src/manage.c @@ -296,3 +296,142 @@ set_state (rp_window *win, int state) XChangeProperty (dpy, win->w, wm_state, wm_state, 32, PropModeReplace, (unsigned char *)data, 2); } + +/* Set a transient window's x,y,width,height fields to maximize the + window. */ +static void +maximize_transient (rp_window *win) +{ + int maxx, maxy; + + /* Honour the window's maximum size */ + if (win->hints->flags & PMaxSize) + { + maxx = win->hints->max_width; + maxy = win->hints->max_height; + } + else + { + 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; + + 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; + } + } + + PRINT_DEBUG ("maxsize: %d %d\n", maxx, maxy); + + 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; +} + +/* 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; + + /* Honour the window's maximum size */ + if (win->hints->flags & PMaxSize) + { + maxx = win->hints->max_width; + maxy = win->hints->max_height; + + /* centre the non-maximized window */ +/* off_x = ((win->scr->root_attr.width - PADDING_LEFT - PADDING_RIGHT) - win->hints->max_width) / 2; */ +/* off_y = ((win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM) - win->hints->max_height) / 2; */ + } + else + { + 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; + + 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; + } + } + + PRINT_DEBUG ("maxsize: %d %d\n", 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 (rp_window *win) +{ + 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); +} + +/* Maximize the current window but don't treat transient windows + differently. */ +void +force_maximize (rp_window *win) +{ + if (!win) win = rp_current_window; + if (!win) return; + + maximize_normal(win); + + /* Actually do the maximizing */ + XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width+1, win->height+1); + XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width, win->height); + + XSync (dpy, False); +} diff --git a/src/manage.h b/src/manage.h index acfa68b..2d0eabc 100644 --- a/src/manage.h +++ b/src/manage.h @@ -35,4 +35,7 @@ void rename_current_window (); void send_configure (rp_window *win); void set_state (rp_window *win, int state); +void maximize (rp_window *win); +void force_maximize (rp_window *win); + #endif /* ! _RATPOISION_MANAGE_H */ -- cgit v1.2.3