Home | History | Annotate | Download | only in events
      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.
      4 
      5 #include "ui/base/events/event_conversion_gtk.h"
      6 
      7 #include "ui/base/events/event_constants.h"
      8 
      9 namespace ui {
     10 
     11 int GdkModifierToEventFlag(GdkModifierType gdk_modifier) {
     12   int event_flags = 0;
     13   if (gdk_modifier & GDK_SHIFT_MASK)
     14     event_flags |= EF_SHIFT_DOWN;
     15   if (gdk_modifier & GDK_CONTROL_MASK)
     16     event_flags |= EF_CONTROL_DOWN;
     17   if (gdk_modifier & GDK_MOD1_MASK)
     18     event_flags |= EF_ALT_DOWN;
     19   return event_flags;
     20 }
     21 
     22 GdkModifierType EventFlagToGdkModifier(int event_flag) {
     23   int modifier = 0;
     24   if (event_flag & EF_SHIFT_DOWN)
     25     modifier |= GDK_SHIFT_MASK;
     26   if (event_flag & EF_CONTROL_DOWN)
     27     modifier |= GDK_CONTROL_MASK;
     28   if (event_flag & EF_ALT_DOWN)
     29     modifier |= GDK_MOD1_MASK;
     30   return static_cast<GdkModifierType>(modifier);
     31 }
     32 
     33 }  // namespace ui
     34