[metacity] move manipulation of the X stack to MetaStackTracker
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] move manipulation of the X stack to MetaStackTracker
- Date: Sat, 1 Apr 2017 16:24:12 +0000 (UTC)
commit 090b3eb55fac851baf2729e854202fdf4dd75fd5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Apr 1 13:48:12 2017 +0300
move manipulation of the X stack to MetaStackTracker
https://git.gnome.org/browse/mutter/commit/?id=34573660665ba4134451cc82a596367dbf3989d0
src/core/stack-tracker.c | 103 ++++++++++++++++++++++++++++++++++-----------
src/core/stack-tracker.h | 18 ++++++--
src/core/stack.c | 54 ++++-------------------
3 files changed, 102 insertions(+), 73 deletions(-)
---
diff --git a/src/core/stack-tracker.c b/src/core/stack-tracker.c
index 865aca6..7f1c7fc 100644
--- a/src/core/stack-tracker.c
+++ b/src/core/stack-tracker.c
@@ -17,10 +17,11 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
+#include "config.h"
#include <string.h>
+#include "errors.h"
#include "frame-private.h"
#include "meta-compositor.h"
#include "screen-private.h"
@@ -525,30 +526,6 @@ meta_stack_tracker_record_remove (MetaStackTracker *tracker,
}
void
-meta_stack_tracker_record_restack_windows (MetaStackTracker *tracker,
- Window *windows,
- int n_windows,
- gulong serial)
-{
- int i;
-
- /* XRestackWindows() isn't actually a X requests - it's broken down
- * by XLib into a series of XConfigureWindow(StackMode=below); we
- * mirror that here.
- *
- * Aside: Having a separate StackOp for this would be possible to
- * get some extra efficiency in memory allocation and in applying
- * the op, at the expense of a code complexity. Implementation hint
- * for that - keep op->restack_window.n_complete, and when receiving
- * events with intermediate serials, set n_complete rather than
- * removing the op from the queue.
- */
- for (i = 0; i < n_windows - 1; i++)
- meta_stack_tracker_record_lower_below (tracker, windows[i + 1], windows[i],
- serial + i);
-}
-
-void
meta_stack_tracker_record_raise_above (MetaStackTracker *tracker,
Window window,
Window sibling,
@@ -865,3 +842,79 @@ meta_stack_tracker_queue_sync_stack (MetaStackTracker *tracker)
tracker, NULL);
}
}
+
+void
+meta_stack_tracker_lower_below (MetaStackTracker *tracker,
+ Window window,
+ Window sibling)
+{
+ MetaDisplay *display;
+ XWindowChanges changes;
+ guint changes_mask;
+ gulong serial;
+
+ display = tracker->screen->display;
+
+ meta_error_trap_push (display);
+
+ changes.sibling = sibling;
+ changes.stack_mode = changes.sibling ? Below : Above;
+ changes_mask = (changes.sibling ? CWSibling : 0) | CWStackMode;
+
+ serial = XNextRequest (display->xdisplay);
+ XConfigureWindow (display->xdisplay, window, changes_mask, &changes);
+
+ meta_error_trap_pop (tracker->screen->display);
+
+ meta_stack_tracker_record_lower_below (tracker, window, sibling, serial);
+}
+
+void
+meta_stack_tracker_lower (MetaStackTracker *tracker,
+ Window window)
+{
+ meta_stack_tracker_raise_above (tracker, window, None);
+}
+
+void
+meta_stack_tracker_raise_above (MetaStackTracker *tracker,
+ Window window,
+ Window sibling)
+{
+ MetaDisplay *display;
+ XWindowChanges changes;
+ guint changes_mask;
+ gulong serial;
+
+ display = tracker->screen->display;
+
+ meta_error_trap_push (display);
+
+ changes.sibling = sibling;
+ changes.stack_mode = changes.sibling ? Above : Below;
+ changes_mask = (changes.sibling ? CWSibling : 0) | CWStackMode;
+
+ serial = XNextRequest (display->xdisplay);
+ XConfigureWindow (display->xdisplay, window, changes_mask, &changes);
+
+ meta_error_trap_pop (tracker->screen->display);
+
+ meta_stack_tracker_record_raise_above (tracker, window, sibling, serial);
+}
+
+void
+meta_stack_tracker_restack_windows (MetaStackTracker *tracker,
+ const Window *windows,
+ int n_windows)
+{
+ int i;
+
+ /* XRestackWindows() isn't actually a X requests - it's broken down
+ * by XLib into a series of XConfigureWindow(StackMode=below); we
+ * just do the same here directly. The main disadvantage of is that
+ * we allocate individual ops for each lower, and also that we are
+ * grabbing the libX11 lock separately for individual component.
+ */
+ for (i = 0; i < n_windows - 1; i++)
+ meta_stack_tracker_lower_below (tracker, windows[i + 1], windows[i]);
+}
diff --git a/src/core/stack-tracker.h b/src/core/stack-tracker.h
index c74bdb2..6947301 100644
--- a/src/core/stack-tracker.h
+++ b/src/core/stack-tracker.h
@@ -50,10 +50,6 @@ void meta_stack_tracker_record_add (MetaStackTracker *tracker,
void meta_stack_tracker_record_remove (MetaStackTracker *tracker,
Window window,
gulong serial);
-void meta_stack_tracker_record_restack_windows (MetaStackTracker *tracker,
- Window *windows,
- int n_windows,
- gulong serial);
void meta_stack_tracker_record_raise_above (MetaStackTracker *tracker,
Window window,
Window sibling,
@@ -66,6 +62,20 @@ void meta_stack_tracker_record_lower (MetaStackTracker *tracker,
Window window,
gulong serial);
+/* We also have functions that also go ahead and do the work
+ */
+void meta_stack_tracker_raise_above (MetaStackTracker *tracker,
+ Window window,
+ Window sibling);
+void meta_stack_tracker_lower_below (MetaStackTracker *tracker,
+ Window window,
+ Window sibling);
+void meta_stack_tracker_lower (MetaStackTracker *tracker,
+ Window window);
+void meta_stack_tracker_restack_windows (MetaStackTracker *tracker,
+ const Window *windows,
+ int n_windows);
+
/* These functions are used to update the stack when we get events
* reflecting changes to the stacking order */
void meta_stack_tracker_create_event (MetaStackTracker *tracker,
diff --git a/src/core/stack.c b/src/core/stack.c
index 01fedb3..8f7a290 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -1059,42 +1059,24 @@ raise_window_relative_to_managed_windows (MetaScreen *screen,
Window xwindow)
{
Window sibling;
- gulong serial;
sibling = find_top_most_managed_window (screen, xwindow);
if (sibling == None)
{
- meta_error_trap_push (screen->display);
- serial = XNextRequest (screen->display->xdisplay);
- XLowerWindow (screen->display->xdisplay, xwindow);
- meta_error_trap_pop (screen->display);
-
/* No sibling to use, just lower ourselves to the bottom
* to be sure we're below any override redirect windows.
*/
- meta_stack_tracker_record_lower (screen->stack_tracker, xwindow, serial);
+ meta_stack_tracker_lower (screen->stack_tracker, xwindow);
}
else
{
- XWindowChanges changes;
-
/* sibling is the topmost managed child */
meta_topic (META_DEBUG_STACK,
"Moving 0x%lx above topmost managed child window 0x%lx\n",
xwindow, sibling);
- changes.sibling = sibling;
- changes.stack_mode = Above;
-
- meta_error_trap_push (screen->display);
- serial = XNextRequest (screen->display->xdisplay);
- XConfigureWindow (screen->display->xdisplay, xwindow,
- CWSibling | CWStackMode, &changes);
- meta_error_trap_pop (screen->display);
-
- meta_stack_tracker_record_raise_above (screen->stack_tracker,
- xwindow, sibling, serial);
+ meta_stack_tracker_raise_above (screen->stack_tracker, xwindow, sibling);
}
}
@@ -1181,13 +1163,9 @@ stack_sync_to_xserver (MetaStack *stack)
if (root_children_stacked->len > 0)
{
- meta_stack_tracker_record_restack_windows (stack->screen->stack_tracker,
- (Window *) root_children_stacked->data,
- root_children_stacked->len,
- XNextRequest (stack->screen->display->xdisplay));
- XRestackWindows (stack->screen->display->xdisplay,
- (Window *) root_children_stacked->data,
- root_children_stacked->len);
+ meta_stack_tracker_restack_windows (stack->screen->stack_tracker,
+ (Window *) root_children_stacked->data,
+ root_children_stacked->len);
}
}
else if (root_children_stacked->len > 0)
@@ -1243,21 +1221,11 @@ stack_sync_to_xserver (MetaStack *stack)
* unmanaging last_window, we'll fix it up.
*/
- XWindowChanges changes;
-
- changes.sibling = last_window;
- changes.stack_mode = Below;
-
meta_topic (META_DEBUG_STACK, "Placing window 0x%lx below 0x%lx\n",
*newp, last_window);
- meta_stack_tracker_record_lower_below (stack->screen->stack_tracker,
- *newp, last_window,
- XNextRequest (stack->screen->display->xdisplay));
- XConfigureWindow (stack->screen->display->xdisplay,
- *newp,
- CWSibling | CWStackMode,
- &changes);
+ meta_stack_tracker_lower_below (stack->screen->stack_tracker,
+ *newp, last_window);
}
last_window = *newp;
@@ -1270,17 +1238,15 @@ stack_sync_to_xserver (MetaStack *stack)
/* Restack remaining windows */
meta_topic (META_DEBUG_STACK, "Restacking remaining %d windows\n",
(int) (new_end - newp));
+
/* We need to include an already-stacked window
* in the restack call, so we get in the proper position
* with respect to it.
*/
if (newp != new_stack)
--newp;
- meta_stack_tracker_record_restack_windows (stack->screen->stack_tracker,
- (Window *) newp, new_end - newp,
- XNextRequest (stack->screen->display->xdisplay));
- XRestackWindows (stack->screen->display->xdisplay,
- (Window *) newp, new_end - newp);
+ meta_stack_tracker_restack_windows (stack->screen->stack_tracker,
+ newp, new_end - newp);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]