app_list_linux.h revision c5cede9ae108bb15f6b7a8aea21c7e1fefa2834c
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_LINUX_APP_LIST_LINUX_H_ 6#define CHROME_BROWSER_UI_VIEWS_APP_LIST_LINUX_APP_LIST_LINUX_H_ 7 8#include "base/callback.h" 9#include "chrome/browser/ui/app_list/app_list.h" 10#include "chrome/browser/ui/app_list/app_list_positioner.h" 11#include "ui/app_list/views/app_list_view_observer.h" 12 13namespace app_list { 14class AppListView; 15} 16 17namespace gfx { 18class Display; 19class Point; 20class Size; 21} // namespace gfx 22 23// Responsible for positioning, hiding and showing an AppListView on Linux. 24// This includes watching window activation/deactivation messages to determine 25// if the user has clicked away from it. 26class AppListLinux : public AppList, 27 public app_list::AppListViewObserver { 28 public: 29 AppListLinux(app_list::AppListView* view, 30 const base::Closure& on_should_dismiss); 31 virtual ~AppListLinux(); 32 33 // Finds the position for a window to anchor it to the shelf. This chooses the 34 // most appropriate position for the window based on whether the shelf exists, 35 // the position of the shelf, and the mouse cursor. Returns the intended 36 // coordinates for the center of the window. If |shelf_rect| is empty, assumes 37 // there is no shelf on the given display. 38 static gfx::Point FindAnchorPoint(const gfx::Size& view_size, 39 const gfx::Display& display, 40 const gfx::Point& cursor, 41 AppListPositioner::ScreenEdge edge); 42 43 // AppList: 44 virtual void Show() OVERRIDE; 45 virtual void Hide() OVERRIDE; 46 virtual void MoveNearCursor() OVERRIDE; 47 virtual bool IsVisible() OVERRIDE; 48 virtual void Prerender() OVERRIDE; 49 virtual gfx::NativeWindow GetWindow() OVERRIDE; 50 virtual void SetProfile(Profile* profile) OVERRIDE; 51 52 // app_list::AppListViewObserver: 53 virtual void OnActivationChanged(views::Widget* widget, bool active) OVERRIDE; 54 55 private: 56 // Weak pointer. The view manages its own lifetime. 57 app_list::AppListView* view_; 58 bool window_icon_updated_; 59 60 // Called to request |view_| be closed. 61 base::Closure on_should_dismiss_; 62 63 DISALLOW_COPY_AND_ASSIGN(AppListLinux); 64}; 65 66#endif // CHROME_BROWSER_UI_VIEWS_APP_LIST_LINUX_APP_LIST_LINUX_H_ 67