<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>kwin Library: activation.cpp Source File (kwin Library)</title> <link href="../../common/doxygen.css" rel="stylesheet" type="text/css"> </head> <div class="header"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td rowspan="2" width="92"> <a href="../../index.html" title="The API documentation main page"><img src="../../common/docheadergears.png" style="border:0px;" alt=""></a> </td> <td width="95%"> <h1>kwin Library API Documentation</h1> </td> </tr> <tr> <td valign="bottom"> <table class="links" border=0 cellspacing=0> <tr> <td><a href="index.html">Overview</a></td> <td><a href="hierarchy.html" title="Inheritance list, sorted roughly alphabetically">Class Hierarchy</a></td> <td><a href="classes.html" title="Alphabetical list of classes">Classes</a></td> <td><a href="annotated.html" title="Classes, structs, unions and interfaces with brief descriptions">Classes (annotated)</a></td> <td><a href="functions.html" title="Documented class members with links to the classes they belong to">Members</a></td> <td><a href="namespaces.html" title="All documented namespaces with brief descriptions">Namespaces</a></td> <td><a href="files.html" title="A list of all documented files with brief descriptions">Source Files</a></td> </tr> </table> </td></tr></table> </div> <div id="hgrad"></div> <div class="text"> <!-- Generated by Doxygen 1.4.4 --> <h1>activation.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> KWin - the KDE window manager</span> <a name="l00003"></a>00003 <span class="comment"> This file is part of the KDE project.</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment">Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org></span> <a name="l00006"></a>00006 <span class="comment">Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org></span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment">You can Freely distribute this program under the GNU General Public</span> <a name="l00009"></a>00009 <span class="comment">License. See the file "COPYING" for the exact licensing terms.</span> <a name="l00010"></a>00010 <span class="comment">******************************************************************/</span> <a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="comment">/*</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment"> This file contains things relevant to window activation and focus</span> <a name="l00015"></a>00015 <span class="comment"> stealing prevention.</span> <a name="l00016"></a>00016 <span class="comment"></span> <a name="l00017"></a>00017 <span class="comment">*/</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include "client.h"</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "workspace.h"</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include <fixx11h.h></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <qpopupmenu.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <kxerrorhandler.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#include <kstartupinfo.h></span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="preprocessor">#include "notifications.h"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "atoms.h"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "group.h"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "rules.h"</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="keyword">extern</span> Time qt_x_time; <a name="l00033"></a>00033 <a name="l00034"></a><a class="code" href="namespaceKWinInternal.html">00034</a> <span class="keyword">namespace </span>KWinInternal <a name="l00035"></a>00035 { <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="comment">/*</span> <a name="l00038"></a>00038 <span class="comment"> Prevention of focus stealing:</span> <a name="l00039"></a>00039 <span class="comment"></span> <a name="l00040"></a>00040 <span class="comment"> KWin tries to prevent unwanted changes of focus, that would result</span> <a name="l00041"></a>00041 <span class="comment"> from mapping a new window. Also, some nasty applications may try</span> <a name="l00042"></a>00042 <span class="comment"> to force focus change even in cases when ICCCM 4.2.7 doesn't allow it</span> <a name="l00043"></a>00043 <span class="comment"> (e.g. they may try to activate their main window because the user</span> <a name="l00044"></a>00044 <span class="comment"> definitely "needs" to see something happened - misusing</span> <a name="l00045"></a>00045 <span class="comment"> of QWidget::setActiveWindow() may be such case).</span> <a name="l00046"></a>00046 <span class="comment"></span> <a name="l00047"></a>00047 <span class="comment"> There are 4 ways how a window may become active:</span> <a name="l00048"></a>00048 <span class="comment"> - the user changes the active window (e.g. focus follows mouse, clicking</span> <a name="l00049"></a>00049 <span class="comment"> on some window's titlebar) - the change of focus will</span> <a name="l00050"></a>00050 <span class="comment"> be done by KWin, so there's nothing to solve in this case</span> <a name="l00051"></a>00051 <span class="comment"> - the change of active window will be requested using the _NET_ACTIVE_WINDOW</span> <a name="l00052"></a>00052 <span class="comment"> message (handled in RootInfo::changeActiveWindow()) - such requests</span> <a name="l00053"></a>00053 <span class="comment"> will be obeyed, because this request is meant mainly for e.g. taskbar</span> <a name="l00054"></a>00054 <span class="comment"> asking the WM to change the active window as a result of some user action.</span> <a name="l00055"></a>00055 <span class="comment"> Normal applications should use this request only rarely in special cases.</span> <a name="l00056"></a>00056 <span class="comment"> See also below the discussion of _NET_ACTIVE_WINDOW_TRANSFER.</span> <a name="l00057"></a>00057 <span class="comment"> - the change of active window will be done by performing XSetInputFocus()</span> <a name="l00058"></a>00058 <span class="comment"> on a window that's not currently active. ICCCM 4.2.7 describes when</span> <a name="l00059"></a>00059 <span class="comment"> the application may perform change of input focus. In order to handle</span> <a name="l00060"></a>00060 <span class="comment"> misbehaving applications, KWin will try to detect focus changes to</span> <a name="l00061"></a>00061 <span class="comment"> windows that don't belong to currently active application, and restore</span> <a name="l00062"></a>00062 <span class="comment"> focus back to the currently active window, instead of activating the window</span> <a name="l00063"></a>00063 <span class="comment"> that got focus (unfortunately there's no way to FocusChangeRedirect similar</span> <a name="l00064"></a>00064 <span class="comment"> to e.g. SubstructureRedirect, so there will be short time when the focus</span> <a name="l00065"></a>00065 <span class="comment"> will be changed). The check itself that's done is</span> <a name="l00066"></a>00066 <span class="comment"> Workspace::allowClientActivation() (see below).</span> <a name="l00067"></a>00067 <span class="comment"> - a new window will be mapped - this is the most complicated case. If</span> <a name="l00068"></a>00068 <span class="comment"> the new window belongs to the currently active application, it may be safely</span> <a name="l00069"></a>00069 <span class="comment"> mapped on top and activated. The same if there's no active window,</span> <a name="l00070"></a>00070 <span class="comment"> or the active window is the desktop. These checks are done by</span> <a name="l00071"></a>00071 <span class="comment"> Workspace::allowClientActivation().</span> <a name="l00072"></a>00072 <span class="comment"> Following checks need to compare times. One time is the timestamp</span> <a name="l00073"></a>00073 <span class="comment"> of last user action in the currently active window, the other time is</span> <a name="l00074"></a>00074 <span class="comment"> the timestamp of the action that originally caused mapping of the new window</span> <a name="l00075"></a>00075 <span class="comment"> (e.g. when the application was started). If the first time is newer than</span> <a name="l00076"></a>00076 <span class="comment"> the second one, the window will not be activated, as that indicates</span> <a name="l00077"></a>00077 <span class="comment"> futher user actions took place after the action leading to this new</span> <a name="l00078"></a>00078 <span class="comment"> mapped window. This check is done by Workspace::allowClientActivation().</span> <a name="l00079"></a>00079 <span class="comment"> There are several ways how to get the timestamp of action that caused</span> <a name="l00080"></a>00080 <span class="comment"> the new mapped window (done in Client::readUserTimeMapTimestamp()) :</span> <a name="l00081"></a>00081 <span class="comment"> - the window may have the _NET_WM_USER_TIME property. This way</span> <a name="l00082"></a>00082 <span class="comment"> the application may either explicitly request that the window is not</span> <a name="l00083"></a>00083 <span class="comment"> activated (by using 0 timestamp), or the property contains the time</span> <a name="l00084"></a>00084 <span class="comment"> of last user action in the application.</span> <a name="l00085"></a>00085 <span class="comment"> - KWin itself tries to detect time of last user action in every window,</span> <a name="l00086"></a>00086 <span class="comment"> by watching KeyPress and ButtonPress events on windows. This way some</span> <a name="l00087"></a>00087 <span class="comment"> events may be missed (if they don't propagate to the toplevel window),</span> <a name="l00088"></a>00088 <span class="comment"> but it's good as a fallback for applications that don't provide</span> <a name="l00089"></a>00089 <span class="comment"> _NET_WM_USER_TIME, and missing some events may at most lead</span> <a name="l00090"></a>00090 <span class="comment"> to unwanted focus stealing.</span> <a name="l00091"></a>00091 <span class="comment"> - the timestamp may come from application startup notification.</span> <a name="l00092"></a>00092 <span class="comment"> Application startup notification, if it exists for the new mapped window,</span> <a name="l00093"></a>00093 <span class="comment"> should include time of the user action that caused it.</span> <a name="l00094"></a>00094 <span class="comment"> - if there's no timestamp available, it's checked whether the new window</span> <a name="l00095"></a>00095 <span class="comment"> belongs to some already running application - if yes, the timestamp</span> <a name="l00096"></a>00096 <span class="comment"> will be 0 (i.e. refuse activation)</span> <a name="l00097"></a>00097 <span class="comment"> - if the window is from session restored window, the timestamp will</span> <a name="l00098"></a>00098 <span class="comment"> be 0 too, unless this application was the active one at the time</span> <a name="l00099"></a>00099 <span class="comment"> when the session was saved, in which case the window will be</span> <a name="l00100"></a>00100 <span class="comment"> activated if there wasn't any user interaction since the time</span> <a name="l00101"></a>00101 <span class="comment"> KWin was started.</span> <a name="l00102"></a>00102 <span class="comment"> - as the last resort, the _KDE_NET_USER_CREATION_TIME timestamp</span> <a name="l00103"></a>00103 <span class="comment"> is used. For every toplevel window that is created (see CreateNotify</span> <a name="l00104"></a>00104 <span class="comment"> handling), this property is set to the at that time current time.</span> <a name="l00105"></a>00105 <span class="comment"> Since at this time it's known that the new window doesn't belong</span> <a name="l00106"></a>00106 <span class="comment"> to any existing application (better said, the application doesn't</span> <a name="l00107"></a>00107 <span class="comment"> have any other window mapped), it is either the very first window</span> <a name="l00108"></a>00108 <span class="comment"> of the application, or its the only window of the application</span> <a name="l00109"></a>00109 <span class="comment"> that was hidden before. The latter case is handled by removing</span> <a name="l00110"></a>00110 <span class="comment"> the property from windows before withdrawing them, making</span> <a name="l00111"></a>00111 <span class="comment"> the timestamp empty for next mapping of the window. In the sooner</span> <a name="l00112"></a>00112 <span class="comment"> case, the timestamp will be used. This helps in case when</span> <a name="l00113"></a>00113 <span class="comment"> an application is launched without application startup notification,</span> <a name="l00114"></a>00114 <span class="comment"> it creates its mainwindow, and starts its initialization (that</span> <a name="l00115"></a>00115 <span class="comment"> may possibly take long time). The timestamp used will be older</span> <a name="l00116"></a>00116 <span class="comment"> than any user action done after launching this application.</span> <a name="l00117"></a>00117 <span class="comment"> - if no timestamp is found at all, the window is activated.</span> <a name="l00118"></a>00118 <span class="comment"> The check whether two windows belong to the same application (same</span> <a name="l00119"></a>00119 <span class="comment"> process) is done in Client::belongToSameApplication(). Not 100% reliable,</span> <a name="l00120"></a>00120 <span class="comment"> but hopefully 99,99% reliable.</span> <a name="l00121"></a>00121 <span class="comment"></span> <a name="l00122"></a>00122 <span class="comment"> As a somewhat special case, window activation is always enabled when</span> <a name="l00123"></a>00123 <span class="comment"> session saving is in progress. When session saving, the session</span> <a name="l00124"></a>00124 <span class="comment"> manager allows only one application to interact with the user.</span> <a name="l00125"></a>00125 <span class="comment"> Not allowing window activation in such case would result in e.g. dialogs</span> <a name="l00126"></a>00126 <span class="comment"> not becoming active, so focus stealing prevention would cause here</span> <a name="l00127"></a>00127 <span class="comment"> more harm than good.</span> <a name="l00128"></a>00128 <span class="comment"></span> <a name="l00129"></a>00129 <span class="comment"> Windows that attempted to become active but KWin prevented this will</span> <a name="l00130"></a>00130 <span class="comment"> be marked as demanding user attention. They'll get</span> <a name="l00131"></a>00131 <span class="comment"> the _NET_WM_STATE_DEMANDS_ATTENTION state, and the taskbar should mark</span> <a name="l00132"></a>00132 <span class="comment"> them specially (blink, etc.). The state will be reset when the window</span> <a name="l00133"></a>00133 <span class="comment"> eventually really becomes active.</span> <a name="l00134"></a>00134 <span class="comment"></span> <a name="l00135"></a>00135 <span class="comment"> There are one more ways how a window can become obstrusive, window stealing</span> <a name="l00136"></a>00136 <span class="comment"> focus: By showing above the active window, by either raising itself,</span> <a name="l00137"></a>00137 <span class="comment"> or by moving itself on the active desktop.</span> <a name="l00138"></a>00138 <span class="comment"> - KWin will refuse raising non-active window above the active one,</span> <a name="l00139"></a>00139 <span class="comment"> unless they belong to the same application. Applications shouldn't</span> <a name="l00140"></a>00140 <span class="comment"> raise their windows anyway (unless the app wants to raise one</span> <a name="l00141"></a>00141 <span class="comment"> of its windows above another of its windows).</span> <a name="l00142"></a>00142 <span class="comment"> - KWin activates windows moved to the current desktop (as that seems</span> <a name="l00143"></a>00143 <span class="comment"> logical from the user's point of view, after sending the window</span> <a name="l00144"></a>00144 <span class="comment"> there directly from KWin, or e.g. using pager). This means</span> <a name="l00145"></a>00145 <span class="comment"> applications shouldn't send their windows to another desktop</span> <a name="l00146"></a>00146 <span class="comment"> (SELI TODO - but what if they do?)</span> <a name="l00147"></a>00147 <span class="comment"></span> <a name="l00148"></a>00148 <span class="comment"> Special cases I can think of:</span> <a name="l00149"></a>00149 <span class="comment"> - konqueror reusing, i.e. kfmclient tells running Konqueror instance</span> <a name="l00150"></a>00150 <span class="comment"> to open new window</span> <a name="l00151"></a>00151 <span class="comment"> - without focus stealing prevention - no problem</span> <a name="l00152"></a>00152 <span class="comment"> - with ASN (application startup notification) - ASN is forwarded,</span> <a name="l00153"></a>00153 <span class="comment"> and because it's newer than the instance's user timestamp,</span> <a name="l00154"></a>00154 <span class="comment"> it takes precedence</span> <a name="l00155"></a>00155 <span class="comment"> - without ASN - user timestamp needs to be reset, otherwise it would</span> <a name="l00156"></a>00156 <span class="comment"> be used, and it's old; moreover this new window mustn't be detected</span> <a name="l00157"></a>00157 <span class="comment"> as window belonging to already running application, or it wouldn't</span> <a name="l00158"></a>00158 <span class="comment"> be activated - see Client::sameAppWindowRoleMatch() for the (rather ugly)</span> <a name="l00159"></a>00159 <span class="comment"> hack</span> <a name="l00160"></a>00160 <span class="comment"> - konqueror preloading, i.e. window is created in advance, and kfmclient</span> <a name="l00161"></a>00161 <span class="comment"> tells this Konqueror instance to show it later</span> <a name="l00162"></a>00162 <span class="comment"> - without focus stealing prevention - no problem</span> <a name="l00163"></a>00163 <span class="comment"> - with ASN - ASN is forwarded, and because it's newer than the instance's</span> <a name="l00164"></a>00164 <span class="comment"> user timestamp, it takes precedence</span> <a name="l00165"></a>00165 <span class="comment"> - without ASN - user timestamp needs to be reset, otherwise it would</span> <a name="l00166"></a>00166 <span class="comment"> be used, and it's old; also, creation timestamp is changed to</span> <a name="l00167"></a>00167 <span class="comment"> the time the instance starts (re-)initializing the window,</span> <a name="l00168"></a>00168 <span class="comment"> this ensures creation timestamp will still work somewhat even in this case</span> <a name="l00169"></a>00169 <span class="comment"> - KUniqueApplication - when the window is already visible, and the new instance</span> <a name="l00170"></a>00170 <span class="comment"> wants it to activate</span> <a name="l00171"></a>00171 <span class="comment"> - without focus stealing prevention - _NET_ACTIVE_WINDOW - no problem</span> <a name="l00172"></a>00172 <span class="comment"> - with ASN - ASN is forwarded, and set on the already visible window, KWin</span> <a name="l00173"></a>00173 <span class="comment"> treats the window as new with that ASN</span> <a name="l00174"></a>00174 <span class="comment"> - without ASN - _NET_ACTIVE_WINDOW as application request is used,</span> <a name="l00175"></a>00175 <span class="comment"> and there's no really usable timestamp, only timestamp</span> <a name="l00176"></a>00176 <span class="comment"> from the time the (new) application instance was started,</span> <a name="l00177"></a>00177 <span class="comment"> so KWin will activate the window *sigh*</span> <a name="l00178"></a>00178 <span class="comment"> - the bad thing here is that there's absolutely no chance to recognize</span> <a name="l00179"></a>00179 <span class="comment"> the case of starting this KUniqueApp from Konsole (and thus wanting</span> <a name="l00180"></a>00180 <span class="comment"> the already visible window to become active) from the case</span> <a name="l00181"></a>00181 <span class="comment"> when something started this KUniqueApp without ASN (in which case</span> <a name="l00182"></a>00182 <span class="comment"> the already visible window shouldn't become active)</span> <a name="l00183"></a>00183 <span class="comment"> - the only solution is using ASN for starting applications, at least silent</span> <a name="l00184"></a>00184 <span class="comment"> (i.e. without feedback)</span> <a name="l00185"></a>00185 <span class="comment"> - when one application wants to activate another application's window (e.g. KMail</span> <a name="l00186"></a>00186 <span class="comment"> activating already running KAddressBook window ?)</span> <a name="l00187"></a>00187 <span class="comment"> - without focus stealing prevention - _NET_ACTIVE_WINDOW - no problem</span> <a name="l00188"></a>00188 <span class="comment"> - with ASN - can't be here, it's the KUniqueApp case then</span> <a name="l00189"></a>00189 <span class="comment"> - without ASN - _NET_ACTIVE_WINDOW as application request should be used,</span> <a name="l00190"></a>00190 <span class="comment"> KWin will activate the new window depending on the timestamp and</span> <a name="l00191"></a>00191 <span class="comment"> whether it belongs to the currently active application</span> <a name="l00192"></a>00192 <span class="comment"></span> <a name="l00193"></a>00193 <span class="comment"> _NET_ACTIVE_WINDOW usage:</span> <a name="l00194"></a>00194 <span class="comment"> data.l[0]= 1 ->app request</span> <a name="l00195"></a>00195 <span class="comment"> = 2 ->pager request</span> <a name="l00196"></a>00196 <span class="comment"> = 0 - backwards compatibility</span> <a name="l00197"></a>00197 <span class="comment"> data.l[1]= timestamp</span> <a name="l00198"></a>00198 <span class="comment">*/</span> <a name="l00199"></a>00199 <a name="l00200"></a>00200 <a name="l00201"></a>00201 <span class="comment">//****************************************</span> <a name="l00202"></a>00202 <span class="comment">// Workspace</span> <a name="l00203"></a>00203 <span class="comment">//****************************************</span> <a name="l00204"></a>00204 <a name="l00205"></a>00205 <a name="l00214"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a91">00214</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a91">Workspace::setActiveClient</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, <a class="code" href="namespaceKWinInternal.html#a120">allowed_t</a> ) <a name="l00215"></a>00215 { <a name="l00216"></a>00216 <span class="keywordflow">if</span> ( active_client == c ) <a name="l00217"></a>00217 <span class="keywordflow">return</span>; <a name="l00218"></a>00218 <span class="keywordflow">if</span>( active_popup && active_popup_client != c && set_active_client_recursion == 0 ) <a name="l00219"></a>00219 closeActivePopup(); <a name="l00220"></a>00220 <a class="code" href="classKWinInternal_1_1StackingUpdatesBlocker.html">StackingUpdatesBlocker</a> blocker( <span class="keyword">this</span> ); <a name="l00221"></a>00221 ++set_active_client_recursion; <a name="l00222"></a>00222 <span class="keywordflow">if</span>( active_client != NULL ) <a name="l00223"></a>00223 { <span class="comment">// note that this may call setActiveClient( NULL ), therefore the recursion counter</span> <a name="l00224"></a>00224 active_client-><a class="code" href="classKWinInternal_1_1Client.html#a42">setActive</a>( <span class="keyword">false</span>, !c || !c-><a class="code" href="classKWinInternal_1_1Client.html#a82">isModal</a>() || c != active_client-><a class="code" href="classKWinInternal_1_1Client.html#a6">transientFor</a>() ); <a name="l00225"></a>00225 } <a name="l00226"></a>00226 active_client = c; <a name="l00227"></a>00227 Q_ASSERT( c == NULL || c-><a class="code" href="classKWinInternal_1_1Client.html#a41">isActive</a>()); <a name="l00228"></a>00228 <span class="keywordflow">if</span>( active_client != NULL ) <a name="l00229"></a>00229 last_active_client = active_client; <a name="l00230"></a>00230 <span class="keywordflow">if</span> ( active_client ) <a name="l00231"></a>00231 { <a name="l00232"></a>00232 focus_chain.remove( c ); <a name="l00233"></a>00233 <span class="keywordflow">if</span> ( c->wantsTabFocus() ) <a name="l00234"></a>00234 focus_chain.append( c ); <a name="l00235"></a>00235 active_client-><a class="code" href="classKWinInternal_1_1Client.html#a102">demandAttention</a>( <span class="keyword">false</span> ); <a name="l00236"></a>00236 } <a name="l00237"></a>00237 pending_take_activity = NULL; <a name="l00238"></a>00238 <a name="l00239"></a>00239 <a class="code" href="classKWinInternal_1_1Workspace.html#a108">updateCurrentTopMenu</a>(); <a name="l00240"></a>00240 updateToolWindows( <span class="keyword">false</span> ); <a name="l00241"></a>00241 <a name="l00242"></a>00242 updateStackingOrder(); <span class="comment">// e.g. fullscreens have different layer when active/not-active</span> <a name="l00243"></a>00243 <a name="l00244"></a>00244 rootInfo->setActiveWindow( active_client? active_client-><a class="code" href="classKWinInternal_1_1Client.html#a1">window</a>() : 0 ); <a name="l00245"></a>00245 <a class="code" href="classKWinInternal_1_1Workspace.html#a28">updateColormap</a>(); <a name="l00246"></a>00246 --set_active_client_recursion; <a name="l00247"></a>00247 } <a name="l00248"></a>00248 <a name="l00260"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a16">00260</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a16">Workspace::activateClient</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, <span class="keywordtype">bool</span> force ) <a name="l00261"></a>00261 { <a name="l00262"></a>00262 <span class="keywordflow">if</span>( c == NULL ) <a name="l00263"></a>00263 { <a name="l00264"></a>00264 <a class="code" href="classKWinInternal_1_1Workspace.html#a91">setActiveClient</a>( NULL, Allowed ); <a name="l00265"></a>00265 <span class="keywordflow">return</span>; <a name="l00266"></a>00266 } <a name="l00267"></a>00267 <a class="code" href="classKWinInternal_1_1Workspace.html#a34">raiseClient</a>( c ); <a name="l00268"></a>00268 <span class="keywordflow">if</span> (!c-><a class="code" href="classKWinInternal_1_1Client.html#a45">isOnDesktop</a>(<a class="code" href="classKWinInternal_1_1Workspace.html#a45">currentDesktop</a>()) ) <a name="l00269"></a>00269 { <a name="l00270"></a>00270 ++block_focus; <a name="l00271"></a>00271 <a class="code" href="classKWinInternal_1_1Workspace.html#a76">setCurrentDesktop</a>( c-><a class="code" href="classKWinInternal_1_1Client.html#a43">desktop</a>() ); <a name="l00272"></a>00272 --block_focus; <a name="l00273"></a>00273 <span class="comment">// popupinfo->showInfo( desktopName(currentDesktop()) ); // AK - not sure</span> <a name="l00274"></a>00274 } <a name="l00275"></a>00275 <span class="keywordflow">if</span>( c-><a class="code" href="classKWinInternal_1_1Client.html#a54">isMinimized</a>()) <a name="l00276"></a>00276 c-><a class="code" href="classKWinInternal_1_1Client.html#a152">unminimize</a>(); <a name="l00277"></a>00277 <a name="l00278"></a>00278 <span class="comment">// TODO force should perhaps allow this only if the window already contains the mouse</span> <a name="l00279"></a>00279 <span class="keywordflow">if</span>( <a class="code" href="namespaceKWinInternal.html#a13">options</a>-><a class="code" href="classKWinInternal_1_1Options.html#a3">focusPolicyIsReasonable</a>() || force ) <a name="l00280"></a>00280 <a class="code" href="classKWinInternal_1_1Workspace.html#a17">requestFocus</a>( c, force ); <a name="l00281"></a>00281 <a name="l00282"></a>00282 <span class="comment">// Don't update user time for clients that have focus stealing workaround.</span> <a name="l00283"></a>00283 <span class="comment">// As they usually belong to the current active window but fail to provide</span> <a name="l00284"></a>00284 <span class="comment">// this information, updating their user time would make the user time</span> <a name="l00285"></a>00285 <span class="comment">// of the currently active window old, and reject further activation for it.</span> <a name="l00286"></a>00286 <span class="comment">// E.g. typing URL in minicli which will show kio_uiserver dialog (with workaround),</span> <a name="l00287"></a>00287 <span class="comment">// and then kdesktop shows dialog about SSL certificate.</span> <a name="l00288"></a>00288 <span class="comment">// This needs also avoiding user creation time in Client::readUserTimeMapTimestamp().</span> <a name="l00289"></a>00289 <span class="keywordflow">if</span>( !c-><a class="code" href="classKWinInternal_1_1Client.html#a150">ignoreFocusStealing</a>()) <a name="l00290"></a>00290 c-><a class="code" href="classKWinInternal_1_1Client.html#a147">updateUserTime</a>(); <a name="l00291"></a>00291 } <a name="l00292"></a>00292 <a name="l00300"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a17">00300</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a17">Workspace::requestFocus</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, <span class="keywordtype">bool</span> force ) <a name="l00301"></a>00301 { <a name="l00302"></a>00302 <a class="code" href="classKWinInternal_1_1Workspace.html#a18">takeActivity</a>( c, ActivityFocus | ( force ? ActivityFocusForce : 0 ), <span class="keyword">false</span>); <a name="l00303"></a>00303 } <a name="l00304"></a>00304 <a name="l00305"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a18">00305</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a18">Workspace::takeActivity</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, <span class="keywordtype">int</span> flags, <span class="keywordtype">bool</span> handled ) <a name="l00306"></a>00306 { <a name="l00307"></a>00307 <span class="comment">// the 'if( c == active_client ) return;' optimization mustn't be done here</span> <a name="l00308"></a>00308 <span class="keywordflow">if</span> (!<a class="code" href="classKWinInternal_1_1Workspace.html#a27">focusChangeEnabled</a>() && ( c != active_client) ) <a name="l00309"></a>00309 flags &= ~ActivityFocus; <a name="l00310"></a>00310 <a name="l00311"></a>00311 <span class="keywordflow">if</span> ( !c ) <a name="l00312"></a>00312 { <a name="l00313"></a>00313 <a class="code" href="classKWinInternal_1_1Workspace.html#a97">focusToNull</a>(); <a name="l00314"></a>00314 <span class="keywordflow">return</span>; <a name="l00315"></a>00315 } <a name="l00316"></a>00316 <a name="l00317"></a>00317 <span class="keywordflow">if</span>( flags & ActivityFocus ) <a name="l00318"></a>00318 { <a name="l00319"></a>00319 <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* modal = c-><a class="code" href="classKWinInternal_1_1Client.html#a15">findModal</a>(); <a name="l00320"></a>00320 <span class="keywordflow">if</span>( modal != NULL && modal != c ) <a name="l00321"></a>00321 { <a name="l00322"></a>00322 <span class="keywordflow">if</span>( !modal-><a class="code" href="classKWinInternal_1_1Client.html#a45">isOnDesktop</a>( c-><a class="code" href="classKWinInternal_1_1Client.html#a43">desktop</a>())) <a name="l00323"></a>00323 { <a name="l00324"></a>00324 modal-><a class="code" href="classKWinInternal_1_1Client.html#a44">setDesktop</a>( c-><a class="code" href="classKWinInternal_1_1Client.html#a43">desktop</a>()); <a name="l00325"></a>00325 <span class="keywordflow">if</span>( modal-><a class="code" href="classKWinInternal_1_1Client.html#a43">desktop</a>() != c-><a class="code" href="classKWinInternal_1_1Client.html#a43">desktop</a>()) <span class="comment">// forced desktop</span> <a name="l00326"></a>00326 <a class="code" href="classKWinInternal_1_1Workspace.html#a16">activateClient</a>( modal ); <a name="l00327"></a>00327 } <a name="l00328"></a>00328 <span class="comment">// if the click was inside the window (i.e. handled is set),</span> <a name="l00329"></a>00329 <span class="comment">// but it has a modal, there's no need to use handled mode, because</span> <a name="l00330"></a>00330 <span class="comment">// the modal doesn't get the click anyway</span> <a name="l00331"></a>00331 <span class="comment">// raising of the original window needs to be still done</span> <a name="l00332"></a>00332 <span class="keywordflow">if</span>( flags & ActivityRaise ) <a name="l00333"></a>00333 <a class="code" href="classKWinInternal_1_1Workspace.html#a34">raiseClient</a>( c ); <a name="l00334"></a>00334 c = modal; <a name="l00335"></a>00335 handled = <span class="keyword">false</span>; <a name="l00336"></a>00336 } <a name="l00337"></a>00337 <a class="code" href="classKWinInternal_1_1Workspace.html#a113">cancelDelayFocus</a>(); <a name="l00338"></a>00338 } <a name="l00339"></a>00339 <span class="keywordflow">if</span> ( !( flags & ActivityFocusForce ) && ( c-><a class="code" href="classKWinInternal_1_1Client.html#a90">isTopMenu</a>() || c-><a class="code" href="classKWinInternal_1_1Client.html#a88">isDock</a>() || c-><a class="code" href="classKWinInternal_1_1Client.html#a94">isSplash</a>()) ) <a name="l00340"></a>00340 flags &= ~ActivityFocus; <span class="comment">// toplevel menus and dock windows don't take focus if not forced</span> <a name="l00341"></a>00341 <span class="keywordflow">if</span>( c-><a class="code" href="classKWinInternal_1_1Client.html#a50">isShade</a>()) <a name="l00342"></a>00342 { <a name="l00343"></a>00343 <span class="keywordflow">if</span>( c-><a class="code" href="classKWinInternal_1_1Client.html#a84">wantsInput</a>() && ( flags & ActivityFocus )) <a name="l00344"></a>00344 { <a name="l00345"></a>00345 <span class="comment">// client cannot accept focus, but at least the window should be active (window menu, et. al. )</span> <a name="l00346"></a>00346 c-><a class="code" href="classKWinInternal_1_1Client.html#a42">setActive</a>( <span class="keyword">true</span> ); <a name="l00347"></a>00347 <a class="code" href="classKWinInternal_1_1Workspace.html#a97">focusToNull</a>(); <a name="l00348"></a>00348 } <a name="l00349"></a>00349 flags &= ~ActivityFocus; <a name="l00350"></a>00350 handled = <span class="keyword">false</span>; <span class="comment">// no point, can't get clicks</span> <a name="l00351"></a>00351 } <a name="l00352"></a>00352 <span class="keywordflow">if</span>( !c-><a class="code" href="classKWinInternal_1_1Client.html#a49">isShown</a>( <span class="keyword">true</span> )) <span class="comment">// shouldn't happen, call activateClient() if needed</span> <a name="l00353"></a>00353 { <a name="l00354"></a>00354 kdWarning( 1212 ) << <span class="stringliteral">"takeActivity: not shown"</span> << endl; <a name="l00355"></a>00355 <span class="keywordflow">return</span>; <a name="l00356"></a>00356 } <a name="l00357"></a>00357 c-><a class="code" href="classKWinInternal_1_1Client.html#a100">takeActivity</a>( flags, handled, Allowed ); <a name="l00358"></a>00358 } <a name="l00359"></a>00359 <a name="l00360"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a19">00360</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a19">Workspace::handleTakeActivity</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, Time <span class="comment">/*timestamp*/</span>, <span class="keywordtype">int</span> flags ) <a name="l00361"></a>00361 { <a name="l00362"></a>00362 <span class="keywordflow">if</span>( pending_take_activity != c ) <span class="comment">// pending_take_activity is reset when doing restack or activation</span> <a name="l00363"></a>00363 <span class="keywordflow">return</span>; <a name="l00364"></a>00364 <span class="keywordflow">if</span>(( flags & ActivityRaise ) != 0 ) <a name="l00365"></a>00365 <a class="code" href="classKWinInternal_1_1Workspace.html#a34">raiseClient</a>( c ); <a name="l00366"></a>00366 <span class="keywordflow">if</span>(( flags & ActivityFocus ) != 0 && c-><a class="code" href="classKWinInternal_1_1Client.html#a49">isShown</a>( <span class="keyword">false</span> )) <a name="l00367"></a>00367 c-><a class="code" href="classKWinInternal_1_1Client.html#a101">takeFocus</a>( Allowed ); <a name="l00368"></a>00368 pending_take_activity = NULL; <a name="l00369"></a>00369 } <a name="l00370"></a>00370 <a name="l00378"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a42">00378</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a42">Workspace::clientHidden</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c ) <a name="l00379"></a>00379 { <a name="l00380"></a>00380 assert( !c-><a class="code" href="classKWinInternal_1_1Client.html#a49">isShown</a>( <span class="keyword">true</span> ) || !c-><a class="code" href="classKWinInternal_1_1Client.html#a46">isOnCurrentDesktop</a>()); <a name="l00381"></a>00381 <a class="code" href="classKWinInternal_1_1Workspace.html#a26">activateNextClient</a>( c ); <a name="l00382"></a>00382 } <a name="l00383"></a>00383 <a name="l00384"></a>00384 <span class="comment">// deactivates 'c' and activates next client</span> <a name="l00385"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a26">00385</a> <span class="keywordtype">bool</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a26">Workspace::activateNextClient</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c ) <a name="l00386"></a>00386 { <a name="l00387"></a>00387 <span class="comment">// if 'c' is not the active or the to-become active one, do nothing</span> <a name="l00388"></a>00388 <span class="keywordflow">if</span>( !( c == active_client <a name="l00389"></a>00389 || ( should_get_focus.count() > 0 && c == should_get_focus.last()))) <a name="l00390"></a>00390 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00391"></a>00391 closeActivePopup(); <a name="l00392"></a>00392 <span class="keywordflow">if</span>( c != NULL ) <a name="l00393"></a>00393 { <a name="l00394"></a>00394 <span class="keywordflow">if</span>( c == active_client ) <a name="l00395"></a>00395 <a class="code" href="classKWinInternal_1_1Workspace.html#a91">setActiveClient</a>( NULL, Allowed ); <a name="l00396"></a>00396 should_get_focus.remove( c ); <a name="l00397"></a>00397 } <a name="l00398"></a>00398 <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Workspace.html#a27">focusChangeEnabled</a>()) <a name="l00399"></a>00399 { <a name="l00400"></a>00400 <span class="keywordflow">if</span> ( c != NULL && c-><a class="code" href="classKWinInternal_1_1Client.html#a83">wantsTabFocus</a>() && focus_chain.contains( c ) ) <a name="l00401"></a>00401 { <a name="l00402"></a>00402 focus_chain.remove( c ); <a name="l00403"></a>00403 focus_chain.prepend( c ); <a name="l00404"></a>00404 } <a name="l00405"></a>00405 <span class="keywordflow">if</span> ( <a class="code" href="namespaceKWinInternal.html#a13">options</a>-><a class="code" href="classKWinInternal_1_1Options.html#a3">focusPolicyIsReasonable</a>()) <a name="l00406"></a>00406 { <span class="comment">// search the focus_chain for a client to transfer focus to</span> <a name="l00407"></a>00407 <span class="comment">// if 'c' is transient, transfer focus to the first suitable mainwindow</span> <a name="l00408"></a>00408 <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* get_focus = NULL; <a name="l00409"></a>00409 <span class="keyword">const</span> <a class="code" href="namespaceKWinInternal.html#a24">ClientList</a> mainwindows = ( c != NULL ? c-><a class="code" href="classKWinInternal_1_1Client.html#a11">mainClients</a>() : <a class="code" href="namespaceKWinInternal.html#a24">ClientList</a>()); <a name="l00410"></a>00410 <span class="keywordflow">for</span>( ClientList::ConstIterator it = focus_chain.fromLast(); <a name="l00411"></a>00411 it != focus_chain.end(); <a name="l00412"></a>00412 --it ) <a name="l00413"></a>00413 { <a name="l00414"></a>00414 <span class="keywordflow">if</span>( !(*it)->isShown( <span class="keyword">false</span> ) || !(*it)->isOnCurrentDesktop()) <a name="l00415"></a>00415 <span class="keywordflow">continue</span>; <a name="l00416"></a>00416 <span class="keywordflow">if</span>( mainwindows.contains( *it )) <a name="l00417"></a>00417 { <a name="l00418"></a>00418 get_focus = *it; <a name="l00419"></a>00419 <span class="keywordflow">break</span>; <a name="l00420"></a>00420 } <a name="l00421"></a>00421 <span class="keywordflow">if</span>( get_focus == NULL ) <a name="l00422"></a>00422 get_focus = *it; <a name="l00423"></a>00423 } <a name="l00424"></a>00424 <span class="keywordflow">if</span>( get_focus == NULL ) <a name="l00425"></a>00425 get_focus = <a class="code" href="classKWinInternal_1_1Workspace.html#a59">findDesktop</a>( <span class="keyword">true</span>, <a class="code" href="classKWinInternal_1_1Workspace.html#a45">currentDesktop</a>()); <a name="l00426"></a>00426 <span class="keywordflow">if</span>( get_focus != NULL ) <a name="l00427"></a>00427 <a class="code" href="classKWinInternal_1_1Workspace.html#a17">requestFocus</a>( get_focus ); <a name="l00428"></a>00428 <span class="keywordflow">else</span> <a name="l00429"></a>00429 <a class="code" href="classKWinInternal_1_1Workspace.html#a97">focusToNull</a>(); <a name="l00430"></a>00430 } <a name="l00431"></a>00431 <span class="keywordflow">else</span> <a name="l00432"></a>00432 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00433"></a>00433 } <a name="l00434"></a>00434 <span class="keywordflow">else</span> <a name="l00435"></a>00435 <span class="comment">// if blocking focus, move focus to the desktop later if needed</span> <a name="l00436"></a>00436 <span class="comment">// in order to avoid flickering</span> <a name="l00437"></a>00437 <a class="code" href="classKWinInternal_1_1Workspace.html#a97">focusToNull</a>(); <a name="l00438"></a>00438 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00439"></a>00439 } <a name="l00440"></a>00440 <a name="l00441"></a>00441 <a name="l00442"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a22">00442</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a22">Workspace::gotFocusIn</a>( <span class="keyword">const</span> <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c ) <a name="l00443"></a>00443 { <a name="l00444"></a>00444 <span class="keywordflow">if</span>( should_get_focus.contains( const_cast< Client* >( c ))) <a name="l00445"></a>00445 { <span class="comment">// remove also all sooner elements that should have got FocusIn,</span> <a name="l00446"></a>00446 <span class="comment">// but didn't for some reason (and also won't anymore, because they were sooner)</span> <a name="l00447"></a>00447 <span class="keywordflow">while</span>( should_get_focus.first() != c ) <a name="l00448"></a>00448 should_get_focus.pop_front(); <a name="l00449"></a>00449 should_get_focus.pop_front(); <span class="comment">// remove 'c'</span> <a name="l00450"></a>00450 } <a name="l00451"></a>00451 } <a name="l00452"></a>00452 <a name="l00453"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a23">00453</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a23">Workspace::setShouldGetFocus</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c ) <a name="l00454"></a>00454 { <a name="l00455"></a>00455 should_get_focus.append( c ); <a name="l00456"></a>00456 updateStackingOrder(); <span class="comment">// e.g. fullscreens have different layer when active/not-active</span> <a name="l00457"></a>00457 } <a name="l00458"></a>00458 <a name="l00459"></a>00459 <span class="comment">// focus_in -> the window got FocusIn event</span> <a name="l00460"></a>00460 <span class="comment">// session_active -> the window was active when saving session</span> <a name="l00461"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a20">00461</a> <span class="keywordtype">bool</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a20">Workspace::allowClientActivation</a>( <span class="keyword">const</span> <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, Time time, <span class="keywordtype">bool</span> focus_in ) <a name="l00462"></a>00462 { <a name="l00463"></a>00463 <span class="comment">// options->focusStealingPreventionLevel :</span> <a name="l00464"></a>00464 <span class="comment">// 0 - none - old KWin behaviour, new windows always get focus</span> <a name="l00465"></a>00465 <span class="comment">// 1 - low - focus stealing prevention is applied normally, when unsure, activation is allowed</span> <a name="l00466"></a>00466 <span class="comment">// 2 - normal - focus stealing prevention is applied normally, when unsure, activation is not allowed,</span> <a name="l00467"></a>00467 <span class="comment">// this is the default</span> <a name="l00468"></a>00468 <span class="comment">// 3 - high - new window gets focus only if it belongs to the active application,</span> <a name="l00469"></a>00469 <span class="comment">// or when no window is currently active</span> <a name="l00470"></a>00470 <span class="comment">// 4 - extreme - no window gets focus without user intervention</span> <a name="l00471"></a>00471 <span class="keywordflow">if</span>( time == -1U ) <a name="l00472"></a>00472 time = c-><a class="code" href="classKWinInternal_1_1Client.html#a148">userTime</a>(); <a name="l00473"></a>00473 <span class="keywordtype">int</span> level = c-><a class="code" href="classKWinInternal_1_1Client.html#a20">rules</a>()-><a class="code" href="classKWinInternal_1_1WindowRules.html#a24">checkFSP</a>( <a class="code" href="namespaceKWinInternal.html#a13">options</a>-><a class="code" href="classKWinInternal_1_1Options.html#o24">focusStealingPreventionLevel</a> ); <a name="l00474"></a>00474 <span class="keywordflow">if</span>( session_saving && level <= 2 ) <span class="comment">// <= normal</span> <a name="l00475"></a>00475 { <a name="l00476"></a>00476 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* ac = <a class="code" href="classKWinInternal_1_1Workspace.html#a15">mostRecentlyActivatedClient</a>(); <a name="l00479"></a>00479 <span class="keywordflow">if</span>( focus_in ) <a name="l00480"></a>00480 { <a name="l00481"></a>00481 <span class="keywordflow">if</span>( should_get_focus.contains( const_cast< Client* >( c ))) <a name="l00482"></a>00482 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// FocusIn was result of KWin's action</span> <a name="l00483"></a>00483 <span class="comment">// Before getting FocusIn, the active Client already</span> <a name="l00484"></a>00484 <span class="comment">// got FocusOut, and therefore got deactivated.</span> <a name="l00485"></a>00485 ac = last_active_client; <a name="l00486"></a>00486 } <a name="l00487"></a>00487 <span class="keywordflow">if</span>( time == 0 ) <span class="comment">// explicitly asked not to get focus</span> <a name="l00488"></a>00488 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00489"></a>00489 <span class="keywordflow">if</span>( level == 0 ) <span class="comment">// none</span> <a name="l00490"></a>00490 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00491"></a>00491 <span class="keywordflow">if</span>( level == 4 ) <span class="comment">// extreme</span> <a name="l00492"></a>00492 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00493"></a>00493 <span class="keywordflow">if</span>( !c-><a class="code" href="classKWinInternal_1_1Client.html#a46">isOnCurrentDesktop</a>()) <a name="l00494"></a>00494 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// allow only with level == 0</span> <a name="l00495"></a>00495 <span class="keywordflow">if</span>( c-><a class="code" href="classKWinInternal_1_1Client.html#a150">ignoreFocusStealing</a>()) <a name="l00496"></a>00496 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00497"></a>00497 <span class="keywordflow">if</span>( ac == NULL || ac-><a class="code" href="classKWinInternal_1_1Client.html#a87">isDesktop</a>()) <a name="l00498"></a>00498 { <a name="l00499"></a>00499 kdDebug( 1212 ) << <span class="stringliteral">"Activation: No client active, allowing"</span> << endl; <a name="l00500"></a>00500 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// no active client -> always allow</span> <a name="l00501"></a>00501 } <a name="l00502"></a>00502 <span class="comment">// TODO window urgency -> return true?</span> <a name="l00503"></a>00503 <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Client.html#e7">Client::belongToSameApplication</a>( c, ac, <span class="keyword">true</span> )) <a name="l00504"></a>00504 { <a name="l00505"></a>00505 kdDebug( 1212 ) << <span class="stringliteral">"Activation: Belongs to active application"</span> << endl; <a name="l00506"></a>00506 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00507"></a>00507 } <a name="l00508"></a>00508 <span class="keywordflow">if</span>( level == 3 ) <span class="comment">// high</span> <a name="l00509"></a>00509 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00510"></a>00510 <span class="keywordflow">if</span>( time == -1U ) <span class="comment">// no time known</span> <a name="l00511"></a>00511 { <a name="l00512"></a>00512 kdDebug( 1212 ) << <span class="stringliteral">"Activation: No timestamp at all"</span> << endl; <a name="l00513"></a>00513 <span class="keywordflow">if</span>( level == 1 ) <span class="comment">// low</span> <a name="l00514"></a>00514 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00515"></a>00515 <span class="comment">// no timestamp at all, don't activate - because there's also creation timestamp</span> <a name="l00516"></a>00516 <span class="comment">// done on CreateNotify, this case should happen only in case application</span> <a name="l00517"></a>00517 <span class="comment">// maps again already used window, i.e. this won't happen after app startup</span> <a name="l00518"></a>00518 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00519"></a>00519 } <a name="l00520"></a>00520 <span class="comment">// level == 2 // normal</span> <a name="l00521"></a>00521 Time user_time = ac-><a class="code" href="classKWinInternal_1_1Client.html#a148">userTime</a>(); <a name="l00522"></a>00522 kdDebug( 1212 ) << <span class="stringliteral">"Activation, compared:"</span> << c << <span class="stringliteral">":"</span> << time << <span class="stringliteral">":"</span> << user_time <a name="l00523"></a>00523 << <span class="stringliteral">":"</span> << ( <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( time, user_time ) >= 0 ) << endl; <a name="l00524"></a>00524 <span class="keywordflow">return</span> <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( time, user_time ) >= 0; <span class="comment">// time >= user_time</span> <a name="l00525"></a>00525 } <a name="l00526"></a>00526 <a name="l00527"></a>00527 <span class="comment">// basically the same like allowClientActivation(), this time allowing</span> <a name="l00528"></a>00528 <span class="comment">// a window to be fully raised upon its own request (XRaiseWindow),</span> <a name="l00529"></a>00529 <span class="comment">// if refused, it will be raised only on top of windows belonging</span> <a name="l00530"></a>00530 <span class="comment">// to the same application</span> <a name="l00531"></a>00531 <span class="keywordtype">bool</span> Workspace::allowFullClientRaising( <span class="keyword">const</span> <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, Time time ) <a name="l00532"></a>00532 { <a name="l00533"></a>00533 <span class="keywordtype">int</span> level = c-><a class="code" href="classKWinInternal_1_1Client.html#a20">rules</a>()-><a class="code" href="classKWinInternal_1_1WindowRules.html#a24">checkFSP</a>( <a class="code" href="namespaceKWinInternal.html#a13">options</a>-><a class="code" href="classKWinInternal_1_1Options.html#o24">focusStealingPreventionLevel</a> ); <a name="l00534"></a>00534 <span class="keywordflow">if</span>( session_saving && level <= 2 ) <span class="comment">// <= normal</span> <a name="l00535"></a>00535 { <a name="l00536"></a>00536 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00537"></a>00537 } <a name="l00538"></a>00538 Client* ac = <a class="code" href="classKWinInternal_1_1Workspace.html#a15">mostRecentlyActivatedClient</a>(); <a name="l00539"></a>00539 <span class="keywordflow">if</span>( level == 0 ) <span class="comment">// none</span> <a name="l00540"></a>00540 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00541"></a>00541 <span class="keywordflow">if</span>( level == 4 ) <span class="comment">// extreme</span> <a name="l00542"></a>00542 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00543"></a>00543 <span class="keywordflow">if</span>( ac == NULL || ac->isDesktop()) <a name="l00544"></a>00544 { <a name="l00545"></a>00545 kdDebug( 1212 ) << <span class="stringliteral">"Raising: No client active, allowing"</span> << endl; <a name="l00546"></a>00546 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// no active client -> always allow</span> <a name="l00547"></a>00547 } <a name="l00548"></a>00548 <span class="keywordflow">if</span>( c-><a class="code" href="classKWinInternal_1_1Client.html#a150">ignoreFocusStealing</a>()) <a name="l00549"></a>00549 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00550"></a>00550 <span class="comment">// TODO window urgency -> return true?</span> <a name="l00551"></a>00551 <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Client.html#e7">Client::belongToSameApplication</a>( c, ac, <span class="keyword">true</span> )) <a name="l00552"></a>00552 { <a name="l00553"></a>00553 kdDebug( 1212 ) << <span class="stringliteral">"Raising: Belongs to active application"</span> << endl; <a name="l00554"></a>00554 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00555"></a>00555 } <a name="l00556"></a>00556 <span class="keywordflow">if</span>( level == 3 ) <span class="comment">// high</span> <a name="l00557"></a>00557 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00558"></a>00558 Time user_time = ac->userTime(); <a name="l00559"></a>00559 kdDebug( 1212 ) << <span class="stringliteral">"Raising, compared:"</span> << time << <span class="stringliteral">":"</span> << user_time <a name="l00560"></a>00560 << <span class="stringliteral">":"</span> << ( <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( time, user_time ) >= 0 ) << endl; <a name="l00561"></a>00561 <span class="keywordflow">return</span> <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( time, user_time ) >= 0; <span class="comment">// time >= user_time</span> <a name="l00562"></a>00562 } <a name="l00563"></a>00563 <a name="l00564"></a>00564 <span class="comment">// called from Client after FocusIn that wasn't initiated by KWin and the client</span> <a name="l00565"></a>00565 <span class="comment">// wasn't allowed to activate</span> <a name="l00566"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a21">00566</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a21">Workspace::restoreFocus</a>() <a name="l00567"></a>00567 { <a name="l00568"></a>00568 <span class="comment">// this updateXTime() is necessary - as FocusIn events don't have</span> <a name="l00569"></a>00569 <span class="comment">// a timestamp *sigh*, kwin's timestamp would be older than the timestamp</span> <a name="l00570"></a>00570 <span class="comment">// that was used by whoever caused the focus change, and therefore</span> <a name="l00571"></a>00571 <span class="comment">// the attempt to restore the focus would fail due to old timestamp</span> <a name="l00572"></a>00572 <a class="code" href="namespaceKWinInternal.html#a104">updateXTime</a>(); <a name="l00573"></a>00573 <span class="keywordflow">if</span>( should_get_focus.count() > 0 ) <a name="l00574"></a>00574 <a class="code" href="classKWinInternal_1_1Workspace.html#a17">requestFocus</a>( should_get_focus.last()); <a name="l00575"></a>00575 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( last_active_client ) <a name="l00576"></a>00576 <a class="code" href="classKWinInternal_1_1Workspace.html#a17">requestFocus</a>( last_active_client ); <a name="l00577"></a>00577 } <a name="l00578"></a>00578 <a name="l00579"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a43">00579</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a43">Workspace::clientAttentionChanged</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c, <span class="keywordtype">bool</span> set ) <a name="l00580"></a>00580 { <a name="l00581"></a>00581 <span class="keywordflow">if</span>( set ) <a name="l00582"></a>00582 { <a name="l00583"></a>00583 attention_chain.remove( c ); <a name="l00584"></a>00584 attention_chain.prepend( c ); <a name="l00585"></a>00585 } <a name="l00586"></a>00586 <span class="keywordflow">else</span> <a name="l00587"></a>00587 attention_chain.remove( c ); <a name="l00588"></a>00588 } <a name="l00589"></a>00589 <a name="l00590"></a>00590 <span class="comment">// This is used when a client should be shown active immediately after requestFocus(),</span> <a name="l00591"></a>00591 <span class="comment">// without waiting for the matching FocusIn that will really make the window the active one.</span> <a name="l00592"></a>00592 <span class="comment">// Used only in special cases, e.g. for MouseActivateRaiseandMove with transparent windows,</span> <a name="l00593"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a24">00593</a> <span class="keywordtype">bool</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a24">Workspace::fakeRequestedActivity</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c ) <a name="l00594"></a>00594 { <a name="l00595"></a>00595 <span class="keywordflow">if</span>( should_get_focus.count() > 0 && should_get_focus.last() == c ) <a name="l00596"></a>00596 { <a name="l00597"></a>00597 <span class="keywordflow">if</span>( c-><a class="code" href="classKWinInternal_1_1Client.html#a41">isActive</a>()) <a name="l00598"></a>00598 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00599"></a>00599 c-><a class="code" href="classKWinInternal_1_1Client.html#a42">setActive</a>( <span class="keyword">true</span> ); <a name="l00600"></a>00600 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00601"></a>00601 } <a name="l00602"></a>00602 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00603"></a>00603 } <a name="l00604"></a>00604 <a name="l00605"></a><a class="code" href="classKWinInternal_1_1Workspace.html#a25">00605</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Workspace.html#a25">Workspace::unfakeActivity</a>( <a class="code" href="classKWinInternal_1_1Client.html">Client</a>* c ) <a name="l00606"></a>00606 { <a name="l00607"></a>00607 <span class="keywordflow">if</span>( should_get_focus.count() > 0 && should_get_focus.last() == c ) <a name="l00608"></a>00608 { <span class="comment">// TODO this will cause flicker, and probably is not needed</span> <a name="l00609"></a>00609 <span class="keywordflow">if</span>( last_active_client != NULL ) <a name="l00610"></a>00610 last_active_client-><a class="code" href="classKWinInternal_1_1Client.html#a42">setActive</a>( <span class="keyword">true</span> ); <a name="l00611"></a>00611 <span class="keywordflow">else</span> <a name="l00612"></a>00612 c-><a class="code" href="classKWinInternal_1_1Client.html#a42">setActive</a>( <span class="keyword">false</span> ); <a name="l00613"></a>00613 } <a name="l00614"></a>00614 } <a name="l00615"></a>00615 <a name="l00616"></a>00616 <a name="l00617"></a>00617 <span class="comment">//********************************************</span> <a name="l00618"></a>00618 <span class="comment">// Client</span> <a name="l00619"></a>00619 <span class="comment">//********************************************</span> <a name="l00620"></a>00620 <a name="l00627"></a><a class="code" href="classKWinInternal_1_1Client.html#a147">00627</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Client.html#a147">Client::updateUserTime</a>( Time time ) <a name="l00628"></a>00628 { <span class="comment">// copied in Group::updateUserTime</span> <a name="l00629"></a>00629 <span class="keywordflow">if</span>( time == CurrentTime ) <a name="l00630"></a>00630 time = qt_x_time; <a name="l00631"></a>00631 <span class="keywordflow">if</span>( time != -1U <a name="l00632"></a>00632 && ( user_time == CurrentTime <a name="l00633"></a>00633 || <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( time, user_time ) > 0 )) <span class="comment">// time > user_time</span> <a name="l00634"></a>00634 user_time = time; <a name="l00635"></a>00635 } <a name="l00636"></a>00636 <a name="l00637"></a>00637 Time Client::readUserCreationTime()<span class="keyword"> const</span> <a name="l00638"></a>00638 <span class="keyword"> </span>{ <a name="l00639"></a>00639 <span class="keywordtype">long</span> result = -1; <span class="comment">// Time == -1 means none</span> <a name="l00640"></a>00640 Atom type; <a name="l00641"></a>00641 <span class="keywordtype">int</span> format, status; <a name="l00642"></a>00642 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> nitems = 0; <a name="l00643"></a>00643 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> extra = 0; <a name="l00644"></a>00644 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *data = 0; <a name="l00645"></a>00645 KXErrorHandler handler; <span class="comment">// ignore errors?</span> <a name="l00646"></a>00646 status = XGetWindowProperty( qt_xdisplay(), <a class="code" href="classKWinInternal_1_1Client.html#a1">window</a>(), <a name="l00647"></a>00647 <a class="code" href="namespaceKWinInternal.html#a0">atoms</a>-><a class="code" href="classKWinInternal_1_1Atoms.html#o11">kde_net_wm_user_creation_time</a>, 0, 10000, FALSE, XA_CARDINAL, <a name="l00648"></a>00648 &type, &format, &nitems, &extra, &data ); <a name="l00649"></a>00649 <span class="keywordflow">if</span> (status == Success ) <a name="l00650"></a>00650 { <a name="l00651"></a>00651 <span class="keywordflow">if</span> (data && nitems > 0) <a name="l00652"></a>00652 result = *((<span class="keywordtype">long</span>*) data); <a name="l00653"></a>00653 XFree(data); <a name="l00654"></a>00654 } <a name="l00655"></a>00655 <span class="keywordflow">return</span> result; <a name="l00656"></a>00656 } <a name="l00657"></a>00657 <a name="l00658"></a><a class="code" href="classKWinInternal_1_1Client.html#a102">00658</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Client.html#a102">Client::demandAttention</a>( <span class="keywordtype">bool</span> set ) <a name="l00659"></a>00659 { <a name="l00660"></a>00660 <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Client.html#a41">isActive</a>()) <a name="l00661"></a>00661 set = <span class="keyword">false</span>; <a name="l00662"></a>00662 info->setState( set ? NET::DemandsAttention : 0, NET::DemandsAttention ); <a name="l00663"></a>00663 <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a43">clientAttentionChanged</a>( <span class="keyword">this</span>, set ); <a name="l00664"></a>00664 } <a name="l00665"></a>00665 <a name="l00666"></a>00666 <span class="comment">// TODO I probably shouldn't be lazy here and do it without the macro, so that people can read it</span> <a name="l00667"></a>00667 KWIN_COMPARE_PREDICATE( SameApplicationActiveHackPredicate, <span class="keyword">const</span> <a class="code" href="classKWinInternal_1_1Client.html">Client</a>*, <a name="l00668"></a>00668 <span class="comment">// ignore already existing splashes, toolbars, utilities, menus and topmenus,</span> <a name="l00669"></a>00669 <span class="comment">// as the app may show those before the main window</span> <a name="l00670"></a>00670 !cl->isSplash() && !cl->isToolbar() && !cl->isTopMenu() && !cl->isUtility() && !cl->isMenu() <a name="l00671"></a>00671 && <a class="code" href="classKWinInternal_1_1Client.html#e7">Client::belongToSameApplication</a>( cl, value, <span class="keyword">true</span> ) && cl != value); <a name="l00672"></a>00672 <a name="l00673"></a>00673 Time Client::readUserTimeMapTimestamp( <span class="keyword">const</span> KStartupInfoId* asn_id, <span class="keyword">const</span> KStartupInfoData* asn_data, <a name="l00674"></a>00674 <span class="keywordtype">bool</span> session )<span class="keyword"> const</span> <a name="l00675"></a>00675 <span class="keyword"> </span>{ <a name="l00676"></a>00676 Time time = info->userTime(); <a name="l00677"></a>00677 kdDebug( 1212 ) << <span class="stringliteral">"User timestamp, initial:"</span> << time << endl; <a name="l00678"></a>00678 <span class="comment">// newer ASN timestamp always replaces user timestamp, unless user timestamp is 0</span> <a name="l00679"></a>00679 <span class="comment">// helps e.g. with konqy reusing</span> <a name="l00680"></a>00680 <span class="keywordflow">if</span>( asn_data != NULL && time != 0 ) <a name="l00681"></a>00681 { <a name="l00682"></a>00682 <span class="comment">// prefer timestamp from ASN id (timestamp from data is obsolete way)</span> <a name="l00683"></a>00683 <span class="keywordflow">if</span>( asn_id->timestamp() != 0 <a name="l00684"></a>00684 && ( time == -1U || <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( asn_id->timestamp(), time ) > 0 )) <a name="l00685"></a>00685 { <a name="l00686"></a>00686 time = asn_id->timestamp(); <a name="l00687"></a>00687 } <a name="l00688"></a>00688 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( asn_data->timestamp() != -1U <a name="l00689"></a>00689 && ( time == -1U || <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( asn_data->timestamp(), time ) > 0 )) <a name="l00690"></a>00690 { <a name="l00691"></a>00691 time = asn_data->timestamp(); <a name="l00692"></a>00692 } <a name="l00693"></a>00693 } <a name="l00694"></a>00694 kdDebug( 1212 ) << <span class="stringliteral">"User timestamp, ASN:"</span> << time << endl; <a name="l00695"></a>00695 <span class="keywordflow">if</span>( time == -1U ) <a name="l00696"></a>00696 { <span class="comment">// The window doesn't have any timestamp.</span> <a name="l00697"></a>00697 <span class="comment">// If it's the first window for its application</span> <a name="l00698"></a>00698 <span class="comment">// (i.e. there's no other window from the same app),</span> <a name="l00699"></a>00699 <span class="comment">// use the _KDE_NET_WM_USER_CREATION_TIME trick.</span> <a name="l00700"></a>00700 <span class="comment">// Otherwise, refuse activation of a window</span> <a name="l00701"></a>00701 <span class="comment">// from already running application if this application</span> <a name="l00702"></a>00702 <span class="comment">// is not the active one (unless focus stealing prevention is turned off).</span> <a name="l00703"></a>00703 <a class="code" href="classKWinInternal_1_1Client.html#a0">Client</a>* act = <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()->mostRecentlyActivatedClient(); <a name="l00704"></a>00704 <span class="keywordflow">if</span>( act != NULL && !<a class="code" href="classKWinInternal_1_1Client.html#e7">belongToSameApplication</a>( act, <span class="keyword">this</span>, <span class="keyword">true</span> )) <a name="l00705"></a>00705 { <a name="l00706"></a>00706 <span class="keywordtype">bool</span> first_window = <span class="keyword">true</span>; <a name="l00707"></a>00707 <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Client.html#a8">isTransient</a>()) <a name="l00708"></a>00708 { <a name="l00709"></a>00709 <span class="keywordflow">if</span>( act->hasTransient( <span class="keyword">this</span>, <span class="keyword">true</span> )) <a name="l00710"></a>00710 ; <span class="comment">// is transient for currently active window, even though it's not</span> <a name="l00711"></a>00711 <span class="comment">// the same app (e.g. kcookiejar dialog) -> allow activation</span> <a name="l00712"></a>00712 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Client.html#a9">groupTransient</a>() && <a name="l00713"></a>00713 <a class="code" href="namespaceKWinInternal.html#a111">findClientInList</a>( <a class="code" href="classKWinInternal_1_1Client.html#a11">mainClients</a>(), SameApplicationActiveHackPredicate( <span class="keyword">this</span> )) == NULL ) <a name="l00714"></a>00714 ; <span class="comment">// standalone transient</span> <a name="l00715"></a>00715 <span class="keywordflow">else</span> <a name="l00716"></a>00716 first_window = <span class="keyword">false</span>; <a name="l00717"></a>00717 } <a name="l00718"></a>00718 <span class="keywordflow">else</span> <a name="l00719"></a>00719 { <a name="l00720"></a>00720 <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()->findClient( SameApplicationActiveHackPredicate( <span class="keyword">this</span> ))) <a name="l00721"></a>00721 first_window = <span class="keyword">false</span>; <a name="l00722"></a>00722 } <a name="l00723"></a>00723 <span class="comment">// don't refuse if focus stealing prevention is turned off</span> <a name="l00724"></a>00724 <span class="keywordflow">if</span>( !first_window && <a class="code" href="classKWinInternal_1_1Client.html#a20">rules</a>()->checkFSP( <a class="code" href="namespaceKWinInternal.html#a13">options</a>->focusStealingPreventionLevel ) > 0 ) <a name="l00725"></a>00725 { <a name="l00726"></a>00726 kdDebug( 1212 ) << <span class="stringliteral">"User timestamp, already exists:"</span> << 0 << endl; <a name="l00727"></a>00727 <span class="keywordflow">return</span> 0; <span class="comment">// refuse activation</span> <a name="l00728"></a>00728 } <a name="l00729"></a>00729 } <a name="l00730"></a>00730 <span class="comment">// Creation time would just mess things up during session startup,</span> <a name="l00731"></a>00731 <span class="comment">// as possibly many apps are started up at the same time.</span> <a name="l00732"></a>00732 <span class="comment">// If there's no active window yet, no timestamp will be needed,</span> <a name="l00733"></a>00733 <span class="comment">// as plain Workspace::allowClientActivation() will return true</span> <a name="l00734"></a>00734 <span class="comment">// in such case. And if there's already active window,</span> <a name="l00735"></a>00735 <span class="comment">// it's better not to activate the new one.</span> <a name="l00736"></a>00736 <span class="comment">// Unless it was the active window at the time</span> <a name="l00737"></a>00737 <span class="comment">// of session saving and there was no user interaction yet,</span> <a name="l00738"></a>00738 <span class="comment">// this check will be done in manage().</span> <a name="l00739"></a>00739 <span class="keywordflow">if</span>( session ) <a name="l00740"></a>00740 <span class="keywordflow">return</span> -1U; <a name="l00741"></a>00741 <span class="keywordflow">if</span>( <a class="code" href="classKWinInternal_1_1Client.html#a150">ignoreFocusStealing</a>() && act != NULL ) <a name="l00742"></a>00742 time = act->userTime(); <a name="l00743"></a>00743 <span class="keywordflow">else</span> <a name="l00744"></a>00744 time = readUserCreationTime(); <a name="l00745"></a>00745 } <a name="l00746"></a>00746 kdDebug( 1212 ) << <span class="stringliteral">"User timestamp, final:"</span> << <span class="keyword">this</span> << <span class="stringliteral">":"</span> << time << endl; <a name="l00747"></a>00747 <span class="keywordflow">return</span> time; <a name="l00748"></a>00748 } <a name="l00749"></a>00749 <a name="l00750"></a><a class="code" href="classKWinInternal_1_1Client.html#a148">00750</a> Time <a class="code" href="classKWinInternal_1_1Client.html#a148">Client::userTime</a>()<span class="keyword"> const</span> <a name="l00751"></a>00751 <span class="keyword"> </span>{ <a name="l00752"></a>00752 Time time = user_time; <a name="l00753"></a>00753 <span class="keywordflow">if</span>( time == 0 ) <span class="comment">// doesn't want focus after showing</span> <a name="l00754"></a>00754 <span class="keywordflow">return</span> 0; <a name="l00755"></a>00755 assert( <a class="code" href="classKWinInternal_1_1Client.html#a16">group</a>() != NULL ); <a name="l00756"></a>00756 <span class="keywordflow">if</span>( time == -1U <a name="l00757"></a>00757 || ( <a class="code" href="classKWinInternal_1_1Client.html#a16">group</a>()-><a class="code" href="classKWinInternal_1_1Group.html#a15">userTime</a>() != -1U <a name="l00758"></a>00758 && <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( <a class="code" href="classKWinInternal_1_1Client.html#a16">group</a>()-><a class="code" href="classKWinInternal_1_1Client.html#a148">userTime</a>(), time ) > 0 )) <a name="l00759"></a>00759 time = <a class="code" href="classKWinInternal_1_1Client.html#a16">group</a>()-><a class="code" href="classKWinInternal_1_1Group.html#a15">userTime</a>(); <a name="l00760"></a>00760 <span class="keywordflow">return</span> time; <a name="l00761"></a>00761 } <a name="l00762"></a>00762 <a name="l00774"></a><a class="code" href="classKWinInternal_1_1Client.html#a42">00774</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Client.html#a42">Client::setActive</a>( <span class="keywordtype">bool</span> act, <span class="keywordtype">bool</span> updateOpacity_) <a name="l00775"></a>00775 { <a name="l00776"></a>00776 <span class="keywordflow">if</span> ( active == act ) <a name="l00777"></a>00777 <span class="keywordflow">return</span>; <a name="l00778"></a>00778 active = act; <a name="l00779"></a>00779 <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a91">setActiveClient</a>( act ? <span class="keyword">this</span> : NULL, Allowed ); <a name="l00780"></a>00780 <a name="l00781"></a>00781 <span class="keywordflow">if</span> (updateOpacity_) <a class="code" href="classKWinInternal_1_1Client.html#a163">updateOpacity</a>(); <a name="l00782"></a>00782 <span class="keywordflow">if</span> (<a class="code" href="classKWinInternal_1_1Client.html#a82">isModal</a>() && <a class="code" href="classKWinInternal_1_1Client.html#a6">transientFor</a>()) <a name="l00783"></a>00783 { <a name="l00784"></a>00784 <span class="keywordflow">if</span> (!act) <a class="code" href="classKWinInternal_1_1Client.html#a6">transientFor</a>()-><a class="code" href="classKWinInternal_1_1Client.html#a163">updateOpacity</a>(); <a name="l00785"></a>00785 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!<a class="code" href="classKWinInternal_1_1Client.html#a6">transientFor</a>()->custom_opacity) <a class="code" href="classKWinInternal_1_1Client.html#a6">transientFor</a>()-><a class="code" href="classKWinInternal_1_1Client.html#a161">setOpacity</a>(<a class="code" href="namespaceKWinInternal.html#a13">options</a>-><a class="code" href="classKWinInternal_1_1Options.html#o28">translucentActiveWindows</a>, <a class="code" href="namespaceKWinInternal.html#a13">options</a>-><a class="code" href="classKWinInternal_1_1Options.html#o29">activeWindowOpacity</a>); <a name="l00786"></a>00786 } <a name="l00787"></a>00787 <a class="code" href="classKWinInternal_1_1Client.html#a164">updateShadowSize</a>(); <a name="l00788"></a>00788 <a name="l00789"></a>00789 <span class="keywordflow">if</span> ( active ) <a name="l00790"></a>00790 <a class="code" href="classKWinInternal_1_1Notify.html#e0">Notify::raise</a>( Notify::Activate ); <a name="l00791"></a>00791 <a name="l00792"></a>00792 <span class="keywordflow">if</span>( !active ) <a name="l00793"></a>00793 <a class="code" href="classKWinInternal_1_1Client.html#a158">cancelAutoRaise</a>(); <a name="l00794"></a>00794 <a name="l00795"></a>00795 <span class="keywordflow">if</span>( !active && shade_mode == ShadeActivated ) <a name="l00796"></a>00796 <a class="code" href="classKWinInternal_1_1Client.html#a52">setShade</a>( ShadeNormal ); <a name="l00797"></a>00797 <a name="l00798"></a>00798 <a class="code" href="classKWinInternal_1_1StackingUpdatesBlocker.html">StackingUpdatesBlocker</a> blocker( <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()); <a name="l00799"></a>00799 <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a39">updateClientLayer</a>( <span class="keyword">this</span> ); <span class="comment">// active windows may get different layer</span> <a name="l00800"></a>00800 <span class="comment">// TODO optimize? mainClients() may be a bit expensive</span> <a name="l00801"></a>00801 <a class="code" href="namespaceKWinInternal.html#a24">ClientList</a> mainclients = <a class="code" href="classKWinInternal_1_1Client.html#a11">mainClients</a>(); <a name="l00802"></a>00802 <span class="keywordflow">for</span>( ClientList::ConstIterator it = mainclients.begin(); <a name="l00803"></a>00803 it != mainclients.end(); <a name="l00804"></a>00804 ++it ) <a name="l00805"></a>00805 <span class="keywordflow">if</span>( (*it)->isFullScreen()) <span class="comment">// fullscreens go high even if their transient is active</span> <a name="l00806"></a>00806 <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a39">updateClientLayer</a>( *it ); <a name="l00807"></a>00807 <span class="keywordflow">if</span>( decoration != NULL ) <a name="l00808"></a>00808 decoration-><a class="code" href="classKDecoration.html#a40">activeChange</a>(); <a name="l00809"></a>00809 <a class="code" href="classKWinInternal_1_1Client.html#a139">updateMouseGrab</a>(); <a name="l00810"></a>00810 updateUrgency(); <span class="comment">// demand attention again if it's still urgent</span> <a name="l00811"></a>00811 } <a name="l00812"></a>00812 <a name="l00813"></a>00813 <span class="keywordtype">void</span> Client::startupIdChanged() <a name="l00814"></a>00814 { <a name="l00815"></a>00815 KStartupInfoId asn_id; <a name="l00816"></a>00816 KStartupInfoData asn_data; <a name="l00817"></a>00817 <span class="keywordtype">bool</span> asn_valid = <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a96">checkStartupNotification</a>( <a class="code" href="classKWinInternal_1_1Client.html#a1">window</a>(), asn_id, asn_data ); <a name="l00818"></a>00818 <span class="keywordflow">if</span>( !asn_valid ) <a name="l00819"></a>00819 <span class="keywordflow">return</span>; <a name="l00820"></a>00820 <span class="keywordflow">if</span>( asn_data.desktop() != 0 ) <a name="l00821"></a>00821 <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a60">sendClientToDesktop</a>( <span class="keyword">this</span>, asn_data.desktop(), true ); <a name="l00822"></a>00822 Time timestamp = asn_id.timestamp(); <a name="l00823"></a>00823 <span class="keywordflow">if</span>( timestamp == 0 && asn_data.timestamp() != -1U ) <a name="l00824"></a>00824 timestamp = asn_data.timestamp(); <a name="l00825"></a>00825 <span class="keywordflow">if</span>( timestamp != 0 ) <a name="l00826"></a>00826 { <a name="l00827"></a>00827 <span class="keywordtype">bool</span> activate = <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a20">allowClientActivation</a>( <span class="keyword">this</span>, timestamp ); <a name="l00828"></a>00828 <span class="keywordflow">if</span>( asn_data.desktop() != 0 && !<a class="code" href="classKWinInternal_1_1Client.html#a46">isOnCurrentDesktop</a>()) <a name="l00829"></a>00829 activate = <span class="keyword">false</span>; <span class="comment">// it was started on different desktop than current one</span> <a name="l00830"></a>00830 <span class="keywordflow">if</span>( activate ) <a name="l00831"></a>00831 <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()-><a class="code" href="classKWinInternal_1_1Workspace.html#a16">activateClient</a>( <span class="keyword">this</span> ); <a name="l00832"></a>00832 <span class="keywordflow">else</span> <a name="l00833"></a>00833 <a class="code" href="classKWinInternal_1_1Client.html#a102">demandAttention</a>(); <a name="l00834"></a>00834 } <a name="l00835"></a>00835 } <a name="l00836"></a>00836 <a name="l00837"></a>00837 <span class="keywordtype">void</span> Client::updateUrgency() <a name="l00838"></a>00838 { <a name="l00839"></a>00839 <span class="keywordflow">if</span>( urgency ) <a name="l00840"></a>00840 <a class="code" href="classKWinInternal_1_1Client.html#a102">demandAttention</a>(); <a name="l00841"></a>00841 } <a name="l00842"></a>00842 <a name="l00843"></a>00843 <span class="keywordtype">void</span> Client::shortcutActivated() <a name="l00844"></a>00844 { <a name="l00845"></a>00845 <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()->activateClient( <span class="keyword">this</span>, <span class="keyword">true</span> ); <span class="comment">// force</span> <a name="l00846"></a>00846 } <a name="l00847"></a>00847 <a name="l00848"></a>00848 <span class="comment">//****************************************</span> <a name="l00849"></a>00849 <span class="comment">// Group</span> <a name="l00850"></a>00850 <span class="comment">//****************************************</span> <a name="l00851"></a>00851 <a name="l00852"></a>00852 <span class="keywordtype">void</span> Group::startupIdChanged() <a name="l00853"></a>00853 { <a name="l00854"></a>00854 KStartupInfoId asn_id; <a name="l00855"></a>00855 KStartupInfoData asn_data; <a name="l00856"></a>00856 <span class="keywordtype">bool</span> asn_valid = <a class="code" href="classKWinInternal_1_1Client.html#a5">workspace</a>()->checkStartupNotification( leader_wid, asn_id, asn_data ); <a name="l00857"></a>00857 <span class="keywordflow">if</span>( !asn_valid ) <a name="l00858"></a>00858 <span class="keywordflow">return</span>; <a name="l00859"></a>00859 <span class="keywordflow">if</span>( asn_id.timestamp() != 0 && user_time != -1U <a name="l00860"></a>00860 && <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( asn_id.timestamp(), user_time ) > 0 ) <a name="l00861"></a>00861 { <a name="l00862"></a>00862 user_time = asn_id.timestamp(); <a name="l00863"></a>00863 } <a name="l00864"></a>00864 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( asn_data.timestamp() != -1U && user_time != -1U <a name="l00865"></a>00865 && <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( asn_data.timestamp(), user_time ) > 0 ) <a name="l00866"></a>00866 { <a name="l00867"></a>00867 user_time = asn_data.timestamp(); <a name="l00868"></a>00868 } <a name="l00869"></a>00869 } <a name="l00870"></a>00870 <a name="l00871"></a><a class="code" href="classKWinInternal_1_1Group.html#a14">00871</a> <span class="keywordtype">void</span> <a class="code" href="classKWinInternal_1_1Group.html#a14">Group::updateUserTime</a>( Time time ) <a name="l00872"></a>00872 { <span class="comment">// copy of Client::updateUserTime</span> <a name="l00873"></a>00873 <span class="keywordflow">if</span>( time == CurrentTime ) <a name="l00874"></a>00874 time = qt_x_time; <a name="l00875"></a>00875 <span class="keywordflow">if</span>( time != -1U <a name="l00876"></a>00876 && ( user_time == CurrentTime <a name="l00877"></a>00877 || <a class="code" href="namespaceKWinInternal.html#a112">timestampCompare</a>( time, user_time ) > 0 )) <span class="comment">// time > user_time</span> <a name="l00878"></a>00878 user_time = time; <a name="l00879"></a>00879 } <a name="l00880"></a>00880 <a name="l00881"></a>00881 } <span class="comment">// namespace</span> </pre></div></div> <div id="bottom-nav"> <img src="../../common/bottom2.png" align="right" height="59" width="227" alt="KDE Logo"> </div> <div class="bottom"> This file is part of the documentation for kwin Library Version 3.4.2. </div> <div class="bottom" style="color:#cccccc"> Documentation copyright © 1996-2004 the KDE developers.<br> Generated on Wed Jun 14 19:06:08 2006 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.4.4 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2003 </div> </body> </html>