Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / event_utils.cc
blobf61c12165674d5e56f51183e38018f521968da62
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/gtk/event_utils.h"
7 #include "base/logging.h"
8 #include "ui/base/window_open_disposition.h"
9 #include "ui/events/event_constants.h"
11 namespace event_utils {
13 int EventFlagsFromGdkState(guint state) {
14 int flags = ui::EF_NONE;
15 flags |= (state & GDK_LOCK_MASK) ? ui::EF_CAPS_LOCK_DOWN : ui::EF_NONE;
16 flags |= (state & GDK_CONTROL_MASK) ? ui::EF_CONTROL_DOWN : ui::EF_NONE;
17 flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
18 flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : ui::EF_NONE;
19 flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : ui::EF_NONE;
20 flags |= (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON
21 : ui::EF_NONE;
22 flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : ui::EF_NONE;
23 return flags;
26 // TODO(shinyak) This function will be removed after refactoring.
27 WindowOpenDisposition DispositionFromGdkState(guint state) {
28 int event_flags = EventFlagsFromGdkState(state);
29 return ui::DispositionFromEventFlags(event_flags);
32 WindowOpenDisposition DispositionForCurrentButtonPressEvent() {
33 GdkEvent* event = gtk_get_current_event();
34 if (!event) {
35 NOTREACHED();
36 return NEW_FOREGROUND_TAB;
39 guint state = event->button.state;
40 gdk_event_free(event);
41 return DispositionFromGdkState(state);
44 } // namespace event_utils