summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/event_utils.cc
blob: 06b9f0d6a395755a04ae0c7b62c50dfdd5ea539b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/views/event_utils.h"

#include "views/event.h"

using views::Event;

namespace event_utils {

WindowOpenDisposition DispositionFromEventFlags(int event_flags) {
  if (((event_flags & Event::EF_MIDDLE_BUTTON_DOWN) ==
          Event::EF_MIDDLE_BUTTON_DOWN) ||
      ((event_flags & Event::EF_CONTROL_DOWN) ==
          Event::EF_CONTROL_DOWN)) {
    return ((event_flags & Event::EF_SHIFT_DOWN) ==  Event::EF_SHIFT_DOWN) ?
        NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
  }

  if ((event_flags & Event::EF_SHIFT_DOWN) == Event::EF_SHIFT_DOWN)
    return NEW_WINDOW;
  return false /*event.IsAltDown()*/ ? SAVE_TO_DISK : CURRENT_TAB;
}

bool IsPossibleDispositionEvent(const views::MouseEvent& event) {
  return event.IsLeftMouseButton() || event.IsMiddleMouseButton();
}

}