With this we always roundtrip position change to the webbrowser.
This avoids conflicts when things change from both directions (app and user).
Also, we fake configure evens when there is no web client to ensure
apps get the events.
typedef struct {
BroadwayRequestBase base;
guint32 id;
+ guint32 with_move;
gint32 x;
gint32 y;
guint32 width;
update_event_state (BroadwayServer *server,
BroadwayInputMsg *message)
{
+ BroadwayWindow *window;
+
switch (message->base.type) {
case BROADWAY_EVENT_ENTER:
server->last_x = message->pointer.root_x;
case BROADWAY_EVENT_UNGRAB_NOTIFY:
break;
case BROADWAY_EVENT_CONFIGURE_NOTIFY:
+ window = g_hash_table_lookup (server->id_ht,
+ GINT_TO_POINTER (message->configure_notify.id));
+ if (window != NULL)
+ {
+ window->x = message->configure_notify.x;
+ window->y = message->configure_notify.y;
+ }
break;
case BROADWAY_EVENT_DELETE_NOTIFY:
break;
message->base.type == BROADWAY_EVENT_UNGRAB_NOTIFY;
}
+static void
+process_input_message (BroadwayServer *server,
+ BroadwayInputMsg *message)
+{
+ gint32 client;
+
+ update_event_state (server, message);
+ client = -1;
+ if (is_pointer_event (message) &&
+ server->pointer_grab_window_id != -1)
+ client = server->pointer_grab_client_id;
+
+ broadway_events_got_input (message, client);
+}
+
static void
process_input_messages (BroadwayServer *server)
{
BroadwayInputMsg *message;
- gint32 client;
while (server->input_messages)
{
message->base.serial = server->saved_serial - 1;
}
- update_event_state (server, message);
- client = -1;
- if (is_pointer_event (message) &&
- server->pointer_grab_window_id != -1)
- client = server->pointer_grab_client_id;
-
- broadway_events_got_input (message, client);
+ process_input_message (server, message);
g_free (message);
}
}
+static void
+fake_configure_notify (BroadwayServer *server,
+ BroadwayWindow *window)
+{
+ BroadwayInputMsg ev = { {0} };
+
+ ev.base.type = BROADWAY_EVENT_CONFIGURE_NOTIFY;
+ ev.base.serial = server->saved_serial - 1;
+ ev.base.time = server->last_seen_time;
+ ev.configure_notify.id = window->id;
+ ev.configure_notify.x = window->x;
+ ev.configure_notify.y = window->y;
+ ev.configure_notify.width = window->width;
+ ev.configure_notify.height = window->height;
+
+ process_input_message (server, &ev);
+}
+
static char *
parse_pointer_data (char *p, BroadwayInputPointerMsg *data)
{
char *p;
gint64 time_;
+ memset (&msg, 0, sizeof (msg));
+
p = (char *)message;
msg.base.type = *p++;
msg.base.serial = (guint32)strtol (p, &p, 10);
gboolean
broadway_server_window_move_resize (BroadwayServer *server,
gint id,
+ gboolean with_move,
int x,
int y,
int width,
int height)
{
BroadwayWindow *window;
- gboolean with_move, with_resize;
+ gboolean with_resize;
gboolean sent = FALSE;
cairo_t *cr;
if (window == NULL)
return FALSE;
- with_move = x != window->x || y != window->y;
with_resize = width != window->width || height != window->height;
- window->x = x;
- window->y = y;
window->width = width;
window->height = height;
{
broadway_output_move_resize_surface (server->output,
window->id,
- with_move, window->x, window->y,
+ with_move, x, y,
with_resize, window->width, window->height);
sent = TRUE;
}
+ else
+ {
+ if (with_move)
+ {
+ window->x = x;
+ window->y = y;
+ }
+
+ fake_configure_notify (server, window);
+ }
return sent;
}
window->id = server->id_counter++;
window->x = x;
window->y = y;
+ if (x == 0 && y == 0 && !is_temp)
+ {
+ /* TODO: Better way to know if we should pick default pos */
+ window->x = 100;
+ window->y = 100;
+ }
window->width = width;
window->height = height;
window->is_temp = is_temp;
window->width,
window->height,
window->is_temp);
+ else
+ fake_configure_notify (server, window);
return window->id;
}
cairo_surface_t *surface);
gboolean broadway_server_window_move_resize (BroadwayServer *server,
gint id,
+ gboolean with_move,
int x,
int y,
int width,
toplevelElement = frame;
document.body.appendChild(frame);
-
- surface.x = 100 + positionIndex * 10;
- surface.y = 100 + positionIndex * 10;
- positionIndex = (positionIndex + 1) % 20;
}
surface.toplevelElement = toplevelElement;
}
break;
case BROADWAY_REQUEST_MOVE_RESIZE:
- if (!broadway_server_window_move_resize (server,
- request->move_resize.id,
- request->move_resize.x,
- request->move_resize.y,
- request->move_resize.width,
- request->move_resize.height))
- {
- /* TODO: Send configure request */
- }
+ broadway_server_window_move_resize (server,
+ request->move_resize.id,
+ request->move_resize.with_move,
+ request->move_resize.x,
+ request->move_resize.y,
+ request->move_resize.width,
+ request->move_resize.height);
break;
case BROADWAY_REQUEST_GRAB_POINTER:
reply_grab_pointer.status =
server->incomming = g_list_append (server->incomming, reply);
}
-
+
if (p < end)
memmove (server->recv_buffer, p, end - p);
server->recv_buffer_size = end - p;
g_source_remove (server->process_input_idle);
server->process_input_idle = 0;
}
-
+
while (server->incomming)
{
reply = server->incomming->data;
memcpy (msg.name, data->name, 34);
msg.width = cairo_image_surface_get_width (surface);
msg.height = cairo_image_surface_get_height (surface);
-
- gdk_broadway_server_send_message (server, msg,
+
+ gdk_broadway_server_send_message (server, msg,
BROADWAY_REQUEST_UPDATE);
}
gboolean
_gdk_broadway_server_window_move_resize (GdkBroadwayServer *server,
gint id,
+ gboolean with_move,
int x,
int y,
int width,
BroadwayRequestMoveResize msg;
msg.id = id;
+ msg.with_move = with_move;
msg.x = x;
msg.y = y;
msg.width = width;
g_assert (reply->base.type == BROADWAY_REPLY_GRAB_POINTER);
status = reply->grab_pointer.status;
-
+
g_free (reply);
return status;
g_assert (reply->base.type == BROADWAY_REPLY_UNGRAB_POINTER);
status = reply->ungrab_pointer.status;
-
+
g_free (reply);
return status;
cairo_surface_t *surface);
gboolean _gdk_broadway_server_window_move_resize (GdkBroadwayServer *server,
gint id,
+ gboolean with_move,
int x,
int y,
int width,
{
GdkWindowImplBroadway *impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
GdkBroadwayDisplay *broadway_display;
- gboolean changed, size_changed;;
+ gboolean size_changed;
- size_changed = changed = FALSE;
+ size_changed = FALSE;
broadway_display = GDK_BROADWAY_DISPLAY (gdk_window_get_display (window));
- if (with_move)
- {
- changed = TRUE;
- window->x = x;
- window->y = y;
- }
if (width > 0 || height > 0)
{
if (width != window->width ||
height != window->height)
{
- changed = TRUE;
size_changed = TRUE;
/* Resize clears the content */
}
}
- if (changed)
- {
- GdkEvent *event;
- GList *node;
-
- if (_gdk_broadway_server_window_move_resize (broadway_display->server,
- impl->id,
- window->x, window->y,
- window->width, window->height))
- {
- queue_dirty_flush (broadway_display);
- if (size_changed)
- window->resize_count++;
- }
-
- event = gdk_event_new (GDK_CONFIGURE);
- event->configure.window = g_object_ref (window);
- event->configure.x = window->x;
- event->configure.y = window->y;
- event->configure.width = window->width;
- event->configure.height = window->height;
-
- gdk_event_set_device (event, GDK_DISPLAY_OBJECT (broadway_display)->core_pointer);
-
- node = _gdk_event_queue_append (GDK_DISPLAY_OBJECT (broadway_display), event);
- _gdk_windowing_got_event (GDK_DISPLAY_OBJECT (broadway_display), node, event,
- _gdk_display_get_next_serial (GDK_DISPLAY (broadway_display)) - 1);
- }
+ _gdk_broadway_server_window_move_resize (broadway_display->server,
+ impl->id,
+ with_move,
+ x, y,
+ window->width, window->height);
+ queue_dirty_flush (broadway_display);
+ if (size_changed)
+ window->resize_count++;
}
static gboolean