summaryrefslogtreecommitdiffstats
path: root/views/window
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-01 04:46:26 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-01 04:46:26 +0000
commitdfd84056ab03d21844376b5d95989440ed86e84a (patch)
tree44d4e0639f344ae76690b85e077f28b5ab0adcf3 /views/window
parent39d72dc6fa1404e88b0ea64a0b4b33f29fba7a8b (diff)
downloadchromium_src-dfd84056ab03d21844376b5d95989440ed86e84a.zip
chromium_src-dfd84056ab03d21844376b5d95989440ed86e84a.tar.gz
chromium_src-dfd84056ab03d21844376b5d95989440ed86e84a.tar.bz2
Remove warning about IsFullScreen() not being implented and
initialize window to proper size Review URL: http://codereview.chromium.org/115983 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window')
-rw-r--r--views/window/window_gtk.cc44
-rw-r--r--views/window/window_gtk.h11
2 files changed, 36 insertions, 19 deletions
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index 4b181ed..30900df 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -42,12 +42,12 @@ gfx::Rect WindowGtk::GetNormalBounds() const {
}
void WindowGtk::SetBounds(const gfx::Rect& bounds) {
+ GtkWindow* gtk_window = GetNativeWindow();
// 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_resize(gtk_window, bounds.width(), bounds.height());
- gtk_window_move(GTK_WINDOW(GetNativeView()), bounds.x(), bounds.y());
+ gtk_window_move(gtk_window, bounds.x(), bounds.y());
}
void WindowGtk::SetBounds(const gfx::Rect& bounds,
@@ -110,20 +110,22 @@ bool WindowGtk::IsVisible() const {
}
bool WindowGtk::IsMaximized() const {
- return window_maximized_;
+ return window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
}
bool WindowGtk::IsMinimized() const {
- return window_minimized_;
+ return window_state_ & GDK_WINDOW_STATE_ICONIFIED;
}
void WindowGtk::SetFullscreen(bool fullscreen) {
- NOTIMPLEMENTED();
+ if (fullscreen)
+ gtk_window_fullscreen(GetNativeWindow());
+ else
+ gtk_window_unfullscreen(GetNativeWindow());
}
bool WindowGtk::IsFullscreen() const {
- NOTIMPLEMENTED();
- return false;
+ return window_state_ & GDK_WINDOW_STATE_FULLSCREEN;
}
void WindowGtk::EnableClose(bool enable) {
@@ -225,7 +227,7 @@ void WindowGtk::Init(const gfx::Rect& bounds) {
G_CALLBACK(CallWindowStateEvent),
NULL);
- // SetInitialBounds(bounds);
+ SetInitialBounds(bounds);
// if (!IsAppWindow()) {
// notification_registrar_.Add(
@@ -237,6 +239,25 @@ void WindowGtk::Init(const gfx::Rect& bounds) {
// ResetWindowRegion(false);
}
+void WindowGtk::SetInitialBounds(const gfx::Rect& create_bounds) {
+ gfx::Rect saved_bounds(create_bounds.ToGdkRectangle());
+ if (window_delegate_->GetSavedWindowBounds(&saved_bounds)) {
+ SetBounds(saved_bounds);
+ } else {
+ if (create_bounds.IsEmpty()) {
+ SizeWindowToDefault();
+ } else {
+ SetBounds(create_bounds, NULL);
+ }
+ }
+}
+
+void WindowGtk::SizeWindowToDefault() {
+ gfx::Size size = non_client_view_->GetPreferredSize();
+ gfx::Rect bounds(size.width(), size.height());
+ SetBounds(bounds, NULL);
+}
+
void WindowGtk::SaveWindowPosition() {
// The delegate may have gone away on us.
if (!window_delegate_)
@@ -249,10 +270,7 @@ void WindowGtk::SaveWindowPosition() {
void WindowGtk::CallWindowStateEvent(GtkWidget* widget,
GdkEventWindowState* window_state) {
WindowGtk* window_gtk = GetWindowForNative(widget);
- window_gtk->window_maximized_ =
- window_state->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
- window_gtk->window_minimized_ =
- window_state->new_window_state & GDK_WINDOW_STATE_ICONIFIED;
+ window_gtk->window_state_ = window_state->new_window_state;
}
} // namespace views
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
index 92ccd56..05908f3 100644
--- a/views/window/window_gtk.h
+++ b/views/window/window_gtk.h
@@ -80,6 +80,9 @@ class WindowGtk : public WidgetGtk, public Window {
// Asks the delegate if any to save the window's location and size.
void SaveWindowPosition();
+ void SetInitialBounds(const gfx::Rect& bounds);
+ void SizeWindowToDefault();
+
// 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.
@@ -94,15 +97,11 @@ class WindowGtk : public WidgetGtk, public Window {
// desired implementation before calling |Init|.
NonClientView* non_client_view_;
+
+ GdkWindowState window_state_;
// Set to true if the window is in the process of closing.
bool window_closed_;
- // Set to true if the window is maximized
- bool window_maximized_;
-
- // Set to true of the window is minimized
- bool window_minimized_;
-
DISALLOW_COPY_AND_ASSIGN(WindowGtk);
};