summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conf.h4
-rw-r--r--src/manage.c38
-rw-r--r--src/manage.h1
-rw-r--r--src/split.c9
-rw-r--r--src/window.c11
5 files changed, 45 insertions, 18 deletions
diff --git a/src/conf.h b/src/conf.h
index 9475182..34fa4d5 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -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 */