Home > Mobile >  GLFW undecorated window on MacOS after turning on and off again, gains black outline
GLFW undecorated window on MacOS after turning on and off again, gains black outline

Time:07-13

So, there is a window, that is being created with these hints:

glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);

main_window = glfwCreateWindow(last_window_size.x, last_window_size.y, main_window_name.c_str(), NULL, NULL);
glfwShowWindow(main_window);

window looks like that: window before fullscreen

later I switch it to fullscreen with this function:

void set_fullscreen_mode()
{
    glfwGetWindowSize(main_window, &last_window_size.x, &last_window_size.y);
    glfwGetWindowPos(main_window, &last_window_position.x, &last_window_position.y);
    full_screen = true;

    current_monitor = get_monitor_by_cpos(get_global_mouse_position(main_window));

    const GLFWvidmode* monitor_video_mode = glfwGetVideoMode(current_monitor);

    glfwSetWindowMonitor(main_window, current_monitor, 0, 0, monitor_video_mode->width, monitor_video_mode->height, monitor_video_mode->refreshRate);
}

and change it back with this one:

void set_windowed_mode()
{   
    glfwHideWindow(main_window);
    full_screen = false;

    current_monitor = get_monitor_by_cpos(get_global_mouse_position(main_window));

    const GLFWvidmode* monitor_video_mode = glfwGetVideoMode(current_monitor);

    glfwSetWindowMonitor(main_window, NULL, last_window_position.x, last_window_position.y, last_window_size.x, last_window_size.y, monitor_video_mode->refreshRate);
    glfwShowWindow(main_window);
}

And after doing all of that, appears black outline like that: window after fullscreen

So, the question is why does it appear, and how to remove it ?

CodePudding user response:

I don't think this is a GLFW side issue or an issue in your code, I think this might be an issue with macOS's Quartz Compositor. QC is responsible for drawing all your windows to the screen just like Windows' DWM.

Or if the window covers the full screen (without "actually" being full screen, just a large window), you could use a quick and dirty hack to make the window 2 pixels bigger X and Y then move the window current_x_pos - 1 and current_y_pos - 1

  • Related