<div dir="ltr">Hello,<div><br></div><div style>I'm not sure that is the correct mailing list to ask this question, but I didn't find an answer anywhere on the web.</div><div style><br></div><div style>I have a laptop running Ubuntu 11.04 connected to an external Dell monitor. When I was calling XRRGetOutputPrimary, it returned me the primary monitor is 0. My code snippet is simple:</div>
<div style><div>    static void test1()</div><div>    {</div><div>        Display *dpy = XOpenDisplay(NULL);</div><div>        int screen_count = ScreenCount(dpy);</div><div>        int screen = DefaultScreen(dpy);<br></div>
<div>        Window root = RootWindow(dpy, screen);</div><div>        RROutput primary = XRRGetOutputPrimary(dpy, root);</div><div>        printf("Primary = %ld\n", primary);<br></div><div>    }</div><div><br></div>
<div style>That seems not a big trouble so I just run command 'xrandr --output LVDS1 --primary' to set the primary monitor. But after that when I'm trying to create a window to maximize the window to both my monitors, it failed. The window only occupy part of the external monitor, with the window size equals to the size of the laptop owned monitor (my external monitor has higher resolution than my laptop owned monitor).</div>
<div style><div>    static void test2()</div><div>    {</div><div>        Display *dpy = XOpenDisplay(NULL);</div><div>    <span class="" style="white-space:pre">    </span>const Atom _NET_WM_FULLSCREEN_MONITORS = XInternAtom(dpy, "_NET_WM_FULLSCREEN_MONITORS", False);<br>
</div><div>    <span class="" style="white-space:pre">    </span>const Atom _NET_WM_STATE = XInternAtom(dpy, "_NET_WM_STATE", False);</div><div>    <span class="" style="white-space:pre"> </span>const Atom _NET_WM_STATE_FULLSCREEN = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);</div>
<div>    <br></div><div>    <span class="" style="white-space:pre">   </span>XSetWindowAttributes attrs;</div><div>    <span class="" style="white-space:pre">    </span>attrs.event_mask = StructureNotifyMask | PropertyChangeMask;</div>
<div>    <span class="" style="white-space:pre">        </span>Window wnd = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 100, 100, 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask | CWBorderPixel, &attrs);</div>
<div>    <br></div><div>    <span class="" style="white-space:pre">   </span>XMapWindow(dpy, wnd);</div><div>    <br></div><div>    <span class="" style="white-space:pre">     </span>{<br></div><div>    <span class="" style="white-space:pre">            </span>XClientMessageEvent ev;</div>
<div>                memset(&ev, 0, sizeof(ev));</div><div>    </div><div>    <span class="" style="white-space:pre">               </span>ev.type = ClientMessage;</div><div>    <span class="" style="white-space:pre">               </span>ev.window = wnd;</div>
<div>    <span class="" style="white-space:pre">                </span>ev.message_type = _NET_WM_STATE;</div><div>    <span class="" style="white-space:pre">               </span>ev.format = 32;<br></div><div>    <span class="" style="white-space:pre">              </span>ev.data.l[0] = 1;</div>
<div>    <span class="" style="white-space:pre">                </span>ev.data.l[1] = _NET_WM_STATE_FULLSCREEN;</div><div>    <span class="" style="white-space:pre">               </span>ev.data.l[2] = 0;<br></div><div>    <span class="" style="white-space:pre">            </span>ev.data.l[3] = 1;</div>
<div>    <span class="" style="white-space:pre">                </span>ev.data.l[4] = 0;</div><div>    </div><div>    <span class="" style="white-space:pre">           </span>XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask | SubstructureRedirectMask, (XEvent*)&ev);</div>
<div>    <span class="" style="white-space:pre">        </span>}<br></div><div>    </div><div>    <span class="" style="white-space:pre"> </span>{<br></div><div>    <span class="" style="white-space:pre">        </span>XClientMessageEvent ev;</div>
<div>            memset(&ev, 0, sizeof(ev));</div><div>    </div><div>            int snumber = 0;</div><div>            XineramaScreenInfo *sinfo = XineramaQueryScreens(dpy, &snumber);</div><div>            int top = 0, bottom = 0, left = 0, right = 0;</div>
<div>            for (int i=1; i<snumber; ++i)</div><div>            {</div><div>                if (sinfo[i].x_org < sinfo[left].x_org)</div><div>                    left = i;</div><div>                if (sinfo[i].y_org < sinfo[top].y_org)</div>
<div>                    top = i;</div><div>                if (sinfo[i].x_org + sinfo[i].width > sinfo[right].x_org + sinfo[right].width)</div><div>                    right = i;</div><div>                if (sinfo[i].y_org + sinfo[i].height > sinfo[bottom].y_org + sinfo[bottom].height)</div>
<div>                    bottom = i;</div><div>            }</div><div>            printf("top = %d, bottom = %d, left = %d, right = %d\n",</div><div>                top, bottom, left, right);</div><div>    </div>
<div>    <span class="" style="white-space:pre">                </span>ev.type = ClientMessage;</div><div>    <span class="" style="white-space:pre">               </span>ev.window = wnd;</div><div>    <span class="" style="white-space:pre">               </span>ev.message_type = _NET_WM_FULLSCREEN_MONITORS;</div>
<div>    <span class="" style="white-space:pre">                </span>ev.format = 32;<br></div><div>    <span class="" style="white-space:pre">              </span>ev.data.l[0] = top;</div><div>    <span class="" style="white-space:pre">            </span>ev.data.l[1] = bottom;</div>
<div>    <span class="" style="white-space:pre">                </span>ev.data.l[2] = left;</div><div>    <span class="" style="white-space:pre">           </span>ev.data.l[3] = right;</div><div>    <span class="" style="white-space:pre">          </span>ev.data.l[4] = 1;</div>
<div>    </div><div>    <span class="" style="white-space:pre">             </span>XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask | SubstructureRedirectMask, (XEvent*)&ev);</div><div>    <span class="" style="white-space:pre">   </span>}<br>
</div><div><div><div><br></div><div style>        XSync(dpy, False);</div><div>        sleep(10);</div></div></div><div><br></div><div><div>        {</div><div>            int black = BlackPixel(dpy, DefaultScreen(dpy));</div>
<div>            int white = WhitePixel(dpy, DefaultScreen(dpy));</div><div>            GC gc = XCreateGC(dpy, wnd, 0, NULL);</div><div>            XSetForeground(dpy, gc, white);</div><div>            XFillRectangle(dpy, wnd, gc, 0, 0, 4000, 1200);<br>
</div><div>            XFlush(dpy);</div><div>        }</div><div><br></div><div>        sleep(10);</div><div>    }<br></div></div><div><br></div><div><br></div><div style>Are my steps wrong to create full screen window span to multiple monitors? Any help or pointers will be greatly appreciated.</div>
<div style><br></div><div style>Best Regards,</div><div style>Kaifeng</div></div></div></div>