Ticket #1916: xrandr.patch

File xrandr.patch, 2.6 KB (added by yunta, 11 years ago)
  • build/premake/extern_libs4.lua

     
    649649            })
    650650        end,
    651651    },
     652    xrandr = {
     653        link_settings = function()
     654            add_default_links({
     655                unix_names = { "Xrandr" },
     656            })
     657        end,
     658    },
    652659    zlib = {
    653660        compile_settings = function()
    654661            if os.is("windows") then
  • build/premake/premake4.lua

     
    751751    -- X11 should only be linked on *nix
    752752    table.insert(used_extern_libs, "x11")
    753753    table.insert(used_extern_libs, "xcursor")
     754    table.insert(used_extern_libs, "xrandr")
    754755end
    755756
    756757if not _OPTIONS["without-audio"] then
  • source/lib/sysdep/os/unix/x/x.cpp

     
    4444#include <stdlib.h>
    4545#include <Xatom.h>
    4646#include <Xcursor/Xcursor.h>
     47#include <X11/extensions/Xrandr.h>
    4748
    4849#include "SDL.h"
    4950#include "SDL_syswm.h"
     
    7172
    7273    int screen = XDefaultScreen(disp);
    7374   
    74     /* 2004-07-13
    75     NOTE: The XDisplayWidth/Height functions don't actually return the current
    76     display mode - they return the size of the root window. This means that
    77     users with "Virtual Desktops" bigger than what their monitors/graphics
    78     card can handle will have to set their 0AD screen resolution manually.
    79    
    80     There's supposed to be an X extension that can give you the actual display
    81     mode, probably including refresh rate info etc, but it's not worth
    82     researching and implementing that at this stage.
     75    /* 2013-04-13
     76    NOTE: Game starts on primary output. In multi-monitor configuration,
     77    for SDL 1.2 users primary output has to be the left-most (at 0,0).
    8378    */
    84    
     79
     80    XRRScreenResources *screen_resources = XRRGetScreenResources(disp, DefaultRootWindow(disp));
     81    RROutput primary_output = XRRGetOutputPrimary(disp, DefaultRootWindow(disp));
     82    XRROutputInfo *output_info = XRRGetOutputInfo(disp, screen_resources, primary_output);
     83    XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(disp, screen_resources, output_info->crtc);
     84
    8585    if(xres)
    86         *xres = XDisplayWidth(disp, screen);
     86        *xres = crtc_info->width;
    8787    if(yres)
    88         *yres = XDisplayHeight(disp, screen);
     88        *yres = crtc_info->height;
     89
     90    XRRFreeCrtcInfo(crtc_info);
     91    XRRFreeOutputInfo(output_info);
     92    XRRFreeScreenResources(screen_resources);
     93
    8994    if(bpp)
    9095        *bpp = XDefaultDepth(disp, screen);
    9196    if(freq)