diff options
author | sabetts <sabetts> | 2006-01-05 04:36:07 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2006-01-05 04:36:07 +0000 |
commit | a83f0a57448524b489e94e06e945e1a551543d94 (patch) | |
tree | c8d9ca53c112579aac06720db704ac55f0a94f0b /src | |
parent | 1d3b753b428842fc9c0bdc6d9ccc9e2289239ffa (diff) | |
download | ratpoison-a83f0a57448524b489e94e06e945e1a551543d94.zip |
* src/conf.h (ASPECT_WINDOWS_ARE_TRANSIENTS): new define
* src/manage.c (window_is_transient): new function
(maximize_normal): honour aspect ratio hint
* src/window.c (update_window_gravity): use maxsize_gravity for windows with aspect hints.
(set_active_window_body): call window_is_transient
* src/split.c (cleanup_frame): call window_is_transient
Diffstat (limited to 'src')
-rw-r--r-- | src/conf.h | 4 | ||||
-rw-r--r-- | src/manage.c | 38 | ||||
-rw-r--r-- | src/manage.h | 1 | ||||
-rw-r--r-- | src/split.c | 9 | ||||
-rw-r--r-- | src/window.c | 11 |
5 files changed, 45 insertions, 18 deletions
@@ -71,6 +71,10 @@ (don't hide the windows underneath, and center them) */ #define MAXSIZE_WINDOWS_ARE_TRANSIENTS +/* Treat windows with aspect hints as if they were a transient window + (don't hide the windows underneath, and center them) */ +#define ASPECT_WINDOWS_ARE_TRANSIENTS + /* An alias command could recursively call inself infinitely. This stops that behavior. */ #define MAX_ALIAS_RECURSIVE_DEPTH 16 diff --git a/src/manage.c b/src/manage.c index 36bb973..364c6c9 100644 --- a/src/manage.c +++ b/src/manage.c @@ -375,6 +375,23 @@ send_configure (Window w, int x, int y, int width, int height, int border) XSendEvent (dpy, w, False, StructureNotifyMask, (XEvent*)&ce); } +/* This function is used to determine if the window should be treated + as a transient. */ +int +window_is_transient (rp_window *win) +{ + return win->transient +#ifdef ASPECT_WINDOWS_ARE_TRANSIENTS + || win->hints->flags & PAspect +#endif +#ifdef MAXSIZE_WINDOWS_ARE_TRANSIENTS +|| (win->hints->flags & PMaxSize + && (win->hints->max_width < win->scr->width + || win->hints->max_height < win->scr->height)) +#endif + ; +} + void update_window_information (rp_window *win) { @@ -395,7 +412,7 @@ update_window_information (rp_window *win) win->border = attr.border_width; /* Transient status */ - win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for); + win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for); update_window_gravity (win); } @@ -680,6 +697,25 @@ maximize_normal (rp_window *win) maxy = frame->height - win->border * 2; } + /* Honour the window's aspect ratio. */ + PRINT_DEBUG (("aspect: %ld\n", win->hints->flags & PAspect)); + if (win->hints->flags & PAspect) + { + float ratio = (float)maxx / maxy; + float min_ratio = (float)win->hints->min_aspect.x / win->hints->min_aspect.y; + float max_ratio = (float)win->hints->max_aspect.x / win->hints->max_aspect.y; + PRINT_DEBUG (("ratio=%f min_ratio=%f max_ratio=%f\n", + ratio,min_ratio,max_ratio)); + if (ratio < min_ratio) + { + maxy = (int) (maxx / min_ratio); + } + else if (ratio > max_ratio) + { + maxx = (int) (maxy * max_ratio); + } + } + /* Fit the window inside its frame (if it has one) */ if (frame) { diff --git a/src/manage.h b/src/manage.h index d24c343..6b15f98 100644 --- a/src/manage.h +++ b/src/manage.h @@ -38,6 +38,7 @@ void send_configure (Window w, int x, int y, int width, int height, int border); void set_state (rp_window *win, int state); long get_state (rp_window *win); +int window_is_transient (rp_window *win); void update_window_information (rp_window *win); void map_window (rp_window *win); diff --git a/src/split.c b/src/split.c index 26231c7..62da8e7 100644 --- a/src/split.c +++ b/src/split.c @@ -82,14 +82,7 @@ cleanup_frame (rp_frame *frame) unhide_window (win); -#ifdef MAXSIZE_WINDOWS_ARE_TRANSIENTS - if (!win->transient - && !(win->hints->flags & PMaxSize - && (win->hints->max_width < win->scr->width - || win->hints->max_height < win->scr->height))) -#else - if (!win->transient) -#endif + if (!window_is_transient (win)) hide_others (win); } diff --git a/src/window.c b/src/window.c index 8105dca..0936999 100644 --- a/src/window.c +++ b/src/window.c @@ -64,7 +64,7 @@ update_window_gravity (rp_window *win) /* { */ if (win->transient) win->gravity = defaults.trans_gravity; - else if (win->hints->flags & PMaxSize) + else if (win->hints->flags & PMaxSize || win->hints->flags & PAspect) win->gravity = defaults.maxsize_gravity; else win->gravity = defaults.win_gravity; @@ -650,14 +650,7 @@ set_active_window_body (rp_window *win, int force) /* The other windows in the frame will be hidden if this window doesn't qualify as a transient window (ie dialog box. */ -#ifdef MAXSIZE_WINDOWS_ARE_TRANSIENTS - if (!win->transient - && !(win->hints->flags & PMaxSize - && (win->hints->max_width < win->scr->width - || win->hints->max_height < win->scr->height))) -#else - if (!win->transient) -#endif + if (!window_is_transient (win)) hide_others(win); /* Make sure the program bar is always on the top */ |