diff options
author | 2018-07-13 21:17:31 +0100 | |
---|---|---|
committer | 2018-07-13 21:17:31 +0100 | |
commit | efda33b28568f2065c2a995d0a05a497b7d33e91 (patch) | |
tree | 4fe0748b3a49e0e0c3bc0ea5652864805457a3d7 /sway | |
parent | Merge pull request #2260 from emersion/fix-has-opaque-lockscreen (diff) | |
download | sway-efda33b28568f2065c2a995d0a05a497b7d33e91.tar.gz sway-efda33b28568f2065c2a995d0a05a497b7d33e91.tar.zst sway-efda33b28568f2065c2a995d0a05a497b7d33e91.zip |
Simplify popup_unconstrain
Just use the parent output.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/xdg_shell.c | 39 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 39 |
2 files changed, 10 insertions, 68 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 17b7b750..fbeeb2e3 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -46,47 +46,18 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) { | |||
46 | } | 46 | } |
47 | 47 | ||
48 | static void popup_unconstrain(struct sway_xdg_popup *popup) { | 48 | static void popup_unconstrain(struct sway_xdg_popup *popup) { |
49 | // get the output of the popup's positioner anchor point and convert it to | ||
50 | // the toplevel parent's coordinate system and then pass it to | ||
51 | // wlr_xdg_popup_unconstrain_from_box | ||
52 | |||
53 | struct sway_view *view = popup->child.view; | 49 | struct sway_view *view = popup->child.view; |
54 | struct wlr_output_layout *output_layout = | ||
55 | root_container.sway_root->output_layout; | ||
56 | struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup; | 50 | struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup; |
57 | 51 | ||
58 | int anchor_lx, anchor_ly; | 52 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); |
59 | wlr_xdg_popup_get_anchor_point(wlr_popup, &anchor_lx, &anchor_ly); | ||
60 | |||
61 | int popup_lx, popup_ly; | ||
62 | wlr_xdg_popup_get_toplevel_coords(wlr_popup, wlr_popup->geometry.x, | ||
63 | wlr_popup->geometry.y, &popup_lx, &popup_ly); | ||
64 | popup_lx += view->x; | ||
65 | popup_ly += view->y; | ||
66 | |||
67 | anchor_lx += popup_lx; | ||
68 | anchor_ly += popup_ly; | ||
69 | |||
70 | double dest_x = 0, dest_y = 0; | ||
71 | wlr_output_layout_closest_point(output_layout, NULL, anchor_lx, anchor_ly, | ||
72 | &dest_x, &dest_y); | ||
73 | |||
74 | struct wlr_output *output = | ||
75 | wlr_output_layout_output_at(output_layout, dest_x, dest_y); | ||
76 | if (output == NULL) { | ||
77 | return; | ||
78 | } | ||
79 | |||
80 | int width = 0, height = 0; | ||
81 | wlr_output_effective_resolution(output, &width, &height); | ||
82 | 53 | ||
83 | // the output box expressed in the coordinate system of the toplevel parent | 54 | // the output box expressed in the coordinate system of the toplevel parent |
84 | // of the popup | 55 | // of the popup |
85 | struct wlr_box output_toplevel_sx_box = { | 56 | struct wlr_box output_toplevel_sx_box = { |
86 | .x = output->lx - view->x, | 57 | .x = output->x - view->x, |
87 | .y = output->ly - view->y, | 58 | .y = output->y - view->y, |
88 | .width = width, | 59 | .width = output->width, |
89 | .height = height | 60 | .height = output->height, |
90 | }; | 61 | }; |
91 | 62 | ||
92 | wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); | 63 | wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 43e58918..88d9bb94 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -45,47 +45,18 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | static void popup_unconstrain(struct sway_xdg_popup_v6 *popup) { | 47 | static void popup_unconstrain(struct sway_xdg_popup_v6 *popup) { |
48 | // get the output of the popup's positioner anchor point and convert it to | ||
49 | // the toplevel parent's coordinate system and then pass it to | ||
50 | // wlr_xdg_popup_unconstrain_from_box | ||
51 | |||
52 | struct sway_view *view = popup->child.view; | 48 | struct sway_view *view = popup->child.view; |
53 | struct wlr_output_layout *output_layout = | ||
54 | root_container.sway_root->output_layout; | ||
55 | struct wlr_xdg_popup_v6 *wlr_popup = popup->wlr_xdg_surface_v6->popup; | 49 | struct wlr_xdg_popup_v6 *wlr_popup = popup->wlr_xdg_surface_v6->popup; |
56 | 50 | ||
57 | int anchor_lx, anchor_ly; | 51 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); |
58 | wlr_xdg_popup_v6_get_anchor_point(wlr_popup, &anchor_lx, &anchor_ly); | ||
59 | |||
60 | int popup_lx, popup_ly; | ||
61 | wlr_xdg_popup_v6_get_toplevel_coords(wlr_popup, wlr_popup->geometry.x, | ||
62 | wlr_popup->geometry.y, &popup_lx, &popup_ly); | ||
63 | popup_lx += view->x; | ||
64 | popup_ly += view->y; | ||
65 | |||
66 | anchor_lx += popup_lx; | ||
67 | anchor_ly += popup_ly; | ||
68 | |||
69 | double dest_x = 0, dest_y = 0; | ||
70 | wlr_output_layout_closest_point(output_layout, NULL, anchor_lx, anchor_ly, | ||
71 | &dest_x, &dest_y); | ||
72 | |||
73 | struct wlr_output *output = | ||
74 | wlr_output_layout_output_at(output_layout, dest_x, dest_y); | ||
75 | if (output == NULL) { | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | int width = 0, height = 0; | ||
80 | wlr_output_effective_resolution(output, &width, &height); | ||
81 | 52 | ||
82 | // the output box expressed in the coordinate system of the toplevel parent | 53 | // the output box expressed in the coordinate system of the toplevel parent |
83 | // of the popup | 54 | // of the popup |
84 | struct wlr_box output_toplevel_sx_box = { | 55 | struct wlr_box output_toplevel_sx_box = { |
85 | .x = output->lx - view->x, | 56 | .x = output->x - view->x, |
86 | .y = output->ly - view->y, | 57 | .y = output->y - view->y, |
87 | .width = width, | 58 | .width = output->width, |
88 | .height = height | 59 | .height = output->height, |
89 | }; | 60 | }; |
90 | 61 | ||
91 | wlr_xdg_popup_v6_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); | 62 | wlr_xdg_popup_v6_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); |