| Home · All Namespaces · All Classes |
#include <switcher.h>


Public Slots | |
| void | handleWindowInfoList (QList< WindowInfo > newWindowList) |
Signals | |
| void | windowListUpdated (const QList< WindowInfo > &windowList) |
| A signal for notifying that the window list has been updated. | |
| void | animationStateChanged (bool animating) |
Public Member Functions | |
| Switcher (const WindowMonitor *windowMonitor=NULL, MWidget *parent=NULL) | |
| ~Switcher () | |
| bool | handleXEvent (const XEvent &event) |
Protected Member Functions | |
| virtual bool | sceneEvent (QEvent *event) |
| REIMPLEMENTATION | |
Switcher is a widget that shows the available windows.
Definition at line 34 of file switcher.h.
| Switcher::Switcher | ( | const WindowMonitor * | windowMonitor = NULL, |
|
| MWidget * | parent = NULL | |||
| ) |
Constructs a Switcher widget.
| windowMonitor | a window monitor instance to be used by this switcher. Switcher takes ownership of the window monitor passed in. | |
| parent | the parent widget of the Switcher, defaults to NULL |
Definition at line 35 of file switcher.cpp.
:
MWidgetController(new SwitcherModel, parent),
windowMonitor(windowMonitor)
{
if (this->windowMonitor == NULL) {
this->windowMonitor = new HomeWindowMonitor;
}
// Get the X11 Atoms for closing and activating a window and for other switcher functionalities
Display *display = QX11Info::display();
closeWindowAtom = X11Wrapper::XInternAtom(display, "_NET_CLOSE_WINDOW", False);
activeWindowAtom = X11Wrapper::XInternAtom(display, "_NET_ACTIVE_WINDOW", False);
clientListAtom = X11Wrapper::XInternAtom(display, "_NET_CLIENT_LIST", False);
netWindowNameAtom = X11Wrapper::XInternAtom(display, "_NET_WM_NAME", False);
windowNameAtom = X11Wrapper::XInternAtom(display, "WM_NAME", False);
// Put the atoms for window types that should be excluded from the switcher into a list
excludeAtoms.insert(WindowInfo::DesktopAtom);
excludeAtoms.insert(WindowInfo::MenuAtom);
excludeAtoms.insert(WindowInfo::DockAtom);
excludeAtoms.insert(WindowInfo::DialogAtom);
excludeAtoms.insert(WindowInfo::NotificationAtom);
excludeAtoms.insert(WindowInfo::SkipTaskbarAtom);
excludeAtoms.insert(WindowInfo::InputWindowAtom);
// Configure the update buttons timer
updateButtonsTimer.setSingleShot(true);
updateButtonsTimer.setInterval(UPDATE_DELAY_MS);
connect(&updateButtonsTimer, SIGNAL(timeout()), this, SLOT(updateButtons()));
connect(this->windowMonitor, SIGNAL(windowStackingOrderChanged(QList<WindowInfo>)),
this, SLOT(handleWindowInfoList(QList<WindowInfo>)));
// This stuff is necessary to receive touch events
setAcceptTouchEvents(true);
grabGesture(Qt::PinchGesture);
}

| Switcher::~Switcher | ( | ) |
| void Switcher::animationStateChanged | ( | bool | animating | ) | [signal] |
Sent when something starts or stops animating in switcher
| animating | if true, something is animating |
| void Switcher::handleWindowInfoList | ( | QList< WindowInfo > | newWindowList | ) | [slot] |
Gets the current stacked client window list as parameter and checks whether new windows are added or removed. Adds and removes such windows from the switcher and emits the updated stacked window list.
| newWindowList | QList<WindowInfo> that contains all windows in stacking order |
Definition at line 222 of file switcher.cpp.
{
foreach(WindowInfo wi, newWindowList) {
if (!isRelevantWindow(wi.window())) {
newWindowList.removeOne(wi);
}
}
QSet<WindowInfo> newWindowSet = newWindowList.toSet() - windowsInfoBeingClosed;
QSet<WindowInfo> oldWindowSet = windowInfoSet;
QSet<WindowInfo> closedWindowSet = oldWindowSet - newWindowSet;
QSet<WindowInfo> openedWindowSet = newWindowSet - oldWindowSet;
windowsInfoBeingClosed -= closedWindowSet;
bool added = addWindowsInfo(openedWindowSet);
bool removed = removeWindows(closedWindowSet);
// The stacking order needs to be cleared out before we start updating the
// buttons as the topmostWindow is set in the 'updateButtons()' method and
// the method call is scheduled with a timer in the case of an addition
QList<WindowInfo> stackingWindowList;
foreach (WindowInfo window, newWindowList) {
if (!windowsInfoBeingClosed.contains(window)) {
stackingWindowList.append(window);
}
}
if (!stackingWindowList.isEmpty()){
topmostWindow = stackingWindowList.last().window();
}
if (added || removed) {
if (!removed) {
// If windows have been added but not removed, update the switcher with a delay
scheduleUpdateButtons();
} else {
// If windows have been removed update the switcher instantly
updateButtons();
}
} else if (!stackingWindowList.isEmpty()) {
if (!windowMonitor->isOwnWindow(topmostWindow)) {
// The view might also need to react (== pan to the correct page) if no buttons were added
// but the stacking order was changed, i.e. due to app chaining or some other activity
model()->setTopmostWindow(topmostWindow);
}
}
}

| bool Switcher::handleXEvent | ( | const XEvent & | event | ) | [virtual] |
Handles an X event if it is related to the Switcher.
| event | the XEvent to be handled |
true if the event was handled, false otherwise Implements XEventListener.
Definition at line 79 of file switcher.cpp.
{
bool eventWasHandled = false;
if (event.type == CreateNotify) {
// A window has been created so add it to the switcher if it has not been added already
if (isRelevantWindow(event.xcreatewindow.window)
&& addWindowInfo(WindowInfo(event.xcreatewindow.window))) {
scheduleUpdateButtons();
}
eventWasHandled = true;
} else if (event.type == DestroyNotify) {
// A window has been destroyed so completely remove it from the switcher
if (removeWindowInfo(WindowInfo(event.xdestroywindow.window))) {
// Update the switcher buttons instantly
updateButtons();
}
eventWasHandled = true;
} else if (event.type == PropertyNotify) {
if (event.xproperty.atom == WindowInfo::TypeAtom || event.xproperty.atom == WindowInfo::StateAtom || event.xproperty.atom == XA_WM_TRANSIENT_FOR) {
// The type, state or transiency of a window has changed so update that window's properties
updateWindowProperties(event.xproperty.window);
eventWasHandled = true;
} else if (event.xproperty.atom == windowNameAtom || event.xproperty.atom == netWindowNameAtom) {
// The title of a window has changed so update that window's title
updateWindowTitle(event.xproperty.window);
eventWasHandled = true;
}
} else if (event.type == ClientMessage && event.xclient.message_type == closeWindowAtom) {
// A _NET_CLOSE_WINDOW message was caught so a window is being closed; add it to windows being closed list
markWindowBeingClosed(event.xclient.window);
eventWasHandled = true;
}
return eventWasHandled;
}
| bool Switcher::sceneEvent | ( | QEvent * | event | ) | [protected, virtual] |
REIMPLEMENTATION
When QEvent::TouchEnd event arrives, stops the Switcher from being an event filter for the SwitcherButtons
Definition at line 271 of file switcher.cpp.
{
bool handled = false;
if (event->type() == QEvent::TouchEnd) {
foreach (const QSharedPointer<SwitcherButton> &button, model()->buttons()) {
button->removeSceneEventFilter(this);
}
handled = true;
}
return handled || MWidgetController::sceneEvent(event);
}
| void Switcher::windowListUpdated | ( | const QList< WindowInfo > & | windowList | ) | [signal] |
A signal for notifying that the window list has been updated.
| Copyright © 2010 Nokia Corporation | Generated on Thu Nov 4 2010 18:20:42 Doxygen 1.7.1 |
MeeGo Touch |