Merge lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements into lp:compiz/0.9.11

Proposed by MC Return
Status: Work in progress
Proposed branch: lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements
Merge into: lp:compiz/0.9.11
Diff against target: 3829 lines (+791/-770)
1 file modified
src/screen.cpp (+791/-770)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+176727@code.launchpad.net

Commit message

src/screen.cpp, cleanup:

Merged if condition checks.
Declaration and assignment of variables in one line.
Declaration of variables outside of loops.
Use pre- instead of postfix in- and decrement.
if (something == 0) == if (!something).
Removed redundant brackets.
Added and removed newlines.
Added default case, if missing (just a style issue).
Fixed indentation.
Added TODOs.

src/screen.cpp, other improvements:

Do not assign values to variables, that are never used -
(int i = 0; for example).
int dSize = nDesktop * 2 + nDesktop * 2 + nDesktop * 4 + 1; ==
int dSize = nDesktop * 8 + 1;.

src/screen.cpp, other fixes:

Initialize multiple non-static class member variables (escapeKeyCode,
returnKeyCode, wmSnTimestamp) and fields (attrib) that are not
initialized in the PrivateScreen::PrivateScreen (CompScreen *, compiz::
private_screen::WindowManager &) constructor nor in any functions that it
calls.
(LP: #1101639)

Also initialize the class members xSync, xRandr, xShape, viewPort,
orphanData, outputDevices, colormap, screenNum, fullscreenOutput,
screenEdge, workArea, xkbEvent, xineramaExtension, displayString_,
region, pingTimer, edgeDelaySettings and pluginManager in the same ctor.

Initialize the non-static class member "grabbed" in the EventManager::
EventManager () ctor.
(LP: #1101590)

Description of the change

quilting needs to be adjusted...

dh_quilt_patch
Applying patch ubuntu_super_p.patch
patching file src/screen.cpp
Hunk #1 FAILED at 3253.
1 out of 1 hunk FAILED -- rejects in file src/screen.cpp
Patch ubuntu_super_p.patch does not apply (enforce with -f)
dh_quilt_patch: quilt --quiltrc /dev/null push -a || test $? = 2 returned exit code 1

Still WIP.

To post a comment you must log in.

Unmerged revisions

3758. By MC Return

Merged latest lp:compiz

3757. By MC Return

Initialize multiple non-static class member variables (escapeKeyCode,
returnKeyCode, wmSnTimestamp) and fields (attrib) that are not
initialized in the PrivateScreen::PrivateScreen (CompScreen *, compiz::
private_screen::WindowManager &) constructor nor in any functions that it
calls (LP: #1101639)

Also initialize the class members xSync, xRandr, xShape, viewPort,
orphanData, outputDevices, colormap, screenNum, fullscreenOutput,
screenEdge, workArea, xkbEvent, xineramaExtension, displayString_,
region, pingTimer, edgeDelaySettings and pluginManager in the same ctor

3756. By MC Return

Initialize the non-static class member "grabbed" in the EventManager::
EventManager () ctor
(LP: #1101590)

3755. By MC Return

Fixed minor style ssues

3754. By MC Return

src/screen.cpp, massive cleanup
(please see main commit message for details)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/screen.cpp'
--- src/screen.cpp 2013-05-13 13:27:30 +0000
+++ src/screen.cpp 2013-07-24 16:11:44 +0000
@@ -67,12 +67,12 @@
6767
68CompOutput *targetOutput;68CompOutput *targetOutput;
6969
70int lastPointerX = 0;70int lastPointerX = 0;
71int lastPointerY = 0;71int lastPointerY = 0;
72unsigned int lastPointerMods = 0;72unsigned int lastPointerMods = 0;
73int pointerX = 0;73int pointerX = 0;
74int pointerY = 0;74int pointerY = 0;
75unsigned int pointerMods = 0;75unsigned int pointerMods = 0;
7676
77namespace77namespace
78{78{
@@ -85,18 +85,17 @@
85#define MwmHintsDecorations (1L << 1)85#define MwmHintsDecorations (1L << 1)
86static const unsigned short PropMotifWmHintElements = 3;86static const unsigned short PropMotifWmHintElements = 3;
8787
88typedef struct {88typedef struct
89{
89 unsigned long flags;90 unsigned long flags;
90 unsigned long functions;91 unsigned long functions;
91 unsigned long decorations;92 unsigned long decorations;
92} MwmHints;93} MwmHints;
9394
94namespace cps = compiz::private_screen;95namespace cps = compiz::private_screen;
95namespace ca = compiz::actions;96namespace ca = compiz::actions;
9697
9798CompScreen *screen;
98
99CompScreen *screen;
100ModifierHandler *modHandler;99ModifierHandler *modHandler;
101100
102PluginClassStorage::Indices screenPluginClassIndices (0);101PluginClassStorage::Indices screenPluginClassIndices (0);
@@ -112,9 +111,9 @@
112 privateScreen.setWindowState (state, id);111 privateScreen.setWindowState (state, id);
113}112}
114113
115void CompScreenImpl::addToDestroyedWindows(CompWindow * cw)114void CompScreenImpl::addToDestroyedWindows (CompWindow * cw)
116{115{
117 windowManager.addToDestroyedWindows(cw);116 windowManager.addToDestroyedWindows (cw);
118}117}
119118
120void CompScreenImpl::processEvents () { privateScreen.processEvents (); }119void CompScreenImpl::processEvents () { privateScreen.processEvents (); }
@@ -146,10 +145,12 @@
146 case SIGTERM:145 case SIGTERM:
147 mainloop->quit ();146 mainloop->quit ();
148 break;147 break;
148
149 case SIGHUP:149 case SIGHUP:
150 restartSignal = true;150 restartSignal = true;
151 mainloop->quit ();151 mainloop->quit ();
152 break;152 break;
153
153 default:154 default:
154 break;155 break;
155 }156 }
@@ -160,11 +161,11 @@
160void161void
161CompScreenImpl::eventLoop ()162CompScreenImpl::eventLoop ()
162{163{
163 privateScreen.eventManager.startEventLoop (dpy());164 privateScreen.eventManager.startEventLoop (dpy ());
164}165}
165166
166void167void
167cps::EventManager::startEventLoop(Display* dpy)168cps::EventManager::startEventLoop (Display *dpy)
168{169{
169 source = CompEventSource::create ();170 source = CompEventSource::create ();
170 timeout = CompTimeoutSource::create (ctx);171 timeout = CompTimeoutSource::create (ctx);
@@ -173,13 +174,13 @@
173174
174 XFlush (dpy);175 XFlush (dpy);
175176
176 mainloop->run();177 mainloop->run ();
177}178}
178179
179CompFileWatchHandle180CompFileWatchHandle
180CompScreenImpl::addFileWatch (const char *path,181CompScreenImpl::addFileWatch (const char *path,
181 int mask,182 int mask,
182 FileWatchCallBack callBack)183 FileWatchCallBack callBack)
183{184{
184 CompFileWatch *fileWatch = privateScreen.eventManager.addFileWatch (path, mask, callBack);185 CompFileWatch *fileWatch = privateScreen.eventManager.addFileWatch (path, mask, callBack);
185186
@@ -192,17 +193,17 @@
192}193}
193194
194CompFileWatch*195CompFileWatch*
195cps::EventManager::addFileWatch (196cps::EventManager::addFileWatch (const char *path,
196 const char *path,197 int mask,
197 int mask,198 FileWatchCallBack callBack)
198 FileWatchCallBack callBack)
199{199{
200 CompFileWatch *fw = new CompFileWatch ();200 CompFileWatch *fw = new CompFileWatch ();
201
201 if (!fw)202 if (!fw)
202 return 0;203 return 0;
203204
204 fw->path = path;205 fw->path = path;
205 fw->mask = mask;206 fw->mask = mask;
206 fw->callBack = callBack;207 fw->callBack = callBack;
207 fw->handle = lastFileWatchHandle++;208 fw->handle = lastFileWatchHandle++;
208209
@@ -237,7 +238,7 @@
237 if (it == fileWatch.end ())238 if (it == fileWatch.end ())
238 return 0;239 return 0;
239240
240 CompFileWatch* w = (*it);241 CompFileWatch *w = (*it);
241 fileWatch.erase (it);242 fileWatch.erase (it);
242243
243 return w;244 return w;
@@ -255,7 +256,7 @@
255 return fileWatch;256 return fileWatch;
256}257}
257258
258CompWatchFd::CompWatchFd (int fd,259CompWatchFd::CompWatchFd (int fd,
259 Glib::IOCondition events,260 Glib::IOCondition events,
260 FdWatchCallBack callback) :261 FdWatchCallBack callback) :
261 Glib::IOSource (fd, events),262 Glib::IOSource (fd, events),
@@ -282,29 +283,33 @@
282283
283CompWatchFdHandle284CompWatchFdHandle
284CompScreenImpl::addWatchFd (int fd,285CompScreenImpl::addWatchFd (int fd,
285 short int events,286 short int events,
286 FdWatchCallBack callBack)287 FdWatchCallBack callBack)
287{288{
288 return privateScreen.eventManager.addWatchFd (fd, events, callBack);289 return privateScreen.eventManager.addWatchFd (fd, events, callBack);
289}290}
290291
291CompWatchFdHandle292CompWatchFdHandle
292cps::EventManager::addWatchFd (int fd,293cps::EventManager::addWatchFd (int fd,
293 short int events,294 short int events,
294 FdWatchCallBack callBack)295 FdWatchCallBack callBack)
295{296{
296 Glib::IOCondition gEvents;297 Glib::IOCondition gEvents;
297 298
298 memset (&gEvents, 0, sizeof (Glib::IOCondition));299 memset (&gEvents, 0, sizeof (Glib::IOCondition));
299300
300 if (events & POLLIN)301 if (events & POLLIN)
301 gEvents |= Glib::IO_IN;302 gEvents |= Glib::IO_IN;
303
302 if (events & POLLOUT)304 if (events & POLLOUT)
303 gEvents |= Glib::IO_OUT;305 gEvents |= Glib::IO_OUT;
306
304 if (events & POLLPRI)307 if (events & POLLPRI)
305 gEvents |= Glib::IO_PRI;308 gEvents |= Glib::IO_PRI;
309
306 if (events & POLLERR)310 if (events & POLLERR)
307 gEvents |= Glib::IO_ERR;311 gEvents |= Glib::IO_ERR;
312
308 if (events & POLLHUP)313 if (events & POLLHUP)
309 gEvents |= Glib::IO_HUP;314 gEvents |= Glib::IO_HUP;
310315
@@ -314,7 +319,8 @@
314319
315 if (!watchFd)320 if (!watchFd)
316 return 0;321 return 0;
317 watchFd->mHandle = lastWatchFdHandle++;322
323 watchFd->mHandle = ++lastWatchFdHandle;
318324
319 if (lastWatchFdHandle == MAXSHORT)325 if (lastWatchFdHandle == MAXSHORT)
320 lastWatchFdHandle = 1;326 lastWatchFdHandle = 1;
@@ -334,19 +340,16 @@
334cps::EventManager::removeWatchFd (CompWatchFdHandle handle)340cps::EventManager::removeWatchFd (CompWatchFdHandle handle)
335{341{
336 std::list<CompWatchFd * >::iterator it;342 std::list<CompWatchFd * >::iterator it;
337 CompWatchFd * w;
338343
339 for (it = watchFds.begin();344 for (it = watchFds.begin ();
340 it != watchFds.end (); ++it)345 it != watchFds.end (); ++it)
341 {
342 if ((*it)->mHandle == handle)346 if ((*it)->mHandle == handle)
343 break;347 break;
344 }
345348
346 if (it == watchFds.end ())349 if (it == watchFds.end ())
347 return;350 return;
348351
349 w = (*it);352 CompWatchFd *w = (*it);
350353
351 if (w->mExecuting)354 if (w->mExecuting)
352 {355 {
@@ -383,14 +386,19 @@
383386
384 if (events & Glib::IO_IN)387 if (events & Glib::IO_IN)
385 revents |= POLLIN;388 revents |= POLLIN;
389
386 if (events & Glib::IO_OUT)390 if (events & Glib::IO_OUT)
387 revents |= POLLOUT;391 revents |= POLLOUT;
392
388 if (events & Glib::IO_PRI)393 if (events & Glib::IO_PRI)
389 revents |= POLLPRI;394 revents |= POLLPRI;
395
390 if (events & Glib::IO_ERR)396 if (events & Glib::IO_ERR)
391 revents |= POLLERR;397 revents |= POLLERR;
398
392 if (events & Glib::IO_HUP)399 if (events & Glib::IO_HUP)
393 revents |= POLLHUP;400 revents |= POLLHUP;
401
394 if (events & Glib::IO_NVAL)402 if (events & Glib::IO_NVAL)
395 return false;403 return false;
396404
@@ -405,9 +413,9 @@
405 //screen->priv->watchFds.remove (this);413 //screen->priv->watchFds.remove (this);
406 return false;414 return false;
407 }415 }
408 416
409 return true;417 return true;
410} 418}
411419
412void420void
413CompScreenImpl::eraseValue (CompString key)421CompScreenImpl::eraseValue (CompString key)
@@ -444,18 +452,18 @@
444 const char *name,452 const char *name,
445 CompOption::Value &value)453 CompOption::Value &value)
446{454{
447 WRAPABLE_HND_FUNCTN_RETURN (bool, setOptionForPlugin,455 WRAPABLE_HND_FUNCTN_RETURN (bool, setOptionForPlugin, plugin, name, value)
448 plugin, name, value)
449456
450 return _setOptionForPlugin(plugin, name, value);457 return _setOptionForPlugin(plugin, name, value);
451}458}
452459
453bool460bool
454CompScreenImpl::_setOptionForPlugin (const char *plugin,461CompScreenImpl::_setOptionForPlugin (const char *plugin,
455 const char *name,462 const char *name,
456 CompOption::Value &value)463 CompOption::Value &value)
457{464{
458 CompPlugin *p = CompPlugin::find (plugin);465 CompPlugin *p = CompPlugin::find (plugin);
466
459 if (p)467 if (p)
460 return p->vTable->setOption (name, value);468 return p->vTable->setOption (name, value);
461469
@@ -472,7 +480,7 @@
472480
473void481void
474CompScreenImpl::_sessionEvent (CompSession::Event event,482CompScreenImpl::_sessionEvent (CompSession::Event event,
475 CompOption::Vector &arguments)483 CompOption::Vector &arguments)
476{484{
477}485}
478486
@@ -515,7 +523,7 @@
515 char str[128];523 char str[128];
516#endif524#endif
517525
518 errors++;526 ++errors;
519527
520#ifdef DEBUG528#ifdef DEBUG
521 XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128);529 XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128);
@@ -529,8 +537,10 @@
529537
530 snprintf (str, 128, "%d", e->request_code);538 snprintf (str, 128, "%d", e->request_code);
531 XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128);539 XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128);
540
532 if (strcmp (str, ""))541 if (strcmp (str, ""))
533 fprintf (stderr, " (%s)", str);542 fprintf (stderr, " (%s)", str);
543
534 fprintf (stderr, "\n ");544 fprintf (stderr, "\n ");
535545
536 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128);546 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128);
@@ -550,11 +560,9 @@
550int560int
551CompScreen::checkForError (Display *dpy)561CompScreen::checkForError (Display *dpy)
552{562{
553 int e;
554
555 XSync (dpy, false);563 XSync (dpy, false);
556564
557 e = errors;565 int e = errors;
558 errors = 0;566 errors = 0;
559567
560 return e;568 return e;
@@ -639,7 +647,7 @@
639void647void
640PrivateScreen::setAudibleBell (bool audible)648PrivateScreen::setAudibleBell (bool audible)
641{649{
642 if (xkbEvent.isEnabled())650 if (xkbEvent.isEnabled ())
643 XkbChangeEnabledControls (dpy,651 XkbChangeEnabledControls (dpy,
644 XkbUseCoreKbd,652 XkbUseCoreKbd,
645 XkbAudibleBellMask,653 XkbAudibleBellMask,
@@ -649,22 +657,23 @@
649bool657bool
650CompScreenImpl::handlePingTimeout ()658CompScreenImpl::handlePingTimeout ()
651{659{
652 return Ping::handlePingTimeout(660 return Ping::handlePingTimeout (windowManager.begin (),
653 windowManager.begin(),661 windowManager.end (),
654 windowManager.end(),662 privateScreen.dpy);
655 privateScreen.dpy);
656}663}
657664
658bool665bool
659cps::Ping::handlePingTimeout (WindowManager::iterator begin, WindowManager::iterator end, Display* dpy)666cps::Ping::handlePingTimeout (WindowManager::iterator begin,
667 WindowManager::iterator end,
668 Display *dpy)
660{669{
661 XEvent ev;670 XEvent ev;
662 int ping = lastPing_ + 1;671 int ping = lastPing_ + 1;
663672
664 ev.type = ClientMessage;673 ev.type = ClientMessage;
665 ev.xclient.window = 0;674 ev.xclient.window = 0;
666 ev.xclient.message_type = Atoms::wmProtocols;675 ev.xclient.message_type = Atoms::wmProtocols;
667 ev.xclient.format = 32;676 ev.xclient.format = 32;
668 ev.xclient.data.l[0] = Atoms::wmPing;677 ev.xclient.data.l[0] = Atoms::wmPing;
669 ev.xclient.data.l[1] = ping;678 ev.xclient.data.l[1] = ping;
670 ev.xclient.data.l[2] = 0;679 ev.xclient.data.l[2] = 0;
@@ -674,6 +683,7 @@
674 for (WindowManager::iterator i = begin; i != end; ++i)683 for (WindowManager::iterator i = begin; i != end; ++i)
675 {684 {
676 CompWindow* const w(*i);685 CompWindow* const w(*i);
686
677 if (w->priv->handlePingTimeout (lastPing_))687 if (w->priv->handlePingTimeout (lastPing_))
678 {688 {
679 ev.xclient.window = w->id ();689 ev.xclient.window = w->id ();
@@ -696,7 +706,7 @@
696706
697bool707bool
698CompScreenImpl::setOption (const CompString &name,708CompScreenImpl::setOption (const CompString &name,
699 CompOption::Value &value)709 CompOption::Value &value)
700{710{
701 return privateScreen.setOption (name, value);711 return privateScreen.setOption (name, value);
702}712}
@@ -709,48 +719,54 @@
709719
710 bool rv = CoreOptions::setOption (name, value);720 bool rv = CoreOptions::setOption (name, value);
711721
712 if (!rv)722 if (!rv ||
723 !CompOption::findOption (getOptions (), name, &index))
713 return false;724 return false;
714725
715 if (!CompOption::findOption (getOptions (), name, &index))726 switch (index)
716 return false;727 {
717
718 switch (index) {
719 case CoreOptions::ActivePlugins:728 case CoreOptions::ActivePlugins:
720 pluginManager.setDirtyPluginList ();729 pluginManager.setDirtyPluginList ();
721 break;730 break;
731
722 case CoreOptions::PingDelay:732 case CoreOptions::PingDelay:
723 pingTimer.setTimes (optionGetPingDelay (),733 pingTimer.setTimes (optionGetPingDelay (),
724 optionGetPingDelay () + 500);734 optionGetPingDelay () + 500);
725 break;735 break;
736
726 case CoreOptions::AudibleBell:737 case CoreOptions::AudibleBell:
727 setAudibleBell (optionGetAudibleBell ());738 setAudibleBell (optionGetAudibleBell ());
728 break;739 break;
740
729 case CoreOptions::DetectOutputs:741 case CoreOptions::DetectOutputs:
730 if (optionGetDetectOutputs ())742 if (optionGetDetectOutputs ())
731 detectOutputDevices (*this);743 detectOutputDevices (*this);
732 break;744 break;
745
733 case CoreOptions::Hsize:746 case CoreOptions::Hsize:
734 case CoreOptions::Vsize:747 case CoreOptions::Vsize:
735748 if (optionGetHsize () * screen->width () > MAXSHORT ||
736 if (optionGetHsize () * screen->width () > MAXSHORT)749 optionGetVsize () * screen->height () > MAXSHORT)
737 return false;
738 if (optionGetVsize () * screen->height () > MAXSHORT)
739 return false;750 return false;
740751
741 setVirtualScreenSize (optionGetHsize (), optionGetVsize ());752 setVirtualScreenSize (optionGetHsize (), optionGetVsize ());
742 break;753 break;
754
743 case CoreOptions::NumberOfDesktops:755 case CoreOptions::NumberOfDesktops:
744 setNumberOfDesktops (optionGetNumberOfDesktops ());756 setNumberOfDesktops (optionGetNumberOfDesktops ());
745 break;757 break;
758
746 case CoreOptions::DefaultIcon:759 case CoreOptions::DefaultIcon:
747 return screen->updateDefaultIcon ();760 return screen->updateDefaultIcon ();
748 break;761 break;
762
749 case CoreOptions::Outputs:763 case CoreOptions::Outputs:
750 if (optionGetDetectOutputs ())764 if (optionGetDetectOutputs ())
751 return false;765 return false;
766
752 updateOutputDevices (*this);767 updateOutputDevices (*this);
753 break;768 break;
769
754 default:770 default:
755 break;771 break;
756 }772 }
@@ -763,6 +779,7 @@
763{779{
764 if (!XEventsQueued (dpy, QueuedAlready))780 if (!XEventsQueued (dpy, QueuedAlready))
765 return false;781 return false;
782
766 XNextEvent (dpy, &ev);783 XNextEvent (dpy, &ev);
767784
768 /* Skip to the last MotionNotify785 /* Skip to the last MotionNotify
@@ -770,6 +787,7 @@
770 if (ev.type == MotionNotify)787 if (ev.type == MotionNotify)
771 {788 {
772 XEvent peekEvent;789 XEvent peekEvent;
790
773 while (XPending (dpy))791 while (XPending (dpy))
774 {792 {
775 XPeekEvent (dpy, &peekEvent);793 XPeekEvent (dpy, &peekEvent);
@@ -790,9 +808,7 @@
790 StackDebugger *dbg = StackDebugger::Default ();808 StackDebugger *dbg = StackDebugger::Default ();
791809
792 if (StackDebugger::Default ())810 if (StackDebugger::Default ())
793 {
794 return dbg->getNextEvent (ev);811 return dbg->getNextEvent (ev);
795 }
796 else812 else
797 return getNextXEvent (ev);813 return getNextXEvent (ev);
798}814}
@@ -804,77 +820,83 @@
804820
805 if (pluginManager.isDirtyPluginList ())821 if (pluginManager.isDirtyPluginList ())
806 {822 {
807 eventManager.resetPossibleTap();823 eventManager.resetPossibleTap ();
808 pluginManager.updatePlugins (screen, optionGetActivePlugins());824 pluginManager.updatePlugins (screen, optionGetActivePlugins ());
809 }825 }
810826
811 windowManager.validateServerWindows();827 windowManager.validateServerWindows ();
812828
813 if (dbg)829 if (dbg)
814 {830 {
815 dbg->windowsChanged (false);831 dbg->windowsChanged (false);
816 dbg->serverWindowsChanged (false);832 dbg->serverWindowsChanged (false);
817 dbg->loadStack (windowManager.getServerWindows());833 dbg->loadStack (windowManager.getServerWindows ());
818 }834 }
819835
820 windowManager.invalidateServerWindows();836 windowManager.invalidateServerWindows ();
821837
822 XEvent event;838 XEvent event;
823839
824 while (getNextEvent (event))840 while (getNextEvent (event))
825 {841 {
826 switch (event.type) {842 switch (event.type)
827 case ButtonPress:843 {
828 case ButtonRelease:844 case ButtonPress:
829 pointerX = event.xbutton.x_root;845 case ButtonRelease:
830 pointerY = event.xbutton.y_root;846 pointerX = event.xbutton.x_root;
831 pointerMods = event.xbutton.state;847 pointerY = event.xbutton.y_root;
832 break;848 pointerMods = event.xbutton.state;
833 case KeyPress:849 break;
834 case KeyRelease:850
835 pointerX = event.xkey.x_root;851 case KeyPress:
836 pointerY = event.xkey.y_root;852 case KeyRelease:
837 pointerMods = event.xkey.state;853 pointerX = event.xkey.x_root;
838 break;854 pointerY = event.xkey.y_root;
839 case MotionNotify:855 pointerMods = event.xkey.state;
840856 break;
841 pointerX = event.xmotion.x_root;857
842 pointerY = event.xmotion.y_root;858 case MotionNotify:
843 pointerMods = event.xmotion.state;859 pointerX = event.xmotion.x_root;
844 break;860 pointerY = event.xmotion.y_root;
845 case EnterNotify:861 pointerMods = event.xmotion.state;
846 case LeaveNotify:862 break;
847 pointerX = event.xcrossing.x_root;863
848 pointerY = event.xcrossing.y_root;864 case EnterNotify:
849 pointerMods = event.xcrossing.state;865 case LeaveNotify:
850 break;866 pointerX = event.xcrossing.x_root;
851 case ClientMessage:867 pointerY = event.xcrossing.y_root;
852 if (event.xclient.message_type == Atoms::xdndPosition)868 pointerMods = event.xcrossing.state;
853 {869 break;
854 pointerX = event.xclient.data.l[2] >> 16;870
855 pointerY = event.xclient.data.l[2] & 0xffff;871 case ClientMessage:
856 /* FIXME: Xdnd provides us no way of getting the pointer mods872 if (event.xclient.message_type == Atoms::xdndPosition)
857 * without doing XQueryPointer, which is a round-trip */873 {
858 pointerMods = 0;874 pointerX = event.xclient.data.l[2] >> 16;
859 }875 pointerY = event.xclient.data.l[2] & 0xffff;
860 else if (event.xclient.message_type == Atoms::wmMoveResize)876 /* FIXME: Xdnd provides us no way of getting the pointer mods
861 {877 * without doing XQueryPointer, which is a round-trip */
862 int i;878 pointerMods = 0;
863 Window child, root;879 }
864 /* _NET_WM_MOVERESIZE is most often sent by clients who provide880 else if (event.xclient.message_type == Atoms::wmMoveResize)
865 * a special "grab space" on a window for the user to initiate881 {
866 * adjustment by the window manager. Since we don't have a882 int i;
867 * passive grab on Button1 for active and raised windows, we883 Window child, root;
868 * need to update the pointer buffer here */884 /* _NET_WM_MOVERESIZE is most often sent by clients who provide
869885 * a special "grab space" on a window for the user to initiate
870 XQueryPointer (screen->dpy (), screen->root (),886 * adjustment by the window manager. Since we don't have a
871 &root, &child, &pointerX, &pointerY,887 * passive grab on Button1 for active and raised windows, we
872 &i, &i, &pointerMods);888 * need to update the pointer buffer here */
873 }889
874 break;890 XQueryPointer (screen->dpy (), screen->root (),
875 default:891 &root, &child, &pointerX, &pointerY,
876 break;892 &i, &i, &pointerMods);
877 }893 }
894
895 break;
896
897 default:
898 break;
899 }
878900
879 sn_display_process_event (snDisplay, &event);901 sn_display_process_event (snDisplay, &event);
880902
@@ -895,20 +917,23 @@
895 if (dbg)917 if (dbg)
896 {918 {
897 if (dbg->windowsChanged () &&919 if (dbg->windowsChanged () &&
898 dbg->cmpStack (windowManager.getWindows(), windowManager.getServerWindows()))920 dbg->cmpStack (windowManager.getWindows (),
921 windowManager.getServerWindows ()))
899 {922 {
900 compLogMessage ("core", CompLogLevelDebug, "stacks are out of sync");923 compLogMessage ("core", CompLogLevelDebug, "stacks are out of sync");
924
901 if (dbg->timedOut ())925 if (dbg->timedOut ())
902 compLogMessage ("core", CompLogLevelDebug, "however, this may be a false positive");926 compLogMessage ("core", CompLogLevelDebug, "however, this may be a false positive");
903 }927 }
904928
905 if (dbg->serverWindowsChanged () && dbg->checkSanity (windowManager.getWindows()))929 if (dbg->serverWindowsChanged () &&
930 dbg->checkSanity (windowManager.getWindows ()))
906 compLogMessage ("core", CompLogLevelDebug, "windows are stacked incorrectly");931 compLogMessage ("core", CompLogLevelDebug, "windows are stacked incorrectly");
907 }932 }
908}933}
909934
910void935void
911cps::WindowManager::validateServerWindows()936cps::WindowManager::validateServerWindows ()
912{937{
913 /* Restacks recently processed, ensure that938 /* Restacks recently processed, ensure that
914 * plugins use the stack last received from939 * plugins use the stack last received from
@@ -927,30 +952,32 @@
927}952}
928953
929void954void
930cps::WindowManager::invalidateServerWindows()955cps::WindowManager::invalidateServerWindows ()
931{956{
932 stackIsFresh = false;957 stackIsFresh = false;
933}958}
934959
935void960void
936cps::WindowManager::clearFullscreenHints() const961cps::WindowManager::clearFullscreenHints () const
937{962{
938 /* clear out fullscreen monitor hints of all windows as963 /* clear out fullscreen monitor hints of all windows as
939 suggested on monitor layout changes in EWMH */964 suggested on monitor layout changes in EWMH */
940 for (iterator i = windows.begin(); i != windows.end(); ++i)965 for (iterator i = windows.begin (); i != windows.end (); ++i)
941 {966 {
942 CompWindow* const w(*i);967 CompWindow* const w (*i);
968
943 if (w->priv->fullscreenMonitorsSet)969 if (w->priv->fullscreenMonitorsSet)
944 w->priv->setFullscreenMonitors (NULL);970 w->priv->setFullscreenMonitors (NULL);
945 }971 }
946}972}
947973
948void974void
949cps::WindowManager::showOrHideForDesktop(unsigned int desktop) const975cps::WindowManager::showOrHideForDesktop (unsigned int desktop) const
950{976{
951 for (iterator i = windows.begin(); i != windows.end(); ++i)977 for (iterator i = windows.begin(); i != windows.end(); ++i)
952 {978 {
953 CompWindow* const w(*i);979 CompWindow* const w (*i);
980
954 if (w->desktop () == 0xffffffff)981 if (w->desktop () == 0xffffffff)
955 continue;982 continue;
956983
@@ -962,22 +989,24 @@
962}989}
963990
964void991void
965cps::WindowManager::setWindowActiveness(cps::History& history) const992cps::WindowManager::setWindowActiveness (cps::History &history) const
966{993{
967 for (iterator i = windows.begin(); i != windows.end(); ++i)994 for (iterator i = windows.begin (); i != windows.end (); ++i)
968 {995 {
969 CompWindow* const w(*i);996 CompWindow* const w(*i);
997
970 if (w->isViewable ())998 if (w->isViewable ())
971 w->priv->activeNum = history.nextActiveNum ();999 w->priv->activeNum = history.nextActiveNum ();
972 }1000 }
973}1001}
9741002
975void1003void
976cps::WindowManager::setNumberOfDesktops(unsigned int desktops) const1004cps::WindowManager::setNumberOfDesktops (unsigned int desktops) const
977{1005{
978 for (iterator i = windows.begin(); i != windows.end(); ++i)1006 for (iterator i = windows.begin (); i != windows.end (); ++i)
979 {1007 {
980 CompWindow* const w(*i);1008 CompWindow* const w(*i);
1009
981 if (w->desktop () == 0xffffffff)1010 if (w->desktop () == 0xffffffff)
982 continue;1011 continue;
9831012
@@ -987,9 +1016,9 @@
987}1016}
9881017
989void1018void
990cps::WindowManager::updateWindowSizes() const1019cps::WindowManager::updateWindowSizes () const
991{1020{
992 for (iterator i = windows.begin(); i != windows.end(); ++i)1021 for (iterator i = windows.begin (); i != windows.end (); ++i)
993 {1022 {
994 CompWindow* const w(*i);1023 CompWindow* const w(*i);
995 w->priv->updateSize ();1024 w->priv->updateSize ();
@@ -1003,7 +1032,7 @@
1003 CompOption::Value::Vector result;1032 CompOption::Value::Vector result;
10041033
1005 /* Must have core as first plugin */1034 /* Must have core as first plugin */
1006 result.push_back("core");1035 result.push_back ("core");
10071036
1008 /* Add initial plugins */1037 /* Add initial plugins */
1009 foreach(CompString & p, initialPlugins)1038 foreach(CompString & p, initialPlugins)
@@ -1018,21 +1047,21 @@
1018 }1047 }
10191048
1020 /* Add plugins not in the initial list */1049 /* Add plugins not in the initial list */
1021 foreach(CompOption::Value const& opt, extraPluginsRequested)1050 foreach (CompOption::Value const &opt, extraPluginsRequested)
1022 {1051 {
1023 if (opt.s() == "core")1052 if (opt.s () == "core")
1024 continue;1053 continue;
10251054
1026 if (blacklist.find (opt.s()) != blacklist.end ())1055 if (blacklist.find (opt.s ()) != blacklist.end ())
1027 continue;1056 continue;
10281057
1029 typedef std::list<CompString>::iterator iterator;1058 typedef std::list<CompString>::iterator iterator;
1030 bool skip = false;1059 bool skip = false;
10311060
1032 for (iterator it = initialPlugins.begin(); it != initialPlugins.end();1061 for (iterator it = initialPlugins.begin ();
1033 ++it)1062 it != initialPlugins.end (); ++it)
1034 {1063 {
1035 if ((*it) == opt.s())1064 if ((*it) == opt.s ())
1036 {1065 {
1037 skip = true;1066 skip = true;
1038 break;1067 break;
@@ -1040,70 +1069,70 @@
1040 }1069 }
10411070
1042 if (!skip)1071 if (!skip)
1043 {1072 result.push_back(opt.s ());
1044 result.push_back(opt.s());
1045 }
1046 }1073 }
1074
1047 return result;1075 return result;
1048}1076}
10491077
1050
1051void1078void
1052cps::PluginManager::updatePlugins (CompScreen* screen, CompOption::Value::Vector const& extraPluginsRequested)1079cps::PluginManager::updatePlugins (CompScreen *screen,
1080 CompOption::Value::Vector const &extraPluginsRequested)
1053{1081{
1054 dirtyPluginList = false;1082 dirtyPluginList = false;
10551083
1056 CompOption::Value::Vector const desiredPlugins(mergedPluginList(extraPluginsRequested));1084 CompOption::Value::Vector const desiredPlugins (mergedPluginList (extraPluginsRequested));
10571085
1058 unsigned int pluginIndex;1086 unsigned int pluginIndex;
1087
1059 for (pluginIndex = 1;1088 for (pluginIndex = 1;
1060 pluginIndex < plugin.list ().size () && pluginIndex < desiredPlugins.size ();1089 pluginIndex < plugin.list ().size () && pluginIndex < desiredPlugins.size ();
1061 pluginIndex++)1090 ++pluginIndex)
1062 {
1063 if (plugin.list ().at (pluginIndex).s () != desiredPlugins.at (pluginIndex).s ())1091 if (plugin.list ().at (pluginIndex).s () != desiredPlugins.at (pluginIndex).s ())
1064 break;1092 break;
1065 }
10661093
1067 unsigned int desireIndex = pluginIndex;1094 unsigned int desireIndex = pluginIndex;
10681095
1069 // We have pluginIndex pointing at first difference (or end).1096 // We have pluginIndex pointing at first difference (or end).
1070 // Now pop plugins off stack to this point, but keep track that they are loaded1097 // Now pop plugins off stack to this point, but keep track that they are loaded
1071 CompPlugin::List alreadyLoaded;1098 CompPlugin::List alreadyLoaded;
1072 if (const unsigned int nPop = plugin.list().size() - pluginIndex)1099
1100 if (const unsigned int nPop = plugin.list ().size () - pluginIndex)
1073 {1101 {
1074 for (pluginIndex = 0; pluginIndex < nPop; pluginIndex++)1102 for (pluginIndex = 0; pluginIndex < nPop; ++pluginIndex)
1075 {1103 {
1076 alreadyLoaded.push_back(CompPlugin::pop());1104 alreadyLoaded.push_back(CompPlugin::pop ());
1077 plugin.list().pop_back();1105 plugin.list ().pop_back ();
1078 }1106 }
1079 }1107 }
10801108
1109 CompPlugin *p;
1110 bool failedPush;
1111
1081 // Now work forward through requested plugins1112 // Now work forward through requested plugins
1082 for (; desireIndex < desiredPlugins.size(); desireIndex++)1113 for (; desireIndex < desiredPlugins.size (); ++desireIndex)
1083 {1114 {
1084 CompPlugin *p = NULL;1115 p = NULL;
1085 bool failedPush = false;1116 failedPush = false;
10861117
1087 // If already loaded, just try to push it...1118 // If already loaded, just try to push it...
1088 foreach(CompPlugin * pp, alreadyLoaded)1119 foreach (CompPlugin *pp, alreadyLoaded)
1089 {1120 {
1090 if (desiredPlugins[desireIndex].s() == pp->vTable->name())1121 if (desiredPlugins[desireIndex].s () == pp->vTable->name ())
1091 {1122 {
1092 if (CompPlugin::push (pp))1123 if (CompPlugin::push (pp))
1093 {1124 {
1094 p = pp;1125 p = pp;
1095 alreadyLoaded.erase(1126 alreadyLoaded.erase (std::find (alreadyLoaded.begin (),
1096 std::find(alreadyLoaded.begin(),1127 alreadyLoaded.end (), pp));
1097 alreadyLoaded.end(), pp));
1098 break;1128 break;
1099 }1129 }
1100 else1130 else
1101 {1131 {
1102 alreadyLoaded.erase(1132 alreadyLoaded.erase (std::find (alreadyLoaded.begin (),
1103 std::find(alreadyLoaded.begin(),1133 alreadyLoaded.end (), pp));
1104 alreadyLoaded.end(), pp));
1105 blacklist.insert (desiredPlugins[desireIndex].s ());1134 blacklist.insert (desiredPlugins[desireIndex].s ());
1106 CompPlugin::unload(pp);1135 CompPlugin::unload (pp);
1107 p = NULL;1136 p = NULL;
1108 failedPush = true;1137 failedPush = true;
1109 break;1138 break;
@@ -1114,25 +1143,23 @@
1114 // ...otherwise, try to load and push1143 // ...otherwise, try to load and push
1115 if (p == 0 && !failedPush)1144 if (p == 0 && !failedPush)
1116 {1145 {
1117 p = CompPlugin::load(desiredPlugins[desireIndex].s ().c_str ());1146 p = CompPlugin::load (desiredPlugins[desireIndex].s ().c_str ());
11181147
1119 if (p)1148 if (p)
1120 {1149 {
1121 if (!CompPlugin::push(p))1150 if (!CompPlugin::push (p))
1122 {1151 {
1123 blacklist.insert (desiredPlugins[desireIndex].s ());1152 blacklist.insert (desiredPlugins[desireIndex].s ());
1124 CompPlugin::unload(p);1153 CompPlugin::unload (p);
1125 p = 0;1154 p = 0;
1126 }1155 }
1127 }1156 }
1128 else1157 else
1129 {
1130 blacklist.insert (desiredPlugins[desireIndex].s ());1158 blacklist.insert (desiredPlugins[desireIndex].s ());
1131 }
1132 }1159 }
11331160
1134 if (p)1161 if (p)
1135 plugin.list().push_back(p->vTable->name());1162 plugin.list ().push_back(p->vTable->name ());
1136 }1163 }
11371164
1138 // Any plugins that are loaded, but were not re-initialized can be unloaded.1165 // Any plugins that are loaded, but were not re-initialized can be unloaded.
@@ -1151,8 +1178,7 @@
1151 Atom target,1178 Atom target,
1152 Atom property)1179 Atom property)
1153{1180{
11541181 static const unsigned short N_TARGETS = 4;
1155static const unsigned short N_TARGETS = 4;
11561182
1157 Atom conversionTargets[N_TARGETS];1183 Atom conversionTargets[N_TARGETS];
11581184
@@ -1192,7 +1218,7 @@
1192PrivateScreen::handleSelectionRequest (XEvent *event)1218PrivateScreen::handleSelectionRequest (XEvent *event)
1193{1219{
1194 if (wmSnSelectionWindow != event->xselectionrequest.owner ||1220 if (wmSnSelectionWindow != event->xselectionrequest.owner ||
1195 wmSnAtom != event->xselectionrequest.selection)1221 wmSnAtom != event->xselectionrequest.selection)
1196 return;1222 return;
11971223
1198 XSelectionEvent reply;1224 XSelectionEvent reply;
@@ -1209,8 +1235,8 @@
1209 {1235 {
1210 if (event->xselectionrequest.property != None)1236 if (event->xselectionrequest.property != None)
1211 {1237 {
1212 Atom type, *adata;1238 Atom type;
1213 int i, format;1239 int format;
1214 unsigned long num, rest;1240 unsigned long num, rest;
1215 unsigned char *data;1241 unsigned char *data;
12161242
@@ -1227,8 +1253,9 @@
1227 * but since we have 4 possible targets, we will hardly ever1253 * but since we have 4 possible targets, we will hardly ever
1228 * meet multiple requests with a length > 81254 * meet multiple requests with a length > 8
1229 */1255 */
1230 adata = (Atom *) data;1256 Atom *adata = (Atom *) data;
1231 i = 0;1257 int i = 0;
1258
1232 while (i < (int) num)1259 while (i < (int) num)
1233 {1260 {
1234 if (!convertProperty (dpy, wmSnTimestamp,1261 if (!convertProperty (dpy, wmSnTimestamp,
@@ -1276,23 +1303,23 @@
1276 eventManager.quit ();1303 eventManager.quit ();
1277}1304}
12781305
1279static const std::string IMAGEDIR("images");1306static const std::string IMAGEDIR = "images";
1280static const std::string HOMECOMPIZDIR(".compiz-1");1307static const std::string HOMECOMPIZDIR = ".compiz-1";
12811308
1282bool1309bool
1283CompScreenImpl::readImageFromFile (CompString &name,1310CompScreenImpl::readImageFromFile (CompString &name,
1284 CompString &pname,1311 CompString &pname,
1285 CompSize &size,1312 CompSize &size,
1286 void *&data)1313 void *&data)
1287{1314{
1288 bool status;
1289 int stride;1315 int stride;
1316 bool status = fileToImage (name, size, stride, data);
12901317
1291 status = fileToImage (name, size, stride, data);
1292 if (!status)1318 if (!status)
1293 {1319 {
1294 char *home = getenv ("HOME");1320 char *home = getenv ("HOME");
1295 CompString path;1321 CompString path;
1322
1296 if (home)1323 if (home)
1297 {1324 {
1298 path = home;1325 path = home;
@@ -1326,9 +1353,9 @@
13261353
1327bool1354bool
1328CompScreenImpl::writeImageToFile (CompString &path,1355CompScreenImpl::writeImageToFile (CompString &path,
1329 const char *format,1356 const char *format,
1330 CompSize &size,1357 CompSize &size,
1331 void *data)1358 void *data)
1332{1359{
1333 CompString formatString (format);1360 CompString formatString (format);
1334 return imageToFile (path, formatString, size, size.width () * 4, data);1361 return imageToFile (path, formatString, size, size.width () * 4, data);
@@ -1337,21 +1364,22 @@
1337Window1364Window
1338PrivateScreen::getActiveWindow (Window root)1365PrivateScreen::getActiveWindow (Window root)
1339{1366{
1340 Atom actual;1367 Atom actual;
1341 int result, format;1368 int format;
1342 unsigned long n, left;1369 unsigned long n, left;
1343 unsigned char *data;1370 unsigned char *data;
1344 Window w = None;1371 Window w = None;
13451372
1346 result = XGetWindowProperty (dpy, root,1373 int result = XGetWindowProperty (dpy, root,
1347 Atoms::winActive, 0L, 1L, false,1374 Atoms::winActive, 0L, 1L, false,
1348 XA_WINDOW, &actual, &format,1375 XA_WINDOW, &actual, &format,
1349 &n, &left, &data);1376 &n, &left, &data);
13501377
1351 if (result == Success && data)1378 if (result == Success && data)
1352 {1379 {
1353 if (n)1380 if (n)
1354 memcpy (&w, data, sizeof (Window));1381 memcpy (&w, data, sizeof (Window));
1382
1355 XFree (data);1383 XFree (data);
1356 }1384 }
13571385
@@ -1370,9 +1398,9 @@
13701398
1371bool1399bool
1372CompScreenImpl::_fileToImage (CompString &name,1400CompScreenImpl::_fileToImage (CompString &name,
1373 CompSize &size,1401 CompSize &size,
1374 int &stride,1402 int &stride,
1375 void *&data)1403 void *&data)
1376{1404{
1377 return false;1405 return false;
1378}1406}
@@ -1384,17 +1412,17 @@
1384 int stride,1412 int stride,
1385 void *data)1413 void *data)
1386{1414{
1387 WRAPABLE_HND_FUNCTN_RETURN (bool, imageToFile, path, format, size,1415 WRAPABLE_HND_FUNCTN_RETURN (bool, imageToFile, path, format,
1388 stride, data);1416 size, stride, data);
1389 return _imageToFile (path, format, size, stride, data);1417 return _imageToFile (path, format, size, stride, data);
1390}1418}
13911419
1392bool1420bool
1393CompScreenImpl::_imageToFile (CompString &path,1421CompScreenImpl::_imageToFile (CompString &path,
1394 CompString &format,1422 CompString &format,
1395 CompSize &size,1423 CompSize &size,
1396 int stride,1424 int stride,
1397 void *data)1425 void *data)
1398{1426{
1399 return false;1427 return false;
1400}1428}
@@ -1410,8 +1438,8 @@
14101438
1411void1439void
1412CompScreenImpl::_logMessage (const char *componentName,1440CompScreenImpl::_logMessage (const char *componentName,
1413 CompLogLevel level,1441 CompLogLevel level,
1414 const char *message)1442 const char *message)
1415{1443{
1416 ::logMessage (componentName, level, message);1444 ::logMessage (componentName, level, message);
1417}1445}
@@ -1419,21 +1447,22 @@
1419int1447int
1420cps::XWindowInfo::getWmState (Window id)1448cps::XWindowInfo::getWmState (Window id)
1421{1449{
1422 Atom actual;1450 Atom actual;
1423 int result, format;1451 int format;
1424 unsigned long n, left;1452 unsigned long n, left;
1425 unsigned char *data;1453 unsigned char *data;
1426 unsigned long state = NormalState;1454 unsigned long state = NormalState;
14271455
1428 result = XGetWindowProperty (dpy, id,1456 int result = XGetWindowProperty (dpy, id,
1429 Atoms::wmState, 0L, 2L, false,1457 Atoms::wmState, 0L, 2L, false,
1430 Atoms::wmState, &actual, &format,1458 Atoms::wmState, &actual, &format,
1431 &n, &left, &data);1459 &n, &left, &data);
14321460
1433 if (result == Success && data)1461 if (result == Success && data)
1434 {1462 {
1435 if (n)1463 if (n)
1436 memcpy (&state, data, sizeof (unsigned long));1464 memcpy (&state, data, sizeof (unsigned long));
1465
1437 XFree ((void *) data);1466 XFree ((void *) data);
1438 }1467 }
14391468
@@ -1441,7 +1470,8 @@
1441}1470}
14421471
1443void1472void
1444cps::XWindowInfo::setWmState (int state, Window id) const1473cps::XWindowInfo::setWmState (int state,
1474 Window id) const
1445{1475{
1446 unsigned long data[2];1476 unsigned long data[2];
14471477
@@ -1520,16 +1550,16 @@
1520unsigned int1550unsigned int
1521cps::XWindowInfo::getWindowState (Window id)1551cps::XWindowInfo::getWindowState (Window id)
1522{1552{
1523 Atom actual;1553 Atom actual;
1524 int result, format;1554 int format;
1525 unsigned long n, left;1555 unsigned long n, left;
1526 unsigned char *data;1556 unsigned char *data;
1527 unsigned int state = 0;1557 unsigned int state = 0;
15281558
1529 result = XGetWindowProperty (dpy, id,1559 int result = XGetWindowProperty (dpy, id,
1530 Atoms::winState,1560 Atoms::winState,
1531 0L, 1024L, false, XA_ATOM, &actual, &format,1561 0L, 1024L, false, XA_ATOM, &actual,
1532 &n, &left, &data);1562 &format, &n, &left, &data);
15331563
1534 if (result == Success && data)1564 if (result == Success && data)
1535 {1565 {
@@ -1545,9 +1575,10 @@
1545}1575}
15461576
1547unsigned int1577unsigned int
1548compiz::window::fillStateData (unsigned int state, Atom *data)1578compiz::window::fillStateData (unsigned int state,
1579 Atom *data)
1549{1580{
1550 int i = 0;1581 int i = 0;
15511582
1552 if (state & CompWindowStateModalMask)1583 if (state & CompWindowStateModalMask)
1553 data[i++] = Atoms::winStateModal;1584 data[i++] = Atoms::winStateModal;
@@ -1582,34 +1613,35 @@
1582}1613}
15831614
1584void1615void
1585PrivateScreen::setWindowState (unsigned int state, Window id)1616PrivateScreen::setWindowState (unsigned int state,
1617 Window id)
1586{1618{
1587 int i = 0;
1588 Atom data[32];1619 Atom data[32];
15891620
1590 i = compiz::window::fillStateData (state, data);1621 int i = compiz::window::fillStateData (state, data);
1591 XChangeProperty (dpy, id, Atoms::winState,1622 XChangeProperty (dpy, id, Atoms::winState,
1592 XA_ATOM, 32, PropModeReplace,1623 XA_ATOM, 32, PropModeReplace,
1593 (unsigned char *) data, i);1624 (unsigned char *) data, i);
1594}1625}
15951626
1596unsigned int1627unsigned int
1597cps::XWindowInfo::getWindowType (Window id)1628cps::XWindowInfo::getWindowType (Window id)
1598{1629{
1599 Atom actual, a = None;1630 Atom actual, a = None;
1600 int result, format;1631 int format;
1601 unsigned long n, left;1632 unsigned long n, left;
1602 unsigned char *data;1633 unsigned char *data;
16031634
1604 result = XGetWindowProperty (dpy , id,1635 int result = XGetWindowProperty (dpy , id,
1605 Atoms::winType,1636 Atoms::winType,
1606 0L, 1L, false, XA_ATOM, &actual, &format,1637 0L, 1L, false, XA_ATOM, &actual,
1607 &n, &left, &data);1638 &format, &n, &left, &data);
16081639
1609 if (result == Success && data)1640 if (result == Success && data)
1610 {1641 {
1611 if (n)1642 if (n)
1612 memcpy (&a, data, sizeof (Atom));1643 memcpy (&a, data, sizeof (Atom));
1644
1613 XFree ((void *) data);1645 XFree ((void *) data);
1614 }1646 }
16151647
@@ -1650,21 +1682,21 @@
16501682
1651void1683void
1652cps::XWindowInfo::getMwmHints (Window id,1684cps::XWindowInfo::getMwmHints (Window id,
1653 unsigned int *func,1685 unsigned int *func,
1654 unsigned int *decor) const1686 unsigned int *decor) const
1655{1687{
1656 Atom actual;1688 Atom actual;
1657 int result, format;1689 int format;
1658 unsigned long n, left;1690 unsigned long n, left;
1659 unsigned char *data;1691 unsigned char *data;
16601692
1661 *func = MwmFuncAll;1693 *func = MwmFuncAll;
1662 *decor = MwmDecorAll;1694 *decor = MwmDecorAll;
16631695
1664 result = XGetWindowProperty (dpy, id,1696 int result = XGetWindowProperty (dpy, id,
1665 Atoms::mwmHints,1697 Atoms::mwmHints,
1666 0L, 20L, false, Atoms::mwmHints,1698 0L, 20L, false, Atoms::mwmHints,
1667 &actual, &format, &n, &left, &data);1699 &actual, &format, &n, &left, &data);
16681700
1669 if (result == Success && data)1701 if (result == Success && data)
1670 {1702 {
@@ -1692,7 +1724,7 @@
16921724
1693 if (XGetWMProtocols (dpy, id, &protocol, &count))1725 if (XGetWMProtocols (dpy, id, &protocol, &count))
1694 {1726 {
1695 for (int i = 0; i < count; i++)1727 for (int i = 0; i < count; ++i)
1696 {1728 {
1697 if (protocol[i] == Atoms::wmDeleteWindow)1729 if (protocol[i] == Atoms::wmDeleteWindow)
1698 protocols |= CompWindowProtocolDeleteMask;1730 protocols |= CompWindowProtocolDeleteMask;
@@ -1712,18 +1744,18 @@
17121744
1713unsigned int1745unsigned int
1714CompScreenImpl::getWindowProp (Window id,1746CompScreenImpl::getWindowProp (Window id,
1715 Atom property,1747 Atom property,
1716 unsigned int defaultValue)1748 unsigned int defaultValue)
1717{1749{
1718 Atom actual;1750 Atom actual;
1719 int result, format;1751 int format;
1720 unsigned long n, left;1752 unsigned long n, left;
1721 unsigned char *data;1753 unsigned char *data;
1722 unsigned int retval = defaultValue;1754 unsigned int retval = defaultValue;
17231755
1724 result = XGetWindowProperty (privateScreen.dpy, id, property,1756 int result = XGetWindowProperty (privateScreen.dpy, id, property,
1725 0L, 1L, false, XA_CARDINAL, &actual, &format,1757 0L, 1L, false, XA_CARDINAL, &actual, &format,
1726 &n, &left, &data);1758 &n, &left, &data);
17271759
1728 if (result == Success && data)1760 if (result == Success && data)
1729 {1761 {
@@ -1742,8 +1774,8 @@
17421774
1743void1775void
1744CompScreenImpl::setWindowProp (Window id,1776CompScreenImpl::setWindowProp (Window id,
1745 Atom property,1777 Atom property,
1746 unsigned int value)1778 unsigned int value)
1747{1779{
1748 unsigned long data = value;1780 unsigned long data = value;
17491781
@@ -1757,15 +1789,15 @@
1757 Atom property,1789 Atom property,
1758 unsigned short *returnValue)1790 unsigned short *returnValue)
1759{1791{
1760 Atom actual;1792 Atom actual;
1761 int result, format;1793 int format;
1762 unsigned long n, left;1794 unsigned long n, left;
1763 unsigned char *data;1795 unsigned char *data;
1764 bool retval = false;1796 bool retval = false;
17651797
1766 result = XGetWindowProperty (dpy, id, property,1798 int result = XGetWindowProperty (dpy, id, property,
1767 0L, 1L, false, XA_CARDINAL, &actual, &format,1799 0L, 1L, false, XA_CARDINAL, &actual,
1768 &n, &left, &data);1800 &format, &n, &left, &data);
17691801
1770 if (result == Success && data)1802 if (result == Success && data)
1771 {1803 {
@@ -1786,8 +1818,8 @@
17861818
1787unsigned short1819unsigned short
1788CompScreenImpl::getWindowProp32 (Window id,1820CompScreenImpl::getWindowProp32 (Window id,
1789 Atom property,1821 Atom property,
1790 unsigned short defaultValue)1822 unsigned short defaultValue)
1791{1823{
1792 unsigned short result;1824 unsigned short result;
17931825
@@ -1799,12 +1831,10 @@
17991831
1800void1832void
1801CompScreenImpl::setWindowProp32 (Window id,1833CompScreenImpl::setWindowProp32 (Window id,
1802 Atom property,1834 Atom property,
1803 unsigned short value)1835 unsigned short value)
1804{1836{
1805 CARD32 value32;1837 CARD32 value32 = value << 16 | value;
1806
1807 value32 = value << 16 | value;
18081838
1809 XChangeProperty (privateScreen.dpy, id, property,1839 XChangeProperty (privateScreen.dpy, id, property,
1810 XA_CARDINAL, 32, PropModeReplace,1840 XA_CARDINAL, 32, PropModeReplace,
@@ -1875,40 +1905,39 @@
1875void1905void
1876PrivateScreen::setDesktopHints ()1906PrivateScreen::setDesktopHints ()
1877{1907{
1878 unsigned long *data;1908 int dSize = nDesktop * 8 + 1;
18791909
1880 int dSize = nDesktop * 2 + nDesktop * 2 + nDesktop * 4 + 1;1910 unsigned long *data = (unsigned long *) malloc (sizeof (unsigned long) * dSize);
18811911
1882 data = (unsigned long *) malloc (sizeof (unsigned long) * dSize);
1883 if (!data)1912 if (!data)
1884 return;1913 return;
18851914
1886 unsigned int i;1915 unsigned int i;
1887 int offset = 0;1916 int offset = 0;
1888 int hintSize = nDesktop * 2;1917 int hintSize = nDesktop * 2;
18891918
1890 for (i = 0; i < nDesktop; i++)1919 for (i = 0; i < nDesktop; ++i)
1891 {1920 {
1892 data[offset + i * 2 + 0] = viewPort.vp.x () * screen->width ();1921 data[offset + i * 2 + 0] = viewPort.vp.x () * screen->width ();
1893 data[offset + i * 2 + 1] = viewPort.vp.y () * screen->height ();1922 data[offset + i * 2 + 1] = viewPort.vp.y () * screen->height ();
1894 }1923 }
18951924
1896 if (!desktopHintEqual (data, dSize, offset, hintSize))1925 if (!desktopHintEqual (data, dSize, offset, hintSize))
1897 XChangeProperty (dpy, rootWindow(),1926 XChangeProperty (dpy, rootWindow (),
1898 Atoms::desktopViewport,1927 Atoms::desktopViewport,
1899 XA_CARDINAL, 32, PropModeReplace,1928 XA_CARDINAL, 32, PropModeReplace,
1900 (unsigned char *) &data[offset], hintSize);1929 (unsigned char *) &data[offset], hintSize);
19011930
1902 offset += hintSize;1931 offset += hintSize;
19031932
1904 for (i = 0; i < nDesktop; i++)1933 for (i = 0; i < nDesktop; ++i)
1905 {1934 {
1906 data[offset + i * 2 + 0] = screen->width () * viewPort.vpSize.width ();1935 data[offset + i * 2 + 0] = screen->width () * viewPort.vpSize.width ();
1907 data[offset + i * 2 + 1] = screen->height () * viewPort.vpSize.height ();1936 data[offset + i * 2 + 1] = screen->height () * viewPort.vpSize.height ();
1908 }1937 }
19091938
1910 if (!desktopHintEqual (data, dSize, offset, hintSize))1939 if (!desktopHintEqual (data, dSize, offset, hintSize))
1911 XChangeProperty (dpy, rootWindow(),1940 XChangeProperty (dpy, rootWindow (),
1912 Atoms::desktopGeometry,1941 Atoms::desktopGeometry,
1913 XA_CARDINAL, 32, PropModeReplace,1942 XA_CARDINAL, 32, PropModeReplace,
1914 (unsigned char *) &data[offset], hintSize);1943 (unsigned char *) &data[offset], hintSize);
@@ -1916,7 +1945,7 @@
1916 offset += hintSize;1945 offset += hintSize;
1917 hintSize = nDesktop * 4;1946 hintSize = nDesktop * 4;
19181947
1919 for (i = 0; i < nDesktop; i++)1948 for (i = 0; i < nDesktop; ++i)
1920 {1949 {
1921 data[offset + i * 4 + 0] = workArea.x ();1950 data[offset + i * 4 + 0] = workArea.x ();
1922 data[offset + i * 4 + 1] = workArea.y ();1951 data[offset + i * 4 + 1] = workArea.y ();
@@ -1925,7 +1954,7 @@
1925 }1954 }
19261955
1927 if (!desktopHintEqual (data, dSize, offset, hintSize))1956 if (!desktopHintEqual (data, dSize, offset, hintSize))
1928 XChangeProperty (dpy, rootWindow(),1957 XChangeProperty (dpy, rootWindow (),
1929 Atoms::workarea,1958 Atoms::workarea,
1930 XA_CARDINAL, 32, PropModeReplace,1959 XA_CARDINAL, 32, PropModeReplace,
1931 (unsigned char *) &data[offset], hintSize);1960 (unsigned char *) &data[offset], hintSize);
@@ -1936,7 +1965,7 @@
1936 hintSize = 1;1965 hintSize = 1;
19371966
1938 if (!desktopHintEqual (data, dSize, offset, hintSize))1967 if (!desktopHintEqual (data, dSize, offset, hintSize))
1939 XChangeProperty (dpy, rootWindow(),1968 XChangeProperty (dpy, rootWindow (),
1940 Atoms::numberOfDesktops,1969 Atoms::numberOfDesktops,
1941 XA_CARDINAL, 32, PropModeReplace,1970 XA_CARDINAL, 32, PropModeReplace,
1942 (unsigned char *) &data[offset], hintSize);1971 (unsigned char *) &data[offset], hintSize);
@@ -1949,14 +1978,15 @@
1949}1978}
19501979
1951void1980void
1952PrivateScreen::setVirtualScreenSize (int newh, int newv)1981PrivateScreen::setVirtualScreenSize (int newh,
1982 int newv)
1953{1983{
1954 /* if newh or newv is being reduced */1984 /* if newh or newv is being reduced */
1955 if (newh < screen->vpSize ().width () ||1985 if (newh < screen->vpSize ().width () ||
1956 newv < screen->vpSize ().height ())1986 newv < screen->vpSize ().height ())
1957 {1987 {
1958 int tx = 0;1988 int tx = 0;
1959 int ty = 0;1989 int ty = 0;
19601990
1961 if (screen->vp ().x () >= newh)1991 if (screen->vp ().x () >= newh)
1962 tx = screen->vp ().x () - (newh - 1);1992 tx = screen->vp ().x () - (newh - 1);
@@ -1966,12 +1996,16 @@
1966 if (tx != 0 || ty != 0)1996 if (tx != 0 || ty != 0)
1967 screen->moveViewport (tx, ty, TRUE);1997 screen->moveViewport (tx, ty, TRUE);
19681998
1999 int moveX, moveY;
2000 int vpX; /* x index of a window's vp */
2001 int vpY; /* y index of a window's vp */
2002
1969 /* Move windows that were in one of the deleted viewports into the2003 /* Move windows that were in one of the deleted viewports into the
1970 closest viewport */2004 closest viewport */
1971 foreach (CompWindow *w, screen->windows ())2005 foreach (CompWindow *w, screen->windows ())
1972 {2006 {
1973 int moveX = 0;2007 moveX = 0;
1974 int moveY = 0;2008 moveY = 0;
19752009
1976 if (w->onAllViewports ())2010 if (w->onAllViewports ())
1977 continue;2011 continue;
@@ -1981,9 +2015,8 @@
1981 vertical index range */2015 vertical index range */
1982 if (newh < screen->vpSize ().width ())2016 if (newh < screen->vpSize ().width ())
1983 {2017 {
1984 int vpX; /* x index of a window's vp */
1985
1986 vpX = w->serverX () / screen->width ();2018 vpX = w->serverX () / screen->width ();
2019
1987 if (w->serverX () < 0)2020 if (w->serverX () < 0)
1988 vpX -= 1;2021 vpX -= 1;
19892022
@@ -1993,11 +2026,11 @@
1993 if (vpX >= newh)2026 if (vpX >= newh)
1994 moveX = ((newh - 1) - vpX) * screen->width ();2027 moveX = ((newh - 1) - vpX) * screen->width ();
1995 }2028 }
2029
1996 if (newv < screen->vpSize ().height ())2030 if (newv < screen->vpSize ().height ())
1997 {2031 {
1998 int vpY; /* y index of a window's vp */
1999
2000 vpY = w->serverY () / screen->height ();2032 vpY = w->serverY () / screen->height ();
2033
2001 if (w->serverY () < 0)2034 if (w->serverY () < 0)
2002 vpY -= 1;2035 vpY -= 1;
20032036
@@ -2032,7 +2065,7 @@
2032{2065{
2033 outputDevices.updateOutputDevices(coreOptions, screen);2066 outputDevices.updateOutputDevices(coreOptions, screen);
20342067
2035 windowManager.clearFullscreenHints();2068 windowManager.clearFullscreenHints ();
20362069
2037 screen->updateWorkarea ();2070 screen->updateWorkarea ();
20382071
@@ -2040,7 +2073,7 @@
2040}2073}
20412074
2042void2075void
2043PrivateScreen::detectOutputDevices (CoreOptions& coreOptions)2076PrivateScreen::detectOutputDevices (CoreOptions &coreOptions)
2044{2077{
2045 if (coreOptions.optionGetDetectOutputs ())2078 if (coreOptions.optionGetDetectOutputs ())
2046 {2079 {
@@ -2050,11 +2083,10 @@
2050 if (!screenInfo.empty ())2083 if (!screenInfo.empty ())
2051 {2084 {
2052 CompOption::Value::Vector l;2085 CompOption::Value::Vector l;
2086
2053 foreach (XineramaScreenInfo xi, screenInfo)2087 foreach (XineramaScreenInfo xi, screenInfo)
2054 {
2055 l.push_back (compPrintf ("%dx%d+%d+%d", xi.width, xi.height,2088 l.push_back (compPrintf ("%dx%d+%d+%d", xi.width, xi.height,
2056 xi.x_org, xi.y_org));2089 xi.x_org, xi.y_org));
2057 }
20582090
2059 value.set (CompOption::TypeString, l);2091 value.set (CompOption::TypeString, l);
2060 }2092 }
@@ -2071,12 +2103,9 @@
2071 coreOptions.getOptions()[CoreOptions::DetectOutputs].value ().set (true);2103 coreOptions.getOptions()[CoreOptions::DetectOutputs].value ().set (true);
2072 }2104 }
2073 else2105 else
2074 {
2075 updateOutputDevices (coreOptions);2106 updateOutputDevices (coreOptions);
2076 }
2077}2107}
20782108
2079
2080void2109void
2081cps::StartupSequenceImpl::updateStartupFeedback ()2110cps::StartupSequenceImpl::updateStartupFeedback ()
2082{2111{
@@ -2089,13 +2118,14 @@
2089 }2118 }
2090}2119}
20912120
2121/* TODO: Investigate this magic number timeout, can it be reduced ? */
2092static const unsigned int STARTUP_TIMEOUT_DELAY = 15000;2122static const unsigned int STARTUP_TIMEOUT_DELAY = 15000;
20932123
2094bool2124bool
2095cps::StartupSequence::handleStartupSequenceTimeout ()2125cps::StartupSequence::handleStartupSequenceTimeout ()
2096{2126{
2097 struct timeval now, active;2127 struct timeval now, active;
2098 double elapsed;2128 double elapsed;
20992129
2100 gettimeofday (&now, NULL);2130 gettimeofday (&now, NULL);
21012131
@@ -2116,11 +2146,11 @@
2116}2146}
21172147
2118void2148void
2119cps::StartupSequence::addSequence (SnStartupSequence *sequence, CompPoint const& vp)2149cps::StartupSequence::addSequence (SnStartupSequence *sequence,
2150 CompPoint const &vp)
2120{2151{
2121 CompStartupSequence *s;2152 CompStartupSequence *s = new CompStartupSequence ();
21222153
2123 s = new CompStartupSequence ();
2124 if (!s)2154 if (!s)
2125 return;2155 return;
21262156
@@ -2188,35 +2218,41 @@
21882218
2189void2219void
2190PrivateScreen::compScreenSnEvent (SnMonitorEvent *event,2220PrivateScreen::compScreenSnEvent (SnMonitorEvent *event,
2191 void *userData)2221 void *userData)
2192{2222{
2193 PrivateScreen *self = (PrivateScreen *) userData;2223 PrivateScreen *self = (PrivateScreen *) userData;
2194 SnStartupSequence *sequence;2224 SnStartupSequence *sequence = sn_monitor_event_get_startup_sequence (event);
21952225
2196 sequence = sn_monitor_event_get_startup_sequence (event);2226 switch (sn_monitor_event_get_type (event))
21972227 {
2198 switch (sn_monitor_event_get_type (event)) {2228 case SN_MONITOR_EVENT_INITIATED:
2199 case SN_MONITOR_EVENT_INITIATED:2229 self->startupSequence.addSequence (sequence, self->viewPort.vp);
2200 self->startupSequence.addSequence (sequence, self->viewPort.vp);2230 break;
2201 break;2231
2202 case SN_MONITOR_EVENT_COMPLETED:2232 case SN_MONITOR_EVENT_COMPLETED:
2203 self->startupSequence.removeSequence (sequence);2233 self->startupSequence.removeSequence (sequence);
2204 break;2234 break;
2205 case SN_MONITOR_EVENT_CHANGED:2235
2206 case SN_MONITOR_EVENT_CANCELED:2236 case SN_MONITOR_EVENT_CHANGED:
2207 break;2237 case SN_MONITOR_EVENT_CANCELED:
2238 break;
2239
2240 default:
2241 break;
2208 }2242 }
2209}2243}
22102244
2211void2245void
2212PrivateScreen::updateScreenEdges ()2246PrivateScreen::updateScreenEdges ()
2213{2247{
2214 struct screenEdgeGeometry {2248 struct screenEdgeGeometry
2249 {
2215 int xw, x0;2250 int xw, x0;
2216 int yh, y0;2251 int yh, y0;
2217 int ww, w0;2252 int ww, w0;
2218 int hh, h0;2253 int hh, h0;
2219 } geometry[SCREEN_EDGE_NUM] = {2254 } geometry[SCREEN_EDGE_NUM] =
2255 {
2220 { 0, -1, 0, 2, 0, 2, 1, -4 }, /* left */2256 { 0, -1, 0, 2, 0, 2, 1, -4 }, /* left */
2221 { 1, -1, 0, 2, 0, 2, 1, -4 }, /* right */2257 { 1, -1, 0, 2, 0, 2, 1, -4 }, /* right */
2222 { 0, 2, 0, -1, 1, -4, 0, 2 }, /* top */2258 { 0, 2, 0, -1, 1, -4, 0, 2 }, /* top */
@@ -2227,8 +2263,7 @@
2227 { 1, -1, 1, -1, 0, 2, 0, 2 } /* bottom-right */2263 { 1, -1, 1, -1, 0, 2, 0, 2 } /* bottom-right */
2228 };2264 };
22292265
2230 for (int i = 0; i < SCREEN_EDGE_NUM; i++)2266 for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
2231 {
2232 if (screenEdge[i].id)2267 if (screenEdge[i].id)
2233 XMoveResizeWindow (dpy, screenEdge[i].id,2268 XMoveResizeWindow (dpy, screenEdge[i].id,
2234 geometry[i].xw * screen->width () +2269 geometry[i].xw * screen->width () +
@@ -2239,11 +2274,11 @@
2239 geometry[i].w0,2274 geometry[i].w0,
2240 geometry[i].hh * screen->height () +2275 geometry[i].hh * screen->height () +
2241 geometry[i].h0);2276 geometry[i].h0);
2242 }
2243}2277}
22442278
2245void2279void
2246PrivateScreen::reshape (int w, int h)2280PrivateScreen::reshape (int w,
2281 int h)
2247{2282{
2248 updateScreenInfo ();2283 updateScreenInfo ();
22492284
@@ -2271,12 +2306,12 @@
2271 reshape (ce->width, ce->height);2306 reshape (ce->width, ce->height);
22722307
2273 detectOutputDevices (*this);2308 detectOutputDevices (*this);
2274
2275 updateOutputDevices (*this);2309 updateOutputDevices (*this);
2276}2310}
22772311
2278void2312void
2279cps::EventManager::setSupportingWmCheck (Display* dpy, Window root)2313cps::EventManager::setSupportingWmCheck (Display* dpy,
2314 Window root)
2280{2315{
2281 XChangeProperty (dpy, grabWindow,2316 XChangeProperty (dpy, grabWindow,
2282 Atoms::supportingWmCheck,2317 Atoms::supportingWmCheck,
@@ -2286,13 +2321,15 @@
2286 XChangeProperty (dpy, grabWindow, Atoms::wmName,2321 XChangeProperty (dpy, grabWindow, Atoms::wmName,
2287 Atoms::utf8String, 8, PropModeReplace,2322 Atoms::utf8String, 8, PropModeReplace,
2288 (unsigned char *) PACKAGE, strlen (PACKAGE));2323 (unsigned char *) PACKAGE, strlen (PACKAGE));
2324
2289 XChangeProperty (dpy, grabWindow, Atoms::winState,2325 XChangeProperty (dpy, grabWindow, Atoms::winState,
2290 XA_ATOM, 32, PropModeReplace,2326 XA_ATOM, 32, PropModeReplace,
2291 (unsigned char *) &Atoms::winStateSkipTaskbar,2327 (unsigned char *) &Atoms::winStateSkipTaskbar, 1);
2292 1);2328
2293 XChangeProperty (dpy, grabWindow, Atoms::winState,2329 XChangeProperty (dpy, grabWindow, Atoms::winState,
2294 XA_ATOM, 32, PropModeAppend,2330 XA_ATOM, 32, PropModeAppend,
2295 (unsigned char *) &Atoms::winStateSkipPager, 1);2331 (unsigned char *) &Atoms::winStateSkipPager, 1);
2332
2296 XChangeProperty (dpy, grabWindow, Atoms::winState,2333 XChangeProperty (dpy, grabWindow, Atoms::winState,
2297 XA_ATOM, 32, PropModeAppend,2334 XA_ATOM, 32, PropModeAppend,
2298 (unsigned char *) &Atoms::winStateHidden, 1);2335 (unsigned char *) &Atoms::winStateHidden, 1);
@@ -2354,6 +2391,7 @@
2354 atoms.push_back (Atoms::workarea);2391 atoms.push_back (Atoms::workarea);
23552392
2356 atoms.push_back (Atoms::wmName);2393 atoms.push_back (Atoms::wmName);
2394 // TODO: Why is this below commented out ?
2357/*2395/*
2358 atoms.push_back (Atoms::wmVisibleName);2396 atoms.push_back (Atoms::wmVisibleName);
2359*/2397*/
@@ -2361,6 +2399,7 @@
2361 atoms.push_back (Atoms::wmStrut);2399 atoms.push_back (Atoms::wmStrut);
2362 atoms.push_back (Atoms::wmStrutPartial);2400 atoms.push_back (Atoms::wmStrutPartial);
23632401
2402 // TODO: Why is this below commented out ?
2364/*2403/*
2365 atoms.push_back (Atoms::wmPid);2404 atoms.push_back (Atoms::wmPid);
2366*/2405*/
@@ -2387,7 +2426,7 @@
2387 atoms.push_back (Atoms::winOpacity);2426 atoms.push_back (Atoms::winOpacity);
2388 atoms.push_back (Atoms::winBrightness);2427 atoms.push_back (Atoms::winBrightness);
23892428
2390/* FIXME */2429/* TODO: FIXME */
2391#if 02430#if 0
2392 if (canDoSaturated)2431 if (canDoSaturated)
2393 {2432 {
@@ -2435,14 +2474,14 @@
2435PrivateScreen::getDesktopHints (unsigned int showingDesktopMask)2474PrivateScreen::getDesktopHints (unsigned int showingDesktopMask)
2436{2475{
2437 unsigned long data[2];2476 unsigned long data[2];
2438 Atom actual;2477 Atom actual;
2439 int result, format;2478 int result, format;
2440 unsigned long n, left;2479 unsigned long n, left;
2441 unsigned char *propData;2480 unsigned char *propData;
24422481
2443 if (useDesktopHints)2482 if (useDesktopHints)
2444 {2483 {
2445 result = XGetWindowProperty (dpy, rootWindow(),2484 result = XGetWindowProperty (dpy, rootWindow (),
2446 Atoms::numberOfDesktops,2485 Atoms::numberOfDesktops,
2447 0L, 1L, false, XA_CARDINAL, &actual,2486 0L, 1L, false, XA_CARDINAL, &actual,
2448 &format, &n, &left, &propData);2487 &format, &n, &left, &propData);
@@ -2452,6 +2491,7 @@
2452 if (n)2491 if (n)
2453 {2492 {
2454 memcpy (data, propData, sizeof (unsigned long));2493 memcpy (data, propData, sizeof (unsigned long));
2494
2455 if (data[0] > 0 && data[0] < 0xffffffff)2495 if (data[0] > 0 && data[0] < 0xffffffff)
2456 nDesktop = data[0];2496 nDesktop = data[0];
2457 }2497 }
@@ -2459,7 +2499,7 @@
2459 XFree (propData);2499 XFree (propData);
2460 }2500 }
24612501
2462 result = XGetWindowProperty (dpy, rootWindow(),2502 result = XGetWindowProperty (dpy, rootWindow (),
2463 Atoms::desktopViewport, 0L, 2L,2503 Atoms::desktopViewport, 0L, 2L,
2464 false, XA_CARDINAL, &actual, &format,2504 false, XA_CARDINAL, &actual, &format,
2465 &n, &left, &propData);2505 &n, &left, &propData);
@@ -2482,7 +2522,7 @@
2482 XFree (propData);2522 XFree (propData);
2483 }2523 }
24842524
2485 result = XGetWindowProperty (dpy, rootWindow(),2525 result = XGetWindowProperty (dpy, rootWindow (),
2486 Atoms::currentDesktop,2526 Atoms::currentDesktop,
2487 0L, 1L, false, XA_CARDINAL, &actual,2527 0L, 1L, false, XA_CARDINAL, &actual,
2488 &format, &n, &left, &propData);2528 &format, &n, &left, &propData);
@@ -2492,6 +2532,7 @@
2492 if (n)2532 if (n)
2493 {2533 {
2494 memcpy (data, propData, sizeof (unsigned long));2534 memcpy (data, propData, sizeof (unsigned long));
2535
2495 if (data[0] < nDesktop)2536 if (data[0] < nDesktop)
2496 currentDesktop = data[0];2537 currentDesktop = data[0];
2497 }2538 }
@@ -2500,7 +2541,7 @@
2500 }2541 }
2501 }2542 }
25022543
2503 result = XGetWindowProperty (dpy, rootWindow(),2544 result = XGetWindowProperty (dpy, rootWindow (),
2504 Atoms::showingDesktop,2545 Atoms::showingDesktop,
2505 0L, 1L, false, XA_CARDINAL, &actual, &format,2546 0L, 1L, false, XA_CARDINAL, &actual, &format,
2506 &n, &left, &propData);2547 &n, &left, &propData);
@@ -2510,6 +2551,7 @@
2510 if (n)2551 if (n)
2511 {2552 {
2512 memcpy (data, propData, sizeof (unsigned long));2553 memcpy (data, propData, sizeof (unsigned long));
2554
2513 if (data[0])2555 if (data[0])
2514 screen->enterShowDesktopMode ();2556 screen->enterShowDesktopMode ();
2515 }2557 }
@@ -2519,13 +2561,13 @@
25192561
2520 data[0] = currentDesktop;2562 data[0] = currentDesktop;
25212563
2522 XChangeProperty (dpy, rootWindow(), Atoms::currentDesktop,2564 XChangeProperty (dpy, rootWindow (), Atoms::currentDesktop,
2523 XA_CARDINAL, 32, PropModeReplace,2565 XA_CARDINAL, 32, PropModeReplace,
2524 (unsigned char *) data, 1);2566 (unsigned char *) data, 1);
25252567
2526 data[0] = showingDesktopMask ? true : false;2568 data[0] = showingDesktopMask ? true : false;
25272569
2528 XChangeProperty (dpy, rootWindow(), Atoms::showingDesktop,2570 XChangeProperty (dpy, rootWindow (), Atoms::showingDesktop,
2529 XA_CARDINAL, 32, PropModeReplace,2571 XA_CARDINAL, 32, PropModeReplace,
2530 (unsigned char *) data, 1);2572 (unsigned char *) data, 1);
2531}2573}
@@ -2537,29 +2579,31 @@
2537 _enterShowDesktopMode ();2579 _enterShowDesktopMode ();
2538}2580}
25392581
2540unsigned int CompScreenImpl::showingDesktopMask() const2582unsigned int CompScreenImpl::showingDesktopMask () const
2541{2583{
2542 return showingDesktopMask_;2584 return showingDesktopMask_;
2543}2585}
25442586
2545bool CompScreenImpl::grabsEmpty() const2587bool CompScreenImpl::grabsEmpty () const
2546{2588{
2547 return privateScreen.eventManager.grabsEmpty();2589 return privateScreen.eventManager.grabsEmpty ();
2548}2590}
25492591
2550void2592void
2551CompScreenImpl::_enterShowDesktopMode ()2593CompScreenImpl::_enterShowDesktopMode ()
2552{2594{
2553 unsigned long data = 1;2595 unsigned long data = 1;
2554 int count = 0;2596 int count = 0;
2555 bool st = privateScreen.optionGetHideSkipTaskbarWindows ();2597 bool st = privateScreen.optionGetHideSkipTaskbarWindows ();
25562598
2557 showingDesktopMask_ = ~(CompWindowTypeDesktopMask |2599 showingDesktopMask_ = ~(CompWindowTypeDesktopMask |
2558 CompWindowTypeDockMask);2600 CompWindowTypeDockMask);
25592601
2560 for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)2602 for (cps::WindowManager::iterator i = windowManager.begin ();
2603 i != windowManager.end (); ++i)
2561 {2604 {
2562 CompWindow* const w(*i);2605 CompWindow* const w(*i);
2606
2563 if ((showingDesktopMask_ & w->wmType ()) &&2607 if ((showingDesktopMask_ & w->wmType ()) &&
2564 (!(w->state () & CompWindowStateSkipTaskbarMask) || st))2608 (!(w->state () & CompWindowStateSkipTaskbarMask) || st))
2565 {2609 {
@@ -2573,7 +2617,7 @@
2573 }2617 }
25742618
2575 if (w->inShowDesktopMode ())2619 if (w->inShowDesktopMode ())
2576 count++;2620 ++count;
2577 }2621 }
25782622
2579 if (!count)2623 if (!count)
@@ -2610,9 +2654,10 @@
2610 window->priv->show ();2654 window->priv->show ();
26112655
2612 /* return if some other window is still in show desktop mode */2656 /* return if some other window is still in show desktop mode */
2613 for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)2657 for (cps::WindowManager::iterator i = windowManager.begin (); i != windowManager.end (); ++i)
2614 {2658 {
2615 CompWindow* const w(*i);2659 CompWindow* const w(*i);
2660
2616 if (w->inShowDesktopMode ())2661 if (w->inShowDesktopMode ())
2617 return;2662 return;
2618 }2663 }
@@ -2622,9 +2667,10 @@
2622 {2667 {
2623 showingDesktopMask_ = 0;2668 showingDesktopMask_ = 0;
26242669
2625 for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)2670 for (cps::WindowManager::iterator i = windowManager.begin (); i != windowManager.end (); ++i)
2626 {2671 {
2627 CompWindow* const w(*i);2672 CompWindow* const w(*i);
2673
2628 if (!w->inShowDesktopMode ())2674 if (!w->inShowDesktopMode ())
2629 continue;2675 continue;
26302676
@@ -2638,7 +2684,7 @@
2638 focusDefaultWindow ();2684 focusDefaultWindow ();
2639 }2685 }
26402686
2641 XChangeProperty (privateScreen.dpy, privateScreen.rootWindow(),2687 XChangeProperty (privateScreen.dpy, privateScreen.rootWindow (),
2642 Atoms::showingDesktop,2688 Atoms::showingDesktop,
2643 XA_CARDINAL, 32, PropModeReplace,2689 XA_CARDINAL, 32, PropModeReplace,
2644 (unsigned char *) &data, 1);2690 (unsigned char *) &data, 1);
@@ -2676,11 +2722,11 @@
2676 /* huh, we didn't find d->below ... perhaps it's out of date;2722 /* huh, we didn't find d->below ... perhaps it's out of date;
2677 try grabbing it through the server */2723 try grabbing it through the server */
26782724
2679 status = XQueryPointer (dpy (), privateScreen.rootWindow(), &rootReturn,2725 status = XQueryPointer (dpy (), privateScreen.rootWindow (), &rootReturn,
2680 &childReturn, &dummyInt, &dummyInt,2726 &childReturn, &dummyInt, &dummyInt,
2681 &dummyInt, &dummyInt, &dummyUInt);2727 &dummyInt, &dummyInt, &dummyUInt);
26822728
2683 if (status && rootReturn == privateScreen.rootWindow())2729 if (status && rootReturn == privateScreen.rootWindow ())
2684 {2730 {
2685 w = findTopLevelWindow (childReturn);2731 w = findTopLevelWindow (childReturn);
26862732
@@ -2697,8 +2743,8 @@
2697 if (!focus)2743 if (!focus)
2698 {2744 {
2699 /* Traverse down the stack */2745 /* Traverse down the stack */
2700 for (cps::WindowManager::reverse_iterator rit = windowManager.rbegin();2746 for (cps::WindowManager::reverse_iterator rit = windowManager.rbegin ();
2701 rit != windowManager.rend(); ++rit)2747 rit != windowManager.rend (); ++rit)
2702 {2748 {
2703 w = (*rit);2749 w = (*rit);
27042750
@@ -2745,8 +2791,8 @@
2745 }2791 }
2746 else2792 else
2747 {2793 {
2748 XSetInputFocus (privateScreen.dpy, privateScreen.rootWindow(), RevertToPointerRoot,2794 XSetInputFocus (privateScreen.dpy, privateScreen.rootWindow (),
2749 CurrentTime);2795 RevertToPointerRoot, CurrentTime);
2750 }2796 }
2751}2797}
27522798
@@ -2760,26 +2806,23 @@
2760cps::WindowManager::findWindow (Window id) const2806cps::WindowManager::findWindow (Window id) const
2761{2807{
2762 if (lastFoundWindow && lastFoundWindow->id () == id)2808 if (lastFoundWindow && lastFoundWindow->id () == id)
2763 {
2764 return lastFoundWindow;2809 return lastFoundWindow;
2765 }
2766 else2810 else
2767 {2811 {
2768 CompWindow::Map::const_iterator it = windowsMap.find (id);2812 CompWindow::Map::const_iterator it = windowsMap.find (id);
27692813
2770 if (it != windowsMap.end ())2814 if (it != windowsMap.end ())
2771 return (lastFoundWindow = it->second);2815 return (lastFoundWindow = it->second);
2772 }2816 }
27732817
2774 return 0;2818 return 0;
2775}2819}
27762820
2777CompWindow *2821CompWindow *
2778CompScreenImpl::findTopLevelWindow (Window id, bool override_redirect)2822CompScreenImpl::findTopLevelWindow (Window id,
2823 bool override_redirect)
2779{2824{
2780 CompWindow *w;2825 CompWindow *w = findWindow (id);
2781
2782 w = findWindow (id);
27832826
2784 if (w)2827 if (w)
2785 {2828 {
@@ -2792,6 +2835,7 @@
2792 for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)2835 for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)
2793 {2836 {
2794 CompWindow* const w(*i);2837 CompWindow* const w(*i);
2838
2795 if (w->priv->serverFrame == id)2839 if (w->priv->serverFrame == id)
2796 {2840 {
2797 if (w->overrideRedirect () && !override_redirect)2841 if (w->overrideRedirect () && !override_redirect)
@@ -2805,7 +2849,8 @@
2805}2849}
28062850
2807void2851void
2808CompScreenImpl::insertWindow (CompWindow *w, Window aboveId)2852CompScreenImpl::insertWindow (CompWindow *w,
2853 Window aboveId)
2809{2854{
2810 windowManager.insertWindow (w, aboveId);2855 windowManager.insertWindow (w, aboveId);
2811}2856}
@@ -2817,7 +2862,7 @@
2817 if (dbg)2862 if (dbg)
2818 dbg->windowsChanged (true);2863 dbg->windowsChanged (true);
28192864
2820 invalidateServerWindows();2865 invalidateServerWindows ();
28212866
2822 w->prev = NULL;2867 w->prev = NULL;
2823 w->next = NULL;2868 w->next = NULL;
@@ -2829,9 +2874,9 @@
2829 windows.front ()->prev = w;2874 windows.front ()->prev = w;
2830 w->next = windows.front ();2875 w->next = windows.front ();
2831 }2876 }
2877
2832 windows.push_front (w);2878 windows.push_front (w);
28332879 addWindowToMap (w);
2834 addWindowToMap(w);
28352880
2836 return;2881 return;
2837 }2882 }
@@ -2842,9 +2887,8 @@
2842 {2887 {
2843 if ((*it)->id () == aboveId ||2888 if ((*it)->id () == aboveId ||
2844 ((*it)->priv->frame && (*it)->priv->frame == aboveId))2889 ((*it)->priv->frame && (*it)->priv->frame == aboveId))
2845 {
2846 break;2890 break;
2847 }2891
2848 ++it;2892 ++it;
2849 }2893 }
28502894
@@ -2863,16 +2907,15 @@
2863 (*it)->next = w;2907 (*it)->next = w;
28642908
2865 if (w->next)2909 if (w->next)
2866 {
2867 w->next->prev = w;2910 w->next->prev = w;
2868 }
28692911
2870 windows.insert (++it, w);2912 windows.insert (++it, w);
2871 addWindowToMap(w);2913 addWindowToMap (w);
2872}2914}
28732915
2874void2916void
2875CompScreenImpl::insertServerWindow (CompWindow *w, Window aboveId)2917CompScreenImpl::insertServerWindow (CompWindow *w,
2918 Window aboveId)
2876{2919{
2877 windowManager.insertServerWindow(w, aboveId);2920 windowManager.insertServerWindow(w, aboveId);
2878}2921}
@@ -2895,6 +2938,7 @@
2895 serverWindows.front ()->serverPrev = w;2938 serverWindows.front ()->serverPrev = w;
2896 w->serverNext = serverWindows.front ();2939 w->serverNext = serverWindows.front ();
2897 }2940 }
2941
2898 serverWindows.push_front (w);2942 serverWindows.push_front (w);
28992943
2900 return;2944 return;
@@ -2906,9 +2950,8 @@
2906 {2950 {
2907 if ((*it)->priv->serverId == aboveId ||2951 if ((*it)->priv->serverId == aboveId ||
2908 ((*it)->priv->serverFrame && (*it)->priv->serverFrame == aboveId))2952 ((*it)->priv->serverFrame && (*it)->priv->serverFrame == aboveId))
2909 {
2910 break;2953 break;
2911 }2954
2912 ++it;2955 ++it;
2913 }2956 }
29142957
@@ -2927,9 +2970,7 @@
2927 (*it)->serverNext = w;2970 (*it)->serverNext = w;
29282971
2929 if (w->serverNext)2972 if (w->serverNext)
2930 {
2931 w->serverNext->serverPrev = w;2973 w->serverNext->serverPrev = w;
2932 }
29332974
2934 serverWindows.insert (++it, w);2975 serverWindows.insert (++it, w);
2935}2976}
@@ -2938,7 +2979,7 @@
2938cps::WindowManager::eraseWindowFromMap (Window id)2979cps::WindowManager::eraseWindowFromMap (Window id)
2939{2980{
2940 if (id != 1)2981 if (id != 1)
2941 windowsMap.erase (id);2982 windowsMap.erase (id);
2942}2983}
29432984
2944void2985void
@@ -2948,17 +2989,16 @@
2948}2989}
29492990
2950void2991void
2951cps::WindowManager::unhookWindow(CompWindow* w)2992cps::WindowManager::unhookWindow (CompWindow* w)
2952{2993{
2953 StackDebugger *dbg = StackDebugger::Default ();2994 StackDebugger *dbg = StackDebugger::Default ();
29542995
2955 if (dbg)2996 if (dbg)
2956 dbg->windowsChanged (true);2997 dbg->windowsChanged (true);
29572998
2958 CompWindowList::iterator it =2999 CompWindowList::iterator it = std::find (windows.begin (), windows.end (), w);
2959 std::find (windows.begin(), windows.end(), w);
29603000
2961 if (it == windows.end())3001 if (it == windows.end ())
2962 {3002 {
2963 compLogMessage ("core", CompLogLevelWarn, "a broken plugin tried to remove a window twice, we won't allow that!");3003 compLogMessage ("core", CompLogLevelWarn, "a broken plugin tried to remove a window twice, we won't allow that!");
2964 return;3004 return;
@@ -2976,7 +3016,7 @@
2976 w->next = NULL;3016 w->next = NULL;
2977 w->prev = NULL;3017 w->prev = NULL;
29783018
2979 removeFromFindWindowCache(w);3019 removeFromFindWindowCache (w);
2980}3020}
29813021
2982void3022void
@@ -3029,25 +3069,26 @@
3029#define POINTER_GRAB_MASK (ButtonReleaseMask | \3069#define POINTER_GRAB_MASK (ButtonReleaseMask | \
3030 ButtonPressMask | \3070 ButtonPressMask | \
3031 PointerMotionMask)3071 PointerMotionMask)
3072
3032CompScreenImpl::GrabHandle3073CompScreenImpl::GrabHandle
3033CompScreenImpl::pushGrab (Cursor cursor, const char *name)3074CompScreenImpl::pushGrab (Cursor cursor,
3075 const char *name)
3034{3076{
3035 if (privateScreen.eventManager.grabsEmpty ())3077 if (privateScreen.eventManager.grabsEmpty ())
3036 {3078 {
3037 int status;3079 int status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow (),
30383080 true, POINTER_GRAB_MASK,
3039 status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow(), true,3081 GrabModeAsync, GrabModeAsync,
3040 POINTER_GRAB_MASK,3082 privateScreen.rootWindow (), cursor,
3041 GrabModeAsync, GrabModeAsync,3083 CurrentTime);
3042 privateScreen.rootWindow(), cursor,
3043 CurrentTime);
30443084
3045 if (status == GrabSuccess)3085 if (status == GrabSuccess)
3046 {3086 {
3047 status = XGrabKeyboard (privateScreen.dpy,3087 status = XGrabKeyboard (privateScreen.dpy,
3048 privateScreen.eventManager.getGrabWindow(), true,3088 privateScreen.eventManager.getGrabWindow (), true,
3049 GrabModeAsync, GrabModeAsync,3089 GrabModeAsync, GrabModeAsync,
3050 CurrentTime);3090 CurrentTime);
3091
3051 if (status != GrabSuccess)3092 if (status != GrabSuccess)
3052 {3093 {
3053 XUngrabPointer (privateScreen.dpy, CurrentTime);3094 XUngrabPointer (privateScreen.dpy, CurrentTime);
@@ -3058,10 +3099,8 @@
3058 return NULL;3099 return NULL;
3059 }3100 }
3060 else3101 else
3061 {
3062 XChangeActivePointerGrab (privateScreen.dpy, POINTER_GRAB_MASK,3102 XChangeActivePointerGrab (privateScreen.dpy, POINTER_GRAB_MASK,
3063 cursor, CurrentTime);3103 cursor, CurrentTime);
3064 }
30653104
3066 cps::Grab *grab = new cps::Grab (cursor, name);3105 cps::Grab *grab = new cps::Grab (cursor, name);
3067 privateScreen.eventManager.grabsPush (grab);3106 privateScreen.eventManager.grabsPush (grab);
@@ -3070,7 +3109,8 @@
3070}3109}
30713110
3072void3111void
3073CompScreenImpl::updateGrab (CompScreen::GrabHandle handle, Cursor cursor)3112CompScreenImpl::updateGrab (CompScreen::GrabHandle handle,
3113 Cursor cursor)
3074{3114{
3075 if (!handle)3115 if (!handle)
3076 return;3116 return;
@@ -3083,12 +3123,12 @@
30833123
3084void3124void
3085CompScreenImpl::removeGrab (CompScreen::GrabHandle handle,3125CompScreenImpl::removeGrab (CompScreen::GrabHandle handle,
3086 CompPoint *restorePointer)3126 CompPoint *restorePointer)
3087{3127{
3088 if (!handle)3128 if (!handle)
3089 return;3129 return;
30903130
3091 privateScreen.eventManager.grabsRemove(handle);3131 privateScreen.eventManager.grabsRemove (handle);
30923132
3093 if (!privateScreen.eventManager.grabsEmpty ())3133 if (!privateScreen.eventManager.grabsEmpty ())
3094 {3134 {
@@ -3109,7 +3149,7 @@
3109}3149}
31103150
3111void3151void
3112cps::GrabList::grabsRemove(Grab* handle)3152cps::GrabList::grabsRemove (Grab *handle)
3113{3153{
3114 GrabIterator it = std::find (grabsBegin (), grabsEnd (), handle);3154 GrabIterator it = std::find (grabsBegin (), grabsEnd (), handle);
31153155
@@ -3125,18 +3165,21 @@
3125 plugins listed, returns false otherwise. */3165 plugins listed, returns false otherwise. */
31263166
3127bool3167bool
3128CompScreenImpl::otherGrabExist (const char *first, ...)3168CompScreenImpl::otherGrabExist (const char *first,
3169 ...)
3129{3170{
3130 va_list ap;3171 va_list ap;
3131 const char *name;3172 const char *name;
31323173
3133 std::list<cps::Grab *>::iterator it;3174 std::list<cps::Grab *>::iterator it;
31343175
3135 for (it = privateScreen.eventManager.grabsBegin (); it != privateScreen.eventManager.grabsEnd (); ++it)3176 for (it = privateScreen.eventManager.grabsBegin ();
3177 it != privateScreen.eventManager.grabsEnd (); ++it)
3136 {3178 {
3137 va_start (ap, first);3179 va_start (ap, first);
31383180
3139 name = first;3181 name = first;
3182
3140 while (name)3183 while (name)
3141 {3184 {
3142 if (strcmp (name, (*it)->name) == 0)3185 if (strcmp (name, (*it)->name) == 0)
@@ -3164,23 +3207,22 @@
3164cps::GrabList::grabExist (const char *grab)3207cps::GrabList::grabExist (const char *grab)
3165{3208{
3166 foreach (cps::Grab* g, grabs)3209 foreach (cps::Grab* g, grabs)
3167 {
3168 if (strcmp (g->name, grab) == 0)3210 if (strcmp (g->name, grab) == 0)
3169 return true;3211 return true;
3170 }3212
3171 return false;3213 return false;
3172}3214}
31733215
3174bool3216bool
3175CompScreenImpl::grabbed ()3217CompScreenImpl::grabbed ()
3176{3218{
3177 return privateScreen.eventManager.isGrabbed();3219 return privateScreen.eventManager.isGrabbed ();
3178}3220}
31793221
3180void3222void
3181cps::GrabManager::grabUngrabOneKey (unsigned int modifiers,3223cps::GrabManager::grabUngrabOneKey (unsigned int modifiers,
3182 int keycode,3224 int keycode,
3183 bool grab)3225 bool grab)
3184{3226{
3185 if (grab)3227 if (grab)
3186 {3228 {
@@ -3188,62 +3230,51 @@
3188 * Always grab the keyboard Sync-ronously. This is so that we can3230 * Always grab the keyboard Sync-ronously. This is so that we can
3189 * choose to ReplayKeyboard in alwaysHandleEvent if need be.3231 * choose to ReplayKeyboard in alwaysHandleEvent if need be.
3190 */3232 */
3191 XGrabKey (screen->dpy(),3233 XGrabKey (screen->dpy (),
3192 keycode,3234 keycode,
3193 modifiers,3235 modifiers,
3194 screen->root(),3236 screen->root (),
3195 true,3237 true,
3196 GrabModeAsync,3238 GrabModeAsync,
3197 GrabModeSync);3239 GrabModeSync);
3198 }3240 }
3199 else3241 else
3200 {3242 {
3201 XUngrabKey (screen->dpy(),3243 XUngrabKey (screen->dpy (),
3202 keycode,3244 keycode,
3203 modifiers,3245 modifiers,
3204 screen->root());3246 screen->root ());
3205 }3247 }
3206}3248}
32073249
3208bool3250bool
3209cps::GrabManager::grabUngrabKeys (unsigned int modifiers,3251cps::GrabManager::grabUngrabKeys (unsigned int modifiers,
3210 int keycode,3252 int keycode,
3211 bool grab)3253 bool grab)
3212{3254{
3213 int mod, k;3255 int mod, k;
3214 unsigned int ignore;3256 int minCode, maxCode;
32153257 unsigned int ignore;
3216 CompScreen::checkForError (screen->dpy());3258
32173259 CompScreen::checkForError (screen->dpy ());
3218 for (ignore = 0; ignore <= modHandler->ignoredModMask (); ignore++)3260
3261 for (ignore = 0; ignore <= modHandler->ignoredModMask (); ++ignore)
3219 {3262 {
3220 if (ignore & ~modHandler->ignoredModMask ())3263 if (ignore & ~modHandler->ignoredModMask ())
3221 continue;3264 continue;
32223265
3223 if (keycode != 0)3266 if (keycode != 0)
3224 {
3225 grabUngrabOneKey (modifiers | ignore, keycode, grab);3267 grabUngrabOneKey (modifiers | ignore, keycode, grab);
3226 }
3227 else3268 else
3228 {3269 {
3229 for (mod = 0; mod < 8; mod++)3270 for (mod = 0; mod < 8; ++mod)
3230 {
3231 if (modifiers & (1 << mod))3271 if (modifiers & (1 << mod))
3232 {
3233 for (k = mod * modHandler->modMap ()->max_keypermod;3272 for (k = mod * modHandler->modMap ()->max_keypermod;
3234 k < (mod + 1) * modHandler->modMap ()->max_keypermod;3273 k < (mod + 1) * modHandler->modMap ()->max_keypermod; ++k)
3235 k++)
3236 {
3237 if (modHandler->modMap ()->modifiermap[k])3274 if (modHandler->modMap ()->modifiermap[k])
3238 {3275 grabUngrabOneKey ((modifiers & ~(1 << mod)) | ignore,
3239 grabUngrabOneKey ((modifiers & ~(1 << mod)) |
3240 ignore,
3241 modHandler->modMap ()->modifiermap[k],3276 modHandler->modMap ()->modifiermap[k],
3242 grab);3277 grab);
3243 }
3244 }
3245 }
3246 }
32473278
3248 /*3279 /*
3249 * keycode == 0, so this is a modifier-only keybinding.3280 * keycode == 0, so this is a modifier-only keybinding.
@@ -3255,15 +3286,15 @@
3255 * keys, and know to cancel the tap if <modifier>+k is pressed.3286 * keys, and know to cancel the tap if <modifier>+k is pressed.
3256 */3287 */
3257 if (!(currentState & CompAction::StateIgnoreTap))3288 if (!(currentState & CompAction::StateIgnoreTap))
3258 {3289 {
3259 int minCode, maxCode;3290 XDisplayKeycodes (screen->dpy (), &minCode, &maxCode);
3260 XDisplayKeycodes (screen->dpy(), &minCode, &maxCode);3291
3261 for (k = minCode; k <= maxCode; k++)3292 for (k = minCode; k <= maxCode; ++k)
3262 grabUngrabOneKey (modifiers | ignore, k, grab);3293 grabUngrabOneKey (modifiers | ignore, k, grab);
3263 }3294 }
3264 }3295 }
32653296
3266 if (CompScreen::checkForError (screen->dpy()))3297 if (CompScreen::checkForError (screen->dpy ()))
3267 return false;3298 return false;
3268 }3299 }
32693300
@@ -3273,29 +3304,22 @@
3273bool3304bool
3274cps::GrabManager::addPassiveKeyGrab (CompAction::KeyBinding &key)3305cps::GrabManager::addPassiveKeyGrab (CompAction::KeyBinding &key)
3275{3306{
3276 KeyGrab newKeyGrab;3307 KeyGrab newKeyGrab;
3277 unsigned int mask;3308 unsigned int mask = modHandler->virtualToRealModMask (key.modifiers ());
3278 std::list<KeyGrab>::iterator it;3309
32793310 for (std::list<KeyGrab>::iterator it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
3280 mask = modHandler->virtualToRealModMask (key.modifiers ());
3281
3282 for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
3283 {3311 {
3284 if (key.keycode () == (*it).keycode &&3312 if (key.keycode () == (*it).keycode &&
3285 mask == (*it).modifiers)3313 mask == (*it).modifiers)
3286 {3314 {
3287 (*it).count++;3315 ++(*it).count;
3288 return true;3316 return true;
3289 }3317 }
3290 }3318 }
32913319
32923320 if (!(mask & CompNoMask) &&
32933321 !grabUngrabKeys (mask, key.keycode (), true))
3294 if (!(mask & CompNoMask))3322 return false;
3295 {
3296 if (!grabUngrabKeys (mask, key.keycode (), true))
3297 return false;
3298 }
32993323
3300 newKeyGrab.keycode = key.keycode ();3324 newKeyGrab.keycode = key.keycode ();
3301 newKeyGrab.modifiers = mask;3325 newKeyGrab.modifiers = mask;
@@ -3309,17 +3333,16 @@
3309void3333void
3310cps::GrabManager::removePassiveKeyGrab (CompAction::KeyBinding &key)3334cps::GrabManager::removePassiveKeyGrab (CompAction::KeyBinding &key)
3311{3335{
3312 unsigned int mask;3336 unsigned int mask = modHandler->virtualToRealModMask (key.modifiers ());
3313 std::list<KeyGrab>::iterator it;3337
33143338 for (std::list<KeyGrab>::iterator it = keyGrabs.begin ();
3315 mask = modHandler->virtualToRealModMask (key.modifiers ());3339 it != keyGrabs.end (); ++it)
3316
3317 for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
3318 {3340 {
3319 if (key.keycode () == (*it).keycode &&3341 if (key.keycode () == (*it).keycode &&
3320 mask == (*it).modifiers)3342 mask == (*it).modifiers)
3321 {3343 {
3322 (*it).count--;3344 --(*it).count;
3345
3323 if ((*it).count)3346 if ((*it).count)
3324 return;3347 return;
33253348
@@ -3342,32 +3365,27 @@
3342void3365void
3343cps::GrabManager::updatePassiveKeyGrabs ()3366cps::GrabManager::updatePassiveKeyGrabs ()
3344{3367{
3345 std::list<cps::KeyGrab>::iterator it;3368 XUngrabKey (screen->dpy (), AnyKey, AnyModifier, screen->root ());
33463369
3347 XUngrabKey (screen->dpy(), AnyKey, AnyModifier, screen->root());3370 for (std::list<cps::KeyGrab>::iterator it = keyGrabs.begin ();
33483371 it != keyGrabs.end (); ++it)
3349 for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
3350 {
3351 if (!((*it).modifiers & CompNoMask))3372 if (!((*it).modifiers & CompNoMask))
3352 {
3353 grabUngrabKeys ((*it).modifiers,3373 grabUngrabKeys ((*it).modifiers,
3354 (*it).keycode, true);3374 (*it).keycode, true);
3355 }
3356 }
3357}3375}
33583376
3359bool3377bool
3360cps::GrabManager::addPassiveButtonGrab (CompAction::ButtonBinding &button)3378cps::GrabManager::addPassiveButtonGrab (CompAction::ButtonBinding &button)
3361{3379{
3362 ButtonGrab newButtonGrab;3380 ButtonGrab newButtonGrab;
3363 std::list<ButtonGrab>::iterator it;
33643381
3365 for (it = buttonGrabs.begin (); it != buttonGrabs.end (); ++it)3382 for (std::list<ButtonGrab>::iterator it = buttonGrabs.begin ();
3383 it != buttonGrabs.end (); ++it)
3366 {3384 {
3367 if (button.button () == (*it).button &&3385 if (button.button () == (*it).button &&
3368 button.modifiers () == (*it).modifiers)3386 button.modifiers () == (*it).modifiers)
3369 {3387 {
3370 (*it).count++;3388 ++(*it).count;
3371 return true;3389 return true;
3372 }3390 }
3373 }3391 }
@@ -3395,18 +3413,17 @@
3395 continue;3413 continue;
33963414
3397 for (unsigned int ignore = 0;3415 for (unsigned int ignore = 0;
3398 ignore <= modHandler->ignoredModMask (); ignore++)3416 ignore <= modHandler->ignoredModMask (); ++ignore)
3399 {3417 {
3400 if (ignore & ~modHandler->ignoredModMask ())3418 if (ignore & ~modHandler->ignoredModMask ())
3401 continue;3419 continue;
34023420
3403 XGrabButton (screen->dpy(),3421 XGrabButton (screen->dpy (),
3404 bind.button,3422 bind.button,
3405 mods | ignore,3423 mods | ignore,
3406 serverFrame,3424 serverFrame,
3407 false,3425 false,
3408 ButtonPressMask | ButtonReleaseMask |3426 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
3409 ButtonMotionMask,
3410 GrabModeSync,3427 GrabModeSync,
3411 GrabModeAsync,3428 GrabModeAsync,
3412 None,3429 None,
@@ -3418,14 +3435,14 @@
3418void3435void
3419cps::GrabManager::removePassiveButtonGrab (CompAction::ButtonBinding &button)3436cps::GrabManager::removePassiveButtonGrab (CompAction::ButtonBinding &button)
3420{3437{
3421 std::list<ButtonGrab>::iterator it;3438 for (std::list<ButtonGrab>::iterator it = buttonGrabs.begin ();
34223439 it != buttonGrabs.end (); ++it)
3423 for (it = buttonGrabs.begin (); it != buttonGrabs.end (); ++it)
3424 {3440 {
3425 if (button.button () == (*it).button &&3441 if (button.button () == (*it).button &&
3426 button.modifiers () == (*it).modifiers)3442 button.modifiers () == (*it).modifiers)
3427 {3443 {
3428 (*it).count--;3444 --(*it).count;
3445
3429 if ((*it).count)3446 if ((*it).count)
3430 return;3447 return;
34313448
@@ -3447,37 +3464,30 @@
3447CompScreenImpl::addAction (CompAction *action)3464CompScreenImpl::addAction (CompAction *action)
3448{3465{
3449 assert (privateScreen.initialized);3466 assert (privateScreen.initialized);
3450 if (!privateScreen.initialized)3467
3451 return false;3468 if (!privateScreen.initialized ||
34523469 action->active ())
3453 if (action->active ())3470 return false;
3454 return false;3471
34553472 grabManager.setCurrentState(action->state ());
3456 grabManager.setCurrentState(action->state());3473
34573474 if (action->type () & CompAction::BindingTypeKey &&
3458 if (action->type () & CompAction::BindingTypeKey)3475 !grabManager.addPassiveKeyGrab (action->key ()))
3459 {3476 return false;
3460 if (!grabManager.addPassiveKeyGrab (action->key ()))3477
3461 return false;3478 if (action->type () & CompAction::BindingTypeButton &&
3462 }3479 !grabManager.addPassiveButtonGrab (action->button ()))
34633480 {
3464 if (action->type () & CompAction::BindingTypeButton)3481 if (action->type () & CompAction::BindingTypeKey)
3465 {3482 grabManager.removePassiveKeyGrab (action->key ());
3466 if (!grabManager.addPassiveButtonGrab (action->button ()))3483
3467 {3484 return false;
3468 if (action->type () & CompAction::BindingTypeKey)
3469 grabManager.removePassiveKeyGrab (action->key ());
3470
3471 return false;
3472 }
3473 }3485 }
34743486
3475 if (action->edgeMask ())3487 if (action->edgeMask ())
3476 {3488 for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
3477 for (int i = 0; i < SCREEN_EDGE_NUM; i++)
3478 if (action->edgeMask () & (1 << i))3489 if (action->edgeMask () & (1 << i))
3479 privateScreen.enableEdge (i);3490 privateScreen.enableEdge (i);
3480 }
34813491
3482 ca::setActionActiveState (*action, true);3492 ca::setActionActiveState (*action, true);
34833493
@@ -3491,7 +3501,7 @@
3491 !action->active ())3501 !action->active ())
3492 return;3502 return;
34933503
3494 grabManager.setCurrentState(action->state());3504 grabManager.setCurrentState(action->state ());
34953505
3496 if (action->type () & CompAction::BindingTypeKey)3506 if (action->type () & CompAction::BindingTypeKey)
3497 grabManager.removePassiveKeyGrab (action->key ());3507 grabManager.removePassiveKeyGrab (action->key ());
@@ -3500,11 +3510,9 @@
3500 grabManager.removePassiveButtonGrab (action->button ());3510 grabManager.removePassiveButtonGrab (action->button ());
35013511
3502 if (action->edgeMask ())3512 if (action->edgeMask ())
3503 {3513 for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
3504 for (int i = 0; i < SCREEN_EDGE_NUM; i++)
3505 if (action->edgeMask () & (1 << i))3514 if (action->edgeMask () & (1 << i))
3506 privateScreen.disableEdge (i);3515 privateScreen.disableEdge (i);
3507 }
35083516
3509 ca::setActionActiveState (*action, false);3517 ca::setActionActiveState (*action, false);
3510}3518}
@@ -3512,14 +3520,14 @@
3512void3520void
3513CompScreenImpl::updateWorkarea ()3521CompScreenImpl::updateWorkarea ()
3514{3522{
3515 CompRect workArea;3523 CompRect workArea;
3516 CompRegion allWorkArea = CompRegion ();3524 CompRegion allWorkArea = CompRegion ();
3517 bool workAreaChanged = false;3525 bool workAreaChanged = false;
3518 privateScreen.outputDevices.computeWorkAreas(3526
3519 workArea,3527 privateScreen.outputDevices.computeWorkAreas (workArea,
3520 workAreaChanged,3528 workAreaChanged,
3521 allWorkArea,3529 allWorkArea,
3522 windowManager.getWindows());3530 windowManager.getWindows ());
35233531
3524 workArea = allWorkArea.boundingRect ();3532 workArea = allWorkArea.boundingRect ();
35253533
@@ -3535,7 +3543,7 @@
3535 {3543 {
3536 /* as work area changed, update all maximized windows on this3544 /* as work area changed, update all maximized windows on this
3537 screen to snap to the new work area */3545 screen to snap to the new work area */
3538 windowManager.updateWindowSizes();3546 windowManager.updateWindowSizes ();
3539 }3547 }
3540}3548}
35413549
@@ -3545,17 +3553,10 @@
3545 /* windows with client id less than 2 have been destroyed and only exists3553 /* windows with client id less than 2 have been destroyed and only exists
3546 because some plugin keeps a reference to them. they should not be in3554 because some plugin keeps a reference to them. they should not be in
3547 client lists */3555 client lists */
3548 if (w->id () < 2)3556 if (w->id () < 2 ||
3549 return false;3557 w->overrideRedirect () ||
35503558 (!w->isViewable () && !(w->state () & CompWindowStateHiddenMask)))
3551 if (w->overrideRedirect ())3559 return false;
3552 return false;
3553
3554 if (!w->isViewable ())
3555 {
3556 if (!(w->state () & CompWindowStateHiddenMask))
3557 return false;
3558 }
35593560
3560 return true;3561 return true;
3561}3562}
@@ -3565,9 +3566,7 @@
3565 int *n)3566 int *n)
3566{3567{
3567 if (isClientListWindow (w))3568 if (isClientListWindow (w))
3568 {
3569 *n = *n + 1;3569 *n = *n + 1;
3570 }
3571}3570}
35723571
3573static bool3572static bool
@@ -3578,15 +3577,15 @@
3578}3577}
35793578
3580void3579void
3581cps::WindowManager::updateClientList (PrivateScreen& ps)3580cps::WindowManager::updateClientList (PrivateScreen &ps)
3582{3581{
3583 bool updateClientList = false;3582 bool updateClientList = false;
3584 bool updateClientListStacking = false;3583 bool updateClientListStacking = false;
3585 int n = 0;3584 int n = 0;
35863585
3587 screen->forEachWindow (boost::bind (countClientListWindow, _1, &n));3586 screen->forEachWindow (boost::bind (countClientListWindow, _1, &n));
35883587
3589 if (n == 0)3588 if (!n)
3590 {3589 {
3591 if ((unsigned int) n != clientList.size ())3590 if ((unsigned int) n != clientList.size ())
3592 {3591 {
@@ -3595,14 +3594,14 @@
3595 clientIdList.clear ();3594 clientIdList.clear ();
3596 clientIdListStacking.clear ();3595 clientIdListStacking.clear ();
35973596
3598 XChangeProperty (ps.dpy, ps.rootWindow(),3597 XChangeProperty (ps.dpy, ps.rootWindow (),
3599 Atoms::clientList,3598 Atoms::clientList,
3600 XA_WINDOW, 32, PropModeReplace,3599 XA_WINDOW, 32, PropModeReplace,
3601 (unsigned char *) &ps.eventManager.getGrabWindow(), 1);3600 (unsigned char *) &ps.eventManager.getGrabWindow (), 1);
3602 XChangeProperty (ps.dpy, ps.rootWindow(),3601 XChangeProperty (ps.dpy, ps.rootWindow (),
3603 Atoms::clientListStacking,3602 Atoms::clientListStacking,
3604 XA_WINDOW, 32, PropModeReplace,3603 XA_WINDOW, 32, PropModeReplace,
3605 (unsigned char *) &ps.eventManager.getGrabWindow(), 1);3604 (unsigned char *) &ps.eventManager.getGrabWindow (), 1);
3606 }3605 }
36073606
3608 return;3607 return;
@@ -3618,9 +3617,10 @@
36183617
3619 clientListStacking.clear ();3618 clientListStacking.clear ();
36203619
3621 for (iterator i = begin(); i != end(); ++i)3620 for (iterator i = begin (); i != end (); ++i)
3622 {3621 {
3623 CompWindow* const w(*i);3622 CompWindow* const w(*i);
3623
3624 if (isClientListWindow (w))3624 if (isClientListWindow (w))
3625 clientListStacking.push_back (w);3625 clientListStacking.push_back (w);
3626 }3626 }
@@ -3633,61 +3633,57 @@
3633 compareMappingOrder);3633 compareMappingOrder);
36343634
3635 /* make sure client id lists are up-to-date */3635 /* make sure client id lists are up-to-date */
3636 for (int i = 0; i < n; i++)3636 for (int i = 0; i < n; ++i)
3637 {3637 {
3638 if (!updateClientList &&3638 if (!updateClientList &&
3639 clientIdList[i] != clientList[i]->id ())3639 clientIdList[i] != clientList[i]->id ())
3640 {
3641 updateClientList = true;3640 updateClientList = true;
3642 }
36433641
3644 clientIdList[i] = clientList[i]->id ();3642 clientIdList[i] = clientList[i]->id ();
3645 }3643 }
3646 for (int i = 0; i < n; i++)3644 for (int i = 0; i < n; ++i)
3647 {3645 {
3648 if (!updateClientListStacking &&3646 if (!updateClientListStacking &&
3649 clientIdListStacking[i] != clientListStacking[i]->id ())3647 clientIdListStacking[i] != clientListStacking[i]->id ())
3650 {
3651 updateClientListStacking = true;3648 updateClientListStacking = true;
3652 }
36533649
3654 clientIdListStacking[i] = clientListStacking[i]->id ();3650 clientIdListStacking[i] = clientListStacking[i]->id ();
3655 }3651 }
36563652
3657 if (updateClientList)3653 if (updateClientList)
3658 XChangeProperty (ps.dpy, ps.rootWindow(),3654 XChangeProperty (ps.dpy, ps.rootWindow (),
3659 Atoms::clientList,3655 Atoms::clientList,
3660 XA_WINDOW, 32, PropModeReplace,3656 XA_WINDOW, 32, PropModeReplace,
3661 (unsigned char *) &clientIdList.at (0), n);3657 (unsigned char *) &clientIdList.at (0), n);
36623658
3663 if (updateClientListStacking)3659 if (updateClientListStacking)
3664 XChangeProperty (ps.dpy, ps.rootWindow(),3660 XChangeProperty (ps.dpy, ps.rootWindow (),
3665 Atoms::clientListStacking,3661 Atoms::clientListStacking,
3666 XA_WINDOW, 32, PropModeReplace,3662 XA_WINDOW, 32, PropModeReplace,
3667 (unsigned char *) &clientIdListStacking.at (0),3663 (unsigned char *) &clientIdListStacking.at (0), n);
3668 n);
3669}3664}
36703665
3671const CompWindowVector &3666const CompWindowVector &
3672CompScreenImpl::clientList (bool stackingOrder)3667CompScreenImpl::clientList (bool stackingOrder)
3673{3668{
3674 return stackingOrder ? windowManager.getClientListStacking() : windowManager.getClientList();3669 return stackingOrder ? windowManager.getClientListStacking () :
3670 windowManager.getClientList ();
3675}3671}
36763672
3677void3673void
3678CompScreenImpl::toolkitAction (Atom toolkitAction,3674CompScreenImpl::toolkitAction (Atom toolkitAction,
3679 Time eventTime,3675 Time eventTime,
3680 Window window,3676 Window window,
3681 long data0,3677 long data0,
3682 long data1,3678 long data1,
3683 long data2)3679 long data2)
3684{3680{
3685 XEvent ev;3681 XEvent ev;
36863682
3687 ev.type = ClientMessage;3683 ev.type = ClientMessage;
3688 ev.xclient.window = window;3684 ev.xclient.window = window;
3689 ev.xclient.message_type = Atoms::toolkitAction;3685 ev.xclient.message_type = Atoms::toolkitAction;
3690 ev.xclient.format = 32;3686 ev.xclient.format = 32;
3691 ev.xclient.data.l[0] = toolkitAction;3687 ev.xclient.data.l[0] = toolkitAction;
3692 ev.xclient.data.l[1] = eventTime;3688 ev.xclient.data.l[1] = eventTime;
3693 ev.xclient.data.l[2] = data0;3689 ev.xclient.data.l[2] = data0;
@@ -3697,7 +3693,7 @@
3697 XUngrabPointer (privateScreen.dpy, CurrentTime);3693 XUngrabPointer (privateScreen.dpy, CurrentTime);
3698 XUngrabKeyboard (privateScreen.dpy, CurrentTime);3694 XUngrabKeyboard (privateScreen.dpy, CurrentTime);
36993695
3700 XSendEvent (privateScreen.dpy, privateScreen.rootWindow(), false,3696 XSendEvent (privateScreen.dpy, privateScreen.rootWindow (), false,
3701 StructureNotifyMask, &ev);3697 StructureNotifyMask, &ev);
3702}3698}
37033699
@@ -3709,23 +3705,21 @@
37093705
3710 if (fork () == 0)3706 if (fork () == 0)
3711 {3707 {
3712 size_t pos;3708 CompString env (privateScreen.displayString ());
3713 CompString env (privateScreen.displayString ());
37143709
3715 setsid ();3710 setsid ();
37163711
3717 pos = env.find (':');3712 size_t pos = env.find (':');
3713
3718 if (pos != std::string::npos)3714 if (pos != std::string::npos)
3719 {3715 {
3720 size_t pointPos = env.find ('.', pos);3716 size_t pointPos = env.find ('.', pos);
37213717
3722 if (pointPos != std::string::npos)3718 if (pointPos != std::string::npos)
3723 {
3724 env.erase (pointPos);3719 env.erase (pointPos);
3725 }
3726 else3720 else
3727 {3721 {
3728 unsigned int displayNum = atoi (env.substr (pos + 1).c_str ());3722 unsigned int displayNum = atoi (env.substr (pos + 1).c_str ());
3729 env.erase (pos);3723 env.erase (pos);
3730 env.append (compPrintf (":%i", displayNum));3724 env.append (compPrintf (":%i", displayNum));
3731 }3725 }
@@ -3740,7 +3734,9 @@
3740}3734}
37413735
3742void3736void
3743CompScreenImpl::moveViewport (int tx, int ty, bool sync)3737CompScreenImpl::moveViewport (int tx,
3738 int ty,
3739 bool sync)
3744{3740{
3745 CompPoint pnt;3741 CompPoint pnt;
37463742
@@ -3761,11 +3757,14 @@
3761 tx *= -width ();3757 tx *= -width ();
3762 ty *= -height ();3758 ty *= -height ();
37633759
3764 for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)3760 unsigned int valueMask;
3761
3762 for (cps::WindowManager::iterator i = windowManager.begin ();
3763 i != windowManager.end (); ++i)
3765 {3764 {
3766 CompWindow* const w(*i);3765 CompWindow* const w (*i);
3767 unsigned int valueMask = CWX | CWY;3766 valueMask = CWX | CWY;
3768 XWindowChanges xwc= XWINDOWCHANGES_INIT;3767 XWindowChanges xwc = XWINDOWCHANGES_INIT;
37693768
3770 if (w->onAllViewports ())3769 if (w->onAllViewports ())
3771 continue;3770 continue;
@@ -3786,18 +3785,15 @@
37863785
3787 if (sync)3786 if (sync)
3788 {3787 {
3789 CompWindow *w;
3790
3791 privateScreen.setDesktopHints ();3788 privateScreen.setDesktopHints ();
37923789
3793 setCurrentActiveWindowHistory (privateScreen.viewPort.vp.x (), privateScreen.viewPort.vp.y ());3790 setCurrentActiveWindowHistory (privateScreen.viewPort.vp.x (), privateScreen.viewPort.vp.y ());
37943791
3795 w = findWindow (privateScreen.orphanData.activeWindow);3792 CompWindow *w = findWindow (privateScreen.orphanData.activeWindow);
3793
3796 if (w)3794 if (w)
3797 {3795 {
3798 CompPoint dvp;3796 CompPoint dvp = w->defaultViewport ();
3799
3800 dvp = w->defaultViewport ();
38013797
3802 /* add window to current history if it's default viewport is3798 /* add window to current history if it's default viewport is
3803 still the current one. */3799 still the current one. */
@@ -3823,7 +3819,8 @@
3823void3819void
3824cps::WindowManager::removeGroup (CompGroup *group)3820cps::WindowManager::removeGroup (CompGroup *group)
3825{3821{
3826 group->refCnt--;3822 --group->refCnt;
3823
3827 if (group->refCnt)3824 if (group->refCnt)
3828 return;3825 return;
38293826
@@ -3831,9 +3828,7 @@
3831 std::find (groups.begin (), groups.end (), group);3828 std::find (groups.begin (), groups.end (), group);
38323829
3833 if (it != groups.end ())3830 if (it != groups.end ())
3834 {
3835 groups.erase (it);3831 groups.erase (it);
3836 }
38373832
3838 delete group;3833 delete group;
3839}3834}
@@ -3849,16 +3844,16 @@
3849}3844}
38503845
3851void3846void
3852cps::StartupSequence::applyStartupProperties (CompScreen* screen, CompWindow *window)3847cps::StartupSequence::applyStartupProperties (CompScreen *screen,
3848 CompWindow *window)
3853{3849{
3854 CompStartupSequence *s = NULL;3850 CompStartupSequence *s = NULL;
3855 const char *startupId = window->startupId ();3851 const char *startupId = window->startupId ();
38563852
3857 if (!startupId)3853 if (!startupId)
3858 {3854 {
3859 CompWindow *leader;3855 CompWindow *leader = screen->findWindow (window->clientLeader ());
38603856
3861 leader = screen->findWindow (window->clientLeader ());
3862 if (leader)3857 if (leader)
3863 startupId = leader->startupId ();3858 startupId = leader->startupId ();
38643859
@@ -3868,9 +3863,8 @@
38683863
3869 foreach (CompStartupSequence *ss, startupSequences)3864 foreach (CompStartupSequence *ss, startupSequences)
3870 {3865 {
3871 const char *id;3866 const char *id = sn_startup_sequence_get_id (ss->sequence);
38723867
3873 id = sn_startup_sequence_get_id (ss->sequence);
3874 if (strcmp (id, startupId) == 0)3868 if (strcmp (id, startupId) == 0)
3875 {3869 {
3876 s = ss;3870 s = ss;
@@ -3892,7 +3886,7 @@
3892 xev.xclient.format = 32;3886 xev.xclient.format = 32;
38933887
3894 xev.xclient.message_type = Atoms::winActive;3888 xev.xclient.message_type = Atoms::winActive;
3895 xev.xclient.window = id;3889 xev.xclient.window = id;
38963890
3897 xev.xclient.data.l[0] = ClientTypePager;3891 xev.xclient.data.l[0] = ClientTypePager;
3898 xev.xclient.data.l[1] = 0;3892 xev.xclient.data.l[1] = 0;
@@ -3900,7 +3894,7 @@
3900 xev.xclient.data.l[3] = 0;3894 xev.xclient.data.l[3] = 0;
3901 xev.xclient.data.l[4] = 0;3895 xev.xclient.data.l[4] = 0;
39023896
3903 XSendEvent (privateScreen.dpy, privateScreen.rootWindow(), false,3897 XSendEvent (privateScreen.dpy, privateScreen.rootWindow (), false,
3904 SubstructureRedirectMask | SubstructureNotifyMask, &xev);3898 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
3905}3899}
39063900
@@ -3912,7 +3906,8 @@
3912void3906void
3913PrivateScreen::enableEdge (int edge)3907PrivateScreen::enableEdge (int edge)
3914{3908{
3915 screenEdge[edge].count++;3909 ++screenEdge[edge].count;
3910
3916 if (screenEdge[edge].count == 1)3911 if (screenEdge[edge].count == 1)
3917 XMapRaised (dpy, screenEdge[edge].id);3912 XMapRaised (dpy, screenEdge[edge].id);
3918}3913}
@@ -3920,13 +3915,14 @@
3920void3915void
3921PrivateScreen::disableEdge (int edge)3916PrivateScreen::disableEdge (int edge)
3922{3917{
3923 screenEdge[edge].count--;3918 --screenEdge[edge].count;
3919
3924 if (screenEdge[edge].count == 0)3920 if (screenEdge[edge].count == 0)
3925 XUnmapWindow (dpy, screenEdge[edge].id);3921 XUnmapWindow (dpy, screenEdge[edge].id);
3926}3922}
39273923
3928CompWindow *3924CompWindow *
3929cps::WindowManager::getTopWindow() const3925cps::WindowManager::getTopWindow () const
3930{3926{
3931 /* return first window that has not been destroyed */3927 /* return first window that has not been destroyed */
3932 if (!windows.empty ())3928 if (!windows.empty ())
@@ -3951,7 +3947,8 @@
3951}3947}
39523948
3953int3949int
3954CompScreenImpl::outputDeviceForPoint (int x, int y)3950CompScreenImpl::outputDeviceForPoint (int x,
3951 int y)
3955{3952{
3956 CompWindow::Geometry geom (x, y, 1, 1, 0);3953 CompWindow::Geometry geom (x, y, 1, 1, 0);
39573954
@@ -3992,7 +3989,7 @@
39923989
3993 unsigned long data = desktop;3990 unsigned long data = desktop;
39943991
3995 XChangeProperty (dpy, rootWindow(), Atoms::currentDesktop,3992 XChangeProperty (dpy, rootWindow (), Atoms::currentDesktop,
3996 XA_CARDINAL, 32, PropModeReplace,3993 XA_CARDINAL, 32, PropModeReplace,
3997 (unsigned char *) &data, 1);3994 (unsigned char *) &data, 1);
3998}3995}
@@ -4024,6 +4021,11 @@
4024 * XXX: It is possible for this function to return a negative viewport, which4021 * XXX: It is possible for this function to return a negative viewport, which
4025 * definitely feels wrong, however it seems that some plugins depend on this behaviour4022 * definitely feels wrong, however it seems that some plugins depend on this behaviour
4026 * so they need to be fixed first4023 * so they need to be fixed first
4024 *
4025 * TODO: This function is responsible for several problems as the viewport containing
4026 * the center of the window is not always the correct one.
4027 * A example for this buggy behaviour is that a window maximizes offscreen, if
4028 * it's center is offscreen !
4027 */4029 */
4028void4030void
4029compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm,4031compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm,
@@ -4032,30 +4034,31 @@
4032 const CompSize & screenSize)4034 const CompSize & screenSize)
4033{4035{
4034 CompRect rect (gm);4036 CompRect rect (gm);
4035 int offset;
40364037
4037 const CompPoint &vp = viewports->getCurrentViewport ();4038 const CompPoint &vp = viewports->getCurrentViewport ();
4038 const CompSize &vpSize = viewports->viewportDimensions ();4039 const CompSize &vpSize = viewports->viewportDimensions ();
40394040
4040 rect.setWidth (gm.widthIncBorders ());4041 rect.setWidth (gm.widthIncBorders ());
4041 rect.setHeight (gm.heightIncBorders ());4042 rect.setHeight (gm.heightIncBorders ());
40424043
4043 offset = rect.centerX () < 0 ? -1 : 0;4044 int offset = rect.centerX () < 0 ? -1 : 0;
4044 viewport.setX (vp.x () + ((rect.centerX () / screenSize.width ()) + offset) % vpSize.width ());4045 viewport.setX (vp.x () + ((rect.centerX () / screenSize.width ()) + offset) %
4046 vpSize.width ());
40454047
4046 offset = rect.centerY () < 0 ? -1 : 0;4048 offset = rect.centerY () < 0 ? -1 : 0;
4047 viewport.setY (vp.y () + ((rect.centerY () / screenSize.height ()) + offset ) % vpSize.height ());4049 viewport.setY (vp.y () + ((rect.centerY () / screenSize.height ()) + offset ) %
4050 vpSize.height ());
4048}4051}
40494052
4050void4053void
4051CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,4054CompScreenImpl::viewportForGeometry (const CompWindow::Geometry &gm,
4052 CompPoint& viewport)4055 CompPoint &viewport)
4053{4056{
4054 compiz::private_screen::viewports::viewportForGeometry (gm, viewport, &privateScreen.viewPort, *this);4057 compiz::private_screen::viewports::viewportForGeometry (gm, viewport, &privateScreen.viewPort, *this);
4055}4058}
40564059
4057int4060int
4058CompScreenImpl::outputDeviceForGeometry (const CompWindow::Geometry& gm)4061CompScreenImpl::outputDeviceForGeometry (const CompWindow::Geometry &gm)
4059{4062{
4060 return privateScreen.outputDevices.outputDeviceForGeometry (gm, privateScreen.optionGetOverlappingOutputs (), this);4063 return privateScreen.outputDevices.outputDeviceForGeometry (gm, privateScreen.optionGetOverlappingOutputs (), this);
4061}4064}
@@ -4094,11 +4097,12 @@
4094}4097}
40954098
4096void4099void
4097cps::History::setCurrentActiveWindowHistory (int x, int y)4100cps::History::setCurrentActiveWindowHistory (int x,
4101 int y)
4098{4102{
4099 int i, min = 0;4103 int i, min = 0;
41004104
4101 for (i = 0; i < ACTIVE_WINDOW_HISTORY_NUM; i++)4105 for (i = 0; i < ACTIVE_WINDOW_HISTORY_NUM; ++i)
4102 {4106 {
4103 if (history[i].x == x && history[i].y == y)4107 if (history[i].x == x && history[i].y == y)
4104 {4108 {
@@ -4107,7 +4111,7 @@
4107 }4111 }
4108 }4112 }
41094113
4110 for (i = 1; i < ACTIVE_WINDOW_HISTORY_NUM; i++)4114 for (i = 1; i < ACTIVE_WINDOW_HISTORY_NUM; ++i)
4111 if (history[i].activeNum < history[min].activeNum)4115 if (history[i].activeNum < history[min].activeNum)
4112 min = i;4116 min = i;
41134117
@@ -4124,10 +4128,10 @@
4124cps::History::addToCurrentActiveWindowHistory (Window id)4128cps::History::addToCurrentActiveWindowHistory (Window id)
4125{4129{
4126 CompActiveWindowHistory *history = &this->history[currentHistory_];4130 CompActiveWindowHistory *history = &this->history[currentHistory_];
4127 Window tmp, next = id;4131 Window tmp, next = id;
41284132
4129 /* walk and move history */4133 /* walk and move history */
4130 for (int i = 0; i < ACTIVE_WINDOW_HISTORY_SIZE; i++)4134 for (int i = 0; i < ACTIVE_WINDOW_HISTORY_SIZE; ++i)
4131 {4135 {
4132 tmp = history->id[i];4136 tmp = history->id[i];
4133 history->id[i] = next;4137 history->id[i] = next;
@@ -4161,7 +4165,7 @@
4161Window4165Window
4162CompScreenImpl::root ()4166CompScreenImpl::root ()
4163{4167{
4164 return privateScreen.rootWindow();4168 return privateScreen.rootWindow ();
4165}4169}
41664170
4167int4171int
@@ -4171,10 +4175,11 @@
4171}4175}
41724176
4173void4177void
4174PrivateScreen::identifyEdgeWindow(Window id)4178PrivateScreen::identifyEdgeWindow (Window id)
4175{4179{
4176 edgeWindow = 0;4180 edgeWindow = 0;
4177 for (unsigned int i = 0; i < SCREEN_EDGE_NUM; i++)4181
4182 for (unsigned int i = 0; i < SCREEN_EDGE_NUM; ++i)
4178 {4183 {
4179 if (id == screenEdge[i].id)4184 if (id == screenEdge[i].id)
4180 {4185 {
@@ -4186,9 +4191,9 @@
41864191
4187void4192void
4188CompScreenImpl::warpPointer (int dx,4193CompScreenImpl::warpPointer (int dx,
4189 int dy)4194 int dy)
4190{4195{
4191 XEvent event;4196 XEvent event;
41924197
4193 pointerX += dx;4198 pointerX += dx;
4194 pointerY += dy;4199 pointerY += dy;
@@ -4204,7 +4209,7 @@
4204 pointerY = 0;4209 pointerY = 0;
42054210
4206 XWarpPointer (privateScreen.dpy,4211 XWarpPointer (privateScreen.dpy,
4207 None, privateScreen.rootWindow(),4212 None, privateScreen.rootWindow (),
4208 0, 0, 0, 0,4213 0, 0, 0, 0,
4209 pointerX, pointerY);4214 pointerX, pointerY);
42104215
@@ -4228,17 +4233,11 @@
4228 EnterWindowMask |4233 EnterWindowMask |
4229 PointerMotionMask,4234 PointerMotionMask,
4230 &event))4235 &event))
4231 {4236 if (event.type == EnterNotify &&
4232 if (event.type == EnterNotify)4237 (event.xcrossing.mode != NotifyGrab ||
4233 {4238 event.xcrossing.mode != NotifyUngrab ||
4234 if (event.xcrossing.mode != NotifyGrab ||4239 event.xcrossing.mode != NotifyInferior))
4235 event.xcrossing.mode != NotifyUngrab ||4240 privateScreen.identifyEdgeWindow(event.xcrossing.window);
4236 event.xcrossing.mode != NotifyInferior)
4237 {
4238 privateScreen.identifyEdgeWindow(event.xcrossing.window);
4239 }
4240 }
4241 }
42424241
4243 if (!inHandleEvent)4242 if (!inHandleEvent)
4244 {4243 {
@@ -4250,22 +4249,21 @@
4250CompWindowList &4249CompWindowList &
4251CompScreenImpl::windows ()4250CompScreenImpl::windows ()
4252{4251{
4253 return windowManager.getWindows();4252 return windowManager.getWindows ();
4254}4253}
42554254
4256CompWindowList &4255CompWindowList &
4257CompScreenImpl::serverWindows ()4256CompScreenImpl::serverWindows ()
4258{4257{
4259 return windowManager.getServerWindows();4258 return windowManager.getServerWindows ();
4260}4259}
42614260
4262CompWindowList &4261CompWindowList &
4263CompScreenImpl::destroyedWindows ()4262CompScreenImpl::destroyedWindows ()
4264{4263{
4265 return windowManager.getDestroyedWindows();4264 return windowManager.getDestroyedWindows ();
4266}4265}
42674266
4268
4269Time4267Time
4270CompScreenImpl::getCurrentTime ()4268CompScreenImpl::getCurrentTime ()
4271{4269{
@@ -4379,7 +4377,7 @@
4379 }4377 }
4380 }4378 }
43814379
4382 pendingDestroys--;4380 --pendingDestroys;
4383 }4381 }
4384}4382}
43854383
@@ -4401,7 +4399,6 @@
4401 return privateScreen.fullscreenOutput;4399 return privateScreen.fullscreenOutput;
4402}4400}
44034401
4404
4405XWindowAttributes4402XWindowAttributes
4406CompScreenImpl::attrib ()4403CompScreenImpl::attrib ()
4407{4404{
@@ -4426,27 +4423,28 @@
4426}4423}
44274424
4428CompScreenImpl::CompScreenImpl () :4425CompScreenImpl::CompScreenImpl () :
4429 cps::XWindowInfo(privateScreen.dpy),4426 cps::XWindowInfo (privateScreen.dpy),
4430 below(),4427 below (),
4431 autoRaiseTimer_(),4428 autoRaiseTimer_ (),
4432 autoRaiseWindow_(0),4429 autoRaiseWindow_ (0),
4433 defaultIcon_(0),4430 defaultIcon_ (0),
4434 grabManager (this),4431 grabManager (this),
4435 eventHandled (false),4432 eventHandled (false),
4436 privateScreen(this, windowManager),4433 privateScreen (this, windowManager),
4437 showingDesktopMask_(0)4434 showingDesktopMask_ (0)
4438{4435{
4439 ValueHolder::SetDefault (&valueHolder);4436 ValueHolder::SetDefault (&valueHolder);
44404437
4441 CompPrivate p;4438 CompPrivate p;
4442 CompOption::Value::Vector vList;4439 CompOption::Value::Vector vList;
44434440
4444 privateScreen.setPingTimerCallback(4441 privateScreen.setPingTimerCallback (
4445 boost::bind (&CompScreenImpl::handlePingTimeout, this));4442 boost::bind (&CompScreenImpl::handlePingTimeout, this));
44464443
4447 screenInitalized = true;4444 screenInitalized = true;
44484445
4449 CompPlugin* corePlugin = CompPlugin::load ("core");4446 CompPlugin *corePlugin = CompPlugin::load ("core");
4447
4450 if (!corePlugin)4448 if (!corePlugin)
4451 {4449 {
4452 compLogMessage ("core", CompLogLevelFatal,4450 compLogMessage ("core", CompLogLevelFatal,
@@ -4470,22 +4468,22 @@
4470}4468}
44714469
4472void4470void
4473PrivateScreen::setPlugins(CompOption::Value::Vector const& vList)4471PrivateScreen::setPlugins (CompOption::Value::Vector const &vList)
4474{4472{
4475 pluginManager.setPlugins(vList);4473 pluginManager.setPlugins(vList);
4476}4474}
44774475
4478void4476void
4479PrivateScreen::initPlugins()4477PrivateScreen::initPlugins ()
4480{4478{
4481 pluginManager.setDirtyPluginList ();4479 pluginManager.setDirtyPluginList ();
4482 pluginManager.updatePlugins (screen, optionGetActivePlugins());4480 pluginManager.updatePlugins (screen, optionGetActivePlugins ());
4483}4481}
44844482
4485bool4483bool
4486CompScreenImpl::init (const char *name)4484CompScreenImpl::init (const char *name)
4487{4485{
4488 privateScreen.eventManager.init();4486 privateScreen.eventManager.init ();
44894487
4490 if (privateScreen.initDisplay(name, *this, showingDesktopMask_))4488 if (privateScreen.initDisplay(name, *this, showingDesktopMask_))
4491 {4489 {
@@ -4502,10 +4500,8 @@
4502 privateScreen.optionSetMinimizeWindowKeyInitiate (CompScreenImpl::minimizeWin);4500 privateScreen.optionSetMinimizeWindowKeyInitiate (CompScreenImpl::minimizeWin);
4503 privateScreen.optionSetMinimizeWindowButtonInitiate (CompScreenImpl::minimizeWin);4501 privateScreen.optionSetMinimizeWindowButtonInitiate (CompScreenImpl::minimizeWin);
4504 privateScreen.optionSetMaximizeWindowKeyInitiate (CompScreenImpl::maximizeWin);4502 privateScreen.optionSetMaximizeWindowKeyInitiate (CompScreenImpl::maximizeWin);
4505 privateScreen.optionSetMaximizeWindowHorizontallyKeyInitiate (4503 privateScreen.optionSetMaximizeWindowHorizontallyKeyInitiate (CompScreenImpl::maximizeWinHorizontally);
4506 CompScreenImpl::maximizeWinHorizontally);4504 privateScreen.optionSetMaximizeWindowVerticallyKeyInitiate (CompScreenImpl::maximizeWinVertically);
4507 privateScreen.optionSetMaximizeWindowVerticallyKeyInitiate (
4508 CompScreenImpl::maximizeWinVertically);
45094505
4510 privateScreen.optionSetWindowMenuKeyInitiate (CompScreenImpl::windowMenu);4506 privateScreen.optionSetWindowMenuKeyInitiate (CompScreenImpl::windowMenu);
4511 privateScreen.optionSetWindowMenuButtonInitiate (CompScreenImpl::windowMenu);4507 privateScreen.optionSetWindowMenuButtonInitiate (CompScreenImpl::windowMenu);
@@ -4523,34 +4519,33 @@
45234519
4524 privateScreen.optionSetToggleWindowShadedKeyInitiate (CompScreenImpl::shadeWin);4520 privateScreen.optionSetToggleWindowShadedKeyInitiate (CompScreenImpl::shadeWin);
45254521
4526 privateScreen.initPlugins();4522 privateScreen.initPlugins ();
45274523
4528 if (debugOutput)4524 if (debugOutput)
4529 {4525 {
4530 StackDebugger::SetDefault (4526 StackDebugger::SetDefault (new StackDebugger (dpy (),
4531 new StackDebugger (4527 root (),
4532 dpy (),4528 &privateScreen));
4533 root (),
4534 &privateScreen));
4535 }4529 }
45364530
4537 return true;4531 return true;
4538 }4532 }
4533
4539 return false;4534 return false;
4540}4535}
45414536
4542void4537void
4543cps::EventManager::init ()4538cps::EventManager::init ()
4544{4539{
4545 ctx = Glib::MainContext::get_default ();4540 ctx = Glib::MainContext::get_default ();
4546 mainloop = Glib::MainLoop::create (ctx, false);4541 mainloop = Glib::MainLoop::create (ctx, false);
4547 sighupSource = CompSignalSource::create (SIGHUP, boost::bind (&EventManager::handleSignal, this, _1));4542 sighupSource = CompSignalSource::create (SIGHUP, boost::bind (&EventManager::handleSignal, this, _1));
4548 sigintSource = CompSignalSource::create (SIGINT, boost::bind (&EventManager::handleSignal, this, _1));4543 sigintSource = CompSignalSource::create (SIGINT, boost::bind (&EventManager::handleSignal, this, _1));
4549 sigtermSource = CompSignalSource::create (SIGTERM, boost::bind (&EventManager::handleSignal, this, _1));4544 sigtermSource = CompSignalSource::create (SIGTERM, boost::bind (&EventManager::handleSignal, this, _1));
4550}4545}
45514546
4552bool4547bool
4553CompScreenImpl::displayInitialised() const4548CompScreenImpl::displayInitialised () const
4554{4549{
4555 return privateScreen.initialized;4550 return privateScreen.initialized;
4556}4551}
@@ -4568,31 +4563,31 @@
4568}4563}
45694564
4570void4565void
4571CompScreenImpl::updateClientList()4566CompScreenImpl::updateClientList ()
4572{4567{
4573 privateScreen.updateClientList ();4568 privateScreen.updateClientList ();
4574}4569}
45754570
4576CompWindow *4571CompWindow *
4577CompScreenImpl::getTopWindow() const4572CompScreenImpl::getTopWindow () const
4578{4573{
4579 return windowManager.getTopWindow();4574 return windowManager.getTopWindow ();
4580}4575}
45814576
4582CompWindow *4577CompWindow *
4583CompScreenImpl::getTopServerWindow () const4578CompScreenImpl::getTopServerWindow () const
4584{4579{
4585 return windowManager.getTopServerWindow();4580 return windowManager.getTopServerWindow ();
4586}4581}
45874582
4588CoreOptions&4583CoreOptions &
4589CompScreenImpl::getCoreOptions()4584CompScreenImpl::getCoreOptions ()
4590{4585{
4591 return privateScreen;4586 return privateScreen;
4592}4587}
45934588
4594Colormap4589Colormap
4595CompScreenImpl::colormap() const4590CompScreenImpl::colormap () const
4596{4591{
4597 return privateScreen.colormap;4592 return privateScreen.colormap;
4598}4593}
@@ -4600,11 +4595,11 @@
4600void4595void
4601CompScreenImpl::setCurrentDesktop (unsigned int desktop)4596CompScreenImpl::setCurrentDesktop (unsigned int desktop)
4602{4597{
4603 privateScreen.setCurrentDesktop(desktop);4598 privateScreen.setCurrentDesktop (desktop);
4604}4599}
46054600
4606Window4601Window
4607CompScreenImpl::activeWindow() const4602CompScreenImpl::activeWindow () const
4608{4603{
4609 return privateScreen.orphanData.activeWindow;4604 return privateScreen.orphanData.activeWindow;
4610}4605}
@@ -4612,70 +4607,73 @@
4612void4607void
4613CompScreenImpl::updatePassiveButtonGrabs(Window serverFrame)4608CompScreenImpl::updatePassiveButtonGrabs(Window serverFrame)
4614{4609{
4615 grabManager.updatePassiveButtonGrabs(serverFrame);4610 grabManager.updatePassiveButtonGrabs (serverFrame);
4616}4611}
46174612
4618bool4613bool
4619CompScreenImpl::grabWindowIsNot(Window w) const4614CompScreenImpl::grabWindowIsNot (Window w) const
4620{4615{
4621 return privateScreen.eventManager.notGrabWindow(w);4616 return privateScreen.eventManager.notGrabWindow (w);
4622}4617}
46234618
4624void4619void
4625CompScreenImpl::incrementPendingDestroys()4620CompScreenImpl::incrementPendingDestroys ()
4626{4621{
4627 windowManager.incrementPendingDestroys();4622 windowManager.incrementPendingDestroys ();
4628}4623}
46294624
4630cps::DesktopWindowCount::DesktopWindowCount() :4625cps::DesktopWindowCount::DesktopWindowCount () :
4631count(0)4626count(0)
4632{4627{
4633}4628}
46344629
4635void4630void
4636cps::DesktopWindowCount::incrementDesktopWindowCount()4631cps::DesktopWindowCount::incrementDesktopWindowCount ()
4637{4632{
4638 count++;4633 ++count;
4639}4634}
4640void4635void
4641cps::DesktopWindowCount::decrementDesktopWindowCount()4636cps::DesktopWindowCount::decrementDesktopWindowCount ()
4642{4637{
4643 count--;4638 --count;
4644}4639}
46454640
4646cps::MapNum::MapNum() :4641cps::MapNum::MapNum () :
4647mapNum (1)4642mapNum (1)
4648{4643{
4649}4644}
46504645
4651unsigned int4646unsigned int
4652cps::MapNum::nextMapNum()4647cps::MapNum::nextMapNum ()
4653{4648{
4654 return mapNum++;4649 return mapNum++;
4655}4650}
46564651
4657void4652void
4658CompScreenImpl::setNextActiveWindow(Window id)4653CompScreenImpl::setNextActiveWindow (Window id)
4659{4654{
4660 privateScreen.orphanData.nextActiveWindow = id;4655 privateScreen.orphanData.nextActiveWindow = id;
4661}4656}
4657
4662Window4658Window
4663CompScreenImpl::getNextActiveWindow() const4659CompScreenImpl::getNextActiveWindow () const
4664{4660{
4665 return privateScreen.orphanData.nextActiveWindow;4661 return privateScreen.orphanData.nextActiveWindow;
4666}4662}
46674663
4668namespace4664namespace
4669{4665{
4670void sendStartupMessageToClients (Display *dpy, bool success)4666void
4667sendStartupMessageToClients (Display *dpy,
4668 bool success)
4671{4669{
4672 /* Send a client message indicating that our startup is complete if4670 /* Send a client message indicating that our startup is complete if
4673 * we were asked to do so */4671 * we were asked to do so */
4674 if (sendStartupMessage)4672 if (sendStartupMessage)
4675 {4673 {
4676 Atom startupMessageAtom = XInternAtom (dpy,4674 Atom startupMessageAtom = XInternAtom (dpy,
4677 "_COMPIZ_TESTING_STARTUP",4675 "_COMPIZ_TESTING_STARTUP",
4678 FALSE);4676 FALSE);
4679 XEvent startupMessageEvent;4677 XEvent startupMessageEvent;
4680 Window root = DefaultRootWindow (dpy);4678 Window root = DefaultRootWindow (dpy);
46814679
@@ -4699,11 +4697,13 @@
4699}4697}
4700}4698}
47014699
4702
4703bool4700bool
4704PrivateScreen::initDisplay (const char *name, cps::History& history, unsigned int showingDesktopMask)4701PrivateScreen::initDisplay (const char *name,
4702 cps::History &history,
4703 unsigned int showingDesktopMask)
4705{4704{
4706 dpy = XOpenDisplay (name);4705 dpy = XOpenDisplay (name);
4706
4707 if (!dpy)4707 if (!dpy)
4708 {4708 {
4709 compLogMessage ("core", CompLogLevelFatal,4709 compLogMessage ("core", CompLogLevelFatal,
@@ -4723,13 +4723,14 @@
4723 XSetErrorHandler (errorHandler);4723 XSetErrorHandler (errorHandler);
47244724
4725 snDisplay = sn_display_new (dpy, NULL, NULL);4725 snDisplay = sn_display_new (dpy, NULL, NULL);
4726
4726 if (!snDisplay)4727 if (!snDisplay)
4727 return true;4728 return true;
47284729
4729 if (!xSync.init<XSyncQueryExtension> (dpy))4730 if (!xSync.init<XSyncQueryExtension> (dpy))
4730 {4731 {
4731 compLogMessage ("core", CompLogLevelFatal,4732 compLogMessage ("core", CompLogLevelFatal,
4732 "No sync extension");4733 "No sync extension");
4733 sendStartupMessageToClients (dpy, false);4734 sendStartupMessageToClients (dpy, false);
4734 return false;4735 return false;
4735 }4736 }
@@ -4738,23 +4739,20 @@
4738 xShape.init<XShapeQueryExtension> (dpy);4739 xShape.init<XShapeQueryExtension> (dpy);
47394740
4740 xkbEvent.init<XkbQueryExtension> (dpy);4741 xkbEvent.init<XkbQueryExtension> (dpy);
4742
4741 if (xkbEvent.isEnabled ())4743 if (xkbEvent.isEnabled ())
4742 {
4743 XkbSelectEvents (dpy, XkbUseCoreKbd,4744 XkbSelectEvents (dpy, XkbUseCoreKbd,
4744 XkbBellNotifyMask | XkbStateNotifyMask,4745 XkbBellNotifyMask | XkbStateNotifyMask,
4745 XkbAllEventsMask);4746 XkbAllEventsMask);
4746 }
4747 else4747 else
4748 {
4749 compLogMessage ("core", CompLogLevelFatal,4748 compLogMessage ("core", CompLogLevelFatal,
4750 "No XKB extension");4749 "No XKB extension");
4751 }4750
47524751 int xineramaError, xineramaEvent;
4753 int xineramaError;4752
4754 int xineramaEvent;
4755 xineramaExtension = XineramaQueryExtension (dpy,4753 xineramaExtension = XineramaQueryExtension (dpy,
4756 &xineramaEvent,4754 &xineramaEvent,
4757 &xineramaError);4755 &xineramaError);
47584756
4759 updateScreenInfo ();4757 updateScreenInfo ();
47604758
@@ -4765,9 +4763,8 @@
47654763
4766 Window root_tmp = XRootWindow (dpy, DefaultScreen (dpy));4764 Window root_tmp = XRootWindow (dpy, DefaultScreen (dpy));
47674765
4768
4769 /* Don't select for SubstructureRedirectMask or4766 /* Don't select for SubstructureRedirectMask or
4770 * SubstructureNotifyMask yet since we need to4767 * SubstructureNotifyMask yet, since we need to
4771 * act in complete synchronization here when4768 * act in complete synchronization here when
4772 * doing the initial window init in order to ensure4769 * doing the initial window init in order to ensure
4773 * that windows don't receive invalid stack positions4770 * that windows don't receive invalid stack positions
@@ -4787,11 +4784,11 @@
47874784
4788 /* We need to register for EnterWindowMask |4785 /* We need to register for EnterWindowMask |
4789 * ButtonPressMask | FocusChangeMask on other4786 * ButtonPressMask | FocusChangeMask on other
4790 * root windows as well because focus happens4787 * root windows as well, because focus happens
4791 * on a display level and we need to check4788 * on a display level and we need to check
4792 * if the screen we are running on lost focus */4789 * if the screen, we are running on, lost focus */
47934790
4794 for (int i = 0; i <= ScreenCount (dpy) - 1; i++)4791 for (int i = 0; i <= ScreenCount (dpy) - 1; ++i)
4795 {4792 {
4796 Window rt = XRootWindow (dpy, i);4793 Window rt = XRootWindow (dpy, i);
47974794
@@ -4803,7 +4800,7 @@
4803 SubstructureNotifyMask);4800 SubstructureNotifyMask);
4804 }4801 }
48054802
4806 for (int i = 0; i < SCREEN_EDGE_NUM; i++)4803 for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
4807 {4804 {
4808 screenEdge[i].id = None;4805 screenEdge[i].id = None;
4809 screenEdge[i].count = 0;4806 screenEdge[i].count = 0;
@@ -4816,17 +4813,18 @@
4816 snContext = sn_monitor_context_new (snDisplay, screenNum,4813 snContext = sn_monitor_context_new (snDisplay, screenNum,
4817 compScreenSnEvent, this, NULL);4814 compScreenSnEvent, this, NULL);
48184815
4819 if (!XGetWindowAttributes (dpy, rootWindow(), &attrib))4816 if (!XGetWindowAttributes (dpy, rootWindow (), &attrib))
4820 return false;4817 return false;
48214818
4822 workArea.setWidth (attrib.width);4819 workArea.setWidth (attrib.width);
4823 workArea.setHeight (attrib.height);4820 workArea.setHeight (attrib.height);
48244821
4825 XVisualInfo templ;4822 XVisualInfo templ;
4826 templ.visualid = XVisualIDFromVisual (attrib.visual);4823 templ.visualid = XVisualIDFromVisual (attrib.visual);
48274824
4828 int nvisinfo;4825 int nvisinfo;
4829 XVisualInfo* visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);4826 XVisualInfo *visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
4827
4830 if (!nvisinfo)4828 if (!nvisinfo)
4831 {4829 {
4832 compLogMessage ("core", CompLogLevelFatal,4830 compLogMessage ("core", CompLogLevelFatal,
@@ -4835,7 +4833,7 @@
4835 return false;4833 return false;
4836 }4834 }
48374835
4838 XColor black;4836 XColor black;
4839 black.red = black.green = black.blue = 0;4837 black.red = black.green = black.blue = 0;
48404838
4841 if (!XAllocColor (dpy, colormap, &black))4839 if (!XAllocColor (dpy, colormap, &black))
@@ -4847,8 +4845,9 @@
4847 return false;4845 return false;
4848 }4846 }
48494847
4850 static char data = 0;4848 static char data = 0;
4851 Pixmap bitmap = XCreateBitmapFromData (dpy, rootWindow(), &data, 1, 1);4849 Pixmap bitmap = XCreateBitmapFromData (dpy, rootWindow (), &data, 1, 1);
4850
4852 if (!bitmap)4851 if (!bitmap)
4853 {4852 {
4854 compLogMessage ("core", CompLogLevelFatal,4853 compLogMessage ("core", CompLogLevelFatal,
@@ -4859,7 +4858,7 @@
4859 }4858 }
48604859
4861 invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,4860 invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
4862 &black, &black, 0, 0);4861 &black, &black, 0, 0);
4863 if (!invisibleCursor)4862 if (!invisibleCursor)
4864 {4863 {
4865 compLogMessage ("core", CompLogLevelFatal,4864 compLogMessage ("core", CompLogLevelFatal,
@@ -4960,12 +4959,12 @@
4960 /* Wait for old window manager to go away */4959 /* Wait for old window manager to go away */
4961 if (currentWmSnOwner != None)4960 if (currentWmSnOwner != None)
4962 {4961 {
4963 do {4962 do
4963 {
4964 XWindowEvent (dpy, currentWmSnOwner, StructureNotifyMask, &event);4964 XWindowEvent (dpy, currentWmSnOwner, StructureNotifyMask, &event);
4965 } while (event.type != DestroyNotify);4965 } while (event.type != DestroyNotify);
4966 }4966 }
49674967
4968
4969 /* Server grab from here, we are creating windows */4968 /* Server grab from here, we are creating windows */
49704969
4971 XGrabServer (dpy);4970 XGrabServer (dpy);
@@ -4975,13 +4974,13 @@
4975 attrib.override_redirect = 1;4974 attrib.override_redirect = 1;
4976 attrib.event_mask = PropertyChangeMask;4975 attrib.event_mask = PropertyChangeMask;
49774976
4978 eventManager.createGrabWindow(dpy, rootWindow(), &attrib);4977 eventManager.createGrabWindow(dpy, rootWindow (), &attrib);
49794978
4980 for (int i = 0; i < SCREEN_EDGE_NUM; i++)4979 for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
4981 {4980 {
4982 long xdndVersion = 3;4981 long xdndVersion = 3;
49834982
4984 screenEdge[i].id = XCreateWindow (dpy, rootWindow(),4983 screenEdge[i].id = XCreateWindow (dpy, rootWindow (),
4985 -100, -100, 1, 1, 0,4984 -100, -100, 1, 1, 0,
4986 CopyFromParent, InputOnly,4985 CopyFromParent, InputOnly,
4987 CopyFromParent,4986 CopyFromParent,
@@ -5006,7 +5005,7 @@
50065005
5007 updateScreenEdges ();5006 updateScreenEdges ();
50085007
5009 eventManager.setSupportingWmCheck (dpy, rootWindow());5008 eventManager.setSupportingWmCheck (dpy, rootWindow ());
5010 screen->updateSupportedWmHints ();5009 screen->updateSupportedWmHints ();
50115010
5012 XIGetClientPointer (dpy, None, &clientPointerDeviceId);5011 XIGetClientPointer (dpy, None, &clientPointerDeviceId);
@@ -5021,7 +5020,7 @@
50215020
5022 /* We should get DestroyNotify events for any windows that were5021 /* We should get DestroyNotify events for any windows that were
5023 * destroyed while initializing windows here now */5022 * destroyed while initializing windows here now */
5024 XSelectInput (dpy, rootWindow(), attrib.your_event_mask |5023 XSelectInput (dpy, rootWindow (), attrib.your_event_mask |
5025 SubstructureRedirectMask | SubstructureNotifyMask);5024 SubstructureRedirectMask | SubstructureNotifyMask);
50265025
5027 if (CompScreenImpl::checkForError (dpy))5026 if (CompScreenImpl::checkForError (dpy))
@@ -5038,12 +5037,12 @@
5038 }5037 }
50395038
5040 wmSnSelectionWindow = newWmSnOwner;5039 wmSnSelectionWindow = newWmSnOwner;
5041 this->wmSnTimestamp = wmSnTimestamp;5040 this->wmSnTimestamp = wmSnTimestamp;
50425041
5043 Window rootReturn, parentReturn;5042 Window rootReturn, parentReturn;
5044 Window *children;5043 Window *children;
5045 unsigned int nchildren;5044 unsigned int nchildren;
5046 XQueryTree (dpy, rootWindow(),5045 XQueryTree (dpy, rootWindow (),
5047 &rootReturn, &parentReturn,5046 &rootReturn, &parentReturn,
5048 &children, &nchildren);5047 &children, &nchildren);
50495048
@@ -5052,7 +5051,7 @@
50525051
5053 /* Start initializing windows here */5052 /* Start initializing windows here */
50545053
5055 for (unsigned int i = 0; i < nchildren; i++)5054 for (unsigned int i = 0; i < nchildren; ++i)
5056 {5055 {
5057 XWindowAttributes attrib;5056 XWindowAttributes attrib;
50585057
@@ -5073,7 +5072,7 @@
5073 * using list last sent to server5072 * using list last sent to server
5074 i = 0;5073 i = 0;
5075 for (CompWindowList::reverse_iterator rit = serverWindows.rbegin ();5074 for (CompWindowList::reverse_iterator rit = serverWindows.rbegin ();
5076 rit != serverWindows.rend (); rit++)5075 rit != serverWindows.rend (); ++rit)
5077 children[i++] = ROOTPARENT ((*rit));5076 children[i++] = ROOTPARENT ((*rit));
50785077
5079 XRestackWindows (dpy, children, i);5078 XRestackWindows (dpy, children, i);
@@ -5082,23 +5081,20 @@
50825081
5083 windowManager.setWindowActiveness(history);5082 windowManager.setWindowActiveness(history);
50845083
5085 Window focus;5084 Window focus;
5086 int revertTo;5085 int revertTo;
5087 XGetInputFocus (dpy, &focus, &revertTo);5086 XGetInputFocus (dpy, &focus, &revertTo);
50885087
5089 /* move input focus to root window so that we get a FocusIn event when5088 /* move input focus to root window so that we get a FocusIn event when
5090 moving it to the default window */5089 moving it to the default window */
5091 XSetInputFocus (dpy, rootWindow(), RevertToPointerRoot, CurrentTime);5090 XSetInputFocus (dpy, rootWindow (), RevertToPointerRoot, CurrentTime);
50925091
5093 if (focus == None || focus == PointerRoot)5092 if (focus == None || focus == PointerRoot)
5094 {
5095 screen->focusDefaultWindow ();5093 screen->focusDefaultWindow ();
5096 }
5097 else5094 else
5098 {5095 {
5099 CompWindow *w;5096 CompWindow *w = screen->findWindow (focus);
51005097
5101 w = screen->findWindow (focus);
5102 if (w)5098 if (w)
5103 w->moveInputFocusTo ();5099 w->moveInputFocusTo ();
5104 else5100 else
@@ -5120,6 +5116,7 @@
5120 * screens from option changes */5116 * screens from option changes */
5121 bool init_succeeded = CompPlugin::screenInitPlugins (screen);5117 bool init_succeeded = CompPlugin::screenInitPlugins (screen);
5122 assert (init_succeeded);5118 assert (init_succeeded);
5119
5123 if (!init_succeeded)5120 if (!init_succeeded)
5124 return false;5121 return false;
51255122
@@ -5131,9 +5128,9 @@
51315128
5132 setAudibleBell (optionGetAudibleBell ());5129 setAudibleBell (optionGetAudibleBell ());
51335130
51345131 /* TODO: just query optionGetPingDelay () once */
5135 pingTimer.setTimes (optionGetPingDelay (),5132 pingTimer.setTimes (optionGetPingDelay (),
5136 optionGetPingDelay () + 500);5133 optionGetPingDelay () + 500);
51375134
5138 pingTimer.start ();5135 pingTimer.start ();
51395136
@@ -5146,8 +5143,8 @@
5146{5143{
5147 privateScreen.startupSequence.removeAllSequences ();5144 privateScreen.startupSequence.removeAllSequences ();
51485145
5149 while (!windowManager.getWindows().empty ())5146 while (!windowManager.getWindows ().empty ())
5150 delete windowManager.getWindows().front ();5147 delete windowManager.getWindows ().front ();
51515148
5152 while (CompPlugin* p = CompPlugin::pop ())5149 while (CompPlugin* p = CompPlugin::pop ())
5153 CompPlugin::unload (p);5150 CompPlugin::unload (p);
@@ -5159,110 +5156,134 @@
5159}5156}
51605157
5161cps::GrabManager::GrabManager (CompScreen *screen) :5158cps::GrabManager::GrabManager (CompScreen *screen) :
5162 screen(screen),5159 screen (screen),
5163 currentState(0),5160 currentState (0),
5164 buttonGrabs (),5161 buttonGrabs (),
5165 keyGrabs ()5162 keyGrabs ()
5166{5163{
5167}5164}
51685165
5169cps::ViewPort::ViewPort() :5166cps::ViewPort::ViewPort () :
5170 vp (0, 0),5167 vp (0, 0),
5171 vpSize (1, 1)5168 vpSize (1, 1)
5172{5169{
5173}5170}
51745171
5175cps::StartupSequence::StartupSequence() :5172cps::StartupSequence::StartupSequence () :
5176 startupSequences (),5173 startupSequences (),
5177 startupSequenceTimer ()5174 startupSequenceTimer ()
5178{5175{
5179 startupSequenceTimer.setCallback (5176 startupSequenceTimer.setCallback (
5180 boost::bind (&cps::StartupSequence::handleStartupSequenceTimeout, this));5177 boost::bind (&cps::StartupSequence::handleStartupSequenceTimeout, this));
5178
5179 /* TODO: Magic number alert */
5181 startupSequenceTimer.setTimes (1000, 1500);5180 startupSequenceTimer.setTimes (1000, 1500);
5182}5181}
51835182
5184PrivateScreen::PrivateScreen (CompScreen *screen, cps::WindowManager& windowManager) :5183PrivateScreen::PrivateScreen (CompScreen *screen, cps::WindowManager& windowManager) :
5185 CoreOptions(false),5184 CoreOptions (false),
5186 dpy (NULL),5185 dpy (NULL),
5187 startupSequence(this),5186 xSync (),
5187 xRandr (),
5188 xShape (),
5189 viewPort (),
5190 startupSequence (this),
5188 eventManager (),5191 eventManager (),
5192 orphanData (),
5193 outputDevices (),
5194 colormap (),
5195 screenNum (0),
5189 nDesktop (1),5196 nDesktop (1),
5190 currentDesktop (0),5197 currentDesktop (0),
5198 fullscreenOutput (),
5199 screenEdge (),
5191 wmSnSelectionWindow (None),5200 wmSnSelectionWindow (None),
5192 clientPointerDeviceId (None),5201 clientPointerDeviceId (None),
5193 normalCursor (None),5202 normalCursor (None),
5194 busyCursor (None),5203 busyCursor (None),
5195 invisibleCursor (None),5204 invisibleCursor (None),
5205 workArea (),
5196 initialized (false),5206 initialized (false),
5197 screen(screen),5207 screen (screen),
5208 xkbEvent (),
5209 xineramaExtension (false),
5198 screenInfo (),5210 screenInfo (),
5199 snDisplay(0),5211 snDisplay (0),
5200 root(None),5212 displayString_ (),
5213 escapeKeyCode (),
5214 returnKeyCode (),
5215 region (),
5216 root (None),
5217 attrib (),
5201 snContext (0),5218 snContext (0),
5202 wmSnAtom (None),5219 wmSnAtom (None),
5220 wmSnTimestamp (0),
5203 desktopHintData (0),5221 desktopHintData (0),
5204 desktopHintSize (0),5222 desktopHintSize (0),
5205 edgeWindow (None),5223 edgeWindow (None),
5224 pingTimer (),
5206 edgeDelayTimer (),5225 edgeDelayTimer (),
5226 edgeDelaySettings (),
5207 xdndWindow (None),5227 xdndWindow (None),
5208 windowManager(windowManager)5228 pluginManager (),
5229 windowManager (windowManager)
5209{5230{
5210 for (int i = 0; i < SCREEN_EDGE_NUM; i++)5231 for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
5211 {5232 {
5212 screenEdge[i].id = None;5233 screenEdge[i].id = None;
5213 screenEdge[i].count = 0;5234 screenEdge[i].count = 0;
5214 }5235 }
5215
5216}5236}
52175237
5218cps::History::History() :5238cps::History::History () :
5219 currentHistory_(0),5239 currentHistory_(0),
5220 activeNum_ (1)5240 activeNum_ (1)
5221{5241{
5222 memset (history, 0, sizeof history);5242 memset (history, 0, sizeof history);
5223}5243}
52245244
5225cps::WindowManager::WindowManager() :5245cps::WindowManager::WindowManager () :
5226 windows (),5246 windows (),
5227 serverWindows (),5247 serverWindows (),
5228 destroyedWindows (),5248 destroyedWindows (),
5229 stackIsFresh (false),5249 stackIsFresh (false),
5230 groups (0),5250 groups (0),
5231 pendingDestroys (0),5251 pendingDestroys (0),
5232 lastFoundWindow(0)5252 lastFoundWindow (0)
5233{5253{
5234}5254}
52355255
5236cps::PluginManager::PluginManager() :5256cps::PluginManager::PluginManager () :
5237 plugin (),5257 plugin (),
5238 dirtyPluginList (true)5258 dirtyPluginList (true)
5239{5259{
5240}5260}
52415261
5242cps::EventManager::EventManager () :5262cps::EventManager::EventManager () :
5243 possibleTap(NULL),5263 possibleTap (NULL),
5244 source(0),5264 source (0),
5245 timeout(0),5265 timeout (0),
5246 sighupSource(0),5266 sighupSource (0),
5247 sigtermSource(0),5267 sigtermSource (0),
5248 sigintSource(0),5268 sigintSource (0),
5249 fileWatch (0),5269 fileWatch (0),
5250 lastFileWatchHandle (1),5270 lastFileWatchHandle (1),
5251 watchFds (0),5271 watchFds (0),
5252 lastWatchFdHandle (1),5272 lastWatchFdHandle (1),
5273 grabbed (false),
5253 grabWindow (None)5274 grabWindow (None)
5254{5275{
5255 TimeoutHandler *dTimeoutHandler = new TimeoutHandler ();5276 TimeoutHandler *dTimeoutHandler = new TimeoutHandler ();
5256 TimeoutHandler::SetDefault (dTimeoutHandler);5277 TimeoutHandler::SetDefault (dTimeoutHandler);
5257}5278}
52585279
5259cps::OrphanData::OrphanData() :5280cps::OrphanData::OrphanData () :
5260 activeWindow (0),5281 activeWindow (0),
5261 nextActiveWindow(0)5282 nextActiveWindow(0)
5262{5283{
5263}5284}
52645285
5265cps::OrphanData::~OrphanData()5286cps::OrphanData::~OrphanData ()
5266{5287{
5267}5288}
52685289
@@ -5275,16 +5296,15 @@
5275 * See LP: #1085590 */5296 * See LP: #1085590 */
5276 g_source_destroy (timeout->gobj ());5297 g_source_destroy (timeout->gobj ());
5277 }5298 }
5299
5278 delete sigintSource;5300 delete sigintSource;
5279 delete sigtermSource;5301 delete sigtermSource;
5280 delete sighupSource;5302 delete sighupSource;
52815303
5282 /* Not guaranteed to be created by EventManager's constructor */5304 /* Not guaranteed to be created by EventManager's constructor */
5283 if (source)5305 if (source)
5284 {
5285 /* This will implicitly call ~CompEventSource */5306 /* This will implicitly call ~CompEventSource */
5286 g_source_destroy (source->gobj ());5307 g_source_destroy (source->gobj ());
5287 }
52885308
5289 /* This will implicitly call ~CompWatchFd */5309 /* This will implicitly call ~CompWatchFd */
5290 foreach (CompWatchFd *fd, watchFds)5310 foreach (CompWatchFd *fd, watchFds)
@@ -5302,11 +5322,12 @@
53025322
5303 if (dpy != NULL)5323 if (dpy != NULL)
5304 {5324 {
5305 XUngrabKey (dpy, AnyKey, AnyModifier, rootWindow());5325 XUngrabKey (dpy, AnyKey, AnyModifier, rootWindow ());
53065326
5307 for (int i = 0; i < SCREEN_EDGE_NUM; i++)5327 for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
5308 {5328 {
5309 Window id = screenEdge[i].id;5329 Window id = screenEdge[i].id;
5330
5310 if (id != None)5331 if (id != None)
5311 XDestroyWindow (dpy, id);5332 XDestroyWindow (dpy, id);
5312 }5333 }
@@ -5340,7 +5361,7 @@
5340 * windows5361 * windows
5341 */5362 */
53425363
5343 XSync (dpy, False); // Redundant?5364 XSync (dpy, False); // TODO: Redundant?
5344 XCloseDisplay (dpy);5365 XCloseDisplay (dpy);
5345 }5366 }
53465367

Subscribers

People subscribed via source and target branches

to all changes: