mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-03-03 21:26:36 +00:00
c/main: Remove comp_window struct
This commit is contained in:
parent
9302bfa028
commit
d60ae941f1
|
@ -1054,21 +1054,18 @@ compositor_check_vulkan_caps(struct comp_compositor *c)
|
|||
}
|
||||
|
||||
static bool
|
||||
compositor_try_window(struct comp_compositor *c, struct comp_window *window)
|
||||
compositor_try_window(struct comp_compositor *c, struct comp_target *ct)
|
||||
{
|
||||
if (window == NULL) {
|
||||
if (ct == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct comp_target *ct = &window->swapchain.base;
|
||||
|
||||
if (!comp_target_init_pre_vulkan(ct)) {
|
||||
ct->destroy(ct);
|
||||
return false;
|
||||
}
|
||||
|
||||
COMP_DEBUG(c, "Window backend %s initialized!",
|
||||
window->swapchain.base.name);
|
||||
COMP_DEBUG(c, "Window backend %s initialized!", ct->name);
|
||||
|
||||
c->target = ct;
|
||||
|
||||
|
|
|
@ -20,25 +20,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Structs
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @interface comp_window
|
||||
* A output device or a window, often directly connected to the device.
|
||||
*
|
||||
* @ingroup comp_main
|
||||
*/
|
||||
struct comp_window
|
||||
{
|
||||
//! This has to be first.
|
||||
struct comp_target_swapchain swapchain;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Functions.
|
||||
|
@ -52,7 +33,7 @@ struct comp_window
|
|||
* @ingroup comp_main
|
||||
* @public @memberof comp_window_xcb
|
||||
*/
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_xcb_create(struct comp_compositor *c);
|
||||
#endif
|
||||
|
||||
|
@ -63,7 +44,7 @@ comp_window_xcb_create(struct comp_compositor *c);
|
|||
* @ingroup comp_main
|
||||
* @public @memberof comp_window_wayland
|
||||
*/
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_wayland_create(struct comp_compositor *c);
|
||||
#endif
|
||||
|
||||
|
@ -74,7 +55,7 @@ comp_window_wayland_create(struct comp_compositor *c);
|
|||
* @ingroup comp_main
|
||||
* @public @memberof comp_window_direct_randr
|
||||
*/
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_direct_randr_create(struct comp_compositor *c);
|
||||
|
||||
/*!
|
||||
|
@ -83,7 +64,7 @@ comp_window_direct_randr_create(struct comp_compositor *c);
|
|||
* @ingroup comp_main
|
||||
* @public @memberof comp_window_direct_nvidia
|
||||
*/
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_direct_nvidia_create(struct comp_compositor *c);
|
||||
#endif
|
||||
|
||||
|
@ -96,7 +77,7 @@ comp_window_direct_nvidia_create(struct comp_compositor *c);
|
|||
* @ingroup comp_main
|
||||
* @public @memberof comp_window_android
|
||||
*/
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_android_create(struct comp_compositor *c);
|
||||
|
||||
#endif // XRT_OS_ANDROID
|
||||
|
|
|
@ -32,11 +32,12 @@
|
|||
/*!
|
||||
* An Android window.
|
||||
*
|
||||
* @implements comp_window
|
||||
* @implements comp_target_swapchain
|
||||
*/
|
||||
struct comp_window_android
|
||||
{
|
||||
struct comp_window base;
|
||||
struct comp_target_swapchain base;
|
||||
|
||||
struct android_custom_surface *custom_surface;
|
||||
};
|
||||
|
||||
|
@ -59,7 +60,7 @@ comp_window_android_destroy(struct comp_target *ct)
|
|||
{
|
||||
struct comp_window_android *cwa = (struct comp_window_android *)ct;
|
||||
|
||||
comp_target_swapchain_cleanup(&cwa->base.swapchain);
|
||||
comp_target_swapchain_cleanup(&cwa->base);
|
||||
|
||||
android_custom_surface_destroy(&cwa->custom_surface);
|
||||
|
||||
|
@ -77,13 +78,13 @@ static VkResult
|
|||
comp_window_android_create_surface(struct comp_window_android *w,
|
||||
VkSurfaceKHR *vk_surface)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.swapchain.vk;
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
VkResult ret;
|
||||
w->custom_surface = android_custom_surface_async_start(
|
||||
android_globals_get_vm(), android_globals_get_activity());
|
||||
if (w->custom_surface == NULL) {
|
||||
COMP_ERROR(
|
||||
w->base.swapchain.base.c,
|
||||
w->base.base.c,
|
||||
"comp_window_android_create_surface: could not "
|
||||
"start asynchronous attachment of our custom surface");
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
@ -91,7 +92,7 @@ comp_window_android_create_surface(struct comp_window_android *w,
|
|||
struct ANativeWindow *window =
|
||||
android_custom_surface_wait_get_surface(w->custom_surface, 2000);
|
||||
if (window == NULL) {
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
COMP_ERROR(w->base.base.c,
|
||||
"comp_window_android_create_surface: could not "
|
||||
"convert surface to ANativeWindow");
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
@ -105,8 +106,7 @@ comp_window_android_create_surface(struct comp_window_android *w,
|
|||
ret = vk->vkCreateAndroidSurfaceKHR(vk->instance, &surface_info, NULL,
|
||||
vk_surface);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
"vkCreateAndroidSurfaceKHR: %s",
|
||||
COMP_ERROR(w->base.base.c, "vkCreateAndroidSurfaceKHR: %s",
|
||||
vk_result_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ comp_window_android_init_swapchain(struct comp_target *ct,
|
|||
{
|
||||
struct comp_window_android *w_android =
|
||||
(struct comp_window_android *)ct;
|
||||
struct comp_window *w = &w_android->base;
|
||||
VkResult ret;
|
||||
|
||||
ret = comp_window_android_create_surface(w_android,
|
||||
&w->swapchain.surface.handle);
|
||||
ret = comp_window_android_create_surface( //
|
||||
w_android, //
|
||||
&w_android->base.surface.handle); //
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(ct->c, "Failed to create surface!");
|
||||
return false;
|
||||
|
@ -141,23 +141,21 @@ comp_window_android_flush(struct comp_target *ct)
|
|||
(void)ct;
|
||||
}
|
||||
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_android_create(struct comp_compositor *c)
|
||||
{
|
||||
struct comp_window_android *w =
|
||||
U_TYPED_CALLOC(struct comp_window_android);
|
||||
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base.swapchain);
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base);
|
||||
|
||||
w->base.swapchain.base.name = "Android";
|
||||
w->base.swapchain.base.destroy = comp_window_android_destroy;
|
||||
w->base.swapchain.base.flush = comp_window_android_flush;
|
||||
w->base.swapchain.base.init_pre_vulkan = comp_window_android_init;
|
||||
w->base.swapchain.base.init_post_vulkan =
|
||||
comp_window_android_init_swapchain;
|
||||
w->base.swapchain.base.set_title =
|
||||
comp_window_android_update_window_title;
|
||||
w->base.swapchain.base.c = c;
|
||||
w->base.base.name = "Android";
|
||||
w->base.base.destroy = comp_window_android_destroy;
|
||||
w->base.base.flush = comp_window_android_flush;
|
||||
w->base.base.init_pre_vulkan = comp_window_android_init;
|
||||
w->base.base.init_post_vulkan = comp_window_android_init_swapchain;
|
||||
w->base.base.set_title = comp_window_android_update_window_title;
|
||||
w->base.base.c = c;
|
||||
|
||||
return &w->base;
|
||||
return &w->base.base;
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ struct comp_window_direct_nvidia_display
|
|||
* Direct mode "window" into a device, using Vulkan direct mode extension
|
||||
* and xcb.
|
||||
*
|
||||
* @implements comp_window
|
||||
* @implements comp_target_swapchain
|
||||
*/
|
||||
struct comp_window_direct_nvidia
|
||||
{
|
||||
struct comp_window base;
|
||||
struct comp_target_swapchain base;
|
||||
|
||||
Display *dpy;
|
||||
struct comp_window_direct_nvidia_display *displays;
|
||||
|
@ -83,24 +83,24 @@ _update_window_title(struct comp_target *ct, const char *title)
|
|||
(void)title;
|
||||
}
|
||||
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_direct_nvidia_create(struct comp_compositor *c)
|
||||
{
|
||||
struct comp_window_direct_nvidia *w =
|
||||
U_TYPED_CALLOC(struct comp_window_direct_nvidia);
|
||||
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base.swapchain);
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base);
|
||||
|
||||
w->base.swapchain.base.name = "direct";
|
||||
w->base.swapchain.base.destroy = comp_window_direct_nvidia_destroy;
|
||||
w->base.swapchain.base.flush = _flush;
|
||||
w->base.swapchain.base.init_pre_vulkan = comp_window_direct_nvidia_init;
|
||||
w->base.swapchain.base.init_post_vulkan =
|
||||
w->base.base.name = "direct";
|
||||
w->base.base.destroy = comp_window_direct_nvidia_destroy;
|
||||
w->base.base.flush = _flush;
|
||||
w->base.base.init_pre_vulkan = comp_window_direct_nvidia_init;
|
||||
w->base.base.init_post_vulkan =
|
||||
comp_window_direct_nvidia_init_swapchain;
|
||||
w->base.swapchain.base.set_title = _update_window_title;
|
||||
w->base.swapchain.base.c = c;
|
||||
w->base.base.set_title = _update_window_title;
|
||||
w->base.base.c = c;
|
||||
|
||||
return &w->base;
|
||||
return &w->base.base;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -109,7 +109,7 @@ comp_window_direct_nvidia_destroy(struct comp_target *ct)
|
|||
struct comp_window_direct_nvidia *w_direct =
|
||||
(struct comp_window_direct_nvidia *)ct;
|
||||
|
||||
comp_target_swapchain_cleanup(&w_direct->base.swapchain);
|
||||
comp_target_swapchain_cleanup(&w_direct->base);
|
||||
|
||||
for (uint32_t i = 0; i < w_direct->num_displays; i++) {
|
||||
struct comp_window_direct_nvidia_display *d =
|
||||
|
@ -143,9 +143,9 @@ append_nvidia_entry_on_match(struct comp_window_direct_nvidia *w,
|
|||
return false;
|
||||
|
||||
// we have a match with this whitelist entry.
|
||||
w->base.swapchain.base.c->settings.preferred.width =
|
||||
w->base.base.c->settings.preferred.width =
|
||||
disp->physicalResolution.width;
|
||||
w->base.swapchain.base.c->settings.preferred.height =
|
||||
w->base.base.c->settings.preferred.height =
|
||||
disp->physicalResolution.height;
|
||||
struct comp_window_direct_nvidia_display d = {
|
||||
.name = U_TYPED_ARRAY_CALLOC(char, disp_entry_length + 1),
|
||||
|
@ -183,8 +183,7 @@ comp_window_direct_nvidia_init(struct comp_target *ct)
|
|||
}
|
||||
|
||||
|
||||
if (!comp_window_direct_connect(&w_direct->base.swapchain,
|
||||
&w_direct->dpy)) {
|
||||
if (!comp_window_direct_connect(&w_direct->base, &w_direct->dpy)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -239,7 +238,7 @@ comp_window_direct_nvidia_init(struct comp_target *ct)
|
|||
static struct comp_window_direct_nvidia_display *
|
||||
comp_window_direct_nvidia_current_display(struct comp_window_direct_nvidia *w)
|
||||
{
|
||||
int index = w->base.swapchain.base.c->settings.display;
|
||||
int index = w->base.base.c->settings.display;
|
||||
if (index == -1)
|
||||
index = 0;
|
||||
|
||||
|
@ -256,9 +255,8 @@ comp_window_direct_nvidia_init_swapchain(struct comp_target *ct,
|
|||
{
|
||||
struct comp_window_direct_nvidia *w_direct =
|
||||
(struct comp_window_direct_nvidia *)ct;
|
||||
struct comp_window *w = &w_direct->base;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w->swapchain, &ct->c->vk);
|
||||
comp_target_swapchain_init_post_vulkan(&w_direct->base, &ct->c->vk);
|
||||
|
||||
struct comp_window_direct_nvidia_display *d =
|
||||
comp_window_direct_nvidia_current_display(w_direct);
|
||||
|
@ -269,7 +267,6 @@ comp_window_direct_nvidia_init_swapchain(struct comp_target *ct,
|
|||
|
||||
COMP_DEBUG(ct->c, "Will use display: %s", d->name);
|
||||
|
||||
return comp_window_direct_init_swapchain(&w_direct->base.swapchain,
|
||||
w_direct->dpy, d->display,
|
||||
width, height);
|
||||
return comp_window_direct_init_swapchain(&w_direct->base, w_direct->dpy,
|
||||
d->display, width, height);
|
||||
}
|
||||
|
|
|
@ -40,11 +40,11 @@ struct comp_window_direct_randr_display
|
|||
* Direct mode "window" into a device, using Vulkan direct mode extension
|
||||
* and xcb.
|
||||
*
|
||||
* @implements comp_window
|
||||
* @implements comp_target_swapchain
|
||||
*/
|
||||
struct comp_window_direct_randr
|
||||
{
|
||||
struct comp_window base;
|
||||
struct comp_target_swapchain base;
|
||||
|
||||
Display *dpy;
|
||||
xcb_screen_t *screen;
|
||||
|
@ -105,24 +105,23 @@ _update_window_title(struct comp_target *ct, const char *title)
|
|||
(void)title;
|
||||
}
|
||||
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_direct_randr_create(struct comp_compositor *c)
|
||||
{
|
||||
struct comp_window_direct_randr *w =
|
||||
U_TYPED_CALLOC(struct comp_window_direct_randr);
|
||||
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base.swapchain);
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base);
|
||||
|
||||
w->base.swapchain.base.name = "direct";
|
||||
w->base.swapchain.base.destroy = comp_window_direct_randr_destroy;
|
||||
w->base.swapchain.base.flush = _flush;
|
||||
w->base.swapchain.base.init_pre_vulkan = comp_window_direct_randr_init;
|
||||
w->base.swapchain.base.init_post_vulkan =
|
||||
comp_window_direct_randr_init_swapchain;
|
||||
w->base.swapchain.base.set_title = _update_window_title;
|
||||
w->base.swapchain.base.c = c;
|
||||
w->base.base.name = "direct";
|
||||
w->base.base.destroy = comp_window_direct_randr_destroy;
|
||||
w->base.base.flush = _flush;
|
||||
w->base.base.init_pre_vulkan = comp_window_direct_randr_init;
|
||||
w->base.base.init_post_vulkan = comp_window_direct_randr_init_swapchain;
|
||||
w->base.base.set_title = _update_window_title;
|
||||
w->base.base.c = c;
|
||||
|
||||
return &w->base;
|
||||
return &w->base.base;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,9 +130,9 @@ comp_window_direct_randr_destroy(struct comp_target *ct)
|
|||
struct comp_window_direct_randr *w_direct =
|
||||
(struct comp_window_direct_randr *)ct;
|
||||
|
||||
comp_target_swapchain_cleanup(&w_direct->base.swapchain);
|
||||
comp_target_swapchain_cleanup(&w_direct->base);
|
||||
|
||||
struct vk_bundle *vk = w_direct->base.swapchain.vk;
|
||||
struct vk_bundle *vk = w_direct->base.vk;
|
||||
|
||||
for (uint32_t i = 0; i < w_direct->num_displays; i++) {
|
||||
struct comp_window_direct_randr_display *d =
|
||||
|
@ -166,7 +165,7 @@ comp_window_direct_randr_list_screens(struct comp_window_direct_randr *w)
|
|||
const struct comp_window_direct_randr_display *d =
|
||||
&w->displays[i];
|
||||
COMP_DEBUG(
|
||||
w->base.swapchain.base.c, "%d: %s %dx%d@%.2f", i, d->name,
|
||||
w->base.base.c, "%d: %s %dx%d@%.2f", i, d->name,
|
||||
d->primary_mode.width, d->primary_mode.height,
|
||||
(double)d->primary_mode.dot_clock /
|
||||
(d->primary_mode.htotal * d->primary_mode.vtotal));
|
||||
|
@ -186,8 +185,7 @@ comp_window_direct_randr_init(struct comp_target *ct)
|
|||
}
|
||||
|
||||
|
||||
if (!comp_window_direct_connect(&w_direct->base.swapchain,
|
||||
&w_direct->dpy)) {
|
||||
if (!comp_window_direct_connect(&w_direct->base, &w_direct->dpy)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -235,7 +233,7 @@ comp_window_direct_randr_init(struct comp_target *ct)
|
|||
static struct comp_window_direct_randr_display *
|
||||
comp_window_direct_randr_current_display(struct comp_window_direct_randr *w)
|
||||
{
|
||||
int index = w->base.swapchain.base.c->settings.display;
|
||||
int index = w->base.base.c->settings.display;
|
||||
if (index == -1)
|
||||
index = 0;
|
||||
|
||||
|
@ -252,9 +250,8 @@ comp_window_direct_randr_init_swapchain(struct comp_target *ct,
|
|||
{
|
||||
struct comp_window_direct_randr *w_direct =
|
||||
(struct comp_window_direct_randr *)ct;
|
||||
struct comp_window *w = &w_direct->base;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w->swapchain, &ct->c->vk);
|
||||
comp_target_swapchain_init_post_vulkan(&w_direct->base, &ct->c->vk);
|
||||
|
||||
struct comp_window_direct_randr_display *d =
|
||||
comp_window_direct_randr_current_display(w_direct);
|
||||
|
@ -274,7 +271,7 @@ comp_window_direct_randr_init_swapchain(struct comp_target *ct,
|
|||
return false;
|
||||
}
|
||||
|
||||
return comp_window_direct_init_swapchain(&w->swapchain, w_direct->dpy,
|
||||
return comp_window_direct_init_swapchain(&w_direct->base, w_direct->dpy,
|
||||
d->display, width, height);
|
||||
}
|
||||
|
||||
|
@ -282,21 +279,20 @@ static VkDisplayKHR
|
|||
comp_window_direct_randr_get_output(struct comp_window_direct_randr *w,
|
||||
RROutput output)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.swapchain.vk;
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
VkResult ret;
|
||||
|
||||
VkDisplayKHR display;
|
||||
ret = vk->vkGetRandROutputDisplayEXT(
|
||||
w->base.swapchain.vk->physical_device, w->dpy, output, &display);
|
||||
ret = vk->vkGetRandROutputDisplayEXT(w->base.vk->physical_device,
|
||||
w->dpy, output, &display);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
"vkGetRandROutputDisplayEXT: %s",
|
||||
COMP_ERROR(w->base.base.c, "vkGetRandROutputDisplayEXT: %s",
|
||||
vk_result_string(ret));
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (display == VK_NULL_HANDLE) {
|
||||
COMP_DEBUG(w->base.swapchain.base.c,
|
||||
COMP_DEBUG(w->base.base.c,
|
||||
"vkGetRandROutputDisplayEXT"
|
||||
" returned a null display! 0x%016" PRIx64,
|
||||
(uint64_t)display);
|
||||
|
@ -320,7 +316,7 @@ append_randr_display(struct comp_window_direct_randr *w,
|
|||
|
||||
int num_modes = xcb_randr_get_output_info_modes_length(output_reply);
|
||||
if (num_modes == 0) {
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
COMP_ERROR(w->base.base.c,
|
||||
"%s does not have any modes "
|
||||
"available. "
|
||||
"Check `xrandr --prop`.",
|
||||
|
@ -338,8 +334,8 @@ append_randr_display(struct comp_window_direct_randr *w,
|
|||
mode_info = &mode_infos[i];
|
||||
|
||||
if (mode_info == NULL)
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
"No mode with id %d found??", output_modes[0]);
|
||||
COMP_ERROR(w->base.base.c, "No mode with id %d found??",
|
||||
output_modes[0]);
|
||||
|
||||
|
||||
struct comp_window_direct_randr_display d = {
|
||||
|
@ -359,7 +355,7 @@ append_randr_display(struct comp_window_direct_randr *w,
|
|||
w->num_displays);
|
||||
|
||||
if (w->displays == NULL)
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
COMP_ERROR(w->base.base.c,
|
||||
"Unable to reallocate randr_displays");
|
||||
|
||||
w->displays[w->num_displays - 1] = d;
|
||||
|
@ -368,7 +364,7 @@ append_randr_display(struct comp_window_direct_randr *w,
|
|||
static void
|
||||
comp_window_direct_randr_get_outputs(struct comp_window_direct_randr *w)
|
||||
{
|
||||
struct comp_target *ct = &w->base.swapchain.base;
|
||||
struct comp_target *ct = &w->base.base;
|
||||
|
||||
xcb_connection_t *connection = XGetXCBConnection(w->dpy);
|
||||
xcb_randr_query_version_cookie_t version_cookie =
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
/*!
|
||||
* A Wayland connection and window.
|
||||
*
|
||||
* @implements comp_window
|
||||
* @implements comp_target_swapchain
|
||||
*/
|
||||
struct comp_window_wayland
|
||||
{
|
||||
struct comp_window base;
|
||||
struct comp_target_swapchain base;
|
||||
|
||||
struct wl_display *display;
|
||||
struct wl_compositor *compositor;
|
||||
|
@ -97,23 +97,21 @@ comp_window_wayland_configure(struct comp_window_wayland *w,
|
|||
*
|
||||
*/
|
||||
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_wayland_create(struct comp_compositor *c)
|
||||
{
|
||||
struct comp_window_wayland *w =
|
||||
U_TYPED_CALLOC(struct comp_window_wayland);
|
||||
|
||||
w->base.swapchain.base.name = "wayland";
|
||||
w->base.swapchain.base.destroy = comp_window_wayland_destroy;
|
||||
w->base.swapchain.base.flush = comp_window_wayland_flush;
|
||||
w->base.swapchain.base.init_pre_vulkan = comp_window_wayland_init;
|
||||
w->base.swapchain.base.init_post_vulkan =
|
||||
comp_window_wayland_init_swapchain;
|
||||
w->base.swapchain.base.set_title =
|
||||
comp_window_wayland_update_window_title;
|
||||
w->base.swapchain.base.c = c;
|
||||
w->base.base.name = "wayland";
|
||||
w->base.base.destroy = comp_window_wayland_destroy;
|
||||
w->base.base.flush = comp_window_wayland_flush;
|
||||
w->base.base.init_pre_vulkan = comp_window_wayland_init;
|
||||
w->base.base.init_post_vulkan = comp_window_wayland_init_swapchain;
|
||||
w->base.base.set_title = comp_window_wayland_update_window_title;
|
||||
w->base.base.c = c;
|
||||
|
||||
return &w->base;
|
||||
return &w->base.base;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -121,7 +119,7 @@ comp_window_wayland_destroy(struct comp_target *ct)
|
|||
{
|
||||
struct comp_window_wayland *cww = (struct comp_window_wayland *)ct;
|
||||
|
||||
comp_target_swapchain_cleanup(&cww->base.swapchain);
|
||||
comp_target_swapchain_cleanup(&cww->base);
|
||||
|
||||
if (cww->surface) {
|
||||
wl_surface_destroy(cww->surface);
|
||||
|
@ -204,13 +202,12 @@ comp_window_wayland_init_swapchain(struct comp_target *ct,
|
|||
{
|
||||
struct comp_window_wayland *w_wayland =
|
||||
(struct comp_window_wayland *)ct;
|
||||
struct comp_window *w = &w_wayland->base;
|
||||
VkResult ret;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w->swapchain, &ct->c->vk);
|
||||
comp_target_swapchain_init_post_vulkan(&w_wayland->base, &ct->c->vk);
|
||||
|
||||
ret = comp_window_wayland_create_surface(w_wayland,
|
||||
&w->swapchain.surface.handle);
|
||||
ret = comp_window_wayland_create_surface(
|
||||
w_wayland, &w_wayland->base.surface.handle);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(ct->c, "Failed to create surface!");
|
||||
return false;
|
||||
|
@ -226,7 +223,7 @@ static VkResult
|
|||
comp_window_wayland_create_surface(struct comp_window_wayland *w,
|
||||
VkSurfaceKHR *vk_surface)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.swapchain.vk;
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
VkResult ret;
|
||||
|
||||
VkWaylandSurfaceCreateInfoKHR surface_info = {
|
||||
|
@ -365,9 +362,8 @@ comp_window_wayland_configure(struct comp_window_wayland *w,
|
|||
int32_t width,
|
||||
int32_t height)
|
||||
{
|
||||
if (w->base.swapchain.base.c->settings.fullscreen &&
|
||||
!w->fullscreen_requested) {
|
||||
COMP_DEBUG(w->base.swapchain.base.c, "Setting full screen");
|
||||
if (w->base.base.c->settings.fullscreen && !w->fullscreen_requested) {
|
||||
COMP_DEBUG(w->base.base.c, "Setting full screen");
|
||||
comp_window_wayland_fullscreen(w);
|
||||
w->fullscreen_requested = true;
|
||||
}
|
||||
|
|
|
@ -44,11 +44,11 @@ struct comp_window_xcb_display
|
|||
/*!
|
||||
* A xcb connection and window.
|
||||
*
|
||||
* @implements comp_window
|
||||
* @implements comp_target_swapchain
|
||||
*/
|
||||
struct comp_window_xcb
|
||||
{
|
||||
struct comp_window base;
|
||||
struct comp_target_swapchain base;
|
||||
|
||||
xcb_connection_t *connection;
|
||||
xcb_window_t window;
|
||||
|
@ -122,23 +122,23 @@ comp_window_xcb_update_window_title(struct comp_target *ct, const char *title);
|
|||
*
|
||||
*/
|
||||
|
||||
struct comp_window *
|
||||
struct comp_target *
|
||||
comp_window_xcb_create(struct comp_compositor *c)
|
||||
{
|
||||
struct comp_window_xcb *w = U_TYPED_CALLOC(struct comp_window_xcb);
|
||||
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base.swapchain);
|
||||
comp_target_swapchain_init_set_fnptrs(&w->base);
|
||||
|
||||
w->base.swapchain.base.name = "xcb";
|
||||
w->base.swapchain.base.destroy = comp_window_xcb_destroy;
|
||||
w->base.swapchain.base.flush = comp_window_xcb_flush;
|
||||
w->base.swapchain.base.init_pre_vulkan = comp_window_xcb_init;
|
||||
w->base.swapchain.base.init_post_vulkan =
|
||||
w->base.base.name = "xcb";
|
||||
w->base.base.destroy = comp_window_xcb_destroy;
|
||||
w->base.base.flush = comp_window_xcb_flush;
|
||||
w->base.base.init_pre_vulkan = comp_window_xcb_init;
|
||||
w->base.base.init_post_vulkan =
|
||||
comp_window_xcb_init_swapchain;
|
||||
w->base.swapchain.base.set_title = comp_window_xcb_update_window_title;
|
||||
w->base.swapchain.base.c = c;
|
||||
w->base.base.set_title = comp_window_xcb_update_window_title;
|
||||
w->base.base.c = c;
|
||||
|
||||
return &w->base;
|
||||
return &w->base.base;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -146,7 +146,7 @@ comp_window_xcb_destroy(struct comp_target *ct)
|
|||
{
|
||||
struct comp_window_xcb *w_xcb = (struct comp_window_xcb *)ct;
|
||||
|
||||
comp_target_swapchain_cleanup(&w_xcb->base.swapchain);
|
||||
comp_target_swapchain_cleanup(&w_xcb->base);
|
||||
|
||||
xcb_destroy_window(w_xcb->connection, w_xcb->window);
|
||||
xcb_disconnect(w_xcb->connection);
|
||||
|
@ -162,13 +162,13 @@ comp_window_xcb_destroy(struct comp_target *ct)
|
|||
static void
|
||||
comp_window_xcb_list_screens(struct comp_window_xcb *w, xcb_screen_t *screen)
|
||||
{
|
||||
COMP_DEBUG(w->base.swapchain.base.c, "Screen 0 %dx%d",
|
||||
COMP_DEBUG(w->base.base.c, "Screen 0 %dx%d",
|
||||
screen->width_in_pixels, screen->height_in_pixels);
|
||||
comp_window_xcb_get_randr_outputs(w);
|
||||
|
||||
for (uint16_t i = 0; i < w->num_displays; i++) {
|
||||
struct comp_window_xcb_display *d = &w->displays[i];
|
||||
COMP_DEBUG(w->base.swapchain.base.c, "%d: %s %dx%d [%d, %d]", i,
|
||||
COMP_DEBUG(w->base.base.c, "%d: %s %dx%d [%d, %d]", i,
|
||||
d->name, d->size.width, d->size.height,
|
||||
d->position.x, d->position.y);
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ comp_window_xcb_init(struct comp_target *ct)
|
|||
static struct comp_window_xcb_display *
|
||||
comp_window_xcb_current_display(struct comp_window_xcb *w)
|
||||
{
|
||||
return &w->displays[w->base.swapchain.base.c->settings.display];
|
||||
return &w->displays[w->base.base.c->settings.display];
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -246,13 +246,12 @@ comp_window_xcb_init_swapchain(struct comp_target *ct,
|
|||
uint32_t height)
|
||||
{
|
||||
struct comp_window_xcb *w_xcb = (struct comp_window_xcb *)ct;
|
||||
struct comp_window *w = &w_xcb->base;
|
||||
VkResult ret;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w->swapchain, &ct->c->vk);
|
||||
comp_target_swapchain_init_post_vulkan(&w_xcb->base, &ct->c->vk);
|
||||
|
||||
ret =
|
||||
comp_window_xcb_create_surface(w_xcb, &w->swapchain.surface.handle);
|
||||
comp_window_xcb_create_surface(w_xcb, &w_xcb->base.surface.handle);
|
||||
if (ret != VK_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
@ -277,7 +276,7 @@ comp_window_xcb_create_window(struct comp_window_xcb *w,
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
if (w->base.swapchain.base.c->settings.fullscreen) {
|
||||
if (w->base.base.c->settings.fullscreen) {
|
||||
x = comp_window_xcb_current_display(w)->position.x;
|
||||
y = comp_window_xcb_current_display(w)->position.y;
|
||||
}
|
||||
|
@ -304,7 +303,7 @@ comp_window_xcb_get_randr_outputs(struct comp_window_xcb *w)
|
|||
w->num_displays =
|
||||
xcb_randr_get_screen_resources_outputs_length(resources_reply);
|
||||
if (w->num_displays < 1)
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
COMP_ERROR(w->base.base.c,
|
||||
"Failed to retrieve randr outputs");
|
||||
|
||||
w->displays =
|
||||
|
@ -395,7 +394,7 @@ comp_window_xcb_get_atom(struct comp_window_xcb *w, const char *name)
|
|||
static VkResult
|
||||
comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *surface)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.swapchain.vk;
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
VkResult ret;
|
||||
|
||||
VkXcbSurfaceCreateInfoKHR surface_info = {
|
||||
|
@ -407,7 +406,7 @@ comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *surface)
|
|||
ret = vk->vkCreateXcbSurfaceKHR(vk->instance, &surface_info, NULL,
|
||||
surface);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(w->base.swapchain.base.c,
|
||||
COMP_ERROR(w->base.base.c,
|
||||
"vkCreateXcbSurfaceKHR: %s", vk_result_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue