Agar


Note: The Agar manual pages follow certain conventions, notably concerning function return values. Please read AG_Intro(3) first.


SYNOPSIS

#include <agar/core.h>
#include <agar/gui.h>

DESCRIPTION

AG_DriverMw is a subclass of AG_Driver(3) for "multiple-window" drivers (i.e., drivers where Agar must interface with a native window system).

INHERITANCE HIERARCHY

AG_Driver(3)-> AG_DriverMw.

INTERNAL API

The AG_DriverMwClass structure describes a "multiple-window" graphics driver, where Agar will need to interface with an existing window manager. AG_DriverMwClass inherits from AG_DriverClass and is defined as follows:

typedef struct ag_driver_mw_class {
	struct ag_driver_class _inherit;
	/* Open/close native windows */
	int  (*openWindow)(AG_Window *, AG_Rect r, int bpp, Uint flags);
	void (*closeWindow)(AG_Window *);
	/* Show and hide window */
	int (*mapWindow)(AG_Window *);
	int (*unmapWindow)(AG_Window *);
	/* Configure stacking order and parenting */
	int (*raiseWindow)(AG_Window *);
	int (*lowerWindow)(AG_Window *);
	int (*reparentWindow)(AG_Window *, AG_Window *winParent,
	                      int x, int y);
	/* Change and query input focus state */
	int (*getInputFocus)(AG_Window **);
	int (*setInputFocus)(AG_Window *);
	/* Move and resize windows */
	int  (*moveWindow)(AG_Window *, int x, int y);
	int  (*resizeWindow)(AG_Window *, Uint w, Uint h);
	int  (*moveResizeWindow)(AG_Window *, AG_SizeAlloc *a);
	void (*preResizeCallback)(AG_Window *);
	void (*postResizeCallback)(AG_Window *, AG_SizeAlloc *a);
	/* Capture window framebuffer contents (unlike renderToSurface) */
	int (*captureWindow)(AG_Window *, AG_Surface **s);
	
	/* Configure window parameters */
	int  (*setBorderWidth)(AG_Window *, Uint w);
	int  (*setWindowCaption)(AG_Window *, const char *s);
	void (*setTransientFor)(AG_Window *, AG_Window *winParent);
	int  (*setOpacity)(AG_Window *, float opacity);
} AG_DriverMwClass;

The openWindow() operation opens a new "native" window corresponding to an AG_Window(3) that is in the process of being created, returning 0 on success or -1 on failure. The r argument specifies the preferred location and geometry of the window, in pixels. bpp specifies a preferred depth in bits per pixels. The following flags are recognized:
AG_DRIVER_MW_ANYPOSIgnore the coordinates in r and let the underlying window system select some default coordinates.

mapWindow() and unmapWindow() make a window visible or invisible, returning 0 on success and -1 on failure.

raiseWindow() and lowerWindow() respectively raise and lower the window, returning 0 on success and -1 on failure. The reparentWindow() function arranges for the window to become a child of winParent, moving it to parent-relative coordinates x, y. The function should return 0 on success or -1 on failure.

The getInputFocus() operation retrieves a pointer to the window currently holding focus, returning 0 on success. If the focus is external to the Agar application, it should return -1. setInputFocus() gives focus to the specified window, returning 0 on success or -1 on failure.

The moveWindow(), resizeWindow() and moveResizeWindow() operations respectively move, resize or move+resize a window to specified coordinates and geometry, returning 0 on success or -1 on failure.

The preResizeCallback() operation is invoked prior to a window resize, and postResizeCallback() is invoked following a window resize (the new window geometry is passed as the a argument).

The captureWindow() operation captures the window's visual rendering to an AG_Surface(3), returning 0 on success or -1 on failure.

setBorderWidth() configures a window border size in pixels, returning 0 on success or -1 if the operation is unsupported or an error occured.

setWindowCaption() sets the associated window caption text, if supported by the window system. The string passed to the function may contain characters in UTF-8 encoding. The function should return 0 on success or -1 on failure.

setTransientFor() passes a hint to the window manager that the window should be marked as "transient" for the specified window winParent. This operation is optional and window manager specific.

setOpacity() passes a window opacity argument (ranging from 0.0 to 1.0) to the underlying window manager.

SEE ALSO

AG_Driver(3), AG_DriverSw(3), AG_DriverGLX(3), AG_DriverWGL(3)

HISTORY

The AG_DriverMw class first appeared in Agar 1.4.0.