66
67
foreach (CompWindow *win, screen->windows ())
68
69
WIDGET_WINDOW (win);
69
71
if (ww->mParentWidget == win)
70
72
ww->mParentWidget = NULL;
73
if (window->destroyed ())
75
if (window->destroyed () ||
79
79
foreach (CompWindow *win, screen->windows ())
93
93
WidgetWindow::updateWidgetStatus ()
95
bool isWidget, retval;
97
97
WIDGET_SCREEN (screen);
99
switch (mPropertyState) {
99
switch (mPropertyState)
100
101
case PropertyWidget:
103
105
case PropertyNoWidget:
104
106
isWidget = false;
107
110
if (!window->managed () ||
108
111
(window->wmType () & CompWindowTypeDesktopMask))
110
112
isWidget = false;
114
114
isWidget = ws->optionGetMatch ().evaluate (window);
119
retval = (!isWidget && mIsWidget) || (isWidget && !mIsWidget);
119
bool retval = (!isWidget && mIsWidget) || (isWidget && !mIsWidget);
120
120
mIsWidget = isWidget;
126
126
WidgetWindow::updateWidgetPropertyState ()
130
130
unsigned long nitems, remain;
131
131
unsigned char *data = NULL;
133
133
WIDGET_SCREEN (screen);
135
result = XGetWindowProperty (screen->dpy (), window->id (),
136
ws->mCompizWidgetAtom, 0, 1L, false,
137
AnyPropertyType, &retType,
138
&format, &nitems, &remain, &data);
135
int result = XGetWindowProperty (screen->dpy (), window->id (),
136
ws->mCompizWidgetAtom, 0, 1L, false,
137
AnyPropertyType, &retType,
138
&format, &nitems, &remain, &data);
140
140
if (result == Success && data)
142
142
if (nitems && format == 32)
144
144
unsigned long int *retData = (unsigned long int *) data;
146
147
mPropertyState = PropertyWidget;
190
191
WidgetScreen::setWidgetLayerMapState (bool map)
192
CompWindow *highest = NULL;
193
unsigned int highestActiveNum = 0;
194
CompWindowList copyWindows = screen->windows ();
193
CompWindow *highest = NULL;
194
unsigned int highestActiveNum = 0;
195
CompWindowList copyWindows = screen->windows ();
196
197
/* We have to operate on a copy of the list, since it's possible
197
198
* for the screen->windows () to be re-ordered by
271
273
foreach (CompWindow *w, screen->windows ())
273
275
WIDGET_WINDOW (w);
274
277
if (ww->updateWidgetStatus ())
278
map = !ww->mIsWidget || (mState != StateOff);
279
bool map = !ww->mIsWidget || (mState != StateOff);
279
280
ww->updateWidgetMapState (map);
281
282
ww->updateTreeStatus ();
362
367
switch (event->type)
365
if (event->xproperty.atom == mCompizWidgetAtom)
367
w = screen->findWindow (event->xproperty.window);
371
if (ww->updateWidgetPropertyState ())
375
map = !ww->mIsWidget || mState != StateOff;
376
ww->updateWidgetMapState (map);
377
ww->updateTreeStatus ();
378
screen->matchPropertyChanged (w);
382
else if (event->xproperty.atom == Atoms::wmClientLeader)
384
w = screen->findWindow (event->xproperty.window);
370
if (event->xproperty.atom == mCompizWidgetAtom)
372
w = screen->findWindow (event->xproperty.window);
378
if (ww->updateWidgetPropertyState ())
380
bool map = !ww->mIsWidget || mState != StateOff;
381
ww->updateWidgetMapState (map);
382
ww->updateTreeStatus ();
383
screen->matchPropertyChanged (w);
387
else if (event->xproperty.atom == Atoms::wmClientLeader)
389
w = screen->findWindow (event->xproperty.window);
396
ww->updateTreeStatus ();
397
else if (ww->mParentWidget)
399
WidgetWindow *pww = WidgetWindow::get (ww->mParentWidget);
400
pww->updateTreeStatus ();
408
/* terminate widget mode if a non-widget window was clicked */
409
if (optionGetEndOnClick () &&
410
event->xbutton.button == Button1)
412
if (mState == StateOn)
414
w = screen->findWindow (event->xbutton.window);
416
if (w && w->managed ())
420
if (!ww->mIsWidget && !ww->mParentWidget)
421
endWidgetMode (NULL);
429
w = screen->findWindow (event->xmap.window);
435
ww->updateWidgetStatus ();
389
437
if (ww->mIsWidget)
390
ww->updateTreeStatus ();
391
else if (ww->mParentWidget)
393
WidgetWindow *pww = WidgetWindow::get (ww->mParentWidget);
394
pww->updateTreeStatus ();
400
/* terminate widget mode if a non-widget window was clicked */
401
if (optionGetEndOnClick () &&
402
event->xbutton.button == Button1)
404
if (mState == StateOn)
406
w = screen->findWindow (event->xbutton.window);
407
if (w && w->managed ())
411
if (!ww->mIsWidget && !ww->mParentWidget)
412
endWidgetMode (NULL);
418
w = screen->findWindow (event->xmap.window);
423
ww->updateWidgetStatus ();
425
ww->updateWidgetMapState (mState != StateOff);
429
w = screen->findWindow (event->xunmap.window);
433
ww->updateTreeStatus ();
438
w = screen->findWindow (event->xdestroywindow.window);
442
ww->updateTreeStatus ();
438
ww->updateWidgetMapState (mState != StateOff);
444
w = screen->findWindow (event->xunmap.window);
449
ww->updateTreeStatus ();
456
w = screen->findWindow (event->xdestroywindow.window);
461
ww->updateTreeStatus ();
465
488
WidgetScreen::updateStatus (CompWindow *w)
469
490
WIDGET_WINDOW (w);
471
492
if (ww->updateWidgetPropertyState ())
472
493
ww->updateWidgetMapState (mState != StateOff);
474
clientLeader = w->clientLeader (true);
495
Window clientLeader = w->clientLeader (true);
476
497
if (ww->mIsWidget)
478
498
ww->updateTreeStatus ();
480
499
else if (clientLeader)
501
CompWindow *lw = screen->findWindow (clientLeader);
484
lw = screen->findWindow (clientLeader);
488
lww = WidgetWindow::get (lw);
505
WidgetWindow *lww = WidgetWindow::get (lw);
490
507
if (lww->mIsWidget)
491
508
ww->mParentWidget = lw;
534
551
fadeProgress = ws->optionGetFadeTime ();
535
553
if (fadeProgress)
536
554
fadeProgress = (float) ws->mFadeTime / (1000.0f * fadeProgress);
537
556
fadeProgress = 1.0f - fadeProgress;
540
559
if (!mIsWidget && !mParentWidget)
544
561
if (ws->mState == WidgetScreen::StateFadeIn ||
545
562
ws->mState == WidgetScreen::StateOn)
547
563
fadeProgress = 1.0f - fadeProgress;
550
progress = ws->optionGetBgSaturation () / 100.0f;
551
progress += (1.0f - progress) * fadeProgress;
565
float progress = ws->optionGetBgSaturation () / 100.0f;
566
progress += (1.0f - progress) * fadeProgress;
552
567
wAttrib.saturation = (float) wAttrib.saturation * progress;
554
progress = ws->optionGetBgBrightness () / 100.0f;
555
progress += (1.0f - progress) * fadeProgress;
569
progress = ws->optionGetBgBrightness () / 100.0f;
570
progress += (1.0f - progress) * fadeProgress;
557
572
wAttrib.brightness = (float) wAttrib.brightness * progress;
657
669
WidgetScreen::WidgetScreen (CompScreen *screen) :
658
670
PluginClassHandler <WidgetScreen, CompScreen> (screen),
659
cScreen (CompositeScreen::get (screen)),
671
cScreen (CompositeScreen::get (screen)),
660
672
mLastActiveWindow (None),
661
673
mCompizWidgetAtom (XInternAtom (screen->dpy (), "_COMPIZ_WIDGET", false)),
664
mCursor (XCreateFontCursor (screen->dpy (), XC_watch))
676
mCursor (XCreateFontCursor (screen->dpy (), XC_watch))
666
678
CompAction::CallBack cb;
667
679
ChangeNotify notify;
702
714
WidgetWindow::WidgetWindow (CompWindow *window) :
703
715
PluginClassHandler <WidgetWindow, CompWindow> (window),
705
gWindow (GLWindow::get (window)),
708
mParentWidget (NULL),
717
gWindow (GLWindow::get (window)),
720
mParentWidget (NULL),
709
721
mPropertyState (PropertyNotSet)
711
723
WindowInterface::setHandler (window);