emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 693815e90f: Improve Haiku frame restacking logic


From: Po Lu
Subject: master 693815e90f: Improve Haiku frame restacking logic
Date: Tue, 4 Jan 2022 01:14:15 -0500 (EST)

branch: master
commit 693815e90f90d977405dc9cd2857505a375caf96
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Improve Haiku frame restacking logic
    
    * src/haiku_support.cc (BWindow_is_active):
    * src/haiku_support.h (BWindow_is_active): New functions.
    
    * src/haikufns.c (Fhaiku_frame_restack): Prevent the newly
    raised frame from being sent to the back of the display.
---
 src/haiku_support.cc |  7 +++++++
 src/haiku_support.h  |  3 +++
 src/haikufns.c       | 36 ++++++++++++++++++++++++++++++++----
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index effd4c33a9..2171b7bf81 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -3002,3 +3002,10 @@ BWindow_send_behind (void *window, void *other_window)
   w->SendBehind (other);
   w->UnlockLooper ();
 }
+
+bool
+BWindow_is_active (void *window)
+{
+  BWindow *w = (BWindow *) window;
+  return w->IsActive ();
+}
diff --git a/src/haiku_support.h b/src/haiku_support.h
index 2b61ec1ac1..ef90374f69 100644
--- a/src/haiku_support.h
+++ b/src/haiku_support.h
@@ -826,6 +826,9 @@ extern "C"
   extern void
   BWindow_send_behind (void *window, void *other_window);
 
+  extern bool
+  BWindow_is_active (void *window);
+
 #ifdef __cplusplus
   extern void *
   find_appropriate_view_for_draw (void *vw);
diff --git a/src/haikufns.c b/src/haikufns.c
index 0b7972f945..f010867fd9 100644
--- a/src/haikufns.c
+++ b/src/haikufns.c
@@ -2341,11 +2341,39 @@ Some window managers may refuse to restack windows.  */)
   block_input ();
 
   if (NILP (above))
-    BWindow_send_behind (FRAME_HAIKU_WINDOW (f1),
-                        FRAME_HAIKU_WINDOW (f2));
+    {
+      /* If the window that is currently active will be sent behind
+        another window, make the window that it is being sent behind
+        active first, to avoid both windows being moved to the back of
+        the display.  */
+
+      if (BWindow_is_active (FRAME_HAIKU_WINDOW (f1))
+         /* But don't do this if any of the frames involved have
+            child frames, since they are guaranteed to be in front of
+            their toplevel parents.  */
+         && !FRAME_PARENT_FRAME (f1)
+         && !FRAME_PARENT_FRAME (f2))
+       {
+         BWindow_activate (FRAME_HAIKU_WINDOW (f2));
+         BWindow_sync (FRAME_HAIKU_WINDOW (f2));
+       }
+
+      BWindow_send_behind (FRAME_HAIKU_WINDOW (f1),
+                          FRAME_HAIKU_WINDOW (f2));
+    }
   else
-    BWindow_send_behind (FRAME_HAIKU_WINDOW (f2),
-                        FRAME_HAIKU_WINDOW (f1));
+    {
+      if (BWindow_is_active (FRAME_HAIKU_WINDOW (f2))
+         && !FRAME_PARENT_FRAME (f1)
+         && !FRAME_PARENT_FRAME (f2))
+       {
+         BWindow_activate (FRAME_HAIKU_WINDOW (f1));
+         BWindow_sync (FRAME_HAIKU_WINDOW (f1));
+       }
+
+      BWindow_send_behind (FRAME_HAIKU_WINDOW (f2),
+                          FRAME_HAIKU_WINDOW (f1));
+    }
   BWindow_sync (FRAME_HAIKU_WINDOW (f1));
   BWindow_sync (FRAME_HAIKU_WINDOW (f2));
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]