This source file includes following definitions.
- EventFlagsFromGdkState
- DispositionFromGdkState
- DispositionForCurrentButtonPressEvent
#include "chrome/browser/ui/gtk/event_utils.h"
#include "base/logging.h"
#include "ui/base/window_open_disposition.h"
#include "ui/events/event_constants.h"
namespace event_utils {
int EventFlagsFromGdkState(guint state) {
int flags = ui::EF_NONE;
flags |= (state & GDK_LOCK_MASK) ? ui::EF_CAPS_LOCK_DOWN : ui::EF_NONE;
flags |= (state & GDK_CONTROL_MASK) ? ui::EF_CONTROL_DOWN : ui::EF_NONE;
flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : ui::EF_NONE;
flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : ui::EF_NONE;
flags |= (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON
: ui::EF_NONE;
flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : ui::EF_NONE;
return flags;
}
WindowOpenDisposition DispositionFromGdkState(guint state) {
int event_flags = EventFlagsFromGdkState(state);
return ui::DispositionFromEventFlags(event_flags);
}
WindowOpenDisposition DispositionForCurrentButtonPressEvent() {
GdkEvent* event = gtk_get_current_event();
if (!event) {
NOTREACHED();
return NEW_FOREGROUND_TAB;
}
guint state = event->button.state;
gdk_event_free(event);
return DispositionFromGdkState(state);
}
}