| Home · All Namespaces · All Classes |
00001 /*************************************************************************** 00002 ** 00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 00004 ** All rights reserved. 00005 ** Contact: Nokia Corporation (directui@nokia.com) 00006 ** 00007 ** This file is part of mhome. 00008 ** 00009 ** If you have questions regarding the use of this file, please contact 00010 ** Nokia at directui@nokia.com. 00011 ** 00012 ** This library is free software; you can redistribute it and/or 00013 ** modify it under the terms of the GNU Lesser General Public 00014 ** License version 2.1 as published by the Free Software Foundation 00015 ** and appearing in the file LICENSE.LGPL included in the packaging 00016 ** of this file. 00017 ** 00018 ****************************************************************************/ 00019 00020 #include <MApplication> 00021 #include <MWindow> 00022 #include "homewindowmonitor.h" 00023 #include "x11wrapper.h" 00024 00025 HomeWindowMonitor::HomeWindowMonitor() : 00026 nonFullscreenApplicationWindowTypes(QSet<Atom>() << WindowInfo::NotificationAtom << 00027 WindowInfo::DialogAtom << 00028 WindowInfo::MenuAtom), 00029 netClientListStacking(X11Wrapper::XInternAtom(QX11Info::display(), "_NET_CLIENT_LIST_STACKING", False)) 00030 { 00031 } 00032 00033 HomeWindowMonitor::~HomeWindowMonitor() 00034 { 00035 } 00036 00037 bool HomeWindowMonitor::isOwnWindow(WId wid) const 00038 { 00039 foreach (MWindow *window, MApplication::windows()) { 00040 if (window->winId() == wid) { 00041 return true; 00042 } 00043 } 00044 00045 return false; 00046 } 00047 00048 bool HomeWindowMonitor::handleXEvent(const XEvent& event) 00049 { 00050 bool eventHandled = false; 00051 00052 if (event.type == PropertyNotify && event.xproperty.atom == netClientListStacking && event.xproperty.window == DefaultRootWindow(QX11Info::display())) { 00053 int numWindowStackingOrderReceivers = receivers(SIGNAL(windowStackingOrderChanged(QList<WindowInfo>))); 00054 int numFullscreenWindowReceivers = receivers(SIGNAL(fullscreenWindowOnTopOfOwnWindow())); 00055 00056 if (numWindowStackingOrderReceivers + numFullscreenWindowReceivers > 0) { 00057 QList<Window> windowOrder = windowStackingOrder(); 00058 00059 if (numWindowStackingOrderReceivers > 0) { 00060 QList<WindowInfo> windowStackingList; 00061 foreach (Window window, windowOrder) { 00062 windowStackingList.append(WindowInfo(window)); 00063 } 00064 00065 emit windowStackingOrderChanged(windowStackingList); 00066 } 00067 00068 if (numFullscreenWindowReceivers > 0) { 00069 if (!windowOrder.isEmpty()) { 00070 QListIterator<Window> iter(windowOrder); 00071 iter.toBack(); 00072 while (iter.hasPrevious()) { 00073 WindowInfo windowInfo(iter.previous()); 00074 if (windowInfo.types().toSet().intersect(nonFullscreenApplicationWindowTypes).isEmpty()) { 00075 if (!isOwnWindow(windowInfo.window())) { 00076 emit fullscreenWindowOnTopOfOwnWindow(); 00077 } 00078 break; 00079 } 00080 } 00081 } 00082 } 00083 } 00084 00085 eventHandled = true; 00086 } 00087 00088 return eventHandled; 00089 } 00090 00091 QList<Window> HomeWindowMonitor::windowStackingOrder() 00092 { 00093 Display *display = QX11Info::display(); 00094 Atom actualType; 00095 int actualFormat; 00096 unsigned long numWindowItems, bytesLeft; 00097 unsigned char *windowData = NULL; 00098 Status result = X11Wrapper::XGetWindowProperty(display, DefaultRootWindow(display), netClientListStacking, 00099 0, 0x7fffffff, False, XA_WINDOW, 00100 &actualType, &actualFormat, &numWindowItems, &bytesLeft, &windowData); 00101 00102 QList<Window> stackingWindowList; 00103 00104 if (result == Success && windowData != None) { 00105 Window *windows = (Window *)windowData; 00106 for (unsigned int i = 0; i < numWindowItems; i++) { 00107 stackingWindowList.append(windows[i]); 00108 } 00109 } 00110 00111 return stackingWindowList; 00112 }
| Copyright © 2010 Nokia Corporation | Generated on Thu Nov 4 2010 18:20:42 Doxygen 1.7.1 |
MeeGo Touch |