FreeRDP
uwac-display.c File Reference
#include "uwac-priv.h"
#include "uwac-utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <sys/epoll.h>
#include "uwac-os.h"
#include "wayland-cursor.h"

Macros

#define TARGET_COMPOSITOR_INTERFACE   3U
 
#define TARGET_SHM_INTERFACE   1U
 
#define TARGET_SHELL_INTERFACE   1U
 
#define TARGET_DDM_INTERFACE   1U
 
#define TARGET_SEAT_INTERFACE   5U
 
#define TARGET_XDG_VERSION   5U /* The version of xdg-shell that we implement */
 

Functions

static bool uwac_default_error_handler (UwacDisplay *display, UwacReturnCode code, const char *msg,...)
 
void UwacInstallErrorHandler (UwacErrorHandler handler)
 
static void cb_shm_format (void *data, struct wl_shm *wl_shm, uint32_t format)
 
static void xdg_shell_ping (void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial)
 
static void display_destroy_seat (UwacDisplay *d, uint32_t name)
 
static void UwacSeatRegisterDDM (UwacSeat *seat)
 
static void UwacRegisterCursor (UwacSeat *seat)
 
static void registry_handle_global (void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version)
 
static void registry_handle_global_remove (void *data, struct wl_registry *registry, uint32_t name)
 
static void UwacDestroyGlobal (UwacGlobal *global)
 
static void * display_bind (UwacDisplay *display, uint32_t name, const struct wl_interface *interface, uint32_t version)
 
int UwacDisplayWatchFd (UwacDisplay *display, int fd, uint32_t events, UwacTask *task)
 
static void UwacDisplayUnwatchFd (UwacDisplay *display, int fd)
 
static void display_exit (UwacDisplay *display)
 
static void display_dispatch_events (UwacTask *task, uint32_t events)
 
UwacDisplay * UwacOpenDisplay (const char *name, UwacReturnCode *err)
 
int UwacDisplayDispatch (UwacDisplay *display, int timeout)
 
UwacReturnCode UwacDisplayGetLastError (const UwacDisplay *display)
 
UwacReturnCode UwacCloseDisplay (UwacDisplay **pdisplay)
 
int UwacDisplayGetFd (UwacDisplay *display)
 
const char * UwacErrorString (UwacReturnCode error)
 
UwacReturnCode UwacDisplayQueryInterfaceVersion (const UwacDisplay *display, const char *name, uint32_t *version)
 
uint32_t UwacDisplayQueryGetNbShmFormats (UwacDisplay *display)
 
UwacReturnCode UwacDisplayQueryShmFormats (const UwacDisplay *display, enum wl_shm_format *formats, int formats_size, int *filled)
 
uint32_t UwacDisplayGetNbOutputs (const UwacDisplay *display)
 
const UwacOutput * UwacDisplayGetOutput (UwacDisplay *display, int index)
 
UwacReturnCode UwacOutputGetResolution (const UwacOutput *output, UwacSize *resolution)
 
UwacReturnCode UwacOutputGetPosition (const UwacOutput *output, UwacPosition *pos)
 
UwacEvent * UwacDisplayNewEvent (UwacDisplay *display, int type)
 
bool UwacHasEvent (UwacDisplay *display)
 
UwacReturnCode UwacNextEvent (UwacDisplay *display, UwacEvent *event)
 

Variables

static const char * event_names []
 
UwacErrorHandler uwacErrorHandler = uwac_default_error_handler
 
static struct wl_shm_listener shm_listener = { cb_shm_format }
 
static const struct xdg_wm_base_listener xdg_wm_base_listener
 
static const struct wl_registry_listener registry_listener
 
static const char * errorStrings []
 

Macro Definition Documentation

◆ TARGET_COMPOSITOR_INTERFACE

#define TARGET_COMPOSITOR_INTERFACE   3U

◆ TARGET_DDM_INTERFACE

#define TARGET_DDM_INTERFACE   1U

◆ TARGET_SEAT_INTERFACE

#define TARGET_SEAT_INTERFACE   5U

◆ TARGET_SHELL_INTERFACE

#define TARGET_SHELL_INTERFACE   1U

◆ TARGET_SHM_INTERFACE

#define TARGET_SHM_INTERFACE   1U

◆ TARGET_XDG_VERSION

#define TARGET_XDG_VERSION   5U /* The version of xdg-shell that we implement */

Function Documentation

◆ cb_shm_format()

static void cb_shm_format ( void *  data,
struct wl_shm *  wl_shm,
uint32_t  format 
)
static
Here is the call graph for this function:

◆ display_bind()

static void* display_bind ( UwacDisplay *  display,
uint32_t  name,
const struct wl_interface *  interface,
uint32_t  version 
)
static

◆ display_destroy_seat()

static void display_destroy_seat ( UwacDisplay *  d,
uint32_t  name 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_dispatch_events()

static void display_dispatch_events ( UwacTask *  task,
uint32_t  events 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_exit()

static void display_exit ( UwacDisplay *  display)
static
Here is the caller graph for this function:

◆ registry_handle_global()

static void registry_handle_global ( void *  data,
struct wl_registry *  registry,
uint32_t  id,
const char *  interface,
uint32_t  version 
)
static
Here is the call graph for this function:

◆ registry_handle_global_remove()

static void registry_handle_global_remove ( void *  data,
struct wl_registry *  registry,
uint32_t  name 
)
static
Here is the call graph for this function:

◆ uwac_default_error_handler()

static bool uwac_default_error_handler ( UwacDisplay *  display,
UwacReturnCode  code,
const char *  msg,
  ... 
)
static
Here is the caller graph for this function:

◆ UwacCloseDisplay()

UwacReturnCode UwacCloseDisplay ( UwacDisplay **  pdisplay)
 closes the corresponding UwacDisplay
Parameters
pdisplaya pointer on the display to close
Returns
UWAC_SUCCESS if the operation was successful, the corresponding error otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UwacDestroyGlobal()

static void UwacDestroyGlobal ( UwacGlobal *  global)
static
Here is the caller graph for this function:

◆ UwacDisplayDispatch()

int UwacDisplayDispatch ( UwacDisplay *  display,
int  timeout 
)

Dispatch the display

Parameters
displayThe display to dispatch
timeoutThe maximum time to wait in milliseconds (-1 == infinite).
Returns
1 for success, 0 if display not running, -1 on failure
Here is the caller graph for this function:

◆ UwacDisplayGetFd()

int UwacDisplayGetFd ( UwacDisplay *  display)

Returns the file descriptor associated with the UwacDisplay, this is useful when you want to poll that file descriptor for activity.

Parameters
displayan opened UwacDisplay
Returns
the corresponding descriptor
Here is the caller graph for this function:

◆ UwacDisplayGetLastError()

UwacReturnCode UwacDisplayGetLastError ( const UwacDisplay *  display)

returns the last error that occurred on a display

Parameters
displaythe display
Returns
the last error that have been set for this display

◆ UwacDisplayGetNbOutputs()

uint32_t UwacDisplayGetNbOutputs ( const UwacDisplay *  display)
 returns the number of registered outputs
Parameters
displaythe display to query
Returns
the number of outputs
Here is the caller graph for this function:

◆ UwacDisplayGetOutput()

const UwacOutput* UwacDisplayGetOutput ( UwacDisplay *  display,
int  index 
)
    retrieve a particular UwacOutput object
Parameters
displaythe display to query
indexindex of the output
Returns
the given UwacOutput, NULL if something failed (so you should query UwacDisplayGetLastError() to have the reason)
Here is the caller graph for this function:

◆ UwacDisplayNewEvent()

UwacEvent* UwacDisplayNewEvent ( UwacDisplay *  display,
int  type 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UwacDisplayQueryGetNbShmFormats()

uint32_t UwacDisplayQueryGetNbShmFormats ( UwacDisplay *  display)
 returns the number SHM formats that have been reported by the compositor
Parameters
displaya connected UwacDisplay
Returns
the number of SHM formats supported

◆ UwacDisplayQueryInterfaceVersion()

UwacReturnCode UwacDisplayQueryInterfaceVersion ( const UwacDisplay *  display,
const char *  name,
uint32_t *  version 
)

retrieves the version of a given interface

Parameters
displaythe display connection
namethe name of the interface
versionthe output variable for the version
Returns
UWAC_SUCCESS if the interface was found, UWAC_NOT_FOUND otherwise

◆ UwacDisplayQueryShmFormats()

UwacReturnCode UwacDisplayQueryShmFormats ( const UwacDisplay *  display,
enum wl_shm_format *  formats,
int  formats_size,
int *  filled 
)
    returns the supported ShmFormats
Parameters
displaya connected UwacDisplay
formatsa pointer on an array of wl_shm_format with enough place for formats_size items
formats_sizethe size of the formats array
filledthe number of filled entries in the formats array
Returns
UWAC_SUCCESS on success, an error otherwise
Here is the call graph for this function:

◆ UwacDisplayUnwatchFd()

static void UwacDisplayUnwatchFd ( UwacDisplay *  display,
int  fd 
)
static

◆ UwacDisplayWatchFd()

int UwacDisplayWatchFd ( UwacDisplay *  display,
int  fd,
uint32_t  events,
UwacTask *  task 
)
Here is the caller graph for this function:

◆ UwacErrorString()

const char* UwacErrorString ( UwacReturnCode  error)
 Returns a human readable form of a Uwac error code
Parameters
errorthe error number
Returns
the associated string

◆ UwacHasEvent()

bool UwacHasEvent ( UwacDisplay *  display)
 Returns if you have some pending events, and you can UwacNextEvent() without blocking
Parameters
displaythe UwacDisplay
Returns
if there's some pending events
Here is the caller graph for this function:

◆ UwacInstallErrorHandler()

void UwacInstallErrorHandler ( UwacErrorHandler  handler)
 install a handler that will be called when UWAC encounter internal errors. The
 handler is supposed to answer if the execution can continue. I can also be used
 to log things.
Parameters
handlerthe error handling function to install
Here is the call graph for this function:

◆ UwacNextEvent()

UwacReturnCode UwacNextEvent ( UwacDisplay *  display,
UwacEvent *  event 
)

Waits until an event occurs, and when it's there copy the event from the queue to event.

Parameters
displaythe Uwac display
eventthe event to fill
Returns
if the operation completed successfully
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UwacOpenDisplay()

UwacDisplay* UwacOpenDisplay ( const char *  name,
UwacReturnCode err 
)
 Opens the corresponding wayland display, using NULL you will open the default
 display.
Parameters
namethe name of the display to open
Returns
the created UwacDisplay object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UwacOutputGetPosition()

UwacReturnCode UwacOutputGetPosition ( const UwacOutput *  output,
UwacPosition *  pos 
)

retrieve the position of a given UwacOutput

Parameters
outputthe UwacOutput
posa pointer on the target position
Returns
UWAC_SUCCESS on success
Here is the caller graph for this function:

◆ UwacOutputGetResolution()

UwacReturnCode UwacOutputGetResolution ( const UwacOutput *  output,
UwacSize *  resolution 
)

retrieve the resolution of a given UwacOutput

Parameters
outputthe UwacOutput
resolutiona pointer on the
Returns
UWAC_SUCCESS on success
Here is the caller graph for this function:

◆ UwacRegisterCursor()

static void UwacRegisterCursor ( UwacSeat *  seat)
static
Here is the caller graph for this function:

◆ UwacSeatRegisterDDM()

static void UwacSeatRegisterDDM ( UwacSeat *  seat)
static
Here is the caller graph for this function:

◆ xdg_shell_ping()

static void xdg_shell_ping ( void *  data,
struct xdg_wm_base *  xdg_wm_base,
uint32_t  serial 
)
static

Variable Documentation

◆ errorStrings

const char* errorStrings[]
static
Initial value:
= {
"success",
"out of memory error",
"unable to connect to wayland display",
"invalid UWAC display",
"not enough resources",
"timed out",
"not found",
"closed connection",
"internal error",
}

◆ event_names

const char* event_names[]
static
Initial value:
= {
"new seat", "removed seat", "new output", "configure", "pointer enter",
"pointer leave", "pointer motion", "pointer buttons", "pointer axis", "keyboard enter",
"key", "touch frame begin", "touch up", "touch down", "touch motion",
"touch cancel", "touch frame end", "frame done", "close", NULL
}
if availableBytes return NULL
Definition: TPCircularBuffer.h:109

◆ registry_listener

const struct wl_registry_listener registry_listener
static
Initial value:
static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version)
Definition: uwac-display.c:142
static void registry_handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
Definition: uwac-display.c:277

◆ shm_listener

struct wl_shm_listener shm_listener = { cb_shm_format }
static

◆ uwacErrorHandler

◆ xdg_wm_base_listener

const struct xdg_wm_base_listener xdg_wm_base_listener
static
Initial value:
= {
}
static void xdg_shell_ping(void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial)
Definition: uwac-display.c:89