# Wrong monitor opened if dual screen setup (Linux)

**URL:** https://discourse.glfw.org/t/wrong-monitor-opened-if-dual-screen-setup-linux/1507
**Category:** support
**Created:** [March 12, 2020, 5:20pm UTC](https://discourse.glfw.org/t/wrong-monitor-opened-if-dual-screen-setup-linux/1507 "2020-03-12T17:20:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![uliglfw](https://avatars.discourse-cdn.com/v4/letter/u/5e9695/32.png) [@uliglfw](https://discourse.glfw.org/u/uliglfw)
#### Post date: [March 12, 2020, 5:20pm UTC](https://discourse.glfw.org/t/wrong-monitor-opened-if-dual-screen-setup-linux/1507/1 "2020-03-12T17:20:18Z")

</div>

Hi,

i encounter a strange behavior if i want to open a full-screen window at my second monitor in a dual screen setup. Monitors are recognized correctly at first, but finally the wrong one shows up.  
I’m on Linux, Python 3.6.10, pyopengl 3.1.5, glfw 3.3.2, pyglfw 1.11.0 - but i confirmed with pure c, see attached example (c code is not allowed as upload, so inline).

output is:

```
$ ~/bin/glfw_2screen_minimaldemo 
found 2 monitors
1600x900
1920x1200
should use monitor 1 with size 1920x1200
have window of size 1600x900
have frame of size 1600x900

```

Thanks and all the best,  
Uli

```
/*
# example to demonstrate that 2nd screen is not used as intended
# behaviour: screen_0 shows fullscreen black for entire 5 secs
# screen_1 does not change
# expected: screen_0 should stay as is with desktop and console
# screen_1 should show fullscreen black for entire 5 sec; then desktop again
# printed output shows, that second monitor is recognized.
# but not used at all.
# meanwhile:
# $ xrandr -q | grep '*'
# 1600x900 60.01*+ 59.99 59.94 59.95 59.82 40.00  
# 1920x1200 59.95*+
*/

#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> 
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main( void ){
  // Initialize the library
  if (!glfwInit()) {
    printf("init failed");
    exit(0);
  }

  int count;
  GLFWmonitor** monitors = glfwGetMonitors(&count); // list available monitors: ok
  printf("found %d monitors\n", count);
  int m;
  int msel = 1; // chose 2nd monitor
  int mw, mh; // its width and height
  for (m=0; m<count; m++) {
    const GLFWvidmode* mode = glfwGetVideoMode( monitors[m] ); // show modes of each monitor: ok
    printf( "%dx%d\n", mode->width, mode->height );
    if(m==msel) {
      mw = mode->width;
      mh = mode->height;
    }
  }
  
  GLFWwindow* window = glfwCreateWindow(mw, mh, "none", monitors[msel], NULL); // become active
  if (!window) { // ok
    // Window or OpenGL context creation failed
    printf("create window failed");
    glfwTerminate();
    exit(0);
  }
  printf("should use monitor %d with size %dx%d\n", msel, mw, mh ); // requested values
  glfwGetWindowSize(window, &mw, &mh); // != used values
  printf("have window of size %dx%d\n", mw, mh );
  glfwMakeContextCurrent(window);
  glfwSwapBuffers(window);
  glfwGetFramebufferSize(window, &mw, &mh);
  printf("have frame of size %dx%d\n", mw, mh);
  sleep(5); // wait log enough to be sure we do not alter something with heavy latency

  glfwDestroyWindow(window); // end nicely
  glfwTerminate();
  exit(0);
}
```

---

<div class="post-metadata">

### Author: ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)
#### Post date: [March 14, 2020, 9:42am UTC](https://discourse.glfw.org/t/wrong-monitor-opened-if-dual-screen-setup-linux/1507/2 "2020-03-14T09:42:07Z")

</div>

I don’t have a linux setup with multiple monitors at the moment, so have left this for others to reply to, but in the meantime it might be worth filing this as [a GLFW issue](https://github.com/glfw/glfw/issues).

I did find one Linux issue related to monitor problems: [glfwSetWindowMonitor doesn’t seem to work for some video modes](https://github.com/glfw/glfw/issues/1558), though this isn’t the same problem so it would be worth opening a new issue. If you don’t have Github access let me know and I can file an issue for you.

---

<div class="post-metadata">

### Author: ![uliglfw](https://avatars.discourse-cdn.com/v4/letter/u/5e9695/32.png) [@uliglfw](https://discourse.glfw.org/u/uliglfw)
#### Post date: [March 14, 2020, 5:01pm UTC](https://discourse.glfw.org/t/wrong-monitor-opened-if-dual-screen-setup-linux/1507/3 "2020-03-14T17:01:47Z")

</div>

hi dougbinks,  
thanks for the suggestion; I opened an issue: [https://github.com/glfw/glfw/issues/1659](https://github.com/glfw/glfw/issues/1659)
