aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2025-02-17 12:06:15 +0800
committerPo Lu2025-02-17 12:07:20 +0800
commita951dbcf162aaf06a134c597ca0ac59c479afc4b (patch)
tree5ff9a81470af45966e2c7ed180c6c5c3c0307644 /src
parent6c1e6ba83c471e6a3c233c611dfe9e88349d5a10 (diff)
downloademacs-a951dbcf162aaf06a134c597ca0ac59c479afc4b.tar.gz
emacs-a951dbcf162aaf06a134c597ca0ac59c479afc4b.zip
Implement `(- N)' frame position specifications on Haiku
* src/haikuterm.c (haiku_calc_absolute_position): New function. (haiku_set_offset): Apply offsets configured by the said function.
Diffstat (limited to 'src')
-rw-r--r--src/haikuterm.c81
1 files changed, 80 insertions, 1 deletions
diff --git a/src/haikuterm.c b/src/haikuterm.c
index 4a217c9e0e2..5c0863d3509 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -4640,6 +4640,83 @@ haiku_scroll_bar_remove (struct scroll_bar *bar)
4640 unblock_input (); 4640 unblock_input ();
4641}; 4641};
4642 4642
4643
4644
4645/* Calculate the absolute position in frame F
4646 from its current recorded position values and gravity. */
4647
4648static void
4649haiku_calc_absolute_position (struct frame *f)
4650{
4651 int flags = f->size_hint_flags;
4652 struct frame *p = FRAME_PARENT_FRAME (f);
4653 int screen_width, screen_height;
4654
4655 /* We have nothing to do if the current position
4656 is already for the top-left corner. */
4657 if (!((flags & XNegative) || (flags & YNegative)))
4658 return;
4659
4660 be_get_screen_dimensions (&screen_width, &screen_height);
4661
4662 /* Treat negative positions as relative to the leftmost bottommost
4663 position that fits on the screen. */
4664 if (flags & XNegative)
4665 {
4666 int width = FRAME_PIXEL_WIDTH (f);
4667
4668 /* A frame that has been visible at least once should have outer
4669 edges. */
4670 if (!p)
4671 {
4672 Lisp_Object frame;
4673 Lisp_Object edges = Qnil;
4674
4675 XSETFRAME (frame, f);
4676 edges = Fhaiku_frame_edges (frame, Qouter_edges);
4677 if (!NILP (edges))
4678 width = (XFIXNUM (Fnth (make_fixnum (2), edges))
4679 - XFIXNUM (Fnth (make_fixnum (0), edges)));
4680 }
4681
4682 if (p)
4683 f->left_pos = (FRAME_PIXEL_WIDTH (p) - width - 2 * f->border_width
4684 + f->left_pos);
4685 else
4686 f->left_pos = (screen_width - width + f->left_pos);
4687
4688 }
4689
4690 if (flags & YNegative)
4691 {
4692 int height = FRAME_PIXEL_HEIGHT (f);
4693
4694 if (!p)
4695 {
4696 Lisp_Object frame;
4697 Lisp_Object edges = Qnil;
4698
4699 XSETFRAME (frame, f);
4700 if (NILP (edges))
4701 edges = Fhaiku_frame_edges (frame, Qouter_edges);
4702 if (!NILP (edges))
4703 height = (XFIXNUM (Fnth (make_fixnum (3), edges))
4704 - XFIXNUM (Fnth (make_fixnum (1), edges)));
4705 }
4706
4707 if (p)
4708 f->top_pos = (FRAME_PIXEL_HEIGHT (p) - height - 2 * f->border_width
4709 + f->top_pos);
4710 else
4711 f->top_pos = (screen_height - height + f->top_pos);
4712 }
4713
4714 /* The left_pos and top_pos
4715 are now relative to the top and left screen edges,
4716 so the flags should correspond. */
4717 f->size_hint_flags &= ~(XNegative | YNegative);
4718}
4719
4643void 4720void
4644haiku_set_offset (struct frame *frame, int x, int y, 4721haiku_set_offset (struct frame *frame, int x, int y,
4645 int change_gravity) 4722 int change_gravity)
@@ -4673,10 +4750,12 @@ haiku_set_offset (struct frame *frame, int x, int y,
4673 } 4750 }
4674 4751
4675 haiku_update_size_hints (frame); 4752 haiku_update_size_hints (frame);
4753 haiku_calc_absolute_position (frame);
4676 4754
4677 block_input (); 4755 block_input ();
4678 if (change_gravity) 4756 if (change_gravity)
4679 BWindow_set_offset (FRAME_HAIKU_WINDOW (frame), x, y); 4757 BWindow_set_offset (FRAME_HAIKU_WINDOW (frame), frame->left_pos,
4758 frame->top_pos);
4680 unblock_input (); 4759 unblock_input ();
4681} 4760}
4682 4761