static void getTargetRect (CompWindow *cw, GridType where) { GRID_SCREEN (cw->screen); gs->props = gridProps[where]; DEBUG_PRINT ((gridOut, "\nPressed KP_%i\n", where)); /* get current available area */ getWorkareaForOutput (cw->screen, outputDeviceForWindow(cw), &gs->workarea); DEBUG_RECT (workarea); /* Convention: * xxxSlot include decorations (it's the screen area occupied) * xxxRect are undecorated (it's the constrained position of the contents) */ /* slice and dice to get desired slot - including decorations */ gs->desiredSlot.y = gs->workarea.y + gs->props.gravityDown * (gs->workarea.height / gs->props.numCellsY); gs->desiredSlot.height = gs->workarea.height / gs->props.numCellsY; gs->desiredSlot.x = gs->workarea.x + gs->props.gravityRight * (gs->workarea.width / gs->props.numCellsX); gs->desiredSlot.width = gs->workarea.width / gs->props.numCellsX; DEBUG_RECT (desiredSlot); /* Adjust for constraints and decorations */ constrainSize (cw, &gs->desiredSlot, &gs->desiredRect); DEBUG_RECT (gs->desiredRect); }
BOOL CALLBACK loginPlatformLeftClickNextStep(HWND hwnd, LPARAM lParam) { TCHAR buff[MAX_PATH] = {0}; RECT rect = {0}; GetWindowText(hwnd, buff, MAX_PATH); //TRACE("find next step button\n"); if(_tcsncmp(buff, TEXT("下一步"), lstrlen(TEXT("下一步"))) == 0) { GetWindowRect(hwnd, &rect); DEBUG_RECT(rect); PostMessage(hwnd, WM_LBUTTONUP, 0, 0x100010); //PostMessage(hwnd, WM_KEYUP, VK_RETURN, NULL); return FALSE; } return TRUE; }
static void gridCommonWindow (CompWindow *cw, GridType where) { GRID_SCREEN (cw->screen); if ((cw) && (where != GridUnknown)) { /* add maximize option */ if (where == GridMaximize) { sendMaximizationRequest (cw); /* maximizeWindow (cw, MAXIMIZE_STATE); */ } else { unsigned int valueMask = 0; int desiredState = 0; getTargetRect (cw, where); XWindowChanges xwc; /* if keys are pressed again then cycle through 1/3 or 2/3 widths... */ /* Get current rect not including decorations */ gs->currentRect.x = cw->serverX; gs->currentRect.y = cw->serverY; gs->currentRect.width = cw->serverWidth; gs->currentRect.height = cw->serverHeight; DEBUG_RECT (currentRect); if ((gs->desiredRect.y == gs->currentRect.y && gs->desiredRect.height == gs->currentRect.height) && gridGetCycleSizes(cw->screen->display)) { int slotWidth33 = gs->workarea.width / 3; int slotWidth66 = gs->workarea.width - slotWidth33; DEBUG_PRINT ((gridOut, "Multi!\n")); if (gs->props.numCellsX == 2) /* keys (1, 4, 7, 3, 6, 9) */ { if (gs->currentRect.width == gs->desiredRect.width && gs->currentRect.x == gs->desiredRect.x) { gs->desiredSlot.width = slotWidth66; gs->desiredSlot.x = gs->workarea.x + gs->props.gravityRight * slotWidth33; } else { /* tricky, have to allow for window constraints when * computing what the 33% and 66% offsets would be */ XRectangle rect33, rect66, slot33, slot66; slot33 = gs->desiredSlot; slot33.x = gs->workarea.x + gs->props.gravityRight * slotWidth66; slot33.width = slotWidth33; constrainSize (cw, &slot33, &rect33); DEBUG_RECT (slot33); DEBUG_RECT (rect33); slot66 = gs->desiredSlot; slot66.x = gs->workarea.x + gs->props.gravityRight * slotWidth33; slot66.width = slotWidth66; constrainSize (cw, &slot66, &rect66); DEBUG_RECT (slot66); DEBUG_RECT (rect66); if (gs->currentRect.width == rect66.width && gs->currentRect.x == rect66.x) { gs->desiredSlot.width = slotWidth33; gs->desiredSlot.x = gs->workarea.x + gs->props.gravityRight * slotWidth66; } } } else /* keys (2, 5, 8) */ { if (gs->currentRect.width == gs->desiredRect.width && gs->currentRect.x == gs->desiredRect.x) { gs->desiredSlot.width = slotWidth33; gs->desiredSlot.x = gs->workarea.x + slotWidth33; } } constrainSize (cw, &gs->desiredSlot, &gs->desiredRect); DEBUG_RECT (gs->desiredRect); } xwc.x = gs->desiredRect.x; xwc.y = gs->desiredRect.y; xwc.width = gs->desiredRect.width; xwc.height = gs->desiredRect.height; if (cw->mapNum) sendSyncRequest (cw); if (where == GridRight || where == GridLeft) { desiredState = CompWindowStateMaximizedVertMask; valueMask = CWX | CWWidth; } else if (where == GridTop || where == GridBottom) { desiredState = CompWindowStateMaximizedHorzMask; valueMask = CWY | CWHeight; } else { desiredState = 0; valueMask = CWX | CWY | CWWidth | CWHeight; } if (cw->state != desiredState) maximizeWindow (cw, desiredState); /* TODO: animate move+resize */ configureXWindow (cw, valueMask, &xwc); } } }
static Bool gridCommon (CompDisplay *d, CompAction *action, CompActionState state, CompOption *option, int nOption, GridType where) { Window xid; CompWindow *cw; xid = getIntOptionNamed (option, nOption, "window", 0); cw = findWindowAtDisplay (d, xid); if (cw) { XRectangle workarea; XRectangle desiredSlot; XRectangle desiredRect; XRectangle currentRect; GridProps props = gridProps[where]; XWindowChanges xwc; DEBUG_PRINT ((gridOut, "\nPressed KP_%i\n", where)); /* get current available area */ getWorkareaForOutput (cw->screen, outputDeviceForWindow(cw), &workarea); DEBUG_RECT (workarea); /* Convention: * xxxSlot include decorations (it's the screen area occupied) * xxxRect are undecorated (it's the constrained position of the contents) */ /* slice and dice to get desired slot - including decorations */ desiredSlot.y = workarea.y + props.gravityDown * (workarea.height / props.numCellsY); desiredSlot.height = workarea.height / props.numCellsY; desiredSlot.x = workarea.x + props.gravityRight * (workarea.width / props.numCellsX); desiredSlot.width = workarea.width / props.numCellsX; DEBUG_RECT (desiredSlot); /* Adjust for constraints and decorations */ constrainSize (cw, &desiredSlot, &desiredRect); DEBUG_RECT (desiredRect); /* Get current rect not including decorations */ currentRect.x = cw->serverX; currentRect.y = cw->serverY; currentRect.width = cw->serverWidth; currentRect.height = cw->serverHeight; DEBUG_RECT (currentRect); if (desiredRect.y == currentRect.y && desiredRect.height == currentRect.height) { int slotWidth33 = workarea.width / 3; int slotWidth66 = workarea.width - slotWidth33; DEBUG_PRINT ((gridOut, "Multi!\n")); if (props.numCellsX == 2) /* keys (1, 4, 7, 3, 6, 9) */ { if (currentRect.width == desiredRect.width && currentRect.x == desiredRect.x) { desiredSlot.width = slotWidth66; desiredSlot.x = workarea.x + props.gravityRight * slotWidth33; } else { /* tricky, have to allow for window constraints when * computing what the 33% and 66% offsets would be */ XRectangle rect33, rect66, slot33, slot66; slot33 = desiredSlot; slot33.x = workarea.x + props.gravityRight * slotWidth66; slot33.width = slotWidth33; constrainSize (cw, &slot33, &rect33); DEBUG_RECT (slot33); DEBUG_RECT (rect33); slot66 = desiredSlot; slot66.x = workarea.x + props.gravityRight * slotWidth33; slot66.width = slotWidth66; constrainSize (cw, &slot66, &rect66); DEBUG_RECT (slot66); DEBUG_RECT (rect66); if (currentRect.width == rect66.width && currentRect.x == rect66.x) { desiredSlot.width = slotWidth33; desiredSlot.x = workarea.x + props.gravityRight * slotWidth66; } } } else /* keys (2, 5, 8) */ { if (currentRect.width == desiredRect.width && currentRect.x == desiredRect.x) { desiredSlot.width = slotWidth33; desiredSlot.x = workarea.x + slotWidth33; } } constrainSize (cw, &desiredSlot, &desiredRect); DEBUG_RECT (desiredRect); } xwc.x = desiredRect.x; xwc.y = desiredRect.y; xwc.width = desiredRect.width; xwc.height = desiredRect.height; if (cw->mapNum) sendSyncRequest (cw); if (cw->state & MAXIMIZE_STATE) { /* maximized state interferes with us, clear it */ maximizeWindow (cw, 0); } /* TODO: animate move+resize */ configureXWindow (cw, CWX | CWY | CWWidth | CWHeight, &xwc); } return TRUE; }