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.
This commit is contained in:
Po Lu 2022-01-04 06:10:25 +00:00
parent 3a7a88d2f8
commit 693815e90f
3 changed files with 42 additions and 4 deletions

View file

@ -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 ();
}

View file

@ -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);

View file

@ -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));