Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / views / widget / desktop_aura / x11_window_event_filter.h
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 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WINDOW_EVENT_FILTER_H_
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WINDOW_EVENT_FILTER_H_
7
8 #include <X11/Xlib.h>
9
10 #include "base/compiler_specific.h"
11 #include "base/message_loop/message_loop.h"
12 #include "ui/events/event_handler.h"
13 #include "ui/gfx/x/x11_atom_cache.h"
14 #include "ui/gfx/x/x11_types.h"
15 #include "ui/views/views_export.h"
16
17 namespace aura {
18 class Window;
19 }
20
21 namespace gfx {
22 class Point;
23 }
24
25 namespace views {
26 class DesktopWindowTreeHost;
27 class NativeWidgetAura;
28
29 // An EventFilter that sets properties on X11 windows.
30 class VIEWS_EXPORT X11WindowEventFilter : public ui::EventHandler {
31  public:
32   explicit X11WindowEventFilter(DesktopWindowTreeHost* window_tree_host);
33   ~X11WindowEventFilter() override;
34
35   // Overridden from ui::EventHandler:
36   void OnMouseEvent(ui::MouseEvent* event) override;
37
38  private:
39   // Called when the user clicked the caption area.
40   void OnClickedCaption(ui::MouseEvent* event,
41                         int previous_click_component);
42
43   // Called when the user clicked the maximize button.
44   void OnClickedMaximizeButton(ui::MouseEvent* event);
45
46   void ToggleMaximizedState();
47
48   // Dispatches a _NET_WM_MOVERESIZE message to the window manager to tell it
49   // to act as if a border or titlebar drag occurred.
50   bool DispatchHostWindowDragMovement(int hittest,
51                                       const gfx::Point& screen_location);
52
53   // The display and the native X window hosting the root window.
54   XDisplay* xdisplay_;
55   ::Window xwindow_;
56
57   // The native root window.
58   ::Window x_root_window_;
59
60   ui::X11AtomCache atom_cache_;
61
62   DesktopWindowTreeHost* window_tree_host_;
63
64   // True if |xwindow_| is the current _NET_ACTIVE_WINDOW.
65   bool is_active_;
66
67   // The non-client component for the target of a MouseEvent. Mouse events can
68   // be destructive to the window tree, which can cause the component of a
69   // ui::EF_IS_DOUBLE_CLICK event to no longer be the same as that of the
70   // initial click. Acting on a double click should only occur for matching
71   // components.
72   int click_component_;
73
74   DISALLOW_COPY_AND_ASSIGN(X11WindowEventFilter);
75 };
76
77 }  // namespace views
78
79 #endif  // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WINDOW_EVENT_FILTER_H_