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

Unified Diff: chrome/browser/ui/panels/panel_browser_window_gtk.cc

Issue 10020057: Resize support for detached GTK Panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback changes Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window_gtk.h ('k') | chrome/browser/ui/panels/panel_drag_gtk.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_browser_window_gtk.cc
diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk.cc b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
index 2602346841b4731ad2e97de6421a2f6c88396e26..8871d884f2ba52305b2a3d4293ef827141964661 100644
--- a/chrome/browser/ui/panels/panel_browser_window_gtk.cc
+++ b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/ui/gtk/browser_titlebar.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_bounds_animation.h"
+#include "chrome/browser/ui/panels/panel_drag_gtk.h"
#include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
@@ -41,7 +42,7 @@ const char* const kDrawAttentionTitleMarkupSuffix = "</span>";
// size in overflow expansion state.
const int kMinWindowWidth = 2;
-}
+} // namespace
NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel,
const gfx::Rect& bounds) {
@@ -104,10 +105,21 @@ void PanelBrowserWindowGtk::Init() {
}
bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
- // Since panels are not resizable or movable by the user, we should not
- // detect the window edge for behavioral purposes. The edge, if any,
- // is present only for visual aspects.
- return FALSE;
+ // Only detect the window edge when panels can be resized by the user.
+ // This method is used by the base class to detect when the cursor has
+ // hit the window edge in order to change the cursor to a resize cursor
+ // and to detect when to initiate a resize drag.
+ return panel_->CanResizeByMouse() ?
+ BrowserWindowGtk::GetWindowEdge(x, y, edge) : FALSE;
+}
+
+void PanelBrowserWindowGtk::EnsureDragHelperCreated() {
+ if (drag_helper_.get())
+ return;
+
+ drag_helper_.reset(new PanelDragGtk(panel_.get()));
+ gtk_box_pack_end(GTK_BOX(window_vbox_), drag_helper_->widget(),
+ FALSE, FALSE, 0);
}
bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress(
@@ -122,6 +134,22 @@ bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress(
return TRUE;
}
+bool PanelBrowserWindowGtk::HandleWindowEdgeLeftMousePress(
+ GtkWindow* window,
+ GdkWindowEdge edge,
+ GdkEventButton* event) {
+ DCHECK_EQ(1U, event->button);
+ DCHECK_EQ(GDK_BUTTON_PRESS, event->type);
+
+ EnsureDragHelperCreated();
+ // Resize cursor was set by BrowserWindowGtk when mouse moved over
+ // window edge.
+ GdkCursor* cursor =
+ gdk_window_get_cursor(gtk_widget_get_window(GTK_WIDGET(window_)));
+ drag_helper_->InitialWindowEdgeMousePress(event, cursor, edge);
+ return TRUE;
+}
+
void PanelBrowserWindowGtk::SaveWindowPosition() {
// We don't save window position for panels as it's controlled by
// PanelManager.
@@ -286,6 +314,10 @@ void PanelBrowserWindowGtk::Observe(
gtk_grab_remove(drag_widget_);
DestroyDragWidget();
}
+
+ if (drag_helper_.get())
+ drag_helper_.reset();
+
panel_->OnNativePanelClosed();
break;
}
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window_gtk.h ('k') | chrome/browser/ui/panels/panel_drag_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698