summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <tiago.vignatti@intel.com>2012-07-25 16:20:44 +0300
committerTiago Vignatti <tiago.vignatti@intel.com>2012-07-30 21:22:23 +0300
commit62aeada4d5ac7f24084fd121961819e2c6d1f118 (patch)
tree4174cb5658f28d95a35022172aecd7ff439418cf
parentd1936b9e2b352e93ace1b3609740ce4902b33a9e (diff)
WIP: compositor/xwm: forward global position to Xxwm-configure2
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
-rw-r--r--src/compositor.c1
-rw-r--r--src/compositor.h6
-rw-r--r--src/shell.c29
-rw-r--r--src/xwayland/window-manager.c81
-rw-r--r--src/xwayland/xwayland.h2
5 files changed, 86 insertions, 33 deletions
diff --git a/src/compositor.c b/src/compositor.c
index ed887a4..d1eb406 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3145,6 +3145,7 @@ weston_compositor_init(struct weston_compositor *ec,
ec->wl_display = display;
wl_signal_init(&ec->destroy_signal);
wl_signal_init(&ec->activate_signal);
+ wl_signal_init(&ec->position_signal);
wl_signal_init(&ec->lock_signal);
wl_signal_init(&ec->unlock_signal);
wl_signal_init(&ec->show_input_panel_signal);
diff --git a/src/compositor.h b/src/compositor.h
index 22c0174..37b9821 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -82,8 +82,7 @@ struct weston_shell_interface {
void (*set_toplevel)(struct shell_surface *shsurf);
- void (*set_transient)(struct shell_surface *shsurf,
- struct weston_surface *parent,
+ void (*set_xwm_transient)(struct shell_surface *shsurf,
int x, int y, uint32_t flags);
int (*move)(struct shell_surface *shsurf, struct weston_seat *ws);
int (*resize)(struct shell_surface *shsurf,
@@ -279,7 +278,10 @@ struct weston_compositor {
struct wl_display *wl_display;
struct weston_shell_interface shell_interface;
+ /* xwayland */
struct wl_signal activate_signal;
+ struct wl_signal position_signal;
+
struct wl_signal lock_signal;
struct wl_signal unlock_signal;
diff --git a/src/shell.c b/src/shell.c
index a9e4d4f..5363a10 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -132,7 +132,9 @@ enum shell_surface_type {
SHELL_SURFACE_TRANSIENT,
SHELL_SURFACE_FULLSCREEN,
SHELL_SURFACE_MAXIMIZED,
- SHELL_SURFACE_POPUP
+ SHELL_SURFACE_POPUP,
+
+ SHELL_SURFACE_XWM_TRANSIENT
};
struct ping_timer {
@@ -276,9 +278,13 @@ shell_grab_start(struct shell_grab *grab,
static void
shell_grab_end(struct shell_grab *grab)
{
+ struct weston_compositor *compositor =
+ grab->shsurf->surface->compositor;
+
if (grab->shsurf)
wl_list_remove(&grab->shsurf_destroy_listener.link);
+ wl_signal_emit(&compositor->position_signal, grab->shsurf->surface);
wl_pointer_end_grab(grab->pointer);
}
@@ -1223,6 +1229,7 @@ reset_shell_surface_type(struct shell_surface *surface)
case SHELL_SURFACE_NONE:
case SHELL_SURFACE_TOPLEVEL:
case SHELL_SURFACE_TRANSIENT:
+ case SHELL_SURFACE_XWM_TRANSIENT:
case SHELL_SURFACE_POPUP:
break;
}
@@ -1245,6 +1252,10 @@ set_surface_type(struct shell_surface *shsurf)
switch (shsurf->type) {
case SHELL_SURFACE_TOPLEVEL:
break;
+ case SHELL_SURFACE_XWM_TRANSIENT:
+ weston_surface_set_position(surface, shsurf->transient.x,
+ shsurf->transient.y);
+ break;
case SHELL_SURFACE_TRANSIENT:
weston_surface_set_position(surface,
pes->geometry.x + shsurf->transient.x,
@@ -1291,6 +1302,15 @@ shell_surface_set_toplevel(struct wl_client *client,
}
static void
+set_xwm_transient(struct shell_surface *shsurf, int x, int y, uint32_t flags)
+{
+ shsurf->transient.x = x;
+ shsurf->transient.y = y;
+ shsurf->transient.flags = flags;
+ shsurf->next_type = SHELL_SURFACE_XWM_TRANSIENT;
+}
+
+static void
set_transient(struct shell_surface *shsurf,
struct weston_surface *parent, int x, int y, uint32_t flags)
{
@@ -2590,6 +2610,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_NONE:
break;
+ case SHELL_SURFACE_XWM_TRANSIENT:
default:
ws = get_current_workspace(shell);
wl_list_insert(&ws->layer.surface_list, &surface->layer_link);
@@ -2603,6 +2624,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
}
switch (surface_type) {
+ case SHELL_SURFACE_XWM_TRANSIENT:
case SHELL_SURFACE_TRANSIENT:
if (shsurf->transient.flags ==
WL_SHELL_SURFACE_TRANSIENT_INACTIVE)
@@ -2682,6 +2704,7 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
{
struct shell_surface *shsurf = get_shell_surface(es);
struct desktop_shell *shell = shsurf->shell;
+ struct weston_compositor *compositor = shsurf->surface->compositor;
int type_changed = 0;
if (shsurf->next_type != SHELL_SURFACE_NONE &&
@@ -2705,6 +2728,8 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
es->geometry.y + to_y - from_y,
es->buffer->width, es->buffer->height);
}
+
+ wl_signal_emit(&compositor->position_signal, shsurf->surface);
}
static int launch_desktop_shell_process(struct desktop_shell *shell);
@@ -3314,7 +3339,7 @@ shell_init(struct weston_compositor *ec)
ec->shell_interface.shell = shell;
ec->shell_interface.create_shell_surface = create_shell_surface;
ec->shell_interface.set_toplevel = set_toplevel;
- ec->shell_interface.set_transient = set_transient;
+ ec->shell_interface.set_xwm_transient = set_xwm_transient;
ec->shell_interface.move = surface_move;
ec->shell_interface.resize = surface_resize;
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index e67cac1..811b2e6 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -511,12 +511,45 @@ weston_wm_window_activate(struct wl_listener *listener, void *data)
if (wm->focus_window)
weston_wm_window_schedule_repaint(wm->focus_window);
wm->focus_window = window;
- if (window)
- wm->focus_latest = window;
if (wm->focus_window)
weston_wm_window_schedule_repaint(wm->focus_window);
}
+static void
+weston_wm_window_position(struct wl_listener *listener, void *data)
+{
+ struct weston_surface *surface = data;
+ struct weston_wm_window *window = get_wm_window(surface);
+ struct weston_wm *wm =
+ container_of(listener, struct weston_wm, position_listener);
+ struct weston_output *output = surface->output;
+ uint32_t mask, values[2];
+ GLfloat sxf, syf;
+ int sx, sy;
+
+ if (!window || !wm)
+ return;
+
+ if (!weston_surface_is_mapped(surface))
+ return;
+
+ weston_surface_to_global_float(surface, output->x, output->y,
+ &sxf, &syf);
+
+ /* TODO: need to check if position in fact has changed before forward
+ * event through the wire */
+
+ sx = (int) sxf;
+ sy = (int) syf;
+ values[0] = sx;
+ values[1] = sy;
+ mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
+
+ xcb_configure_window(wm->conn, window->frame_id, mask, values);
+ xcb_flush(wm->conn);
+ fprintf(stderr, "%s: %d %d\n", __func__, sx, sy);
+}
+
static int
our_resource(struct weston_wm *wm, uint32_t id)
{
@@ -1088,6 +1121,9 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
break;
}
}
+
+ fprintf(stderr, "%s: (%d %d)\n", __func__, button->event_x,
+ button->event_y);
}
static void
@@ -1124,6 +1160,9 @@ weston_wm_handle_enter(struct weston_wm *wm, xcb_generic_event_t *event)
enter->event_x, enter->event_y);
weston_wm_window_set_cursor(wm, window->frame_id, cursor);
+
+ fprintf(stderr, "%s: %d (%d %d)\n", __func__, cursor, enter->event_x,
+ enter->event_y);
}
static void
@@ -1137,6 +1176,9 @@ weston_wm_handle_leave(struct weston_wm *wm, xcb_generic_event_t *event)
return;
weston_wm_window_set_cursor(wm, window->frame_id, XWM_CURSOR_LEFT_PTR);
+
+ fprintf(stderr, "%s: (%d %d)\n", __func__, leave->event_x,
+ leave->event_y);
}
static int
@@ -1461,6 +1503,10 @@ weston_wm_create(struct weston_xserver *wxs)
wl_signal_add(&wxs->compositor->activate_signal,
&wm->activate_listener);
+ wm->position_listener.notify = weston_wm_window_position;
+ wl_signal_add(&wxs->compositor->position_signal,
+ &wm->position_listener);
+
weston_wm_create_cursors(wm);
weston_wm_window_set_cursor(wm, wm->screen->root, XWM_CURSOR_LEFT_PTR);
@@ -1572,9 +1618,7 @@ xserver_map_shell_surface(struct weston_wm *wm,
{
struct weston_shell_interface *shell_interface =
&wm->server->compositor->shell_interface;
- struct weston_wm_window *parent;
struct theme *t = window->wm->theme;
- int parent_id, x = 0, y = 0;
if (!shell_interface->create_shell_surface)
return;
@@ -1584,32 +1628,13 @@ xserver_map_shell_surface(struct weston_wm *wm,
window->surface,
&shell_client);
- /* ICCCM 4.1.1 */
- if (!window->override_redirect) {
+ if (!window->override_redirect)
shell_interface->set_toplevel(window->shsurf);
- return;
- }
-
- /* not all non-toplevel has transient_for set. So we need this
- * workaround to guess a parent that will determine the relative
- * position of the transient surface */
- if (!window->transient_for)
- parent_id = wm->focus_latest->id;
else
- parent_id = window->transient_for->id;
-
- parent = hash_table_lookup(wm->window_hash, parent_id);
-
- /* non-decorated and non-toplevel windows, e.g. sub-menus */
- if (!parent->decorate && parent->override_redirect) {
- x = parent->x + t->margin;
- y = parent->y + t->margin;
- }
-
- shell_interface->set_transient(window->shsurf, parent->surface,
- window->x + t->margin - x,
- window->y + t->margin - y,
- WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
+ shell_interface->set_xwm_transient(window->shsurf,
+ window->x + t->margin,
+ window->y + t->margin,
+ WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
}
static void
diff --git a/src/xwayland/xwayland.h b/src/xwayland/xwayland.h
index 23c6a77..75a9c1a 100644
--- a/src/xwayland/xwayland.h
+++ b/src/xwayland/xwayland.h
@@ -57,12 +57,12 @@ struct weston_wm {
struct weston_xserver *server;
xcb_window_t wm_window;
struct weston_wm_window *focus_window;
- struct weston_wm_window *focus_latest;
struct theme *theme;
xcb_cursor_t *cursors;
int last_cursor;
xcb_render_pictforminfo_t format_rgb, format_rgba;
struct wl_listener activate_listener;
+ struct wl_listener position_listener;
xcb_window_t selection_window;
xcb_window_t selection_owner;