]> khamidou — GitHub mirrors - electron.git/commitdiff
gtk: Do not count menubar in work area size on Unity.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 27 Mar 2014 09:54:07 +0000 (17:54 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 27 Mar 2014 09:55:28 +0000 (17:55 +0800)
atom/common/api/atom_api_screen.cc

index f5dc4388d552059ad059e4cc4cb19a9d1727abcb..ccc1edf4e9e92f37a3166eae584e8064ff9ec087 100644 (file)
@@ -11,6 +11,8 @@
 
 #if defined(TOOLKIT_GTK)
 #include "base/command_line.h"
+#include "base/environment.h"
+#include "base/nix/xdg_util.h"
 #include "ui/gfx/gtk_util.h"
 #endif
 
@@ -25,7 +27,23 @@ namespace api {
 
 namespace {
 
-v8::Handle<v8::Object> DisplayToV8Value(const gfx::Display& display) {
+gfx::Display AdaptToWindowManager(const gfx::Display& display) {
+  gfx::Display changed(display);
+#if defined(TOOLKIT_GTK)
+  scoped_ptr<base::Environment> env(base::Environment::Create());
+  base::nix::DesktopEnvironment de(base::nix::GetDesktopEnvironment(env.get()));
+  if (de == base::nix::DESKTOP_ENVIRONMENT_UNITY) {
+    // Unity's 24px global menu bar should not be included in the work area.
+    gfx::Rect rect(changed.work_area());
+    rect.set_height(rect.height() - 24);
+    changed.set_work_area(rect);
+  }
+#endif
+  return changed;
+}
+
+v8::Handle<v8::Object> DisplayToV8Value(const gfx::Display& raw) {
+  gfx::Display display(AdaptToWindowManager(raw));
   v8::Handle<v8::Object> obj = v8::Object::New();
   obj->Set(ToV8Value("bounds"), ToV8Value(display.bounds()));
   obj->Set(ToV8Value("workArea"), ToV8Value(display.work_area()));