2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +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>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// This file contains things relevant to handling incoming events.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "client.h"
|
|
|
|
|
|
|
|
#include <kstartupinfo.h>
|
|
|
|
#include <kglobal.h>
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
|
|
|
|
#include "notifications.h"
|
|
|
|
#include <QX11Info>
|
|
|
|
#include "rules.h"
|
|
|
|
#include "group.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
bool Client::manage(Window w, bool isMapped)
|
|
|
|
{
|
|
|
|
StackingUpdatesBlocker stacking_blocker(workspace());
|
2010-11-14 08:45:55 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
grabXServer();
|
|
|
|
|
|
|
|
XWindowAttributes attr;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!XGetWindowAttributes(display(), w, &attr)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
ungrabXServer();
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// From this place on, manage() must not return false
|
2007-04-29 17:35:43 +00:00
|
|
|
block_geometry_updates = 1;
|
2008-12-18 15:01:25 +00:00
|
|
|
pending_geometry_update = PendingGeometryForced; // Force update when finishing with geometry changes
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
embedClient(w, attr);
|
2008-12-18 15:01:25 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
vis = attr.visual;
|
|
|
|
bit_depth = attr.depth;
|
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// SELI TODO: Order all these things in some sane manner
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool init_minimize = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
XWMHints* hints = XGetWMHints(display(), w);
|
|
|
|
if (hints && (hints->flags & StateHint) && hints->initial_state == IconicState)
|
2007-04-29 17:35:43 +00:00
|
|
|
init_minimize = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (hints)
|
|
|
|
XFree(hints);
|
|
|
|
if (isMapped)
|
2008-12-18 15:01:25 +00:00
|
|
|
init_minimize = false; // If it's already mapped, ignore hint
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
unsigned long properties[2];
|
|
|
|
properties[WinInfo::PROTOCOLS] =
|
2007-04-29 17:35:43 +00:00
|
|
|
NET::WMDesktop |
|
|
|
|
NET::WMState |
|
|
|
|
NET::WMWindowType |
|
|
|
|
NET::WMStrut |
|
|
|
|
NET::WMName |
|
|
|
|
NET::WMIconGeometry |
|
|
|
|
NET::WMIcon |
|
|
|
|
NET::WMPid |
|
|
|
|
NET::WMIconName |
|
|
|
|
0;
|
2008-12-18 15:01:25 +00:00
|
|
|
properties[WinInfo::PROTOCOLS2] =
|
2007-04-29 17:35:43 +00:00
|
|
|
NET::WM2UserTime |
|
|
|
|
NET::WM2StartupId |
|
|
|
|
NET::WM2ExtendedStrut |
|
|
|
|
NET::WM2Opacity |
|
2008-11-17 08:03:39 +00:00
|
|
|
NET::WM2FullscreenMonitors |
|
2009-11-25 23:32:35 +00:00
|
|
|
NET::WM2FrameOverlap |
|
2007-04-29 17:35:43 +00:00
|
|
|
0;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
info = new WinInfo(this, display(), client, rootWindow(), properties, 2);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
cmap = attr.colormap;
|
|
|
|
|
|
|
|
getResourceClass();
|
|
|
|
getWindowRole();
|
|
|
|
getWmClientLeader();
|
|
|
|
getWmClientMachine();
|
2007-06-25 08:51:44 +00:00
|
|
|
getSyncCounter();
|
2008-12-18 15:01:25 +00:00
|
|
|
// First only read the caption text, so that setupWindowRules() can use it for matching,
|
2007-04-29 17:35:43 +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();
|
2011-01-30 14:34:42 +00:00
|
|
|
setupWindowRules(false);
|
|
|
|
setCaption(cap_normal, true);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (Extensions::shapeAvailable())
|
|
|
|
XShapeSelectInput(display(), window(), ShapeNotifyMask);
|
|
|
|
detectShape(window());
|
2007-04-29 17:35:43 +00:00
|
|
|
detectNoBorder();
|
|
|
|
fetchIconicName();
|
2008-12-18 15:01:25 +00:00
|
|
|
getWMHints(); // Needs to be done before readTransient() because of reading the group
|
2011-01-30 14:34:42 +00:00
|
|
|
modal = (info->state() & NET::Modal) != 0; // Needs to be valid before handling groups
|
2007-04-29 17:35:43 +00:00
|
|
|
readTransient();
|
|
|
|
getIcons();
|
|
|
|
getWindowProtocols();
|
2008-12-18 15:01:25 +00:00
|
|
|
getWmNormalHints(); // Get xSizeHint
|
2007-04-29 17:35:43 +00:00
|
|
|
getMotifHints();
|
2011-10-22 09:02:49 +00:00
|
|
|
getWmOpaqueRegion();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// TODO: Try to obey all state information from info->state()
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
original_skip_taskbar = skip_taskbar = (info->state() & NET::SkipTaskbar) != 0;
|
|
|
|
skip_pager = (info->state() & NET::SkipPager) != 0;
|
2011-12-01 12:15:11 +00:00
|
|
|
updateFirstInTabBox();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-08-12 11:02:58 +00:00
|
|
|
setupCompositing();
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
KStartupInfoId asn_id;
|
|
|
|
KStartupInfoData asn_data;
|
2011-01-30 14:34:42 +00:00
|
|
|
bool asn_valid = workspace()->checkStartupNotification(window(), asn_id, asn_data);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-11-09 19:39:13 +00:00
|
|
|
// Make sure that the input window is created before we update the stacking order
|
|
|
|
updateInputWindow();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateClientLayer(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
SessionInfo* session = workspace()->takeSessionInfo(this);
|
|
|
|
if (session) {
|
2008-03-23 00:12:11 +00:00
|
|
|
init_minimize = session->minimized;
|
|
|
|
noborder = session->noBorder;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
setShortcut(rules()->checkShortcut(session ? session->shortcut : QString(), true));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
init_minimize = rules()->checkMinimize(init_minimize, !isMapped);
|
|
|
|
noborder = rules()->checkNoBorder(noborder, !isMapped);
|
2008-12-18 15:01:25 +00:00
|
|
|
|
2010-09-24 12:03:22 +00:00
|
|
|
checkActivities();
|
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// Initial desktop placement
|
2011-01-30 14:34:42 +00:00
|
|
|
if (session) {
|
2007-04-29 17:35:43 +00:00
|
|
|
desk = session->desktop;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (session->onAllDesktops)
|
2007-04-29 17:35:43 +00:00
|
|
|
desk = NET::OnAllDesktops;
|
2010-10-02 17:04:24 +00:00
|
|
|
setOnActivities(session->activities);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2008-12-18 15:01:25 +00:00
|
|
|
// If this window is transient, ensure that it is opened on the
|
2007-04-29 17:35:43 +00:00
|
|
|
// same window as its parent. this is necessary when an application
|
|
|
|
// starts up on a different desktop than is currently displayed
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isTransient()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
ClientList mainclients = mainClients();
|
|
|
|
bool on_current = false;
|
2010-08-19 12:07:44 +00:00
|
|
|
bool on_all = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
Client* maincl = NULL;
|
2008-12-18 15:01:25 +00:00
|
|
|
// This is slightly duplicated from Placement::placeOnMainWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = mainclients.constBegin();
|
|
|
|
it != mainclients.constEnd();
|
|
|
|
++it) {
|
|
|
|
if (mainclients.count() > 1 && (*it)->isSpecialWindow())
|
2008-12-18 15:01:25 +00:00
|
|
|
continue; // Don't consider toolbars etc when placing
|
2007-04-29 17:35:43 +00:00
|
|
|
maincl = *it;
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((*it)->isOnCurrentDesktop())
|
2007-04-29 17:35:43 +00:00
|
|
|
on_current = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((*it)->isOnAllDesktops())
|
2010-08-19 12:07:44 +00:00
|
|
|
on_all = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (on_all)
|
2010-08-19 12:07:44 +00:00
|
|
|
desk = NET::OnAllDesktops;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (on_current)
|
2007-04-29 17:35:43 +00:00
|
|
|
desk = workspace()->currentDesktop();
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (maincl != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
desk = maincl->desktop();
|
2010-09-26 16:44:07 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (maincl)
|
2010-09-26 16:44:07 +00:00
|
|
|
setOnActivities(maincl->activities());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (info->desktop())
|
2008-12-18 15:01:25 +00:00
|
|
|
desk = info->desktop(); // Window had the initial desktop property, force it
|
2011-01-30 14:34:42 +00:00
|
|
|
if (desktop() == 0 && asn_valid && asn_data.desktop() != 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
desk = asn_data.desktop();
|
2010-12-16 20:14:22 +00:00
|
|
|
if (!isMapped && !noborder && isNormalWindow() && !activitiesDefined) {
|
2010-11-11 23:37:50 +00:00
|
|
|
//a new, regular window, when we're not recovering from a crash,
|
|
|
|
//and it hasn't got an activity. let's try giving it the current one.
|
|
|
|
//TODO: decide whether to keep this before the 4.6 release
|
2010-11-14 10:35:16 +00:00
|
|
|
//TODO: if we are keeping it (at least as an option), replace noborder checking
|
|
|
|
//with a public API for setting windows to be on all activities.
|
|
|
|
//something like KWindowSystem::setOnAllActivities or
|
|
|
|
//KActivityConsumer::setOnAllActivities
|
2010-11-11 23:37:50 +00:00
|
|
|
setOnActivity(Workspace::self()->currentActivity(), true);
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-05-17 14:32:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (desk == 0) // Assume window wants to be visible on the current desktop
|
2012-02-29 00:17:42 +00:00
|
|
|
desk = isDesktop() ? NET::OnAllDesktops : workspace()->currentDesktop();
|
2011-01-30 14:34:42 +00:00
|
|
|
desk = rules()->checkDesktop(desk, !isMapped);
|
|
|
|
if (desk != NET::OnAllDesktops) // Do range check
|
|
|
|
desk = qMax(1, qMin(workspace()->numberOfDesktops(), desk));
|
|
|
|
info->setDesktop(desk);
|
|
|
|
workspace()->updateOnAllDesktopsOfTransients(this); // SELI TODO
|
2008-12-18 15:01:25 +00:00
|
|
|
//onAllDesktopsChange(); // Decoration doesn't exist here yet
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-05-17 14:32:06 +00:00
|
|
|
QString activitiesList;
|
|
|
|
activitiesList = rules()->checkActivity(activitiesList, !isMapped);
|
|
|
|
if (!activitiesList.isEmpty())
|
|
|
|
setOnActivities(activitiesList.split(","));
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect geom(attr.x, attr.y, attr.width, attr.height);
|
2007-04-29 17:35:43 +00:00
|
|
|
bool placementDone = false;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (session)
|
2007-04-29 17:35:43 +00:00
|
|
|
geom = session->geometry;
|
|
|
|
|
|
|
|
QRect area;
|
|
|
|
bool partial_keep_in_area = isMapped || session;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMapped || session)
|
|
|
|
area = workspace()->clientArea(FullArea, geom.center(), desktop());
|
2012-01-22 10:04:55 +00:00
|
|
|
else {
|
|
|
|
int screen = asn_data.xinerama() == -1 ? workspace()->activeScreen() : asn_data.xinerama();
|
2012-08-24 16:48:50 +00:00
|
|
|
screen = rules()->checkScreen(screen, !isMapped);
|
2011-01-30 14:34:42 +00:00
|
|
|
area = workspace()->clientArea(PlacementArea, workspace()->screenGeometry(screen).center(), desktop());
|
2012-01-22 10:04:55 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (int type = checkFullScreenHack(geom)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
fullscreen_mode = FullScreenHack;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (rules()->checkStrictGeometry(false)) {
|
2008-12-18 15:01:25 +00:00
|
|
|
geom = type == 2 // 1 = It's xinerama-aware fullscreen hack, 2 = It's full area
|
2011-01-30 14:34:42 +00:00
|
|
|
? workspace()->clientArea(FullArea, geom.center(), desktop())
|
|
|
|
: workspace()->clientArea(ScreenArea, geom.center(), desktop());
|
|
|
|
} else
|
|
|
|
geom = workspace()->clientArea(FullScreenArea, geom.center(), desktop());
|
2007-04-29 17:35:43 +00:00
|
|
|
placementDone = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isDesktop())
|
2008-12-18 15:01:25 +00:00
|
|
|
// KWin doesn't manage desktop windows
|
2008-05-02 16:39:49 +00:00
|
|
|
placementDone = true;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool usePosition = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMapped || session || placementDone)
|
2008-12-18 15:01:25 +00:00
|
|
|
placementDone = true; // Use geometry
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (isTransient() && !isUtility() && !isDialog() && !isSplash())
|
2007-04-29 17:35:43 +00:00
|
|
|
usePosition = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (isTransient() && !hasNETSupport())
|
2007-04-29 17:35:43 +00:00
|
|
|
usePosition = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
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)
|
|
|
|
if (mainClients().count() >= 1) {
|
2007-04-29 17:35:43 +00:00
|
|
|
#if 1
|
2007-07-19 16:38:46 +00:00
|
|
|
// #78082 - Ok, it seems there are after all some cases when an application has a good
|
2007-04-29 17:35:43 +00:00
|
|
|
// 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.
|
2007-07-19 16:38:46 +00:00
|
|
|
// Using ignoring requested position in window-specific settings helps, and now
|
|
|
|
// there's also _NET_WM_FULL_PLACEMENT.
|
2007-04-29 17:35:43 +00:00
|
|
|
usePosition = true;
|
|
|
|
#else
|
2008-12-18 15:01:25 +00:00
|
|
|
; // Force using placement policy
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2007-04-29 17:35:43 +00:00
|
|
|
usePosition = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (isSplash())
|
2008-12-18 15:01:25 +00:00
|
|
|
; // Force using placement policy
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
|
|
|
usePosition = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!rules()->checkIgnoreGeometry(!usePosition)) {
|
2012-03-14 07:03:42 +00:00
|
|
|
if (((xSizeHint.flags & PPosition)) ||
|
2011-01-30 14:34:42 +00:00
|
|
|
(xSizeHint.flags & USPosition)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
placementDone = true;
|
2008-12-18 15:01:25 +00:00
|
|
|
// Disobey xinerama placement option for now (#70943)
|
2011-01-30 14:34:42 +00:00
|
|
|
area = workspace()->clientArea(PlacementArea, geom.center(), desktop());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
//if ( true ) // Size is always obeyed for now, only with constraints applied
|
|
|
|
// if (( xSizeHint.flags & USSize ) || ( xSizeHint.flags & PSize ))
|
2008-12-18 15:01:25 +00:00
|
|
|
// {
|
|
|
|
// // Keep in mind that we now actually have a size :-)
|
|
|
|
// }
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (xSizeHint.flags & PMaxSize)
|
|
|
|
geom.setSize(geom.size().boundedTo(
|
|
|
|
rules()->checkMaxSize(QSize(xSizeHint.max_width, xSizeHint.max_height))));
|
|
|
|
if (xSizeHint.flags & PMinSize)
|
|
|
|
geom.setSize(geom.size().expandedTo(
|
|
|
|
rules()->checkMinSize(QSize(xSizeHint.min_width, xSizeHint.min_height))));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMovable() && (geom.x() > area.right() || geom.y() > area.bottom()))
|
2008-12-18 15:01:25 +00:00
|
|
|
placementDone = false; // Weird, do not trust.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (placementDone)
|
|
|
|
move(geom.x(), geom.y()); // Before gravitating
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
// Create client group if the window will have a decoration
|
2009-11-16 13:31:02 +00:00
|
|
|
bool dontKeepInArea = false;
|
2012-01-12 06:42:55 +00:00
|
|
|
setTabGroup(NULL);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!noBorder()) {
|
2012-02-20 09:25:13 +00:00
|
|
|
const bool autogrouping = rules()->checkAutogrouping(options->isAutogroupSimilarWindows());
|
|
|
|
const bool autogroupInFg = rules()->checkAutogroupInForeground(options->isAutogroupInForeground());
|
2009-11-15 03:24:04 +00:00
|
|
|
// Automatically add to previous groups on session restore
|
2012-06-08 18:39:27 +00:00
|
|
|
if (session && session->tabGroupClient && !workspace()->hasClient(session->tabGroupClient))
|
|
|
|
session->tabGroupClient = NULL;
|
2012-01-12 06:42:55 +00:00
|
|
|
if (session && session->tabGroupClient && session->tabGroupClient != this) {
|
|
|
|
tabBehind(session->tabGroupClient, autogroupInFg);
|
|
|
|
} else if (isMapped && autogrouping) {
|
2009-11-15 03:24:04 +00:00
|
|
|
// If the window is already mapped (Restarted KWin) add any windows that already have the
|
|
|
|
// same geometry to the same client group. (May incorrectly handle maximized windows)
|
2012-01-12 06:42:55 +00:00
|
|
|
foreach (Client *other, workspace()->clientList()) {
|
|
|
|
if (other->maximizeMode() != MaximizeFull &&
|
|
|
|
geom == QRect(other->pos(), other->clientSize()) &&
|
|
|
|
desk == other->desktop() && activities() == other->activities()) {
|
|
|
|
|
|
|
|
tabBehind(other, autogroupInFg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-01-12 06:42:55 +00:00
|
|
|
}
|
2012-06-18 19:19:11 +00:00
|
|
|
if (!(tab_group || isMapped || session)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// Attempt to automatically group similar windows
|
2012-01-12 06:42:55 +00:00
|
|
|
Client* similar = findAutogroupCandidate();
|
|
|
|
if (similar && !similar->noBorder()) {
|
|
|
|
if (autogroupInFg) {
|
|
|
|
similar->setDesktop(desk); // can happen when grouping by id. ...
|
|
|
|
similar->setMinimized(false); // ... or anyway - still group, but "here" and visible
|
|
|
|
}
|
|
|
|
if (!similar->isMinimized()) { // do not attempt to tab in background of a hidden group
|
|
|
|
geom = QRect(similar->pos() + similar->clientPos(), similar->clientSize());
|
|
|
|
updateDecoration(false);
|
|
|
|
if (tabBehind(similar, autogroupInFg)) {
|
|
|
|
// Don't move entire group
|
|
|
|
geom = QRect(similar->pos() + similar->clientPos(), similar->clientSize());
|
|
|
|
placementDone = true;
|
|
|
|
dontKeepInArea = true;
|
|
|
|
}
|
|
|
|
}
|
2009-11-16 10:09:03 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
updateDecoration(false); // Also gravitates
|
2008-12-18 15:01:25 +00:00
|
|
|
// TODO: Is CentralGravity right here, when resizing is done after gravitating?
|
2011-01-30 14:34:42 +00:00
|
|
|
plainResize(rules()->checkSize(sizeForClientSize(geom.size()), !isMapped));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint forced_pos = rules()->checkPosition(invalidPoint, !isMapped);
|
|
|
|
if (forced_pos != invalidPoint) {
|
|
|
|
move(forced_pos);
|
2007-04-29 17:35:43 +00:00
|
|
|
placementDone = true;
|
2008-12-18 15:01:25 +00:00
|
|
|
// Don't keep inside workarea if the window has specially configured position
|
2007-04-29 17:35:43 +00:00
|
|
|
partial_keep_in_area = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
area = workspace()->clientArea(FullArea, geom.center(), desktop());
|
|
|
|
}
|
|
|
|
if (!placementDone) {
|
|
|
|
// Placement needs to be after setting size
|
|
|
|
workspace()->place(this, area);
|
2007-04-29 17:35:43 +00:00
|
|
|
placementDone = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-11-12 20:39:06 +00:00
|
|
|
// bugs #285967, #286146, #183694
|
|
|
|
// geometry() now includes the requested size and the decoration and is at the correct screen/position (hopefully)
|
|
|
|
// Maximization for oversized windows must happen NOW.
|
|
|
|
// If we effectively pass keepInArea(), the window will resizeWithChecks() - i.e. constrained
|
|
|
|
// to the combo of all screen MINUS all struts on the edges
|
|
|
|
// If only one screen struts, this will affect screens as a side-effect, the window is artificailly shrinked
|
|
|
|
// below the screen size and as result no more maximized what breaks KMainWindow's stupid width+1, height+1 hack
|
|
|
|
// TODO: get KMainWindow a correct state storage what will allow to store the restore size as well.
|
|
|
|
|
|
|
|
if (!session) { // has a better handling of this
|
|
|
|
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()) {
|
|
|
|
dontKeepInArea = true;
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((!isSpecialWindow() || isToolbar()) && isMovable() && !dontKeepInArea)
|
|
|
|
keepInArea(area, partial_keep_in_area);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-12-17 16:30:36 +00:00
|
|
|
updateShape();
|
2008-12-18 15:01:25 +00:00
|
|
|
|
|
|
|
// CT: Extra check for stupid jdk 1.3.1. But should make sense in general
|
2007-04-29 17:35:43 +00:00
|
|
|
// if client has initial state set to Iconic and is transient with a parent
|
|
|
|
// window that is not Iconic, set init_state to Normal
|
2011-01-30 14:34:42 +00:00
|
|
|
if (init_minimize && isTransient()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
ClientList mainclients = mainClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = mainclients.constBegin();
|
|
|
|
it != mainclients.constEnd();
|
|
|
|
++it)
|
|
|
|
if ((*it)->isShown(true))
|
2008-12-18 15:01:25 +00:00
|
|
|
init_minimize = false; // SELI TODO: Even e.g. for NET::Utility?
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-18 15:01:25 +00:00
|
|
|
// If a dialog is shown for minimized window, minimize it too
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!init_minimize && isTransient() && mainClients().count() > 0) {
|
2008-03-18 14:56:57 +00:00
|
|
|
bool visible_parent = false;
|
2008-12-18 15:01:25 +00:00
|
|
|
// Use allMainClients(), to include also main clients of group transients
|
2008-04-18 15:50:12 +00:00
|
|
|
// that have been optimized out in Client::checkGroupTransients()
|
|
|
|
ClientList mainclients = allMainClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = mainclients.constBegin();
|
|
|
|
it != mainclients.constEnd();
|
|
|
|
++it)
|
|
|
|
if ((*it)->isShown(true))
|
2008-03-18 14:56:57 +00:00
|
|
|
visible_parent = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!visible_parent) {
|
2008-03-18 14:56:57 +00:00
|
|
|
init_minimize = true;
|
|
|
|
demandAttention();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (init_minimize)
|
|
|
|
minimize(true); // No animation
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-08-15 17:33:47 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// SELI TODO: This seems to be mainly for kstart and ksystraycmd
|
2007-04-29 17:35:43 +00:00
|
|
|
// probably should be replaced by something better
|
|
|
|
bool doNotShow = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (workspace()->isNotManaged(caption()))
|
2007-04-29 17:35:43 +00:00
|
|
|
doNotShow = true;
|
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// Other settings from the previous session
|
2011-01-30 14:34:42 +00:00
|
|
|
if (session) {
|
2008-12-18 15:01:25 +00:00
|
|
|
// Session restored windows are not considered to be new windows WRT rules,
|
|
|
|
// I.e. obey only forcing rules
|
2011-01-30 14:34:42 +00:00
|
|
|
setKeepAbove(session->keepAbove);
|
|
|
|
setKeepBelow(session->keepBelow);
|
|
|
|
setSkipTaskbar(session->skipTaskbar, true);
|
|
|
|
setSkipPager(session->skipPager);
|
|
|
|
setSkipSwitcher(session->skipSwitcher);
|
|
|
|
setShade(session->shaded ? ShadeNormal : ShadeNone);
|
|
|
|
setOpacity(session->opacity);
|
2012-04-11 16:18:50 +00:00
|
|
|
geom_restore = session->restore;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (session->maximized != MaximizeRestore) {
|
|
|
|
maximize(MaximizeMode(session->maximized));
|
|
|
|
}
|
|
|
|
if (session->fullscreen == FullScreenHack)
|
2008-12-18 15:01:25 +00:00
|
|
|
; // Nothing, this should be already set again above
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (session->fullscreen != FullScreenNone) {
|
|
|
|
setFullScreen(true, false);
|
2007-04-29 17:35:43 +00:00
|
|
|
geom_fs_restore = session->fsrestore;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2008-12-18 15:01:25 +00:00
|
|
|
// Window may want to be maximized
|
2007-04-29 17:35:43 +00:00
|
|
|
// 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
|
2008-12-18 15:01:25 +00:00
|
|
|
MaximizeMode maxmode = static_cast<MaximizeMode>(
|
2011-01-30 14:34:42 +00:00
|
|
|
((info->state() & NET::MaxVert) ? MaximizeVertical : 0) |
|
|
|
|
((info->state() & NET::MaxHoriz) ? MaximizeHorizontal : 0));
|
|
|
|
MaximizeMode forced_maxmode = rules()->checkMaximize(maxmode, !isMapped);
|
2008-12-18 15:01:25 +00:00
|
|
|
|
|
|
|
// Either hints were set to maximize, or is forced to maximize,
|
2007-04-29 17:35:43 +00:00
|
|
|
// or is forced to non-maximize and hints were set to maximize
|
2011-01-30 14:34:42 +00:00
|
|
|
if (forced_maxmode != MaximizeRestore || maxmode != MaximizeRestore)
|
|
|
|
maximize(forced_maxmode);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// Read other initial states
|
2011-01-30 14:34:42 +00:00
|
|
|
setShade(rules()->checkShade(info->state() & NET::Shaded ? ShadeNormal : ShadeNone, !isMapped));
|
|
|
|
setKeepAbove(rules()->checkKeepAbove(info->state() & NET::KeepAbove, !isMapped));
|
|
|
|
setKeepBelow(rules()->checkKeepBelow(info->state() & NET::KeepBelow, !isMapped));
|
|
|
|
setSkipTaskbar(rules()->checkSkipTaskbar(info->state() & NET::SkipTaskbar, !isMapped), true);
|
|
|
|
setSkipPager(rules()->checkSkipPager(info->state() & NET::SkipPager, !isMapped));
|
|
|
|
setSkipSwitcher(rules()->checkSkipSwitcher(false, !isMapped));
|
|
|
|
if (info->state() & NET::DemandsAttention)
|
2007-04-29 17:35:43 +00:00
|
|
|
demandAttention();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (info->state() & NET::Modal)
|
|
|
|
setModal(true);
|
|
|
|
if (fullscreen_mode != FullScreenHack && isFullScreenable())
|
|
|
|
setFullScreen(rules()->checkFullScreen(info->state() & NET::FullScreen, !isMapped), false);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
updateAllowedActions(true);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// Set initial user time directly
|
2011-01-30 14:34:42 +00:00
|
|
|
user_time = readUserTimeMapTimestamp(asn_valid ? &asn_id : NULL, asn_valid ? &asn_data : NULL, session);
|
|
|
|
group()->updateUserTime(user_time); // And do what Client::updateUserTime() does
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// This should avoid flicker, because real restacking is done
|
2007-04-29 17:35:43 +00:00
|
|
|
// only after manage() finishes because of blocking, but the window is shown sooner
|
2011-01-30 14:34:42 +00:00
|
|
|
XLowerWindow(display(), frameId());
|
|
|
|
if (session && session->stackingOrder != -1) {
|
2007-04-29 17:35:43 +00:00
|
|
|
sm_stacking_order = session->stackingOrder;
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->restoreSessionStackingOrder(this);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing())
|
2008-12-18 15:01:25 +00:00
|
|
|
// Sending ConfigureNotify is done when setting mapping state below,
|
|
|
|
// Getting the first sync response means window is ready for compositing
|
|
|
|
sendSyncRequest();
|
2011-08-13 14:39:58 +00:00
|
|
|
else
|
|
|
|
ready_for_painting = true; // set to true in case compositing is turned on later. bug #160393
|
2007-06-25 08:51:44 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShown(true) && !doNotShow) {
|
|
|
|
if (isDialog())
|
|
|
|
Notify::raise(Notify::TransNew);
|
|
|
|
if (isNormalWindow())
|
|
|
|
Notify::raise(Notify::New);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool allow;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (session)
|
2008-12-18 15:01:25 +00:00
|
|
|
allow = session->active &&
|
2011-01-30 14:34:42 +00:00
|
|
|
(!workspace()->wasUserInteraction() || workspace()->activeClient() == NULL ||
|
|
|
|
workspace()->activeClient()->isDesktop());
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
allow = workspace()->allowClientActivation(this, userTime(), false);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-12-16 20:14:22 +00:00
|
|
|
if (!(isMapped || session)) {
|
|
|
|
if (workspace()->sessionSaving()) {
|
|
|
|
/*
|
|
|
|
* If we get a new window during session saving, we assume it's some 'save file?' dialog
|
|
|
|
* which the user really needs to see (to know why logout's stalled).
|
|
|
|
*
|
|
|
|
* Given the current session management protocol, I can't see a nicer way of doing this.
|
|
|
|
* Someday I'd like to see a protocol that tells the windowmanager who's doing SessionInteract.
|
|
|
|
*/
|
|
|
|
needsSessionInteract = true;
|
|
|
|
//show the parent too
|
|
|
|
ClientList mainclients = mainClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = mainclients.constBegin();
|
|
|
|
it != mainclients.constEnd(); ++it) {
|
2010-12-16 20:14:22 +00:00
|
|
|
(*it)->setSessionInteract(true);
|
|
|
|
}
|
|
|
|
} else if (allow) {
|
|
|
|
// also force if activation is allowed
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!isOnCurrentDesktop()) {
|
|
|
|
workspace()->setCurrentDesktop(desktop());
|
2010-12-16 20:14:22 +00:00
|
|
|
}
|
|
|
|
/*if (!isOnCurrentActivity()) {
|
|
|
|
workspace()->setCurrentActivity( activities().first() );
|
|
|
|
} FIXME no such method*/
|
|
|
|
}
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-08-26 14:16:38 +00:00
|
|
|
resetShowingDesktop(options->isShowDesktopIsMinimizeAll());
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isOnCurrentDesktop() && !isMapped && !allow && (!session || session->stackingOrder < 0))
|
|
|
|
workspace()->restackClientUnderActive(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
updateVisibility();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!isMapped) {
|
|
|
|
if (allow && isOnCurrentDesktop()) {
|
|
|
|
if (!isSpecialWindow())
|
|
|
|
if (options->focusPolicyIsReasonable() && wantsTabFocus())
|
|
|
|
workspace()->requestFocus(this);
|
|
|
|
} else if (!session && !isSpecialWindow())
|
2008-12-18 15:01:25 +00:00
|
|
|
demandAttention();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (!doNotShow) // if ( !isShown( true ) && !doNotShow )
|
2007-04-29 17:35:43 +00:00
|
|
|
updateVisibility();
|
|
|
|
else // doNotShow
|
2011-01-30 14:34:42 +00:00
|
|
|
hideClient(true); // SELI HACK !!!
|
|
|
|
assert(mapping_state != Withdrawn);
|
2012-06-19 21:12:37 +00:00
|
|
|
m_managed = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
blockGeometryUpdates(false);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (user_time == CurrentTime || user_time == -1U) {
|
|
|
|
// No known user time, set something old
|
2007-04-29 17:35:43 +00:00
|
|
|
user_time = xTime() - 1000000;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (user_time == CurrentTime || user_time == -1U) // Let's be paranoid
|
2007-04-29 17:35:43 +00:00
|
|
|
user_time = xTime() - 1000000 + 10;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
//sendSyntheticConfigureNotify(); // Done when setting mapping state
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
delete session;
|
2008-12-18 15:01:25 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
ungrabXServer();
|
2008-12-18 15:01:25 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
client_rules.discardTemporary();
|
2008-12-18 15:01:25 +00:00
|
|
|
applyWindowRules(); // Just in case
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->discardUsedWindowRules(this, false); // Remove ApplyNow rules
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::All); // Was blocked while !isManaged()
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-03-20 14:42:05 +00:00
|
|
|
updateCompositeBlocking(true);
|
|
|
|
|
2008-12-18 15:01:25 +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()
|
2012-01-21 09:51:22 +00:00
|
|
|
emit clientManaging(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 15:01:25 +00:00
|
|
|
// Called only from manage()
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::embedClient(Window w, const XWindowAttributes& attr)
|
|
|
|
{
|
|
|
|
assert(client == None);
|
|
|
|
assert(frameId() == None);
|
|
|
|
assert(wrapper == None);
|
2007-04-29 17:35:43 +00:00
|
|
|
client = w;
|
2008-12-18 15:01:25 +00:00
|
|
|
|
|
|
|
// We don't want the window to be destroyed when we are destroyed
|
2011-01-30 14:34:42 +00:00
|
|
|
XAddToSaveSet(display(), client);
|
|
|
|
XSelectInput(display(), client, NoEventMask);
|
|
|
|
XUnmapWindow(display(), client);
|
2008-12-18 15:01:25 +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
|
2011-01-30 14:34:42 +00:00
|
|
|
XConfigureWindow(display(), client, CWBorderWidth, &wc);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
XSetWindowAttributes swa;
|
|
|
|
swa.colormap = attr.colormap;
|
|
|
|
swa.background_pixmap = None;
|
|
|
|
swa.border_pixel = 0;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Window frame = XCreateWindow(display(), rootWindow(), 0, 0, 1, 1, 0,
|
|
|
|
attr.depth, InputOutput, attr.visual, CWColormap | CWBackPixmap | CWBorderPixel, &swa);
|
|
|
|
setWindowHandles(client, frame);
|
|
|
|
wrapper = XCreateWindow(display(), frame, 0, 0, 1, 1, 0,
|
|
|
|
attr.depth, InputOutput, attr.visual, CWColormap | CWBackPixmap | CWBorderPixel, &swa);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
XDefineCursor(display(), frame, QCursor(Qt::ArrowCursor).handle());
|
2008-12-18 15:01:25 +00:00
|
|
|
// Some apps are stupid and don't define their own cursor - set the arrow one for them
|
2011-01-30 14:34:42 +00:00
|
|
|
XDefineCursor(display(), wrapper, QCursor(Qt::ArrowCursor).handle());
|
|
|
|
XReparentWindow(display(), client, wrapper, 0, 0);
|
|
|
|
XSelectInput(display(), frame,
|
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeymapStateMask |
|
|
|
|
ButtonMotionMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
ExposureMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
StructureNotifyMask | SubstructureRedirectMask);
|
|
|
|
XSelectInput(display(), wrapper, ClientWinMask | SubstructureNotifyMask);
|
|
|
|
XSelectInput(display(), client,
|
|
|
|
FocusChangeMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ColormapChangeMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
KeyPressMask | KeyReleaseMask
|
|
|
|
);
|
2008-12-18 15:01:25 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
updateMouseGrab();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
// To accept "mainwindow#1" to "mainwindow#2"
|
|
|
|
static QByteArray truncatedWindowRole(QByteArray a)
|
|
|
|
{
|
|
|
|
int i = a.indexOf('#');
|
|
|
|
if (i == -1)
|
|
|
|
return a;
|
|
|
|
QByteArray b(a);
|
|
|
|
b.truncate(i);
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
Client* Client::findAutogroupCandidate() const
|
|
|
|
{
|
|
|
|
// Attempt to find a similar window to the input. If we find multiple possibilities that are in
|
|
|
|
// different groups then ignore all of them. This function is for automatic window grouping.
|
|
|
|
Client *found = NULL;
|
|
|
|
|
|
|
|
// See if the window has a group ID to match with
|
|
|
|
QString wGId = rules()->checkAutogroupById(QString());
|
|
|
|
if (!wGId.isEmpty()) {
|
|
|
|
foreach (Client *c, workspace()->clientList()) {
|
|
|
|
if (activities() != c->activities())
|
|
|
|
continue; // don't cross activities
|
|
|
|
if (wGId == c->rules()->checkAutogroupById(QString())) {
|
|
|
|
if (found && found->tabGroup() != c->tabGroup()) { // We've found two, ignore both
|
|
|
|
found = NULL;
|
|
|
|
break; // Continue to the next test
|
|
|
|
}
|
|
|
|
found = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this is a transient window don't take a guess
|
|
|
|
if (isTransient())
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// If we don't have an ID take a guess
|
2012-02-20 09:25:13 +00:00
|
|
|
if (rules()->checkAutogrouping(options->isAutogroupSimilarWindows())) {
|
2012-01-12 06:42:55 +00:00
|
|
|
QByteArray wRole = truncatedWindowRole(windowRole());
|
|
|
|
foreach (Client *c, workspace()->clientList()) {
|
|
|
|
if (desktop() != c->desktop() || activities() != c->activities())
|
|
|
|
continue;
|
|
|
|
QByteArray wRoleB = truncatedWindowRole(c->windowRole());
|
|
|
|
if (resourceClass() == c->resourceClass() && // Same resource class
|
|
|
|
wRole == wRoleB && // Same window role
|
|
|
|
c->isNormalWindow()) { // Normal window TODO: Can modal windows be "normal"?
|
|
|
|
if (found && found->tabGroup() != c->tabGroup()) // We've found two, ignore both
|
|
|
|
return NULL;
|
|
|
|
found = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|