aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/dmx/examples
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/dmx/examples')
-rw-r--r--xorg-server/hw/dmx/examples/dmxaddinput.c20
-rw-r--r--xorg-server/hw/dmx/examples/dmxaddscreen.c61
-rw-r--r--xorg-server/hw/dmx/examples/dmxinfo.c129
-rw-r--r--xorg-server/hw/dmx/examples/dmxreconfig.c139
-rw-r--r--xorg-server/hw/dmx/examples/dmxresize.c27
-rw-r--r--xorg-server/hw/dmx/examples/dmxrminput.c13
-rw-r--r--xorg-server/hw/dmx/examples/dmxrmscreen.c15
-rw-r--r--xorg-server/hw/dmx/examples/dmxwininfo.c748
-rw-r--r--xorg-server/hw/dmx/examples/ev.c218
-rw-r--r--xorg-server/hw/dmx/examples/evi.c21
-rw-r--r--xorg-server/hw/dmx/examples/res.c32
-rw-r--r--xorg-server/hw/dmx/examples/xbell.c45
-rw-r--r--xorg-server/hw/dmx/examples/xinput.c215
-rw-r--r--xorg-server/hw/dmx/examples/xled.c28
-rw-r--r--xorg-server/hw/dmx/examples/xtest.c14
15 files changed, 932 insertions, 793 deletions
diff --git a/xorg-server/hw/dmx/examples/dmxaddinput.c b/xorg-server/hw/dmx/examples/dmxaddinput.c
index dcfd4f5cc..fdd09b99b 100644
--- a/xorg-server/hw/dmx/examples/dmxaddinput.c
+++ b/xorg-server/hw/dmx/examples/dmxaddinput.c
@@ -36,14 +36,15 @@
#include <X11/Xlib.h>
#include <X11/extensions/dmxext.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- int id = -1;
- int status;
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int id = -1;
+ int status;
if (argc != 5) {
printf("Usage: %s display c|b name|screen isCore\n", argv[0]);
@@ -72,8 +73,9 @@ int main(int argc, char **argv)
if (argv[2][0] == 'c') {
status = DMXAddConsoleInput(display, argv[3], atoi(argv[4]), &id);
- } else {
- status = DMXAddBackendInput(display, atoi(argv[3]), atoi(argv[4]),&id);
+ }
+ else {
+ status = DMXAddBackendInput(display, atoi(argv[3]), atoi(argv[4]), &id);
}
printf("status = %d, id = %d\n", status, id);
diff --git a/xorg-server/hw/dmx/examples/dmxaddscreen.c b/xorg-server/hw/dmx/examples/dmxaddscreen.c
index 8e60872df..58129faa5 100644
--- a/xorg-server/hw/dmx/examples/dmxaddscreen.c
+++ b/xorg-server/hw/dmx/examples/dmxaddscreen.c
@@ -37,18 +37,21 @@
#include <X11/Xlib.h>
#include <X11/extensions/dmxext.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- int screenNum;
- DMXScreenAttributes attr;
- unsigned int mask = 0;
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int screenNum;
+ DMXScreenAttributes attr;
+ unsigned int mask = 0;
if (argc != 4 && argc != 14) {
- printf("Usage: %s display screenNum displayName [scrnx scrny scrnw scrnh rootx rooty rootw rooth originx originy]\n", argv[0]);
+ printf
+ ("Usage: %s display screenNum displayName [scrnx scrny scrnw scrnh rootx rooty rootw rooth originx originy]\n",
+ argv[0]);
return -1;
}
@@ -59,27 +62,25 @@ int main(int argc, char **argv)
screenNum = strtol(argv[2], NULL, 0);
if (argc == 14) {
- mask |= (DMXScreenWindowXoffset |
- DMXScreenWindowYoffset |
- DMXScreenWindowWidth |
- DMXScreenWindowHeight);
- attr.screenWindowXoffset = strtol(argv[4], NULL, 0);
- attr.screenWindowYoffset = strtol(argv[5], NULL, 0);
- attr.screenWindowWidth = strtol(argv[6], NULL, 0);
- attr.screenWindowHeight = strtol(argv[7], NULL, 0);
+ mask |= (DMXScreenWindowXoffset |
+ DMXScreenWindowYoffset |
+ DMXScreenWindowWidth | DMXScreenWindowHeight);
+ attr.screenWindowXoffset = strtol(argv[4], NULL, 0);
+ attr.screenWindowYoffset = strtol(argv[5], NULL, 0);
+ attr.screenWindowWidth = strtol(argv[6], NULL, 0);
+ attr.screenWindowHeight = strtol(argv[7], NULL, 0);
- mask |= (DMXRootWindowXoffset |
- DMXRootWindowYoffset |
- DMXRootWindowWidth |
- DMXRootWindowHeight);
- attr.rootWindowXoffset = strtol(argv[8], NULL, 0);
- attr.rootWindowYoffset = strtol(argv[9], NULL, 0);
- attr.rootWindowWidth = strtol(argv[10], NULL, 0);
- attr.rootWindowHeight = strtol(argv[11], NULL, 0);
+ mask |= (DMXRootWindowXoffset |
+ DMXRootWindowYoffset |
+ DMXRootWindowWidth | DMXRootWindowHeight);
+ attr.rootWindowXoffset = strtol(argv[8], NULL, 0);
+ attr.rootWindowYoffset = strtol(argv[9], NULL, 0);
+ attr.rootWindowWidth = strtol(argv[10], NULL, 0);
+ attr.rootWindowHeight = strtol(argv[11], NULL, 0);
- mask |= DMXRootWindowXorigin | DMXRootWindowYorigin;
- attr.rootWindowXorigin = strtol(argv[12], NULL, 0);
- attr.rootWindowYorigin = strtol(argv[13], NULL, 0);
+ mask |= DMXRootWindowXorigin | DMXRootWindowYorigin;
+ attr.rootWindowXorigin = strtol(argv[12], NULL, 0);
+ attr.rootWindowYorigin = strtol(argv[13], NULL, 0);
}
if (!DMXQueryExtension(display, &event_base, &error_base)) {
@@ -98,8 +99,8 @@ int main(int argc, char **argv)
major_version, minor_version, patch_version);
if (!DMXAddScreen(display, argv[3], mask, &attr, &screenNum))
- printf("Failed to add %s as screen #%d\n", argv[2], screenNum);
-
+ printf("Failed to add %s as screen #%d\n", argv[2], screenNum);
+
XCloseDisplay(display);
return 0;
}
diff --git a/xorg-server/hw/dmx/examples/dmxinfo.c b/xorg-server/hw/dmx/examples/dmxinfo.c
index dedce6e8d..fea94e203 100644
--- a/xorg-server/hw/dmx/examples/dmxinfo.c
+++ b/xorg-server/hw/dmx/examples/dmxinfo.c
@@ -36,45 +36,52 @@
#include <X11/Xlib.h>
#include <X11/extensions/dmxext.h>
-static void indent(int level)
+static void
+indent(int level)
{
int i;
- for (i = 0; i < level; i++) printf(" ");
+
+ for (i = 0; i < level; i++)
+ printf(" ");
}
-static void print_window_id(const char *displayName, Display *display,
- Window window, int level, int child)
+static void
+print_window_id(const char *displayName, Display * display,
+ Window window, int level, int child)
{
- char *name;
-
- if (!XFetchName(display, window, &name)) name = NULL;
+ char *name;
+
+ if (!XFetchName(display, window, &name))
+ name = NULL;
indent(level);
- if (child) printf("(%d) ", child);
+ if (child)
+ printf("(%d) ", child);
printf("%s window 0x%08lx: %s%s\n",
displayName,
- (long unsigned)window,
- name ? name : "",
- (window == DefaultRootWindow(display))
+ (long unsigned) window,
+ name ? name : "", (window == DefaultRootWindow(display))
? " (DMX root window)" : "");
- if (name) XFree(name);
+ if (name)
+ XFree(name);
}
-static void print_info(Display *display, Window window, int level, int child)
+static void
+print_info(Display * display, Window window, int level, int child)
{
DMXWindowAttributes winfo[128];
- int count;
- int i;
-
+ int count;
+ int i;
+
if (!DMXGetWindowAttributes(display, window, &count, 128, winfo)) {
printf("Could not get window information for 0x%08lx\n",
- (long unsigned)window);
+ (long unsigned) window);
exit(-2);
}
printf("\n");
print_window_id("DMX", display, window, level, child);
for (i = 0; i < count; i++) {
- DMXScreenAttributes sinfo;
- Display *backend;
+ DMXScreenAttributes sinfo;
+ Display *backend;
/* This could also be cached -- the information doesn't change. */
if (!DMXGetScreenAttributes(display, winfo[i].screen, &sinfo)) {
@@ -86,78 +93,86 @@ static void print_info(Display *display, Window window, int level, int child)
exit(-2);
}
XCloseDisplay(backend);
-
- indent(level+1);
+
+ indent(level + 1);
printf("%s window 0x%08lx: %dx%d%+d%+d",
sinfo.displayName,
- (long unsigned)winfo[i].window,
+ (long unsigned) winfo[i].window,
winfo[i].pos.width, winfo[i].pos.height,
winfo[i].pos.x, winfo[i].pos.y);
if (!winfo[i].vis.width
- && !winfo[i].vis.height
- && !winfo[i].vis.x
- && !winfo[i].vis.y) printf(" not visible\n");
+ && !winfo[i].vis.height && !winfo[i].vis.x && !winfo[i].vis.y)
+ printf(" not visible\n");
else if (winfo[i].vis.width == winfo[i].pos.width
&& winfo[i].vis.height == winfo[i].pos.height) {
- printf( " %+d%+d\n", winfo[i].vis.x, winfo[i].vis.y);
- } else {
- printf( " %dx%d%+d%+d\n",
- winfo[i].vis.width, winfo[i].vis.height,
- winfo[i].vis.x, winfo[i].vis.y);
+ printf(" %+d%+d\n", winfo[i].vis.x, winfo[i].vis.y);
+ }
+ else {
+ printf(" %dx%d%+d%+d\n",
+ winfo[i].vis.width, winfo[i].vis.height,
+ winfo[i].vis.x, winfo[i].vis.y);
}
}
}
-static void print_tree(Display *display, Window window, int level, int child)
+static void
+print_tree(Display * display, Window window, int level, int child)
{
- Window root, parent;
- Window *list;
+ Window root, parent;
+ Window *list;
unsigned int count;
unsigned int i;
print_info(display, window, level, child);
-
+
if (!XQueryTree(display, window, &root, &parent, &list, &count)) {
printf("Cannot query window tree for 0x%08lx\n",
- (long unsigned)window);
+ (long unsigned) window);
exit(-3);
}
if (count) {
- indent(level+1);
+ indent(level + 1);
printf("%d child%s:\n", count, count > 1 ? "ren" : "");
for (i = 0; i < count; i++) {
- print_tree(display, list[i], level+1, i+1);
+ print_tree(display, list[i], level + 1, i + 1);
}
}
}
-static const char *core(DMXInputAttributes *iinfo)
+static const char *
+core(DMXInputAttributes * iinfo)
{
- if (iinfo->isCore) return "core";
- else if (iinfo->sendsCore) return "extension (sends core)";
- else return "extension";
+ if (iinfo->isCore)
+ return "core";
+ else if (iinfo->sendsCore)
+ return "extension (sends core)";
+ else
+ return "extension";
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- Window window = 0;
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- DMXScreenAttributes sinfo;
- DMXInputAttributes iinfo;
- int count;
- int i;
+ Display *display = NULL;
+ Window window = 0;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ DMXScreenAttributes sinfo;
+ DMXInputAttributes iinfo;
+ int count;
+ int i;
if (argc == 2 || argc == 3) {
if (!(display = XOpenDisplay(argv[1]))) {
printf("Cannot open display %s\n", argv[1]);
return -1;
}
- if (argc == 3) window = strtol(argv[2], NULL, 0);
- } else {
+ if (argc == 3)
+ window = strtol(argv[2], NULL, 0);
+ }
+ else {
printf("Usage: %s display [windowid]\n", argv[0]);
return -1;
}
@@ -231,9 +246,11 @@ int main(int argc, char **argv)
}
}
- if (window) print_info(display, window, 0, 0);
- else print_tree(display, DefaultRootWindow(display), 0, 0);
-
+ if (window)
+ print_info(display, window, 0, 0);
+ else
+ print_tree(display, DefaultRootWindow(display), 0, 0);
+
XCloseDisplay(display);
return 0;
}
diff --git a/xorg-server/hw/dmx/examples/dmxreconfig.c b/xorg-server/hw/dmx/examples/dmxreconfig.c
index 042f8a112..9587682db 100644
--- a/xorg-server/hw/dmx/examples/dmxreconfig.c
+++ b/xorg-server/hw/dmx/examples/dmxreconfig.c
@@ -36,47 +36,47 @@
#include <X11/Xlib.h>
#include <X11/extensions/dmxext.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- int screen;
- DMXScreenAttributes attr;
- unsigned int mask = 0;
- int status;
- int errorScreen;
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int screen;
+ DMXScreenAttributes attr;
+ unsigned int mask = 0;
+ int status;
+ int errorScreen;
if (argc != 13) {
- fprintf(stderr, "Usage: %s display screen scrnx scrny scrnw scrnh rootx rooty rootw rooth originx originy\n", argv[0]);
- return -1;
+ fprintf(stderr,
+ "Usage: %s display screen scrnx scrny scrnw scrnh rootx rooty rootw rooth originx originy\n",
+ argv[0]);
+ return -1;
}
if (!(display = XOpenDisplay(argv[1]))) {
- fprintf(stderr, "Cannot open display %s\n", argv[1]);
- return -1;
+ fprintf(stderr, "Cannot open display %s\n", argv[1]);
+ return -1;
}
- screen = strtol(argv[2], NULL, 0);
+ screen = strtol(argv[2], NULL, 0);
mask |= (DMXScreenWindowXoffset |
- DMXScreenWindowYoffset |
- DMXScreenWindowWidth |
- DMXScreenWindowHeight);
- attr.screenWindowXoffset = strtol(argv[3], NULL, 0);
- attr.screenWindowYoffset = strtol(argv[4], NULL, 0);
- attr.screenWindowWidth = strtol(argv[5], NULL, 0);
- attr.screenWindowHeight = strtol(argv[6], NULL, 0);
+ DMXScreenWindowYoffset |
+ DMXScreenWindowWidth | DMXScreenWindowHeight);
+ attr.screenWindowXoffset = strtol(argv[3], NULL, 0);
+ attr.screenWindowYoffset = strtol(argv[4], NULL, 0);
+ attr.screenWindowWidth = strtol(argv[5], NULL, 0);
+ attr.screenWindowHeight = strtol(argv[6], NULL, 0);
mask |= (DMXRootWindowXoffset |
- DMXRootWindowYoffset |
- DMXRootWindowWidth |
- DMXRootWindowHeight);
- attr.rootWindowXoffset = strtol(argv[7], NULL, 0);
- attr.rootWindowYoffset = strtol(argv[8], NULL, 0);
- attr.rootWindowWidth = strtol(argv[9], NULL, 0);
- attr.rootWindowHeight = strtol(argv[10], NULL, 0);
+ DMXRootWindowYoffset | DMXRootWindowWidth | DMXRootWindowHeight);
+ attr.rootWindowXoffset = strtol(argv[7], NULL, 0);
+ attr.rootWindowYoffset = strtol(argv[8], NULL, 0);
+ attr.rootWindowWidth = strtol(argv[9], NULL, 0);
+ attr.rootWindowHeight = strtol(argv[10], NULL, 0);
mask |= DMXRootWindowXorigin | DMXRootWindowYorigin;
attr.rootWindowXorigin = strtol(argv[11], NULL, 0);
@@ -99,62 +99,61 @@ int main(int argc, char **argv)
if (major_version == 1 && minor_version < 3) {
fprintf(stderr,
- "ReconfigureScreen not supported in this extension version\n");
+ "ReconfigureScreen not supported in this extension version\n");
return -1;
}
if (major_version < 2) {
fprintf(stderr,
- "ChangeScreensAttributes not supported in this extension "
- "version\n");
+ "ChangeScreensAttributes not supported in this extension "
+ "version\n");
return -1;
}
if (!(status = DMXChangeScreensAttributes(display, 1, &screen, 1, &mask,
&attr, &errorScreen))) {
printf("Reconfigured screen #%d to "
- "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n",
- screen,
- attr.screenWindowWidth,
- attr.screenWindowHeight,
- (attr.screenWindowXoffset < 0 ? "" : "+"),
- attr.screenWindowXoffset,
- (attr.screenWindowYoffset < 0 ? "" : "+"),
- attr.screenWindowYoffset,
- attr.rootWindowWidth,
- attr.rootWindowHeight,
- (attr.rootWindowXoffset < 0 ? "" : "+"),
- attr.rootWindowXoffset,
- (attr.rootWindowYoffset < 0 ? "" : "+"),
- attr.rootWindowYoffset,
- (attr.rootWindowXorigin < 0 ? "" : "+"),
- attr.rootWindowXorigin,
- (attr.rootWindowYorigin < 0 ? "" : "+"),
- attr.rootWindowYorigin);
- } else {
+ "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n",
+ screen,
+ attr.screenWindowWidth,
+ attr.screenWindowHeight,
+ (attr.screenWindowXoffset < 0 ? "" : "+"),
+ attr.screenWindowXoffset,
+ (attr.screenWindowYoffset < 0 ? "" : "+"),
+ attr.screenWindowYoffset,
+ attr.rootWindowWidth,
+ attr.rootWindowHeight,
+ (attr.rootWindowXoffset < 0 ? "" : "+"),
+ attr.rootWindowXoffset,
+ (attr.rootWindowYoffset < 0 ? "" : "+"),
+ attr.rootWindowYoffset,
+ (attr.rootWindowXorigin < 0 ? "" : "+"),
+ attr.rootWindowXorigin,
+ (attr.rootWindowYorigin < 0 ? "" : "+"), attr.rootWindowYorigin);
+ }
+ else {
fprintf(stderr,
"Could not set screen #%d to "
- "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n"
+ "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n"
"[status = %d, errorScreen=%d]\n",
screen,
- attr.screenWindowWidth,
- attr.screenWindowHeight,
- (attr.screenWindowXoffset < 0 ? "" : "+"),
- attr.screenWindowXoffset,
- (attr.screenWindowYoffset < 0 ? "" : "+"),
- attr.screenWindowYoffset,
- attr.rootWindowWidth,
- attr.rootWindowHeight,
- (attr.rootWindowXoffset < 0 ? "" : "+"),
- attr.rootWindowXoffset,
- (attr.rootWindowYoffset < 0 ? "" : "+"),
- attr.rootWindowYoffset,
- (attr.rootWindowXorigin < 0 ? "" : "+"),
- attr.rootWindowXorigin,
- (attr.rootWindowYorigin < 0 ? "" : "+"),
- attr.rootWindowYorigin,
- status, errorScreen);
- return -1;
+ attr.screenWindowWidth,
+ attr.screenWindowHeight,
+ (attr.screenWindowXoffset < 0 ? "" : "+"),
+ attr.screenWindowXoffset,
+ (attr.screenWindowYoffset < 0 ? "" : "+"),
+ attr.screenWindowYoffset,
+ attr.rootWindowWidth,
+ attr.rootWindowHeight,
+ (attr.rootWindowXoffset < 0 ? "" : "+"),
+ attr.rootWindowXoffset,
+ (attr.rootWindowYoffset < 0 ? "" : "+"),
+ attr.rootWindowYoffset,
+ (attr.rootWindowXorigin < 0 ? "" : "+"),
+ attr.rootWindowXorigin,
+ (attr.rootWindowYorigin < 0 ? "" : "+"),
+ attr.rootWindowYorigin, status, errorScreen);
+ return -1;
}
XCloseDisplay(display);
diff --git a/xorg-server/hw/dmx/examples/dmxresize.c b/xorg-server/hw/dmx/examples/dmxresize.c
index caed91d8d..fed3bd08a 100644
--- a/xorg-server/hw/dmx/examples/dmxresize.c
+++ b/xorg-server/hw/dmx/examples/dmxresize.c
@@ -36,15 +36,16 @@
#include <X11/Xlib.h>
#include <X11/extensions/dmxext.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- int width, height, shiftX, shiftY, status;
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int width, height, shiftX, shiftY, status;
DMXDesktopAttributes attr;
- unsigned int mask;
+ unsigned int mask;
if (argc != 6) {
printf("Usage: %s display width height shiftX shiftY\n", argv[0]);
@@ -56,7 +57,7 @@ int main(int argc, char **argv)
return -1;
}
- width = strtol(argv[2], NULL, 0);
+ width = strtol(argv[2], NULL, 0);
height = strtol(argv[3], NULL, 0);
shiftX = strtol(argv[4], NULL, 0);
shiftY = strtol(argv[5], NULL, 0);
@@ -76,11 +77,9 @@ int main(int argc, char **argv)
printf("Extension version: %d.%d patch %d\n",
major_version, minor_version, patch_version);
- mask = (DMXDesktopWidth |
- DMXDesktopHeight |
- DMXDesktopShiftX |
- DMXDesktopShiftY);
- attr.width = width;
+ mask = (DMXDesktopWidth |
+ DMXDesktopHeight | DMXDesktopShiftX | DMXDesktopShiftY);
+ attr.width = width;
attr.height = height;
attr.shiftX = shiftX;
attr.shiftY = shiftY;
@@ -98,7 +97,7 @@ int main(int argc, char **argv)
printf("status = %d (UNKNOWN ERROR *****)\n", status);
break;
}
-
+
XCloseDisplay(display);
return 0;
}
diff --git a/xorg-server/hw/dmx/examples/dmxrminput.c b/xorg-server/hw/dmx/examples/dmxrminput.c
index ef62cab8b..0113a7f5c 100644
--- a/xorg-server/hw/dmx/examples/dmxrminput.c
+++ b/xorg-server/hw/dmx/examples/dmxrminput.c
@@ -36,13 +36,14 @@
#include <X11/Xlib.h>
#include <X11/extensions/dmxext.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- int status;
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int status;
if (argc != 3) {
printf("Usage: %s display id\n", argv[0]);
diff --git a/xorg-server/hw/dmx/examples/dmxrmscreen.c b/xorg-server/hw/dmx/examples/dmxrmscreen.c
index fecf0f6c1..627875bda 100644
--- a/xorg-server/hw/dmx/examples/dmxrmscreen.c
+++ b/xorg-server/hw/dmx/examples/dmxrmscreen.c
@@ -37,13 +37,14 @@
#include <X11/Xlib.h>
#include <X11/extensions/dmxext.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- int screenNum;
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int screenNum;
if (argc != 3) {
printf("Usage: %s display screenNum\n", argv[0]);
@@ -74,7 +75,7 @@ int main(int argc, char **argv)
if (!DMXRemoveScreen(display, screenNum))
printf("Failed to remove screen #%d\n", screenNum);
-
+
XCloseDisplay(display);
return 0;
}
diff --git a/xorg-server/hw/dmx/examples/dmxwininfo.c b/xorg-server/hw/dmx/examples/dmxwininfo.c
index 3d027d530..9b1ce76b6 100644
--- a/xorg-server/hw/dmx/examples/dmxwininfo.c
+++ b/xorg-server/hw/dmx/examples/dmxwininfo.c
@@ -43,183 +43,180 @@
static const char *FontName = "fixed";
-
static void
-EventLoop(Display *dpy, Window win, GC gc)
+EventLoop(Display * dpy, Window win, GC gc)
{
- XEvent ev;
- while (1) {
- XNextEvent( dpy, &ev );
- switch (ev.type) {
- case ReparentNotify:
- break;
- case MapNotify:
- break;
- case ConfigureNotify:
- case Expose:
- {
+ XEvent ev;
+
+ while (1) {
+ XNextEvent(dpy, &ev);
+ switch (ev.type) {
+ case ReparentNotify:
+ break;
+ case MapNotify:
+ break;
+ case ConfigureNotify:
+ case Expose:
+ {
int numScreens, count, i;
DMXWindowAttributes *winInfo;
int x, y;
const char *msg = "DMX window info:";
DMXGetScreenCount(dpy, &numScreens);
- winInfo
- = (DMXWindowAttributes *)
+ winInfo = (DMXWindowAttributes *)
malloc(numScreens * sizeof(DMXWindowAttributes));
assert(winInfo);
- if (!DMXGetWindowAttributes(dpy, win, &count,
- numScreens, winInfo)) {
- printf("Could not get window information for 0x%08lx\n",
- (long unsigned)win);
+ if (!DMXGetWindowAttributes(dpy, win, &count, numScreens, winInfo)) {
+ printf("Could not get window information for 0x%08lx\n",
+ (long unsigned) win);
}
x = y = 50;
XClearWindow(dpy, win);
XDrawString(dpy, win, gc, x, y, msg, strlen(msg));
y += 20;
for (i = 0; i < count; i++) {
- char str[500];
- snprintf(str, sizeof(str),
- "screen %d: pos: %dx%d+%d+%d visible: %dx%d+%d+%d",
- winInfo[i].screen,
- winInfo[i].pos.width, winInfo[i].pos.height,
- winInfo[i].pos.x, winInfo[i].pos.y,
- winInfo[i].vis.width, winInfo[i].vis.height,
- winInfo[i].vis.x, winInfo[i].vis.y);
- XDrawString(dpy, win, gc, x, y, str, strlen(str));
- y += 20;
+ char str[500];
+
+ snprintf(str, sizeof(str),
+ "screen %d: pos: %dx%d+%d+%d visible: %dx%d+%d+%d",
+ winInfo[i].screen,
+ winInfo[i].pos.width, winInfo[i].pos.height,
+ winInfo[i].pos.x, winInfo[i].pos.y,
+ winInfo[i].vis.width, winInfo[i].vis.height,
+ winInfo[i].vis.x, winInfo[i].vis.y);
+ XDrawString(dpy, win, gc, x, y, str, strlen(str));
+ y += 20;
}
free(winInfo);
- }
- break;
- default:
- printf("Event type 0x%x\n", ev.type);
- }
- }
+ }
+ break;
+ default:
+ printf("Event type 0x%x\n", ev.type);
+ }
+ }
}
int
main(int argc, char *argv[])
{
- const char *displayName = NULL;
- Display *dpy;
- int event_base, error_base;
- int scr, n;
- long vinfoMask, attrMask;
- XVisualInfo vinfoTemp, *visInfo;
- Visual *vis;
- Window win, root;
- XSetWindowAttributes attr;
- XFontStruct *fontInfo;
- GC gc;
-
- if (argc > 1) {
- displayName = argv[1];
- }
-
- dpy = XOpenDisplay(displayName);
- if (!dpy) {
- fprintf(stderr, "Unable to open display %s\n", displayName);
- return -1;
- }
-
- if (!DMXQueryExtension(dpy, &event_base, &error_base)) {
- fprintf(stderr, "DMX extension not available on this display.\n");
- return -1;
- }
-
- scr = DefaultScreen(dpy);
- root = RootWindow(dpy, scr);
- vis = DefaultVisual(dpy, scr);
-
- vinfoMask = VisualIDMask;
- vinfoTemp.visualid = vis->visualid;
- visInfo = XGetVisualInfo(dpy, vinfoMask, &vinfoTemp, &n);
- if (!visInfo || n != 1) {
- fprintf(stderr, "Unable to get visual!\n");
- XCloseDisplay(dpy);
- return -1;
- }
-
- attr.background_pixel = 0;
- attr.border_pixel = 0;
- attr.colormap = XCreateColormap(dpy, root, visInfo->visual, AllocNone);
- attr.event_mask = StructureNotifyMask | ExposureMask;
- attrMask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
-
- win = XCreateWindow(dpy, root,
- 500, 500, 600, 400, /* x, y, w, h */
- 0, /* border_width */
- visInfo->depth, InputOutput,
- visInfo->visual, attrMask, &attr);
-
-
- if (!win) {
- fprintf(stderr, "Unable to create window!\n");
- XCloseDisplay(dpy);
- return -1;
- }
-
- fontInfo = XLoadQueryFont(dpy, FontName);
- if (!fontInfo) {
- fprintf(stderr, "Error: font %s not found\n", FontName);
- exit(0);
- }
-
- gc = XCreateGC(dpy, win, 0, NULL);
- XSetBackground(dpy, gc, BlackPixel(dpy, scr));
- XSetForeground(dpy, gc, WhitePixel(dpy, scr));
- XSetFont(dpy, gc, fontInfo->fid);
-
- XMapWindow(dpy, win);
-
- EventLoop(dpy, win, gc);
-
- XDestroyWindow(dpy, win);
- XCloseDisplay(dpy);
- return 0;
+ const char *displayName = NULL;
+ Display *dpy;
+ int event_base, error_base;
+ int scr, n;
+ long vinfoMask, attrMask;
+ XVisualInfo vinfoTemp, *visInfo;
+ Visual *vis;
+ Window win, root;
+ XSetWindowAttributes attr;
+ XFontStruct *fontInfo;
+ GC gc;
+
+ if (argc > 1) {
+ displayName = argv[1];
+ }
+
+ dpy = XOpenDisplay(displayName);
+ if (!dpy) {
+ fprintf(stderr, "Unable to open display %s\n", displayName);
+ return -1;
+ }
+
+ if (!DMXQueryExtension(dpy, &event_base, &error_base)) {
+ fprintf(stderr, "DMX extension not available on this display.\n");
+ return -1;
+ }
+
+ scr = DefaultScreen(dpy);
+ root = RootWindow(dpy, scr);
+ vis = DefaultVisual(dpy, scr);
+
+ vinfoMask = VisualIDMask;
+ vinfoTemp.visualid = vis->visualid;
+ visInfo = XGetVisualInfo(dpy, vinfoMask, &vinfoTemp, &n);
+ if (!visInfo || n != 1) {
+ fprintf(stderr, "Unable to get visual!\n");
+ XCloseDisplay(dpy);
+ return -1;
+ }
+
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(dpy, root, visInfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask;
+ attrMask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ win = XCreateWindow(dpy, root, 500, 500, 600, 400, /* x, y, w, h */
+ 0, /* border_width */
+ visInfo->depth, InputOutput,
+ visInfo->visual, attrMask, &attr);
+
+ if (!win) {
+ fprintf(stderr, "Unable to create window!\n");
+ XCloseDisplay(dpy);
+ return -1;
+ }
+
+ fontInfo = XLoadQueryFont(dpy, FontName);
+ if (!fontInfo) {
+ fprintf(stderr, "Error: font %s not found\n", FontName);
+ exit(0);
+ }
+
+ gc = XCreateGC(dpy, win, 0, NULL);
+ XSetBackground(dpy, gc, BlackPixel(dpy, scr));
+ XSetForeground(dpy, gc, WhitePixel(dpy, scr));
+ XSetFont(dpy, gc, fontInfo->fid);
+
+ XMapWindow(dpy, win);
+
+ EventLoop(dpy, win, gc);
+
+ XDestroyWindow(dpy, win);
+ XCloseDisplay(dpy);
+ return 0;
}
#if 00
-static void make_window( char *title, int color_flag )
+static void
+make_window(char *title, int color_flag)
{
- int x = 10, y = 10, width = 400, height = 300;
- Display *dpy;
- int scr;
- Window root, win;
- Colormap cmap;
- XColor xcolor;
- int attr_flags;
- XVisualInfo *visinfo;
- XSetWindowAttributes attr;
- XTextProperty tp;
- XSizeHints sh;
- XEvent e;
- XMesaContext context;
- XMesaVisual visual;
- XMesaBuffer buffer;
-
-
- /*
- * Do the usual X things to make a window.
- */
-
- dpy = XOpenDisplay(NULL);
- if (!dpy) {
- printf("Couldn't open default display!\n");
- exit(1);
- }
-
- scr = DefaultScreen(dpy);
- root = RootWindow(dpy, scr);
-
- /* alloc visinfo struct */
- visinfo = (XVisualInfo *) malloc( sizeof(XVisualInfo) );
-
- /* Get a visual and colormap */
- if (color_flag) {
- /* Open TrueColor window */
+ int x = 10, y = 10, width = 400, height = 300;
+ Display *dpy;
+ int scr;
+ Window root, win;
+ Colormap cmap;
+ XColor xcolor;
+ int attr_flags;
+ XVisualInfo *visinfo;
+ XSetWindowAttributes attr;
+ XTextProperty tp;
+ XSizeHints sh;
+ XEvent e;
+ XMesaContext context;
+ XMesaVisual visual;
+ XMesaBuffer buffer;
+
+ /*
+ * Do the usual X things to make a window.
+ */
+
+ dpy = XOpenDisplay(NULL);
+ if (!dpy) {
+ printf("Couldn't open default display!\n");
+ exit(1);
+ }
+
+ scr = DefaultScreen(dpy);
+ root = RootWindow(dpy, scr);
+
+ /* alloc visinfo struct */
+ visinfo = (XVisualInfo *) malloc(sizeof(XVisualInfo));
+
+ /* Get a visual and colormap */
+ if (color_flag) {
+ /* Open TrueColor window */
/*
if (!XMatchVisualInfo( dpy, scr, 24, TrueColor, visinfo )) {
@@ -227,269 +224,254 @@ static void make_window( char *title, int color_flag )
exit(1);
}
*/
- if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) {
- printf("Couldn't get 8-bit PseudoColor visual!\n");
- exit(1);
- }
+ if (!XMatchVisualInfo(dpy, scr, 8, PseudoColor, visinfo)) {
+ printf("Couldn't get 8-bit PseudoColor visual!\n");
+ exit(1);
+ }
- cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone );
- Black = Red = Green = Blue = 0;
- }
- else {
- /* Open color index window */
+ cmap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
+ Black = Red = Green = Blue = 0;
+ }
+ else {
+ /* Open color index window */
- if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) {
- printf("Couldn't get 8-bit PseudoColor visual\n");
- exit(1);
- }
+ if (!XMatchVisualInfo(dpy, scr, 8, PseudoColor, visinfo)) {
+ printf("Couldn't get 8-bit PseudoColor visual\n");
+ exit(1);
+ }
- cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone );
+ cmap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
- /* Allocate colors */
- xcolor.red = 0x0;
- xcolor.green = 0x0;
- xcolor.blue = 0x0;
- xcolor.flags = DoRed | DoGreen | DoBlue;
- if (!XAllocColor( dpy, cmap, &xcolor )) {
- printf("Couldn't allocate black!\n");
- exit(1);
- }
- Black = xcolor.pixel;
-
- xcolor.red = 0xffff;
- xcolor.green = 0x0;
- xcolor.blue = 0x0;
- xcolor.flags = DoRed | DoGreen | DoBlue;
- if (!XAllocColor( dpy, cmap, &xcolor )) {
- printf("Couldn't allocate red!\n");
- exit(1);
- }
- Red = xcolor.pixel;
-
- xcolor.red = 0x0;
- xcolor.green = 0xffff;
- xcolor.blue = 0x0;
- xcolor.flags = DoRed | DoGreen | DoBlue;
- if (!XAllocColor( dpy, cmap, &xcolor )) {
- printf("Couldn't allocate green!\n");
- exit(1);
- }
- Green = xcolor.pixel;
-
- xcolor.red = 0x0;
- xcolor.green = 0x0;
- xcolor.blue = 0xffff;
- xcolor.flags = DoRed | DoGreen | DoBlue;
- if (!XAllocColor( dpy, cmap, &xcolor )) {
- printf("Couldn't allocate blue!\n");
- exit(1);
- }
- Blue = xcolor.pixel;
- }
-
- /* set window attributes */
- attr.colormap = cmap;
- attr.event_mask = ExposureMask | StructureNotifyMask;
- attr.border_pixel = BlackPixel( dpy, scr );
- attr.background_pixel = BlackPixel( dpy, scr );
- attr_flags = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel;
-
- /* Create the window */
- win = XCreateWindow( dpy, root, x,y, width, height, 0,
- visinfo->depth, InputOutput,
- visinfo->visual,
- attr_flags, &attr);
- if (!win) {
- printf("Couldn't open window!\n");
- exit(1);
- }
-
- XStringListToTextProperty(&title, 1, &tp);
- sh.flags = USPosition | USSize;
- XSetWMProperties(dpy, win, &tp, &tp, 0, 0, &sh, 0, 0);
- XMapWindow(dpy, win);
- while (1) {
- XNextEvent( dpy, &e );
- if (e.type == MapNotify && e.xmap.window == win) {
- break;
- }
- }
-
-
- /*
- * Now do the special Mesa/Xlib stuff!
- */
-
- visual = XMesaCreateVisual( dpy, visinfo,
- (GLboolean) color_flag,
- GL_FALSE, /* alpha_flag */
- GL_FALSE, /* db_flag */
- GL_FALSE, /* stereo flag */
- GL_FALSE, /* ximage_flag */
- 0, /* depth size */
- 0, /* stencil size */
- 0,0,0,0, /* accum_size */
- 0, /* num samples */
- 0, /* level */
- 0 /* caveat */
- );
- if (!visual) {
- printf("Couldn't create Mesa/X visual!\n");
- exit(1);
- }
-
- /* Create a Mesa rendering context */
- context = XMesaCreateContext( visual,
- NULL /* share_list */
- );
- if (!context) {
- printf("Couldn't create Mesa/X context!\n");
- exit(1);
- }
-
- buffer = XMesaCreateWindowBuffer( visual, win );
- if (!buffer) {
- printf("Couldn't create Mesa/X buffer!\n");
- exit(1);
- }
-
-
- XMesaMakeCurrent( context, buffer );
-
- /* Ready to render! */
+ /* Allocate colors */
+ xcolor.red = 0x0;
+ xcolor.green = 0x0;
+ xcolor.blue = 0x0;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor(dpy, cmap, &xcolor)) {
+ printf("Couldn't allocate black!\n");
+ exit(1);
+ }
+ Black = xcolor.pixel;
+
+ xcolor.red = 0xffff;
+ xcolor.green = 0x0;
+ xcolor.blue = 0x0;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor(dpy, cmap, &xcolor)) {
+ printf("Couldn't allocate red!\n");
+ exit(1);
+ }
+ Red = xcolor.pixel;
+
+ xcolor.red = 0x0;
+ xcolor.green = 0xffff;
+ xcolor.blue = 0x0;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor(dpy, cmap, &xcolor)) {
+ printf("Couldn't allocate green!\n");
+ exit(1);
+ }
+ Green = xcolor.pixel;
+
+ xcolor.red = 0x0;
+ xcolor.green = 0x0;
+ xcolor.blue = 0xffff;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor(dpy, cmap, &xcolor)) {
+ printf("Couldn't allocate blue!\n");
+ exit(1);
+ }
+ Blue = xcolor.pixel;
+ }
+
+ /* set window attributes */
+ attr.colormap = cmap;
+ attr.event_mask = ExposureMask | StructureNotifyMask;
+ attr.border_pixel = BlackPixel(dpy, scr);
+ attr.background_pixel = BlackPixel(dpy, scr);
+ attr_flags = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel;
+
+ /* Create the window */
+ win = XCreateWindow(dpy, root, x, y, width, height, 0,
+ visinfo->depth, InputOutput,
+ visinfo->visual, attr_flags, &attr);
+ if (!win) {
+ printf("Couldn't open window!\n");
+ exit(1);
+ }
+
+ XStringListToTextProperty(&title, 1, &tp);
+ sh.flags = USPosition | USSize;
+ XSetWMProperties(dpy, win, &tp, &tp, 0, 0, &sh, 0, 0);
+ XMapWindow(dpy, win);
+ while (1) {
+ XNextEvent(dpy, &e);
+ if (e.type == MapNotify && e.xmap.window == win) {
+ break;
+ }
+ }
+
+ /*
+ * Now do the special Mesa/Xlib stuff!
+ */
+
+ visual = XMesaCreateVisual(dpy, visinfo, (GLboolean) color_flag, GL_FALSE, /* alpha_flag */
+ GL_FALSE, /* db_flag */
+ GL_FALSE, /* stereo flag */
+ GL_FALSE, /* ximage_flag */
+ 0, /* depth size */
+ 0, /* stencil size */
+ 0, 0, 0, 0, /* accum_size */
+ 0, /* num samples */
+ 0, /* level */
+ 0 /* caveat */
+ );
+ if (!visual) {
+ printf("Couldn't create Mesa/X visual!\n");
+ exit(1);
+ }
+
+ /* Create a Mesa rendering context */
+ context = XMesaCreateContext(visual, NULL /* share_list */
+ );
+ if (!context) {
+ printf("Couldn't create Mesa/X context!\n");
+ exit(1);
+ }
+
+ buffer = XMesaCreateWindowBuffer(visual, win);
+ if (!buffer) {
+ printf("Couldn't create Mesa/X buffer!\n");
+ exit(1);
+ }
+
+ XMesaMakeCurrent(context, buffer);
+
+ /* Ready to render! */
}
-
-
-static void draw_cube( void )
+static void
+draw_cube(void)
{
- /* X faces */
- glIndexi( Red );
- glColor3f( 1.0, 0.0, 0.0 );
- glBegin( GL_POLYGON );
- glVertex3f( 1.0, 1.0, 1.0 );
- glVertex3f( 1.0, -1.0, 1.0 );
- glVertex3f( 1.0, -1.0, -1.0 );
- glVertex3f( 1.0, 1.0, -1.0 );
- glEnd();
-
- glBegin( GL_POLYGON );
- glVertex3f( -1.0, 1.0, 1.0 );
- glVertex3f( -1.0, 1.0, -1.0 );
- glVertex3f( -1.0, -1.0, -1.0 );
- glVertex3f( -1.0, -1.0, 1.0 );
- glEnd();
-
- /* Y faces */
- glIndexi( Green );
- glColor3f( 0.0, 1.0, 0.0 );
- glBegin( GL_POLYGON );
- glVertex3f( 1.0, 1.0, 1.0 );
- glVertex3f( 1.0, 1.0, -1.0 );
- glVertex3f( -1.0, 1.0, -1.0 );
- glVertex3f( -1.0, 1.0, 1.0 );
- glEnd();
-
- glBegin( GL_POLYGON );
- glVertex3f( 1.0, -1.0, 1.0 );
- glVertex3f( -1.0, -1.0, 1.0 );
- glVertex3f( -1.0, -1.0, -1.0 );
- glVertex3f( 1.0, -1.0, -1.0 );
- glEnd();
-
- /* Z faces */
- glIndexi( Blue );
- glColor3f( 0.0, 0.0, 1.0 );
- glBegin( GL_POLYGON );
- glVertex3f( 1.0, 1.0, 1.0 );
- glVertex3f( -1.0, 1.0, 1.0 );
- glVertex3f( -1.0, -1.0, 1.0 );
- glVertex3f( 1.0, -1.0, 1.0 );
- glEnd();
-
- glBegin( GL_POLYGON );
- glVertex3f( 1.0, 1.0, -1.0 );
- glVertex3f( 1.0,-1.0, -1.0 );
- glVertex3f( -1.0,-1.0, -1.0 );
- glVertex3f( -1.0, 1.0, -1.0 );
- glEnd();
+ /* X faces */
+ glIndexi(Red);
+ glColor3f(1.0, 0.0, 0.0);
+ glBegin(GL_POLYGON);
+ glVertex3f(1.0, 1.0, 1.0);
+ glVertex3f(1.0, -1.0, 1.0);
+ glVertex3f(1.0, -1.0, -1.0);
+ glVertex3f(1.0, 1.0, -1.0);
+ glEnd();
+
+ glBegin(GL_POLYGON);
+ glVertex3f(-1.0, 1.0, 1.0);
+ glVertex3f(-1.0, 1.0, -1.0);
+ glVertex3f(-1.0, -1.0, -1.0);
+ glVertex3f(-1.0, -1.0, 1.0);
+ glEnd();
+
+ /* Y faces */
+ glIndexi(Green);
+ glColor3f(0.0, 1.0, 0.0);
+ glBegin(GL_POLYGON);
+ glVertex3f(1.0, 1.0, 1.0);
+ glVertex3f(1.0, 1.0, -1.0);
+ glVertex3f(-1.0, 1.0, -1.0);
+ glVertex3f(-1.0, 1.0, 1.0);
+ glEnd();
+
+ glBegin(GL_POLYGON);
+ glVertex3f(1.0, -1.0, 1.0);
+ glVertex3f(-1.0, -1.0, 1.0);
+ glVertex3f(-1.0, -1.0, -1.0);
+ glVertex3f(1.0, -1.0, -1.0);
+ glEnd();
+
+ /* Z faces */
+ glIndexi(Blue);
+ glColor3f(0.0, 0.0, 1.0);
+ glBegin(GL_POLYGON);
+ glVertex3f(1.0, 1.0, 1.0);
+ glVertex3f(-1.0, 1.0, 1.0);
+ glVertex3f(-1.0, -1.0, 1.0);
+ glVertex3f(1.0, -1.0, 1.0);
+ glEnd();
+
+ glBegin(GL_POLYGON);
+ glVertex3f(1.0, 1.0, -1.0);
+ glVertex3f(1.0, -1.0, -1.0);
+ glVertex3f(-1.0, -1.0, -1.0);
+ glVertex3f(-1.0, 1.0, -1.0);
+ glEnd();
}
-
-
-
-static void display_loop( void )
+static void
+display_loop(void)
{
- GLfloat xrot, yrot, zrot;
+ GLfloat xrot, yrot, zrot;
- xrot = yrot = zrot = 0.0;
+ xrot = yrot = zrot = 0.0;
- glClearColor( 0.0, 0.0, 0.0, 0.0 );
- glClearIndex( Black );
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClearIndex(Black);
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glFrustum( -1.0, 1.0, -1.0, 1.0, 1.0, 10.0 );
- glTranslatef( 0.0, 0.0, -5.0 );
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10.0);
+ glTranslatef(0.0, 0.0, -5.0);
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
- glCullFace( GL_BACK );
- glEnable( GL_CULL_FACE );
+ glCullFace(GL_BACK);
+ glEnable(GL_CULL_FACE);
- glShadeModel( GL_FLAT );
+ glShadeModel(GL_FLAT);
- while (1) {
- glClear( GL_COLOR_BUFFER_BIT );
- glPushMatrix();
- glRotatef( xrot, 1.0, 0.0, 0.0 );
- glRotatef( yrot, 0.0, 1.0, 0.0 );
- glRotatef( zrot, 0.0, 0.0, 1.0 );
+ while (1) {
+ glClear(GL_COLOR_BUFFER_BIT);
+ glPushMatrix();
+ glRotatef(xrot, 1.0, 0.0, 0.0);
+ glRotatef(yrot, 0.0, 1.0, 0.0);
+ glRotatef(zrot, 0.0, 0.0, 1.0);
- draw_cube();
+ draw_cube();
- glPopMatrix();
- glFinish();
+ glPopMatrix();
+ glFinish();
- xrot += 10.0;
- yrot += 7.0;
- zrot -= 3.0;
- }
+ xrot += 10.0;
+ yrot += 7.0;
+ zrot -= 3.0;
+ }
}
-
-
-
-int main( int argc, char *argv[] )
+int
+main(int argc, char *argv[])
{
- int mode = 0;
-
- if (argc >= 2)
- {
- if (strcmp(argv[1],"-ci")==0)
- mode = 0;
- else if (strcmp(argv[1],"-rgb")==0)
- mode = 1;
- else
- {
- printf("Bad flag: %s\n", argv[1]);
- printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n");
- exit(1);
+ int mode = 0;
+
+ if (argc >= 2) {
+ if (strcmp(argv[1], "-ci") == 0)
+ mode = 0;
+ else if (strcmp(argv[1], "-rgb") == 0)
+ mode = 1;
+ else {
+ printf("Bad flag: %s\n", argv[1]);
+ printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n");
+ exit(1);
}
- }
- else
- {
+ }
+ else {
printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n");
printf("Defaulting to 8-bit color index\n");
- }
+ }
- make_window( argv[0], mode );
+ make_window(argv[0], mode);
- display_loop();
- return 0;
+ display_loop();
+ return 0;
}
-
#endif
diff --git a/xorg-server/hw/dmx/examples/ev.c b/xorg-server/hw/dmx/examples/ev.c
index ed23b8aa9..b70016a45 100644
--- a/xorg-server/hw/dmx/examples/ev.c
+++ b/xorg-server/hw/dmx/examples/ev.c
@@ -46,16 +46,17 @@
struct input_event event;
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- char name[64]; /* RATS: Use ok, but could be better */
- char buf[256] = { 0, }; /* RATS: Use ok */
- unsigned char mask[EV_MAX/8 + 1]; /* RATS: Use ok */
- int version;
- int fd = 0;
- int rc;
- int i, j;
- char *tmp;
+ char name[64]; /* RATS: Use ok, but could be better */
+ char buf[256] = { 0, }; /* RATS: Use ok */
+ unsigned char mask[EV_MAX / 8 + 1]; /* RATS: Use ok */
+ int version;
+ int fd = 0;
+ int rc;
+ int i, j;
+ char *tmp;
#define test_bit(bit) (mask[(bit)/8] & (1 << ((bit)%8)))
@@ -73,15 +74,32 @@ int main(int argc, char **argv)
for (j = 0; j < EV_MAX; j++) {
if (test_bit(j)) {
const char *type = "unknown";
- switch(j) {
- case EV_KEY: type = "keys/buttons"; break;
- case EV_REL: type = "relative"; break;
- case EV_ABS: type = "absolute"; break;
- case EV_MSC: type = "reserved"; break;
- case EV_LED: type = "leds"; break;
- case EV_SND: type = "sound"; break;
- case EV_REP: type = "repeat"; break;
- case EV_FF: type = "feedback"; break;
+
+ switch (j) {
+ case EV_KEY:
+ type = "keys/buttons";
+ break;
+ case EV_REL:
+ type = "relative";
+ break;
+ case EV_ABS:
+ type = "absolute";
+ break;
+ case EV_MSC:
+ type = "reserved";
+ break;
+ case EV_LED:
+ type = "leds";
+ break;
+ case EV_SND:
+ type = "sound";
+ break;
+ case EV_REP:
+ type = "repeat";
+ break;
+ case EV_FF:
+ type = "feedback";
+ break;
}
printf(" %s", type);
}
@@ -96,27 +114,27 @@ int main(int argc, char **argv)
if ((fd = open(name, O_RDWR, 0)) >= 0) {
printf("%s: open, fd = %d\n", name, fd);
for (i = 0; i < LED_MAX; i++) {
- event.time.tv_sec = time(0);
+ event.time.tv_sec = time(0);
event.time.tv_usec = 0;
- event.type = EV_LED;
- event.code = i;
- event.value = 0;
+ event.type = EV_LED;
+ event.code = i;
+ event.value = 0;
write(fd, &event, sizeof(event));
}
-
+
while ((rc = read(fd, &event, sizeof(event))) > 0) {
printf("%-24.24s.%06lu type 0x%04x; code 0x%04x;"
" value 0x%08x; ",
ctime(&event.time.tv_sec),
- event.time.tv_usec,
- event.type, event.code, event.value);
+ event.time.tv_usec, event.type, event.code, event.value);
switch (event.type) {
case EV_KEY:
if (event.code > BTN_MISC) {
printf("Button %d %s",
event.code & 0xff,
event.value ? "press" : "release");
- } else {
+ }
+ else {
printf("Key %d (0x%x) %s",
event.code & 0xff,
event.code & 0xff,
@@ -125,51 +143,125 @@ int main(int argc, char **argv)
break;
case EV_REL:
switch (event.code) {
- case REL_X: tmp = "X"; break;
- case REL_Y: tmp = "Y"; break;
- case REL_HWHEEL: tmp = "HWHEEL"; break;
- case REL_DIAL: tmp = "DIAL"; break;
- case REL_WHEEL: tmp = "WHEEL"; break;
- case REL_MISC: tmp = "MISC"; break;
- default: tmp = "UNKNOWN"; break;
+ case REL_X:
+ tmp = "X";
+ break;
+ case REL_Y:
+ tmp = "Y";
+ break;
+ case REL_HWHEEL:
+ tmp = "HWHEEL";
+ break;
+ case REL_DIAL:
+ tmp = "DIAL";
+ break;
+ case REL_WHEEL:
+ tmp = "WHEEL";
+ break;
+ case REL_MISC:
+ tmp = "MISC";
+ break;
+ default:
+ tmp = "UNKNOWN";
+ break;
}
printf("Relative %s %d", tmp, event.value);
break;
case EV_ABS:
switch (event.code) {
- case ABS_X: tmp = "X"; break;
- case ABS_Y: tmp = "Y"; break;
- case ABS_Z: tmp = "Z"; break;
- case ABS_RX: tmp = "RX"; break;
- case ABS_RY: tmp = "RY"; break;
- case ABS_RZ: tmp = "RZ"; break;
- case ABS_THROTTLE: tmp = "THROTTLE"; break;
- case ABS_RUDDER: tmp = "RUDDER"; break;
- case ABS_WHEEL: tmp = "WHEEL"; break;
- case ABS_GAS: tmp = "GAS"; break;
- case ABS_BRAKE: tmp = "BRAKE"; break;
- case ABS_HAT0X: tmp = "HAT0X"; break;
- case ABS_HAT0Y: tmp = "HAT0Y"; break;
- case ABS_HAT1X: tmp = "HAT1X"; break;
- case ABS_HAT1Y: tmp = "HAT1Y"; break;
- case ABS_HAT2X: tmp = "HAT2X"; break;
- case ABS_HAT2Y: tmp = "HAT2Y"; break;
- case ABS_HAT3X: tmp = "HAT3X"; break;
- case ABS_HAT3Y: tmp = "HAT3Y"; break;
- case ABS_PRESSURE: tmp = "PRESSURE"; break;
- case ABS_DISTANCE: tmp = "DISTANCE"; break;
- case ABS_TILT_X: tmp = "TILT_X"; break;
- case ABS_TILT_Y: tmp = "TILT_Y"; break;
- case ABS_MISC: tmp = "MISC"; break;
- default: tmp = "UNKNOWN"; break;
+ case ABS_X:
+ tmp = "X";
+ break;
+ case ABS_Y:
+ tmp = "Y";
+ break;
+ case ABS_Z:
+ tmp = "Z";
+ break;
+ case ABS_RX:
+ tmp = "RX";
+ break;
+ case ABS_RY:
+ tmp = "RY";
+ break;
+ case ABS_RZ:
+ tmp = "RZ";
+ break;
+ case ABS_THROTTLE:
+ tmp = "THROTTLE";
+ break;
+ case ABS_RUDDER:
+ tmp = "RUDDER";
+ break;
+ case ABS_WHEEL:
+ tmp = "WHEEL";
+ break;
+ case ABS_GAS:
+ tmp = "GAS";
+ break;
+ case ABS_BRAKE:
+ tmp = "BRAKE";
+ break;
+ case ABS_HAT0X:
+ tmp = "HAT0X";
+ break;
+ case ABS_HAT0Y:
+ tmp = "HAT0Y";
+ break;
+ case ABS_HAT1X:
+ tmp = "HAT1X";
+ break;
+ case ABS_HAT1Y:
+ tmp = "HAT1Y";
+ break;
+ case ABS_HAT2X:
+ tmp = "HAT2X";
+ break;
+ case ABS_HAT2Y:
+ tmp = "HAT2Y";
+ break;
+ case ABS_HAT3X:
+ tmp = "HAT3X";
+ break;
+ case ABS_HAT3Y:
+ tmp = "HAT3Y";
+ break;
+ case ABS_PRESSURE:
+ tmp = "PRESSURE";
+ break;
+ case ABS_DISTANCE:
+ tmp = "DISTANCE";
+ break;
+ case ABS_TILT_X:
+ tmp = "TILT_X";
+ break;
+ case ABS_TILT_Y:
+ tmp = "TILT_Y";
+ break;
+ case ABS_MISC:
+ tmp = "MISC";
+ break;
+ default:
+ tmp = "UNKNOWN";
+ break;
}
printf("Absolute %s %d", tmp, event.value);
break;
- case EV_MSC: printf("Misc"); break;
- case EV_LED: printf("Led"); break;
- case EV_SND: printf("Snd"); break;
- case EV_REP: printf("Rep"); break;
- case EV_FF: printf("FF"); break;
+ case EV_MSC:
+ printf("Misc");
+ break;
+ case EV_LED:
+ printf("Led");
+ break;
+ case EV_SND:
+ printf("Snd");
+ break;
+ case EV_REP:
+ printf("Rep");
+ break;
+ case EV_FF:
+ printf("FF");
+ break;
break;
}
printf("\n");
diff --git a/xorg-server/hw/dmx/examples/evi.c b/xorg-server/hw/dmx/examples/evi.c
index 644ea8f51..64dfb7eaa 100644
--- a/xorg-server/hw/dmx/examples/evi.c
+++ b/xorg-server/hw/dmx/examples/evi.c
@@ -36,20 +36,22 @@
#include <X11/Xlib.h>
#include <X11/extensions/XEVI.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int major_version, minor_version;
- ExtendedVisualInfo *evi;
- int count;
- int i;
+ Display *display = NULL;
+ int major_version, minor_version;
+ ExtendedVisualInfo *evi;
+ int count;
+ int i;
if (argc == 2) {
if (!(display = XOpenDisplay(argv[1]))) {
printf("Cannot open display %s\n", argv[1]);
return -1;
}
- } else {
+ }
+ else {
printf("Usage: %s display\n", argv[0]);
return -1;
}
@@ -71,14 +73,13 @@ int main(int argc, char **argv)
printf("%02d vid=0x%02lx screen=%d level=%d type=%u value=%u"
" min=%u max=%u conflicts=%u\n",
i,
- (long unsigned)evi[i].core_visual_id,
+ (long unsigned) evi[i].core_visual_id,
evi[i].screen,
evi[i].level,
evi[i].transparency_type,
evi[i].transparency_value,
evi[i].min_hw_colormaps,
- evi[i].max_hw_colormaps,
- evi[i].num_colormap_conflicts);
+ evi[i].max_hw_colormaps, evi[i].num_colormap_conflicts);
}
XCloseDisplay(display);
diff --git a/xorg-server/hw/dmx/examples/res.c b/xorg-server/hw/dmx/examples/res.c
index 901a1958b..138216e4c 100644
--- a/xorg-server/hw/dmx/examples/res.c
+++ b/xorg-server/hw/dmx/examples/res.c
@@ -36,21 +36,23 @@
#include <X11/Xlib.h>
#include <X11/extensions/XRes.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int major_version, minor_version;
- int event, error;
- int count;
- int i;
- XResClient *clients;
+ Display *display = NULL;
+ int major_version, minor_version;
+ int event, error;
+ int count;
+ int i;
+ XResClient *clients;
if (argc == 2) {
if (!(display = XOpenDisplay(argv[1]))) {
printf("Cannot open display %s\n", argv[1]);
return -1;
}
- } else {
+ }
+ else {
printf("Usage: %s display\n", argv[0]);
return -1;
}
@@ -65,7 +67,7 @@ int main(int argc, char **argv)
return -1;
}
printf("X-Resource extension present: event=%d error=%d\n", event, error);
-
+
if (!XResQueryVersion(display, &major_version, &minor_version)) {
printf("XResQueryVersion call failed\n");
return -1;
@@ -77,16 +79,16 @@ int main(int argc, char **argv)
printf("%d clients:\n", count);
for (i = 0; i < count; i++) {
- int c, j;
+ int c, j;
XResType *types;
-
- XResQueryClientResources(display, clients[i].resource_base,
- &c, &types);
+
+ XResQueryClientResources(display, clients[i].resource_base, &c, &types);
printf(" %3d: base = 0x%lx, mask = 0x%lx, %d resource types:\n",
- i, (long unsigned)clients[i].resource_base,
- (long unsigned)clients[i].resource_mask, c);
+ i, (long unsigned) clients[i].resource_base,
+ (long unsigned) clients[i].resource_mask, c);
for (j = 0; j < c; j++) {
char *name = XGetAtomName(display, types[j].resource_type);
+
printf(" %2d: %s %d\n", j, name, types[j].count);
XFree(name);
}
diff --git a/xorg-server/hw/dmx/examples/xbell.c b/xorg-server/hw/dmx/examples/xbell.c
index 79419d324..543db24bf 100644
--- a/xorg-server/hw/dmx/examples/xbell.c
+++ b/xorg-server/hw/dmx/examples/xbell.c
@@ -35,27 +35,29 @@
#include <stdlib.h>
#include <X11/Xlib.h>
-static void pkc(XKeyboardControl *kc, unsigned long vm)
+static void
+pkc(XKeyboardControl * kc, unsigned long vm)
{
- if (vm&KBKeyClickPercent)
+ if (vm & KBKeyClickPercent)
printf(" key_click_percent = %d\n", kc->key_click_percent);
- if (vm&KBBellPercent)
+ if (vm & KBBellPercent)
printf(" bell_percent = %d\n", kc->bell_percent);
- if (vm&KBBellPitch)
+ if (vm & KBBellPitch)
printf(" bell_pitch = %d\n", kc->bell_pitch);
- if (vm&KBBellDuration)
+ if (vm & KBBellDuration)
printf(" bell_duration = %d\n", kc->bell_duration);
- if (vm&KBLed)
+ if (vm & KBLed)
printf(" led = 0x%x\n", kc->led);
- if (vm&KBLedMode)
+ if (vm & KBLedMode)
printf(" led_mode = %d\n", kc->led_mode);
- if (vm&KBKey)
+ if (vm & KBKey)
printf(" key = %d\n", kc->key);
- if (vm&KBAutoRepeatMode)
+ if (vm & KBAutoRepeatMode)
printf(" auto_repeat_mode = %d\n", kc->auto_repeat_mode);
}
-static void pks(XKeyboardState *ks)
+static void
+pks(XKeyboardState * ks)
{
printf(" key_click_percent = %d\n", ks->key_click_percent);
printf(" bell_percent = %d\n", ks->bell_percent);
@@ -65,24 +67,23 @@ static void pks(XKeyboardState *ks)
printf(" global_auto_repeat = %d\n", ks->global_auto_repeat);
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = XOpenDisplay(NULL);
+ Display *display = XOpenDisplay(NULL);
XKeyboardControl kc;
- XKeyboardState ks;
- unsigned long vm;
+ XKeyboardState ks;
+ unsigned long vm;
if (argc != 5) {
printf("Usage: xbell percent baseVolume pitch duration\n");
return 1;
}
-
- vm = (KBBellPercent
- | KBBellPitch
- | KBBellDuration);
+
+ vm = (KBBellPercent | KBBellPitch | KBBellDuration);
kc.key_click_percent = atoi(argv[1]);
- kc.bell_percent = atoi(argv[2]);
- kc.bell_pitch = atoi(argv[3]);
+ kc.bell_percent = atoi(argv[2]);
+ kc.bell_pitch = atoi(argv[3]);
kc.bell_duration = atoi(argv[4]);
printf("Setting:\n");
@@ -92,9 +93,9 @@ int main(int argc, char **argv)
printf("Have:\n");
XGetKeyboardControl(display, &ks);
pks(&ks);
-
+
XBell(display, 100);
-
+
XCloseDisplay(display);
return 0;
}
diff --git a/xorg-server/hw/dmx/examples/xinput.c b/xorg-server/hw/dmx/examples/xinput.c
index b12daf201..db6601030 100644
--- a/xorg-server/hw/dmx/examples/xinput.c
+++ b/xorg-server/hw/dmx/examples/xinput.c
@@ -42,31 +42,42 @@
#include <X11/extensions/dmxext.h>
#include <sys/time.h>
-static const char *core(DMXInputAttributes *iinf)
+static const char *
+core(DMXInputAttributes * iinf)
{
- if (iinf->isCore) return "core";
- else if (iinf->sendsCore) return "extension (sends core events)";
- else return "extension";
+ if (iinf->isCore)
+ return "core";
+ else if (iinf->sendsCore)
+ return "extension (sends core events)";
+ else
+ return "extension";
}
-static void printdmxinfo(Display *display, int id)
+static void
+printdmxinfo(Display * display, int id)
{
- int event_base;
- int error_base;
- int major_version, minor_version, patch_version;
- DMXInputAttributes iinf;
- Display *backend;
- char *backendname = NULL;
-
- if (!DMXQueryExtension(display, &event_base, &error_base)) return;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ DMXInputAttributes iinf;
+ Display *backend;
+ char *backendname = NULL;
+
+ if (!DMXQueryExtension(display, &event_base, &error_base))
+ return;
if (!DMXQueryVersion(display, &major_version, &minor_version,
- &patch_version)) return;
- if (major_version == 1 && minor_version == 0) return; /* too old */
- if (!DMXGetInputAttributes(display, id, &iinf)) return;
+ &patch_version))
+ return;
+ if (major_version == 1 && minor_version == 0)
+ return; /* too old */
+ if (!DMXGetInputAttributes(display, id, &iinf))
+ return;
printf(" DMX Information: ");
- if (iinf.detached) printf("detached ");
- else printf("active ");
+ if (iinf.detached)
+ printf("detached ");
+ else
+ printf("active ");
switch (iinf.inputType) {
case DMXLocalInputType:
printf("local, %s", core(&iinf));
@@ -78,12 +89,14 @@ static void printdmxinfo(Display *display, int id)
if (iinf.physicalId >= 0) {
if ((backend = XOpenDisplay(iinf.name))) {
XExtensionVersion *ext = XGetExtensionVersion(backend, INAME);
- if (ext && ext != (XExtensionVersion *)NoSuchExtension) {
+
+ if (ext && ext != (XExtensionVersion *) NoSuchExtension) {
int count, i;
XDeviceInfo *devInfo = XListInputDevices(backend, &count);
+
if (devInfo) {
for (i = 0; i < count; i++) {
- if ((unsigned)iinf.physicalId == devInfo[i].id
+ if ((unsigned) iinf.physicalId == devInfo[i].id
&& devInfo[i].name) {
backendname = strdup(devInfo[i].name);
break;
@@ -95,8 +108,9 @@ static void printdmxinfo(Display *display, int id)
XCloseDisplay(backend);
}
}
- printf("backend o%d/%s",iinf.physicalScreen, iinf.name);
- if (iinf.physicalId >= 0) printf("/id%d", iinf.physicalId);
+ printf("backend o%d/%s", iinf.physicalScreen, iinf.name);
+ if (iinf.physicalId >= 0)
+ printf("/id%d", iinf.physicalId);
if (backendname) {
printf("=%s", backendname);
free(backendname);
@@ -107,26 +121,31 @@ static void printdmxinfo(Display *display, int id)
printf("\n");
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int device = -1;
- int newmouse = -1;
- int newkbd = -1;
- int count;
- int i, j;
- XDeviceInfo *devInfo;
- XExtensionVersion *ext;
+ Display *display = NULL;
+ int device = -1;
+ int newmouse = -1;
+ int newkbd = -1;
+ int count;
+ int i, j;
+ XDeviceInfo *devInfo;
+ XExtensionVersion *ext;
if (argc == 2 || argc == 3 || argc == 4 || argc == 5) {
if (!(display = XOpenDisplay(argv[1]))) {
printf("Cannot open display %s\n", argv[1]);
return -1;
}
- if (argc >= 3) device = strtol(argv[2], NULL, 0);
- if (argc >= 4) newmouse = strtol(argv[3], NULL, 0);
- if (argc >= 5) newkbd = strtol(argv[4], NULL, 0);
- } else {
+ if (argc >= 3)
+ device = strtol(argv[2], NULL, 0);
+ if (argc >= 4)
+ newmouse = strtol(argv[3], NULL, 0);
+ if (argc >= 5)
+ newkbd = strtol(argv[4], NULL, 0);
+ }
+ else {
printf("Usage: %s display [device] [newmouse] [newkbd]\n", argv[0]);
return -1;
}
@@ -137,12 +156,11 @@ int main(int argc, char **argv)
}
ext = XGetExtensionVersion(display, INAME);
- if (!ext || ext == (XExtensionVersion *)NoSuchExtension) {
+ if (!ext || ext == (XExtensionVersion *) NoSuchExtension) {
printf("No XInputExtension\n");
return -1;
}
- printf("%s version %d.%d\n",
- INAME, ext->major_version, ext->minor_version);
+ printf("%s version %d.%d\n", INAME, ext->major_version, ext->minor_version);
if (!(devInfo = XListInputDevices(display, &count)) || !count) {
printf("Cannot list devices\n");
@@ -151,30 +169,52 @@ int main(int argc, char **argv)
for (i = 0; i < count; i++) {
XAnyClassPtr any;
- const char *kind = "Unknown";
- int has_key = 0;
-
+ const char *kind = "Unknown";
+ int has_key = 0;
+
switch (devInfo[i].use) {
- case IsXPointer: kind = "XPointer"; break;
- case IsXKeyboard: kind = "XKeyboard"; break;
- case IsXExtensionDevice: kind = "XExtensionDevice"; break;
+ case IsXPointer:
+ kind = "XPointer";
+ break;
+ case IsXKeyboard:
+ kind = "XKeyboard";
+ break;
+ case IsXExtensionDevice:
+ kind = "XExtensionDevice";
+ break;
}
printf("%2lu %-20.20s %-16.16s",
- (long unsigned)devInfo[i].id,
+ (long unsigned) devInfo[i].id,
devInfo[i].name ? devInfo[i].name : "", kind);
for (j = 0, any = devInfo[i].inputclassinfo;
j < devInfo[i].num_classes;
- any = (XAnyClassPtr)((char *)any + any->length), j++) {
- const char *class = "unk";
+ any = (XAnyClassPtr) ((char *) any + any->length), j++) {
+ const char *class = "unk";
+
switch (any->class) {
- case KeyClass: class = "key"; ++has_key; break;
- case ButtonClass: class = "btn"; break;
- case ValuatorClass: class = "val"; break;
- case FeedbackClass: class = "fdb"; break;
- case ProximityClass: class = "prx"; break;
- case FocusClass: class = "foc"; break;
- case OtherClass: class = "oth"; break;
+ case KeyClass:
+ class = "key";
+ ++has_key;
+ break;
+ case ButtonClass:
+ class = "btn";
+ break;
+ case ValuatorClass:
+ class = "val";
+ break;
+ case FeedbackClass:
+ class = "fdb";
+ break;
+ case ProximityClass:
+ class = "prx";
+ break;
+ case FocusClass:
+ class = "foc";
+ break;
+ case OtherClass:
+ class = "oth";
+ break;
}
printf(" %s", class);
}
@@ -182,10 +222,10 @@ int main(int argc, char **argv)
printdmxinfo(display, i);
if (has_key) {
- XkbDescPtr xkb;
+ XkbDescPtr xkb;
+
if ((xkb = XkbGetKeyboard(display,
- XkbAllComponentsMask,
- devInfo[i].id))) {
+ XkbAllComponentsMask, devInfo[i].id))) {
printf(" Xkb Information:\n");
printf(" Device id = %d\n", xkb->device_spec);
printf(" Min keycode = 0x%02x\n", xkb->min_key_code);
@@ -203,41 +243,37 @@ int main(int argc, char **argv)
}
if (newmouse >= 0) {
- XDevice *dev;
+ XDevice *dev;
printf("Trying to make device %d core mouse\n", newmouse);
dev = XOpenDevice(display, devInfo[newmouse].id);
- printf("Status = %d\n",
- XChangePointerDevice(display, dev, 0, 1));
+ printf("Status = %d\n", XChangePointerDevice(display, dev, 0, 1));
return 0;
}
if (newkbd >= 0) {
- XDevice *dev;
+ XDevice *dev;
printf("Trying to make device %d core keyboard\n", newkbd);
dev = XOpenDevice(display, devInfo[newkbd].id);
- printf("Status = %d\n",
- XChangeKeyboardDevice(display, dev));
+ printf("Status = %d\n", XChangeKeyboardDevice(display, dev));
return 0;
}
-
- if (device >=0){
+ if (device >= 0) {
#define MAX_EVENTS 100
- int cnt = 0;
- XDevice *dev;
+ int cnt = 0;
+ XDevice *dev;
XEventClass event_list[MAX_EVENTS];
- int event_type[MAX_EVENTS];
- const char *names[MAX_EVENTS];
- int total = 0;
+ int event_type[MAX_EVENTS];
+ const char *names[MAX_EVENTS];
+ int total = 0;
#define ADD(type) \
if (cnt >= MAX_EVENTS) abort(); \
names[cnt] = #type; \
type(dev, event_type[cnt], event_list[cnt]); \
if (event_type[cnt]) ++cnt
-
dev = XOpenDevice(display, devInfo[device].id);
ADD(DeviceKeyPress);
@@ -252,54 +288,55 @@ int main(int argc, char **argv)
ADD(DeviceStateNotify);
ADD(DeviceMappingNotify);
ADD(ChangeDeviceNotify);
-
+
for (i = 0; i < cnt; i++) {
printf("Waiting for %s events of type %d (%lu) on 0x%08lx\n",
names[i],
- event_type[i], (unsigned long)event_list[i],
- (long unsigned)DefaultRootWindow(display));
+ event_type[i], (unsigned long) event_list[i],
+ (long unsigned) DefaultRootWindow(display));
}
XSelectExtensionEvent(display, DefaultRootWindow(display),
event_list, cnt);
-
+
for (;;) {
XEvent event;
+
XNextEvent(display, &event);
for (i = 0; i < cnt; i++) {
- XDeviceMotionEvent *e = (XDeviceMotionEvent *)&event;
- XDeviceButtonEvent *b = (XDeviceButtonEvent *)&event;
+ XDeviceMotionEvent *e = (XDeviceMotionEvent *) & event;
+ XDeviceButtonEvent *b = (XDeviceButtonEvent *) & event;
+
if (event.type == event_type[i]) {
printf("%s id=%lu (%d @ %d,%d; s=0x%04x, d=%d, t=%lu)"
" axes_count=%d first=%d %d %d %d %d %d %d\n",
names[i],
- (long unsigned)e->deviceid,
+ (long unsigned) e->deviceid,
e->type,
e->x, e->y,
e->device_state,
b->button,
- (long unsigned)b->time,
+ (long unsigned) b->time,
e->axes_count,
e->first_axis,
e->axis_data[0],
e->axis_data[1],
e->axis_data[2],
- e->axis_data[3],
- e->axis_data[4],
- e->axis_data[5]);
+ e->axis_data[3], e->axis_data[4], e->axis_data[5]);
}
}
++total;
#if 0
- /* Used to check motion history for
- * extension devices. */
+ /* Used to check motion history for
+ * extension devices. */
if (!(total % 10)) {
XDeviceTimeCoord *tc;
- int n, m, a;
- struct timeval tv;
- unsigned long ms;
+ int n, m, a;
+ struct timeval tv;
+ unsigned long ms;
+
gettimeofday(&tv, NULL);
ms = tv.tv_sec * 1000 + tv.tv_usec / 1000;
- tc = XGetDeviceMotionEvents(display, dev, ms-1000, ms,
+ tc = XGetDeviceMotionEvents(display, dev, ms - 1000, ms,
&n, &m, &a);
printf("Got %d events of mode %s with %d axes\n",
n, m == Absolute ? "Absolute" : "Relative", a);
@@ -309,7 +346,7 @@ int main(int argc, char **argv)
}
XFreeDeviceMotionEvents(tc);
}
-#endif
+#endif
}
}
diff --git a/xorg-server/hw/dmx/examples/xled.c b/xorg-server/hw/dmx/examples/xled.c
index 270f80511..32e8e3770 100644
--- a/xorg-server/hw/dmx/examples/xled.c
+++ b/xorg-server/hw/dmx/examples/xled.c
@@ -40,23 +40,26 @@
#include <X11/extensions/XKBstr.h>
#include <sys/time.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int mask = 0;
- unsigned i;
- XKeyboardState ks;
- XKeyboardControl kc;
- XkbDescPtr xkb;
- int old[32];
+ Display *display = NULL;
+ int mask = 0;
+ unsigned i;
+ XKeyboardState ks;
+ XKeyboardControl kc;
+ XkbDescPtr xkb;
+ int old[32];
if (argc == 2 || argc == 3) {
if (!(display = XOpenDisplay(argv[1]))) {
printf("Cannot open display %s\n", argv[1]);
return -1;
}
- if (argc >= 3) mask = strtol(argv[2], NULL, 0);
- } else {
+ if (argc >= 3)
+ mask = strtol(argv[2], NULL, 0);
+ }
+ else {
printf("Usage: %s display [mask]\n", argv[0]);
return -1;
}
@@ -81,14 +84,13 @@ int main(int argc, char **argv)
for (i = 0; i < XkbNumIndicators; i++) {
if (xkb->indicators->phys_indicators & (1 << i)) {
printf("led %d = %d\n", i, xkb->indicators->maps[i].flags);
- old[i] = xkb->indicators->maps[i].flags;
+ old[i] = xkb->indicators->maps[i].flags;
xkb->indicators->maps[i].flags = XkbIM_NoAutomatic;
}
}
printf("XkbSetIndicatorMap = %d\n", XkbSetIndicatorMap(display, ~0, xkb));
XkbFreeKeyboard(xkb, 0, True);
-
if (!(xkb = XkbAllocKeyboard())) {
printf("Cannot allocate\n");
return -1;
@@ -105,7 +107,7 @@ int main(int argc, char **argv)
printf("XGetKeyboardControl = %d\n", XGetKeyboardControl(display, &ks));
printf("old mask = 0x%08lx\n", ks.led_mask);
for (i = 0; i < 5; i++) {
- kc.led = i + 1;
+ kc.led = i + 1;
kc.led_mode = (mask & (1 << i)) ? LedModeOn : LedModeOff;
printf("XChangeKeyboardControl = %d\n",
XChangeKeyboardControl(display, KBLed | KBLedMode, &kc));
diff --git a/xorg-server/hw/dmx/examples/xtest.c b/xorg-server/hw/dmx/examples/xtest.c
index 1e2d1cfff..9ce896a29 100644
--- a/xorg-server/hw/dmx/examples/xtest.c
+++ b/xorg-server/hw/dmx/examples/xtest.c
@@ -36,19 +36,21 @@
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Display *display = NULL;
- int event_base;
- int error_base;
- int major_version, minor_version;
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version;
if (argc == 2) {
if (!(display = XOpenDisplay(argv[1]))) {
printf("Cannot open display %s\n", argv[1]);
return -1;
}
- } else {
+ }
+ else {
printf("Usage: %s display\n", argv[0]);
return -1;
}