X11-Display

Handles access to a X11 display server.  To create X11 windows and to do some graphics operations a connection to a X11 display server is needed.  Before any other function in the X11 subsystem can be used call <init_x11display> to establish a connection to an X11 display server.

Summary
X11-DisplayHandles access to a X11 display server.
CopyrightThis program is free software.
Files
C-kern/api/platform/X11/x11display.hHeader file of X11-Display.
C-kern/platform/X11/x11display.cImplementation file of X11-Display impl.
Types
struct x11display_tExport x11display_t into global namespace.
struct x11extension_tExport x11extension_t into global namespace.
Functions
test
unittest_platform_X11_x11displayTests connection to local X11 display.
x11extension_tStores the version number and the event offsets numbers of an X11 extension.
x11display_tDescribes connection to an X11 display server.
idmapUsed internally to map an id to an object pointer.
sys_displayThe X11 display handle of type »Display*«.
xdbeCheck isSupported whether »Double Buffer extension« is supported.
xrandrCheck isSupported whether »X Resize, Rotate and Reflection extension« is supported.
xrenderCheck isSupported whether »X Rendering Extension « is supported.
lifetime
x11display_FREEStatic initializer.
init_x11displayConnects to a X11 display server and returns the newly created connection.
init2_x11displaySame as init_x11display but allows to not initialize any X11 extension.
free_x11displayCloses display connection and frees all resources.
initmove_x11displayMust be called if address of x11display_t changes.
query
io_x11displayReturns file descriptor of network connection.
errorstring_x11displayReturns a NULL terminated name of the error with code »x11_errcode« in plain english.
isextxrandr_x11displayReturns true if xrandr extension is supported.
isfree_x11displayReturns true if x11disp is set to x11display_FREE.
screen
defaultscreen_x11displayReturns the default screen of x11disp.
defaultscreennr_x11displayReturns the default screen number of x11disp.
nrofscreens_x11displayReturns the number of all screens attached to x11disp.
ID-manager
tryfindobject_x11displayMaps an objectid to its associated object pointer.
insertobject_x11displayRegisters an object under an objectid.
removeobject_x11displayRemoves objectid and its associated pointer from the registration.
replaceobject_x11displayReplaces the object for an already registered objectid.
inline implementation
x11display_t
isextxrandr_x11displayImplements x11display_t.isextxrandr_x11display.
isfree_x11displayImplements x11display_t.isfree_x11display.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2011 Jörg Seebohn

Files

C-kern/api/platform/X11/x11display.h

Header file of X11-Display.

C-kern/platform/X11/x11display.c

Implementation file of X11-Display impl.

Types

struct x11display_t

typedef struct x11display_t x11display_t

Export x11display_t into global namespace.  Describes connection to X11 display server.

struct x11extension_t

typedef struct x11extension_t x11extension_t

Export x11extension_t into global namespace.  Describes an X11 server extension.

Functions

Summary
test
unittest_platform_X11_x11displayTests connection to local X11 display.

test

unittest_platform_X11_x11display

int unittest_platform_X11_x11display(void)

Tests connection to local X11 display.

x11extension_t

struct x11extension_t

Stores the version number and the event offsets numbers of an X11 extension.  It stores also if the extension is supported.

x11display_t

struct x11display_t

Describes connection to an X11 display server.  If more then one thread wants to access a display every thread must create its own x11display_t.

Not thread safe

The functions on a display object are not thread safe.  The underlying X11 library is initialized to be thread safe so that accessing core X11 directly via sys_display is thread safe.

A display normally corresponds to a graphics card.

Summary
idmapUsed internally to map an id to an object pointer.
sys_displayThe X11 display handle of type »Display*«.
xdbeCheck isSupported whether »Double Buffer extension« is supported.
xrandrCheck isSupported whether »X Resize, Rotate and Reflection extension« is supported.
xrenderCheck isSupported whether »X Rendering Extension « is supported.
lifetime
x11display_FREEStatic initializer.
init_x11displayConnects to a X11 display server and returns the newly created connection.
init2_x11displaySame as init_x11display but allows to not initialize any X11 extension.
free_x11displayCloses display connection and frees all resources.
initmove_x11displayMust be called if address of x11display_t changes.
query
io_x11displayReturns file descriptor of network connection.
errorstring_x11displayReturns a NULL terminated name of the error with code »x11_errcode« in plain english.
isextxrandr_x11displayReturns true if xrandr extension is supported.
isfree_x11displayReturns true if x11disp is set to x11display_FREE.
screen
defaultscreen_x11displayReturns the default screen of x11disp.
defaultscreennr_x11displayReturns the default screen number of x11disp.
nrofscreens_x11displayReturns the number of all screens attached to x11disp.
ID-manager
tryfindobject_x11displayMaps an objectid to its associated object pointer.
insertobject_x11displayRegisters an object under an objectid.
removeobject_x11displayRemoves objectid and its associated pointer from the registration.
replaceobject_x11displayReplaces the object for an already registered objectid.

idmap

struct x11windowmap_t * idmap

Used internally to map an id to an object pointer.

sys_display

void * sys_display

The X11 display handle of type »Display*«.  The generic »void*« type is used to not pollute the global namespace with X11 type names.

xdbe

x11extension_t xdbe

Check isSupported whether »Double Buffer extension« is supported.  x11dblbuffer_t works only if this extension is supported.

xrandr

x11extension_t xrandr

Check isSupported whether »X Resize, Rotate and Reflection extension« is supported.  The types x11videomode_iterator_t and x11videomode_t work only if this extension is implemented by the X11 server.

xrender

x11extension_t xrender

Check isSupported whether »X Rendering Extension « is supported.  Transparent toplevel windows (as a whole) and alpha blending of single pixels drawn into the window with the underlying window background work only if this extension is implemented by the X11 server.

See

<setopacity_x11window> and windowconfig_TRANSPARENCY.

lifetime

x11display_FREE

#define x11display_FREE { .idmap = 0, .sys_display = 0 }

Static initializer.

init_x11display

int init_x11display(/*out*/x11display_t *x11disp,
const char *display_server_name)

Connects to a X11 display server and returns the newly created connection.  The server can be located on the same local node or on a remote node reachable through a tcp/ip network.  If the parameter is set to 0 the default connection is used.  The default is read from the environment variable “DISPLAY” which is normally set to “:0.0”.

Syntax of display_server_name

[ <ip-number> | <dns-server-name> | "" ] ":" <display-number> "." <default-screen-number>

An empty server name connects to the local host with the fastest possible type of connection.

Do not share connections

Every thread must have its own connection to a X11 graphics display.

init2_x11display

int init2_x11display(/*out*/x11display_t *x11disp,
const char *display_server_name,
bool isInitExtension)

Same as init_x11display but allows to not initialize any X11 extension.

free_x11display

int free_x11display(x11display_t *x11disp)

Closes display connection and frees all resources.

initmove_x11display

int initmove_x11display(/*out*/x11display_t *destination,
x11display_t *source)

Must be called if address of x11display_t changes.  A simple memcpy from source to destination does not work.

Not Implemented.

query

io_x11display

sys_iochannel_t io_x11display(const x11display_t *x11disp)

Returns file descriptor of network connection.  You can use it to wait for incoming events sent by X11 display server.

errorstring_x11display

void errorstring_x11display(const x11display_t *x11disp,
int x11_errcode,
char *buffer,
uint8_t buffer_size)

Returns a NULL terminated name of the error with code »x11_errcode« in plain english.  In case of an internal error the number of x11_errcode is returned.

isextxrandr_x11display

bool isextxrandr_x11display(const x11display_t *x11disp)

Returns true if xrandr extension is supported.  This extension supports querying and setting different video modes (screen resolutions) - see x11videomode_t.

isfree_x11display

static inline bool isfree_x11display(const x11display_t *x11disp)

Returns true if x11disp is set to x11display_FREE.

screen

defaultscreen_x11display

struct x11screen_t defaultscreen_x11display(x11display_t *x11disp)

Returns the default screen of x11disp.

defaultscreennr_x11display

uint32_t defaultscreennr_x11display(const x11display_t *x11disp)

Returns the default screen number of x11disp.

nrofscreens_x11display

uint32_t nrofscreens_x11display(const x11display_t *x11disp)

Returns the number of all screens attached to x11disp.  The first screen has the number 0 and the last nrofscreens_x11display-1.

ID-manager

tryfindobject_x11display

int tryfindobject_x11display(
   x11display_t *x11disp,
   /*out*/struct x11window_t ** object/*could be NULL*/,
   uint32_t objectid
)

Maps an objectid to its associated object pointer.  Returns ESRCH if no object is registered with objectid.  On success the returned object contains either a pointer to an object which could be 0.  No error logging is done in case of error ESRCH.

insertobject_x11display

int insertobject_x11display(x11display_t *x11disp,
struct x11window_t *object,
uint32_t objectid)

Registers an object under an objectid.

removeobject_x11display

int removeobject_x11display(x11display_t *x11disp,
uint32_t objectid)

Removes objectid and its associated pointer from the registration.  This function is called from <free_x11window> or from <dispatchevent_X11> in case a DestroyNotify for a registerd window was received.

replaceobject_x11display

int replaceobject_x11display(x11display_t *x11disp,
struct x11window_t *object,
uint32_t objectid)

Replaces the object for an already registered objectid.

x11display_t

isextxrandr_x11display

#define isextxrandr_x11display(x11disp) ((x11disp)->xrandr.isSupported)

Implements x11display_t.isextxrandr_x11display.

isfree_x11display

static inline bool isfree_x11display(const x11display_t *x11disp)

Implements x11display_t.isfree_x11display.

Handles access to a X11 display server.
Implements X11-Display.
typedef struct x11display_t x11display_t
Export x11display_t into global namespace.
struct x11display_t
Describes connection to an X11 display server.
typedef struct x11extension_t x11extension_t
Export x11extension_t into global namespace.
struct x11extension_t
Stores the version number and the event offsets numbers of an X11 extension.
int unittest_platform_X11_x11display(void)
Tests connection to local X11 display.
struct x11windowmap_t * idmap
Used internally to map an id to an object pointer.
void * sys_display
The X11 display handle of type »Display*«.
x11extension_t xdbe
Check isSupported whether »Double Buffer extension« is supported.
x11extension_t xrandr
Check isSupported whether »X Resize, Rotate and Reflection extension« is supported.
x11extension_t xrender
Check isSupported whether »X Rendering Extension « is supported.
#define x11display_FREE { .idmap = 0, .sys_display = 0 }
Static initializer.
int init_x11display(/*out*/x11display_t *x11disp,
const char *display_server_name)
Connects to a X11 display server and returns the newly created connection.
int init2_x11display(/*out*/x11display_t *x11disp,
const char *display_server_name,
bool isInitExtension)
Same as init_x11display but allows to not initialize any X11 extension.
int free_x11display(x11display_t *x11disp)
Closes display connection and frees all resources.
int initmove_x11display(/*out*/x11display_t *destination,
x11display_t *source)
Must be called if address of x11display_t changes.
sys_iochannel_t io_x11display(const x11display_t *x11disp)
Returns file descriptor of network connection.
void errorstring_x11display(const x11display_t *x11disp,
int x11_errcode,
char *buffer,
uint8_t buffer_size)
Returns a NULL terminated name of the error with code »x11_errcode« in plain english.
bool isextxrandr_x11display(const x11display_t *x11disp)
Returns true if xrandr extension is supported.
static inline bool isfree_x11display(const x11display_t *x11disp)
Returns true if x11disp is set to x11display_FREE.
struct x11screen_t defaultscreen_x11display(x11display_t *x11disp)
Returns the default screen of x11disp.
uint32_t defaultscreennr_x11display(const x11display_t *x11disp)
Returns the default screen number of x11disp.
uint32_t nrofscreens_x11display(const x11display_t *x11disp)
Returns the number of all screens attached to x11disp.
int tryfindobject_x11display(
   x11display_t *x11disp,
   /*out*/struct x11window_t ** object/*could be NULL*/,
   uint32_t objectid
)
Maps an objectid to its associated object pointer.
int insertobject_x11display(x11display_t *x11disp,
struct x11window_t *object,
uint32_t objectid)
Registers an object under an objectid.
int removeobject_x11display(x11display_t *x11disp,
uint32_t objectid)
Removes objectid and its associated pointer from the registration.
int replaceobject_x11display(x11display_t *x11disp,
struct x11window_t *object,
uint32_t objectid)
Replaces the object for an already registered objectid.
#define isextxrandr_x11display(x11disp) ((x11disp)->xrandr.isSupported)
Implements x11display_t.isextxrandr_x11display.
static inline bool isfree_x11display(const x11display_t *x11disp)
Implements x11display_t.isfree_x11display.
struct x11dblbuffer_t
A drawable which describes the double buffer (back buffer) of a x11window_t.
Sets a transparency value for the whole window.
Close