summaryrefslogtreecommitdiffstats
path: root/views/window
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 21:04:17 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 21:04:17 +0000
commitefc6544b43973ee7dfed1f7e56986982e42ebee0 (patch)
treebfc655f45240b2d7da4148983123e073dff04ebe /views/window
parentc3bb07a6e81588caaf2d5efced692b2166a30161 (diff)
downloadchromium_src-efc6544b43973ee7dfed1f7e56986982e42ebee0.zip
chromium_src-efc6544b43973ee7dfed1f7e56986982e42ebee0.tar.gz
chromium_src-efc6544b43973ee7dfed1f7e56986982e42ebee0.tar.bz2
Resurrect Scott's WindowGtk changes.
http://crbug.com/11387 Review URL: http://codereview.chromium.org/115143 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15678 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window')
-rw-r--r--views/window/client_view.cc3
-rw-r--r--views/window/custom_frame_view.cc11
-rw-r--r--views/window/hit_test.h41
-rw-r--r--views/window/non_client_view.cc9
-rw-r--r--views/window/window_delegate.h1
-rw-r--r--views/window/window_gtk.cc199
-rw-r--r--views/window/window_gtk.h92
7 files changed, 355 insertions, 1 deletions
diff --git a/views/window/client_view.cc b/views/window/client_view.cc
index 5b5afb1..e5bfe32 100644
--- a/views/window/client_view.cc
+++ b/views/window/client_view.cc
@@ -4,6 +4,9 @@
#include "base/logging.h"
#include "views/window/client_view.h"
+#if defined(OS_LINUX)
+#include "chrome/views/window/hit_test.h"
+#endif
#include "views/window/window.h"
#include "views/window/window_delegate.h"
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index cf8173f..8639340 100644
--- a/views/window/custom_frame_view.cc
+++ b/views/window/custom_frame_view.cc
@@ -8,10 +8,15 @@
#include "app/gfx/chrome_font.h"
#include "app/gfx/path.h"
#include "app/resource_bundle.h"
+#if defined(OS_WIN)
#include "base/win_util.h"
#include "chrome/common/win_util.h"
+#endif
#include "grit/theme_resources.h"
#include "views/window/client_view.h"
+#if defined(OS_LINUX)
+#include "views/window/hit_test.h"
+#endif
#include "views/window/window_delegate.h"
namespace views {
@@ -686,8 +691,12 @@ void CustomFrameView::InitClass() {
active_resources_ = new ActiveWindowResources;
inactive_resources_ = new InactiveWindowResources;
+#if defined(OS_WIN)
title_font_ = new ChromeFont(win_util::GetWindowTitleFont());
-
+#elif defined(OS_LINUX)
+ // TODO: need to resolve what font this is.
+ title_font_ = new ChromeFont();
+#endif
initialized = true;
}
}
diff --git a/views/window/hit_test.h b/views/window/hit_test.h
new file mode 100644
index 0000000..35e88ae
--- /dev/null
+++ b/views/window/hit_test.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef VIEWS_WINDOW_HIT_TEST_H_
+#define VIEWS_WINDOW_HIT_TEST_H_
+
+// Defines the same symbolic names used by the WM_NCHITTEST Notification under
+// win32 (the integer values are not guaranteed to be equivalent). We do this
+// because we have a whole bunch of code that deals with window resizing and
+// such that requires these values.
+enum HitTestCompat {
+ HTBORDER = 1,
+ HTBOTTOM,
+ HTBOTTOMLEFT,
+ HTBOTTOMRIGHT,
+ HTCAPTION,
+ HTCLIENT,
+ HTCLOSE,
+ HTERROR,
+ HTGROWBOX,
+ HTHELP,
+ HTHSCROLL,
+ HTLEFT,
+ HTMENU,
+ HTMAXBUTTON,
+ HTMINBUTTON,
+ HTNOWHERE,
+ HTREDUCE,
+ HTRIGHT,
+ HTSIZE,
+ HTSYSMENU,
+ HTTOP,
+ HTTOPLEFT,
+ HTTOPRIGHT,
+ HTTRANSPARENT,
+ HTVSCROLL,
+ HTZOOM
+};
+
+#endif // VIEWS_WINDOW_HIT_TEST_H_
diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc
index 9a06cfc..6135a7b 100644
--- a/views/window/non_client_view.cc
+++ b/views/window/non_client_view.cc
@@ -4,9 +4,14 @@
#include "views/window/non_client_view.h"
+#if defined(OS_WIN)
#include "chrome/common/win_util.h"
+#endif
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
+#if defined(OS_LINUX)
+#include "views/window/hit_test.h"
+#endif
#include "views/window/window.h"
namespace views {
@@ -27,7 +32,11 @@ static const int kClientViewIndex = 1;
NonClientView::NonClientView(Window* frame)
: frame_(frame),
client_view_(NULL),
+#if defined(OS_WIN)
use_native_frame_(win_util::ShouldUseVistaFrame()) {
+#else
+ use_native_frame_(false) {
+#endif
}
NonClientView::~NonClientView() {
diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h
index af8285c..992e94a 100644
--- a/views/window/window_delegate.h
+++ b/views/window/window_delegate.h
@@ -148,6 +148,7 @@ class WindowDelegate {
void ReleaseWindow();
private:
+ friend class WindowGtk;
friend class WindowWin;
// This is a little unusual. We use a scoped_ptr here because it's
// initialized to NULL automatically. We do this because we want to allow
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
new file mode 100644
index 0000000..a8c710c
--- /dev/null
+++ b/views/window/window_gtk.cc
@@ -0,0 +1,199 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "views/window/window_gtk.h"
+
+#include "app/l10n_util.h"
+#include "base/gfx/rect.h"
+#include "views/window/custom_frame_view.h"
+#include "views/window/non_client_view.h"
+#include "views/window/window_delegate.h"
+
+namespace views {
+
+WindowGtk::~WindowGtk() {
+}
+
+// static
+Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
+ const gfx::Rect& bounds,
+ WindowDelegate* window_delegate) {
+ WindowGtk* window = new WindowGtk(window_delegate);
+ window->GetNonClientView()->SetFrameView(window->CreateFrameViewForWindow());
+ window->Init(bounds);
+ return window;
+}
+
+gfx::Rect WindowGtk::GetBounds() const {
+ gfx::Rect bounds;
+ WidgetGtk::GetBounds(&bounds, true);
+ return bounds;
+}
+
+gfx::Rect WindowGtk::GetNormalBounds() const {
+ NOTIMPLEMENTED();
+ return GetBounds();
+}
+
+void WindowGtk::SetBounds(const gfx::Rect& bounds) {
+ // TODO: this may need to set an initial size if not showing.
+ // TODO: need to constrain based on screen size.
+ gtk_window_resize(GTK_WINDOW(GetNativeView()), bounds.width(),
+ bounds.height());
+
+ gtk_window_move(GTK_WINDOW(GetNativeView()), bounds.x(), bounds.y());
+}
+
+void WindowGtk::SetBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window) {
+ // TODO: need to deal with other_window.
+ SetBounds(bounds);
+}
+
+void WindowGtk::Show() {
+ gtk_widget_show_all(GetNativeView());
+}
+
+void WindowGtk::Activate() {
+ NOTIMPLEMENTED();
+}
+
+void WindowGtk::Close() {
+ NOTIMPLEMENTED();
+}
+
+void WindowGtk::Maximize() {
+ gtk_window_maximize(GetNativeWindow());
+}
+
+void WindowGtk::Minimize() {
+ gtk_window_iconify(GetNativeWindow());
+}
+
+void WindowGtk::Restore() {
+ NOTIMPLEMENTED();
+}
+
+bool WindowGtk::IsActive() const {
+ return gtk_window_is_active(GetNativeWindow());
+}
+
+bool WindowGtk::IsVisible() const {
+ return GTK_WIDGET_VISIBLE(GetNativeView());
+}
+
+bool WindowGtk::IsMaximized() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool WindowGtk::IsMinimized() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void WindowGtk::SetFullscreen(bool fullscreen) {
+ NOTIMPLEMENTED();
+}
+
+bool WindowGtk::IsFullscreen() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void WindowGtk::EnableClose(bool enable) {
+ gtk_window_set_deletable(GetNativeWindow(), enable);
+}
+
+void WindowGtk::DisableInactiveRendering() {
+ NOTIMPLEMENTED();
+}
+
+void WindowGtk::UpdateWindowTitle() {
+ // If the non-client view is rendering its own title, it'll need to relayout
+ // now.
+ non_client_view_->Layout();
+
+ // Update the native frame's text. We do this regardless of whether or not
+ // the native frame is being used, since this also updates the taskbar, etc.
+ std::wstring window_title = window_delegate_->GetWindowTitle();
+ std::wstring localized_text;
+ if (l10n_util::AdjustStringForLocaleDirection(window_title, &localized_text))
+ window_title.assign(localized_text);
+
+ gtk_window_set_title(GetNativeWindow(), WideToUTF8(window_title).c_str());
+}
+
+void WindowGtk::UpdateWindowIcon() {
+ NOTIMPLEMENTED();
+}
+
+NonClientFrameView* WindowGtk::CreateFrameViewForWindow() {
+ // TODO(erg): Always use a custom frame view? Are there cases where we let
+ // the window manager deal with the X11 equivalent of the "non-client" area?
+ return new CustomFrameView(this);
+}
+
+void WindowGtk::UpdateFrameAfterFrameChange() {
+ NOTIMPLEMENTED();
+}
+
+WindowDelegate* WindowGtk::GetDelegate() const {
+ return window_delegate_;
+}
+
+NonClientView* WindowGtk::GetNonClientView() const {
+ return non_client_view_;
+}
+
+ClientView* WindowGtk::GetClientView() const {
+ return non_client_view_->client_view();
+}
+
+gfx::NativeWindow WindowGtk::GetNativeWindow() const {
+ return GTK_WINDOW(GetNativeView());
+}
+
+WindowGtk::WindowGtk(WindowDelegate* window_delegate)
+ : WidgetGtk(TYPE_WINDOW),
+ is_modal_(false),
+ is_always_on_top_(false),
+ window_delegate_(window_delegate),
+ non_client_view_(new NonClientView(this)) {
+ window_delegate_->window_.reset(this);
+}
+
+void WindowGtk::Init(const gfx::Rect& bounds) {
+ // We call this after initializing our members since our implementations of
+ // assorted WidgetWin functions may be called during initialization.
+ is_modal_ = window_delegate_->IsModal();
+ if (is_modal_) {
+ // TODO(erg): Fix once modality works.
+ // BecomeModal();
+ }
+ is_always_on_top_ = window_delegate_->IsAlwaysOnTop();
+
+ WidgetGtk::Init(bounds, true);
+
+ // Create the ClientView, add it to the NonClientView and add the
+ // NonClientView to the RootView. This will cause everything to be parented.
+ non_client_view_->set_client_view(window_delegate_->CreateClientView(this));
+ WidgetGtk::SetContentsView(non_client_view_);
+
+ UpdateWindowTitle();
+
+ // SetInitialBounds(bounds);
+ // InitAlwaysOnTopState();
+
+ // if (!IsAppWindow()) {
+ // notification_registrar_.Add(
+ // this,
+ // NotificationType::ALL_APPWINDOWS_CLOSED,
+ // NotificationService::AllSources());
+ // }
+
+ // ResetWindowRegion(false);
+}
+
+} // namespace views
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
new file mode 100644
index 0000000..224c85a5
--- /dev/null
+++ b/views/window/window_gtk.h
@@ -0,0 +1,92 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef VIEWS_WINDOW_WINDOW_GTK_H_
+#define VIEWS_WINDOW_WINDOW_GTK_H_
+
+#include "base/basictypes.h"
+#include "views/widget/widget_gtk.h"
+#include "views/window/window.h"
+
+namespace gfx {
+class Point;
+class Size;
+};
+
+namespace views {
+
+class Client;
+class WindowDelegate;
+
+// Window implementation for GTK.
+class WindowGtk : public WidgetGtk, public Window {
+ public:
+ virtual ~WindowGtk();
+
+ // Window overrides:
+ virtual gfx::Rect GetBounds() const;
+ virtual gfx::Rect GetNormalBounds() const;
+ virtual void SetBounds(const gfx::Rect& bounds);
+ virtual void SetBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window);
+ virtual void Show();
+ virtual void Activate();
+ virtual void Close();
+ virtual void Maximize();
+ virtual void Minimize();
+ virtual void Restore();
+ virtual bool IsActive() const;
+ virtual bool IsVisible() const;
+ virtual bool IsMaximized() const;
+ virtual bool IsMinimized() const;
+ virtual void SetFullscreen(bool fullscreen);
+ virtual bool IsFullscreen() const;
+ virtual void EnableClose(bool enable);
+ virtual void DisableInactiveRendering();
+ virtual void UpdateWindowTitle();
+ virtual void UpdateWindowIcon();
+ virtual NonClientFrameView* CreateFrameViewForWindow();
+ virtual void UpdateFrameAfterFrameChange();
+ virtual WindowDelegate* GetDelegate() const;
+ virtual NonClientView* GetNonClientView() const;
+ virtual ClientView* GetClientView() const;
+ virtual gfx::NativeWindow GetNativeWindow() const;
+
+ virtual Window* AsWindow() { return this; }
+ virtual const Window* AsWindow() const { return this; }
+
+ protected:
+ // For the constructor.
+ friend class Window;
+
+ // Constructs the WindowGtk. |window_delegate| cannot be NULL.
+ explicit WindowGtk(WindowDelegate* window_delegate);
+
+ // Initializes the window to the passed in bounds.
+ void Init(const gfx::Rect& bounds);
+
+ private:
+ // Whether or not the window is modal. This comes from the delegate and is
+ // cached at Init time to avoid calling back to the delegate from the
+ // destructor.
+ bool is_modal_;
+
+ // Whether the window is currently always on top.
+ bool is_always_on_top_;
+
+ // Our window delegate.
+ WindowDelegate* window_delegate_;
+
+ // The View that provides the non-client area of the window (title bar,
+ // window controls, sizing borders etc). To use an implementation other than
+ // the default, this class must be subclassed and this value set to the
+ // desired implementation before calling |Init|.
+ NonClientView* non_client_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowGtk);
+};
+
+} // namespace views
+
+#endif // VIEWS_WINDOW_WINDOW_GTK_H_