x11_window.h revision 116680a4aac90f2aa7413d9095a592090648e557
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 UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_
6#define UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_
7
8#include "ui/events/platform/platform_event_dispatcher.h"
9#include "ui/gfx/geometry/rect.h"
10#include "ui/gfx/x/x11_atom_cache.h"
11#include "ui/platform_window/platform_window.h"
12#include "ui/platform_window/platform_window_delegate.h"
13#include "ui/platform_window/x11/x11_window_export.h"
14
15typedef struct _XDisplay XDisplay;
16typedef unsigned long XID;
17
18namespace ui {
19
20class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
21                                    public PlatformEventDispatcher {
22 public:
23  explicit X11Window(PlatformWindowDelegate* delegate);
24  virtual ~X11Window();
25
26 private:
27  void Destroy();
28
29  void ProcessXInput2Event(XEvent* xevent);
30
31  // PlatformWindow:
32  virtual void Show() OVERRIDE;
33  virtual void Hide() OVERRIDE;
34  virtual void Close() OVERRIDE;
35  virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
36  virtual gfx::Rect GetBounds() OVERRIDE;
37  virtual void SetCapture() OVERRIDE;
38  virtual void ReleaseCapture() OVERRIDE;
39  virtual void ToggleFullscreen() OVERRIDE;
40  virtual void Maximize() OVERRIDE;
41  virtual void Minimize() OVERRIDE;
42  virtual void Restore() OVERRIDE;
43
44  // PlatformEventDispatcher:
45  virtual bool CanDispatchEvent(const PlatformEvent& event) OVERRIDE;
46  virtual uint32_t DispatchEvent(const PlatformEvent& event) OVERRIDE;
47
48  PlatformWindowDelegate* delegate_;
49
50  XDisplay* xdisplay_;
51  XID xwindow_;
52  XID xroot_window_;
53  X11AtomCache atom_cache_;
54
55  // Setting the bounds is an asynchronous operation in X11. |requested_bounds_|
56  // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is
57  // the bounds the X11 server has set on the window.
58  gfx::Rect requested_bounds_;
59  gfx::Rect confirmed_bounds_;
60
61  bool window_mapped_;
62
63  DISALLOW_COPY_AND_ASSIGN(X11Window);
64};
65
66}  // namespace ui
67
68#endif  // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_
69