mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
treewide: use helper dixGetScreenPtr() for retrieving ScreenPtr's
Instead of directly accessing the global screenInfo.screens[] array, let everybody go through a little inline helper. This one also checks for array bounds - if the screen doesn't exist, return NULL. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
d2fcf85214
commit
0fbb681fce
@@ -6,6 +6,7 @@
|
||||
#ifndef _XSERVER_DIX_SCREENINT_PRIV_H
|
||||
#define _XSERVER_DIX_SCREENINT_PRIV_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <X11/Xdefs.h>
|
||||
|
||||
#include "include/callback.h"
|
||||
@@ -31,6 +32,30 @@ static inline ScreenPtr dixGetMasterScreen(void) {
|
||||
return screenInfo.screens[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* retrieve pointer to screen by it's index. If index is above the total
|
||||
* number of screens, returns NULL
|
||||
*
|
||||
* @param idx screen index
|
||||
* @return pointer to idx'th screen or NULL
|
||||
*/
|
||||
static inline ScreenPtr dixGetScreenPtr(unsigned int idx) {
|
||||
if (idx < screenInfo.numScreens)
|
||||
return screenInfo.screens[idx];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* check whether screen with given index exists
|
||||
*
|
||||
* @param idx screen index
|
||||
* @return TRUE if the screen at this index exists
|
||||
*/
|
||||
static inline bool dixScreenExists(unsigned int idx) {
|
||||
return ((idx < screenInfo.numScreens) &&
|
||||
(screenInfo.screens[idx] != NULL));
|
||||
}
|
||||
|
||||
/*
|
||||
* macro for looping over all screens (up to `screenInfo.numScreens`).
|
||||
* Makes a new scopes and declares `walkScreenIdx` as the current screen's
|
||||
|
||||
Reference in New Issue
Block a user