static Bool tileSetNewWindowSize (CompWindow *w) { XWindowChanges xwc; unsigned int mask = CWX | CWY | CWWidth | CWHeight; TILE_WINDOW (w); TILE_SCREEN (w->screen); xwc.x = tw->newCoords.x; xwc.y = tw->newCoords.y; xwc.width = tw->newCoords.width; xwc.height = tw->newCoords.height; if (ts->tileType == -1) { if (tw->savedValid) maximizeWindow (w, tw->savedMaxState); } else maximizeWindow (w, 0); if (xwc.width == w->serverWidth) mask &= ~CWWidth; if (xwc.height == w->serverHeight) mask &= ~CWHeight; if (w->mapNum && (mask & (CWWidth | CWHeight))) sendSyncRequest (w); configureXWindow (w, mask, &xwc); tw->needConfigure = FALSE; return TRUE; }
void KviMainWindow::installAccelerators() { m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_PREV,this,SLOT(switchToPrevWindow()),0,Qt::ApplicationShortcut)); m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_NEXT,this,SLOT(switchToNextWindow()),0,Qt::ApplicationShortcut)); m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_PREV_CONTEXT,this,SLOT(switchToPrevWindowInContext()),0,Qt::ApplicationShortcut)); m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_NEXT_CONTEXT,this,SLOT(switchToNextWindowInContext()),0,Qt::ApplicationShortcut)); m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_PREV_HIGHLIGHT,this,SLOT(switchToPrevHighlightedWindow()),0,Qt::ApplicationShortcut)); m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_NEXT_HIGHLIGHT,this,SLOT(switchToNextHighlightedWindow()),0,Qt::ApplicationShortcut)); m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_MAXIMIZE,this,SLOT(maximizeWindow()),0,Qt::ApplicationShortcut)); m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_MINIMIZE,this,SLOT(minimizeWindow()),0,Qt::ApplicationShortcut)); static int accel_table[] = { Qt::Key_1 + Qt::ControlModifier, // script accels... Qt::Key_2 + Qt::ControlModifier, Qt::Key_3 + Qt::ControlModifier, Qt::Key_4 + Qt::ControlModifier, Qt::Key_5 + Qt::ControlModifier, Qt::Key_6 + Qt::ControlModifier, Qt::Key_7 + Qt::ControlModifier, Qt::Key_8 + Qt::ControlModifier, Qt::Key_9 + Qt::ControlModifier, Qt::Key_0 + Qt::ControlModifier, Qt::Key_F2, Qt::Key_F3, Qt::Key_F4, Qt::Key_F5, Qt::Key_F6, Qt::Key_F7, Qt::Key_F8, Qt::Key_F9, Qt::Key_F10, Qt::Key_F11, Qt::Key_F12, 0 }; int i=0, keys=0; while((keys = accel_table[i])) { m_pAccellerators->append(KviShortcut::create(keys,this,SLOT(accelActivated()),SLOT(accelActivated()),Qt::ApplicationShortcut)); i++; } }
void groupWindowStateChangeNotify (CompWindow *w, unsigned int lastState) { CompScreen *s = w->screen; GROUP_DISPLAY (&display); GROUP_SCREEN (s); GROUP_WINDOW (w); if (gw->group && !gd->ignoreMode) { const BananaValue * option_maximize_unmaximize_all = bananaGetOption (bananaIndex, "maximize_unmaximize_all", s->screenNum); if (((lastState & MAXIMIZE_STATE) != (w->state & MAXIMIZE_STATE)) && option_maximize_unmaximize_all->b) { int i; for (i = 0; i < gw->group->nWins; i++) { CompWindow *cw = gw->group->windows[i]; if (!cw) continue; if (cw->id == w->id) continue; maximizeWindow (cw, w->state & MAXIMIZE_STATE); } } } UNWRAP (gs, s, windowStateChangeNotify); (*s->windowStateChangeNotify)(w, lastState); WRAP (gs, s, windowStateChangeNotify, groupWindowStateChangeNotify); }
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); } } }
void TaskbarProxy::showMenu (const QString& widStr, int x, int y) { auto& w = Util::XWrapper::Instance (); const auto& wid = widStr.toULong (); const auto state = w.GetWindowState (wid); const auto actions = w.GetWindowActions (wid); auto menu = new QMenu; menu->setAttribute (Qt::WA_DeleteOnClose); { auto minimizeAct = menu->addAction (tr ("Minimize")); minimizeAct->setCheckable (true); if (state & Util::WinStateFlag::Hidden) minimizeAct->setChecked (true); else minimizeAct->setEnabled (actions & Util::AllowedActionFlag::Minimize); minimizeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, state] (const QString& wid) { state & Util::WinStateFlag::Hidden ? raiseWindow (wid) : minimizeWindow (wid); })); } { auto maximizeAct = menu->addAction (tr ("Maximize")); maximizeAct->setCheckable (true); const bool isMaximized = state & Util::WinStateFlag::MaximizedHorz || state & Util::WinStateFlag::MaximizedVert; if (isMaximized) maximizeAct->setChecked (true); else maximizeAct->setEnabled (actions & Util::AllowedActionFlag::MaximizeHorz || actions & Util::AllowedActionFlag::MaximizeVert); maximizeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, isMaximized] (const QString& wid) { isMaximized ? unmaximizeWindow (wid) : maximizeWindow (wid); })); } auto moreMenu = menu->addMenu (tr ("More")); { auto keepAbove = moreMenu->addAction (tr ("Keep above others")); keepAbove->setEnabled (actions & Util::AllowedActionFlag::MoveToTop); keepAbove->setCheckable (true); const bool isTop = state & Util::WinStateFlag::OnTop; keepAbove->setChecked (isTop); keepAbove->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, isTop] (const QString& wid) { moveWindowTo (wid, isTop ? "normal" : "top"); })); keepAbove->setIcon (Proxy_->GetIconThemeManager ()->GetIcon ("go-top")); } { auto keepBelow = moreMenu->addAction (tr ("Keep below others")); keepBelow->setEnabled (actions & Util::AllowedActionFlag::MoveToBottom); keepBelow->setCheckable (true); const bool isBottom = state & Util::WinStateFlag::OnBottom; keepBelow->setChecked (isBottom); keepBelow->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, isBottom] (const QString& wid) { moveWindowTo (wid, isBottom ? "normal" : "bottom"); })); keepBelow->setIcon (Proxy_->GetIconThemeManager ()->GetIcon ("go-bottom")); } { auto shadeAct = moreMenu->addAction (tr ("Shade")); shadeAct->setEnabled (actions & Util::AllowedActionFlag::Shade); shadeAct->setCheckable (true); shadeAct->setChecked (state & Util::WinStateFlag::Shaded); shadeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this] (const QString& wid) { toggleShadeWindow (wid); })); } QMenu *desksMenu = 0; { const auto numDesks = w.GetDesktopCount (); if (numDesks > 1) { desksMenu = menu->addMenu (tr ("Move to desktop")); const auto winDesk = w.GetWindowDesktop (wid); auto addAct = [this, actions, winDesk, desksMenu] (int num, const QString& name) { auto act = desksMenu->addAction (name); act->setEnabled (actions & Util::AllowedActionFlag::ChangeDesktop); act->setCheckable (true); act->setChecked (winDesk == num); act->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, num] (const QString& wid) { moveToDesktop (wid, num); })); }; const auto& deskNames = w.GetDesktopNames (); for (int i = 0; i < numDesks; ++i) addAct (i, deskNames.value (i, QString::number (i))); desksMenu->addSeparator (); addAct (0xFFFFFFFF, tr ("All desktops")); } } menu->addSeparator (); { auto closeAct = menu->addAction (tr ("Close")); closeAct->setEnabled (actions & Util::AllowedActionFlag::Close); closeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this] (const QString& wid) { closeWindow (wid); })); closeAct->setIcon (Proxy_->GetIconThemeManager ()->GetIcon ("window-close")); } auto allActions = menu->actions () + moreMenu->actions (); if (desksMenu) allActions += desksMenu->actions (); for (auto act : allActions) { act->setProperty ("WID", widStr); connect (act, SIGNAL (triggered ()), this, SLOT (handleAction ())); } menu->popup ({ x, y }); }
static Bool gridPlaceWindow (Window xid, GridType where) { CompWindow *w; w = findWindowAtDisplay (xid); if (w) { XRectangle workarea; XRectangle desiredSlot; XRectangle desiredRect; XRectangle currentRect; GridProps props = gridProps[where]; XWindowChanges xwc; /* get current available area */ getWorkareaForOutput (w->screen, outputDeviceForWindow(w), &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; /* Adjust for constraints and decorations */ constrainSize (w, &desiredSlot, &desiredRect); /* Get current rect not including decorations */ currentRect.x = w->serverX; currentRect.y = w->serverY; currentRect.width = w->serverWidth; currentRect.height = w->serverHeight; if (desiredRect.y == currentRect.y && desiredRect.height == currentRect.height) { int slotWidth33 = workarea.width / 3; int slotWidth66 = workarea.width - slotWidth33; 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 (w, &slot33, &rect33); slot66 = desiredSlot; slot66.x = workarea.x + props.gravityRight * slotWidth33; slot66.width = slotWidth66; constrainSize (w, &slot66, &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 (w, &desiredSlot, &desiredRect); } xwc.x = desiredRect.x; xwc.y = desiredRect.y; xwc.width = desiredRect.width; xwc.height = desiredRect.height; if (w->mapNum) sendSyncRequest (w); if (w->state & MAXIMIZE_STATE) { /* maximized state interferes with us, clear it */ maximizeWindow (w, 0); } /* TODO: animate move+resize */ configureXWindow (w, CWX | CWY | CWWidth | CWHeight, &xwc); } return TRUE; }