Bug 1896418 - glfw doesn't properly set window size in full screen mode on Wayland
Summary: glfw doesn't properly set window size in full screen mode on Wayland
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: glfw
Version: 33
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Till Hofmann
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-11-10 14:13 UTC by malkovjohnny
Modified: 2021-05-08 01:33 UTC (History)
4 users (show)

Fixed In Version: glfw-3.3.4-1.fc33 glfw-3.3.4-1.fc34
Doc Type: ---
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-08 01:23:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description malkovjohnny 2020-11-10 14:13:32 UTC
Description of problem:
glfw doesn't properly set window size in full screen mode on Wayland. Possible bug???

Version-Release number of selected component (if applicable):
glfw-3.3.2-8.fc33 https://bugzilla.redhat.com/show_bug.cgi?id=1895018 fixes problem with connection to display.
Bug exist in previous version and new one.

How reproducible:
Run test application
g++ -std=c++17 -Wall -lGL -lGLEW -lglfw xxx.cxx -o xxx

Actual results:
Application runs with invalid window size

Expected results:
Fix possible bug

When session X11:
XDG_SESSION_TYPE=x11
XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME
XDG_SESSION_CLASS=user

output is:
available video modes:
1920 1080 60
1920 1080 40
1680 1050 60
1280 1024 60
1440 900 60
1280 800 60
1280 720 60 // <- required size
1024 768 60
800 600 60
640 480 60
frbuff size (current): 800 800
window size (current): 800 800
monitr mode (current): 1280 720 60
4.6 (Compatibility Profile) Mesa 20.2.2  4.60
frbuff size (resized): 1280 720 // <- proper size
window size (resized): 1280 720 // <- proper size


When session Wayland:
XDG_SESSION_TYPE=wayland
XDG_CURRENT_DESKTOP=GNOME
XDG_SESSION_CLASS=user

output is:
available video modes:
1920 1080 60
1680 1050 60
1440 1080 60
1400 1050 60
1600 900 60
1280 1024 60
1440 900 60
1280 960 60
1368 768 60
1280 800 60
1152 864 60
1280 720 60 // <- required size
1024 768 60
1024 576 60
800 600 60
864 486 60
720 480 60
640 480 59
720 400 60
640 400 60
640 350 60
320 240 60
320 200 59
frbuff size (current): 800 800
window size (current): 800 800
monitr mode (current): 1920 1080 60
4.6 (Compatibility Profile) Mesa 20.2.2  4.60
frbuff size (resized): 1920 1080 // <- invalid size should be 1280x720
window size (resized): 1920 1080 // <- invalid size should be 1280x720

Check line 78: full screen mode with size 1280x720

Test application:

#include <iostream>

#include <GL/glew.h>
#include <GLFW/glfw3.h>

static void error_call(int error, const char* description)
{
  std::cout << "(" << error << ") ";
  std::cout << description << "\n";
}

static void fbsize_call(GLFWwindow* window, int width, int height)
{
  std::cout << "frbuff size (resized): " << width << " " << height << "\n";
  glViewport(0, 0, width, height);
}

static void wisize_call(GLFWwindow* window, int width, int height)
{
  std::cout << "window size (resized): " << width << " " << height << "\n";
}

static bool print_video_modes(GLFWmonitor* monitor)
{
  bool good = false;
  
  int count = 0;
  const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
  
  if(good = modes != NULL && count > 0; good)
  {
    std::cout << "available video modes:\n";
   
    for(int i = count - 1; i >= 0; --i)
    {
      std::cout << modes[i].width << " ";
      std::cout << modes[i].height << " ";
      std::cout << modes[i].refreshRate << "\n";
    }
  }
  
  return good;
}

int main(void)
{
  glfwSetErrorCallback(error_call);
  
  if(glfwInit() == GLFW_FALSE)
  {
    std::cout << "fail init glfw\n";
    exit(EXIT_FAILURE);
  }

  GLFWmonitor* monitor = glfwGetPrimaryMonitor();
  GLFWwindow* window = glfwCreateWindow(800, 800, "GLFW", NULL, NULL);
  
  if(window == NULL)
  {
    std::cout << "fail create GLFW window\n";
    glfwTerminate();
    exit(EXIT_FAILURE);
  }
  
  glfwMakeContextCurrent(window);

  if(GLenum error = glewInit(); error != GLEW_OK)
  {
    std::cout << "fail init GLEW " << glewGetErrorString(error) << "\n";
    glfwTerminate();
    exit(EXIT_FAILURE);
  }

  glfwSetFramebufferSizeCallback(window, fbsize_call);
  glfwSetWindowSizeCallback(window, wisize_call);
  
  print_video_modes(monitor);
  glfwSetWindowMonitor(window, monitor, 0, 0, 1280, 720, 60); // <- doesn't properly set size on Wayland, application full screen mode
  
  int width = 0;
  int height = 0;
  glfwGetFramebufferSize(window, &width, &height);
  std::cout << "frbuff size (current): " << width << " " << height << "\n";

  glfwGetWindowSize(window, &width, &height);
  std::cout << "window size (current): " << width << " " << height << "\n";
  
  const GLFWvidmode* m = glfwGetVideoMode(monitor);
  std::cout << "monitr mode (current): ";
  std::cout << m->width << " " << m->height << " " << m->refreshRate  << "\n";
  
  std::cout << glGetString(GL_VERSION) << "  ";
  std::cout << glGetString(GL_SHADING_LANGUAGE_VERSION) << "\n";
  
  
  while(!glfwWindowShouldClose(window))
  {
    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    glColor3f(0.9f, 0.0f, 0.0f);
    glBegin(GL_QUADS);
        glVertex2f(-0.5f, +0.5f);
        glVertex2f(-0.5f, -0.5f);
        glVertex2f(+0.5f, -0.5f);
        glVertex2f(+0.5f, +0.5f);
    glEnd();

    glfwSwapBuffers(window);
    glfwPollEvents();
  }

  glfwDestroyWindow(window);
  glfwTerminate();
  
  return 0;
}

Comment 1 Fedora Update System 2021-04-29 21:35:32 UTC
FEDORA-2021-b6a7d97f2f has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-b6a7d97f2f

Comment 2 Fedora Update System 2021-04-29 21:35:33 UTC
FEDORA-2021-29e3e3bc60 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-29e3e3bc60

Comment 3 Fedora Update System 2021-04-30 01:43:41 UTC
FEDORA-2021-29e3e3bc60 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-29e3e3bc60`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-29e3e3bc60

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 Fedora Update System 2021-04-30 02:05:53 UTC
FEDORA-2021-b6a7d97f2f has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-b6a7d97f2f`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-b6a7d97f2f

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2021-05-08 01:23:20 UTC
FEDORA-2021-b6a7d97f2f has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 6 Fedora Update System 2021-05-08 01:33:54 UTC
FEDORA-2021-29e3e3bc60 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.