Home | History | Annotate | Download | only in wm
      1 // Copyright 2014 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 ASH_WM_WM_EVENT_H_
      6 #define ASH_WM_WM_EVENT_H_
      7 
      8 #include "ash/ash_export.h"
      9 #include "ash/wm/wm_types.h"
     10 #include "ui/gfx/rect.h"
     11 
     12 namespace ash {
     13 namespace wm {
     14 
     15 // WMEventType defines a set of operations that can change the
     16 // window's state type and bounds.
     17 enum WMEventType {
     18   // Following events are the request to become corresponding state.
     19   // Note that this does not mean the window will be in corresponding
     20   // state and the request may not be fullfilled.
     21 
     22   // NORMAL is used as a restore operation with a few exceptions.
     23   WM_EVENT_NORMAL,
     24   WM_EVENT_MAXIMIZE,
     25   WM_EVENT_MINIMIZE,
     26   WM_EVENT_FULLSCREEN,
     27   WM_EVENT_SNAP_LEFT,
     28   WM_EVENT_SNAP_RIGHT,
     29 
     30   // A window is requested to be the given bounds. The request may or
     31   // may not be fulfilled depending on the requested bounds and window's
     32   // state. This will not change the window state type.
     33   WM_EVENT_SET_BOUNDS,
     34 
     35   // Following events are compond events which may lead to different
     36   // states depending on the current state.
     37 
     38   // A user requested to toggle maximized state by double clicking window
     39   // header.
     40   WM_EVENT_TOGGLE_MAXIMIZE_CAPTION,
     41 
     42   // A user requested to toggle maximized state using shortcut.
     43   WM_EVENT_TOGGLE_MAXIMIZE,
     44 
     45   // A user requested to toggle vertical maximize by double clicking
     46   // top/bottom edge.
     47   WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE,
     48 
     49   // A user requested to toggle horizontal maximize by double clicking
     50   // left/right edge.
     51   WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE,
     52 
     53   // A user requested to toggle fullscreen state.
     54   WM_EVENT_TOGGLE_FULLSCREEN,
     55 
     56   // A user requested to center a window.
     57   WM_EVENT_CENTER,
     58 
     59   // TODO(oshima): Investigate if this can be removed from ash.
     60   // Widget requested to show in inactive state.
     61   WM_EVENT_SHOW_INACTIVE,
     62 
     63   // Following events are generated when the workspace envrionment has changed.
     64   // The window's state type will not be changed by these events.
     65 
     66   // The window is added to the workspace, either as a new window, due to
     67   // display disconnection or dragging.
     68   WM_EVENT_ADDED_TO_WORKSPACE,
     69 
     70   // Bounds of the display has changed.
     71   WM_EVENT_DISPLAY_BOUNDS_CHANGED,
     72 
     73   // Bounds of the work area has changed. This will not occur when the work
     74   // area has changed as a result of DISPLAY_BOUNDS_CHANGED.
     75   WM_EVENT_WORKAREA_BOUNDS_CHANGED,
     76 };
     77 
     78 class ASH_EXPORT WMEvent {
     79  public:
     80   explicit WMEvent(WMEventType type);
     81   virtual ~WMEvent();
     82 
     83   WMEventType type() const { return type_; }
     84 
     85  private:
     86   WMEventType type_;
     87   DISALLOW_COPY_AND_ASSIGN(WMEvent);
     88 };
     89 
     90 // An WMEvent to request new bounds for the window.
     91 class SetBoundsEvent : public WMEvent {
     92 public:
     93   SetBoundsEvent(WMEventType type, const gfx::Rect& requested_bounds);
     94   virtual ~SetBoundsEvent();
     95 
     96   const gfx::Rect& requested_bounds() const { return requested_bounds_; }
     97 
     98  private:
     99   gfx::Rect requested_bounds_;
    100 
    101   DISALLOW_COPY_AND_ASSIGN(SetBoundsEvent);
    102 };
    103 
    104 }  // namespace wm
    105 }  // namespace ash
    106 
    107 #endif  // ASH_WM_WM_EVENT_H_
    108 
    109