diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2008-01-18 16:41:09 +0100 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2008-01-18 16:41:09 +0100 |
commit | e595578f2be2f4f9e5f8d78130adc8eb5257b1ff (patch) | |
tree | cb28902c84512e4693d1198e241ea4065ff62872 /shelf.c | |
parent | fade28c36e1fa26ee9be8a0b8de10b6557ecb33c (diff) | |
download | shelf-e595578f2be2f4f9e5f8d78130adc8eb5257b1ff.tar.gz shelf-e595578f2be2f4f9e5f8d78130adc8eb5257b1ff.tar.bz2 |
Binding to scale to a 1/2, 1/3 or a 1/6th of the screen.
Diffstat (limited to 'shelf.c')
-rw-r--r-- | shelf.c | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -238,6 +238,50 @@ shelfTrigger (CompDisplay *d, return TRUE; } +/* Returns the ratio to multiply by to get a window that's 1/ration the + * size of the screen. + */ +static inline float +shelfRat (CompWindow *w, + float ratio) +{ + float winHeight = (float) w->height; + float winWidth = (float) w->width; + float scrHeight = (float) w->screen->height; + float scrWidth = (float) w->screen->width; + float ret; + if (winHeight/scrHeight < winWidth/scrWidth) + ret = scrWidth/winWidth; + else + ret = scrHeight/winHeight; + return ret/ratio; +} + +static Bool +shelfTriggerScreen (CompDisplay *d, + CompAction *action, + CompActionState state, + CompOption *option, + int nOption) +{ + CompWindow *w = findWindowAtDisplay (d, d->activeWindow); + if (!w) + return TRUE; + SHELF_SCREEN (w->screen); + SHELF_WINDOW (w); + if (sw->targetScale > shelfRat(w,2.0f)) + shelfScaleWindow (w, shelfRat(w,2.0f)); + else if (sw->targetScale <= shelfRat(w,2.0f) && + sw->targetScale > shelfRat(w,3.0f)) + shelfScaleWindow (w, shelfRat(w,3.0f)); + else if (sw->targetScale <= shelfRat(w,3.0f) && + sw->targetScale > shelfRat(w,6.0f)) + shelfScaleWindow (w, shelfRat(w,6.0f)); + else + shelfScaleWindow (w, 1.0f); + return TRUE; +} + /* shelfInc and shelfDec are matcing functions and bindings; * They increase and decrease the scale factor by 'interval'. */ @@ -532,7 +576,9 @@ shelfInitDisplay (CompPlugin *p, freeScreenPrivateIndex (d, screenPrivateIndex); return FALSE; } + shelfSetTriggerKeyInitiate (d, shelfTrigger); + shelfSetTriggerscreenKeyInitiate (d, shelfTriggerScreen); shelfSetIncButtonInitiate (d, shelfInc); shelfSetDecButtonInitiate (d, shelfDec); WRAP (sd, d, handleEvent, shelfHandleEvent); |