Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions simulate/glfw_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ int MaybeGlfwInit() {
GlfwAdapter& GlfwAdapterFromWindow(GLFWwindow* window) {
return *static_cast<GlfwAdapter*>(Glfw().glfwGetWindowUserPointer(window));
}

bool WindowPositionAvailable() {
#if GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)
return Glfw().glfwGetPlatform() != GLFW_PLATFORM_WAYLAND;
#else
return true;
#endif
}
} // namespace

GlfwAdapter::GlfwAdapter() {
Expand All @@ -65,7 +73,9 @@ GlfwAdapter::GlfwAdapter() {
}

// save window position and size
Glfw().glfwGetWindowPos(window_, &window_pos_.first, &window_pos_.second);
if (WindowPositionAvailable()) {
Glfw().glfwGetWindowPos(window_, &window_pos_.first, &window_pos_.second);
}
Glfw().glfwGetWindowSize(window_, &window_size_.first, &window_size_.second);

// set callbacks
Expand Down Expand Up @@ -193,7 +203,9 @@ void GlfwAdapter::ToggleFullscreen() {
// currently windowed: switch to full screen
else {
// save window data
Glfw().glfwGetWindowPos(window_, &window_pos_.first, &window_pos_.second);
if (WindowPositionAvailable()) {
Glfw().glfwGetWindowPos(window_, &window_pos_.first, &window_pos_.second);
}
Glfw().glfwGetWindowSize(window_, &window_size_.first,
&window_size_.second);

Expand Down
3 changes: 3 additions & 0 deletions simulate/glfw_dispatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ const struct Glfw& Glfw(void* dlhandle) {
mjGLFW_INITIALIZE_SYMBOL(glfwGetKey);
mjGLFW_INITIALIZE_SYMBOL(glfwGetMonitorPhysicalSize);
mjGLFW_INITIALIZE_SYMBOL(glfwGetMouseButton);
#if GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)
mjGLFW_INITIALIZE_SYMBOL(glfwGetPlatform);
#endif
mjGLFW_INITIALIZE_SYMBOL(glfwGetPrimaryMonitor);
mjGLFW_INITIALIZE_SYMBOL(glfwGetTime);
mjGLFW_INITIALIZE_SYMBOL(glfwGetVideoMode);
Expand Down
3 changes: 3 additions & 0 deletions simulate/glfw_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ struct Glfw {
mjGLFW_DECLARE_SYMBOL(glfwGetKey);
mjGLFW_DECLARE_SYMBOL(glfwGetMonitorPhysicalSize);
mjGLFW_DECLARE_SYMBOL(glfwGetMouseButton);
#if GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)
mjGLFW_DECLARE_SYMBOL(glfwGetPlatform);
#endif
mjGLFW_DECLARE_SYMBOL(glfwGetPrimaryMonitor);
mjGLFW_DECLARE_SYMBOL(glfwGetTime);
mjGLFW_DECLARE_SYMBOL(glfwGetVideoMode);
Expand Down