Chromium Code Reviews| Index: ui/wayland/wayland_display.h |
| diff --git a/ui/wayland/wayland_display.h b/ui/wayland/wayland_display.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9669b7b6baceb3639df21674751a284183aff5c1 |
| --- /dev/null |
| +++ b/ui/wayland/wayland_display.h |
| @@ -0,0 +1,100 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WAYLAND_DISPLAY_H_ |
| +#define WAYLAND_DISPLAY_H_ |
| + |
| +#include <list> |
| +#include <stdint.h> |
| + |
| +#include "base/basictypes.h" |
| + |
| +class WaylandBuffer; |
| +class WaylandInputDevice; |
| +class WaylandScreen; |
| + |
| +struct wl_compositor; |
| +struct wl_display; |
| +struct wl_shell; |
| +struct wl_shm; |
| +struct wl_surface; |
| +struct wl_visual; |
| + |
| +/* WaylandDisplay is a wrapper around wl_display. Once we get a valid |
| +wl_display, the Wayland server will send different events to register |
| +the Wayland compositor, shell, visuals, screens, input devices, ... |
| + |
| +Since only one connection is needed, this class is a singleton keeping track |
| +of that connection. |
|
Evan Martin
2011/07/22 18:21:22
Is a singleton necessary? In general they make co
|
| +*/ |
| +class WaylandDisplay { |
| + public: |
| + /* Create a connection if one doesn't exist. Otherwise return the existing |
| + connection. |
| + */ |
| + static WaylandDisplay* Connect(char* name); |
| + ~WaylandDisplay(); |
| + |
| + /* Creates a wayland surface. This is used to create a window surface. |
| + The returned pointer should be deleted by the caller. |
| + */ |
| + wl_surface* CreateSurface(); |
| + /* Sets the specified buffer as the surface for the cursor. (x, y) is |
| + the hotspot for the cursor. |
| + */ |
| + void SetCursor(WaylandBuffer* buffer, int32_t x, int32_t y); |
| + |
| + /* Returns a pointer to the wl_display. */ |
| + wl_display* GetNativeDisplay() const; |
| + /* Returns a list of the registered screens. |
| + */ |
| + std::list<WaylandScreen*> GetScreenList() const; |
| + wl_shell* GetShell() const; |
| + wl_shm* GetShm() const; |
| + wl_visual* GetVisual() const; |
| + private: |
| + WaylandDisplay(char* name); |
| + |
| + /* WaylandDisplay manages the memory of all these pointers. |
| + */ |
| + wl_display* display_; |
| + wl_compositor* compositor_; |
| + wl_shell* shell_; |
| + wl_shm* shm_; |
| + wl_visual* visual_; |
| + std::list<WaylandScreen*> screen_list_; |
| + std::list<WaylandInputDevice*> input_list_; |
| + |
| + /* This handle resolves all server events used in initialization. It also |
| + handles input device registration, screen registration. |
| + */ |
| + static void DisplayHandleGlobal(wl_display* display, |
| + uint32_t id, |
| + const char* interface, |
| + uint32_t version, |
| + void* data); |
| + /* Used by the compositor initialization to register the different visuals. |
| + */ |
| + static void CompositorHandleVisual(void* data, |
| + wl_compositor* compositor, |
| + uint32_t id, |
| + uint32_t token); |
| + /* Used when the shell requires configuration. This is called when a |
| + window is configured and receives its size. |
| + TODO(dnicoara) Need to look if there is one shell per window. Then it makes |
| + more sense to move this into the WaylandWindow and it would keep track |
| + of the shell. |
| + */ |
| + static void ShellHandleConfigure(void* data, |
| + wl_shell* shell, |
| + uint32_t time, |
| + uint32_t edges, |
| + wl_surface* surface, |
| + int32_t width, |
| + int32_t height); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); |
| +}; |
| + |
| +#endif |