1 /* 2 * Copyright (C) 2016 Google, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SHELL_WAYLAND_H 18 #define SHELL_WAYLAND_H 19 20 #include "Shell.h" 21 22 class ShellWayland : public Shell { 23 public: 24 ShellWayland(Game &game); 25 ~ShellWayland(); 26 27 void run(); quit()28 void quit() { quit_ = true; } 29 30 private: 31 void init_connection(); 32 33 PFN_vkGetInstanceProcAddr load_vk(); 34 bool can_present(VkPhysicalDevice phy, uint32_t queue_family); 35 36 void create_window(); 37 VkSurfaceKHR create_surface(VkInstance instance); 38 39 void loop_wait(); 40 void loop_poll(); 41 42 void *lib_handle_; 43 bool quit_; 44 45 struct wl_display *display_; 46 struct wl_registry *registry_; 47 struct wl_compositor *compositor_; 48 struct wl_shell *shell_; 49 struct wl_surface *surface_; 50 struct wl_shell_surface *shell_surface_; 51 52 static void handle_global(void *data, struct wl_registry *registry, 53 uint32_t id, const char *interface, 54 uint32_t version); 55 static void handle_global_remove(void *data, struct wl_registry *registry, 56 uint32_t name); 57 static void handle_ping(void *data, struct wl_shell_surface *shell_surface, 58 uint32_t serial); 59 static void handle_configure(void *data, 60 struct wl_shell_surface *shell_surface, 61 uint32_t edges, int32_t width, int32_t height); 62 static void handle_popup_done(void *data, 63 struct wl_shell_surface *shell_surface); 64 65 static const struct wl_registry_listener registry_listener_; 66 static const struct wl_shell_surface_listener shell_surface_listener_; 67 }; 68 69 #endif // SHELL_WAYLAND_H 70