blob: 7ba4a920b695583dbc8d748b390166086997e535 [file] [log] [blame]
Tony Barbour2f18b292016-02-25 15:44:10 -07001/*
2 * Copyright (C) 2016 Google, Inc.
3 *
Jon Ashburn43b53e82016-04-19 11:30:31 -06004 * 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
Tony Barbour2f18b292016-02-25 15:44:10 -07007 *
Jon Ashburn43b53e82016-04-19 11:30:31 -06008 * http://www.apache.org/licenses/LICENSE-2.0
Tony Barbour2f18b292016-02-25 15:44:10 -07009 *
Jon Ashburn43b53e82016-04-19 11:30:31 -060010 * 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.
Tony Barbour2f18b292016-02-25 15:44:10 -070015 */
16
17#ifndef SHELL_XCB_H
18#define SHELL_XCB_H
19
20#include <xcb/xcb.h>
21#include "Shell.h"
22
23class ShellXcb : public Shell {
Mark Lobodzinskibc9caa52017-01-26 12:16:30 -070024 public:
Tony Barbour2f18b292016-02-25 15:44:10 -070025 ShellXcb(Game &game);
26 ~ShellXcb();
27
28 void run();
29 void quit() { quit_ = true; }
30
Mark Lobodzinskibc9caa52017-01-26 12:16:30 -070031 private:
Tony Barbour2f18b292016-02-25 15:44:10 -070032 void init_connection();
33
34 PFN_vkGetInstanceProcAddr load_vk();
35 bool can_present(VkPhysicalDevice phy, uint32_t queue_family);
36
37 void create_window();
38 VkSurfaceKHR create_surface(VkInstance instance);
39
40 void handle_event(const xcb_generic_event_t *ev);
41 void loop_wait();
42 void loop_poll();
43
44 xcb_connection_t *c_;
45 xcb_screen_t *scr_;
46 xcb_window_t win_;
47
48 xcb_atom_t wm_protocols_;
49 xcb_atom_t wm_delete_window_;
50
51 void *lib_handle_;
52
53 bool quit_;
54};
55
56#endif // SHELL_XCB_H