2003-09-16 19:28:03 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to handling incoming events.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "client.h"
|
|
|
|
|
|
|
|
#include <kstartupinfo.h>
|
2004-03-01 17:20:19 +00:00
|
|
|
#include <kglobal.h>
|
2003-09-16 19:28:03 +00:00
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
|
|
|
|
#include "notifications.h"
|
2005-07-28 14:59:42 +00:00
|
|
|
#include <QX11Info>
|
2004-05-28 13:51:11 +00:00
|
|
|
#include "rules.h"
|
2006-01-20 15:49:03 +00:00
|
|
|
#include "group.h"
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Manages the clients. This means handling the very first maprequest:
|
|
|
|
reparenting, initial geometry, initial state, placement, etc.
|
|
|
|
Returns false if KWin is not going to manage this window.
|
|
|
|
*/
|
2003-11-24 15:05:50 +00:00
|
|
|
bool Client::manage( Window w, bool isMapped )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2006-04-20 14:57:10 +00:00
|
|
|
StackingUpdatesBlocker stacking_blocker( workspace());
|
|
|
|
|
2006-09-30 17:28:27 +00:00
|
|
|
grabXServer();
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
XWindowAttributes attr;
|
2006-08-10 17:00:14 +00:00
|
|
|
if( !XGetWindowAttributes(display(), w, &attr))
|
2006-09-30 17:28:27 +00:00
|
|
|
{
|
|
|
|
ungrabXServer();
|
2003-09-16 19:28:03 +00:00
|
|
|
return false;
|
2006-09-30 17:28:27 +00:00
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
// from this place on, manage() mustn't return false
|
2005-06-08 17:16:53 +00:00
|
|
|
postpone_geometry_updates = 1;
|
2005-06-08 17:32:19 +00:00
|
|
|
pending_geometry_update = true; // force update when finishing with geometry changes
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2003-12-11 17:41:47 +00:00
|
|
|
embedClient( w, attr );
|
2006-09-30 17:28:27 +00:00
|
|
|
|
|
|
|
vis = attr.visual;
|
2006-10-21 15:23:01 +00:00
|
|
|
bit_depth = attr.depth;
|
2006-09-30 17:28:27 +00:00
|
|
|
|
|
|
|
setupCompositing();
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
// SELI order all these things in some sane manner
|
|
|
|
|
2003-11-20 16:25:52 +00:00
|
|
|
bool init_minimize = false;
|
2006-08-10 17:00:14 +00:00
|
|
|
XWMHints * hints = XGetWMHints(display(), w );
|
2003-11-20 16:25:52 +00:00
|
|
|
if (hints && (hints->flags & StateHint) && hints->initial_state == IconicState)
|
|
|
|
init_minimize = true;
|
|
|
|
if (hints)
|
|
|
|
XFree(hints);
|
|
|
|
if( isMapped )
|
|
|
|
init_minimize = false; // if it's already mapped, ignore hint
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
unsigned long properties[ 2 ];
|
|
|
|
properties[ WinInfo::PROTOCOLS ] =
|
|
|
|
NET::WMDesktop |
|
|
|
|
NET::WMState |
|
|
|
|
NET::WMWindowType |
|
|
|
|
NET::WMStrut |
|
|
|
|
NET::WMName |
|
|
|
|
NET::WMIconGeometry |
|
|
|
|
NET::WMIcon |
|
|
|
|
NET::WMPid |
|
|
|
|
NET::WMIconName |
|
|
|
|
0;
|
|
|
|
properties[ WinInfo::PROTOCOLS2 ] =
|
|
|
|
NET::WM2UserTime |
|
|
|
|
NET::WM2StartupId |
|
2004-02-17 17:34:00 +00:00
|
|
|
NET::WM2ExtendedStrut |
|
2006-09-30 17:28:27 +00:00
|
|
|
NET::WM2Opacity |
|
2003-09-16 19:28:03 +00:00
|
|
|
0;
|
|
|
|
|
2006-08-10 17:00:14 +00:00
|
|
|
info = new WinInfo( this, display(), client, rootWindow(), properties, 2 );
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
cmap = attr.colormap;
|
|
|
|
|
|
|
|
XClassHint classHint;
|
2006-08-10 17:00:14 +00:00
|
|
|
if ( XGetClassHint( display(), client, &classHint ) )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2004-02-23 12:47:28 +00:00
|
|
|
// Qt3.2 and older had this all lowercase, Qt3.3 capitalized resource class
|
|
|
|
// force lowercase, so that workarounds listing resource classes still work
|
2006-03-17 18:18:20 +00:00
|
|
|
resource_name = QByteArray( classHint.res_name ).toLower();
|
|
|
|
resource_class = QByteArray( classHint.res_class ).toLower();
|
2003-09-16 19:28:03 +00:00
|
|
|
XFree( classHint.res_name );
|
|
|
|
XFree( classHint.res_class );
|
|
|
|
}
|
2004-05-28 15:04:01 +00:00
|
|
|
ignore_focus_stealing = options->checkIgnoreFocusStealing( this ); // TODO change to rules
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2004-06-28 13:47:02 +00:00
|
|
|
window_role = staticWindowRole( w );
|
2005-02-07 14:35:53 +00:00
|
|
|
getWmClientLeader();
|
|
|
|
getWmClientMachine();
|
2004-05-31 14:25:25 +00:00
|
|
|
// first only read the caption text, so that setupWindowRules() can use it for matching,
|
2004-05-28 15:04:01 +00:00
|
|
|
// and only then really set the caption using setCaption(), which checks for duplicates etc.
|
|
|
|
// and also relies on rules already existing
|
|
|
|
cap_normal = readName();
|
2004-06-11 15:10:09 +00:00
|
|
|
setupWindowRules( false );
|
2004-05-28 15:04:01 +00:00
|
|
|
setCaption( cap_normal, true );
|
2004-05-28 13:51:11 +00:00
|
|
|
|
2006-09-30 17:28:27 +00:00
|
|
|
if( Extensions::shapeAvailable())
|
|
|
|
XShapeSelectInput( display(), window(), ShapeNotifyMask );
|
|
|
|
detectShape( window());
|
2004-05-28 13:51:11 +00:00
|
|
|
detectNoBorder();
|
2003-09-16 19:28:03 +00:00
|
|
|
fetchIconicName();
|
2003-12-10 11:28:31 +00:00
|
|
|
getWMHints(); // needs to be done before readTransient() because of reading the group
|
2004-06-03 16:16:27 +00:00
|
|
|
modal = ( info->state() & NET::Modal ) != 0; // needs to be valid before handling groups
|
2003-09-16 19:28:03 +00:00
|
|
|
readTransient();
|
|
|
|
getIcons();
|
|
|
|
getWindowProtocols();
|
|
|
|
getWmNormalHints(); // get xSizeHint
|
2004-07-27 08:35:51 +00:00
|
|
|
getMotifHints();
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
// TODO try to obey all state information from info->state()
|
|
|
|
|
|
|
|
original_skip_taskbar = skip_taskbar = ( info->state() & NET::SkipTaskbar) != 0;
|
|
|
|
skip_pager = ( info->state() & NET::SkipPager) != 0;
|
|
|
|
|
2004-05-26 09:24:14 +00:00
|
|
|
KStartupInfoId asn_id;
|
2003-09-16 19:28:03 +00:00
|
|
|
KStartupInfoData asn_data;
|
2004-05-26 09:24:14 +00:00
|
|
|
bool asn_valid = workspace()->checkStartupNotification( window(), asn_id, asn_data );
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
workspace()->updateClientLayer( this );
|
|
|
|
|
|
|
|
SessionInfo* session = workspace()->takeSessionInfo( this );
|
2004-05-28 13:51:11 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
if ( session )
|
|
|
|
{
|
|
|
|
if ( session->minimized )
|
|
|
|
init_minimize = true;
|
|
|
|
if( session->userNoBorder )
|
|
|
|
setUserNoBorder( true );
|
|
|
|
}
|
2005-01-17 15:53:14 +00:00
|
|
|
|
2006-01-02 16:27:55 +00:00
|
|
|
setShortcut( rules()->checkShortcut( session ? session->shortcut : QString(), true ));
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2004-06-03 14:09:45 +00:00
|
|
|
init_minimize = rules()->checkMinimize( init_minimize, !isMapped );
|
|
|
|
if( rules()->checkNoBorder( false, !isMapped ))
|
|
|
|
setUserNoBorder( true );
|
2005-01-15 17:07:48 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
// initial desktop placement
|
|
|
|
if ( session )
|
|
|
|
{
|
|
|
|
desk = session->desktop;
|
|
|
|
if( session->onAllDesktops )
|
|
|
|
desk = NET::OnAllDesktops;
|
|
|
|
}
|
2004-11-04 18:32:30 +00:00
|
|
|
else
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
// if this window is transient, ensure that it is opened on the
|
|
|
|
// same window as its parent. this is necessary when an application
|
|
|
|
// starts up on a different desktop than is currently displayed
|
|
|
|
if( isTransient())
|
|
|
|
{
|
|
|
|
ClientList mainclients = mainClients();
|
|
|
|
bool on_current = false;
|
2004-01-15 14:30:02 +00:00
|
|
|
Client* maincl = NULL;
|
|
|
|
// this is slightly duplicated from Placement::placeOnMainWindow()
|
2003-09-16 19:28:03 +00:00
|
|
|
for( ClientList::ConstIterator it = mainclients.begin();
|
|
|
|
it != mainclients.end();
|
|
|
|
++it )
|
2004-01-15 14:30:02 +00:00
|
|
|
{
|
2005-05-11 14:20:54 +00:00
|
|
|
if( (*it)->isSpecialWindow())
|
2004-01-15 14:30:02 +00:00
|
|
|
continue; // don't consider toolbars etc when placing
|
|
|
|
maincl = *it;
|
2003-09-16 19:28:03 +00:00
|
|
|
if( (*it)->isOnCurrentDesktop())
|
|
|
|
on_current = true;
|
2004-01-15 14:30:02 +00:00
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
if( on_current )
|
|
|
|
desk = workspace()->currentDesktop();
|
2004-01-15 14:30:02 +00:00
|
|
|
else if( maincl != NULL )
|
|
|
|
desk = maincl->desktop();
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
2004-11-04 18:32:30 +00:00
|
|
|
if ( info->desktop() )
|
|
|
|
desk = info->desktop(); // window had the initial desktop property, force it
|
|
|
|
if( desktop() == 0 && asn_valid && asn_data.desktop() != 0 )
|
|
|
|
desk = asn_data.desktop();
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
if ( desk == 0 ) // assume window wants to be visible on the current desktop
|
|
|
|
desk = workspace()->currentDesktop();
|
2004-07-20 14:29:28 +00:00
|
|
|
desk = rules()->checkDesktop( desk, !isMapped );
|
2004-03-01 17:20:19 +00:00
|
|
|
if( desk != NET::OnAllDesktops ) // do range check
|
2005-10-22 11:35:06 +00:00
|
|
|
desk = qMax( 1, qMin( workspace()->numberOfDesktops(), desk ));
|
2003-09-16 19:28:03 +00:00
|
|
|
info->setDesktop( desk );
|
|
|
|
workspace()->updateOnAllDesktopsOfTransients( this ); // SELI
|
|
|
|
// onAllDesktopsChange(); decoration doesn't exist here yet
|
|
|
|
|
|
|
|
QRect geom( attr.x, attr.y, attr.width, attr.height );
|
2006-02-19 01:33:48 +00:00
|
|
|
bool placementDone = false;
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
if ( session )
|
|
|
|
geom = session->geometry;
|
|
|
|
|
2003-11-24 15:05:50 +00:00
|
|
|
QRect area;
|
2004-12-13 11:40:25 +00:00
|
|
|
bool partial_keep_in_area = isMapped || session;
|
2004-01-21 08:46:32 +00:00
|
|
|
if( isMapped || session )
|
2004-07-30 11:36:47 +00:00
|
|
|
area = workspace()->clientArea( FullArea, geom.center(), desktop());
|
2004-01-10 15:13:23 +00:00
|
|
|
else if( options->xineramaPlacementEnabled )
|
2003-11-24 15:05:50 +00:00
|
|
|
area = workspace()->clientArea( PlacementArea, QCursor::pos(), desktop());
|
|
|
|
else
|
|
|
|
area = workspace()->clientArea( PlacementArea, geom.center(), desktop());
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2006-02-28 13:03:31 +00:00
|
|
|
if( int type = checkFullScreenHack( geom ))
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
fullscreen_mode = FullScreenHack;
|
2006-02-28 13:03:31 +00:00
|
|
|
if( rules()->checkStrictGeometry( false ))
|
|
|
|
{
|
|
|
|
geom = type == 2 // 1 - it's xinerama-aware fullscreen hack, 2 - it's full area
|
|
|
|
? workspace()->clientArea( FullArea, geom.center(), desktop())
|
|
|
|
: workspace()->clientArea( ScreenArea, geom.center(), desktop());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
geom = workspace()->clientArea( FullScreenArea, geom.center(), desktop());
|
2003-09-16 19:28:03 +00:00
|
|
|
placementDone = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isDesktop() )
|
|
|
|
{
|
|
|
|
// desktops are treated slightly special
|
2003-10-10 12:58:38 +00:00
|
|
|
geom = workspace()->clientArea( FullArea, geom.center(), desktop());
|
2003-09-16 19:28:03 +00:00
|
|
|
placementDone = true;
|
|
|
|
}
|
|
|
|
|
2004-06-21 12:38:40 +00:00
|
|
|
bool usePosition = false;
|
|
|
|
if ( isMapped || session || placementDone )
|
|
|
|
placementDone = true; // use geometry
|
|
|
|
else if( isTransient() && !isUtility() && !isDialog() && !isSplash())
|
|
|
|
usePosition = true;
|
2003-10-02 08:56:44 +00:00
|
|
|
else if( isTransient() && !hasNETSupport())
|
2004-06-21 12:38:40 +00:00
|
|
|
usePosition = true;
|
|
|
|
else if( isDialog() && hasNETSupport())
|
|
|
|
// if the dialog is actually non-NETWM transient window, don't try to apply placement to it,
|
|
|
|
// it breaks with too many things (xmms, display)
|
2004-08-27 12:24:30 +00:00
|
|
|
{
|
|
|
|
if( mainClients().count() >= 1 )
|
2005-01-27 14:21:31 +00:00
|
|
|
{
|
|
|
|
#if 1
|
|
|
|
// TODO #78082 - Ok, it seems there are after all some cases when an application has a good
|
|
|
|
// reason to specify a position for its dialog. Too bad other WMs have never bothered
|
|
|
|
// with placement for dialogs, so apps always specify positions for their dialogs,
|
|
|
|
// including such silly positions like always centered on the screen or under mouse.
|
|
|
|
// Using ignoring requested position in window-specific settings helps, but at least
|
|
|
|
// for Qt apps this should work better.
|
|
|
|
usePosition = true;
|
|
|
|
#else
|
2004-08-27 12:24:30 +00:00
|
|
|
; // force using placement policy
|
2005-01-27 14:21:31 +00:00
|
|
|
#endif
|
|
|
|
}
|
2004-08-27 12:24:30 +00:00
|
|
|
else
|
|
|
|
usePosition = true;
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
else if( isSplash())
|
|
|
|
; // force using placement policy
|
|
|
|
else
|
2004-06-21 12:38:40 +00:00
|
|
|
usePosition = true;
|
2005-08-08 14:27:03 +00:00
|
|
|
if( !rules()->checkIgnoreGeometry( !usePosition ))
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2003-12-15 13:36:27 +00:00
|
|
|
bool ignorePPosition = ( options->ignorePositionClasses.contains(QString::fromLatin1(resourceClass())));
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
if ( ( (xSizeHint.flags & PPosition) && !ignorePPosition ) ||
|
|
|
|
(xSizeHint.flags & USPosition) )
|
|
|
|
{
|
2006-02-19 01:33:48 +00:00
|
|
|
placementDone = true;
|
2004-03-22 16:39:58 +00:00
|
|
|
// disobey xinerama placement option for now (#70943)
|
|
|
|
area = workspace()->clientArea( PlacementArea, geom.center(), desktop());
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
2004-06-21 12:38:40 +00:00
|
|
|
}
|
|
|
|
if( true ) // size is always obeyed for now, only with constraints applied
|
2003-09-16 19:28:03 +00:00
|
|
|
if ( (xSizeHint.flags & USSize) || (xSizeHint.flags & PSize) )
|
|
|
|
{
|
|
|
|
// keep in mind that we now actually have a size :-)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xSizeHint.flags & PMaxSize)
|
2004-05-31 14:15:33 +00:00
|
|
|
geom.setSize( geom.size().boundedTo(
|
|
|
|
rules()->checkMaxSize( QSize(xSizeHint.max_width, xSizeHint.max_height ) ) ) );
|
2003-09-16 19:28:03 +00:00
|
|
|
if (xSizeHint.flags & PMinSize)
|
2004-05-31 14:15:33 +00:00
|
|
|
geom.setSize( geom.size().expandedTo(
|
|
|
|
rules()->checkMinSize( QSize(xSizeHint.min_width, xSizeHint.min_height ) ) ) );
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2003-09-19 11:14:16 +00:00
|
|
|
if( isMovable())
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
if( geom.x() > area.right() || geom.y() > area.bottom())
|
2006-02-19 01:33:48 +00:00
|
|
|
placementDone = false; // weird, do not trust.
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( placementDone )
|
|
|
|
move( geom.x(), geom.y() ); // before gravitating
|
|
|
|
|
|
|
|
updateDecoration( false ); // also gravitates
|
2003-10-01 12:10:22 +00:00
|
|
|
// TODO is CentralGravity right here, when resizing is done after gravitating?
|
2004-06-03 14:09:45 +00:00
|
|
|
plainResize( rules()->checkSize( sizeForClientSize( geom.size()), !isMapped ));
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2004-06-03 14:09:45 +00:00
|
|
|
QPoint forced_pos = rules()->checkPosition( invalidPoint, !isMapped );
|
2004-05-31 14:25:25 +00:00
|
|
|
if( forced_pos != invalidPoint )
|
|
|
|
{
|
|
|
|
move( forced_pos );
|
|
|
|
placementDone = true;
|
2004-12-13 11:40:25 +00:00
|
|
|
// don't keep inside workarea if the window has specially configured position
|
|
|
|
partial_keep_in_area = true;
|
|
|
|
area = workspace()->clientArea( FullArea, geom.center(), desktop());
|
2004-05-31 14:25:25 +00:00
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
if( !placementDone )
|
|
|
|
{ // placement needs to be after setting size
|
2004-01-10 15:13:23 +00:00
|
|
|
workspace()->place( this, area );
|
2006-02-19 01:33:48 +00:00
|
|
|
placementDone = true;
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
2004-12-13 11:40:25 +00:00
|
|
|
if(( !isSpecialWindow() || isToolbar()) && isMovable())
|
|
|
|
keepInArea( area, partial_keep_in_area );
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2006-09-30 17:28:27 +00:00
|
|
|
if( shape())
|
|
|
|
updateShape();
|
2005-01-28 23:28:11 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
//CT extra check for stupid jdk 1.3.1. But should make sense in general
|
|
|
|
// if client has initial state set to Iconic and is transient with a parent
|
|
|
|
// window that is not Iconic, set init_state to Normal
|
|
|
|
if( init_minimize && isTransient())
|
|
|
|
{
|
2003-10-01 15:46:23 +00:00
|
|
|
ClientList mainclients = mainClients();
|
|
|
|
for( ClientList::ConstIterator it = mainclients.begin();
|
|
|
|
it != mainclients.end();
|
2003-09-16 19:28:03 +00:00
|
|
|
++it )
|
2003-10-10 13:00:01 +00:00
|
|
|
if( (*it)->isShown( true ))
|
2003-09-16 19:28:03 +00:00
|
|
|
init_minimize = false; // SELI even e.g. for NET::Utility?
|
|
|
|
}
|
|
|
|
|
|
|
|
if( init_minimize )
|
2004-03-01 18:00:07 +00:00
|
|
|
minimize( true ); // no animation
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
// SELI this seems to be mainly for kstart and ksystraycmd
|
|
|
|
// probably should be replaced by something better
|
|
|
|
bool doNotShow = false;
|
|
|
|
if ( workspace()->isNotManaged( caption() ) )
|
2006-02-19 01:33:48 +00:00
|
|
|
doNotShow = true;
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
// other settings from the previous session
|
|
|
|
if ( session )
|
|
|
|
{
|
2004-05-28 13:51:11 +00:00
|
|
|
// session restored windows are not considered to be new windows WRT rules,
|
|
|
|
// i.e. obey only forcing rules
|
2003-09-16 19:28:03 +00:00
|
|
|
setKeepAbove( session->keepAbove );
|
|
|
|
setKeepBelow( session->keepBelow );
|
|
|
|
setSkipTaskbar( session->skipTaskbar, true );
|
|
|
|
setSkipPager( session->skipPager );
|
|
|
|
setShade( session->shaded ? ShadeNormal : ShadeNone );
|
|
|
|
if( session->maximized != MaximizeRestore )
|
|
|
|
{
|
|
|
|
maximize( (MaximizeMode) session->maximized );
|
|
|
|
geom_restore = session->restore;
|
|
|
|
}
|
|
|
|
if( session->fullscreen == FullScreenHack )
|
|
|
|
; // nothing, this should be already set again above
|
|
|
|
else if( session->fullscreen != FullScreenNone )
|
|
|
|
{
|
|
|
|
setFullScreen( true, false );
|
|
|
|
geom_fs_restore = session->fsrestore;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geom_restore = geometry(); // remember restore geometry
|
|
|
|
if ( isMaximizable()
|
|
|
|
&& ( width() >= area.width() || height() >= area.height() ) )
|
|
|
|
{
|
|
|
|
// window is too large for the screen, maximize in the
|
|
|
|
// directions necessary
|
|
|
|
if ( width() >= area.width() && height() >= area.height() )
|
|
|
|
{
|
|
|
|
maximize( Client::MaximizeFull );
|
|
|
|
geom_restore = QRect(); // use placement when unmaximizing
|
|
|
|
}
|
|
|
|
else if ( width() >= area.width() )
|
|
|
|
{
|
|
|
|
maximize( Client::MaximizeHorizontal );
|
|
|
|
geom_restore = QRect(); // use placement when unmaximizing
|
|
|
|
geom_restore.setY( y()); // but only for horizontal direction
|
|
|
|
geom_restore.setHeight( height());
|
|
|
|
}
|
|
|
|
else if ( height() >= area.height() )
|
|
|
|
{
|
|
|
|
maximize( Client::MaximizeVertical );
|
|
|
|
geom_restore = QRect(); // use placement when unmaximizing
|
|
|
|
geom_restore.setX( x()); // but only for vertical direction
|
|
|
|
geom_restore.setWidth( width());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// window may want to be maximized
|
|
|
|
// done after checking that the window isn't larger than the workarea, so that
|
|
|
|
// the restore geometry from the checks above takes precedence, and window
|
|
|
|
// isn't restored larger than the workarea
|
2004-06-03 14:09:45 +00:00
|
|
|
MaximizeMode maxmode = static_cast< MaximizeMode >
|
|
|
|
((( info->state() & NET::MaxVert ) ? MaximizeVertical : 0 )
|
|
|
|
| (( info->state() & NET::MaxHoriz ) ? MaximizeHorizontal : 0 ));
|
|
|
|
MaximizeMode forced_maxmode = rules()->checkMaximize( maxmode, !isMapped );
|
|
|
|
// either hints were set to maximize, or is forced to maximize,
|
|
|
|
// or is forced to non-maximize and hints were set to maximize
|
|
|
|
if( forced_maxmode != MaximizeRestore || maxmode != MaximizeRestore )
|
|
|
|
maximize( forced_maxmode );
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2003-10-10 12:59:40 +00:00
|
|
|
// read other initial states
|
2004-06-03 14:09:45 +00:00
|
|
|
setShade( rules()->checkShade( info->state() & NET::Shaded ? ShadeNormal : ShadeNone, !isMapped ));
|
2004-05-28 13:51:11 +00:00
|
|
|
setKeepAbove( rules()->checkKeepAbove( info->state() & NET::KeepAbove, !isMapped ));
|
|
|
|
setKeepBelow( rules()->checkKeepBelow( info->state() & NET::KeepBelow, !isMapped ));
|
2004-06-03 14:09:45 +00:00
|
|
|
setSkipTaskbar( rules()->checkSkipTaskbar( info->state() & NET::SkipTaskbar, !isMapped ), true );
|
|
|
|
setSkipPager( rules()->checkSkipPager( info->state() & NET::SkipPager, !isMapped ));
|
2003-10-10 12:59:40 +00:00
|
|
|
if( info->state() & NET::DemandsAttention )
|
|
|
|
demandAttention();
|
|
|
|
if( info->state() & NET::Modal )
|
|
|
|
setModal( true );
|
2004-06-03 14:09:45 +00:00
|
|
|
if( fullscreen_mode != FullScreenHack && isFullScreenable())
|
|
|
|
setFullScreen( rules()->checkFullScreen( info->state() & NET::FullScreen, !isMapped ), false );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateAllowedActions( true );
|
|
|
|
|
2006-01-20 15:49:03 +00:00
|
|
|
// set initial user time directly
|
2004-05-26 09:24:14 +00:00
|
|
|
user_time = readUserTimeMapTimestamp( asn_valid ? &asn_id : NULL, asn_valid ? &asn_data : NULL, session );
|
2006-01-20 15:49:03 +00:00
|
|
|
group()->updateUserTime( user_time ); // and do what Client::updateUserTime() does
|
2003-09-24 18:31:30 +00:00
|
|
|
|
2003-11-04 10:53:04 +00:00
|
|
|
if( isTopMenu()) // they're shown in Workspace::addClient() if their mainwindow
|
|
|
|
hideClient( true ); // is the active one
|
|
|
|
|
2006-04-20 14:57:10 +00:00
|
|
|
// this should avoid flicker, because real restacking is done
|
|
|
|
// only after manage() finishes because of blocking, but the window is shown sooner
|
2006-08-10 17:00:14 +00:00
|
|
|
XLowerWindow( display(), frameId());
|
2006-04-20 14:57:10 +00:00
|
|
|
if( session && session->stackingOrder != -1 )
|
|
|
|
{
|
|
|
|
sm_stacking_order = session->stackingOrder;
|
|
|
|
workspace()->restoreSessionStackingOrder( this );
|
|
|
|
}
|
|
|
|
|
2005-04-12 17:44:05 +00:00
|
|
|
if( isShown( true ) && !doNotShow )
|
2005-04-12 17:22:47 +00:00
|
|
|
{
|
|
|
|
if( isDialog())
|
|
|
|
Notify::raise( Notify::TransNew );
|
|
|
|
if( isNormalWindow())
|
|
|
|
Notify::raise( Notify::New );
|
|
|
|
|
|
|
|
bool allow;
|
|
|
|
if( session )
|
2006-06-02 22:47:04 +00:00
|
|
|
allow = session->active
|
|
|
|
&& ( !workspace()->wasUserInteraction()
|
|
|
|
|| workspace()->activeClient() == NULL || workspace()->activeClient()->isDesktop());
|
2005-04-12 17:22:47 +00:00
|
|
|
else
|
|
|
|
allow = workspace()->allowClientActivation( this, userTime(), false );
|
|
|
|
|
|
|
|
// if session saving, force showing new windows (i.e. "save file?" dialogs etc.)
|
|
|
|
// also force if activation is allowed
|
|
|
|
if( !isOnCurrentDesktop() && !isMapped && !session && ( allow || workspace()->sessionSaving()))
|
|
|
|
workspace()->setCurrentDesktop( desktop());
|
|
|
|
|
2006-04-10 22:11:44 +00:00
|
|
|
bool belongs_to_desktop = false;
|
|
|
|
for( ClientList::ConstIterator it = group()->members().begin();
|
|
|
|
it != group()->members().end();
|
|
|
|
++it )
|
|
|
|
if( (*it)->isDesktop())
|
|
|
|
{
|
|
|
|
belongs_to_desktop = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( !belongs_to_desktop && workspace()->showingDesktop())
|
2006-05-30 11:47:16 +00:00
|
|
|
workspace()->resetShowingDesktop( options->showDesktopIsMinimizeAll );
|
2005-05-13 08:57:21 +00:00
|
|
|
|
2006-04-20 14:57:10 +00:00
|
|
|
if( isOnCurrentDesktop() && !isMapped && !allow && (!session || session->stackingOrder < 0 ))
|
2005-04-12 17:22:47 +00:00
|
|
|
workspace()->restackClientUnderActive( this );
|
|
|
|
|
|
|
|
updateVisibility();
|
|
|
|
|
|
|
|
if( !isMapped )
|
|
|
|
{
|
|
|
|
if( allow && isOnCurrentDesktop())
|
|
|
|
{
|
2005-05-11 14:20:54 +00:00
|
|
|
if( !isSpecialWindow())
|
2005-04-12 17:22:47 +00:00
|
|
|
if ( options->focusPolicyIsReasonable() && wantsTabFocus() )
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-11 14:20:54 +00:00
|
|
|
if( !session && !isSpecialWindow())
|
2005-04-12 17:22:47 +00:00
|
|
|
demandAttention();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-12 17:44:05 +00:00
|
|
|
else if( !doNotShow ) // if( !isShown( true ) && !doNotShow )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2005-04-12 17:44:05 +00:00
|
|
|
updateVisibility();
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
else // doNotShow
|
|
|
|
{ // SELI HACK !!!
|
2003-11-04 10:53:04 +00:00
|
|
|
hideClient( true );
|
2003-09-16 19:28:03 +00:00
|
|
|
setMappingState( IconicState );
|
|
|
|
}
|
|
|
|
assert( mappingState() != WithdrawnState );
|
|
|
|
|
2003-10-02 14:38:17 +00:00
|
|
|
if( user_time == CurrentTime || user_time == -1U ) // no known user time, set something old
|
|
|
|
{
|
2006-08-10 17:00:14 +00:00
|
|
|
user_time = xTime() - 1000000;
|
2003-10-02 14:38:17 +00:00
|
|
|
if( user_time == CurrentTime || user_time == -1U ) // let's be paranoid
|
2006-08-10 17:00:14 +00:00
|
|
|
user_time = xTime() - 1000000 + 10;
|
2003-10-02 14:38:17 +00:00
|
|
|
}
|
2003-09-24 18:31:30 +00:00
|
|
|
|
2003-10-10 12:58:38 +00:00
|
|
|
updateWorkareaDiffs();
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
// sendSyntheticConfigureNotify(); done when setting mapping state
|
|
|
|
|
|
|
|
delete session;
|
2006-09-30 17:28:27 +00:00
|
|
|
|
2003-12-04 13:54:10 +00:00
|
|
|
ungrabXServer();
|
2004-06-11 15:10:09 +00:00
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
client_rules.discardTemporary();
|
2005-06-07 15:31:15 +00:00
|
|
|
applyWindowRules(); // just in case
|
|
|
|
workspace()->discardUsedWindowRules( this, false ); // remove ApplyNow rules
|
2004-07-20 14:35:33 +00:00
|
|
|
updateWindowRules(); // was blocked while !isManaged()
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2004-11-04 17:56:05 +00:00
|
|
|
// TODO there's a small problem here - isManaged() depends on the mapping state,
|
|
|
|
// but this client is not yet in Workspace's client list at this point, will
|
|
|
|
// be only done in addClient()
|
2003-09-16 19:28:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// called only from manage()
|
2003-12-11 17:41:47 +00:00
|
|
|
void Client::embedClient( Window w, const XWindowAttributes &attr )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
assert( client == None );
|
2006-09-30 17:28:27 +00:00
|
|
|
assert( frameId() == None );
|
2003-09-16 19:28:03 +00:00
|
|
|
assert( wrapper == None );
|
|
|
|
client = w;
|
|
|
|
// we don't want the window to be destroyed when we are destroyed
|
2006-08-10 17:00:14 +00:00
|
|
|
XAddToSaveSet( display(), client );
|
|
|
|
XSelectInput( display(), client, NoEventMask );
|
|
|
|
XUnmapWindow( display(), client );
|
2003-09-16 19:28:03 +00:00
|
|
|
XWindowChanges wc; // set the border width to 0
|
|
|
|
wc.border_width = 0; // TODO possibly save this, and also use it for initial configuring of the window
|
2006-08-10 17:00:14 +00:00
|
|
|
XConfigureWindow( display(), client, CWBorderWidth, &wc );
|
2003-12-11 17:41:47 +00:00
|
|
|
|
|
|
|
XSetWindowAttributes swa;
|
|
|
|
swa.colormap = attr.colormap;
|
|
|
|
swa.background_pixmap = None;
|
|
|
|
swa.border_pixel = 0;
|
|
|
|
|
2006-09-30 17:28:27 +00:00
|
|
|
Window frame = XCreateWindow( display(), rootWindow(), 0, 0, 1, 1, 0,
|
2003-12-11 17:41:47 +00:00
|
|
|
attr.depth, InputOutput, attr.visual,
|
|
|
|
CWColormap | CWBackPixmap | CWBorderPixel, &swa );
|
2006-09-30 17:28:27 +00:00
|
|
|
setHandle( frame );
|
2006-08-10 17:00:14 +00:00
|
|
|
wrapper = XCreateWindow( display(), frame, 0, 0, 1, 1, 0,
|
2003-12-11 17:41:47 +00:00
|
|
|
attr.depth, InputOutput, attr.visual,
|
|
|
|
CWColormap | CWBackPixmap | CWBorderPixel, &swa );
|
|
|
|
|
2006-08-10 17:00:14 +00:00
|
|
|
XDefineCursor( display(), frame, QCursor( Qt::ArrowCursor ).handle());
|
2003-09-16 19:28:03 +00:00
|
|
|
// some apps are stupid and don't define their own cursor - set the arrow one for them
|
2006-08-10 17:00:14 +00:00
|
|
|
XDefineCursor( display(), wrapper, QCursor( Qt::ArrowCursor ).handle());
|
|
|
|
XReparentWindow( display(), client, wrapper, 0, 0 );
|
|
|
|
XSelectInput( display(), frame,
|
2003-09-16 19:28:03 +00:00
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeymapStateMask |
|
|
|
|
ButtonMotionMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
ExposureMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
StructureNotifyMask | SubstructureRedirectMask |
|
|
|
|
VisibilityChangeMask );
|
2006-08-10 17:00:14 +00:00
|
|
|
XSelectInput( display(), wrapper, ClientWinMask | SubstructureNotifyMask );
|
|
|
|
XSelectInput( display(), client,
|
2003-09-16 19:28:03 +00:00
|
|
|
FocusChangeMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ColormapChangeMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
KeyPressMask | KeyReleaseMask
|
|
|
|
);
|
|
|
|
updateMouseGrab();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|