[PATCH xf86-video-nested v4 11/11] Update overall coding style (braces and if-clauses)
Laércio de Sousa
laerciosousa at sme-mogidascruzes.sp.gov.br
Fri Nov 13 10:28:11 PST 2015
Signed-off-by: Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
---
src/driver.c | 464 ++++++++++++++++++++++++++---------------------------
src/nested_input.c | 155 ++++++++----------
2 files changed, 294 insertions(+), 325 deletions(-)
diff --git a/src/driver.c b/src/driver.c
index 2d5f9a5..bae243a 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -52,6 +52,10 @@
#include "client.h"
#include "nested_input.h"
+#ifndef HW_SKIP_CONSOLE
+#define HW_SKIP_CONSOLE 4
+#endif
+
#define NESTED_VERSION 0
#define NESTED_NAME "NESTED"
#define NESTED_DRIVER_NAME "nested"
@@ -199,14 +203,16 @@ NestedSetup(pointer module, pointer opts, int *errmaj, int *errmin) {
xf86AddDriver(&NESTED, module, HaveDriverFuncs);
- if (enableNestedInput)
+ if (enableNestedInput) {
xf86AddInputDriver(&NESTEDINPUT, module, 0);
+ }
return (pointer)1;
} else {
- if (errmaj)
+ if (errmaj) {
*errmaj = LDR_ONCEONLY;
-
+ }
+
return NULL;
}
}
@@ -228,24 +234,21 @@ NestedProbe(DriverPtr drv, int flags) {
int numDevSections;
GDevPtr *devSections;
int i;
-
ScrnInfoPtr pScrn;
int entityIndex;
- if (flags & PROBE_DETECT)
+ if (flags & PROBE_DETECT) {
return FALSE;
-
- if ((numDevSections = xf86MatchDevice(NESTED_DRIVER_NAME,
- &devSections)) <= 0) {
+ } else if ((numDevSections = xf86MatchDevice(NESTED_DRIVER_NAME,
+ &devSections)) <= 0) {
return FALSE;
- }
-
- if (numDevSections > 0) {
+ } else if (numDevSections > 0) {
for(i = 0; i < numDevSections; i++) {
pScrn = NULL;
entityIndex = xf86ClaimNoSlot(drv, NESTED_CHIP, devSections[i],
TRUE);
pScrn = xf86AllocateScreen(drv, 0);
+
if (pScrn) {
xf86AddEntityToScreen(pScrn, entityIndex);
pScrn->driverVersion = NESTED_VERSION;
@@ -263,16 +266,12 @@ NestedProbe(DriverPtr drv, int flags) {
foundScreen = TRUE;
}
}
- }
- free(devSections);
- return foundScreen;
+ free(devSections);
+ return foundScreen;
+ }
}
-#ifndef HW_SKIP_CONSOLE
-#define HW_SKIP_CONSOLE 4
-#endif
-
static Bool
NestedDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) {
CARD32 *flag;
@@ -280,16 +279,15 @@ NestedDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) {
/* XXX implement */
switch(op) {
- case GET_REQUIRED_HW_INTERFACES:
- flag = (CARD32*)ptr;
- (*flag) = HW_SKIP_CONSOLE;
- return TRUE;
-
- case RR_GET_INFO:
- case RR_SET_CONFIG:
- case RR_GET_MODE_MM:
- default:
- return FALSE;
+ case GET_REQUIRED_HW_INTERFACES:
+ flag = (CARD32*)ptr;
+ (*flag) = HW_SKIP_CONSOLE;
+ return TRUE;
+ case RR_GET_INFO:
+ case RR_SET_CONFIG:
+ case RR_GET_MODE_MM:
+ default:
+ return FALSE;
}
}
@@ -298,12 +296,15 @@ static Bool NestedAllocatePrivate(ScrnInfoPtr pScrn) {
xf86Msg(X_WARNING, "NestedAllocatePrivate called for an already "
"allocated private!\n");
return FALSE;
- }
+ } else {
+ pScrn->driverPrivate = xnfcalloc(sizeof(NestedPrivate), 1);
- pScrn->driverPrivate = xnfcalloc(sizeof(NestedPrivate), 1);
- if (pScrn->driverPrivate == NULL)
- return FALSE;
- return TRUE;
+ if (pScrn->driverPrivate == NULL) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+ }
}
static void NestedFreePrivate(ScrnInfoPtr pScrn) {
@@ -311,10 +312,10 @@ static void NestedFreePrivate(ScrnInfoPtr pScrn) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Double freeing NestedPrivate!\n");
return;
+ } else {
+ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
}
-
- free(pScrn->driverPrivate);
- pScrn->driverPrivate = NULL;
}
/* Data from here is valid to all server generations */
@@ -325,131 +326,121 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedPreInit\n");
- if (flags & PROBE_DETECT)
+ if (flags & PROBE_DETECT) {
return FALSE;
-
- if (!NestedAllocatePrivate(pScrn)) {
+ } else if (!NestedAllocatePrivate(pScrn)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to allocate private\n");
return FALSE;
- }
-
- pNested = PNESTED(pScrn);
- pNested->originX = 0;
- pNested->originY = 0;
- pNested->fullWidth = 0;
- pNested->fullHeight = 0;
- pNested->fullscreen = FALSE;
- pNested->output = NULL;
-
- if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb))
- return FALSE;
-
- xf86PrintDepthBpp(pScrn);
-
- if (pScrn->depth > 8) {
- rgb zeros = {0, 0, 0};
- if (!xf86SetWeight(pScrn, zeros, zeros)) {
+ } else {
+ pNested = PNESTED(pScrn);
+ pNested->originX = 0;
+ pNested->originY = 0;
+ pNested->fullWidth = 0;
+ pNested->fullHeight = 0;
+ pNested->fullscreen = FALSE;
+ pNested->output = NULL;
+
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) {
return FALSE;
- }
- }
-
- if (!xf86SetDefaultVisual(pScrn, -1))
- return FALSE;
-
- pScrn->monitor = pScrn->confScreen->monitor; /* XXX */
+ } else {
+ xf86PrintDepthBpp(pScrn);
- xf86CollectOptions(pScrn, NULL);
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, NestedOptions);
+ if (pScrn->depth > 8) {
+ rgb zeros = {0, 0, 0};
- if (xf86IsOptionSet(NestedOptions, OPTION_DISPLAY)) {
- displayName = xf86GetOptValString(NestedOptions,
- OPTION_DISPLAY);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using display \"%s\"\n",
- displayName);
- setenv("DISPLAY", displayName, 1);
- }
-
- if (xf86IsOptionSet(NestedOptions, OPTION_XAUTHORITY)) {
- setenv("XAUTHORITY",
- xf86GetOptValString(NestedOptions,
- OPTION_XAUTHORITY), 1);
- }
-
- if (xf86IsOptionSet(NestedOptions, OPTION_ORIGIN)) {
- originString = xf86GetOptValString(NestedOptions, OPTION_ORIGIN);
-
- if (sscanf(originString, "%d %d", &pNested->originX,
- &pNested->originY) != 2) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Invalid value for option \"Origin\"\n");
- return FALSE;
- }
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using origin x:%d y:%d\n",
- pNested->originX, pNested->originY);
- }
+ if (!xf86SetWeight(pScrn, zeros, zeros)) {
+ return FALSE;
+ }
+ }
- if (xf86GetOptValBool(NestedOptions, OPTION_FULLSCREEN, &pNested->fullscreen))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fullscreen mode %s\n",
- pNested->fullscreen ? "enabled" : "disabled");
+ if (!xf86SetDefaultVisual(pScrn, -1)) {
+ return FALSE;
+ } else {
+ pScrn->monitor = pScrn->confScreen->monitor; /* XXX */
- if (xf86IsOptionSet(NestedOptions, OPTION_OUTPUT)) {
- pNested->output = xf86GetOptValString(NestedOptions,
- OPTION_OUTPUT);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Targeting host X server output \"%s\"\n",
- pNested->output);
- }
+ xf86CollectOptions(pScrn, NULL);
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, NestedOptions);
- xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
-
- if (!NestedClientCheckDisplay(pScrn->scrnIndex,
- pNested->output,
- &pNested->fullWidth,
- &pNested->fullHeight,
- &pNested->originX,
- &pNested->originY)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Can't open display: %s\n",
- displayName);
- return FALSE;
- }
+ if (xf86IsOptionSet(NestedOptions, OPTION_DISPLAY)) {
+ displayName = xf86GetOptValString(NestedOptions,
+ OPTION_DISPLAY);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using display \"%s\"\n",
+ displayName);
+ setenv("DISPLAY", displayName, 1);
+ }
+
+ if (xf86IsOptionSet(NestedOptions, OPTION_XAUTHORITY)) {
+ setenv("XAUTHORITY",
+ xf86GetOptValString(NestedOptions,
+ OPTION_XAUTHORITY), 1);
+ }
- if (!NestedClientValidDepth(pScrn->depth)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid depth: %d\n",
- pScrn->depth);
- return FALSE;
- }
+ if (xf86IsOptionSet(NestedOptions, OPTION_ORIGIN)) {
+ originString = xf86GetOptValString(NestedOptions, OPTION_ORIGIN);
+
+ if (sscanf(originString, "%d %d", &pNested->originX,
+ &pNested->originY) != 2) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Invalid value for option \"Origin\"\n");
+ return FALSE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using origin x:%d y:%d\n",
+ pNested->originX, pNested->originY);
+ }
+ }
- /*if (pScrn->depth > 1) {
- Gamma zeros = {0.0, 0.0, 0.0};
- if (!xf86SetGamma(pScrn, zeros))
- return FALSE;
- }*/
+ if (xf86GetOptValBool(NestedOptions, OPTION_FULLSCREEN, &pNested->fullscreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fullscreen mode %s\n",
+ pNested->fullscreen ? "enabled" : "disabled");
+ }
- if (NestedValidateModes(pScrn) < 1) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes\n");
- return FALSE;
- }
+ if (xf86IsOptionSet(NestedOptions, OPTION_OUTPUT)) {
+ pNested->output = xf86GetOptValString(NestedOptions,
+ OPTION_OUTPUT);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Targeting host X server output \"%s\"\n",
+ pNested->output);
+ }
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+
+ if (!NestedClientCheckDisplay(pScrn->scrnIndex,
+ pNested->output,
+ &pNested->fullWidth,
+ &pNested->fullHeight,
+ &pNested->originX,
+ &pNested->originY)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Can't open display: %s\n",
+ displayName);
+ return FALSE;
+ } else if (!NestedClientValidDepth(pScrn->depth)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid depth: %d\n",
+ pScrn->depth);
+ return FALSE;
+ } else if (NestedValidateModes(pScrn) < 1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes\n");
+ return FALSE;
+ } else if (!pScrn->modes) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
+ return FALSE;
+ }
- if (!pScrn->modes) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
- return FALSE;
+ xf86SetCrtcForModes(pScrn, 0);
+ pScrn->currentMode = pScrn->modes;
+ xf86SetDpi(pScrn, 0, 0);
+
+ if (!xf86LoadSubModule(pScrn, "shadow")) {
+ return FALSE;
+ } else if (!xf86LoadSubModule(pScrn, "fb")) {
+ return FALSE;
+ } else {
+ pScrn->memPhysBase = 0;
+ pScrn->fbOffset = 0;
+
+ return TRUE;
+ }
+ }
+ }
}
- xf86SetCrtcForModes(pScrn, 0);
-
- pScrn->currentMode = pScrn->modes;
-
- xf86SetDpi(pScrn, 0, 0);
-
- if (!xf86LoadSubModule(pScrn, "shadow"))
- return FALSE;
- if (!xf86LoadSubModule(pScrn, "fb"))
- return FALSE;
-
- pScrn->memPhysBase = 0;
- pScrn->fbOffset = 0;
-
- return TRUE;
}
int
@@ -487,9 +478,7 @@ NestedValidateModes(ScrnInfoPtr pScrn) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"This is not the mode name I was expecting...\n");
return 0;
- }
-
- if (!NestedAddMode(pScrn, width, height)) {
+ } else if (!NestedAddMode(pScrn, width, height)) {
return 0;
}
}
@@ -514,18 +503,23 @@ NestedValidateModes(ScrnInfoPtr pScrn) {
/* XXX: if not specified, make virtualX and virtualY as big as the max X
* and Y. I'm not sure this is correct */
mode = pScrn->modes;
+
while (mode != NULL) {
- if (mode->HDisplay > maxX)
+ if (mode->HDisplay > maxX) {
maxX = mode->HDisplay;
+ }
- if (mode->VDisplay > maxY)
+ if (mode->VDisplay > maxY) {
maxY = mode->VDisplay;
-
+ }
+
mode = mode->next;
}
+
pScrn->virtualX = maxX;
pScrn->virtualY = maxY;
}
+
pScrn->virtualFrom = X_DEFAULT;
pScrn->displayWidth = pScrn->virtualX;
@@ -534,6 +528,7 @@ NestedValidateModes(ScrnInfoPtr pScrn) {
/* Calculate the return value */
mode = pScrn->modes;
+
while (mode != NULL) {
mode = mode->next;
ret++;
@@ -541,7 +536,6 @@ NestedValidateModes(ScrnInfoPtr pScrn) {
/* Finally, make the mode list circular */
pScrn->modes->prev->next = pScrn->modes;
-
return ret;
}
@@ -551,34 +545,36 @@ NestedAddMode(ScrnInfoPtr pScrn, int width, int height) {
char nameBuf[64];
size_t len;
- if (snprintf(nameBuf, 64, "%dx%d", width, height) >= 64)
+ if (snprintf(nameBuf, 64, "%dx%d", width, height) >= 64) {
return FALSE;
-
- mode = XNFcalloc(sizeof(DisplayModeRec));
- mode->status = MODE_OK;
- mode->type = M_T_DRIVER;
- mode->HDisplay = width;
- mode->VDisplay = height;
-
- len = strlen(nameBuf);
- mode->name = XNFalloc(len+1);
- strcpy((char *)mode->name, nameBuf);
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Adding mode %s\n", mode->name);
-
- /* Now add mode to pScrn->modes. We'll keep the list non-circular for now,
- * but we'll maintain pScrn->modes->prev to know the last element */
- mode->next = NULL;
- if (!pScrn->modes) {
- pScrn->modes = mode;
- mode->prev = mode;
} else {
- mode->prev = pScrn->modes->prev;
- pScrn->modes->prev->next = mode;
- pScrn->modes->prev = mode;
- }
+ mode = XNFcalloc(sizeof(DisplayModeRec));
+ mode->status = MODE_OK;
+ mode->type = M_T_DRIVER;
+ mode->HDisplay = width;
+ mode->VDisplay = height;
+
+ len = strlen(nameBuf);
+ mode->name = XNFalloc(len+1);
+ strcpy((char *)mode->name, nameBuf);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Adding mode %s\n", mode->name);
+
+ /* Now add mode to pScrn->modes. We'll keep the list non-circular for now,
+ * but we'll maintain pScrn->modes->prev to know the last element */
+ mode->next = NULL;
+
+ if (!pScrn->modes) {
+ pScrn->modes = mode;
+ mode->prev = mode;
+ } else {
+ mode->prev = pScrn->modes->prev;
+ pScrn->modes->prev->next = mode;
+ pScrn->modes->prev = mode;
+ }
- return TRUE;
+ return TRUE;
+ }
}
// Wrapper for timed call to NestedInputLoadDriver. Used with timer in order
@@ -605,8 +601,8 @@ NestedWakeupHandler(pointer data, int i, pointer LastSelectMask) {
}
/* Called at each server generation */
-static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL)
-{
+static Bool
+NestedScreenInit(SCREEN_INIT_ARGS_DECL) {
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
NestedPrivatePtr pNested;
Pixel redMask, greenMask, blueMask;
@@ -614,15 +610,7 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedScreenInit\n");
pNested = PNESTED(pScrn);
- /*NESTEDScrn = pScrn;*/
-
NestedPrintPscreen(pScrn);
-
- /* Save state:
- * NestedSave(pScrn); */
-
- //Load_Nested_Mouse();
-
pNested->clientData = NestedClientCreateScreen(pScrn->scrnIndex,
pNested->output != NULL || pNested->fullscreen,
pScrn->virtualX,
@@ -636,53 +624,54 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL)
if (!pNested->clientData) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to create client screen\n");
return FALSE;
- }
-
- // Schedule the NestedInputLoadDriver function to load once the
- // input core is initialized.
-
- if (enableNestedInput)
- TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData);
-
- miClearVisualTypes();
- if (!miSetVisualTypesAndMasks(pScrn->depth,
- miGetDefaultVisualMask(pScrn->depth),
- pScrn->rgbBits, pScrn->defaultVisual,
- redMask, greenMask, blueMask))
- return FALSE;
-
- if (!miSetPixmapDepths())
- return FALSE;
-
- if (!fbScreenInit(pScreen, NestedClientGetFrameBuffer(PCLIENTDATA(pScrn)),
- pScrn->virtualX, pScrn->virtualY, pScrn->xDpi,
- pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel))
- return FALSE;
-
- fbPictureInit(pScreen, 0, 0);
-
- xf86SetBlackWhitePixels(pScreen);
- xf86SetBackingStore(pScreen);
- miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
-
- if (!miCreateDefColormap(pScreen))
- return FALSE;
-
- pNested->update = NestedShadowUpdate;
- pScreen->SaveScreen = NestedSaveScreen;
-
- if (!shadowSetup(pScreen))
- return FALSE;
-
- pNested->CreateScreenResources = pScreen->CreateScreenResources;
- pScreen->CreateScreenResources = NestedCreateScreenResources;
-
- pNested->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = NestedCloseScreen;
-
- RegisterBlockAndWakeupHandlers(NestedBlockHandler, NestedWakeupHandler, pNested->clientData);
+ } else {
+ // Schedule the NestedInputLoadDriver function to load once the
+ // input core is initialized.
+ if (enableNestedInput) {
+ TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData);
+ }
- return TRUE;
+ miClearVisualTypes();
+ if (!miSetVisualTypesAndMasks(pScrn->depth,
+ miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual,
+ redMask, greenMask, blueMask)) {
+ return FALSE;
+ } else if (!miSetPixmapDepths()) {
+ return FALSE;
+ } else if (!fbScreenInit(pScreen, NestedClientGetFrameBuffer(PCLIENTDATA(pScrn)),
+ pScrn->virtualX, pScrn->virtualY, pScrn->xDpi,
+ pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel)) {
+ return FALSE;
+ } else {
+ fbPictureInit(pScreen, 0, 0);
+
+ xf86SetBlackWhitePixels(pScreen);
+ xf86SetBackingStore(pScreen);
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+ if (!miCreateDefColormap(pScreen)) {
+ return FALSE;
+ } else {
+ pNested->update = NestedShadowUpdate;
+ pScreen->SaveScreen = NestedSaveScreen;
+
+ if (!shadowSetup(pScreen)) {
+ return FALSE;
+ } else {
+ pNested->CreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = NestedCreateScreenResources;
+
+ pNested->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = NestedCloseScreen;
+
+ RegisterBlockAndWakeupHandlers(NestedBlockHandler, NestedWakeupHandler, pNested->clientData);
+
+ return TRUE;
+ }
+ }
+ }
+ }
}
static Bool
@@ -700,9 +689,9 @@ NestedCreateScreenResources(ScreenPtr pScreen) {
pNested->update, NULL, 0, 0)) {
xf86DrvMsg(pScreen->myNum, X_ERROR, "NestedCreateScreenResources failed to shadowAdd.\n");
return FALSE;
+ } else {
+ return ret;
}
-
- return ret;
}
static void
@@ -766,8 +755,9 @@ static ModeStatus NestedValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode,
SCRN_INFO_PTR(arg);
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedValidMode:\n");
- if (!mode)
+ if (!mode) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "NULL MODE!\n");
+ }
xf86DrvMsg(pScrn->scrnIndex, X_INFO, " name: %s\n", mode->name);
xf86DrvMsg(pScrn->scrnIndex, X_INFO, " HDisplay: %d\n", mode->HDisplay);
diff --git a/src/nested_input.c b/src/nested_input.c
index 9a6303e..cbb567b 100644
--- a/src/nested_input.c
+++ b/src/nested_input.c
@@ -108,16 +108,17 @@ NestedInputPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) {
pNestedInput = calloc(1, sizeof(NestedInputDeviceRec));
- if (!pNestedInput)
+ if (!pNestedInput) {
return BadAlloc;
-
- pInfo->private = pNestedInput;
- pInfo->type_name = XI_MOUSE; // This is really both XI_MOUSE and XI_KEYBOARD... but oh well.
- pInfo->read_input = NestedInputReadInput; // new data available.
- pInfo->switch_mode = NULL; // Toggle absolute/relative mode.
- pInfo->device_control = NestedInputControl; // Enable/disable device.
-
- return Success;
+ } else {
+ pInfo->private = pNestedInput;
+ pInfo->type_name = XI_MOUSE; // This is really both XI_MOUSE and XI_KEYBOARD... but oh well.
+ pInfo->read_input = NestedInputReadInput; // new data available.
+ pInfo->switch_mode = NULL; // Toggle absolute/relative mode.
+ pInfo->device_control = NestedInputControl; // Enable/disable device.
+
+ return Success;
+ }
}
void
@@ -172,8 +173,9 @@ NestedInputUpdateKeymap(DeviceIntPtr device) {
free(keySyms.map);
- if (inputInfo.keyboard != device)
+ if (inputInfo.keyboard != device) {
XkbCopyDeviceKeymap(inputInfo.keyboard, device);
+ }
}
static int
@@ -183,9 +185,9 @@ _nested_input_init_keyboard(DeviceIntPtr device) {
if (!InitKeyboardDeviceStruct(device, NULL, NULL, NULL)) {
xf86Msg(X_ERROR, "%s: Failed to register keyboard.\n", pInfo->name);
return BadAlloc;
+ } else {
+ return Success;
}
-
- return Success;
}
static int
_nested_input_init_buttons(DeviceIntPtr device) {
@@ -197,8 +199,9 @@ _nested_input_init_buttons(DeviceIntPtr device) {
map = calloc(NUM_MOUSE_BUTTONS + 1, sizeof(CARD8));
int i;
- for (i = 0; i < NUM_MOUSE_BUTTONS; i++)
+ for (i = 0; i < NUM_MOUSE_BUTTONS; i++) {
map[i] = i;
+ }
if (!InitButtonClassDeviceStruct(device, NUM_MOUSE_BUTTONS, buttonLabels, map)) {
xf86Msg(X_ERROR, "%s: Failed to register buttons.\n", pInfo->name);
@@ -217,15 +220,15 @@ _nested_input_init_axes(DeviceIntPtr device) {
GetMotionHistorySize(),
(Atom)0)) {
return BadAlloc;
- }
+ } else {
+ int i;
+ for (i = 0; i < NUM_MOUSE_AXES; i++) {
+ xf86InitValuatorAxisStruct(device, i, (Atom)0, -1, -1, 1, 1, 1, Absolute);
+ xf86InitValuatorDefaults(device, i);
+ }
- int i;
- for (i = 0; i < NUM_MOUSE_AXES; i++) {
- xf86InitValuatorAxisStruct(device, i, (Atom)0, -1, -1, 1, 1, 1, Absolute);
- xf86InitValuatorDefaults(device, i);
+ return Success;
}
-
- return Success;
}
static CARD32
@@ -239,12 +242,12 @@ nested_input_on(OsTimerPtr timer, CARD32 time, pointer arg) {
timer = NULL;
}
- if(device->public.on)
- {
+ if(device->public.on) {
pInfo->fd = NestedClientGetFileDescriptor(pNestedInput->clientData);
xf86FlushInput(pInfo->fd);
xf86AddEnabledDevice(pInfo);
}
+
return 0;
}
@@ -254,42 +257,50 @@ NestedInputControl(DeviceIntPtr device, int what) {
InputInfoPtr pInfo = device->public.devicePrivate;
switch (what) {
- case DEVICE_INIT:
- err = _nested_input_init_keyboard(device);
- if (err != Success)
- return err;
+ case DEVICE_INIT:
+ err = _nested_input_init_keyboard(device);
- err = _nested_input_init_buttons(device);
- if (err != Success)
- return err;
+ if (err != Success) {
+ return err;
+ }
- err = _nested_input_init_axes(device);
- if (err != Success)
- return err;
+ err = _nested_input_init_buttons(device);
+ if (err != Success) {
+ return err;
+ }
+
+ err = _nested_input_init_axes(device);
+
+ if (err != Success) {
+ return err;
+ }
+
+ break;
+ case DEVICE_ON:
+ xf86Msg(X_INFO, "%s: On.\n", pInfo->name);
+
+ if (device->public.on) {
break;
- case DEVICE_ON:
- xf86Msg(X_INFO, "%s: On.\n", pInfo->name);
-
- if (device->public.on)
- break;
-
- device->public.on = TRUE;
- TimerSet(NULL, 0, 1, nested_input_on, device);
- break;
- case DEVICE_OFF:
- xf86Msg(X_INFO, "%s: Off.\n", pInfo->name);
-
- if (!device->public.on)
- break;
-
- xf86RemoveEnabledDevice(pInfo);
-
- pInfo->fd = -1;
- device->public.on = FALSE;
- break;
- case DEVICE_CLOSE:
+ }
+
+ device->public.on = TRUE;
+ TimerSet(NULL, 0, 1, nested_input_on, device);
+ break;
+ case DEVICE_OFF:
+ xf86Msg(X_INFO, "%s: Off.\n", pInfo->name);
+
+ if (!device->public.on) {
break;
+ }
+
+ xf86RemoveEnabledDevice(pInfo);
+
+ pInfo->fd = -1;
+ device->public.on = FALSE;
+ break;
+ case DEVICE_CLOSE:
+ break;
}
return Success;
@@ -298,7 +309,7 @@ NestedInputControl(DeviceIntPtr device, int what) {
static CARD32
nested_input_ready(OsTimerPtr timer, CARD32 time, pointer arg) {
NestedClientPrivatePtr clientData = arg;
-
+
if (timer) {
TimerFree(timer);
timer = NULL;
@@ -314,39 +325,6 @@ NestedInputReadInput(InputInfoPtr pInfo) {
TimerSet(NULL, 0, 1, nested_input_ready, pNestedInput->clientData);
}
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 14
-static InputOption*
-input_option_new(InputOption* list, char *key, char *value)
-{
- InputOption *tmp;
-
- tmp = calloc(1, sizeof(*tmp));
- tmp->key = key;
- tmp->value = value;
- tmp->next = list;
-
- return tmp;
-}
-
-static void
-input_option_free_list(InputOption **list)
-{
- InputOption *iopts = *list;
-
- while(iopts)
- {
- InputOption *tmp = iopts->next;
- free(iopts->key);
- free(iopts->value);
- free(iopts);
- iopts = tmp;
- }
-
- *list = NULL;
-}
-#endif
-
-
void
NestedInputLoadDriver(NestedClientPrivatePtr clientData) {
DeviceIntPtr dev;
@@ -384,8 +362,9 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) {
* as the first core pointer. */
pInfo = xf86LookupInput("<default pointer>");
- if (pInfo)
+ if (pInfo) {
DeleteInputDeviceRequest(pInfo->dev);
+ }
}
void
--
2.1.4
More information about the xorg-devel
mailing list