Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow simultaneous X11 and Wayland support #3152

Merged
merged 8 commits into from
Aug 17, 2023

Conversation

belegdol
Copy link
Contributor

@belegdol belegdol commented Aug 3, 2023

XWayland detection is a hack currently. Feedback is welcome how to do this in a less ugly way

@belegdol
Copy link
Contributor Author

belegdol commented Aug 3, 2023

XWayland "detection" fails for mame for example so it definitely needs to be improved. Suggestions are welcome.

@bkaradzic
Copy link
Owner

Actually I was thinking about this, and maybe would be worth adding type of handle inside PlatformData. To specify which handle is passed.

@belegdol
Copy link
Contributor Author

belegdol commented Aug 3, 2023

I think this would be ideal. Anything else is going to be a workaround to some extent. Do you have something like my original attempt in #3143 in mind?

@bkaradzic
Copy link
Owner

Not original because you were adding new field for specific type of window handle. What I'm thinking just one enum to identify pointer type. Since all platforms have one type it would be default (on Linux default would mean X11) and if you passing Wayland handle on Linux you would specify with enum.

struct NativeWindowHandleType
{
     enum Enum
     {
           Default = 0,
           Wayland,
           
           Count
     };
};

@belegdol
Copy link
Contributor Author

belegdol commented Aug 4, 2023

Something like this? If so, I will add the code to other examples.

belegdol referenced this pull request Aug 15, 2023
@belegdol
Copy link
Contributor Author

I have added the code to the remaining entries and the remaining examples.

@bkaradzic bkaradzic merged commit f4d4639 into bkaradzic:master Aug 17, 2023
13 checks passed
@bkaradzic
Copy link
Owner

Submit another PR where you use BX_UNUSED(_handle) on code like this:

	bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
	{
		return bgfx::NativeWindowHandleType::Default;
	}

@belegdol belegdol deleted the wayland_at_runtime branch August 17, 2023 15:56
@belegdol
Copy link
Contributor Author

Submit another PR where you use BX_UNUSED(_handle) on code like this:

	bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
	{
		return bgfx::NativeWindowHandleType::Default;
	}

I just tried but this results in SIGILL:

	bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
	{
		BX_UNUSED(_handle);
	}

@bkaradzic
Copy link
Owner

BX_UNUSED is just for handle, you don't need to change anything else...

@bkaradzic
Copy link
Owner

	bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
	{
	        BX_UNUSED(_handle); <--- prevents warnings about unused argument...
		return bgfx::NativeWindowHandleType::Default;
	}

@bkaradzic
Copy link
Owner

See: cbfea75

jay3d pushed a commit to jay3d/bgfx that referenced this pull request Dec 7, 2023
* Allow simultaneous X11 and Wayland support

* Add NativeWindowHandleType

* Set default value for g_platformData.type

* Use g_platformData.type to check for a native Wayland window

* Stub getNativeWindowHandleType on platform where Wayland is not an option

* Implement getNativeWindowHandleType for GLFW

* Add getNativeWindowHandleType to the remaining C++ examples

* Add getNativeWindowHandleType to the C example
mipek pushed a commit to mipek/bgfx that referenced this pull request Mar 2, 2024
* Allow simultaneous X11 and Wayland support

* Add NativeWindowHandleType

* Set default value for g_platformData.type

* Use g_platformData.type to check for a native Wayland window

* Stub getNativeWindowHandleType on platform where Wayland is not an option

* Implement getNativeWindowHandleType for GLFW

* Add getNativeWindowHandleType to the remaining C++ examples

* Add getNativeWindowHandleType to the C example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants