[broadway] Handle screen size

Without this menu placement doesn't work right
This commit is contained in:
Alexander Larsson 2011-04-07 15:10:39 +02:00
parent 8c20b476df
commit dd07f534f4
6 changed files with 61 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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