15
15
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
16
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECI<<<<<fAL, INDIRECT OR
17
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
18
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
19
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
20
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
625
PrivateScreen::queueEvents ()
627
std::list <XEvent> events;
629
while (XPending (dpy))
631
XEvent event, peekEvent;
632
XNextEvent (dpy, &event);
634
/* Skip to the last MotionNotify
635
* event in this sequence */
636
if (event.type == MotionNotify)
638
while (XPending (dpy))
640
XPeekEvent (dpy, &peekEvent);
642
if (peekEvent.type != MotionNotify)
645
XNextEvent (dpy, &event);
649
events.push_back (event);
624
656
PrivateScreen::processEvents ()
626
XEvent event, peekEvent;
628
/* remove destroyed windows */
658
std::list <XEvent> events;
659
StackDebugger *dbg = StackDebugger::Default ();
631
661
if (dirtyPluginList)
632
662
updatePlugins ();
634
while (XPending (dpy))
636
XNextEvent (dpy, &event);
664
/* Restacks recently processed, ensure that
665
* plugins use the stack last received from
669
priv->serverWindows.clear ();
671
foreach (CompWindow *sw, priv->windows)
673
sw->serverPrev = sw->prev;
674
sw->serverNext = sw->next;
675
priv->serverWindows.push_back (sw);
681
dbg->windowsChanged (false);
682
dbg->serverWindowsChanged (false);
683
events = dbg->loadStack (priv->serverWindows);
686
events = queueEvents ();
688
stackIsFresh = false;
690
foreach (XEvent &event, events)
638
692
switch (event.type) {
639
693
case ButtonPress:
640
694
case ButtonRelease:
647
701
pointerX = event.xkey.x_root;
648
702
pointerY = event.xkey.y_root;
649
pointerMods = event.xbutton.state;
703
pointerMods = event.xkey.state;
651
705
case MotionNotify:
652
while (XPending (dpy))
654
XPeekEvent (dpy, &peekEvent);
656
if (peekEvent.type != MotionNotify)
659
XNextEvent (dpy, &event);
662
707
pointerX = event.xmotion.x_root;
663
708
pointerY = event.xmotion.y_root;
664
pointerMods = event.xbutton.state;
709
pointerMods = event.xmotion.state;
666
711
case EnterNotify:
667
712
case LeaveNotify:
668
713
pointerX = event.xcrossing.x_root;
669
714
pointerY = event.xcrossing.y_root;
670
pointerMods = event.xbutton.state;
715
pointerMods = event.xcrossing.state;
672
717
case ClientMessage:
673
718
if (event.xclient.message_type == Atoms::xdndPosition)
707
752
lastPointerY = pointerY;
708
753
lastPointerMods = pointerMods;
756
/* remove destroyed windows */
761
if (dbg->windowsChanged () && dbg->cmpStack (priv->windows, priv->serverWindows))
763
compLogMessage ("core", CompLogLevelDebug, "stacks are out of sync");
764
if (dbg->timedOut ())
765
compLogMessage ("core", CompLogLevelDebug, "however, this may be a false positive");
768
if (dbg->serverWindowsChanged () && dbg->checkSanity (priv->serverWindows))
769
compLogMessage ("core", CompLogLevelDebug, "windows are stacked incorrectly");
2635
CompScreen::insertServerWindow (CompWindow *w, Window aboveId)
2637
StackDebugger *dbg = StackDebugger::Default ();
2640
dbg->serverWindowsChanged (true);
2642
w->serverPrev = NULL;
2643
w->serverNext = NULL;
2645
if (!aboveId || priv->serverWindows.empty ())
2647
if (!priv->serverWindows.empty ())
2649
priv->serverWindows.front ()->serverPrev = w;
2650
w->serverNext = priv->serverWindows.front ();
2652
priv->serverWindows.push_front (w);
2657
CompWindowList::iterator it = priv->serverWindows.begin ();
2659
while (it != priv->serverWindows.end ())
2661
if ((*it)->priv->serverId == aboveId ||
2662
((*it)->priv->serverFrame && (*it)->priv->serverFrame == aboveId))
2669
if (it == priv->serverWindows.end ())
2671
compLogMessage ("core", CompLogLevelDebug, "could not insert 0x%x above 0x%x",
2672
(unsigned int) (*it)->priv->serverId, aboveId);
2679
w->serverNext = (*it)->serverNext;
2680
w->serverPrev = (*it);
2681
(*it)->serverNext = w;
2685
w->serverNext->serverPrev = w;
2688
priv->serverWindows.insert (++it, w);
2565
2692
PrivateScreen::eraseWindowFromMap (Window id)
2590
2722
lastFoundWindow = NULL;
2726
CompScreen::unhookServerWindow (CompWindow *w)
2728
StackDebugger *dbg = StackDebugger::Default ();
2731
dbg->serverWindowsChanged (true);
2733
CompWindowList::iterator it =
2734
std::find (priv->serverWindows.begin (), priv->serverWindows.end (), w);
2736
priv->serverWindows.erase (it);
2739
w->serverNext->serverPrev = w->serverPrev;
2742
w->serverPrev->serverNext = w->serverNext;
2744
w->serverNext = NULL;
2745
w->serverPrev = NULL;
2594
2749
CompScreen::normalCursor ()
4325
4494
if (CompScreen::checkForError (dpy))
4327
4496
compLogMessage ("core", CompLogLevelError,
4328
"Another window manager is "
4329
"already running on screen: %d", DefaultScreen (dpy));
4497
"Another window manager is "
4498
"already running on screen: %d", DefaultScreen (dpy));
4331
4500
XUngrabServer (dpy);
4335
/* We only care about windows we're not going to
4336
* get a CreateNotify for later, so query the tree
4337
* here, init plugin screens, and then init windows */
4339
XQueryTree (dpy, root,
4340
&rootReturn, &parentReturn,
4341
&children, &nchildren);
4343
4505
for (i = 0; i < SCREEN_EDGE_NUM; i++)
4345
4507
priv->screenEdge[i].id = None;
4432
4594
priv->screenEdge[i].id = XCreateWindow (dpy, priv->root,
4433
4595
-100, -100, 1, 1, 0,
4434
CopyFromParent, InputOnly,
4596
CopyFromParent, InputOnly,
4436
4598
CWOverrideRedirect,
4439
4601
XChangeProperty (dpy, priv->screenEdge[i].id, Atoms::xdndAware,
4440
4602
XA_ATOM, 32, PropModeReplace,
4462
4625
XDefineCursor (dpy, priv->root, priv->normalCursor);
4627
/* We should get DestroyNotify events for any windows that were
4628
* destroyed while initializing windows here now */
4629
XSelectInput (dpy, root, priv->attrib.your_event_mask |
4630
SubstructureRedirectMask | SubstructureNotifyMask);
4632
XQueryTree (dpy, root,
4633
&rootReturn, &parentReturn,
4634
&children, &nchildren);
4464
4636
XUngrabServer (dpy);
4465
4637
XSync (dpy, FALSE);
4467
priv->setAudibleBell (priv->optionGetAudibleBell ());
4469
priv->pingTimer.setTimes (priv->optionGetPingDelay (),
4470
priv->optionGetPingDelay () + 500);
4472
priv->pingTimer.start ();
4474
priv->addScreenActions ();
4476
/* Need to set a default here so that the value isn't uninitialized
4477
* when loading plugins FIXME: Should find a way to initialize options
4478
* first and then set this value, or better yet, tie this value directly
4480
priv->vpSize.setWidth (priv->optionGetHsize ());
4481
priv->vpSize.setHeight (priv->optionGetVsize ());
4483
priv->initialized = true;
4485
/* TODO: Bailout properly when screenInitPlugins fails
4486
* TODO: It would be nicer if this line could mean
4487
* "init all the screens", but unfortunately it only inits
4488
* plugins loaded on the command line screen's and then
4489
* we need to call updatePlugins () to init the remaining
4490
* screens from option changes */
4491
assert (CompPlugin::screenInitPlugins (this));
4493
/* The active plugins list might have been changed - load any
4496
priv->vpSize.setWidth (priv->optionGetHsize ());
4497
priv->vpSize.setHeight (priv->optionGetVsize ());
4499
if (priv->dirtyPluginList)
4500
priv->updatePlugins ();
4502
4639
/* Start initializing windows here */
4504
4641
for (unsigned int i = 0; i < nchildren; i++)
4506
4643
XWindowAttributes attrib;
4508
/* Failure means the window has been destroyed, but
4509
* still add it to the window list anyways since we
4510
* will soon handle the DestroyNotify event for it
4511
* and in between CreateNotify time and DestroyNotify
4512
* time there might be ConfigureRequests asking us
4513
* to stack windows relative to it
4645
/* Failure means the window has been destroyed, do not
4646
* manage this window since we will not receive a DestroyNotify
4516
4650
if (!XGetWindowAttributes (screen->dpy (), children[i], &attrib))
4517
priv->setDefaultWindowAttributes (&attrib);
4651
priv->setDefaultWindowAttributes(&attrib);
4519
CoreWindow *cw = new CoreWindow (children[i]);
4653
CoreWindow *cw = new CoreWindow (children[i]);
4520
4654
cw->manage (i ? children[i - 1] : 0, attrib);
4522
4656
priv->createdWindows.remove (cw);
4528
/* enforce restack on all windows */
4530
for (CompWindowList::reverse_iterator rit = priv->windows.rbegin ();
4531
rit != priv->windows.rend (); rit++)
4532
children[i++] = (*rit)->id ();
4659
/* enforce restack on all windows
4660
* using list last sent to server
4662
for (CompWindowList::reverse_iterator rit = priv->serverWindows.rbegin ();
4663
rit != priv->serverWindows.rend (); rit++)
4664
children[i++] = ROOTPARENT ((*rit));
4534
4666
XRestackWindows (dpy, children, i);
4536
4668
XFree (children);
4538
4670
foreach (CompWindow *w, priv->windows)
4562
4694
focusDefaultWindow ();
4697
/* Need to set a default here so that the value isn't uninitialized
4698
* when loading plugins FIXME: Should find a way to initialize options
4699
* first and then set this value, or better yet, tie this value directly
4701
priv->vpSize.setWidth (priv->optionGetHsize ());
4702
priv->vpSize.setHeight (priv->optionGetVsize ());
4704
priv->initialized = true;
4706
/* TODO: Bailout properly when screenInitPlugins fails
4707
* TODO: It would be nicer if this line could mean
4708
* "init all the screens", but unfortunately it only inits
4709
* plugins loaded on the command line screen's and then
4710
* we need to call updatePlugins () to init the remaining
4711
* screens from option changes */
4712
assert (CompPlugin::screenInitPlugins (this));
4714
/* The active plugins list might have been changed - load any
4717
priv->vpSize.setWidth (priv->optionGetHsize ());
4718
priv->vpSize.setHeight (priv->optionGetVsize ());
4720
priv->setAudibleBell (priv->optionGetAudibleBell ());
4722
priv->pingTimer.setTimes (priv->optionGetPingDelay (),
4723
priv->optionGetPingDelay () + 500);
4725
priv->pingTimer.start ();
4727
priv->addScreenActions ();
4729
if (priv->dirtyPluginList)
4730
priv->updatePlugins ();