summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--NEWS4
-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
7 files changed, 61 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index d9bc7e0..ff20cd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-01-04 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * 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
+
2006-01-03 Shawn Betts <sabetts@vcn.bc.ca>
* src/number.c (numset_add_num): store the ret val of
diff --git a/NEWS b/NEWS
index 5b25cc9..b6cd13c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,10 @@ are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
* Changes since 1.4.0-beta4
+** aspect ratio hint honoured
+windows with aspect ratio hints are treated as transients and are
+given the same default gravity as maxsize windows.
+
** new hook deletewindow
When a window is deleted this hook is called.
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 */