]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle negative top/left in frame parameters (Bug#7510).
authorJan Djärv <jan.h.d@swipnet.se>
Thu, 2 Dec 2010 07:12:54 +0000 (08:12 +0100)
committerJan Djärv <jan.h.d@swipnet.se>
Thu, 2 Dec 2010 07:12:54 +0000 (08:12 +0100)
* src/nsterm.h (FRAME_NS_TOOLBAR_HEIGHT): Rename to FRAME_TOOLBAR_HEIGHT.

* src/nsterm.m (x_set_window_size, windowWillResize, initFrameFromEmacs):
Use FRAME_TOOLBAR_HEIGHT.
(x_set_offset): Handle XNegative and YNegative in
f->size_hint_flags.

src/ChangeLog
src/nsterm.h
src/nsterm.m

index 45aed177ef2cc10faf0116dd3605575960e059ec..025161cc3959325ff0b1c47cd0ef22a3a69fbbc4 100644 (file)
@@ -1,3 +1,12 @@
+2010-12-02  Jan Djärv  <jhd@zeplinf.localdomain>
+
+       * nsterm.h (FRAME_NS_TOOLBAR_HEIGHT): Rename to FRAME_TOOLBAR_HEIGHT.
+
+       * nsterm.m (x_set_window_size, windowWillResize, initFrameFromEmacs):
+       Use FRAME_TOOLBAR_HEIGHT.
+       (x_set_offset): Handle XNegative and YNegative in
+       f->size_hint_flags (Bug#7510).
+
 2010-11-25  Kenichi Handa  <handa@m17n.org>
 
        * charset.c (emacs_mule_charset): Make it an array of charset ID;
index 01086e63b698fa9856b45d22f86fca37f8b8f282..5b24eb6f2894a26fc00b6dac525a654256cd0006 100644 (file)
@@ -606,7 +606,7 @@ struct x_output
 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
 #define NS_FACE_BACKGROUND(f) ((f)->background)
 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
-#define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
+#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
 
 #define FONT_WIDTH(f)  ((f)->max_width)
 #define FONT_HEIGHT(f) ((f)->height)
index d1b984d5382341675ca7cf0fb254b7f35a99db8c..43e53cb30e7c13c71b8ca56e84d486b60c317e9d 100644 (file)
@@ -1082,16 +1082,31 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
 
   f->left_pos = xoff;
   f->top_pos = yoff;
+
+  if (view != nil && (screen = [[view window] screen]))
+    {
+      f->left_pos = f->size_hint_flags & XNegative
+        ? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f)
+        : f->left_pos;
+      /* We use visibleFrame here to take menu bar into account.
+        Ideally we should also adjust left/top with visibleFrame.offset.  */
+        
+      f->top_pos = f->size_hint_flags & YNegative
+        ? ([screen visibleFrame].size.height + f->top_pos
+           - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f)
+           - FRAME_TOOLBAR_HEIGHT (f))
+        : f->top_pos;
 #ifdef NS_IMPL_GNUSTEP
-  if (xoff < 100)
-    f->left_pos = 100;  /* don't overlap menu */
+      if (f->left_pos < 100)
+        f->left_pos = 100;  /* don't overlap menu */
 #endif
+      [[view window] setFrameTopLeftPoint:
+                       NSMakePoint (SCREENMAXBOUND (f->left_pos),
+                                    SCREENMAXBOUND ([screen frame].size.height
+                                                    - NS_TOP_POS (f)))];
+      f->size_hint_flags &= ~(XNegative|YNegative);
+    }
 
-  if (view != nil && (screen = [[view window] screen]))
-    [[view window] setFrameTopLeftPoint:
-        NSMakePoint (SCREENMAXBOUND (f->left_pos),
-                     SCREENMAXBOUND ([screen frame].size.height
-                                     - NS_TOP_POS (f)))];
   UNBLOCK_INPUT;
 }
 
@@ -1148,15 +1163,15 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
     /* NOTE: previously this would generate wrong result if toolbar not
              yet displayed and fixing toolbar_height=32 helped, but
              now (200903) seems no longer needed */
-    FRAME_NS_TOOLBAR_HEIGHT (f) =
+    FRAME_TOOLBAR_HEIGHT (f) =
       NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
         - FRAME_NS_TITLEBAR_HEIGHT (f);
   else
-    FRAME_NS_TOOLBAR_HEIGHT (f) = 0;
+    FRAME_TOOLBAR_HEIGHT (f) = 0;
 
   wr.size.width = pixelwidth + f->border_width;
   wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f) 
-                  + FRAME_NS_TOOLBAR_HEIGHT (f);
+                  + FRAME_TOOLBAR_HEIGHT (f);
 
   /* constrain to screen if we can */
   if (screen)
@@ -4897,16 +4912,16 @@ ns_term_shutdown (int sig)
   rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, frameSize.height
 #ifdef NS_IMPL_GNUSTEP
       - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + 3
-        - FRAME_NS_TOOLBAR_HEIGHT (emacsframe));
+        - FRAME_TOOLBAR_HEIGHT (emacsframe));
 #else
       - FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
-        - FRAME_NS_TOOLBAR_HEIGHT (emacsframe));
+        - FRAME_TOOLBAR_HEIGHT (emacsframe));
 #endif
   if (rows < MINHEIGHT)
     rows = MINHEIGHT;
   frameSize.height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (emacsframe, rows)
                        + FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
-                       + FRAME_NS_TOOLBAR_HEIGHT (emacsframe);
+                       + FRAME_TOOLBAR_HEIGHT (emacsframe);
 #ifdef NS_IMPL_COCOA
   {
     /* this sets window title to have size in it; the wm does this under GS */
@@ -5117,7 +5132,7 @@ ns_term_shutdown (int sig)
   [toggleButton setTarget: self];
   [toggleButton setAction: @selector (toggleToolbar: )];
 #endif
-  FRAME_NS_TOOLBAR_HEIGHT (f) = 0;
+  FRAME_TOOLBAR_HEIGHT (f) = 0;
 
   tem = f->icon_name;
   if (!NILP (tem))