void MWWorld::InventoryStore::rechargeItems(float duration) { if (!mRechargingItemsUpToDate) { updateRechargingItems(); mRechargingItemsUpToDate = true; } for (TRechargingItems::iterator it = mRechargingItems.begin(); it != mRechargingItems.end(); ++it) { if (it->first->getCellRef().getEnchantmentCharge() == -1 || it->first->getCellRef().getEnchantmentCharge() == it->second) continue; static float fMagicItemRechargePerSecond = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find( "fMagicItemRechargePerSecond")->getFloat(); if (it->first->getCellRef().getEnchantmentCharge() <= it->second) { it->first->getCellRef().setEnchantmentCharge(std::min (it->first->getCellRef().getEnchantmentCharge() + fMagicItemRechargePerSecond * duration, it->second)); // attempt to restack when fully recharged if (it->first->getCellRef().getEnchantmentCharge() == it->second) it->first = restack(*it->first); } } }
// Move, resize, or stacking order change void Workspace::configureNotifyEvent( const XConfigureEvent *event ) { Client *client = find( event->window ); if ( client ) { QRect geometry = QRect( event->x, event->y, event->width, event->height ); int borderWidth = event->border_width; Window above = event->above; // Compress configure events. There's no need to union each of these rects with // the damage region, since there are only two visibly affected rects; the rect // where the window is currently drawn, and the rect in the last configure event, // which is where we'll draw the window in the next paint cycle. XConfigureEvent e; while ( XCheckTypedWindowEvent( dpy, client->winId(), ConfigureNotify, (XEvent*)&e ) ) { geometry = QRect( e.x, e.y, e.width, e.height ); borderWidth = e.border_width; above = e.above; } client->geometryChanged( geometry, borderWidth ); restack( client, above ); } else if ( event->window == rootId() ) { // Recreate the back buffer releasePicture( mBackbuffer ); createBackbuffer(); } }
void Workspace::circulateNotifyEvent( const XCirculateEvent *event ) { Client *client = find( event->window ); if ( client ) { Window above = ( event->place == PlaceOnTop ) ? mList.first()->winId() : None; restack( client, above ); } }
static void buttonpress(XEvent *e) { Client *c; XButtonPressedEvent *ev = &e->xbutton; if((c = getclient(ev->window))) { focus(c); if(CLEANMASK(ev->state) != MODKEY) return; if(ev->button == Button1 && c->isfloat) { restack(); movemouse(c); } else if(ev->button == Button2) zoom(NULL); else if(ev->button == Button3 && c->isfloat && !c->isfixed) { restack(); resizemouse(c); } } }
void focusnext(Arg *arg) { Client *c; if(!sel) return; if(!(c = getnext(sel->next))) c = getnext(clients); if(c) { focus(c); restack(); } }
void Amor::slotTimeout() { if( mForceHideAmorWidget ) { return; } if( !mTheme.isStatic() ) { mPosition += mCurrAnim->movement(); } mAmor->setPixmap( mCurrAnim->frame() ); mAmor->move( mTargetRect.x() + mPosition - mCurrAnim->hotspot().x(), mTargetRect.y() - mCurrAnim->hotspot().y() + ( !mInDesktopBottom?mConfig.mOffset:0 ) ); if( !mAmor->isVisible() ) { mAmor->show(); restack(); } if( mCurrAnim == mBaseAnim && mCurrAnim->validFrame() ) { // GP: Application tips/messages can be shown in any frame number; amor tips are // only displayed on the first frame of mBaseAnim (the old way of doing this). if( !mTipsQueue.isEmpty() && !mBubble && mConfig.mAppTips ) { showBubble(); } else if( KRandom::random()%TIP_FREQUENCY == 1 && mConfig.mTips && !mBubble && !mCurrAnim->frameNum() ) { mTipsQueue.enqueue( new QueueItem( QueueItem::Tip, mTips.tip() ) ); showBubble(); } } if( mTheme.isStatic() ) { mTimer->setSingleShot( true ); mTimer->start( ( mState == Normal ) || ( mState == Sleeping ) ? 1000 : 100 ); } else { mTimer->setSingleShot( true ); mTimer->start( mCurrAnim->delay() ); } if( !mCurrAnim->next() ) { if( mBubble ) { mCurrAnim->reset(); } else { selectAnimation( mState ); } } }
void focusprev(Arg *arg) { Client *c; if(!sel) return; if(!(c = getprev(sel->prev))) { for(c = clients; c && c->next; c = c->next); c = getprev(c); } if(c) { focus(c); restack(); } }
void Compositor::addChildWindow(xcb_window_t window) { Q_ASSERT(window != root_); Q_ASSERT(!overlayWindow_ || window != overlayWindow_->winId()); if (windows_.contains(window)) { return; } QSharedPointer<ClientWindow> w(new ClientWindow(&ewmh_, window)); // TODO: replace with ::create if (w->isValid() && w->windowClass() != XCB_WINDOW_CLASS_INPUT_ONLY) { windows_.insert(window, w); connect(w.data(), SIGNAL(pixmapChanged(WindowPixmap*)), SLOT(registerPixmap(WindowPixmap*))); connect(w.data(), SIGNAL(stackingOrderChanged()), SLOT(restack())); restack(); if (initFinished_) { Q_EMIT windowCreated(w.data()); } else { QMetaObject::invokeMethod(this, "windowCreated", Qt::QueuedConnection, Q_ARG(ClientWindow*, w.data())); } updateActiveWindow(); }
void arrange(void) { unsigned int i, n, mw, mh, tw, th; Client *c; for(n = 0, c = getnext(clients); c; c = getnext(c->next)) n++; /* window geoms */ mh = (n > nmaster) ? sh / nmaster : sh / (n > 0 ? n : 1); mw = (n > nmaster) ? (sw * master) / 1000 : sw; th = (n > nmaster) ? sh / (n - nmaster) : 0; tw = sw - mw; for(i = 0, c = clients; c; c = c->next) if(c->view == view) { c->ismax = False; c->x = sx; c->y = sy; if(i < nmaster) { c->y += i * mh; c->w = mw - 2 * BORDERPX; c->h = mh - 2 * BORDERPX; } else { /* tile window */ c->x += mw; c->w = tw - 2 * BORDERPX; if(th > 2 * BORDERPX) { c->y += (i - nmaster) * th; c->h = th - 2 * BORDERPX; } else /* fallback if th <= 2 * BORDERPX */ c->h = sh - 2 * BORDERPX; } resize(c, False); i++; } else XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); if(!sel || sel->view != view) { for(c = stack; c && c->view != view; c = c->snext); focus(c); } restack(); }
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor) { if (slot<0 || slot>=static_cast<int> (mSlots.size())) throw std::runtime_error ("slot number out of range"); ContainerStoreIterator it = mSlots[slot]; if (it != end()) { ContainerStoreIterator retval = it; // empty this slot mSlots[slot] = end(); if (it->getRefData().getCount()) { retval = restack(*it); if (actor == MWMechanics::getPlayer()) { // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared const std::string& script = it->getClass().getScript(*it); if (script != "") (*it).getRefData().getLocals().setVarByInt(script, "onpcequip", 0); } if ((mSelectedEnchantItem != end()) && (mSelectedEnchantItem == it)) { mSelectedEnchantItem = end(); } } fireEquipmentChangedEvent(actor); updateMagicEffects(actor); return retval; } return it; }
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor) { ContainerStoreIterator it = mSlots[slot]; if (it != end()) { ContainerStoreIterator retval = it; // empty this slot mSlots[slot] = end(); if (it->getRefData().getCount()) { retval = restack(*it); if (actor.getRefData().getHandle() == "player") { // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared const std::string& script = it->getClass().getScript(*it); if (script != "") (*it).getRefData().getLocals().setVarByInt(script, "onpcequip", 0); if ((mSelectedEnchantItem != end()) && (mSelectedEnchantItem == it)) { mSelectedEnchantItem = end(); } } } fireEquipmentChangedEvent(); updateMagicEffects(actor); return retval; } return it; }
Amor::Amor() : mAmor( 0 ), mBubble( 0 ), mForceHideAmorWidget( false ) { new AmorAdaptor( this ); QDBusConnection::sessionBus().registerObject( QLatin1String( "/Amor" ), this ); if( !readConfig() ) { qApp->quit(); } mTargetWin = 0; mNextTarget = 0; mAmorDialog = 0; mMenu = 0; mCurrAnim = mBaseAnim; mPosition = mCurrAnim->hotspot().x(); mState = Normal; mWin = KWindowSystem::self(); connect( mWin, SIGNAL(activeWindowChanged(WId)), this, SLOT(slotWindowActivate(WId)) ); connect( mWin, SIGNAL(windowRemoved(WId)), this, SLOT(slotWindowRemove(WId)) ); connect( mWin, SIGNAL(stackingOrderChanged()), this, SLOT(slotStackingChanged()) ); connect( mWin, SIGNAL(windowChanged(WId,const ulong*)), this, SLOT(slotWindowChange(WId,const ulong*)) ); connect( mWin, SIGNAL(currentDesktopChanged(int)), this, SLOT(slotDesktopChange(int)) ); mAmor = new AmorWidget; connect( mAmor, SIGNAL(mouseClicked(QPoint)), SLOT(slotMouseClicked(QPoint)) ); connect( mAmor, SIGNAL(dragged(QPoint,bool)), SLOT(slotWidgetDragged(QPoint,bool)) ); mAmor->resize(mTheme.maximumSize()); mTimer = new QTimer( this ); connect( mTimer, SIGNAL(timeout()), SLOT(slotTimeout()) ); mStackTimer = new QTimer( this ); connect( mStackTimer, SIGNAL(timeout()), SLOT(restack()) ); mBubbleTimer = new QTimer( this ); connect( mBubbleTimer, SIGNAL(timeout()), SLOT(slotBubbleTimeout()) ); std::time( &mActiveTime ); mCursPos = QCursor::pos(); mCursorTimer = new QTimer( this ); connect( mCursorTimer, SIGNAL(timeout()), SLOT(slotCursorTimeout()) ); mCursorTimer->start( 500 ); if( mWin->activeWindow() ) { mNextTarget = mWin->activeWindow(); selectAnimation( Focus ); mTimer->setSingleShot( true ); mTimer->start( 0 ); } if( !QDBusConnection::sessionBus().connect( QString(), QString(), QLatin1String( "org.kde.amor" ), QLatin1String( "KDE_stop_screensaver" ), this, SLOT(screenSaverStopped()) ) ) { kDebug(10000) << "Could not attach DBus signal: KDE_stop_screensaver()"; } if( !QDBusConnection::sessionBus().connect( QString(), QString(), QLatin1String( "org.kde.amor" ), QLatin1String( "KDE_start_screensaver" ), this, SLOT(screenSaverStarted()) ) ) { kDebug(10000) << "Could not attach DBus signal: KDE_start_screensaver()"; } KStartupInfo::appStarted(); }
void Amor::selectAnimation(State state) { bool changedLocation = true; AmorAnimation *oldAnim = mCurrAnim; switch( state ) { case Blur: hideBubble(); mCurrAnim = mTheme.random(QLatin1String( ANIM_BLUR ) ); mState = Focus; break; case Focus: hideBubble(); mCurrAnim = mTheme.random(QLatin1String( ANIM_FOCUS ) ); if( oldAnim != mCurrAnim ) { mCurrAnim->reset(); } mTargetWin = mNextTarget; if( mTargetWin != None ) { mTargetRect = KWindowSystem::windowInfo( mTargetWin, NET::WMFrameExtents ).frameGeometry(); // if the animation falls outside of the working area, // then relocate it so that is inside the desktop again QRect desktopArea = mWin->workArea(); if( mTargetRect.y() - mCurrAnim->hotspot().y() + mConfig.mOffset < desktopArea.y() ) { if( mInDesktopBottom ) { changedLocation = false; } // relocate the animation at the bottom of the screen mTargetRect = QRect( desktopArea.x(), desktopArea.y() + desktopArea.height(), desktopArea.width(), 0 ); // we'll relocate the animation in the desktop // frame, so do not add the offset to its vertical position mInDesktopBottom = true; } else { mInDesktopBottom = false; } if( mTheme.isStatic() ) { if( mConfig.mStaticPos < 0 ) { mPosition = mTargetRect.width() + mConfig.mStaticPos; } else { mPosition = mConfig.mStaticPos; } if( mPosition >= mTargetRect.width() ) { mPosition = mTargetRect.width()-1; } else if( mPosition < 0 ) { mPosition = 0; } } else { if( mCurrAnim->frame() ) { if( mTargetRect.width() == mCurrAnim->frame()->width() ) { mPosition = mCurrAnim->hotspot().x(); } else if(changedLocation) { mPosition = KRandom::random() % ( mTargetRect.width() - mCurrAnim->frame()->width() ); mPosition += mCurrAnim->hotspot().x(); } } else { mPosition = mTargetRect.width()/2; } } } else { // We don't want to do anything until a window comes into focus. mTimer->stop(); } mAmor->hide(); restack(); mState = Normal; break; case Destroy: hideBubble(); mCurrAnim = mTheme.random(QLatin1String( ANIM_DESTROY ) ); mState = Focus; break; case Sleeping: mCurrAnim = mTheme.random(QLatin1String( ANIM_SLEEP ) ); break; case Waking: mCurrAnim = mTheme.random(QLatin1String( ANIM_WAKE ) ); mState = Normal; break; default: // Select a random normal animation if the current animation // is not the base, otherwise select the base. This makes us // alternate between the base animation and a random animination. if( !mBubble && mCurrAnim == mBaseAnim ) { mCurrAnim = mTheme.random(QLatin1String( ANIM_NORMAL ) ); } else { mCurrAnim = mBaseAnim; } break; } if( mCurrAnim->totalMovement() + mPosition > mTargetRect.width() || mCurrAnim->totalMovement() + mPosition < 0 ) { // The selected animation would end outside of this window's width // We could randomly select a different one, but I prefer to just // use the default animation. mCurrAnim = mBaseAnim; } if( changedLocation ) { mCurrAnim->reset(); } else { mCurrAnim = oldAnim; } }
bool Adx::onHotKey(KeySym sym, uint mod) { bool hot = false; qDebug() << "HOTKEY ACTIVATED"; switch (sym) { case XK_F4:{ qDebug() << "F4"; if (mod != ALT_MOD) break; hot = true; if ((client = toppanel->currentApp->getCurrent()) != NULL) { client->destroyClient(); } }break; case XK_F9:{ qDebug() << "F9"; if (mod != ALT_MOD) break; hot = true; if ((client = toppanel->currentApp->getCurrent()) != NULL) { if (client->clientState == NormalState) { qDebug() << "HIDING WINDOW"; client->iconify(); toppanel->windowIsIconified(client); XSetInputFocus(display(), rootWindow(), None, CurrentTime); } else if (client->clientState == IconicState) { qDebug() << "SHOW WINDOW"; client->removeFromDock(); toppanel->iconIsRemoved(client); client->setChildFocus(0, CurrentTime); restack(client); } } }break; case XK_Tab:{ qDebug() << "TAB"; if (mod != ALT_MOD) break; if (m_Process != process_SwitchingWindows) { QTimer::singleShot(220, this, SLOT(onAltTab())); } hot = true; }break; case XK_Shift_L:{ qDebug() << "ALT+SHIFT"; if (mod != ALT_MOD) break; toppanel->kbswitch->nextLayout(); }break; case XK_Escape:{ qDebug() << "CTRL+ALT+ESC"; if (mod != CTRLALT_MOD) break; QProcess::startDetached("xkill"); }break; } XAllowEvents(display(), SyncBoth, CurrentTime); return hot; }