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
|
void
|
||||||
broadway_output_new_surface(BroadwayOutput *output,
|
broadway_output_new_surface(BroadwayOutput *output,
|
||||||
int id, int x, int y, int w, int h,
|
int id, int x, int y, int w, int h)
|
||||||
gboolean is_temp)
|
|
||||||
{
|
{
|
||||||
write_header (output, BROADWAY_OP_NEW_SURFACE);
|
write_header (output, BROADWAY_OP_NEW_SURFACE);
|
||||||
append_uint16 (output, id);
|
append_uint16 (output, id);
|
||||||
@ -209,7 +208,6 @@ broadway_output_new_surface(BroadwayOutput *output,
|
|||||||
append_uint16 (output, y);
|
append_uint16 (output, y);
|
||||||
append_uint16 (output, w);
|
append_uint16 (output, w);
|
||||||
append_uint16 (output, h);
|
append_uint16 (output, h);
|
||||||
append_bool (output, is_temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -30,8 +30,7 @@ void broadway_output_new_surface (BroadwayOutput *output,
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int w,
|
int w,
|
||||||
int h,
|
int h);
|
||||||
gboolean is_temp);
|
|
||||||
void broadway_output_disconnected (BroadwayOutput *output);
|
void broadway_output_disconnected (BroadwayOutput *output);
|
||||||
void broadway_output_show_surface (BroadwayOutput *output,
|
void broadway_output_show_surface (BroadwayOutput *output,
|
||||||
int id);
|
int id);
|
||||||
|
@ -276,7 +276,6 @@ typedef struct {
|
|||||||
gint32 y;
|
gint32 y;
|
||||||
guint32 width;
|
guint32 width;
|
||||||
guint32 height;
|
guint32 height;
|
||||||
guint32 is_temp;
|
|
||||||
} BroadwayRequestNewSurface;
|
} BroadwayRequestNewSurface;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -120,7 +120,6 @@ struct BroadwaySurface {
|
|||||||
gint32 y;
|
gint32 y;
|
||||||
gint32 width;
|
gint32 width;
|
||||||
gint32 height;
|
gint32 height;
|
||||||
gboolean is_temp;
|
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
gint32 transient_for;
|
gint32 transient_for;
|
||||||
guint32 texture;
|
guint32 texture;
|
||||||
@ -2074,8 +2073,7 @@ broadway_server_new_surface (BroadwayServer *server,
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height)
|
||||||
gboolean is_temp)
|
|
||||||
{
|
{
|
||||||
BroadwaySurface *surface;
|
BroadwaySurface *surface;
|
||||||
|
|
||||||
@ -2084,15 +2082,8 @@ broadway_server_new_surface (BroadwayServer *server,
|
|||||||
surface->id = server->id_counter++;
|
surface->id = server->id_counter++;
|
||||||
surface->x = x;
|
surface->x = x;
|
||||||
surface->y = y;
|
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->width = width;
|
||||||
surface->height = height;
|
surface->height = height;
|
||||||
surface->is_temp = is_temp;
|
|
||||||
surface->node_lookup = g_hash_table_new (g_direct_hash, g_direct_equal);
|
surface->node_lookup = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
|
||||||
g_hash_table_insert (server->surface_id_hash,
|
g_hash_table_insert (server->surface_id_hash,
|
||||||
@ -2107,8 +2098,7 @@ broadway_server_new_surface (BroadwayServer *server,
|
|||||||
surface->x,
|
surface->x,
|
||||||
surface->y,
|
surface->y,
|
||||||
surface->width,
|
surface->width,
|
||||||
surface->height,
|
surface->height);
|
||||||
surface->is_temp);
|
|
||||||
else
|
else
|
||||||
fake_configure_notify (server, surface);
|
fake_configure_notify (server, surface);
|
||||||
|
|
||||||
@ -2148,8 +2138,7 @@ broadway_server_resync_surfaces (BroadwayServer *server)
|
|||||||
surface->x,
|
surface->x,
|
||||||
surface->y,
|
surface->y,
|
||||||
surface->width,
|
surface->width,
|
||||||
surface->height,
|
surface->height);
|
||||||
surface->is_temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then do everything that may reference other surfaces */
|
/* Then do everything that may reference other surfaces */
|
||||||
|
@ -91,8 +91,7 @@ guint32 broadway_server_new_surface (BroadwayServer *
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height);
|
||||||
gboolean is_temp);
|
|
||||||
void broadway_server_destroy_surface (BroadwayServer *server,
|
void broadway_server_destroy_surface (BroadwayServer *server,
|
||||||
gint id);
|
gint id);
|
||||||
gboolean broadway_server_surface_show (BroadwayServer *server,
|
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]);
|
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 };
|
var surface = { id: id, x: x, y:y, width: width, height: height };
|
||||||
surface.positioned = isTemp;
|
|
||||||
surface.transientParent = 0;
|
surface.transientParent = 0;
|
||||||
surface.visible = false;
|
surface.visible = false;
|
||||||
surface.imageData = null;
|
surface.imageData = null;
|
||||||
@ -1039,8 +1038,7 @@ function handleCommands(cmd, display_commands, new_textures, modified_trees)
|
|||||||
y = cmd.get_16s();
|
y = cmd.get_16s();
|
||||||
w = cmd.get_16();
|
w = cmd.get_16();
|
||||||
h = cmd.get_16();
|
h = cmd.get_16();
|
||||||
var isTemp = cmd.get_bool();
|
var div = cmdCreateSurface(id, x, y, w, h);
|
||||||
var div = cmdCreateSurface(id, x, y, w, h, isTemp);
|
|
||||||
display_commands.push([DISPLAY_OP_APPEND_ROOT, div]);
|
display_commands.push([DISPLAY_OP_APPEND_ROOT, div]);
|
||||||
need_restack = true;
|
need_restack = true;
|
||||||
break;
|
break;
|
||||||
@ -1109,7 +1107,6 @@ function handleCommands(cmd, display_commands, new_textures, modified_trees)
|
|||||||
var has_size = ops & 2;
|
var has_size = ops & 2;
|
||||||
surface = surfaces[id];
|
surface = surfaces[id];
|
||||||
if (has_pos) {
|
if (has_pos) {
|
||||||
surface.positioned = true;
|
|
||||||
surface.x = cmd.get_16s();
|
surface.x = cmd.get_16s();
|
||||||
surface.y = cmd.get_16s();
|
surface.y = cmd.get_16s();
|
||||||
display_commands.push([DISPLAY_OP_MOVE_NODE, surface.div, surface.x, surface.y]);
|
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.x,
|
||||||
request->new_surface.y,
|
request->new_surface.y,
|
||||||
request->new_surface.width,
|
request->new_surface.width,
|
||||||
request->new_surface.height,
|
request->new_surface.height);
|
||||||
request->new_surface.is_temp);
|
|
||||||
client->surfaces =
|
client->surfaces =
|
||||||
g_list_prepend (client->surfaces,
|
g_list_prepend (client->surfaces,
|
||||||
GUINT_TO_POINTER (reply_new_surface.id));
|
GUINT_TO_POINTER (reply_new_surface.id));
|
||||||
|
@ -482,8 +482,7 @@ _gdk_broadway_server_new_surface (GdkBroadwayServer *server,
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height)
|
||||||
gboolean is_temp)
|
|
||||||
{
|
{
|
||||||
BroadwayRequestNewSurface msg;
|
BroadwayRequestNewSurface msg;
|
||||||
guint32 serial, id;
|
guint32 serial, id;
|
||||||
@ -493,7 +492,6 @@ _gdk_broadway_server_new_surface (GdkBroadwayServer *server,
|
|||||||
msg.y = y;
|
msg.y = y;
|
||||||
msg.width = width;
|
msg.width = width;
|
||||||
msg.height = height;
|
msg.height = height;
|
||||||
msg.is_temp = is_temp;
|
|
||||||
serial = gdk_broadway_server_send_message (server, msg,
|
serial = gdk_broadway_server_send_message (server, msg,
|
||||||
BROADWAY_REQUEST_NEW_SURFACE);
|
BROADWAY_REQUEST_NEW_SURFACE);
|
||||||
reply = gdk_broadway_server_wait_for_reply (server, serial);
|
reply = gdk_broadway_server_wait_for_reply (server, serial);
|
||||||
|
@ -43,8 +43,7 @@ guint32 _gdk_broadway_server_new_surface (GdkBroadwaySe
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height);
|
||||||
gboolean is_temp);
|
|
||||||
void _gdk_broadway_server_destroy_surface (GdkBroadwayServer *server,
|
void _gdk_broadway_server_destroy_surface (GdkBroadwayServer *server,
|
||||||
gint id);
|
gint id);
|
||||||
gboolean _gdk_broadway_server_surface_show (GdkBroadwayServer *server,
|
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));
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->configure_notify.id));
|
||||||
if (surface)
|
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,
|
event = gdk_event_configure_new (surface,
|
||||||
message->configure_notify.width,
|
message->configure_notify.width,
|
||||||
message->configure_notify.height);
|
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_destroy (GdkSurface *surface);
|
||||||
void _gdk_broadway_surface_grab_check_unmap (GdkSurface *surface,
|
void _gdk_broadway_surface_grab_check_unmap (GdkSurface *surface,
|
||||||
gulong serial);
|
gulong serial);
|
||||||
void gdk_broadway_surface_update_popups (GdkSurface *surface);
|
|
||||||
|
|
||||||
void gdk_broadway_surface_move_resize (GdkSurface *surface,
|
void gdk_broadway_surface_move_resize (GdkSurface *surface,
|
||||||
gint x,
|
gint x,
|
||||||
|
@ -253,12 +253,19 @@ _gdk_broadway_display_create_surface (GdkDisplay *display,
|
|||||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||||
|
|
||||||
impl = GDK_BROADWAY_SURFACE (surface);
|
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,
|
impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
|
||||||
surface->x,
|
impl->root_x,
|
||||||
surface->y,
|
impl->root_y,
|
||||||
surface->width,
|
surface->width,
|
||||||
surface->height,
|
surface->height);
|
||||||
surface_type == GDK_SURFACE_TEMP);
|
|
||||||
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
|
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
|
||||||
|
|
||||||
if (!surface->parent)
|
if (!surface->parent)
|
||||||
@ -399,6 +406,41 @@ gdk_broadway_surface_get_scale_factor (GdkSurface *surface)
|
|||||||
return broadway_display->scale_factor;
|
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
|
static void
|
||||||
gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
|
gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
|
||||||
gboolean with_move,
|
gboolean with_move,
|
||||||
@ -411,6 +453,20 @@ gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
|
|||||||
GdkBroadwayDisplay *broadway_display;
|
GdkBroadwayDisplay *broadway_display;
|
||||||
gboolean size_changed;
|
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;
|
size_changed = FALSE;
|
||||||
|
|
||||||
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
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,
|
_gdk_broadway_server_surface_move_resize (broadway_display->server,
|
||||||
impl->id,
|
impl->id,
|
||||||
with_move,
|
with_move,
|
||||||
x, y,
|
impl->root_x, impl->root_y,
|
||||||
surface->width, surface->height);
|
surface->width, surface->height);
|
||||||
|
sync_child_root_pos (surface);
|
||||||
|
|
||||||
queue_flush (surface);
|
queue_flush (surface);
|
||||||
if (size_changed)
|
if (size_changed)
|
||||||
{
|
{
|
||||||
@ -501,9 +553,8 @@ gdk_broadway_surface_layout_popup (GdkSurface *surface,
|
|||||||
layout,
|
layout,
|
||||||
&final_rect);
|
&final_rect);
|
||||||
|
|
||||||
gdk_surface_get_origin (surface->parent, &x, &y);
|
x = final_rect.x;
|
||||||
x += final_rect.x;
|
y = final_rect.y;
|
||||||
y += final_rect.y;
|
|
||||||
|
|
||||||
if (final_rect.width != surface->width ||
|
if (final_rect.width != surface->width ||
|
||||||
final_rect.height != surface->height)
|
final_rect.height != surface->height)
|
||||||
@ -658,10 +709,14 @@ gdk_broadway_surface_get_root_coords (GdkSurface *surface,
|
|||||||
gint *root_x,
|
gint *root_x,
|
||||||
gint *root_y)
|
gint *root_y)
|
||||||
{
|
{
|
||||||
|
GdkBroadwaySurface *impl;
|
||||||
|
|
||||||
|
impl = GDK_BROADWAY_SURFACE (surface);
|
||||||
|
|
||||||
if (root_x)
|
if (root_x)
|
||||||
*root_x = x + surface->x;
|
*root_x = x + impl->root_x;
|
||||||
if (root_y)
|
if (root_y)
|
||||||
*root_y = y + surface->y;
|
*root_y = y + impl->root_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -762,25 +817,6 @@ gdk_broadway_surface_unmaximize (GdkSurface *surface)
|
|||||||
impl->pre_maximize_height);
|
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;
|
typedef struct _MoveResizeData MoveResizeData;
|
||||||
|
|
||||||
struct _MoveResizeData
|
struct _MoveResizeData
|
||||||
|
@ -61,8 +61,8 @@ struct _GdkBroadwaySurface
|
|||||||
GArray *node_data;
|
GArray *node_data;
|
||||||
GPtrArray *node_data_textures;
|
GPtrArray *node_data_textures;
|
||||||
|
|
||||||
int offset_x;
|
int root_x;
|
||||||
int offset_y;
|
int root_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GdkBroadwaySurfaceClass
|
struct _GdkBroadwaySurfaceClass
|
||||||
|
Loading…
Reference in New Issue
Block a user