summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-22 20:15:05 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-22 20:15:05 +0000
commit959f02f686125777e7a744a81fbfcc240e648e54 (patch)
treef84a0fad2889cd7adcc798fcc204098fdcac6a89 /views
parenta3a8fb6d3692cf61db8cfed20e15e83916e6602b (diff)
downloadchromium_src-959f02f686125777e7a744a81fbfcc240e648e54.zip
chromium_src-959f02f686125777e7a744a81fbfcc240e648e54.tar.gz
chromium_src-959f02f686125777e7a744a81fbfcc240e648e54.tar.bz2
Enable System Context Menu for linux views.
* Chagned WindowGtk to pass through right click mouse event for HTCAPTION so that ContextMenuController on Frame/Tab view works. * Added ContetMenuController to NonClientView. * Added "PointIsWithinWindowCaption to BrowserView to exclude chromeos specific components from Caption area. Fix a minor bug in NonClientView * GetViewForPoint was using wrong point. This wasn't causing any issue as the frame_view's origin was (0, 0) BUG=None TEST=run chromeos build and right click frame view and verify that you get system menu. Review URL: http://codereview.chromium.org/303014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/widget/widget_gtk.cc44
-rw-r--r--views/widget/widget_gtk.h3
-rw-r--r--views/window/non_client_view.cc2
-rw-r--r--views/window/non_client_view.h4
-rw-r--r--views/window/window_gtk.cc22
5 files changed, 46 insertions, 29 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index de5b43e..1224414 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -66,28 +66,6 @@ static void GetWidgetPositionOnScreen(GtkWidget* widget, int* x, int *y) {
*y += window_y;
}
-// Returns the view::Event::flags for a GdkEventButton.
-static int GetFlagsForEventButton(const GdkEventButton& event) {
- int flags = Event::GetFlagsFromGdkState(event.state);
- switch (event.button) {
- case 1:
- flags |= Event::EF_LEFT_BUTTON_DOWN;
- break;
- case 2:
- flags |= Event::EF_MIDDLE_BUTTON_DOWN;
- break;
- case 3:
- flags |= Event::EF_RIGHT_BUTTON_DOWN;
- break;
- default:
- // We only deal with 1-3.
- break;
- }
- if (event.type == GDK_2BUTTON_PRESS)
- flags |= MouseEvent::EF_IS_DOUBLE_CLICK;
- return flags;
-}
-
// static
GtkWidget* WidgetGtk::null_parent_ = NULL;
@@ -850,6 +828,28 @@ void WidgetGtk::ReleaseGrab() {
}
// static
+int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) {
+ int flags = Event::GetFlagsFromGdkState(event.state);
+ switch (event.button) {
+ case 1:
+ flags |= Event::EF_LEFT_BUTTON_DOWN;
+ break;
+ case 2:
+ flags |= Event::EF_MIDDLE_BUTTON_DOWN;
+ break;
+ case 3:
+ flags |= Event::EF_RIGHT_BUTTON_DOWN;
+ break;
+ default:
+ // We only deal with 1-3.
+ break;
+ }
+ if (event.type == GDK_2BUTTON_PRESS)
+ flags |= MouseEvent::EF_IS_DOUBLE_CLICK;
+ return flags;
+}
+
+// static
WindowGtk* WidgetGtk::GetWindowForNative(GtkWidget* widget) {
gpointer user_data = g_object_get_data(G_OBJECT(widget), "chrome-window");
return static_cast<WindowGtk*>(user_data);
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index e082eea..b146b8e 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -169,6 +169,9 @@ class WidgetGtk
void ResetDropTarget();
protected:
+ // Returns the view::Event::flags for a GdkEventButton.
+ static int GetFlagsForEventButton(const GdkEventButton& event);
+
virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation);
virtual void OnPaint(GtkWidget* widget, GdkEventExpose* event);
virtual void OnDragDataGet(GdkDragContext* context,
diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc
index d6d7b93..903a774 100644
--- a/views/window/non_client_view.cc
+++ b/views/window/non_client_view.cc
@@ -187,7 +187,7 @@ views::View* NonClientView::GetViewForPoint(const gfx::Point& point) {
gfx::Point point_in_child_coords(point);
View::ConvertPointToView(this, frame_view_.get(), &point_in_child_coords);
if (frame_view_->HitTest(point_in_child_coords))
- return frame_view_->GetViewForPoint(point);
+ return frame_view_->GetViewForPoint(point_in_child_coords);
return View::GetViewForPoint(point);
}
diff --git a/views/window/non_client_view.h b/views/window/non_client_view.h
index 902967d..0956442 100644
--- a/views/window/non_client_view.h
+++ b/views/window/non_client_view.h
@@ -137,6 +137,10 @@ class NonClientView : public View {
explicit NonClientView(Window* frame);
virtual ~NonClientView();
+ // Returns the current NonClientFrameView instance, or NULL if
+ // it does not exist.
+ NonClientFrameView* frame_view() const { return frame_view_.get(); }
+
// Replaces the current NonClientFrameView (if any) with the specified one.
void SetFrameView(NonClientFrameView* frame_view);
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index c17df87..9bf2071 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -7,6 +7,7 @@
#include "app/gfx/path.h"
#include "app/l10n_util.h"
#include "base/gfx/rect.h"
+#include "views/event.h"
#include "views/screen.h"
#include "views/widget/root_view.h"
#include "views/window/custom_frame_view.h"
@@ -257,12 +258,21 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
non_client_view_->NonClientHitTest(gfx::Point(event->x, event->y));
switch (hittest_code) {
case HTCAPTION: {
- gfx::Point screen_point(event->x, event->y);
- View::ConvertPointToScreen(GetRootView(), &screen_point);
- gtk_window_begin_move_drag(GetNativeWindow(), event->button,
- screen_point.x(), screen_point.y(),
- event->time);
- return TRUE;
+ MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, event->x, event->y,
+ WidgetGtk::GetFlagsForEventButton(*event));
+ // Start dragging only if the mouse event is *not* a right
+ // click. If it is a right click, then pass it through to
+ // WidgetGtk::OnButtonPress so that View class can show
+ // ContextMenu upon a mouse release event.
+ if (!mouse_pressed.IsOnlyRightMouseButton()) {
+ gfx::Point screen_point(event->x, event->y);
+ View::ConvertPointToScreen(GetRootView(), &screen_point);
+ gtk_window_begin_move_drag(GetNativeWindow(), event->button,
+ screen_point.x(), screen_point.y(),
+ event->time);
+ return TRUE;
+ }
+ break;
}
case HTBOTTOM:
case HTBOTTOMLEFT: