Index: mojo/services/native_viewport/native_viewport_x11.cc |
diff --git a/mojo/services/native_viewport/native_viewport_x11.cc b/mojo/services/native_viewport/native_viewport_x11.cc |
index d47e16afe191664f21fd689634cfb5524a68eaf8..ad9d68a6414b61b549b579278c76bb31af375362 100644 |
--- a/mojo/services/native_viewport/native_viewport_x11.cc |
+++ b/mojo/services/native_viewport/native_viewport_x11.cc |
@@ -7,7 +7,9 @@ |
#include <X11/Xlib.h> |
#include <X11/Xutil.h> |
+#include "base/command_line.h" |
#include "base/message_loop/message_loop.h" |
+#include "mojo/shell/switches.h" |
#include "ui/events/event.h" |
#include "ui/events/event_utils.h" |
#include "ui/events/platform/platform_event_dispatcher.h" |
@@ -47,6 +49,37 @@ class NativeViewportX11 : public NativeViewport, |
} |
private: |
+ void InitWindowManagerState(XDisplay* display) { |
+ // TODO(hansmuller): should not be processing the shell's commad line here. |
jamesr
2014/07/02 18:12:49
I think it'd be better to split this part into a s
|
+ CommandLine* cmd = CommandLine::ForCurrentProcess(); |
+ bool fullscreen = cmd->HasSwitch("start-fullscreen"); |
+ bool maximized = cmd->HasSwitch("start-maximized"); |
+ if (!(fullscreen || maximized)) |
+ return; |
+ |
+ XEvent xevent; |
+ memset(&xevent, 0, sizeof(xevent)); |
+ xevent.type = ClientMessage; |
+ xevent.xclient.window = window_; |
+ xevent.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", False); |
+ xevent.xclient.format = 32; |
+ xevent.xclient.data.l[0] = 1; // NET_WM_STATE_ADD |
+ |
+ if (maximized) { |
+ xevent.xclient.data.l[1] = |
+ XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); |
+ xevent.xclient.data.l[2] = |
+ XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False); |
+ } else { |
+ xevent.xclient.data.l[1] = |
+ XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False); |
+ } |
+ |
+ // TODO(hansmuller): rationalize the value of event_mask; |
+ long event_mask = SubstructureNotifyMask | SubstructureRedirectMask; |
+ XSendEvent(display, DefaultRootWindow(display), False, event_mask, &xevent); |
+ } |
+ |
// Overridden from NativeViewport: |
virtual void Init(const gfx::Rect& bounds) OVERRIDE { |
XDisplay* display = gfx::GetXDisplay(); |
@@ -84,6 +117,8 @@ class NativeViewportX11 : public NativeViewport, |
// the desktop environment. |
XSetWMProperties(display, window_, NULL, NULL, NULL, 0, NULL, NULL, NULL); |
+ InitWindowManagerState(display); |
+ |
// TODO(aa): Setup xinput2 events. |
// See desktop_aura/desktop_window_tree_host_x11.cc. |
@@ -133,6 +168,7 @@ class NativeViewportX11 : public NativeViewport, |
case ButtonPress: |
case ButtonRelease: |
case MotionNotify: |
+ case ConfigureNotify: |
return true; |
case ClientMessage: |
return event->xclient.message_type == atom_wm_protocols_; |
@@ -159,6 +195,9 @@ class NativeViewportX11 : public NativeViewport, |
ui::MouseEvent mouse_event(event); |
delegate_->OnEvent(&mouse_event); |
} |
+ } else if (event->type == ConfigureNotify) { |
jamesr
2014/07/02 18:12:49
nit: i think you have two spaces between 'else' an
|
+ bounds_ = gfx::Rect(event->xconfigure.width, event->xconfigure.height); |
+ delegate_->OnBoundsChanged(bounds_); |
} |
return ui::POST_DISPATCH_NONE; |
} |