changeset 7210:682ff6213c36

(x_wm_set_size_hint): Always set PWinGravity. Rename the args. Compute x and y fields from negative positions. Use XGetWMNormalHints if X11R4 or newer. (x_make_frame_visible): Call x_set_offset only if not USE_X_TOOLKIT. (x_make_frame_invisible): Call x_wm_set_size_hint. (x_set_offset): Pass 0 as 3rd arg to x_wm_set_size_hint. (x_set_window_size): Likewise. Set win_gravity field here if nec.
author Richard M. Stallman <rms@gnu.org>
date Sat, 30 Apr 1994 00:15:20 +0000
parents ca5e04c9795c
children b2485e94101a
files src/xterm.c
diffstat 1 files changed, 53 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Sat Apr 30 00:13:44 1994 +0000
+++ b/src/xterm.c	Sat Apr 30 00:15:20 1994 +0000
@@ -261,7 +261,7 @@
    to Qnil, to tell XTmouse_position to return an ordinary motion event.  */
 static Lisp_Object last_mouse_scroll_bar;
 
-/* Record which buttons are currently pressed. */
+/* Record which buttons are currently pressed.  */
 unsigned int x_mouse_grabbed;
 
 /* This is a hack.  We would really prefer that XTmouse_position would
@@ -5182,7 +5182,7 @@
   if (change_gravity)
     f->display.x->win_gravity = NorthWestGravity;
 
-  x_wm_set_size_hint (f, 0, 1);
+  x_wm_set_size_hint (f, 0, 0);
 #endif /* ! defined (HAVE_X11) */
   UNBLOCK_INPUT;
 }
@@ -5218,7 +5218,8 @@
   pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
 
 #ifdef HAVE_X11
-  x_wm_set_size_hint (f, 0, change_gravity);
+  f->display.x->win_gravity = NorthWestGravity;
+  x_wm_set_size_hint (f, 0, 0);
 #endif /* ! defined (HAVE_X11) */
   XSync (x_current_display, False);
   XChangeWindowSize (FRAME_X_WINDOW (f), pixelwidth, pixelheight);
@@ -5386,7 +5387,9 @@
   if (! FRAME_VISIBLE_P (f))
     {
 #ifdef HAVE_X11
+#ifndef USE_X_TOOLKIT
       x_set_offset (f, f->display.x->left_pos, f->display.x->top_pos, 0);
+#endif
 
       if (! EQ (Vx_no_window_manager, Qt))
 	x_wm_set_window_state (f, NormalState);
@@ -5439,6 +5442,13 @@
 
   BLOCK_INPUT;
 
+  /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
+     that the current position of the window is user-specified, rather than
+     program-specified, so that when the window is mapped again, it will be
+     placed at the same location, without forcing the user to position it
+     by hand again (they have already done that once for this window.)  */
+  x_wm_set_size_hint (f, 0, 1);
+
 #ifdef HAVE_X11R4
 
 #ifdef USE_X_TOOLKIT
@@ -5713,14 +5723,16 @@
 
 #ifdef HAVE_X11
 
-/* SPEC_X and SPEC_Y are the specified positions.
-   We look only at their sign, to decide the gravity.
-   If CHANGE_GRAVITY is 0, we may set PWinGravity.  */
-
-x_wm_set_size_hint (f, prompting, change_gravity)
+/* Set the normal size hints for the window manager, for frame F.
+   FLAGS is the flags word to use--or 0 meaning preserve the flags
+   that the window now has.
+   If USER_POSITION is nonzero, we set the USPosition
+   flag (this is useful when FLAGS is 0).  */
+
+x_wm_set_size_hint (f, flags, user_position)
      struct frame *f;
-     long prompting;
-     int change_gravity;
+     long flags;
+     int user_position;
 {
   XSizeHints size_hints;
 
@@ -5741,6 +5753,19 @@
   size_hints.x = f->display.x->left_pos;
   size_hints.y = f->display.x->top_pos;
 
+  /* Treat negative positions as relative to the leftmost bottommost
+     position that fits on the screen.  */
+  if (flags & XNegative)
+    size_hints.x = (x_screen_width 
+		    - 2 * f->display.x->border_width
+		    - PIXEL_WIDTH (f)
+		    + f->display.x->left_pos);
+  if (flags & YNegative)
+    size_hints.y = (x_screen_height
+		    - 2 * f->display.x->border_width
+		    - PIXEL_HEIGHT (f)
+		    + f->display.x->top_pos);
+
 #ifdef USE_X_TOOLKIT
   XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
   XtSetArg (al[ac], XtNheight, &widget_height); ac++;
@@ -5788,13 +5813,22 @@
 #endif
   }
 
-  if (prompting)
-    size_hints.flags |= prompting;
+  if (flags)
+    size_hints.flags |= flags;
   else
     {
       XSizeHints hints;		/* Sometimes I hate X Windows... */
+      long supplied_return;
+      int value;
+
+#ifdef HAVE_X11R4
+      value = XGetWMNormalHints (x_current_display, window, &hints,
+				 &supplied_return);
+#else
+      value = XGetNormalHints (x_current_display, window, &hints);
+#endif
       
-      if (XGetNormalHints (x_current_display, window, &hints) == 0)
+      if (value == 0)
 	hints.flags = 0;
       if (hints.flags & PSize)
 	size_hints.flags |= PSize;
@@ -5806,13 +5840,14 @@
 	size_hints.flags |= USSize;
     }
 
-#if defined (PWinGravity)
+#ifdef PWinGravity
   size_hints.win_gravity = f->display.x->win_gravity;
-
-  if (change_gravity)
+  size_hints.flags |= PWinGravity;
+
+  if (user_position)
     {
-      if (! (size_hints.flags & USPosition))
-	size_hints.flags |= PWinGravity;
+      size_hints.flags &= ~ PPosition;
+      size_hints.flags |= USPosition;
     }
 #endif /* PWinGravity */