summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authormdejong <mdejong>2003-03-12 00:25:40 (GMT)
committermdejong <mdejong>2003-03-12 00:25:40 (GMT)
commit5fa0b916e1a1c47c2251286bd3aad486bb08238b (patch)
tree1c5f6fc421347a2e042b8056bdecab04a447614a /win
parent6be1cd95fff709a3869038db3e989865154259fb (diff)
downloadtk-5fa0b916e1a1c47c2251286bd3aad486bb08238b.zip
tk-5fa0b916e1a1c47c2251286bd3aad486bb08238b.tar.gz
tk-5fa0b916e1a1c47c2251286bd3aad486bb08238b.tar.bz2
* doc/wm.n (minimize, maximize): Remove claim
that the resizable command keeps scripts from changing the size of windows since it is not true. The resizable command only applies to user sizing via user interaction. * tests/unixWm.test: Replace broken tests with the nonPortable constraint with new tests for maxsize and minsize options. These tests verify that setting the minsize and maxsize will resize the window if needed, and that the wm hints will be updated with the new sizes. * tests/wm.test: Add an exhaustive set of tests for the wm maxsize and wm minsize commands. These tests verify that setting the minsize and maxsize will resize the window if needed. These tests have only been run under Win98 and Window Maker under Linux, so further tweaking may be needed for other systems. * unix/tkUnixWm.c (UpdateGeometryInfo, UpdateSizeHints): Fixup comments and initialization for the minWidth, minHeight, maxWidth, maxHeight, width, and height members of the WmInfo struct. Check to ensure that a new toplevel window size is not larger than the maxsize or smaller than the minsize when updating the geometry at idle time. Pass new width and height values to the UpdateSizeHints method so that it can properly set the window min and max sizes for a window that cannot be resized by the user. This fixes a bug where the window resizes back to the original size when the user clicks on the window border. * win/tkWinWm.c (UpdateGeometryInfo): Fixup comments and initialization for the minWidth, minHeight, maxWidth, maxHeight, width, and height members of the WmInfo struct. Check to ensure that a new toplevel window size is not larger than the maxsize or smaller than the minsize when updating the geometry at idle time. [Patch 568861]
Diffstat (limited to 'win')
-rw-r--r--win/tkWinWm.c57
1 files changed, 51 insertions, 6 deletions
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 69a4bd5..edd91a2 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.54 2002/12/06 23:29:37 hobbs Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.55 2003/03/12 00:25:42 mdejong Exp $
*/
#include "tkWinInt.h"
@@ -176,9 +176,9 @@ typedef struct TkWmInfo {
* window is gridded; otherwise it isn't
* gridded. */
int minWidth, minHeight; /* Minimum dimensions of window, in
- * grid units, not pixels. */
+ * pixels or grid units. */
int maxWidth, maxHeight; /* Maximum dimensions of window, in
- * grid units, not pixels, or 0 to default. */
+ * pixels or grid units. 0 to default. */
Tk_Window gridWin; /* Identifies the window that controls
* gridding for this top-level, or NULL if
* the top-level isn't currently gridded. */
@@ -199,7 +199,7 @@ typedef struct TkWmInfo {
*/
int width, height; /* Desired dimensions of window, specified
- * in grid units. These values are
+ * in pixels or grid units. These values are
* set by the "wm geometry" command and by
* ConfigureNotify events (for when wm
* resizes window). -1 means user hasn't
@@ -5018,6 +5018,7 @@ UpdateGeometryInfo(clientData)
{
int x, y; /* Position of border on desktop. */
int width, height; /* Size of client area. */
+ int min, max;
RECT rect;
register TkWindow *winPtr = (TkWindow *) clientData;
register WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -5056,8 +5057,9 @@ UpdateGeometryInfo(clientData)
* requested depends on (a) the size requested internally
* by the window's widgets, (b) the size requested by the
* user in a "wm geometry" command or via wm-based interactive
- * resizing (if any), and (c) whether or not the window is
- * gridded. Don't permit sizes <= 0 because this upsets
+ * resizing (if any), (c) whether or not the window is
+ * gridded, and (d) the current min or max size for
+ * the toplevel. Don't permit sizes <= 0 because this upsets
* the X server.
*/
@@ -5072,6 +5074,28 @@ UpdateGeometryInfo(clientData)
if (width <= 0) {
width = 1;
}
+ /*
+ * Account for window max/min width
+ */
+ if (wmPtr->gridWin != NULL) {
+ min = winPtr->reqWidth
+ + (wmPtr->minWidth - wmPtr->reqGridWidth)*wmPtr->widthInc;
+ if (wmPtr->maxWidth > 0) {
+ max = winPtr->reqWidth
+ + (wmPtr->maxWidth - wmPtr->reqGridWidth)*wmPtr->widthInc;
+ } else {
+ max = 0;
+ }
+ } else {
+ min = wmPtr->minWidth;
+ max = wmPtr->maxWidth;
+ }
+ if (width < min) {
+ width = min;
+ } else if ((max > 0) && (width > max)) {
+ width = max;
+ }
+
if (wmPtr->height == -1) {
height = winPtr->reqHeight;
} else if (wmPtr->gridWin != NULL) {
@@ -5083,6 +5107,27 @@ UpdateGeometryInfo(clientData)
if (height <= 0) {
height = 1;
}
+ /*
+ * Account for window max/min height
+ */
+ if (wmPtr->gridWin != NULL) {
+ min = winPtr->reqHeight
+ + (wmPtr->minHeight - wmPtr->reqGridHeight)*wmPtr->heightInc;
+ if (wmPtr->maxHeight > 0) {
+ max = winPtr->reqHeight
+ + (wmPtr->maxHeight - wmPtr->reqGridHeight)*wmPtr->heightInc;
+ } else {
+ max = 0;
+ }
+ } else {
+ min = wmPtr->minHeight;
+ max = wmPtr->maxHeight;
+ }
+ if (height < min) {
+ height = min;
+ } else if ((max > 0) && (height > max)) {
+ height = max;
+ }
/*
* Compute the new position for the upper-left pixel of the window's