Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Unified Diff: chrome/browser/ui/gtk/extensions/shell_window_gtk.cc

Issue 10834205: Draggable region support for frameless app window on GTK. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 65010a04bc2e111f288fb02799fb282a5662e204..30bf186a5c28d0353952831eb4bfe7b0f9aa0cf5 100644
--- a/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc
+++ b/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc
@@ -10,6 +10,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
+#include "content/public/common/draggable_region.h"
#include "ui/base/x/active_window_watcher_x.h"
#include "ui/gfx/rect.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,8 @@ ShellWindowGtk::ShellWindowGtk(Profile* profile,
G_CALLBACK(OnConfigureThunk), this);
g_signal_connect(window_, "window-state-event",
G_CALLBACK(OnWindowStateThunk), this);
+ g_signal_connect(window_, "button-press-event",
Evan Stade 2012/08/07 23:20:58 you only need to this if frameless.
+ G_CALLBACK(OnButtonPressThunk), this);
ui::ActiveWindowWatcherX::AddObserver(this);
}
@@ -212,6 +216,19 @@ gboolean ShellWindowGtk::OnWindowState(GtkWidget* sender,
return FALSE;
}
+gboolean ShellWindowGtk::OnButtonPress(GtkWidget* widget,
+ GdkEventButton * event) {
Evan Stade 2012/08/07 23:20:58 no space before *
+ if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
+ if (frameless_ && draggable_region_.Get() &&
+ draggable_region_.Get()->contains(event->x, event->y)) {
+ gtk_window_begin_move_drag(GTK_WINDOW(widget), event->button,
+ event->x_root, event->y_root, event->time);
Evan Stade 2012/08/07 23:20:58 I think you actually want to return TRUE to indica
+ }
+ }
jeremya 2012/08/08 04:38:37 Is this sufficient? Do we get behaviour like maxim
+
+ return FALSE;
+}
+
void ShellWindowGtk::SetFullscreen(bool fullscreen) {
content_thinks_its_fullscreen_ = fullscreen;
if (fullscreen)
@@ -224,6 +241,34 @@ bool ShellWindowGtk::IsFullscreenOrPending() const {
return content_thinks_its_fullscreen_;
}
+void ShellWindowGtk::UpdateDraggableRegions(
+ const std::vector<content::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.
+ for (std::vector<content::DraggableRegion>::const_iterator iter =
+ regions.begin();
+ iter != regions.end(); ++iter) {
+ const content::DraggableRegion& region = *iter;
+ draggable_region->op(region.bounds.x(),
+ region.bounds.y(),
+ region.bounds.right(),
+ region.bounds.bottom(),
+ SkRegion::kDifference_Op);
+ }
+
+ draggable_region_.Set(draggable_region);
+}
+
// static
ShellWindow* ShellWindow::CreateImpl(Profile* profile,
const extensions::Extension* extension,

Powered by Google App Engine
This is Rietveld 408576698