[PATCH weston 07/10] compositor: hook xserver transient windows with shell_interface
Tiago Vignatti
tiago.vignatti at intel.com
Fri May 18 08:47:14 PDT 2012
I cared about tooltip type of windows on this commit. I also marked by default
all non-toplevel windows as inactive, which in general gives a better
experience.
Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
src/compositor.h | 3 +++
src/shell.c | 21 +++++++++++++++------
src/xserver-launcher.c | 43 +++++++++++++++++++++++++++++++++----------
3 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/src/compositor.h b/src/compositor.h
index de30647..7290584 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -62,6 +62,9 @@ struct weston_shell_interface {
struct weston_surface *surface,
struct shell_surface **ret);
void (*set_toplevel)(struct shell_surface *shsurf);
+ void (*set_transient)(struct shell_surface *shsurf,
+ struct shell_surface *pshsurf, int x, int y,
+ uint32_t flags);
};
struct weston_border {
diff --git a/src/shell.c b/src/shell.c
index d15ffbb..8d7a67a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -826,19 +826,27 @@ shell_surface_set_toplevel(struct wl_client *client,
}
static void
+set_transient(struct shell_surface *shsurf, struct shell_surface *pshsurf,
+ int x, int y, uint32_t flags)
+{
+ /* assign to parents output */
+ shsurf->parent = pshsurf;
+ shsurf->transient.x = x;
+ shsurf->transient.y = y;
+ shsurf->transient.flags = flags;
+ shsurf->next_type = SHELL_SURFACE_TRANSIENT;
+}
+
+static void
shell_surface_set_transient(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *parent_resource,
int x, int y, uint32_t flags)
{
struct shell_surface *shsurf = resource->data;
+ struct shell_surface *pshsurf = parent_resource->data;
- /* assign to parents output */
- shsurf->parent = parent_resource->data;
- shsurf->transient.x = x;
- shsurf->transient.y = y;
- shsurf->transient.flags = flags;
- shsurf->next_type = SHELL_SURFACE_TRANSIENT;
+ set_transient(shsurf, pshsurf, x, y, flags);
}
static struct desktop_shell *
@@ -2610,6 +2618,7 @@ shell_init(struct weston_compositor *ec)
ec->ping_handler = ping_handler;
ec->shell_interface.create_shell_surface = create_shell_surface;
ec->shell_interface.set_toplevel = set_toplevel;
+ ec->shell_interface.set_transient = set_transient;
wl_list_init(&shell->backgrounds);
wl_list_init(&shell->panels);
diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
index f785508..7c7bd0b 100644
--- a/src/xserver-launcher.c
+++ b/src/xserver-launcher.c
@@ -1773,6 +1773,38 @@ get_wm_window(struct weston_surface *surface)
}
static void
+xserver_map_shell_surface(struct weston_wm *wm,
+ struct weston_wm_window *window)
+{
+ struct weston_shell_interface *shell_interface =
+ &wm->server->compositor->shell_interface;
+ struct weston_wm_window *parent;
+ struct wl_pointer pointer;
+ const int offset_y = 20;
+
+ if (!shell_interface->create_shell_surface)
+ return;
+
+ shell_interface->create_shell_surface(shell_interface->shell,
+ window->surface, &window->shsurf);
+
+ if (!window->transient_for)
+ shell_interface->set_toplevel(window->shsurf);
+ else {
+ parent = hash_table_lookup(wm->window_hash,
+ window->transient_for->id);
+ pointer = wm->server->compositor->seat->pointer;
+ shell_interface->set_transient(window->shsurf,
+ parent->shsurf,
+ wl_fixed_to_int(pointer.x) -
+ parent->surface->geometry.x,
+ wl_fixed_to_int(pointer.y) -
+ parent->surface->geometry.y + offset_y,
+ WL_SHELL_SURFACE_TRANSIENT_METHOD_INACTIVE);
+ }
+}
+
+static void
xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *surface_resource, uint32_t id)
{
@@ -1780,8 +1812,6 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
struct weston_wm *wm = wxs->wm;
struct wl_surface *surface = surface_resource->data;
struct weston_wm_window *window;
- struct weston_shell_interface *shell_interface =
- &wm->server->compositor->shell_interface;
if (client != wxs->client)
return;
@@ -1802,14 +1832,7 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
&window->surface_destroy_listener);
weston_wm_window_schedule_repaint(window);
-
- if (shell_interface->create_shell_surface) {
- shell_interface->create_shell_surface(shell_interface->shell,
- window->surface,
- &window->shsurf);
-
- shell_interface->set_toplevel(window->shsurf);
- }
+ xserver_map_shell_surface(wm, window);
}
static const struct xserver_interface xserver_implementation = {
--
1.7.9.5
More information about the wayland-devel
mailing list