forked from AuroraMiddleware/gtk
[broadway] Combine window move and resize into one op
This way we avoid sending a configure event for the inbetween state if we're resizeing and moving at the same time.
This commit is contained in:
parent
ca49ec2c8c
commit
f4bef2c720
@ -186,7 +186,7 @@ demo2 (BroadwayOutput *output)
|
||||
broadway_output_put_rgba (output, 0, 0, 0, 800, 600, 800*4,
|
||||
cairo_image_surface_get_data(old_surface));
|
||||
}
|
||||
broadway_output_move_surface (output, 0, 100 + i, 100 + i);
|
||||
broadway_output_move_resize_surface (output, 0, 1, 100 + i, 100 + i, 0, 0, 0);
|
||||
|
||||
rects[0].x = 500;
|
||||
rects[0].y = 0;
|
||||
|
@ -747,38 +747,42 @@ broadway_output_destroy_surface(BroadwayOutput *output, int id)
|
||||
broadway_output_write (output, buf, sizeof (buf));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
broadway_output_move_surface(BroadwayOutput *output, int id, int x, int y)
|
||||
broadway_output_move_resize_surface (BroadwayOutput *output,
|
||||
int id,
|
||||
gboolean has_pos,
|
||||
int x,
|
||||
int y,
|
||||
gboolean has_size,
|
||||
int w,
|
||||
int h)
|
||||
{
|
||||
char buf[HEADER_LEN + 9];
|
||||
char buf[HEADER_LEN+3+1+6+6];
|
||||
int p;
|
||||
int val;
|
||||
|
||||
if (!has_pos && !has_size)
|
||||
return;
|
||||
|
||||
p = write_header (output, buf, 'm');
|
||||
|
||||
val = (!!has_pos) | ((!!has_size) << 1);
|
||||
append_uint16 (id, buf, &p);
|
||||
append_uint16 (x, buf, &p);
|
||||
append_uint16 (y, buf, &p);
|
||||
buf[p++] = val + '0';
|
||||
if (has_pos)
|
||||
{
|
||||
append_uint16 (x, buf, &p);
|
||||
append_uint16 (y, buf, &p);
|
||||
}
|
||||
if (has_size)
|
||||
{
|
||||
append_uint16 (w, buf, &p);
|
||||
append_uint16 (h, buf, &p);
|
||||
}
|
||||
assert (p <= sizeof (buf));
|
||||
|
||||
assert (p == sizeof (buf));
|
||||
|
||||
broadway_output_write (output, buf, sizeof (buf));
|
||||
}
|
||||
|
||||
void
|
||||
broadway_output_resize_surface(BroadwayOutput *output, int id, int w, int h)
|
||||
{
|
||||
char buf[HEADER_LEN + 9];
|
||||
int p;
|
||||
|
||||
p = write_header (output, buf, 'r');
|
||||
|
||||
append_uint16 (id, buf, &p);
|
||||
append_uint16 (w, buf, &p);
|
||||
append_uint16 (h, buf, &p);
|
||||
|
||||
assert (p == sizeof (buf));
|
||||
|
||||
broadway_output_write (output, buf, sizeof (buf));
|
||||
broadway_output_write (output, buf, p);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -26,14 +26,14 @@ void broadway_output_hide_surface (BroadwayOutput *output,
|
||||
int id);
|
||||
void broadway_output_destroy_surface (BroadwayOutput *output,
|
||||
int id);
|
||||
void broadway_output_move_surface (BroadwayOutput *output,
|
||||
int id,
|
||||
int x,
|
||||
int y);
|
||||
void broadway_output_resize_surface (BroadwayOutput *output,
|
||||
int id,
|
||||
int w,
|
||||
int h);
|
||||
void broadway_output_move_resize_surface (BroadwayOutput *output,
|
||||
int id,
|
||||
gboolean has_pos,
|
||||
int x,
|
||||
int y,
|
||||
gboolean has_size,
|
||||
int w,
|
||||
int h);
|
||||
void broadway_output_set_transient_for (BroadwayOutput *output,
|
||||
int id,
|
||||
int parent_id);
|
||||
|
@ -638,12 +638,21 @@ function cmdDeleteSurface(id)
|
||||
delete surfaces[id];
|
||||
}
|
||||
|
||||
function cmdMoveSurface(id, x, y)
|
||||
function cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h)
|
||||
{
|
||||
var surface = surfaces[id];
|
||||
surface.positioned = true;
|
||||
surface.x = x;
|
||||
surface.y = y;
|
||||
if (has_pos) {
|
||||
surface.positioned = true;
|
||||
surface.x = x;
|
||||
surface.y = y;
|
||||
}
|
||||
if (has_size) {
|
||||
surface.width = w;
|
||||
surface.height = h;
|
||||
}
|
||||
|
||||
/* Flush any outstanding draw ops before (possibly) changing size */
|
||||
flushSurface(surface);
|
||||
|
||||
if (surface.visible) {
|
||||
if (surface.window) {
|
||||
@ -651,27 +660,35 @@ function cmdMoveSurface(id, x, y)
|
||||
* However this isn't *strictly* invalid, as any WM could have done whatever it
|
||||
* wanted with the positioning of the window.
|
||||
*/
|
||||
surface.window.moveTo(surface.x, surface.y);
|
||||
if (has_pos)
|
||||
surface.window.moveTo(surface.x, surface.y);
|
||||
if (has_size)
|
||||
resizeBrowserWindow(surface.window, w, h);
|
||||
} else {
|
||||
var xOffset = surface.x;
|
||||
var yOffset = surface.y;
|
||||
if (has_size)
|
||||
resizeCanvas(surface.canvas, w, h);
|
||||
|
||||
var transientToplevel = getTransientToplevel(surface);
|
||||
if (transientToplevel) {
|
||||
xOffset = surface.x - transientToplevel.x;
|
||||
yOffset = surface.y - transientToplevel.y;
|
||||
if (has_pos) {
|
||||
var xOffset = surface.x;
|
||||
var yOffset = surface.y;
|
||||
|
||||
var transientToplevel = getTransientToplevel(surface);
|
||||
if (transientToplevel) {
|
||||
xOffset = surface.x - transientToplevel.x;
|
||||
yOffset = surface.y - transientToplevel.y;
|
||||
}
|
||||
|
||||
var element = surface.canvas;
|
||||
if (surface.frame) {
|
||||
element = surface.frame;
|
||||
var offset = getFrameOffset(surface);
|
||||
xOffset -= offset.x;
|
||||
yOffset -= offset.y;
|
||||
}
|
||||
|
||||
element.style["left"] = xOffset + "px";
|
||||
element.style["top"] = yOffset + "px";
|
||||
}
|
||||
|
||||
var element = surface.canvas;
|
||||
if (surface.frame) {
|
||||
element = surface.frame;
|
||||
var offset = getFrameOffset(surface);
|
||||
xOffset -= offset.x;
|
||||
yOffset -= offset.y;
|
||||
}
|
||||
|
||||
element.style["left"] = xOffset + "px";
|
||||
element.style["top"] = yOffset + "px";
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,26 +699,6 @@ function cmdMoveSurface(id, x, y)
|
||||
}
|
||||
}
|
||||
|
||||
function cmdResizeSurface(id, w, h)
|
||||
{
|
||||
var surface = surfaces[id];
|
||||
|
||||
surface.width = w;
|
||||
surface.height = h;
|
||||
|
||||
/* Flush any outstanding draw ops before changing size */
|
||||
flushSurface(surface);
|
||||
|
||||
resizeCanvas(surface.canvas, w, h);
|
||||
|
||||
if (surface.window) {
|
||||
resizeBrowserWindow(surface.window, w, h);
|
||||
updateBrowserWindowGeometry(surface.window, true);
|
||||
} else {
|
||||
sendConfigureNotify(surface);
|
||||
}
|
||||
}
|
||||
|
||||
function cmdFlushSurface(id)
|
||||
{
|
||||
flushSurface(surfaces[id]);
|
||||
@ -776,21 +773,22 @@ function handleCommands(cmdObj)
|
||||
case 'm': // Move a surface
|
||||
id = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
x = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
y = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
cmdMoveSurface(id, x, y);
|
||||
break;
|
||||
|
||||
case 'r': // Resize a surface
|
||||
id = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
w = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
h = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
cmdResizeSurface(id, w, h);
|
||||
var ops = cmd.charCodeAt(i++) - 48;
|
||||
var has_pos = ops & 1;
|
||||
if (has_pos) {
|
||||
x = base64_16s(cmd, i);
|
||||
i = i + 3;
|
||||
y = base64_16s(cmd, i);
|
||||
i = i + 3;
|
||||
}
|
||||
var has_size = ops & 2;
|
||||
if (has_size) {
|
||||
w = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
h = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
}
|
||||
cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h);
|
||||
break;
|
||||
|
||||
case 'i': // Put image data surface
|
||||
|
@ -598,6 +598,7 @@ gdk_window_broadway_move_resize (GdkWindow *window,
|
||||
GdkWindowImplBroadway *impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
gboolean changed;
|
||||
gboolean with_resize;
|
||||
|
||||
changed = FALSE;
|
||||
|
||||
@ -607,17 +608,12 @@ gdk_window_broadway_move_resize (GdkWindow *window,
|
||||
changed = TRUE;
|
||||
window->x = x;
|
||||
window->y = y;
|
||||
if (broadway_display->output != NULL)
|
||||
{
|
||||
broadway_output_move_surface (broadway_display->output,
|
||||
impl->id, x, y);
|
||||
queue_dirty_flush (broadway_display);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
with_resize = FALSE;
|
||||
if (width > 0 || height > 0)
|
||||
{
|
||||
with_resize = TRUE;
|
||||
if (width < 1)
|
||||
width = 1;
|
||||
|
||||
@ -633,13 +629,6 @@ gdk_window_broadway_move_resize (GdkWindow *window,
|
||||
impl->dirty = TRUE;
|
||||
impl->last_synced = FALSE;
|
||||
|
||||
if (broadway_display->output != NULL)
|
||||
{
|
||||
broadway_output_resize_surface (broadway_display->output,
|
||||
impl->id, width, height);
|
||||
queue_dirty_flush (broadway_display);
|
||||
}
|
||||
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
_gdk_broadway_window_resize_surface (window);
|
||||
@ -651,6 +640,15 @@ gdk_window_broadway_move_resize (GdkWindow *window,
|
||||
GdkEvent *event;
|
||||
GList *node;
|
||||
|
||||
if (broadway_display->output != NULL)
|
||||
{
|
||||
broadway_output_move_resize_surface (broadway_display->output,
|
||||
impl->id,
|
||||
with_move, window->x, window->y,
|
||||
with_resize, window->width, window->height);
|
||||
queue_dirty_flush (broadway_display);
|
||||
}
|
||||
|
||||
event = gdk_event_new (GDK_CONFIGURE);
|
||||
event->configure.window = g_object_ref (window);
|
||||
event->configure.x = window->x;
|
||||
|
Loading…
Reference in New Issue
Block a user