| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_UI_VIEWS_APP_LIST_WIN_ACTIVATION_TRACKER_WIN_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_APP_LIST_WIN_ACTIVATION_TRACKER_WIN_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/timer/timer.h" | |
| 10 #include "ui/app_list/views/app_list_view_observer.h" | |
| 11 | |
| 12 class AppListServiceWin; | |
| 13 | |
| 14 // Periodically checks to see if an AppListView has lost focus using a timer. | |
| 15 class ActivationTrackerWin : public app_list::AppListViewObserver { | |
| 16 public: | |
| 17 explicit ActivationTrackerWin(AppListServiceWin* service); | |
| 18 ~ActivationTrackerWin() override; | |
| 19 | |
| 20 // app_list::AppListViewObserver: | |
| 21 void OnActivationChanged(views::Widget* widget, bool active) override; | |
| 22 | |
| 23 void OnViewHidden(); | |
| 24 | |
| 25 private: | |
| 26 // Dismisses the app launcher if it has lost focus and the user is not trying | |
| 27 // to pin it. | |
| 28 void MaybeDismissAppList(); | |
| 29 | |
| 30 // Determines whether the app launcher should be dismissed. This should be | |
| 31 // called at most once per timer tick, as it is not idempotent (if the taskbar | |
| 32 // is focused, it waits until it has been called twice before dismissing the | |
| 33 // app list). | |
| 34 bool ShouldDismissAppList(); | |
| 35 | |
| 36 AppListServiceWin* service_; // Weak. Owns this. | |
| 37 | |
| 38 // Records whether, on the previous timer tick, the taskbar had focus without | |
| 39 // the right mouse button being down. We allow the taskbar to have focus for | |
| 40 // one tick before dismissing the app list. This allows the app list to be | |
| 41 // kept visible if the taskbar is seen briefly without the right mouse button | |
| 42 // down, but not if this happens for two consecutive ticks. | |
| 43 bool taskbar_has_focus_; | |
| 44 | |
| 45 // Timer used to check if the taskbar or app list is active. Using a timer | |
| 46 // means we don't need to hook Windows, which is apparently not possible | |
| 47 // since Vista (and is not nice at any time). | |
| 48 base::RepeatingTimer timer_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(ActivationTrackerWin); | |
| 51 }; | |
| 52 | |
| 53 #endif // CHROME_BROWSER_UI_VIEWS_APP_LIST_WIN_ACTIVATION_TRACKER_WIN_H_ | |
| OLD | NEW |