Merge branch 'update-broadway' into 'master'

Update broadway

See merge request GNOME/gtk!1521
This commit is contained in:
Matthias Clasen 2020-03-13 15:09:47 +00:00
commit 9aa270f928
16 changed files with 181 additions and 115 deletions

View File

@ -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

View File

@ -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);

View File

@ -165,6 +165,7 @@ typedef struct {
BroadwayInputBaseMsg base; BroadwayInputBaseMsg base;
guint32 width; guint32 width;
guint32 height; guint32 height;
guint32 scale;
} BroadwayInputScreenResizeNotify; } BroadwayInputScreenResizeNotify;
typedef struct { typedef struct {
@ -275,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 {

View File

@ -67,8 +67,7 @@ struct _BroadwayServer {
guint32 next_texture_id; guint32 next_texture_id;
GHashTable *textures; GHashTable *textures;
guint32 screen_width; guint32 screen_scale;
guint32 screen_height;
gint32 mouse_in_surface_id; gint32 mouse_in_surface_id;
int last_x, last_y; /* in root coords */ int last_x, last_y; /* in root coords */
@ -121,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;
@ -273,6 +271,7 @@ broadway_server_init (BroadwayServer *server)
root->visible = TRUE; root->visible = TRUE;
server->root = root; server->root = root;
server->screen_scale = 1;
g_hash_table_insert (server->surface_id_hash, g_hash_table_insert (server->surface_id_hash,
GINT_TO_POINTER (root->id), GINT_TO_POINTER (root->id),
@ -428,6 +427,7 @@ update_event_state (BroadwayServer *server,
case BROADWAY_EVENT_SCREEN_SIZE_CHANGED: case BROADWAY_EVENT_SCREEN_SIZE_CHANGED:
server->root->width = message->screen_resize_notify.width; server->root->width = message->screen_resize_notify.width;
server->root->height = message->screen_resize_notify.height; server->root->height = message->screen_resize_notify.height;
server->screen_scale = message->screen_resize_notify.scale;
break; break;
default: default:
@ -722,6 +722,7 @@ parse_input_message (BroadwayInput *input, const unsigned char *message)
case BROADWAY_EVENT_SCREEN_SIZE_CHANGED: case BROADWAY_EVENT_SCREEN_SIZE_CHANGED:
msg.screen_resize_notify.width = ntohl (*p++); msg.screen_resize_notify.width = ntohl (*p++);
msg.screen_resize_notify.height = ntohl (*p++); msg.screen_resize_notify.height = ntohl (*p++);
msg.screen_resize_notify.scale = ntohl (*p++);
break; break;
default: default:
@ -958,10 +959,12 @@ broadway_server_get_next_serial (BroadwayServer *server)
void void
broadway_server_get_screen_size (BroadwayServer *server, broadway_server_get_screen_size (BroadwayServer *server,
guint32 *width, guint32 *width,
guint32 *height) guint32 *height,
guint32 *scale)
{ {
*width = server->root->width; *width = server->root->width;
*height = server->root->height; *height = server->root->height;
*scale = server->screen_scale;
} }
static void static void
@ -2070,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;
@ -2080,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,
@ -2103,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);
@ -2144,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 */

View File

@ -64,7 +64,8 @@ void broadway_server_roundtrip (BroadwayServer *
guint32 tag); guint32 tag);
void broadway_server_get_screen_size (BroadwayServer *server, void broadway_server_get_screen_size (BroadwayServer *server,
guint32 *width, guint32 *width,
guint32 *height); guint32 *height,
guint32 *scale);
guint32 broadway_server_get_next_serial (BroadwayServer *server); guint32 broadway_server_get_next_serial (BroadwayServer *server);
guint32 broadway_server_get_last_seen_time (BroadwayServer *server); guint32 broadway_server_get_last_seen_time (BroadwayServer *server);
gboolean broadway_server_lookahead_event (BroadwayServer *server, gboolean broadway_server_lookahead_event (BroadwayServer *server,
@ -90,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,

View File

@ -274,6 +274,7 @@ function Texture(id, data) {
var image = new Image(); var image = new Image();
image.src = this.url; image.src = this.url;
this.image = image; this.image = image;
this.decoded = image.decode();
textures[id] = this; textures[id] = this;
} }
@ -297,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;
@ -997,12 +997,13 @@ function handleDisplayCommands(display_commands)
case DISPLAY_OP_CHANGE_TEXTURE: case DISPLAY_OP_CHANGE_TEXTURE:
var image = cmd[1]; var image = cmd[1];
var texture = cmd[2]; var texture = cmd[2];
// We need a new closure here to have a separate copy of "template" for each iteration... // We need a new closure here to have a separate copy of "texture" for each iteration in the onload callback...
function a_block(t) { var block = function(t) {
image.src = t.url; image.src = t.url;
// Unref blob url when loaded // Unref blob url when loaded
image.onload = function() { t.unref(); }; image.onload = function() { t.unref(); };
}(texture); };
block(texture);
break; break;
case DISPLAY_OP_CHANGE_TRANSFORM: case DISPLAY_OP_CHANGE_TRANSFORM:
var div = cmd[1]; var div = cmd[1];
@ -1037,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;
@ -1059,6 +1059,7 @@ function handleCommands(cmd, display_commands, new_textures, modified_trees)
doUngrab(); doUngrab();
surface = surfaces[id]; surface = surfaces[id];
if (surface.visible) { if (surface.visible) {
surface.visible = false;
display_commands.push([DISPLAY_OP_HIDE_SURFACE, surface.div]); display_commands.push([DISPLAY_OP_HIDE_SURFACE, surface.div]);
} }
break; break;
@ -1106,14 +1107,13 @@ 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]);
} }
if (has_size) { if (has_size) {
surface.width = cmd.get_16(); surface.width = cmd.get_16();
surface.height = cmd.get_16();; surface.height = cmd.get_16();
display_commands.push([DISPLAY_OP_RESIZE_NODE, surface.div, surface.width, surface.height]); display_commands.push([DISPLAY_OP_RESIZE_NODE, surface.div, surface.width, surface.height]);
} }
@ -1236,16 +1236,14 @@ function handleOutstanding()
outstandingDisplayCommands = display_commands; outstandingDisplayCommands = display_commands;
if (new_textures.length > 0) { if (new_textures.length > 0) {
var n_textures = new_textures.length; var decodes = [];
for (var i = 0; i < new_textures.length; i++) { for (var i = 0; i < new_textures.length; i++) {
var t = new_textures[i]; decodes.push(new_textures[i].decoded);
t.image.onload = function() {
n_textures -= 1;
if (n_textures == 0) {
handleOutstandingDisplayCommands();
}
};
} }
Promise.allSettled(decodes).then(
() => {
handleOutstandingDisplayCommands();
});
} else { } else {
handleOutstandingDisplayCommands(); handleOutstandingDisplayCommands();
} }
@ -3184,20 +3182,32 @@ function setupDocument(document)
} }
} }
function sendScreenSizeChanged() {
var w, h, s;
w = window.innerWidth;
h = window.innerHeight;
s = Math.round(window.devicePixelRatio);
sendInput (BROADWAY_EVENT_SCREEN_SIZE_CHANGED, [w, h, s]);
}
function start() function start()
{ {
setupDocument(document); setupDocument(document);
var w, h;
w = window.innerWidth;
h = window.innerHeight;
window.onresize = function(ev) { window.onresize = function(ev) {
var w, h; sendScreenSizeChanged();
w = window.innerWidth;
h = window.innerHeight;
sendInput (BROADWAY_EVENT_SCREEN_SIZE_CHANGED, [w, h]);
}; };
sendInput (BROADWAY_EVENT_SCREEN_SIZE_CHANGED, [w, h]); window.matchMedia('screen and (min-resolution: 2dppx)').
addListener(function(e) {
if (e.matches) {
/* devicePixelRatio >= 2 */
sendScreenSizeChanged();
} else {
/* devicePixelRatio < 2 */
sendScreenSizeChanged();
}
});
sendScreenSizeChanged();
} }
function connect() function connect()

View File

@ -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));
@ -513,7 +512,8 @@ incoming_client (GSocketService *service,
ev.base.time = broadway_server_get_last_seen_time (server); ev.base.time = broadway_server_get_last_seen_time (server);
broadway_server_get_screen_size (server, broadway_server_get_screen_size (server,
&ev.screen_resize_notify.width, &ev.screen_resize_notify.width,
&ev.screen_resize_notify.height); &ev.screen_resize_notify.height,
&ev.screen_resize_notify.scale);
broadway_events_got_input (&ev, broadway_events_got_input (&ev,
client->id); client->id);

View File

@ -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);

View File

@ -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,

View File

@ -63,6 +63,10 @@ gdk_broadway_display_init (GdkBroadwayDisplay *display)
NULL); NULL);
gdk_monitor_set_manufacturer (display->monitor, "browser"); gdk_monitor_set_manufacturer (display->monitor, "browser");
gdk_monitor_set_model (display->monitor, "0"); gdk_monitor_set_model (display->monitor, "0");
display->scale_factor = 1;
gdk_monitor_set_size (display->monitor, 1024, 768);
gdk_monitor_set_physical_size (display->monitor, 1024 * 25.4 / 96, 768 * 25.4 / 96);
gdk_monitor_set_scale_factor (display->monitor, 1);
} }
static void static void
@ -80,16 +84,21 @@ _gdk_broadway_display_size_changed (GdkDisplay *display,
{ {
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display); GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
GdkMonitor *monitor; GdkMonitor *monitor;
GdkRectangle size; GdkRectangle current_size;
GList *toplevels, *l; GList *toplevels, *l;
monitor = broadway_display->monitor; monitor = broadway_display->monitor;
gdk_monitor_get_geometry (monitor, &size); gdk_monitor_get_geometry (monitor, &current_size);
if (msg->width == size.width && msg->height == size.height) if (msg->width == current_size.width &&
msg->height == current_size.height &&
msg->scale == broadway_display->scale_factor)
return; return;
broadway_display->scale_factor = msg->scale;
gdk_monitor_set_size (monitor, msg->width, msg->height); gdk_monitor_set_size (monitor, msg->width, msg->height);
gdk_monitor_set_scale_factor (monitor, msg->scale);
gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96); gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96);
toplevels = broadway_display->toplevels; toplevels = broadway_display->toplevels;
@ -101,8 +110,7 @@ _gdk_broadway_display_size_changed (GdkDisplay *display,
gdk_broadway_surface_move_resize (GDK_SURFACE (toplevel), gdk_broadway_surface_move_resize (GDK_SURFACE (toplevel),
0, 0, 0, 0,
msg->width, msg->height); msg->width, msg->height);
} }}
}
static GdkDevice * static GdkDevice *
create_core_pointer (GdkDisplay *display) create_core_pointer (GdkDisplay *display)

View File

@ -50,10 +50,10 @@ struct _GdkBroadwayDisplay
GdkKeymap *keymap; GdkKeymap *keymap;
GdkBroadwayServer *server; GdkBroadwayServer *server;
gpointer move_resize_data; gpointer move_resize_data;
GdkMonitor *monitor; GdkMonitor *monitor;
int scale_factor;
GHashTable *texture_cache; GHashTable *texture_cache;

View File

@ -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);

View File

@ -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,

View File

@ -219,7 +219,10 @@ _gdk_broadway_display_create_surface (GdkDisplay *display,
GdkBroadwaySurface *impl; GdkBroadwaySurface *impl;
GType type; GType type;
frame_clock = _gdk_frame_clock_idle_new (); if (parent)
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
else
frame_clock = _gdk_frame_clock_idle_new ();
switch (surface_type) switch (surface_type)
{ {
@ -253,12 +256,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)
@ -266,6 +276,13 @@ _gdk_broadway_display_create_surface (GdkDisplay *display,
connect_frame_clock (surface); connect_frame_clock (surface);
/* We treat the real parent as a default transient for to get stacking right */
if (parent)
{
impl->transient_for = GDK_BROADWAY_SURFACE (parent)->id;
_gdk_broadway_server_surface_set_transient_for (broadway_display->server, impl->id, impl->transient_for);
}
return surface; return surface;
} }
@ -386,6 +403,54 @@ gdk_broadway_surface_hide (GdkSurface *surface)
_gdk_surface_clear_update_area (surface); _gdk_surface_clear_update_area (surface);
} }
static gint
gdk_broadway_surface_get_scale_factor (GdkSurface *surface)
{
GdkBroadwayDisplay *broadway_display;
if (GDK_SURFACE_DESTROYED (surface))
return 1;
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (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 static void
gdk_broadway_surface_move_resize_internal (GdkSurface *surface, gdk_broadway_surface_move_resize_internal (GdkSurface *surface,
gboolean with_move, gboolean with_move,
@ -398,6 +463,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));
@ -424,17 +503,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)
{ {
@ -488,9 +563,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)
@ -606,6 +680,10 @@ gdk_broadway_surface_set_transient_for (GdkSurface *surface,
impl = GDK_BROADWAY_SURFACE (surface); impl = GDK_BROADWAY_SURFACE (surface);
/* We treat the real parent as a default transient for to get stacking right */
if (parent == NULL)
parent = surface->parent;
parent_id = 0; parent_id = 0;
if (parent) if (parent)
parent_id = GDK_BROADWAY_SURFACE (parent)->id; parent_id = GDK_BROADWAY_SURFACE (parent)->id;
@ -645,10 +723,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
@ -749,25 +831,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
@ -1249,6 +1312,7 @@ gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass)
impl_class->begin_move_drag = gdk_broadway_surface_begin_move_drag; impl_class->begin_move_drag = gdk_broadway_surface_begin_move_drag;
impl_class->destroy_notify = gdk_broadway_surface_destroy_notify; impl_class->destroy_notify = gdk_broadway_surface_destroy_notify;
impl_class->drag_begin = _gdk_broadway_surface_drag_begin; impl_class->drag_begin = _gdk_broadway_surface_drag_begin;
impl_class->get_scale_factor = gdk_broadway_surface_get_scale_factor;
} }
#define LAST_PROP 1 #define LAST_PROP 1

View File

@ -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

View File

@ -477,6 +477,7 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
float offset_y) float offset_y)
{ {
GdkDisplay *display = gdk_surface_get_display (gsk_renderer_get_surface (renderer)); GdkDisplay *display = gdk_surface_get_display (gsk_renderer_get_surface (renderer));
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
GskBroadwayRenderer *self = GSK_BROADWAY_RENDERER (renderer); GskBroadwayRenderer *self = GSK_BROADWAY_RENDERER (renderer);
GArray *nodes = self->nodes; GArray *nodes = self->nodes;
@ -753,9 +754,11 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
int y = floorf (node->bounds.origin.y); int y = floorf (node->bounds.origin.y);
int width = ceil (node->bounds.origin.x + node->bounds.size.width) - x; int width = ceil (node->bounds.origin.x + node->bounds.size.width) - x;
int height = ceil (node->bounds.origin.y + node->bounds.size.height) - y; int height = ceil (node->bounds.origin.y + node->bounds.size.height) - y;
int scale = broadway_display->scale_factor;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width * scale, height * scale);
cr = cairo_create (surface); cr = cairo_create (surface);
cairo_scale (cr, scale, scale);
cairo_translate (cr, -x, -y); cairo_translate (cr, -x, -y);
gsk_render_node_draw (node, cr); gsk_render_node_draw (node, cr);
cairo_destroy (cr); cairo_destroy (cr);
@ -766,8 +769,8 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
texture_id = gdk_broadway_display_ensure_texture (display, texture); texture_id = gdk_broadway_display_ensure_texture (display, texture);
add_float (nodes, x - offset_x); add_float (nodes, x - offset_x);
add_float (nodes, y - offset_y); add_float (nodes, y - offset_y);
add_float (nodes, gdk_texture_get_width (texture)); add_float (nodes, width);
add_float (nodes, gdk_texture_get_height (texture)); add_float (nodes, height);
add_uint32 (nodes, texture_id); add_uint32 (nodes, texture_id);
} }
} }