Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: ui/ozone/platform/wayland/wayland_display.h

Issue 2027943002: [WIP] Make content_shell run under Wayland Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ 5 #ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_
6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ 6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/message_loop/message_pump_libevent.h" 10 #include "base/message_loop/message_pump_libevent.h"
11 #include "ui/events/platform/platform_event_source.h" 11 #include "ui/events/platform/platform_event_source.h"
12 #include "ui/gfx/native_widget_types.h" 12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/ozone/platform/wayland/desktop_platform_screen_delegate.h"
13 #include "ui/ozone/platform/wayland/wayland_object.h" 14 #include "ui/ozone/platform/wayland/wayland_object.h"
14 #include "ui/ozone/platform/wayland/wayland_pointer.h" 15 #include "ui/ozone/platform/wayland/wayland_pointer.h"
16 #include "ui/ozone/platform/wayland/wayland_screen.h"
15 17
16 namespace ui { 18 namespace ui {
17 19
18 class WaylandWindow; 20 class WaylandWindow;
19 21
20 class WaylandDisplay : public PlatformEventSource, 22 class WaylandDisplay : public PlatformEventSource,
21 public base::MessagePumpLibevent::Watcher { 23 public base::MessagePumpLibevent::Watcher {
22 public: 24 public:
23 WaylandDisplay(); 25 WaylandDisplay();
24 ~WaylandDisplay() override; 26 ~WaylandDisplay() override;
25 27
28 static WaylandDisplay* GetInstance() { return instance_; }
26 bool Initialize(); 29 bool Initialize();
27 bool StartProcessingEvents(); 30 bool StartProcessingEvents();
28 31
29 // Schedules a flush of the Wayland connection. 32 // Schedules a flush of the Wayland connection.
30 void ScheduleFlush(); 33 void ScheduleFlush();
31 34
32 wl_display* display() { return display_.get(); } 35 wl_display* display() { return display_.get(); }
33 wl_compositor* compositor() { return compositor_.get(); } 36 wl_compositor* compositor() { return compositor_.get(); }
34 wl_shm* shm() { return shm_.get(); } 37 wl_shm* shm() { return shm_.get(); }
35 xdg_shell* shell() { return shell_.get(); } 38 xdg_shell* shell() { return shell_.get(); }
36 39
37 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget); 40 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget);
38 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window); 41 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window);
39 void RemoveWindow(gfx::AcceleratedWidget widget); 42 void RemoveWindow(gfx::AcceleratedWidget widget);
40 43
44 const std::vector<WaylandScreen*>& GetScreenList() const;
45 WaylandScreen* PrimaryScreen() const { return primary_screen_; }
46 void OutputSizeChanged(int32_t name, unsigned width, unsigned height);
47 void SetDesktopScreenDelegate(DesktopPlatformScreenDelegate*);
48 DesktopPlatformScreenDelegate* GetDesktopScreenDelegate() {
49 return desktop_platform_screen_delegate_;
50 }
51
41 private: 52 private:
42 void Flush(); 53 void Flush();
43 void DispatchUiEvent(Event* event); 54 void DispatchUiEvent(Event* event);
44 55
45 // PlatformEventSource 56 // PlatformEventSource
46 void OnDispatcherListChanged() override; 57 void OnDispatcherListChanged() override;
47 58
48 // base::MessagePumpLibevent::Watcher 59 // base::MessagePumpLibevent::Watcher
49 void OnFileCanReadWithoutBlocking(int fd) override; 60 void OnFileCanReadWithoutBlocking(int fd) override;
50 void OnFileCanWriteWithoutBlocking(int fd) override; 61 void OnFileCanWriteWithoutBlocking(int fd) override;
51 62
52 // wl_registry_listener 63 // wl_registry_listener
53 static void Global(void* data, 64 static void Global(void* data,
54 wl_registry* registry, 65 wl_registry* registry,
55 uint32_t name, 66 uint32_t name,
56 const char* interface, 67 const char* interface,
57 uint32_t version); 68 uint32_t version);
58 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name); 69 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name);
59 70
60 // wl_seat_listener 71 // wl_seat_listener
61 static void Capabilities(void* data, wl_seat* seat, uint32_t capabilities); 72 static void Capabilities(void* data, wl_seat* seat, uint32_t capabilities);
62 static void Name(void* data, wl_seat* seat, const char* name); 73 static void Name(void* data, wl_seat* seat, const char* name);
63 74
64 // xdg_shell_listener 75 // xdg_shell_listener
65 static void Ping(void* data, xdg_shell* shell, uint32_t serial); 76 static void Ping(void* data, xdg_shell* shell, uint32_t serial);
66 77
67 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; 78 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_;
79 static WaylandDisplay* instance_;
68 80
69 wl::Object<wl_display> display_; 81 wl::Object<wl_display> display_;
70 wl::Object<wl_registry> registry_; 82 wl::Object<wl_registry> registry_;
71 wl::Object<wl_compositor> compositor_; 83 wl::Object<wl_compositor> compositor_;
72 wl::Object<wl_seat> seat_; 84 wl::Object<wl_seat> seat_;
73 wl::Object<wl_shm> shm_; 85 wl::Object<wl_shm> shm_;
74 wl::Object<xdg_shell> shell_; 86 wl::Object<xdg_shell> shell_;
75 87
76 std::unique_ptr<WaylandPointer> pointer_; 88 std::unique_ptr<WaylandPointer> pointer_;
77 89
78 bool scheduled_flush_ = false; 90 bool scheduled_flush_ = false;
79 bool watching_ = false; 91 bool watching_ = false;
80 base::MessagePumpLibevent::FileDescriptorWatcher controller_; 92 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
81 93
94 WaylandScreen* primary_screen_;
95 std::vector<WaylandScreen*> screen_list_;
96
97 DesktopPlatformScreenDelegate* desktop_platform_screen_delegate_;
82 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); 98 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay);
83 }; 99 };
84 100
85 } // namespace ui 101 } // namespace ui
86 102
87 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ 103 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698