forked from AuroraMiddleware/gtk
broadway: Track surface position correctly
surface->x/y (and various x,y arguments) should be in the parent coordinates, so treat it as such. We also keep track of the root coords as these are needed for popup positioning. Also, drop the isTemp property server side and the weird initial placement at (100, 100) in the daemon. We now fully control window placement from the client instead. If this is not we want we should do a serious design for that but until then lets do the simplest thing.
This commit is contained in:
parent
1a763c440f
commit
03d6d272f7
@ -200,8 +200,7 @@ broadway_output_ungrab_pointer (BroadwayOutput *output)
|
||||
|
||||
void
|
||||
broadway_output_new_surface(BroadwayOutput *output,
|
||||
int id, int x, int y, int w, int h,
|
||||
gboolean is_temp)
|
||||
int id, int x, int y, int w, int h)
|
||||
{
|
||||
write_header (output, BROADWAY_OP_NEW_SURFACE);
|
||||
append_uint16 (output, id);
|
||||
@ -209,7 +208,6 @@ broadway_output_new_surface(BroadwayOutput *output,
|
||||
append_uint16 (output, y);
|
||||
append_uint16 (output, w);
|
||||
append_uint16 (output, h);
|
||||
append_bool (output, is_temp);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -30,8 +30,7 @@ void broadway_output_new_surface (BroadwayOutput *output,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
gboolean is_temp);
|
||||
int h);
|
||||
void broadway_output_disconnected (BroadwayOutput *output);
|
||||
void broadway_output_show_surface (BroadwayOutput *output,
|
||||
int id);
|
||||
|
@ -276,7 +276,6 @@ typedef struct {
|
||||
gint32 y;
|
||||
guint32 width;
|
||||
guint32 height;
|
||||
guint32 is_temp;
|
||||
} BroadwayRequestNewSurface;
|
||||
|
||||
typedef struct {
|
||||
|
@ -120,7 +120,6 @@ struct BroadwaySurface {
|
||||
gint32 y;
|
||||
gint32 width;
|
||||
gint32 height;
|
||||
gboolean is_temp;
|
||||
gboolean visible;
|
||||
gint32 transient_for;
|
||||
guint32 texture;
|
||||
@ -2074,8 +2073,7 @@ broadway_server_new_surface (BroadwayServer *server,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gboolean is_temp)
|
||||
int height)
|
||||
{
|
||||
BroadwaySurface *surface;
|
||||
|
||||
@ -2084,15 +2082,8 @@ broadway_server_new_surface (BroadwayServer *server,
|
||||
surface->id = server->id_counter++;
|
||||
surface->x = x;
|
||||
surface->y = y;
|
||||
if (x == 0 && y == 0 && !is_temp)
|
||||
{
|
||||
/* TODO: Better way to know if we should pick default pos */
|
||||
surface->x = 100;
|
||||
surface->y = 100;
|
||||
}
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->is_temp = is_temp;
|
||||
surface->node_lookup = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
g_hash_table_insert (server->surface_id_hash,
|
||||
@ -2107,8 +2098,7 @@ broadway_server_new_surface (BroadwayServer *server,
|
||||
surface->x,
|
||||
surface->y,
|
||||
surface->width,
|
||||
surface->height,
|
||||
surface->is_temp);
|
||||
surface->height);
|
||||
else
|
||||
fake_configure_notify (server, surface);
|
||||
|
||||
@ -2148,8 +2138,7 @@ broadway_server_resync_surfaces (BroadwayServer *server)
|
||||
surface->x,
|
||||
surface->y,
|
||||
surface->width,
|
||||
surface->height,
|
||||
surface->is_temp);
|
||||
surface->height);
|
||||
}
|
||||
|
||||
/* Then do everything that may reference other surfaces */
|
||||
|
@ -91,8 +91,7 @@ guint32 broadway_server_new_surface (BroadwayServer *
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gboolean is_temp);
|
||||
int height);
|
||||
void broadway_server_destroy_surface (BroadwayServer *server,
|
||||
gint id);
|
||||
gboolean broadway_server_surface_show (BroadwayServer *server,
|
||||
|
@ -298,10 +298,9 @@ function sendConfigureNotify(surface)
|
||||
sendInput(BROADWAY_EVENT_CONFIGURE_NOTIFY, [surface.id, surface.x, surface.y, surface.width, surface.height]);
|
||||
}
|
||||
|
||||
function cmdCreateSurface(id, x, y, width, height, isTemp)
|
||||
function cmdCreateSurface(id, x, y, width, height)
|
||||
{
|
||||
var surface = { id: id, x: x, y:y, width: width, height: height, isTemp: isTemp };
|
||||
surface.positioned = isTemp;
|
||||
var surface = { id: id, x: x, y:y, width: width, height: height };
|
||||
surface.transientParent = 0;
|
||||
surface.visible = false;
|
||||
surface.imageData = null;
|
||||
@ -1039,8 +1038,7 @@ function handleCommands(cmd, display_commands, new_textures, modified_trees)
|
||||
y = cmd.get_16s();
|
||||
w = cmd.get_16();
|
||||
h = cmd.get_16();
|
||||
var isTemp = cmd.get_bool();
|
||||
var div = cmdCreateSurface(id, x, y, w, h, isTemp);
|
||||
var div = cmdCreateSurface(id, x, y, w, h);
|
||||
display_commands.push([DISPLAY_OP_APPEND_ROOT, div]);
|
||||
need_restack = true;
|
||||
break;
|
||||
@ -1109,7 +1107,6 @@ function handleCommands(cmd, display_commands, new_textures, modified_trees)
|
||||
var has_size = ops & 2;
|
||||
surface = surfaces[id];
|
||||
if (has_pos) {
|
||||
surface.positioned = true;
|
||||
surface.x = cmd.get_16s();
|
||||
surface.y = cmd.get_16s();
|
||||
display_commands.push([DISPLAY_OP_MOVE_NODE, surface.div, surface.x, surface.y]);
|
||||
|
@ -238,8 +238,7 @@ client_handle_request (BroadwayClient *client,
|
||||
request->new_surface.x,
|
||||
request->new_surface.y,
|
||||
request->new_surface.width,
|
||||
request->new_surface.height,
|
||||
request->new_surface.is_temp);
|
||||
request->new_surface.height);
|
||||
client->surfaces =
|
||||
g_list_prepend (client->surfaces,
|
||||
GUINT_TO_POINTER (reply_new_surface.id));
|
||||
|
@ -482,8 +482,7 @@ _gdk_broadway_server_new_surface (GdkBroadwayServer *server,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gboolean is_temp)
|
||||
int height)
|
||||
{
|
||||
BroadwayRequestNewSurface msg;
|
||||
guint32 serial, id;
|
||||
@ -493,7 +492,6 @@ _gdk_broadway_server_new_surface (GdkBroadwayServer *server,
|
||||
msg.y = y;
|
||||
msg.width = width;
|
||||
msg.height = height;
|
||||
msg.is_temp = is_temp;
|
||||
serial = gdk_broadway_server_send_message (server, msg,
|
||||
BROADWAY_REQUEST_NEW_SURFACE);
|
||||
reply = gdk_broadway_server_wait_for_reply (server, serial);
|
||||
|
@ -43,8 +43,7 @@ guint32 _gdk_broadway_server_new_surface (GdkBroadwaySe
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gboolean is_temp);
|
||||
int height);
|
||||
void _gdk_broadway_server_destroy_surface (GdkBroadwayServer *server,
|
||||
gint id);
|
||||
gboolean _gdk_broadway_server_surface_show (GdkBroadwayServer *server,
|
||||
|
@ -294,11 +294,6 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->configure_notify.id));
|
||||
if (surface)
|
||||
{
|
||||
surface->x = message->configure_notify.x;
|
||||
surface->y = message->configure_notify.y;
|
||||
|
||||
gdk_broadway_surface_update_popups (surface);
|
||||
|
||||
event = gdk_event_configure_new (surface,
|
||||
message->configure_notify.width,
|
||||
message->configure_notify.height);
|
||||
|
@ -67,7 +67,6 @@ void _gdk_broadway_roundtrip_notify (GdkSurface *surface,
|
||||
void _gdk_broadway_surface_grab_check_destroy (GdkSurface *surface);
|
||||
void _gdk_broadway_surface_grab_check_unmap (GdkSurface *surface,
|
||||
gulong serial);
|
||||
void gdk_broadway_surface_update_popups (GdkSurface *surface);
|
||||
|
||||
void gdk_broadway_surface_move_resize (GdkSurface *surface,
|
||||
gint x,
|
||||
|
@ -253,12 +253,19 @@ _gdk_broadway_display_create_surface (GdkDisplay *display,
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
|
||||
impl = GDK_BROADWAY_SURFACE (surface);
|
||||
impl->root_x = x;
|
||||
impl->root_y = y;
|
||||
if (parent)
|
||||
{
|
||||
impl->root_x += GDK_BROADWAY_SURFACE (parent)->root_x;
|
||||
impl->root_y += GDK_BROADWAY_SURFACE (parent)->root_y;
|
||||
}
|
||||
|
||||
impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
|
||||
surface->x,
|
||||
surface->y,
|
||||
impl->root_x,
|
||||
impl->root_y,
|
||||
surface->width,
|
||||
surface->height,
|
||||
surface_type == GDK_SURFACE_TEMP);
|
||||
surface->height);
|
||||
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
|
||||
|
||||
if (!surface->parent)
|
||||
@ -399,6 +406,41 @@ gdk_broadway_surface_get_scale_factor (GdkSurface *surface)
|
||||
return broadway_display->scale_factor;
|
||||
}
|
||||
|
||||
static void
|
||||
sync_child_root_pos (GdkSurface *parent)
|
||||
{
|
||||
GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (parent);
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
GList *l;
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (parent));
|
||||
|
||||
for (l = parent->children; l; l = l->next)
|
||||
{
|
||||
GdkBroadwaySurface *child_impl = l->data;
|
||||
GdkSurface *child = GDK_SURFACE (child_impl);
|
||||
int root_x, root_y;
|
||||
|
||||
root_x = child->x + parent_impl->root_x;
|
||||
root_y = child->y + parent_impl->root_y;
|
||||
|
||||
if (root_x != child_impl->root_x ||
|
||||
root_y != child_impl->root_y)
|
||||
{
|
||||
child_impl->root_x = root_x;
|
||||
child_impl->root_y = root_y;
|
||||
|
||||
_gdk_broadway_server_surface_move_resize (broadway_display->server,
|
||||
child_impl->id,
|
||||
TRUE,
|
||||
child_impl->root_x, child_impl->root_y,
|
||||
child->width, child->height);
|
||||
sync_child_root_pos (child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* x, y is relative to parent */
|
||||
static void
|
||||
gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
|
||||
gboolean with_move,
|
||||
@ -411,6 +453,20 @@ gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
gboolean size_changed;
|
||||
|
||||
if (with_move)
|
||||
{
|
||||
surface->x = x;
|
||||
surface->y = y;
|
||||
impl->root_x = x;
|
||||
impl->root_y = y;
|
||||
if (surface->parent)
|
||||
{
|
||||
GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (surface->parent);
|
||||
impl->root_x += parent_impl->root_x;
|
||||
impl->root_y += parent_impl->root_y;
|
||||
}
|
||||
}
|
||||
|
||||
size_changed = FALSE;
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
||||
@ -437,17 +493,13 @@ gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
if (surface->parent)
|
||||
{
|
||||
impl->offset_x = x - surface->parent->x;
|
||||
impl->offset_y = y - surface->parent->y;
|
||||
}
|
||||
|
||||
_gdk_broadway_server_surface_move_resize (broadway_display->server,
|
||||
impl->id,
|
||||
with_move,
|
||||
x, y,
|
||||
impl->root_x, impl->root_y,
|
||||
surface->width, surface->height);
|
||||
sync_child_root_pos (surface);
|
||||
|
||||
queue_flush (surface);
|
||||
if (size_changed)
|
||||
{
|
||||
@ -501,9 +553,8 @@ gdk_broadway_surface_layout_popup (GdkSurface *surface,
|
||||
layout,
|
||||
&final_rect);
|
||||
|
||||
gdk_surface_get_origin (surface->parent, &x, &y);
|
||||
x += final_rect.x;
|
||||
y += final_rect.y;
|
||||
x = final_rect.x;
|
||||
y = final_rect.y;
|
||||
|
||||
if (final_rect.width != surface->width ||
|
||||
final_rect.height != surface->height)
|
||||
@ -658,10 +709,14 @@ gdk_broadway_surface_get_root_coords (GdkSurface *surface,
|
||||
gint *root_x,
|
||||
gint *root_y)
|
||||
{
|
||||
GdkBroadwaySurface *impl;
|
||||
|
||||
impl = GDK_BROADWAY_SURFACE (surface);
|
||||
|
||||
if (root_x)
|
||||
*root_x = x + surface->x;
|
||||
*root_x = x + impl->root_x;
|
||||
if (root_y)
|
||||
*root_y = y + surface->y;
|
||||
*root_y = y + impl->root_y;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -762,25 +817,6 @@ gdk_broadway_surface_unmaximize (GdkSurface *surface)
|
||||
impl->pre_maximize_height);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_broadway_surface_update_popups (GdkSurface *parent)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = parent ->children; l; l = l->next)
|
||||
{
|
||||
GdkBroadwaySurface *popup_impl = l->data;
|
||||
GdkSurface *popup = GDK_SURFACE (popup_impl);
|
||||
int new_x = parent->x + popup_impl->offset_x;
|
||||
int new_y = parent->y + popup_impl->offset_y;
|
||||
|
||||
if (new_x != popup->x || new_y != popup->y)
|
||||
gdk_broadway_surface_move_resize (popup,
|
||||
new_x, new_y,
|
||||
popup->width, popup->height);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _MoveResizeData MoveResizeData;
|
||||
|
||||
struct _MoveResizeData
|
||||
|
@ -61,8 +61,8 @@ struct _GdkBroadwaySurface
|
||||
GArray *node_data;
|
||||
GPtrArray *node_data_textures;
|
||||
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
int root_x;
|
||||
int root_y;
|
||||
};
|
||||
|
||||
struct _GdkBroadwaySurfaceClass
|
||||
|
Loading…
Reference in New Issue
Block a user