From 192c25525a55e72bfecd55ca63c397e5694be51c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 16 May 2018 15:40:45 +0200
Subject: [PATCH] phosh: Fix menu positioning with recent rootston/wlroots

There were some fixes regarding xdg popup positioning.
---
 src/phosh.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/phosh.c b/src/phosh.c
index d1a585f..867e83e 100644
--- a/src/phosh.c
+++ b/src/phosh.c
@@ -268,9 +268,9 @@ favorites_activated_cb (PhoshShell *self,
   gtk_window_get_size (GTK_WINDOW (favorites->window), &width, &height);
   xdg_positioner_set_size(xdg_positioner, width, height);
   xdg_positioner_set_offset(xdg_positioner, 0, PHOSH_PANEL_HEIGHT-1);
-  xdg_positioner_set_anchor_rect(xdg_positioner, 100, 0, 1, 1);
-  xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM);
-  xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM);
+  xdg_positioner_set_anchor_rect(xdg_positioner, 0, 0, 1, 1);
+  xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM_LEFT);
+  xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
 
   favorites->popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner);
   g_return_if_fail (favorites->popup);
@@ -315,7 +315,7 @@ settings_activated_cb (PhoshShell *self,
   struct popup *settings;
   struct xdg_surface *xdg_surface;
   struct xdg_positioner *xdg_positioner;
-  gint width, height;
+  gint width, height, panel_width;
 
   if (priv->settings)
     return;
@@ -332,11 +332,11 @@ settings_activated_cb (PhoshShell *self,
   xdg_positioner = xdg_wm_base_create_positioner(priv->xdg_wm_base);
   gtk_window_get_size (GTK_WINDOW (settings->window), &width, &height);
   xdg_positioner_set_size(xdg_positioner, width, height);
-  phosh_shell_get_usable_area (self, NULL, NULL, &width, NULL);
-  xdg_positioner_set_offset(xdg_positioner, 0, PHOSH_PANEL_HEIGHT-1);
-  xdg_positioner_set_anchor_rect(xdg_positioner, width, 0, 1, 1);
-  xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM);
-  xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM);
+  phosh_shell_get_usable_area (self, NULL, NULL, &panel_width, NULL);
+  xdg_positioner_set_offset(xdg_positioner, -width+1, PHOSH_PANEL_HEIGHT-1);
+  xdg_positioner_set_anchor_rect(xdg_positioner, panel_width-1, 0, panel_width-2, 1);
+  xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM_LEFT);
+  xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
 
   settings->popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner);
   g_return_if_fail (settings->popup);
-- 
GitLab