summaryrefslogtreecommitdiff
path: root/src/manage.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-04-01 01:17:53 +0000
committersabetts <sabetts>2001-04-01 01:17:53 +0000
commit299d16aa6ae37bd73ae92ee8a5d1c6715682ee35 (patch)
tree2361849e3956311464ab696132f35ed931946fd1 /src/manage.c
parentf04f2c8483f144d20caa9ee7103a0eca8493545f (diff)
downloadratpoison-299d16aa6ae37bd73ae92ee8a5d1c6715682ee35.zip
* src/split.h (find_window_for_frame): new function prototype
(find_window_for_frame): likewise (find_window_for_frame): likewise (find_window_for_frame): likewise (find_window_for_frame): likewise * src/split.c (window_fits_in_frame): new function (find_window_for_frame): likewise (split_window): likewise (v_split_window): likewise (h_split_window): likewise (remove_all_frames): likewise (frame_is_below): likewise (frame_is_above): likewise (frame_is_left): likewise (frame_is_right): likewise (total_frame_area): likewise (num_frames): likewise (frames_overlap): likewise (frame_overlaps): likewise (remove_frame): likewise * src/ratpoison.h: includes "split.h" * src/manage.c (unmanage): calls free_window (maximize_transient): takes the window's frame into account (maximize_normal): likewise * src/list.h (find_window_prev_with_frame): new function prototype (find_window_next_with_frame): likewise (free_window): likewise * src/list.c (free_window): new function (add_to_window_list): initialize new window's frame to NULL. (find_window_prev): skips windows with frames (find_window_next): likewise (find_window_other): likewise (find_window_prev_with_frame): new function (find_window_next_with_frame): new function (set_active_window): returns if the specified window is already the current window. (set_active_window): If the new window has no frame it inherits the current window's frame. (set_active_window): maximize and raise the newly active window. * src/events.c (unmap_notify): handles window frames. (destroy_window): simplified * src/data.h (struct rp_window_frame): new struct (struct rp_window): add frame variable * src/conf.h (WINDOW_BORDER_WIDTH): set to 1 * src/actions.h (cmd_next_frame): new function prototype (cmd_prev_frame): likewise (cmd_h_split): likewise (cmd_v_split): likewise (cmd_only): likewise (cmd_remove): likewise * src/actions.c (initialize_default_keybindings): new default bindings for "split", "vsplit", "focus", "only", "remove" (user_commands): new user commands "split", "vsplit", "focus", "only", "remove" (cmd_prev_frame): new function (cmd_next_frame): likewise (cmd_h_split): likewise (cmd_v_split): likewise (cmd_only): likewise (cmd_remove): likewise * src/Makefile.am (ratpoison_SOURCES): new files split.c split.h
Diffstat (limited to 'src/manage.c')
-rw-r--r--src/manage.c124
1 files changed, 75 insertions, 49 deletions
diff --git a/src/manage.c b/src/manage.c
index 9980f93..e8b1b06 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -195,16 +195,15 @@ unmanage (rp_window *w)
{
return_window_number (w->number);
remove_from_list (w);
- XFree (w->hints);
- free (w);
+ free_window (w);
#ifdef AUTO_CLOSE
if (rp_mapped_window_sentinel->next == rp_mapped_window_sentinel
&& rp_mapped_window_sentinel->prev == rp_mapped_window_sentinel)
{
/* If the mapped window list is empty then we have run out of
- managed windows, So kill ratpoison. */
+ managed windows, so kill ratpoison. */
/* FIXME: The unmapped window list may also have to be checked
in the case that the only mapped window in unmapped and
@@ -306,33 +305,45 @@ maximize_transient (rp_window *win)
{
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;
- if (amount < 0) 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;
- if (amount < 0) amount -= win->hints->height_inc;
- PRINT_DEBUG ("amount y: %d\n", amount);
- maxy = amount + 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;
+ if (amount < 0) 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;
+ if (amount < 0) 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 - win->border * 2) / 2;
- win->y = PADDING_TOP - win->height / 2
- + (win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM - win->border * 2) / 2;
+ /* Fit the window inside its frame (if it has one) */
+ if (win->frame)
+ {
+ win->x = win->frame->x - win->width / 2
+ + (win->frame->width - win->border * 2) / 2;
+ win->y = win->frame->y - win->height / 2
+ + (win->frame->height - win->border * 2) / 2;
+ }
+ else
+ {
+ win->x = PADDING_LEFT - win->width / 2
+ + (win->scr->root_attr.width - PADDING_LEFT - PADDING_RIGHT - win->border * 2) / 2;
+ win->y = PADDING_TOP - win->height / 2
+ + (win->scr->root_attr.height - PADDING_TOP - PADDING_BOTTOM - win->border * 2) / 2;
+ }
+
win->width = maxx;
win->height = maxy;
}
@@ -355,10 +366,6 @@ maximize_normal (rp_window *win)
{
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
{
@@ -366,31 +373,50 @@ maximize_normal (rp_window *win)
- PADDING_LEFT - PADDING_RIGHT - win->border * 2;
maxy = win->scr->root_attr.height
- PADDING_TOP - PADDING_BOTTOM - win->border * 2;
+ }
- /* 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;
- if (amount < 0) 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;
- if (amount < 0) amount -= win->hints->height_inc;
- PRINT_DEBUG ("amount y: %d\n", amount);
- maxy = amount + win->height;
- }
+ /* Fit the window inside its frame (if it has one) */
+ if (win->frame)
+ {
+ if (maxx > win->frame->width) maxx = win->frame->width
+ - win->border * 2;
+ if (maxy > win->frame->height) maxy = win->frame->height
+ - win->border * 2;
+ }
+
+ /* 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;
+ if (amount < 0) 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;
+ if (amount < 0) 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;
+ /* Fit the window inside its frame (if it has one) */
+ if (win->frame)
+ {
+ win->x = win->frame->x;
+ win->y = win->frame->y;
+ }
+ else
+ {
+ win->x = PADDING_LEFT + off_x;
+ win->y = PADDING_TOP + off_y;
+ }
+
win->width = maxx;
win->height = maxy;
}