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(); 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 wl_display *display_; 46 wl_registry *registry_; 47 wl_compositor *compositor_; 48 wl_shell *shell_; 49 wl_surface *surface_; 50 wl_shell_surface *shell_surface_; 51 wl_seat *seat_; 52 wl_pointer *pointer_; 53 wl_keyboard *keyboard_; 54 55 static void handle_ping(void *data, wl_shell_surface *shell_surface, uint32_t serial); 56 static void handle_configure(void *data, wl_shell_surface *shell_surface, uint32_t edges, int32_t width, int32_t height); 57 static void handle_popup_done(void *data, wl_shell_surface *shell_surface); 58 static const wl_shell_surface_listener shell_surface_listener; 59 static void pointer_handle_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, 60 wl_fixed_t sx, wl_fixed_t sy); 61 static void pointer_handle_leave(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface); 62 static void pointer_handle_motion(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy); 63 static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, uint32_t time, uint32_t button, 64 uint32_t state); 65 static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value); 66 static const wl_pointer_listener pointer_listener; 67 static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size); 68 static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, 69 struct wl_array *keys); 70 static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface); 71 static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, 72 uint32_t state); 73 static void keyboard_handle_modifiers(void *data, wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, 74 uint32_t mods_latched, uint32_t mods_locked, uint32_t group); 75 static const wl_keyboard_listener keyboard_listener; 76 static void seat_handle_capabilities(void *data, wl_seat *seat, uint32_t caps); 77 static const wl_seat_listener seat_listener; 78 static void registry_handle_global(void *data, wl_registry *registry, uint32_t id, const char *interface, uint32_t version); 79 static void registry_handle_global_remove(void *data, wl_registry *registry, uint32_t name); 80 static const wl_registry_listener registry_listener; 81 }; 82 83 #endif // SHELL_WAYLAND_H 84