diff options
-rw-r--r-- | views/widget/widget_gtk.cc | 4 | ||||
-rw-r--r-- | views/window/window_gtk.cc | 21 | ||||
-rw-r--r-- | views/window/window_gtk.h | 5 |
3 files changed, 29 insertions, 1 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index ee380d3..f1cb67d 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -370,6 +370,10 @@ void WidgetGtk::CreateGtkWidget() { SetViewForNative(child_widget_parent_, this); } + + // The widget needs to be realized before handlers like size-allocate can + // function properly. + gtk_widget_realize(widget_); } void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index c5b2208..51c726c 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -4,6 +4,7 @@ #include "views/window/window_gtk.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "base/gfx/rect.h" #include "views/window/custom_frame_view.h" @@ -184,6 +185,25 @@ void WindowGtk::FrameTypeChanged() { NOTIMPLEMENTED(); } +//////////////////////////////////////////////////////////////////////////////// +// WindowGtk, WidgetGtk overrides: + +void WindowGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { + WidgetGtk::OnSizeAllocate(widget, allocation); + + // The Window's NonClientView may provide a custom shape for the Window. + gfx::Path window_mask; + non_client_view_->GetWindowMask(gfx::Size(allocation->width, + allocation->height), + &window_mask); + GdkRegion* mask_region = window_mask.CreateGdkRegion(); + gdk_window_shape_combine_region(GetNativeView()->window, mask_region, 0, 0); + gdk_region_destroy(mask_region); +} + +//////////////////////////////////////////////////////////////////////////////// +// WindowGtk, protected: + WindowGtk::WindowGtk(WindowDelegate* window_delegate) : WidgetGtk(TYPE_WINDOW), is_modal_(false), @@ -214,6 +234,7 @@ void WindowGtk::Init(const gfx::Rect& bounds) { UpdateWindowTitle(); GtkWindow* gtk_window = GetNativeWindow(); + g_signal_connect(G_OBJECT(gtk_window), "window-state-event", G_CALLBACK(CallWindowStateEvent), diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index a670536..94cca05 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -24,7 +24,7 @@ class WindowGtk : public WidgetGtk, public Window { public: virtual ~WindowGtk(); - // Window overrides: + // Overridden from Window: virtual gfx::Rect GetBounds() const; virtual gfx::Rect GetNormalBounds() const; virtual void SetBounds(const gfx::Rect& bounds, @@ -61,6 +61,9 @@ class WindowGtk : public WidgetGtk, public Window { virtual Window* AsWindow() { return this; } virtual const Window* AsWindow() const { return this; } + // Overridden from WidgetGtk: + virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation); + protected: // For the constructor. friend class Window; |