From: Brian Paul Date: Tue, 23 Mar 2010 23:22:43 +0000 (-0600) Subject: st/glx: add support for multiple displays X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8ba47561dd45e1cd737992544545d7fa0f61918b;p=mesa.git st/glx: add support for multiple displays This is a quick & dirty solution, but it works. See comments in the code for other ideas. Fixes regressions/breakage seen in progs/xdemos/glxheads, etc. from commit 6632915e957149c153a3f793c400a532b4995b18. --- diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 8dd54206af2..3022d45157a 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -78,17 +78,39 @@ void xmesa_set_driver( const struct xm_driver *templ ) stapi = driver.create_st_api(); } + +/* + * XXX replace this with a linked list, or better yet, try to attach the + * gallium/mesa extra bits to the X Display object with XAddExtension(). + */ +#define MAX_DISPLAYS 10 +static struct xmesa_display Displays[MAX_DISPLAYS]; +static int NumDisplays = 0; + + static XMesaDisplay xmesa_init_display( Display *display ) { pipe_static_mutex(init_mutex); - static struct xmesa_display xm_display; XMesaDisplay xmdpy; - + int i; + pipe_mutex_lock(init_mutex); - /* TODO support for multiple displays */ - xmdpy = &xm_display; + /* Look for XMesaDisplay which corresponds to 'display' */ + for (i = 0; i < NumDisplays; i++) { + if (Displays[i].display == display) { + /* Found it */ + pipe_mutex_unlock(init_mutex); + return &Displays[i]; + } + } + + /* Create new XMesaDisplay */ + + assert(NumDisplays < MAX_DISPLAYS); + xmdpy = &Displays[NumDisplays]; + NumDisplays++; if (!xmdpy->display && display) { xmdpy->display = display;