Chromium Code Reviews| Index: chrome/browser/ui/gtk/extensions/shell_window_gtk.cc |
| diff --git a/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc b/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc |
| index fe265587ee8c9cceafbeef1ab90330e5314af283..b9fef7ee76814d841c205d7423600380869feef1 100644 |
| --- a/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc |
| +++ b/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/extensions/draggable_region.h" |
| #include "chrome/common/extensions/extension.h" |
| #include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/render_widget_host_view.h" |
| @@ -20,7 +21,8 @@ ShellWindowGtk::ShellWindowGtk(Profile* profile, |
| : ShellWindow(profile, extension, url), |
| state_(GDK_WINDOW_STATE_WITHDRAWN), |
| is_active_(!ui::ActiveWindowWatcherX::WMSupportsActivation()), |
| - content_thinks_its_fullscreen_(false) { |
| + content_thinks_its_fullscreen_(false), |
| + frameless_(params.frame == ShellWindow::CreateParams::FRAME_NONE) { |
| window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
| gfx::NativeView native_view = |
| @@ -31,7 +33,7 @@ ShellWindowGtk::ShellWindowGtk(Profile* profile, |
| window_, params.bounds.width(), params.bounds.height()); |
| // Hide titlebar when {frame: 'none'} specified on ShellWindow. |
| - if (params.frame == ShellWindow::CreateParams::FRAME_NONE) |
| + if (frameless_) |
| gtk_window_set_decorated(window_, false); |
| int min_width = params.minimum_size.width(); |
| @@ -67,6 +69,9 @@ ShellWindowGtk::ShellWindowGtk(Profile* profile, |
| G_CALLBACK(OnConfigureThunk), this); |
| g_signal_connect(window_, "window-state-event", |
| G_CALLBACK(OnWindowStateThunk), this); |
| + if (frameless_) |
|
Evan Stade
2012/08/08 21:01:42
curlies
|
| + g_signal_connect(window_, "button-press-event", |
| + G_CALLBACK(OnButtonPressThunk), this); |
| ui::ActiveWindowWatcherX::AddObserver(this); |
| } |
| @@ -208,6 +213,26 @@ gboolean ShellWindowGtk::OnWindowState(GtkWidget* sender, |
| return FALSE; |
| } |
| +gboolean ShellWindowGtk::OnButtonPress(GtkWidget* widget, |
| + GdkEventButton* event) { |
| + if (frameless_ && draggable_region_.get() && |
|
Evan Stade
2012/08/08 21:01:42
you don't need the frameless_ check now.
|
| + draggable_region_->contains(event->x, event->y)) { |
| + if (event->type == GDK_BUTTON_PRESS && event->button == 1) { |
| + gtk_window_begin_move_drag(GTK_WINDOW(widget), event->button, |
| + event->x_root, event->y_root, event->time); |
| + return TRUE; |
| + } else if (event->type == GDK_2BUTTON_PRESS) { |
| + bool is_maximized_ = gdk_window_get_state(GTK_WIDGET(widget)->window) & |
|
Evan Stade
2012/08/08 21:01:42
there are too many spaces after the =
|
| + GDK_WINDOW_STATE_MAXIMIZED; |
| + !is_maximized_ ? gtk_window_maximize(GTK_WINDOW(widget)) : |
|
Evan Stade
2012/08/08 21:01:42
nit: I would get rid of the ! here because it just
|
| + gtk_window_unmaximize(GTK_WINDOW(widget)); |
| + return TRUE; |
| + } |
| + } |
| + |
| + return FALSE; |
| +} |
| + |
| void ShellWindowGtk::SetFullscreen(bool fullscreen) { |
| content_thinks_its_fullscreen_ = fullscreen; |
| if (fullscreen) |
| @@ -220,6 +245,34 @@ bool ShellWindowGtk::IsFullscreenOrPending() const { |
| return content_thinks_its_fullscreen_; |
| } |
| +void ShellWindowGtk::UpdateDraggableRegions( |
| + const std::vector<extensions::DraggableRegion>& regions) { |
| + // Draggable region is not supported for non-frameless window. |
| + if (!frameless_) |
| + return; |
| + |
| + SkRegion* draggable_region = new SkRegion; |
| + |
| + // By default, the whole window is draggable. |
| + gfx::Rect bounds = GetBounds(); |
| + draggable_region->op(0, 0, bounds.right(), bounds.bottom(), |
| + SkRegion::kUnion_Op); |
| + |
| + // Exclude those desinated as non-draggable. |
|
Evan Stade
2012/08/08 21:01:42
designated
|
| + for (std::vector<extensions::DraggableRegion>::const_iterator iter = |
| + regions.begin(); |
| + iter != regions.end(); ++iter) { |
| + const extensions::DraggableRegion& region = *iter; |
| + draggable_region->op(region.bounds.x(), |
| + region.bounds.y(), |
| + region.bounds.right(), |
| + region.bounds.bottom(), |
| + SkRegion::kDifference_Op); |
| + } |
| + |
| + draggable_region_.reset(draggable_region); |
| +} |
| + |
| // static |
| ShellWindow* ShellWindow::CreateImpl(Profile* profile, |
| const extensions::Extension* extension, |