ShellXcb.h revision 2f18b292ff155af7df35930474857b507dbf18fe
12f18b292ff155af7df35930474857b507dbf18feTony Barbour/*
22f18b292ff155af7df35930474857b507dbf18feTony Barbour * Copyright (C) 2016 Google, Inc.
32f18b292ff155af7df35930474857b507dbf18feTony Barbour *
42f18b292ff155af7df35930474857b507dbf18feTony Barbour * Permission is hereby granted, free of charge, to any person obtaining a
52f18b292ff155af7df35930474857b507dbf18feTony Barbour * copy of this software and associated documentation files (the "Software"),
62f18b292ff155af7df35930474857b507dbf18feTony Barbour * to deal in the Software without restriction, including without limitation
72f18b292ff155af7df35930474857b507dbf18feTony Barbour * the rights to use, copy, modify, merge, publish, distribute, sublicense,
82f18b292ff155af7df35930474857b507dbf18feTony Barbour * and/or sell copies of the Software, and to permit persons to whom the
92f18b292ff155af7df35930474857b507dbf18feTony Barbour * Software is furnished to do so, subject to the following conditions:
102f18b292ff155af7df35930474857b507dbf18feTony Barbour *
112f18b292ff155af7df35930474857b507dbf18feTony Barbour * The above copyright notice and this permission notice shall be included
122f18b292ff155af7df35930474857b507dbf18feTony Barbour * in all copies or substantial portions of the Software.
132f18b292ff155af7df35930474857b507dbf18feTony Barbour *
142f18b292ff155af7df35930474857b507dbf18feTony Barbour * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
152f18b292ff155af7df35930474857b507dbf18feTony Barbour * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
162f18b292ff155af7df35930474857b507dbf18feTony Barbour * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
172f18b292ff155af7df35930474857b507dbf18feTony Barbour * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
182f18b292ff155af7df35930474857b507dbf18feTony Barbour * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
192f18b292ff155af7df35930474857b507dbf18feTony Barbour * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
202f18b292ff155af7df35930474857b507dbf18feTony Barbour * DEALINGS IN THE SOFTWARE.
212f18b292ff155af7df35930474857b507dbf18feTony Barbour */
222f18b292ff155af7df35930474857b507dbf18feTony Barbour
232f18b292ff155af7df35930474857b507dbf18feTony Barbour#ifndef SHELL_XCB_H
242f18b292ff155af7df35930474857b507dbf18feTony Barbour#define SHELL_XCB_H
252f18b292ff155af7df35930474857b507dbf18feTony Barbour
262f18b292ff155af7df35930474857b507dbf18feTony Barbour#include <xcb/xcb.h>
272f18b292ff155af7df35930474857b507dbf18feTony Barbour#include "Shell.h"
282f18b292ff155af7df35930474857b507dbf18feTony Barbour
292f18b292ff155af7df35930474857b507dbf18feTony Barbourclass ShellXcb : public Shell {
302f18b292ff155af7df35930474857b507dbf18feTony Barbourpublic:
312f18b292ff155af7df35930474857b507dbf18feTony Barbour    ShellXcb(Game &game);
322f18b292ff155af7df35930474857b507dbf18feTony Barbour    ~ShellXcb();
332f18b292ff155af7df35930474857b507dbf18feTony Barbour
342f18b292ff155af7df35930474857b507dbf18feTony Barbour    void run();
352f18b292ff155af7df35930474857b507dbf18feTony Barbour    void quit() { quit_ = true; }
362f18b292ff155af7df35930474857b507dbf18feTony Barbour
372f18b292ff155af7df35930474857b507dbf18feTony Barbourprivate:
382f18b292ff155af7df35930474857b507dbf18feTony Barbour    void init_connection();
392f18b292ff155af7df35930474857b507dbf18feTony Barbour
402f18b292ff155af7df35930474857b507dbf18feTony Barbour    PFN_vkGetInstanceProcAddr load_vk();
412f18b292ff155af7df35930474857b507dbf18feTony Barbour    bool can_present(VkPhysicalDevice phy, uint32_t queue_family);
422f18b292ff155af7df35930474857b507dbf18feTony Barbour
432f18b292ff155af7df35930474857b507dbf18feTony Barbour    void create_window();
442f18b292ff155af7df35930474857b507dbf18feTony Barbour    VkSurfaceKHR create_surface(VkInstance instance);
452f18b292ff155af7df35930474857b507dbf18feTony Barbour
462f18b292ff155af7df35930474857b507dbf18feTony Barbour    void handle_event(const xcb_generic_event_t *ev);
472f18b292ff155af7df35930474857b507dbf18feTony Barbour    void loop_wait();
482f18b292ff155af7df35930474857b507dbf18feTony Barbour    void loop_poll();
492f18b292ff155af7df35930474857b507dbf18feTony Barbour
502f18b292ff155af7df35930474857b507dbf18feTony Barbour    xcb_connection_t *c_;
512f18b292ff155af7df35930474857b507dbf18feTony Barbour    xcb_screen_t *scr_;
522f18b292ff155af7df35930474857b507dbf18feTony Barbour    xcb_window_t win_;
532f18b292ff155af7df35930474857b507dbf18feTony Barbour
542f18b292ff155af7df35930474857b507dbf18feTony Barbour    xcb_atom_t wm_protocols_;
552f18b292ff155af7df35930474857b507dbf18feTony Barbour    xcb_atom_t wm_delete_window_;
562f18b292ff155af7df35930474857b507dbf18feTony Barbour
572f18b292ff155af7df35930474857b507dbf18feTony Barbour    void *lib_handle_;
582f18b292ff155af7df35930474857b507dbf18feTony Barbour
592f18b292ff155af7df35930474857b507dbf18feTony Barbour    bool quit_;
602f18b292ff155af7df35930474857b507dbf18feTony Barbour};
612f18b292ff155af7df35930474857b507dbf18feTony Barbour
622f18b292ff155af7df35930474857b507dbf18feTony Barbour#endif // SHELL_XCB_H
63