mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
[broadway] Handle screen size
Without this menu placement doesn't work right
This commit is contained in:
parent
8c20b476df
commit
dd07f534f4
@ -282,14 +282,14 @@ function browserWindowClosed(win) {
|
||||
|
||||
sendInput ("W", [surface.id]);
|
||||
for (id in surfaces) {
|
||||
if (surfaces[id].transientToplevel != null && surfaces[id].transientToplevel == surface) {
|
||||
if (surfaces[id].transientToplevel != null &&
|
||||
surfaces[id].transientToplevel == surface) {
|
||||
var childSurface = surfaces[id];
|
||||
sendInput ("W", [childSurface.id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function registerWindow(win)
|
||||
{
|
||||
toplevelWindows.push(win);
|
||||
@ -926,6 +926,22 @@ function connect()
|
||||
var ws = new WebSocket(loc, "broadway");
|
||||
ws.onopen = function() {
|
||||
inputSocket = ws;
|
||||
|
||||
var w, h;
|
||||
if (useToplevelWindows) {
|
||||
w = window.screen.width;
|
||||
h = window.screen.height;
|
||||
} else {
|
||||
w = window.innerWidth;
|
||||
h = window.innerHeight;
|
||||
win.onresize = function(ev) {
|
||||
var w, h;
|
||||
w = window.innerWidth;
|
||||
h = window.innerHeight;
|
||||
sendInput ("d", [w, h]);
|
||||
};
|
||||
}
|
||||
sendInput ("d", [w, h]);
|
||||
};
|
||||
ws.onclose = function() {
|
||||
inputSocket = null;
|
||||
|
@ -265,6 +265,12 @@ parse_input_message (BroadwayInput *input, const char *message)
|
||||
msg.delete_notify.id = strtol(p, &p, 10);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
msg.screen_resize_notify.width = strtol (p, &p, 10);
|
||||
p++; /* Skip , */
|
||||
msg.screen_resize_notify.height = strtol (p, &p, 10);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_printerr ("Unknown input command %s\n", message);
|
||||
break;
|
||||
|
@ -96,6 +96,12 @@ typedef struct {
|
||||
int height;
|
||||
} BroadwayInputConfigureNotify;
|
||||
|
||||
typedef struct {
|
||||
BroadwayInputBaseMsg base;
|
||||
int width;
|
||||
int height;
|
||||
} BroadwayInputScreenResizeNotify;
|
||||
|
||||
typedef struct {
|
||||
BroadwayInputBaseMsg base;
|
||||
int id;
|
||||
@ -111,6 +117,7 @@ typedef union {
|
||||
BroadwayInputGrabReply grab_reply;
|
||||
BroadwayInputConfigureNotify configure_notify;
|
||||
BroadwayInputDeleteNotify delete_notify;
|
||||
BroadwayInputScreenResizeNotify screen_resize_notify;
|
||||
} BroadwayInputMsg;
|
||||
|
||||
struct _GdkBroadwayDisplay
|
||||
|
@ -93,6 +93,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
BroadwayInputMsg *message)
|
||||
{
|
||||
GdkBroadwayDisplay *display_broadway = GDK_BROADWAY_DISPLAY (display);
|
||||
GdkScreen *screen;
|
||||
GdkWindow *window;
|
||||
GdkEvent *event = NULL;
|
||||
GList *node;
|
||||
@ -308,6 +309,16 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
screen = gdk_display_get_default_screen (display);
|
||||
window = gdk_screen_get_root_window (screen);
|
||||
window->width = message->screen_resize_notify.width;
|
||||
window->height = message->screen_resize_notify.height;
|
||||
|
||||
_gdk_window_update_size (window);
|
||||
_gdk_broadway_screen_size_changed (screen, &message->screen_resize_notify);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_printerr ("Unknown input command %c\n", message->base.type);
|
||||
break;
|
||||
|
@ -119,6 +119,8 @@ void _gdk_broadway_screen_query_visual_types (GdkScreen * screen,
|
||||
GdkVisualType **visual_types,
|
||||
gint *count);
|
||||
GList *_gdk_broadway_screen_list_visuals (GdkScreen *screen);
|
||||
void _gdk_broadway_screen_size_changed (GdkScreen *screen,
|
||||
BroadwayInputScreenResizeNotify *msg);
|
||||
|
||||
void _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
BroadwayInputMsg *message);
|
||||
|
@ -102,6 +102,23 @@ gdk_broadway_screen_get_root_window (GdkScreen *screen)
|
||||
return GDK_BROADWAY_SCREEN (screen)->root_window;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_broadway_screen_size_changed (GdkScreen *screen, BroadwayInputScreenResizeNotify *msg)
|
||||
{
|
||||
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
|
||||
gint width, height;
|
||||
|
||||
width = gdk_screen_get_width (screen);
|
||||
height = gdk_screen_get_height (screen);
|
||||
|
||||
broadway_screen->width = msg->width;
|
||||
broadway_screen->height = msg->height;
|
||||
|
||||
if (width != gdk_screen_get_width (screen) ||
|
||||
height != gdk_screen_get_height (screen))
|
||||
g_signal_emit_by_name (screen, "size-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_screen_dispose (GObject *object)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user