From 1cd6d7ffcfb20215c225e613a67b39dc5f51c4cf Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" Date: Thu, 4 Jun 2009 03:49:49 +0000 Subject: Implement custom window shapes as provided by the NonClientView in WindowGtk. BUG=none TEST=none Review URL: http://codereview.chromium.org/119145 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17597 0039d316-1c4b-4281-b951-d872f2087c98 --- views/window/window_gtk.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'views/window/window_gtk.cc') 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), -- cgit v1.1