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
|
|
|
|
|
|
|
#include "client.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QDateTime>
|
2007-06-17 17:09:40 +00:00
|
|
|
#include <QProcess>
|
2011-05-15 11:22:28 +00:00
|
|
|
#include <QPaintEngine>
|
2012-11-09 12:44:50 +00:00
|
|
|
|
2012-10-16 20:42:19 +00:00
|
|
|
#ifdef KWIN_BUILD_SCRIPTING
|
|
|
|
#include <QScriptEngine>
|
|
|
|
#include <QScriptProgram>
|
|
|
|
#endif
|
2012-11-09 12:44:50 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <QWhatsThis>
|
2007-04-30 15:48:34 +00:00
|
|
|
#include <kwindowsystem.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <kiconloader.h>
|
|
|
|
#include <stdlib.h>
|
2007-11-26 15:42:44 +00:00
|
|
|
#include <signal.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "bridge.h"
|
2011-08-21 19:50:23 +00:00
|
|
|
#include "composite.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "group.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
#include "atoms.h"
|
|
|
|
#include "notifications.h"
|
|
|
|
#include "rules.h"
|
2011-04-10 19:24:27 +00:00
|
|
|
#include "shadow.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "deleted.h"
|
2009-04-22 17:29:56 +00:00
|
|
|
#include "paintredirector.h"
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2009-09-13 11:36:45 +00:00
|
|
|
#include "tabbox.h"
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#include <QX11Info>
|
|
|
|
|
2007-06-25 08:51:44 +00:00
|
|
|
#ifdef HAVE_XSYNC
|
|
|
|
#include <X11/extensions/sync.h>
|
|
|
|
#endif
|
|
|
|
|
2009-04-22 17:29:56 +00:00
|
|
|
#ifdef HAVE_XRENDER
|
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Put all externs before the namespace statement to allow the linker
|
2007-04-29 17:35:43 +00:00
|
|
|
// to resolve them properly
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-12-09 19:44:06 +00:00
|
|
|
bool Client::s_haveResizeEffect = false;
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Creating a client:
|
|
|
|
// - only by calling Workspace::createClient()
|
|
|
|
// - it creates a new client and calls manage() for it
|
|
|
|
//
|
|
|
|
// Destroying a client:
|
|
|
|
// - destroyClient() - only when the window itself has been destroyed
|
|
|
|
// - releaseWindow() - the window is kept, only the client itself is destroyed
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class Client client.h
|
|
|
|
* \brief The Client class encapsulates a window decoration frame.
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* This ctor is "dumb" - it only initializes data. All the real initialization
|
|
|
|
* is done in manage().
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
Client::Client(Workspace* ws)
|
|
|
|
: Toplevel(ws)
|
|
|
|
, client(None)
|
|
|
|
, wrapper(None)
|
|
|
|
, decoration(NULL)
|
|
|
|
, bridge(new Bridge(this))
|
|
|
|
, move_resize_grab_window(None)
|
|
|
|
, move_resize_has_keyboard_grab(false)
|
2012-06-19 21:12:37 +00:00
|
|
|
, m_managed(false)
|
2011-01-30 14:34:42 +00:00
|
|
|
, transient_for (NULL)
|
|
|
|
, transient_for_id(None)
|
|
|
|
, original_transient_for_id(None)
|
2012-03-14 08:59:41 +00:00
|
|
|
, shade_below(NULL)
|
2011-10-29 15:05:25 +00:00
|
|
|
, skip_switcher(false)
|
2011-03-20 14:42:05 +00:00
|
|
|
, blocks_compositing(false)
|
2011-01-30 14:34:42 +00:00
|
|
|
, autoRaiseTimer(NULL)
|
|
|
|
, shadeHoverTimer(NULL)
|
|
|
|
, delayedMoveResizeTimer(NULL)
|
|
|
|
, in_group(NULL)
|
|
|
|
, window_group(None)
|
2012-01-12 06:42:55 +00:00
|
|
|
, tab_group(NULL)
|
2011-01-30 14:34:42 +00:00
|
|
|
, in_layer(UnknownLayer)
|
|
|
|
, ping_timer(NULL)
|
2012-04-16 21:52:13 +00:00
|
|
|
, m_killHelperPID(0)
|
2011-01-30 14:34:42 +00:00
|
|
|
, user_time(CurrentTime) // Not known yet
|
|
|
|
, allowed_actions(0)
|
|
|
|
, block_geometry_updates(0)
|
|
|
|
, pending_geometry_update(PendingGeometryNone)
|
|
|
|
, shade_geometry_change(false)
|
|
|
|
, border_left(0)
|
|
|
|
, border_right(0)
|
|
|
|
, border_top(0)
|
|
|
|
, border_bottom(0)
|
|
|
|
, padding_left(0)
|
|
|
|
, padding_right(0)
|
|
|
|
, padding_top(0)
|
|
|
|
, padding_bottom(0)
|
|
|
|
, sm_stacking_order(-1)
|
|
|
|
, demandAttentionKNotifyTimer(NULL)
|
|
|
|
, paintRedirector(0)
|
2011-12-01 12:15:11 +00:00
|
|
|
, m_firstInTabBox(false)
|
2011-01-30 14:34:42 +00:00
|
|
|
, electricMaximizing(false)
|
|
|
|
, activitiesDefined(false)
|
2010-12-16 20:14:22 +00:00
|
|
|
, needsSessionInteract(false)
|
2012-11-07 23:54:05 +00:00
|
|
|
, needsXWindowMove(false)
|
2012-11-09 12:44:50 +00:00
|
|
|
#ifdef KWIN_BUILD_KAPPMENU
|
|
|
|
, m_menuAvailable(false)
|
|
|
|
#endif
|
2011-11-09 19:39:13 +00:00
|
|
|
, input_window(None)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
// TODO: Do all as initialization
|
2011-08-13 14:39:58 +00:00
|
|
|
#ifdef HAVE_XSYNC
|
|
|
|
syncRequest.counter = syncRequest.alarm = None;
|
|
|
|
syncRequest.timeout = syncRequest.failsafeTimeout = NULL;
|
|
|
|
syncRequest.isPending = false;
|
|
|
|
#endif
|
2008-12-18 13:50:57 +00:00
|
|
|
|
|
|
|
// Set the initial mapping state
|
2008-08-12 11:02:58 +00:00
|
|
|
mapping_state = Withdrawn;
|
2009-09-13 17:09:44 +00:00
|
|
|
quick_tile_mode = QuickTileNone;
|
2008-12-18 13:50:57 +00:00
|
|
|
desk = 0; // No desktop yet
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
mode = PositionCenter;
|
|
|
|
buttonDown = false;
|
|
|
|
moveResizeMode = false;
|
|
|
|
|
|
|
|
info = NULL;
|
|
|
|
|
|
|
|
shade_mode = ShadeNone;
|
|
|
|
active = false;
|
|
|
|
deleting = false;
|
|
|
|
keep_above = false;
|
|
|
|
keep_below = false;
|
|
|
|
motif_may_move = true;
|
|
|
|
motif_may_resize = true;
|
|
|
|
motif_may_close = true;
|
|
|
|
fullscreen_mode = FullScreenNone;
|
|
|
|
skip_taskbar = false;
|
|
|
|
original_skip_taskbar = false;
|
|
|
|
minimized = false;
|
|
|
|
hidden = false;
|
|
|
|
modal = false;
|
|
|
|
noborder = false;
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = false;
|
2009-10-03 14:32:24 +00:00
|
|
|
motif_noborder = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
urgency = false;
|
|
|
|
ignore_focus_stealing = false;
|
|
|
|
demands_attention = false;
|
|
|
|
check_active_modal = false;
|
|
|
|
|
|
|
|
Pdeletewindow = 0;
|
|
|
|
Ptakefocus = 0;
|
|
|
|
Ptakeactivity = 0;
|
|
|
|
Pcontexthelp = 0;
|
|
|
|
Pping = 0;
|
|
|
|
input = false;
|
|
|
|
skip_pager = false;
|
|
|
|
|
|
|
|
max_mode = MaximizeRestore;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
cmap = None;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2010-09-21 14:31:40 +00:00
|
|
|
//Client to workspace connections require that each
|
|
|
|
//client constructed be connected to the workspace wrapper
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2009-09-13 11:36:45 +00:00
|
|
|
// TabBoxClient
|
2012-05-20 13:52:24 +00:00
|
|
|
m_tabBoxClient = QSharedPointer<TabBox::TabBoxClientImpl>(new TabBox::TabBoxClientImpl(this));
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
geom = QRect(0, 0, 100, 100); // So that decorations don't start with size being (0,0)
|
|
|
|
client_size = QSize(100, 100);
|
2007-06-25 08:51:44 +00:00
|
|
|
ready_for_painting = false; // wait for first damage or sync reply
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-06-19 20:07:19 +00:00
|
|
|
connect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SIGNAL(geometryChanged()));
|
2011-04-03 10:43:57 +00:00
|
|
|
connect(this, SIGNAL(clientMaximizedStateChanged(KWin::Client*,KDecorationDefines::MaximizeMode)), SIGNAL(geometryChanged()));
|
|
|
|
connect(this, SIGNAL(clientStepUserMovedResized(KWin::Client*,QRect)), SIGNAL(geometryChanged()));
|
2011-12-29 09:19:36 +00:00
|
|
|
connect(this, SIGNAL(clientStartUserMovedResized(KWin::Client*)), SIGNAL(moveResizedChanged()));
|
|
|
|
connect(this, SIGNAL(clientFinishUserMovedResized(KWin::Client*)), SIGNAL(moveResizedChanged()));
|
2011-04-03 10:43:57 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// SELI TODO: Initialize xsizehints??
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* "Dumb" destructor.
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
Client::~Client()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-08-14 19:22:30 +00:00
|
|
|
if (m_killHelperPID && !::kill(m_killHelperPID, 0)) { // means the process is alive
|
|
|
|
::kill(m_killHelperPID, SIGTERM);
|
|
|
|
m_killHelperPID = 0;
|
|
|
|
}
|
2010-09-21 14:31:40 +00:00
|
|
|
//SWrapper::Client::clientRelease(this);
|
2007-06-25 08:51:44 +00:00
|
|
|
#ifdef HAVE_XSYNC
|
2011-08-13 14:39:58 +00:00
|
|
|
if (syncRequest.alarm != None)
|
|
|
|
XSyncDestroyAlarm(display(), syncRequest.alarm);
|
2007-06-25 08:51:44 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
assert(!moveResizeMode);
|
2011-01-30 14:34:42 +00:00
|
|
|
assert(client == None);
|
|
|
|
assert(wrapper == None);
|
2008-12-18 13:50:57 +00:00
|
|
|
//assert( frameId() == None );
|
2011-01-30 14:34:42 +00:00
|
|
|
assert(decoration == NULL);
|
|
|
|
assert(block_geometry_updates == 0);
|
|
|
|
assert(!check_active_modal);
|
2007-04-29 17:35:43 +00:00
|
|
|
delete bridge;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Use destroyClient() or releaseWindow(), Client instances cannot be deleted directly
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::deleteClient(Client* c, allowed_t)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete c;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Releases the window. The client has done its job and the window is still existing.
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::releaseWindow(bool on_shutdown)
|
|
|
|
{
|
|
|
|
assert(!deleting);
|
2007-04-29 17:35:43 +00:00
|
|
|
deleting = true;
|
2012-04-22 07:27:53 +00:00
|
|
|
Deleted* del = NULL;
|
|
|
|
if (!on_shutdown) {
|
|
|
|
del = Deleted::create(this);
|
|
|
|
}
|
2011-07-16 12:23:54 +00:00
|
|
|
if (moveResizeMode)
|
|
|
|
emit clientFinishUserMovedResized(this);
|
2011-06-21 11:52:25 +00:00
|
|
|
emit windowClosed(this, del);
|
2007-04-29 17:35:43 +00:00
|
|
|
finishCompositing();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->discardUsedWindowRules(this, true); // Remove ForceTemporarily rules
|
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
2007-04-29 17:35:43 +00:00
|
|
|
if (moveResizeMode)
|
2011-01-30 14:34:42 +00:00
|
|
|
leaveMoveResize();
|
2007-04-29 17:35:43 +00:00
|
|
|
finishWindowRules();
|
|
|
|
++block_geometry_updates;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isOnCurrentDesktop() && isShown(true))
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
2008-12-18 13:50:57 +00:00
|
|
|
// Grab X during the release to make removing of properties, setting to withdrawn state
|
2007-04-30 09:41:48 +00:00
|
|
|
// and repareting to root an atomic operation (http://lists.kde.org/?l=kde-devel&m=116448102901184&w=2)
|
|
|
|
grabXServer();
|
2011-01-30 14:34:42 +00:00
|
|
|
exportMappingState(WithdrawnState);
|
|
|
|
setModal(false); // Otherwise its mainwindow wouldn't get focus
|
2008-12-18 13:50:57 +00:00
|
|
|
hidden = true; // So that it's not considered visible anymore (can't use hideClient(), it would set flags)
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!on_shutdown)
|
|
|
|
workspace()->clientHidden(this);
|
|
|
|
XUnmapWindow(display(), frameId()); // Destroying decoration would cause ugly visual effect
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
|
|
|
cleanGrouping();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!on_shutdown) {
|
|
|
|
workspace()->removeClient(this, Allowed);
|
2008-12-18 13:50:57 +00:00
|
|
|
// Only when the window is being unmapped, not when closing down KWin (NETWM sections 5.5,5.7)
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setDesktop(0);
|
2007-04-29 17:35:43 +00:00
|
|
|
desk = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setState(0, info->state()); // Reset all state flags
|
2012-01-12 06:42:55 +00:00
|
|
|
} else
|
|
|
|
untab();
|
2011-01-30 14:34:42 +00:00
|
|
|
XDeleteProperty(display(), client, atoms->kde_net_wm_user_creation_time);
|
|
|
|
XDeleteProperty(display(), client, atoms->net_frame_extents);
|
|
|
|
XDeleteProperty(display(), client, atoms->kde_net_wm_frame_strut);
|
|
|
|
XReparentWindow(display(), client, rootWindow(), x(), y());
|
|
|
|
XRemoveFromSaveSet(display(), client);
|
|
|
|
XSelectInput(display(), client, NoEventMask);
|
|
|
|
if (on_shutdown)
|
2008-12-18 13:50:57 +00:00
|
|
|
// Map the window, so it can be found after another WM is started
|
2011-01-30 14:34:42 +00:00
|
|
|
XMapWindow(display(), client);
|
|
|
|
// TODO: Preserve minimized, shaded etc. state?
|
2008-12-18 13:50:57 +00:00
|
|
|
else // Make sure it's not mapped if the app unmapped it (#65279). The app
|
2011-01-30 14:34:42 +00:00
|
|
|
// may do map+unmap before we initially map the window by calling rawShow() from manage().
|
|
|
|
XUnmapWindow(display(), client);
|
2007-04-29 17:35:43 +00:00
|
|
|
client = None;
|
2011-01-30 14:34:42 +00:00
|
|
|
XDestroyWindow(display(), wrapper);
|
2007-04-29 17:35:43 +00:00
|
|
|
wrapper = None;
|
2011-01-30 14:34:42 +00:00
|
|
|
XDestroyWindow(display(), frameId());
|
2008-12-18 13:50:57 +00:00
|
|
|
//frame = None;
|
|
|
|
--block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry
|
2012-04-22 07:27:53 +00:00
|
|
|
if (!on_shutdown) {
|
|
|
|
disownDataPassedToDeleted();
|
|
|
|
del->unrefWindow();
|
|
|
|
}
|
2007-04-30 09:50:38 +00:00
|
|
|
checkNonExistentClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
deleteClient(this, Allowed);
|
2007-04-30 09:41:48 +00:00
|
|
|
ungrabXServer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Like releaseWindow(), but this one is called when the window has been already destroyed
|
|
|
|
* (E.g. The application closed it)
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
void Client::destroyClient()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
assert(!deleting);
|
2007-04-29 17:35:43 +00:00
|
|
|
deleting = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
Deleted* del = Deleted::create(this);
|
2011-07-16 12:23:54 +00:00
|
|
|
if (moveResizeMode)
|
|
|
|
emit clientFinishUserMovedResized(this);
|
2011-06-21 11:52:25 +00:00
|
|
|
emit windowClosed(this, del);
|
2007-04-29 17:35:43 +00:00
|
|
|
finishCompositing();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->discardUsedWindowRules(this, true); // Remove ForceTemporarily rules
|
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
2007-04-29 17:35:43 +00:00
|
|
|
if (moveResizeMode)
|
2011-01-30 14:34:42 +00:00
|
|
|
leaveMoveResize();
|
2007-04-29 17:35:43 +00:00
|
|
|
finishWindowRules();
|
|
|
|
++block_geometry_updates;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isOnCurrentDesktop() && isShown(true))
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
setModal(false);
|
2008-12-18 13:50:57 +00:00
|
|
|
hidden = true; // So that it's not considered visible anymore
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->clientHidden(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
|
|
|
cleanGrouping();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->removeClient(this, Allowed);
|
2007-04-29 17:35:43 +00:00
|
|
|
client = None; // invalidate
|
2011-01-30 14:34:42 +00:00
|
|
|
XDestroyWindow(display(), wrapper);
|
2007-04-29 17:35:43 +00:00
|
|
|
wrapper = None;
|
2011-01-30 14:34:42 +00:00
|
|
|
XDestroyWindow(display(), frameId());
|
2008-12-18 13:50:57 +00:00
|
|
|
//frame = None;
|
|
|
|
--block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry
|
2007-04-29 17:35:43 +00:00
|
|
|
disownDataPassedToDeleted();
|
|
|
|
del->unrefWindow();
|
2007-04-30 09:47:59 +00:00
|
|
|
checkNonExistentClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
deleteClient(this, Allowed);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-11-09 19:39:13 +00:00
|
|
|
void Client::updateInputWindow()
|
|
|
|
{
|
|
|
|
QRegion region;
|
|
|
|
|
|
|
|
if (!noBorder() && dynamic_cast<KDecorationUnstable*>(decoration)) {
|
|
|
|
// This function is implemented as a slot to avoid breaking binary
|
|
|
|
// compatibility
|
|
|
|
QMetaObject::invokeMethod(decoration, "region", Qt::DirectConnection,
|
|
|
|
Q_RETURN_ARG(QRegion, region),
|
|
|
|
Q_ARG(KDecorationDefines::Region, KDecorationDefines::ExtendedBorderRegion));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region.isEmpty()) {
|
|
|
|
if (input_window) {
|
|
|
|
XDestroyWindow(display(), input_window);
|
|
|
|
input_window = None;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect bounds = region.boundingRect();
|
|
|
|
input_offset = bounds.topLeft();
|
|
|
|
|
|
|
|
// Move the bounding rect to screen coordinates
|
|
|
|
bounds.translate(geometry().topLeft());
|
|
|
|
|
|
|
|
// Move the region to input window coordinates
|
|
|
|
region.translate(-input_offset);
|
|
|
|
|
|
|
|
if (!input_window) {
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
attr.event_mask = EnterWindowMask | LeaveWindowMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
|
|
|
attr.override_redirect = True;
|
|
|
|
|
|
|
|
input_window = XCreateWindow(display(), rootWindow(), bounds.x(), bounds.y(),
|
|
|
|
bounds.width(), bounds.height(), 0, 0,
|
|
|
|
InputOnly, 0, CWEventMask | CWOverrideRedirect, &attr);
|
|
|
|
} else {
|
|
|
|
XMoveResizeWindow(display(), input_window, bounds.x(), bounds.y(),
|
|
|
|
bounds.width(), bounds.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
XShapeCombineRegion(display(), input_window, ShapeInput, 0, 0, region.handle(), ShapeSet);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::updateDecoration(bool check_workspace_pos, bool force)
|
|
|
|
{
|
|
|
|
if (!force &&
|
|
|
|
((decoration == NULL && noBorder()) || (decoration != NULL && !noBorder())))
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
QRect oldgeom = geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
blockGeometryUpdates(true);
|
|
|
|
if (force)
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!noBorder()) {
|
|
|
|
setMask(QRegion()); // Reset shape mask
|
|
|
|
decoration = workspace()->createDecoration(bridge);
|
2012-11-09 12:44:50 +00:00
|
|
|
#ifdef KWIN_BUILD_KAPPMENU
|
|
|
|
connect(this, SIGNAL(showRequest()), decoration, SIGNAL(showRequest()));
|
|
|
|
connect(this, SIGNAL(appMenuAvailable()), decoration, SIGNAL(appMenuAvailable()));
|
|
|
|
connect(this, SIGNAL(appMenuUnavailable()), decoration, SIGNAL(appMenuUnavailable()));
|
|
|
|
connect(this, SIGNAL(menuHidden()), decoration, SIGNAL(menuHidden()));
|
|
|
|
#endif
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: Check decoration's minimum size?
|
2007-04-29 17:35:43 +00:00
|
|
|
decoration->init();
|
2011-01-30 14:34:42 +00:00
|
|
|
decoration->widget()->installEventFilter(this);
|
|
|
|
XReparentWindow(display(), decoration->widget()->winId(), frameId(), 0, 0);
|
2007-04-29 17:35:43 +00:00
|
|
|
decoration->widget()->lower();
|
2011-01-30 14:34:42 +00:00
|
|
|
decoration->borders(border_left, border_right, border_top, border_bottom);
|
2009-05-04 22:35:33 +00:00
|
|
|
padding_left = padding_right = padding_top = padding_bottom = 0;
|
|
|
|
if (KDecorationUnstable *deco2 = dynamic_cast<KDecorationUnstable*>(decoration))
|
2011-01-30 14:34:42 +00:00
|
|
|
deco2->padding(padding_left, padding_right, padding_top, padding_bottom);
|
|
|
|
XMoveWindow(display(), decoration->widget()->winId(), -padding_left, -padding_top);
|
|
|
|
move(calculateGravitation(false));
|
|
|
|
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
2012-09-28 09:59:42 +00:00
|
|
|
if (Compositor::compositing()) {
|
|
|
|
paintRedirector = new PaintRedirector(this, decoration->widget());
|
2007-04-29 17:35:43 +00:00
|
|
|
discardWindowPixmap();
|
2012-09-28 09:59:42 +00:00
|
|
|
}
|
2011-06-19 20:07:19 +00:00
|
|
|
emit geometryShapeChanged(this, oldgeom);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (check_workspace_pos)
|
2011-07-10 00:24:54 +00:00
|
|
|
checkWorkspacePosition(oldgeom);
|
2011-11-09 19:39:13 +00:00
|
|
|
updateInputWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
blockGeometryUpdates(false);
|
|
|
|
if (!noBorder())
|
2007-04-29 17:35:43 +00:00
|
|
|
decoration->widget()->show();
|
|
|
|
updateFrameExtents();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::destroyDecoration()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QRect oldgeom = geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (decoration != NULL) {
|
2007-04-29 17:35:43 +00:00
|
|
|
delete decoration;
|
|
|
|
decoration = NULL;
|
2012-09-28 09:59:42 +00:00
|
|
|
paintRedirector = NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint grav = calculateGravitation(true);
|
2007-04-29 17:35:43 +00:00
|
|
|
border_left = border_right = border_top = border_bottom = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
setMask(QRegion()); // Reset shape mask
|
|
|
|
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
|
|
|
move(grav);
|
|
|
|
if (compositing())
|
2007-04-29 17:35:43 +00:00
|
|
|
discardWindowPixmap();
|
2011-03-12 11:34:59 +00:00
|
|
|
if (!deleting) {
|
2011-06-19 20:07:19 +00:00
|
|
|
emit geometryShapeChanged(this, oldgeom);
|
2011-03-12 11:34:59 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-11-09 19:39:13 +00:00
|
|
|
if (inputId()) {
|
|
|
|
XDestroyWindow(display(), input_window);
|
|
|
|
input_window = None;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool Client::checkBorderSizes(bool also_resize)
|
|
|
|
{
|
|
|
|
if (decoration == NULL)
|
2008-03-19 19:32:32 +00:00
|
|
|
return false;
|
2009-05-04 22:35:33 +00:00
|
|
|
|
|
|
|
int new_left = 0, new_right = 0, new_top = 0, new_bottom = 0;
|
|
|
|
if (KDecorationUnstable *deco2 = dynamic_cast<KDecorationUnstable*>(decoration))
|
2011-01-30 14:34:42 +00:00
|
|
|
deco2->padding(new_left, new_right, new_top, new_bottom);
|
2009-05-04 22:35:33 +00:00
|
|
|
if (padding_left != new_left || padding_top != new_top)
|
2011-01-30 14:34:42 +00:00
|
|
|
XMoveWindow(display(), decoration->widget()->winId(), -new_left, -new_top);
|
2009-05-04 22:35:33 +00:00
|
|
|
padding_left = new_left;
|
|
|
|
padding_right = new_right;
|
|
|
|
padding_top = new_top;
|
|
|
|
padding_bottom = new_bottom;
|
2011-01-30 14:34:42 +00:00
|
|
|
decoration->borders(new_left, new_right, new_top, new_bottom);
|
|
|
|
if (new_left == border_left && new_right == border_right &&
|
|
|
|
new_top == border_top && new_bottom == border_bottom)
|
2008-03-19 19:32:32 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!also_resize) {
|
2008-03-19 19:32:32 +00:00
|
|
|
border_left = new_left;
|
|
|
|
border_right = new_right;
|
|
|
|
border_top = new_top;
|
|
|
|
border_bottom = new_bottom;
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
GeometryUpdatesBlocker blocker(this);
|
|
|
|
move(calculateGravitation(true));
|
2007-04-29 17:35:43 +00:00
|
|
|
border_left = new_left;
|
|
|
|
border_right = new_right;
|
|
|
|
border_top = new_top;
|
|
|
|
border_bottom = new_bottom;
|
2011-01-30 14:34:42 +00:00
|
|
|
move(calculateGravitation(false));
|
2011-07-10 00:24:54 +00:00
|
|
|
QRect oldgeom = geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
2011-07-10 00:24:54 +00:00
|
|
|
checkWorkspacePosition(oldgeom);
|
2008-03-19 19:32:32 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-04-22 17:29:56 +00:00
|
|
|
void Client::triggerDecorationRepaint()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (decoration != NULL)
|
2008-03-21 12:57:41 +00:00
|
|
|
decoration->widget()->update();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-03-21 12:57:41 +00:00
|
|
|
|
2009-05-04 22:35:33 +00:00
|
|
|
void Client::layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, Client::CoordinateMode mode) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-05-04 22:35:33 +00:00
|
|
|
QRect r = decoration->widget()->rect();
|
|
|
|
if (mode == WindowRelative)
|
|
|
|
r.translate(-padding_left, -padding_top);
|
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
NETStrut strut = info->frameOverlap();
|
2009-11-30 00:37:52 +00:00
|
|
|
|
|
|
|
// Ignore the overlap strut when compositing is disabled
|
2009-12-16 20:51:54 +00:00
|
|
|
if (!compositing() || !Workspace::self()->decorationSupportsFrameOverlap())
|
2009-11-30 00:37:52 +00:00
|
|
|
strut.left = strut.top = strut.right = strut.bottom = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1) {
|
2009-11-25 23:32:35 +00:00
|
|
|
top = QRect(r.x(), r.y(), r.width(), r.height() / 3);
|
|
|
|
left = QRect(r.x(), r.y() + top.height(), width() / 2, r.height() / 3);
|
|
|
|
right = QRect(r.x() + left.width(), r.y() + top.height(), r.width() - left.width(), left.height());
|
|
|
|
bottom = QRect(r.x(), r.y() + top.height() + left.height(), r.width(), r.height() - left.height() - top.height());
|
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-25 23:32:35 +00:00
|
|
|
|
|
|
|
top = QRect(r.x(), r.y(), r.width(), padding_top + border_top + strut.top);
|
|
|
|
bottom = QRect(r.x(), r.y() + r.height() - padding_bottom - border_bottom - strut.bottom,
|
|
|
|
r.width(), padding_bottom + border_bottom + strut.bottom);
|
2009-05-04 22:35:33 +00:00
|
|
|
left = QRect(r.x(), r.y() + top.height(),
|
2009-11-25 23:32:35 +00:00
|
|
|
padding_left + border_left + strut.left, r.height() - top.height() - bottom.height());
|
|
|
|
right = QRect(r.x() + r.width() - padding_right - border_right - strut.right, r.y() + top.height(),
|
|
|
|
padding_right + border_right + strut.right, r.height() - top.height() - bottom.height());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-05-04 22:35:33 +00:00
|
|
|
|
2009-11-08 19:47:58 +00:00
|
|
|
QRegion Client::decorationPendingRegion() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-08 19:47:58 +00:00
|
|
|
if (!paintRedirector)
|
|
|
|
return QRegion();
|
2011-01-30 14:34:42 +00:00
|
|
|
return paintRedirector->scheduledRepaintRegion().translated(x() - padding_left, y() - padding_top);
|
|
|
|
}
|
2009-11-08 19:47:58 +00:00
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
QRect Client::transparentRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-30 00:37:52 +00:00
|
|
|
if (isShade())
|
|
|
|
return QRect();
|
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
NETStrut strut = info->frameOverlap();
|
2009-12-16 20:51:54 +00:00
|
|
|
// Ignore the strut when compositing is disabled or the decoration doesn't support it
|
|
|
|
if (!compositing() || !Workspace::self()->decorationSupportsFrameOverlap())
|
2009-11-30 00:37:52 +00:00
|
|
|
strut.left = strut.top = strut.right = strut.bottom = 0;
|
|
|
|
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1)
|
2009-11-25 23:32:35 +00:00
|
|
|
return QRect();
|
|
|
|
|
|
|
|
const QRect r = QRect(clientPos(), clientSize())
|
2011-01-30 14:34:42 +00:00
|
|
|
.adjusted(strut.left, strut.top, -strut.right, -strut.bottom);
|
2009-11-25 23:32:35 +00:00
|
|
|
if (r.isValid())
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return QRect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-25 23:32:35 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void Client::detectNoBorder()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (shape()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
noborder = true;
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = true;
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
switch(windowType()) {
|
|
|
|
case NET::Desktop :
|
|
|
|
case NET::Dock :
|
|
|
|
case NET::TopMenu :
|
|
|
|
case NET::Splash :
|
|
|
|
noborder = true;
|
|
|
|
app_noborder = true;
|
|
|
|
break;
|
|
|
|
case NET::Unknown :
|
|
|
|
case NET::Normal :
|
|
|
|
case NET::Toolbar :
|
|
|
|
case NET::Menu :
|
|
|
|
case NET::Dialog :
|
|
|
|
case NET::Utility :
|
|
|
|
noborder = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// NET::Override is some strange beast without clear definition, usually
|
|
|
|
// just meaning "noborder", so let's treat it only as such flag, and ignore it as
|
|
|
|
// a window type otherwise (SUPPORTED_WINDOW_TYPES_MASK doesn't include it)
|
2011-01-30 14:34:42 +00:00
|
|
|
if (info->windowType(SUPPORTED_MANAGED_WINDOW_TYPES_MASK | NET::OverrideMask) == NET::Override) {
|
2007-04-29 17:35:43 +00:00
|
|
|
noborder = true;
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::updateFrameExtents()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
NETStrut strut;
|
|
|
|
strut.left = border_left;
|
|
|
|
strut.right = border_right;
|
|
|
|
strut.top = border_top;
|
|
|
|
strut.bottom = border_bottom;
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setFrameExtents(strut);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Resizes the decoration, and makes sure the decoration widget gets resize event
|
|
|
|
* even if the size hasn't changed. This is needed to make sure the decoration
|
|
|
|
* re-layouts (e.g. when options()->moveResizeMaximizedWindows() changes,
|
|
|
|
* the decoration may turn on/off some borders, but the actual size
|
|
|
|
* of the decoration stays the same).
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::resizeDecoration(const QSize& s)
|
|
|
|
{
|
|
|
|
if (decoration == NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2009-05-04 22:35:33 +00:00
|
|
|
QSize newSize = s + QSize(padding_left + padding_right, padding_top + padding_bottom);
|
|
|
|
QSize oldSize = decoration->widget()->size();
|
2011-01-30 14:34:42 +00:00
|
|
|
decoration->resize(newSize);
|
|
|
|
if (oldSize == newSize) {
|
|
|
|
QResizeEvent e(newSize, oldSize);
|
|
|
|
QApplication::sendEvent(decoration->widget(), &e);
|
2012-09-28 09:59:42 +00:00
|
|
|
} else if (paintRedirector) { // oldSize != newSize
|
|
|
|
paintRedirector->resizePixmaps();
|
|
|
|
} else {
|
|
|
|
triggerDecorationRepaint();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-11-09 19:39:13 +00:00
|
|
|
updateInputWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Client::noBorder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-04-28 13:56:50 +00:00
|
|
|
return !workspace()->hasDecorationPlugin() || noborder || isFullScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Client::userCanSetNoBorder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return !isFullScreen() && !isShade() && !tabGroup();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setNoBorder(bool set)
|
|
|
|
{
|
|
|
|
if (!userCanSetNoBorder())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
set = rules()->checkNoBorder(set);
|
|
|
|
if (noborder == set)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2008-03-23 00:12:11 +00:00
|
|
|
noborder = set;
|
2011-01-30 14:34:42 +00:00
|
|
|
updateDecoration(true, false);
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::NoBorder);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-10-26 14:43:29 +00:00
|
|
|
void Client::checkNoBorder()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setNoBorder(app_noborder);
|
|
|
|
}
|
2010-10-26 14:43:29 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void Client::updateShape()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (shape()) {
|
|
|
|
// Workaround for #19644 - Shaped windows shouldn't have decoration
|
|
|
|
if (!app_noborder) {
|
|
|
|
// Only when shape is detected for the first time, still let the user to override
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = true;
|
2012-07-08 20:29:39 +00:00
|
|
|
noborder = rules()->checkNoBorder(true);
|
2011-01-30 14:34:42 +00:00
|
|
|
updateDecoration(true);
|
2007-04-29 21:19:29 +00:00
|
|
|
}
|
2012-02-17 17:41:44 +00:00
|
|
|
if (noBorder())
|
|
|
|
XShapeCombineShape(display(), frameId(), ShapeBounding,
|
2011-01-30 14:34:42 +00:00
|
|
|
clientPos().x(), clientPos().y(), window(), ShapeBounding, ShapeSet);
|
2012-02-17 17:41:44 +00:00
|
|
|
} else if (app_noborder) {
|
|
|
|
XShapeCombineMask(display(), frameId(), ShapeBounding, 0, 0, None, ShapeSet);
|
|
|
|
detectNoBorder();
|
2012-07-08 20:29:39 +00:00
|
|
|
app_noborder = noborder = rules()->checkNoBorder(noborder);
|
2012-02-17 17:41:44 +00:00
|
|
|
updateDecoration(true);
|
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2008-03-23 00:12:11 +00:00
|
|
|
// Decoration mask (i.e. 'else' here) setting is done in setMask()
|
|
|
|
// when the decoration calls it or when the decoration is created/destroyed
|
2007-07-04 09:51:10 +00:00
|
|
|
updateInputShape();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing()) {
|
2008-09-30 16:45:24 +00:00
|
|
|
addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
addWorkspaceRepaint(visibleRect()); // In case shape change removes part of this window
|
2007-07-04 09:51:10 +00:00
|
|
|
}
|
2011-06-19 20:07:19 +00:00
|
|
|
emit geometryShapeChanged(this, geometry());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 21:39:58 +00:00
|
|
|
|
2008-03-23 00:12:11 +00:00
|
|
|
static Window shape_helper_window = None;
|
|
|
|
|
2007-07-04 09:51:10 +00:00
|
|
|
void Client::updateInputShape()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (hiddenPreview()) // Sets it to none, don't change
|
2007-07-04 09:51:10 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (Extensions::shapeInputAvailable()) {
|
|
|
|
// There appears to be no way to find out if a window has input
|
|
|
|
// shape set or not, so always propagate the input shape
|
|
|
|
// (it's the same like the bounding shape by default).
|
|
|
|
// Also, build the shape using a helper window, not directly
|
|
|
|
// in the frame window, because the sequence set-shape-to-frame,
|
|
|
|
// remove-shape-of-client, add-input-shape-of-client has the problem
|
|
|
|
// that after the second step there's a hole in the input shape
|
|
|
|
// until the real shape of the client is added and that can make
|
|
|
|
// the window lose focus (which is a problem with mouse focus policies)
|
|
|
|
// TODO: It seems there is, after all - XShapeGetRectangles() - but maybe this is better
|
|
|
|
if (shape_helper_window == None)
|
|
|
|
shape_helper_window = XCreateSimpleWindow(display(), rootWindow(),
|
|
|
|
0, 0, 1, 1, 0, 0, 0);
|
|
|
|
XResizeWindow(display(), shape_helper_window, width(), height());
|
|
|
|
XShapeCombineShape(display(), shape_helper_window, ShapeInput, 0, 0,
|
|
|
|
frameId(), ShapeBounding, ShapeSet);
|
|
|
|
XShapeCombineShape(display(), shape_helper_window, ShapeInput,
|
|
|
|
clientPos().x(), clientPos().y(), window(), ShapeBounding, ShapeSubtract);
|
|
|
|
XShapeCombineShape(display(), shape_helper_window, ShapeInput,
|
|
|
|
clientPos().x(), clientPos().y(), window(), ShapeInput, ShapeUnion);
|
|
|
|
XShapeCombineShape(display(), frameId(), ShapeInput, 0, 0,
|
|
|
|
shape_helper_window, ShapeInput, ShapeSet);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setMask(const QRegion& reg, int mode)
|
|
|
|
{
|
|
|
|
QRegion r = reg.translated(-padding_left, -padding_right) & QRect(0, 0, width(), height());
|
|
|
|
if (_mask == r)
|
2008-03-23 00:12:11 +00:00
|
|
|
return;
|
2009-05-04 22:35:33 +00:00
|
|
|
_mask = r;
|
2008-03-23 00:12:11 +00:00
|
|
|
Window shape_window = frameId();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (shape()) {
|
|
|
|
// The same way of applying a shape without strange intermediate states like above
|
|
|
|
if (shape_helper_window == None)
|
|
|
|
shape_helper_window = XCreateSimpleWindow(display(), rootWindow(),
|
|
|
|
0, 0, 1, 1, 0, 0, 0);
|
2008-03-23 00:12:11 +00:00
|
|
|
shape_window = shape_helper_window;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (_mask.isEmpty())
|
|
|
|
XShapeCombineMask(display(), shape_window, ShapeBounding, 0, 0, None, ShapeSet);
|
|
|
|
else if (mode == X::Unsorted)
|
|
|
|
XShapeCombineRegion(display(), shape_window, ShapeBounding, 0, 0, _mask.handle(), ShapeSet);
|
|
|
|
else {
|
2009-05-04 22:35:33 +00:00
|
|
|
QVector< QRect > rects = _mask.rects();
|
2008-12-18 13:50:57 +00:00
|
|
|
XRectangle* xrects = new XRectangle[rects.count()];
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int i = 0; i < rects.count(); ++i) {
|
2008-12-18 13:50:57 +00:00
|
|
|
xrects[i].x = rects[i].x();
|
|
|
|
xrects[i].y = rects[i].y();
|
|
|
|
xrects[i].width = rects[i].width();
|
|
|
|
xrects[i].height = rects[i].height();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
XShapeCombineRectangles(display(), shape_window, ShapeBounding, 0, 0,
|
|
|
|
xrects, rects.count(), ShapeSet, mode);
|
|
|
|
delete[] xrects;
|
|
|
|
}
|
|
|
|
if (shape()) {
|
|
|
|
// The rest of the applyign using a temporary window
|
2012-10-23 21:16:29 +00:00
|
|
|
XRectangle rec = { 0, 0, static_cast<unsigned short>(clientSize().width()),
|
|
|
|
static_cast<unsigned short>(clientSize().height()) };
|
2011-01-30 14:34:42 +00:00
|
|
|
XShapeCombineRectangles(display(), shape_helper_window, ShapeBounding,
|
|
|
|
clientPos().x(), clientPos().y(), &rec, 1, ShapeSubtract, Unsorted);
|
|
|
|
XShapeCombineShape(display(), shape_helper_window, ShapeBounding,
|
|
|
|
clientPos().x(), clientPos().y(), window(), ShapeBounding, ShapeUnion);
|
|
|
|
XShapeCombineShape(display(), frameId(), ShapeBounding, 0, 0,
|
|
|
|
shape_helper_window, ShapeBounding, ShapeSet);
|
|
|
|
}
|
2011-06-19 20:07:19 +00:00
|
|
|
emit geometryShapeChanged(this, geometry());
|
2007-05-02 12:50:37 +00:00
|
|
|
updateShape();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QRegion Client::mask() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (_mask.isEmpty())
|
|
|
|
return QRegion(0, 0, width(), height());
|
2007-04-29 17:35:43 +00:00
|
|
|
return _mask;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::hideClient(bool hide)
|
|
|
|
{
|
|
|
|
if (hidden == hide)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
hidden = hide;
|
|
|
|
updateVisibility();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the window is minimizable or not
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
bool Client::isMinimizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (isSpecialWindow())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-12-10 19:29:01 +00:00
|
|
|
if (!rules()->checkMinimize(true))
|
|
|
|
return false;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isTransient()) {
|
|
|
|
// #66868 - Let other xmms windows be minimized when the mainwindow is minimized
|
2007-04-29 17:35:43 +00:00
|
|
|
bool shown_mainwindow = false;
|
|
|
|
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))
|
2007-04-29 17:35:43 +00:00
|
|
|
shown_mainwindow = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!shown_mainwindow)
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-01-09 14:07:03 +00:00
|
|
|
#if 0
|
2008-12-18 13:50:57 +00:00
|
|
|
// This is here because kicker's taskbar doesn't provide separate entries
|
2007-04-29 17:35:43 +00:00
|
|
|
// for windows with an explicitly given parent
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: perhaps this should be redone
|
2009-01-09 14:07:03 +00:00
|
|
|
// Disabled for now, since at least modal dialogs should be minimizable
|
|
|
|
// (resulting in the mainwindow being minimized too).
|
2011-01-30 14:34:42 +00:00
|
|
|
if (transientFor() != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2009-01-09 14:07:03 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!wantsTabFocus()) // SELI, TODO: - NET::Utility? why wantsTabFocus() - skiptaskbar? ?
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-12-22 18:01:01 +00:00
|
|
|
void Client::setMinimized(bool set)
|
|
|
|
{
|
|
|
|
set ? minimize() : unminimize();
|
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Minimizes this client plus its transients
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::minimize(bool avoid_animation)
|
|
|
|
{
|
|
|
|
if (!isMinimizable() || isMinimized())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2011-12-10 14:29:59 +00:00
|
|
|
if (isShade()) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
|
|
|
|
info->setState(0, NET::Shaded);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Notify::raise(Notify::Minimize);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
minimized = true;
|
|
|
|
|
|
|
|
updateVisibility();
|
|
|
|
updateAllowedActions();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateMinimizedOfTransients(this);
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::Minimize);
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateFocusChains(this, Workspace::FocusChainMakeLast);
|
2011-03-06 09:55:27 +00:00
|
|
|
// TODO: merge signal with s_minimized
|
|
|
|
emit clientMinimized(this, !avoid_animation);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
// Update states of all other windows in this group
|
2012-01-12 06:42:55 +00:00
|
|
|
if (tabGroup())
|
2012-03-15 23:15:13 +00:00
|
|
|
tabGroup()->updateStates(this, TabGroup::Minimized);
|
2011-12-22 18:01:01 +00:00
|
|
|
emit minimizedChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::unminimize(bool avoid_animation)
|
|
|
|
{
|
|
|
|
if (!isMinimized())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2011-12-09 13:39:17 +00:00
|
|
|
if (rules()->checkMinimize(false)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-10 14:29:59 +00:00
|
|
|
if (isShade()) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
|
|
|
|
info->setState(NET::Shaded, NET::Shaded);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Notify::raise(Notify::UnMinimize);
|
2007-04-29 17:35:43 +00:00
|
|
|
minimized = false;
|
|
|
|
updateVisibility();
|
|
|
|
updateAllowedActions();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateMinimizedOfTransients(this);
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::Minimize);
|
2011-03-06 10:08:19 +00:00
|
|
|
emit clientUnminimized(this, !avoid_animation);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
// Update states of all other windows in this group
|
2012-01-12 06:42:55 +00:00
|
|
|
if (tabGroup())
|
2012-03-15 23:15:13 +00:00
|
|
|
tabGroup()->updateStates(this, TabGroup::Minimized);
|
2011-12-22 18:01:01 +00:00
|
|
|
emit minimizedChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QRect Client::iconGeometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
NETRect r = info->iconGeometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect geom(r.pos.x, r.pos.y, r.size.width, r.size.height);
|
|
|
|
if (geom.isValid())
|
2007-04-29 17:35:43 +00:00
|
|
|
return geom;
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
|
|
|
// Check all mainwindows of this window (recursively)
|
|
|
|
foreach (Client * mainwin, mainClients()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
geom = mainwin->iconGeometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (geom.isValid())
|
2007-04-29 17:35:43 +00:00
|
|
|
return geom;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// No mainwindow (or their parents) with icon geometry was found
|
|
|
|
return QRect();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Client::isShadeable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-12-10 19:29:01 +00:00
|
|
|
return !isSpecialWindow() && !noBorder() && (rules()->checkShade(ShadeNormal) != rules()->checkShade(ShadeNone));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-12-22 17:10:18 +00:00
|
|
|
void Client::setShade(bool set) {
|
|
|
|
set ? setShade(ShadeNormal) : setShade(ShadeNone);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setShade(ShadeMode mode)
|
|
|
|
{
|
2012-03-20 15:38:08 +00:00
|
|
|
if (mode == ShadeHover && isMove())
|
|
|
|
return; // causes geometry breaks and is probably nasty
|
2011-12-10 19:29:01 +00:00
|
|
|
if (isSpecialWindow() || noBorder())
|
|
|
|
mode = ShadeNone;
|
2011-01-30 14:34:42 +00:00
|
|
|
mode = rules()->checkShade(mode);
|
|
|
|
if (shade_mode == mode)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
bool was_shade = isShade();
|
|
|
|
ShadeMode was_shade_mode = shade_mode;
|
|
|
|
shade_mode = mode;
|
2012-08-25 20:44:44 +00:00
|
|
|
|
2012-10-21 15:42:30 +00:00
|
|
|
// Decorations may turn off some borders when shaded
|
|
|
|
// this has to happen _before_ the tab alignment since it will restrict the minimum geometry
|
|
|
|
if (decoration)
|
|
|
|
decoration->borders(border_left, border_right, border_top, border_bottom);
|
|
|
|
|
2012-08-25 20:44:44 +00:00
|
|
|
// Update states of all other windows in this group
|
|
|
|
if (tabGroup())
|
|
|
|
tabGroup()->updateStates(this, TabGroup::Shaded);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (was_shade == isShade()) {
|
|
|
|
if (decoration != NULL) // Decoration may want to update after e.g. hover-shade changes
|
2007-04-29 17:35:43 +00:00
|
|
|
decoration->shadeChange();
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // No real change in shaded state
|
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 (shade_mode == ShadeNormal) {
|
|
|
|
if (isShown(true) && isOnCurrentDesktop())
|
|
|
|
Notify::raise(Notify::ShadeUp);
|
|
|
|
} else if (shade_mode == ShadeNone) {
|
|
|
|
if (isShown(true) && isOnCurrentDesktop())
|
|
|
|
Notify::raise(Notify::ShadeDown);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
assert(decoration != NULL); // noborder windows can't be shaded
|
|
|
|
GeometryUpdatesBlocker blocker(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: All this unmapping, resizing etc. feels too much duplicated from elsewhere
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShade()) {
|
|
|
|
// shade_mode == ShadeNormal
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
2008-12-18 13:50:57 +00:00
|
|
|
// Shade
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
QSize s(sizeForClientSize(QSize(clientSize())));
|
|
|
|
s.setHeight(border_top + border_bottom);
|
|
|
|
XSelectInput(display(), wrapper, ClientWinMask); // Avoid getting UnmapNotify
|
|
|
|
XUnmapWindow(display(), wrapper);
|
|
|
|
XUnmapWindow(display(), client);
|
|
|
|
XSelectInput(display(), wrapper, ClientWinMask | SubstructureNotifyMask);
|
|
|
|
plainResize(s);
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = false;
|
2012-04-16 17:13:02 +00:00
|
|
|
if (was_shade_mode == ShadeHover) {
|
|
|
|
if (shade_below && workspace()->stackingOrder().indexOf(shade_below) > -1)
|
2012-03-14 08:59:41 +00:00
|
|
|
workspace()->restack(this, shade_below);
|
2012-04-16 17:13:02 +00:00
|
|
|
if (isActive())
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->activateNextClient(this);
|
2012-04-16 17:13:02 +00:00
|
|
|
} else if (isActive()) {
|
|
|
|
workspace()->focusToNull();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
QSize s(sizeForClientSize(clientSize()));
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
plainResize(s);
|
2012-04-16 17:13:02 +00:00
|
|
|
if ((shade_mode == ShadeHover || shade_mode == ShadeActivated) && rules()->checkAcceptFocus(input))
|
2011-01-30 14:34:42 +00:00
|
|
|
setActive(true);
|
2012-03-14 08:59:41 +00:00
|
|
|
if (shade_mode == ShadeHover) {
|
2012-04-08 08:07:35 +00:00
|
|
|
ToplevelList order = workspace()->stackingOrder();
|
|
|
|
// this is likely related to the index parameter?!
|
|
|
|
for (int idx = order.indexOf(this) + 1; idx < order.count(); ++idx) {
|
|
|
|
shade_below = qobject_cast<Client*>(order.at(idx));
|
|
|
|
if (shade_below) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-14 08:59:41 +00:00
|
|
|
if (shade_below && shade_below->isNormalWindow())
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
else
|
|
|
|
shade_below = NULL;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
XMapWindow(display(), wrapperId());
|
|
|
|
XMapWindow(display(), window());
|
|
|
|
if (isActive())
|
|
|
|
workspace()->requestFocus(this);
|
|
|
|
}
|
|
|
|
info->setState(isShade() ? NET::Shaded : 0, NET::Shaded);
|
|
|
|
info->setState(isShown(false) ? 0 : NET::Hidden, NET::Hidden);
|
2007-04-29 17:35:43 +00:00
|
|
|
discardWindowPixmap();
|
|
|
|
updateVisibility();
|
|
|
|
updateAllowedActions();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (decoration)
|
2010-06-20 12:21:44 +00:00
|
|
|
decoration->shadeChange();
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::Shade);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-12-22 17:10:18 +00:00
|
|
|
emit shadeChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::shadeHover()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setShade(ShadeHover);
|
2008-12-15 08:27:17 +00:00
|
|
|
cancelShadeHoverTimer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-15 08:27:17 +00:00
|
|
|
void Client::shadeUnhover()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-08-25 20:44:44 +00:00
|
|
|
if (!tabGroup() || tabGroup()->current() == this ||
|
|
|
|
tabGroup()->current()->shadeMode() == ShadeNormal)
|
|
|
|
setShade(ShadeNormal);
|
2008-12-15 08:27:17 +00:00
|
|
|
cancelShadeHoverTimer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-15 08:27:17 +00:00
|
|
|
|
|
|
|
void Client::cancelShadeHoverTimer()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete shadeHoverTimer;
|
|
|
|
shadeHoverTimer = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::toggleShade()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
// If the mode is ShadeHover or ShadeActive, cancel shade too
|
|
|
|
setShade(shade_mode == ShadeNone ? ShadeNormal : ShadeNone);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::updateVisibility()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (deleting)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2012-01-12 06:42:55 +00:00
|
|
|
if (hidden && isCurrentTab()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setState(NET::Hidden, NET::Hidden);
|
|
|
|
setSkipTaskbar(true, false); // Also hide from taskbar
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() == HiddenPreviewsAlways)
|
2011-01-30 14:34:42 +00:00
|
|
|
internalKeep(Allowed);
|
2008-08-12 11:02:58 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
internalHide(Allowed);
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-01-12 06:42:55 +00:00
|
|
|
if (isCurrentTab())
|
2011-01-30 14:34:42 +00:00
|
|
|
setSkipTaskbar(original_skip_taskbar, false); // Reset from 'hidden'
|
|
|
|
if (minimized) {
|
|
|
|
info->setState(NET::Hidden, NET::Hidden);
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() == HiddenPreviewsAlways)
|
2011-01-30 14:34:42 +00:00
|
|
|
internalKeep(Allowed);
|
2008-08-12 11:02:58 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
internalHide(Allowed);
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
info->setState(0, NET::Hidden);
|
|
|
|
if (!isOnCurrentDesktop()) {
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() != HiddenPreviewsNever)
|
2011-01-30 14:34:42 +00:00
|
|
|
internalKeep(Allowed);
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
internalHide(Allowed);
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (!isOnCurrentActivity()) {
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() != HiddenPreviewsNever)
|
2011-01-30 14:34:42 +00:00
|
|
|
internalKeep(Allowed);
|
2010-05-11 20:30:20 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
internalHide(Allowed);
|
2010-05-11 20:30:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-08-26 14:16:38 +00:00
|
|
|
resetShowingDesktop(true);
|
2011-01-30 14:34:42 +00:00
|
|
|
internalShow(Allowed);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-08-26 14:16:38 +00:00
|
|
|
|
|
|
|
void Client::resetShowingDesktop(bool keep_hidden)
|
|
|
|
{
|
|
|
|
if (isDock() || !workspace()->showingDesktop())
|
|
|
|
return;
|
|
|
|
bool belongs_to_desktop = false;
|
|
|
|
for (ClientList::ConstIterator it = group()->members().constBegin(),
|
|
|
|
end = group()->members().constEnd(); it != end; ++it)
|
2012-09-04 13:55:35 +00:00
|
|
|
if ((belongs_to_desktop = (*it)->isDesktop()))
|
2012-08-26 14:16:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (!belongs_to_desktop)
|
|
|
|
workspace()->resetShowingDesktop(keep_hidden);
|
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Sets the client window's mapping state. Possible values are
|
|
|
|
* WithdrawnState, IconicState, NormalState.
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::exportMappingState(int s)
|
|
|
|
{
|
|
|
|
assert(client != None);
|
|
|
|
assert(!deleting || s == WithdrawnState);
|
|
|
|
if (s == WithdrawnState) {
|
|
|
|
XDeleteProperty(display(), window(), atoms->wm_state);
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
assert(s == NormalState || s == IconicState);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
unsigned long data[2];
|
|
|
|
data[0] = (unsigned long) s;
|
|
|
|
data[1] = (unsigned long) None;
|
|
|
|
XChangeProperty(display(), window(), atoms->wm_state, atoms->wm_state, 32,
|
2011-01-30 14:34:42 +00:00
|
|
|
PropModeReplace, (unsigned char*)(data), 2);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::internalShow(allowed_t)
|
|
|
|
{
|
|
|
|
if (mapping_state == Mapped)
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
|
|
|
MappingState old = mapping_state;
|
|
|
|
mapping_state = Mapped;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old == Unmapped || old == Withdrawn)
|
|
|
|
map(Allowed);
|
2011-11-09 19:39:13 +00:00
|
|
|
if (old == Kept) {
|
|
|
|
if (inputId())
|
|
|
|
XMapWindow(display(), inputId());
|
2008-08-12 11:02:58 +00:00
|
|
|
updateHiddenPreview();
|
2011-11-09 19:39:13 +00:00
|
|
|
}
|
2012-08-28 17:31:17 +00:00
|
|
|
if (Compositor::isCreated()) {
|
|
|
|
Compositor::self()->checkUnredirect();
|
2011-08-21 19:50:23 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 11:02:58 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::internalHide(allowed_t)
|
|
|
|
{
|
|
|
|
if (mapping_state == Unmapped)
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
|
|
|
MappingState old = mapping_state;
|
|
|
|
mapping_state = Unmapped;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old == Mapped || old == Kept)
|
|
|
|
unmap(Allowed);
|
|
|
|
if (old == Kept)
|
2008-08-12 11:02:58 +00:00
|
|
|
updateHiddenPreview();
|
2011-01-30 14:34:42 +00:00
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
workspace()->clientHidden(this);
|
2012-08-28 17:31:17 +00:00
|
|
|
if (Compositor::isCreated()) {
|
|
|
|
Compositor::self()->checkUnredirect();
|
2011-08-21 19:50:23 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 11:02:58 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::internalKeep(allowed_t)
|
|
|
|
{
|
|
|
|
assert(compositing());
|
|
|
|
if (mapping_state == Kept)
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
|
|
|
MappingState old = mapping_state;
|
|
|
|
mapping_state = Kept;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old == Unmapped || old == Withdrawn)
|
|
|
|
map(Allowed);
|
2011-11-09 19:39:13 +00:00
|
|
|
if (inputId())
|
|
|
|
XUnmapWindow(display(), inputId());
|
2008-08-12 11:02:58 +00:00
|
|
|
updateHiddenPreview();
|
2011-01-30 14:34:42 +00:00
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
workspace()->clientHidden(this);
|
2012-08-28 17:31:17 +00:00
|
|
|
if (Compositor::isCreated()) {
|
|
|
|
Compositor::self()->checkUnredirect();
|
2011-08-21 19:50:23 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Maps (shows) the client. Note that it is mapping state of the frame,
|
|
|
|
* not necessarily the client window itself (i.e. a shaded window is here
|
|
|
|
* considered mapped, even though it is in IconicState).
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::map(allowed_t)
|
|
|
|
{
|
2008-08-12 11:02:58 +00:00
|
|
|
// XComposite invalidates backing pixmaps on unmap (minimize, different
|
|
|
|
// virtual desktop, etc.). We kept the last known good pixmap around
|
|
|
|
// for use in effects, but now we want to have access to the new pixmap
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing())
|
2008-08-12 11:02:58 +00:00
|
|
|
discardWindowPixmap();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (decoration != NULL)
|
2008-12-18 13:50:57 +00:00
|
|
|
decoration->widget()->show(); // Not really necessary, but let it know the state
|
2011-01-30 14:34:42 +00:00
|
|
|
XMapWindow(display(), frameId());
|
|
|
|
if (!isShade()) {
|
|
|
|
XMapWindow(display(), wrapper);
|
|
|
|
XMapWindow(display(), client);
|
2011-11-09 19:39:13 +00:00
|
|
|
if (inputId())
|
|
|
|
XMapWindow(display(), inputId());
|
2011-01-30 14:34:42 +00:00
|
|
|
exportMappingState(NormalState);
|
|
|
|
} else
|
|
|
|
exportMappingState(IconicState);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Unmaps the client. Again, this is about the frame.
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::unmap(allowed_t)
|
|
|
|
{
|
2008-08-12 11:02:58 +00:00
|
|
|
// Here it may look like a race condition, as some other client might try to unmap
|
|
|
|
// the window between these two XSelectInput() calls. However, they're supposed to
|
|
|
|
// use XWithdrawWindow(), which also sends a synthetic event to the root window,
|
|
|
|
// which won't be missed, so this shouldn't be a problem. The chance the real UnmapNotify
|
|
|
|
// will be missed is also very minimal, so I don't think it's needed to grab the server
|
|
|
|
// here.
|
2011-01-30 14:34:42 +00:00
|
|
|
XSelectInput(display(), wrapper, ClientWinMask); // Avoid getting UnmapNotify
|
|
|
|
XUnmapWindow(display(), frameId());
|
|
|
|
XUnmapWindow(display(), wrapper);
|
|
|
|
XUnmapWindow(display(), client);
|
2011-11-09 19:39:13 +00:00
|
|
|
if (inputId())
|
|
|
|
XUnmapWindow(display(), inputId());
|
2011-01-30 14:34:42 +00:00
|
|
|
XSelectInput(display(), wrapper, ClientWinMask | SubstructureNotifyMask);
|
|
|
|
if (decoration != NULL)
|
2008-12-18 13:50:57 +00:00
|
|
|
decoration->widget()->hide(); // Not really necessary, but let it know the state
|
2011-01-30 14:34:42 +00:00
|
|
|
exportMappingState(IconicState);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* XComposite doesn't keep window pixmaps of unmapped windows, which means
|
|
|
|
* there wouldn't be any previews of windows that are minimized or on another
|
|
|
|
* virtual desktop. Therefore rawHide() actually keeps such windows mapped.
|
|
|
|
* However special care needs to be taken so that such windows don't interfere.
|
|
|
|
* Therefore they're put very low in the stacking order and they have input shape
|
|
|
|
* set to none, which hopefully is enough. If there's no input shape available,
|
|
|
|
* then it's hoped that there will be some other desktop above it *shrug*.
|
|
|
|
* Using normal shape would be better, but that'd affect other things, e.g. painting
|
|
|
|
* of the actual preview.
|
|
|
|
*/
|
2008-08-12 11:02:58 +00:00
|
|
|
void Client::updateHiddenPreview()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (hiddenPreview()) {
|
2007-07-04 09:51:10 +00:00
|
|
|
workspace()->forceRestacking();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (Extensions::shapeInputAvailable())
|
|
|
|
XShapeCombineRectangles(display(), frameId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted);
|
|
|
|
} else {
|
2007-07-04 09:51:10 +00:00
|
|
|
workspace()->forceRestacking();
|
|
|
|
updateInputShape();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-04 09:51:10 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::sendClientMessage(Window w, Atom a, Atom protocol, long data1, long data2, long data3)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
XEvent ev;
|
|
|
|
long mask;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
memset(&ev, 0, sizeof(ev));
|
2007-04-29 17:35:43 +00:00
|
|
|
ev.xclient.type = ClientMessage;
|
|
|
|
ev.xclient.window = w;
|
|
|
|
ev.xclient.message_type = a;
|
|
|
|
ev.xclient.format = 32;
|
|
|
|
ev.xclient.data.l[0] = protocol;
|
|
|
|
ev.xclient.data.l[1] = xTime();
|
|
|
|
ev.xclient.data.l[2] = data1;
|
|
|
|
ev.xclient.data.l[3] = data2;
|
|
|
|
ev.xclient.data.l[4] = data3;
|
|
|
|
mask = 0L;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w == rootWindow())
|
|
|
|
mask = SubstructureRedirectMask; // Magic!
|
|
|
|
XSendEvent(display(), w, False, mask, &ev);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the window may be closed (have a close button)
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
bool Client::isCloseable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return rules()->checkCloseable(motif_may_close && !isSpecialWindow());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Closes the window by either sending a delete_window message or using XKill.
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
void Client::closeWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!isCloseable())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// Update user time, because the window may create a confirming dialog.
|
2008-12-18 13:50:57 +00:00
|
|
|
updateUserTime();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (Pdeletewindow) {
|
|
|
|
Notify::raise(Notify::Close);
|
|
|
|
sendClientMessage(window(), atoms->wm_protocols, atoms->wm_delete_window);
|
2007-04-29 17:35:43 +00:00
|
|
|
pingWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else // Client will not react on wm_delete_window. We have not choice
|
|
|
|
// but destroy his connection to the XServer.
|
2007-04-29 17:35:43 +00:00
|
|
|
killWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Kills the window via XKill
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
void Client::killWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
kDebug(1212) << "Client::killWindow():" << caption();
|
2008-12-18 13:50:57 +00:00
|
|
|
|
|
|
|
// Not sure if we need an Notify::Kill or not.. until then, use
|
2007-04-29 17:35:43 +00:00
|
|
|
// Notify::Close
|
2011-01-30 14:34:42 +00:00
|
|
|
Notify::raise(Notify::Close);
|
|
|
|
|
|
|
|
if (isDialog())
|
|
|
|
Notify::raise(Notify::TransDelete);
|
|
|
|
if (isNormalWindow())
|
|
|
|
Notify::raise(Notify::Delete);
|
|
|
|
killProcess(false);
|
|
|
|
XKillClient(display(), window()); // Always kill this client at the server
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyClient();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Send a ping to the window using _NET_WM_PING if possible if it
|
|
|
|
* doesn't respond within a reasonable time, it will be killed.
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
void Client::pingWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!Pping)
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // Can't ping :(
|
2012-02-20 09:25:13 +00:00
|
|
|
if (options->killPingTimeout() == 0)
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // Turned off
|
2011-01-30 14:34:42 +00:00
|
|
|
if (ping_timer != NULL)
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // Pinging already
|
2011-01-30 14:34:42 +00:00
|
|
|
ping_timer = new QTimer(this);
|
|
|
|
connect(ping_timer, SIGNAL(timeout()), SLOT(pingTimeout()));
|
|
|
|
ping_timer->setSingleShot(true);
|
2012-02-20 09:25:13 +00:00
|
|
|
ping_timer->start(options->killPingTimeout());
|
2007-04-29 17:35:43 +00:00
|
|
|
ping_timestamp = xTime();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->sendPingToWindow(window(), ping_timestamp);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::gotPing(Time timestamp)
|
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
// Just plain compare is not good enough because of 64bit and truncating and whatnot
|
2011-01-30 14:34:42 +00:00
|
|
|
if (NET::timestampCompare(timestamp, ping_timestamp) != 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
delete ping_timer;
|
|
|
|
ping_timer = NULL;
|
2012-04-16 21:52:13 +00:00
|
|
|
if (m_killHelperPID && !::kill(m_killHelperPID, 0)) { // means the process is alive
|
|
|
|
::kill(m_killHelperPID, SIGTERM);
|
|
|
|
m_killHelperPID = 0;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::pingTimeout()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
kDebug(1212) << "Ping timeout:" << caption();
|
2008-03-07 19:54:11 +00:00
|
|
|
ping_timer->deleteLater();
|
2007-04-29 17:35:43 +00:00
|
|
|
ping_timer = NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
killProcess(true, ping_timestamp);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::killProcess(bool ask, Time timestamp)
|
|
|
|
{
|
2012-04-16 21:52:13 +00:00
|
|
|
if (m_killHelperPID && !::kill(m_killHelperPID, 0)) // means the process is alive
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
Q_ASSERT(!ask || timestamp != CurrentTime);
|
|
|
|
QByteArray machine = wmClientMachine(true);
|
2007-04-29 17:35:43 +00:00
|
|
|
pid_t pid = info->pid();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (pid <= 0 || machine.isEmpty()) // Needed properties missing
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
kDebug(1212) << "Kill process:" << pid << "(" << machine << ")";
|
|
|
|
if (!ask) {
|
|
|
|
if (machine != "localhost") {
|
2008-12-18 13:50:57 +00:00
|
|
|
QStringList lst;
|
2011-01-30 14:34:42 +00:00
|
|
|
lst << machine << "kill" << QString::number(pid);
|
|
|
|
QProcess::startDetached("xon", lst);
|
|
|
|
} else
|
|
|
|
::kill(pid, SIGTERM);
|
|
|
|
} else {
|
2012-04-16 21:52:13 +00:00
|
|
|
QProcess::startDetached(KStandardDirs::findExe("kwin_killer_helper"),
|
|
|
|
QStringList() << "--pid" << QByteArray().setNum(unsigned(pid)) << "--hostname" << machine
|
|
|
|
<< "--windowname" << caption()
|
|
|
|
<< "--applicationname" << resourceClass()
|
|
|
|
<< "--wid" << QString::number(window())
|
|
|
|
<< "--timestamp" << QString::number(timestamp),
|
|
|
|
QString(), &m_killHelperPID);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setSkipTaskbar(bool b, bool from_outside)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
int was_wants_tab_focus = wantsTabFocus();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (from_outside) {
|
|
|
|
b = rules()->checkSkipTaskbar(b);
|
2007-04-29 17:35:43 +00:00
|
|
|
original_skip_taskbar = b;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (b == skipTaskbar())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
skip_taskbar = b;
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setState(b ? NET::SkipTaskbar : 0, NET::SkipTaskbar);
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::SkipTaskbar);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (was_wants_tab_focus != wantsTabFocus())
|
|
|
|
workspace()->updateFocusChains(this,
|
|
|
|
isActive() ? Workspace::FocusChainMakeFirst : Workspace::FocusChainUpdate);
|
2012-02-27 20:09:36 +00:00
|
|
|
emit skipTaskbarChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setSkipPager(bool b)
|
|
|
|
{
|
|
|
|
b = rules()->checkSkipPager(b);
|
|
|
|
if (b == skipPager())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
skip_pager = b;
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setState(b ? NET::SkipPager : 0, NET::SkipPager);
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::SkipPager);
|
2012-02-27 20:09:36 +00:00
|
|
|
emit skipPagerChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setSkipSwitcher(bool set)
|
|
|
|
{
|
|
|
|
set = rules()->checkSkipSwitcher(set);
|
|
|
|
if (set == skipSwitcher())
|
2010-05-03 20:04:44 +00:00
|
|
|
return;
|
|
|
|
skip_switcher = set;
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::SkipSwitcher);
|
2011-12-29 09:19:36 +00:00
|
|
|
emit skipSwitcherChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-03 20:04:44 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setModal(bool m)
|
|
|
|
{
|
|
|
|
// Qt-3.2 can have even modal normal windows :(
|
|
|
|
if (modal == m)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
modal = m;
|
2011-12-22 16:54:07 +00:00
|
|
|
emit modalChanged();
|
2008-12-18 13:50:57 +00:00
|
|
|
// Changing modality for a mapped window is weird (?)
|
2007-04-29 17:35:43 +00:00
|
|
|
// _NET_WM_STATE_MODAL should possibly rather be _NET_WM_WINDOW_TYPE_MODAL_DIALOG
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setDesktop(int desktop)
|
|
|
|
{
|
|
|
|
if (desktop != NET::OnAllDesktops) // Do range check
|
|
|
|
desktop = qMax(1, qMin(workspace()->numberOfDesktops(), desktop));
|
|
|
|
desktop = qMin(workspace()->numberOfDesktops(), rules()->checkDesktop(desktop));
|
|
|
|
if (desk == desktop)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2010-11-10 03:01:49 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int was_desk = desk;
|
|
|
|
desk = desktop;
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setDesktop(desktop);
|
|
|
|
if ((was_desk == NET::OnAllDesktops) != (desktop == NET::OnAllDesktops)) {
|
|
|
|
// onAllDesktops changed
|
|
|
|
if (isShown(true))
|
|
|
|
Notify::raise(isOnAllDesktops() ? Notify::OnAllDesktops : Notify::NotOnAllDesktops);
|
|
|
|
workspace()->updateOnAllDesktopsOfTransients(this);
|
|
|
|
}
|
|
|
|
if (decoration != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
decoration->desktopChange();
|
2010-11-10 03:01:49 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
ClientList transients_stacking_order = workspace()->ensureStackingOrder(transients());
|
|
|
|
for (ClientList::ConstIterator it = transients_stacking_order.constBegin();
|
|
|
|
it != transients_stacking_order.constEnd();
|
|
|
|
++it)
|
|
|
|
(*it)->setDesktop(desktop);
|
2010-11-10 03:01:49 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isModal()) // if a modal dialog is moved, move the mainwindow with it as otherwise
|
|
|
|
// the (just moved) modal dialog will confusingly return to the mainwindow with
|
|
|
|
// the next desktop change
|
|
|
|
{
|
|
|
|
foreach (Client * c2, mainClients())
|
|
|
|
c2->setDesktop(desktop);
|
|
|
|
}
|
2010-11-10 03:01:49 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst);
|
2007-04-29 17:35:43 +00:00
|
|
|
updateVisibility();
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::Desktop);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
// Update states of all other windows in this group
|
2012-01-12 06:42:55 +00:00
|
|
|
if (tabGroup())
|
2012-03-15 23:15:13 +00:00
|
|
|
tabGroup()->updateStates(this, TabGroup::Desktop);
|
2011-12-22 14:02:35 +00:00
|
|
|
emit desktopChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-05-11 20:30:20 +00:00
|
|
|
/**
|
|
|
|
* Sets whether the client is on @p activity.
|
|
|
|
* If you remove it from its last activity, then it's on all activities.
|
|
|
|
*
|
|
|
|
* Note: If it was on all activities and you try to remove it from one, nothing will happen;
|
|
|
|
* I don't think that's an important enough use case to handle here.
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setOnActivity(const QString &activity, bool enable)
|
|
|
|
{
|
2010-09-24 12:03:22 +00:00
|
|
|
QStringList newActivitiesList = activities();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (newActivitiesList.contains(activity) == enable) //nothing to do
|
2010-05-11 20:30:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (enable) {
|
2010-09-24 12:03:22 +00:00
|
|
|
QStringList allActivities = workspace()->activityList();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!allActivities.contains(activity)) //bogus ID
|
2010-05-13 04:06:27 +00:00
|
|
|
return;
|
2010-05-11 20:30:20 +00:00
|
|
|
newActivitiesList.append(activity);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2010-05-11 20:30:20 +00:00
|
|
|
newActivitiesList.removeOne(activity);
|
2011-01-30 14:34:42 +00:00
|
|
|
setOnActivities(newActivitiesList);
|
|
|
|
}
|
2010-05-19 22:32:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set exactly which activities this client is on
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setOnActivities(QStringList newActivitiesList)
|
|
|
|
{
|
2012-05-17 14:32:06 +00:00
|
|
|
QString joinedActivitiesList = newActivitiesList.join(",");
|
|
|
|
joinedActivitiesList = rules()->checkActivity(joinedActivitiesList, false);
|
2012-05-22 16:51:33 +00:00
|
|
|
newActivitiesList = joinedActivitiesList.split(',', QString::SkipEmptyParts);
|
2012-05-17 14:32:06 +00:00
|
|
|
|
2010-09-24 12:03:22 +00:00
|
|
|
QStringList allActivities = workspace()->activityList();
|
2012-06-09 11:36:53 +00:00
|
|
|
if ( newActivitiesList.isEmpty() ||
|
|
|
|
(newActivitiesList.count() > 1 && newActivitiesList.count() == allActivities.count()) ||
|
2012-05-31 09:11:43 +00:00
|
|
|
(newActivitiesList.count() == 1 && newActivitiesList.at(0) == "ALL")) {
|
2012-05-17 14:32:06 +00:00
|
|
|
activityList.clear();
|
|
|
|
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
|
|
|
|
PropModeReplace, (const unsigned char *)"ALL", 3);
|
2010-09-24 12:03:22 +00:00
|
|
|
|
2012-05-17 14:32:06 +00:00
|
|
|
} else {
|
|
|
|
QByteArray joined = joinedActivitiesList.toAscii();
|
|
|
|
char *data = joined.data();
|
|
|
|
activityList = newActivitiesList;
|
|
|
|
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
|
2011-01-30 14:34:42 +00:00
|
|
|
PropModeReplace, (unsigned char *)data, joined.size());
|
2010-09-24 12:03:22 +00:00
|
|
|
|
2012-05-17 14:32:06 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
updateActivities(false);
|
|
|
|
}
|
2010-05-19 22:32:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* update after activities changed
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::updateActivities(bool includeTransients)
|
|
|
|
{
|
2010-05-19 22:32:57 +00:00
|
|
|
/* FIXME do I need this?
|
2011-01-30 14:34:42 +00:00
|
|
|
if ( decoration != NULL )
|
2010-05-11 20:30:20 +00:00
|
|
|
decoration->desktopChange();
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
if (includeTransients)
|
|
|
|
workspace()->updateOnAllActivitiesOfTransients(this);
|
|
|
|
workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst);
|
2010-05-11 20:30:20 +00:00
|
|
|
updateVisibility();
|
2012-05-17 14:32:06 +00:00
|
|
|
updateWindowRules(Rules::Activity);
|
2010-05-11 20:30:20 +00:00
|
|
|
|
|
|
|
// Update states of all other windows in this group
|
2012-01-12 06:42:55 +00:00
|
|
|
if (tabGroup())
|
2012-03-15 23:15:13 +00:00
|
|
|
tabGroup()->updateStates(this, TabGroup::Activity);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the virtual desktop within the workspace() the client window
|
|
|
|
* is located in, 0 if it isn't located on any special desktop (not mapped yet),
|
|
|
|
* or NET::OnAllDesktops. Do not use desktop() directly, use
|
|
|
|
* isOnDesktop() instead.
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
int Client::desktop() const
|
2010-12-16 20:14:22 +00:00
|
|
|
{
|
|
|
|
if (needsSessionInteract) {
|
|
|
|
return NET::OnAllDesktops;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2010-12-16 20:14:22 +00:00
|
|
|
return desk;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-05-11 20:30:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the list of activities the client window is on.
|
|
|
|
* if it's on all activities, the list will be empty.
|
|
|
|
* Don't use this, use isOnActivity() and friends (from class Toplevel)
|
|
|
|
*/
|
|
|
|
QStringList Client::activities() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-12-16 20:14:22 +00:00
|
|
|
if (needsSessionInteract) {
|
|
|
|
return QStringList();
|
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
return activityList;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setOnAllDesktops(bool b)
|
|
|
|
{
|
|
|
|
if ((b && isOnAllDesktops()) ||
|
|
|
|
(!b && !isOnAllDesktops()))
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (b)
|
|
|
|
setDesktop(NET::OnAllDesktops);
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
setDesktop(workspace()->currentDesktop());
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
// Update states of all other windows in this group
|
2012-01-12 06:42:55 +00:00
|
|
|
if (tabGroup())
|
2012-03-15 23:15:13 +00:00
|
|
|
tabGroup()->updateStates(this, TabGroup::Desktop);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-05-11 20:30:20 +00:00
|
|
|
/**
|
2010-05-13 04:56:38 +00:00
|
|
|
* if @p on is true, sets on all activities.
|
2010-05-11 20:30:20 +00:00
|
|
|
* if it's false, sets it to only be on the current activity
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setOnAllActivities(bool on)
|
|
|
|
{
|
|
|
|
if (on == isOnAllActivities())
|
2010-05-11 20:30:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (on) {
|
2012-05-17 14:32:06 +00:00
|
|
|
setOnActivities(QStringList());
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2010-05-13 03:10:31 +00:00
|
|
|
setOnActivity(Workspace::self()->currentActivity(), true);
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateOnAllActivitiesOfTransients(this);
|
2010-05-11 20:30:20 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Performs activation and/or raising of the window
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::takeActivity(int flags, bool handled, allowed_t)
|
|
|
|
{
|
|
|
|
if (!handled || !Ptakeactivity) {
|
|
|
|
if (flags & ActivityFocus)
|
|
|
|
takeFocus(Allowed);
|
|
|
|
if (flags & ActivityRaise)
|
|
|
|
workspace()->raiseClient(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
static Time previous_activity_timestamp;
|
|
|
|
static Client* previous_client;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
//if ( previous_activity_timestamp == xTime() && previous_client != this )
|
2008-12-18 13:50:57 +00:00
|
|
|
// {
|
|
|
|
// kDebug( 1212 ) << "Repeated use of the same X timestamp for activity";
|
|
|
|
// kDebug( 1212 ) << kBacktrace();
|
|
|
|
// }
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
previous_activity_timestamp = xTime();
|
|
|
|
previous_client = this;
|
|
|
|
#endif
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->sendTakeActivity(this, xTime(), flags);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Performs the actual focusing of the window using XSetInputFocus and WM_TAKE_FOCUS
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::takeFocus(allowed_t)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
static Time previous_focus_timestamp;
|
2010-09-21 15:56:20 +00:00
|
|
|
static Client* previous_client;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
//if ( previous_focus_timestamp == xTime() && previous_client != this )
|
2008-12-18 13:50:57 +00:00
|
|
|
// {
|
|
|
|
// kDebug( 1212 ) << "Repeated use of the same X timestamp for focus";
|
|
|
|
// kDebug( 1212 ) << kBacktrace();
|
|
|
|
// }
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
previous_focus_timestamp = xTime();
|
|
|
|
previous_client = this;
|
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
if (rules()->checkAcceptFocus(input))
|
|
|
|
XSetInputFocus(display(), window(), RevertToPointerRoot, xTime());
|
2012-04-16 15:27:53 +00:00
|
|
|
else
|
|
|
|
demandAttention(false); // window cannot take input, at least withdraw urgency
|
2011-01-30 14:34:42 +00:00
|
|
|
if (Ptakefocus)
|
|
|
|
sendClientMessage(window(), atoms->wm_protocols, atoms->wm_take_focus);
|
|
|
|
workspace()->setShouldGetFocus(this);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the window provides context help or not. If it does,
|
|
|
|
* you should show a help menu item or a help button like '?' and call
|
|
|
|
* contextHelp() if this is invoked.
|
|
|
|
*
|
|
|
|
* \sa contextHelp()
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
bool Client::providesContextHelp() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Pcontexthelp;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Invokes context help on the window. Only works if the window
|
|
|
|
* actually provides context help.
|
|
|
|
*
|
|
|
|
* \sa providesContextHelp()
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
void Client::showContextHelp()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Pcontexthelp) {
|
|
|
|
sendClientMessage(window(), atoms->wm_protocols, atoms->net_wm_context_help);
|
2008-12-18 13:50:57 +00:00
|
|
|
QWhatsThis::enterWhatsThisMode(); // SELI TODO: ?
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Fetches the window's caption (WM_NAME property). It will be
|
|
|
|
* stored in the client's caption().
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
void Client::fetchName()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setCaption(readName());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QString Client::readName() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (info->name() && info->name()[0] != '\0')
|
|
|
|
return QString::fromUtf8(info->name());
|
2008-12-18 13:50:57 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
return KWindowSystem::readNameProperty(window(), XA_WM_NAME);
|
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_COMPARE_PREDICATE(FetchNameInternalPredicate, Client, const Client*, (!cl->isSpecialWindow() || cl->isToolbar()) && cl != value && cl->caption() == value->caption());
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-19 10:32:54 +00:00
|
|
|
// The list is taken from http://www.unicode.org/reports/tr9/ (#154840)
|
2008-08-13 16:33:54 +00:00
|
|
|
QChar LRM(0x200E);
|
|
|
|
QChar RLM(0x200F);
|
|
|
|
QChar LRE(0x202A);
|
|
|
|
QChar RLE(0x202B);
|
|
|
|
QChar LRO(0x202D);
|
|
|
|
QChar RLO(0x202E);
|
|
|
|
QChar PDF(0x202C);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setCaption(const QString& _s, bool force)
|
|
|
|
{
|
2012-10-16 20:42:19 +00:00
|
|
|
if (!force && _s == cap_normal)
|
|
|
|
return;
|
|
|
|
QString s(_s);
|
|
|
|
for (int i = 0; i < s.length(); ++i)
|
|
|
|
if (!s[i].isPrint())
|
|
|
|
s[i] = QChar(' ');
|
|
|
|
cap_normal = s;
|
|
|
|
#ifdef KWIN_BUILD_SCRIPTING
|
|
|
|
if (options->condensedTitle()) {
|
|
|
|
static QScriptEngine engine;
|
|
|
|
static QScriptProgram stripTitle;
|
|
|
|
static QScriptValue script;
|
|
|
|
if (stripTitle.isNull()) {
|
|
|
|
const QString scriptFile = KStandardDirs::locate("data", QLatin1String(KWIN_NAME) + "/stripTitle.js");
|
|
|
|
if (!scriptFile.isEmpty()) {
|
|
|
|
QFile f(scriptFile);
|
|
|
|
if (f.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
|
|
|
f.reset();
|
|
|
|
stripTitle = QScriptProgram(QString::fromLocal8Bit(f.readAll()), "stripTitle.js");
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (stripTitle.isNull())
|
|
|
|
stripTitle = QScriptProgram("(function(title, wm_name, wm_class){ return title ; })", "stripTitle.js");
|
|
|
|
script = engine.evaluate(stripTitle);
|
|
|
|
}
|
|
|
|
QScriptValueList args;
|
|
|
|
args << _s << QString(resourceName()) << QString(resourceClass());
|
|
|
|
s = script.call(QScriptValue(), args).toString();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!force && s == cap_deco)
|
|
|
|
return;
|
|
|
|
cap_deco = s;
|
|
|
|
|
|
|
|
bool reset_name = force;
|
|
|
|
bool was_suffix = (!cap_suffix.isEmpty());
|
|
|
|
cap_suffix.clear();
|
|
|
|
QString machine_suffix;
|
|
|
|
if (!options->condensedTitle()) { // machine doesn't qualify for "clean"
|
2011-01-30 14:34:42 +00:00
|
|
|
if (wmClientMachine(false) != "localhost" && !isLocalMachine(wmClientMachine(false)))
|
|
|
|
machine_suffix = QString(" <@") + wmClientMachine(true) + '>' + LRM;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2012-10-16 20:42:19 +00:00
|
|
|
QString shortcut_suffix = !shortcut().isEmpty() ? (" {" + shortcut().toString() + '}') : QString();
|
|
|
|
cap_suffix = machine_suffix + shortcut_suffix;
|
|
|
|
if ((!isSpecialWindow() || isToolbar()) && workspace()->findClient(FetchNameInternalPredicate(this))) {
|
|
|
|
int i = 2;
|
|
|
|
do {
|
|
|
|
cap_suffix = machine_suffix + " <" + QString::number(i) + '>' + LRM;
|
|
|
|
i++;
|
|
|
|
} while (workspace()->findClient(FetchNameInternalPredicate(this)));
|
|
|
|
info->setVisibleName(caption().toUtf8());
|
|
|
|
reset_name = false;
|
|
|
|
}
|
|
|
|
if ((was_suffix && cap_suffix.isEmpty()) || reset_name) {
|
|
|
|
// If it was new window, it may have old value still set, if the window is reused
|
|
|
|
info->setVisibleName("");
|
|
|
|
info->setVisibleIconName("");
|
|
|
|
} else if (!cap_suffix.isEmpty() && !cap_iconic.isEmpty())
|
|
|
|
// Keep the same suffix in iconic name if it's set
|
|
|
|
info->setVisibleIconName(QString(cap_iconic + cap_suffix).toUtf8());
|
|
|
|
|
|
|
|
if (isManaged() && decoration) {
|
|
|
|
decoration->captionChange();
|
|
|
|
}
|
|
|
|
emit captionChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::updateCaption()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setCaption(cap_normal, true);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::fetchIconicName()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QString s;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (info->iconName() && info->iconName()[0] != '\0')
|
|
|
|
s = QString::fromUtf8(info->iconName());
|
2008-12-18 13:50:57 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
s = KWindowSystem::readNameProperty(window(), XA_WM_ICON_NAME);
|
|
|
|
if (s != cap_iconic) {
|
2008-12-18 13:50:57 +00:00
|
|
|
bool was_set = !cap_iconic.isEmpty();
|
2007-04-29 17:35:43 +00:00
|
|
|
cap_iconic = s;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!cap_suffix.isEmpty()) {
|
|
|
|
if (!cap_iconic.isEmpty()) // Keep the same suffix in iconic name if it's set
|
2011-05-22 11:53:25 +00:00
|
|
|
info->setVisibleIconName(QString(s + cap_suffix).toUtf8());
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (was_set)
|
|
|
|
info->setVisibleIconName("");
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* \reimp
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2012-10-16 20:42:19 +00:00
|
|
|
QString Client::caption(bool full, bool stripped) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-10-16 20:42:19 +00:00
|
|
|
QString cap = stripped ? cap_deco : cap_normal;
|
|
|
|
if (full)
|
|
|
|
cap += cap_suffix;
|
|
|
|
return cap;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
bool Client::tabTo(Client *other, bool behind, bool activate)
|
2011-11-07 19:52:21 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
Q_ASSERT(other && other != this);
|
|
|
|
|
|
|
|
if (tab_group && tab_group == other->tabGroup()) { // special case: move inside group
|
|
|
|
tab_group->move(this, other, behind);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
GeometryUpdatesBlocker blocker(this);
|
|
|
|
const bool wasBlocking = signalsBlocked();
|
|
|
|
blockSignals(true); // prevent client emitting "retabbed to nowhere" cause it's about to be entabbed the next moment
|
|
|
|
untab();
|
|
|
|
blockSignals(wasBlocking);
|
|
|
|
|
|
|
|
TabGroup *newGroup = other->tabGroup() ? other->tabGroup() : new TabGroup(other);
|
|
|
|
|
|
|
|
if (!newGroup->add(this, other, behind, activate)) {
|
|
|
|
if (newGroup->count() < 2) { // adding "c" to "to" failed for whatever reason
|
|
|
|
newGroup->remove(other);
|
|
|
|
delete newGroup;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2011-11-07 19:52:21 +00:00
|
|
|
}
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
bool Client::untab(const QRect &toGeometry)
|
2012-01-15 10:26:38 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
TabGroup *group = tab_group;
|
2012-08-25 16:20:34 +00:00
|
|
|
if (group && group->remove(this)) { // remove sets the tabgroup to "0", therefore the pointer is cached
|
2012-01-12 06:42:55 +00:00
|
|
|
if (group->isEmpty()) {
|
|
|
|
delete group;
|
|
|
|
}
|
|
|
|
setClientShown(!(isMinimized() || isShade()));
|
2012-08-25 16:20:34 +00:00
|
|
|
bool keepSize = toGeometry.size() == size();
|
|
|
|
bool changedSize = false;
|
|
|
|
if (quickTileMode() != QuickTileNone) {
|
|
|
|
changedSize = true;
|
|
|
|
setQuickTileMode(QuickTileNone); // if we leave a quicktiled group, assume that the user wants to untile
|
|
|
|
}
|
|
|
|
if (toGeometry.isValid()) {
|
|
|
|
if (maximizeMode() != Client::MaximizeRestore) {
|
|
|
|
changedSize = true;
|
|
|
|
maximize(Client::MaximizeRestore); // explicitly calling for a geometry -> unmaximize
|
|
|
|
}
|
|
|
|
if (keepSize && changedSize) {
|
|
|
|
geom_restore = geometry(); // checkWorkspacePosition() invokes it
|
|
|
|
QPoint cpoint = QCursor::pos();
|
|
|
|
QPoint point = cpoint;
|
|
|
|
point.setX((point.x() - toGeometry.x()) * geom_restore.width() / toGeometry.width());
|
|
|
|
point.setY((point.y() - toGeometry.y()) * geom_restore.height() / toGeometry.height());
|
|
|
|
geom_restore.moveTo(cpoint-point);
|
|
|
|
} else {
|
|
|
|
geom_restore = toGeometry; // checkWorkspacePosition() invokes it
|
|
|
|
}
|
|
|
|
setGeometry(geom_restore);
|
|
|
|
checkWorkspacePosition();
|
|
|
|
}
|
2012-01-15 10:26:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-01-12 06:42:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::setTabGroup(TabGroup *group)
|
|
|
|
{
|
|
|
|
tab_group = group;
|
|
|
|
if (group) {
|
|
|
|
unsigned long data = qHash(group); //->id();
|
|
|
|
XChangeProperty(display(), window(), atoms->kde_net_wm_tab_group, XA_CARDINAL, 32,
|
|
|
|
PropModeReplace, (unsigned char*)(&data), 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
XDeleteProperty(display(), window(), atoms->kde_net_wm_tab_group);
|
|
|
|
emit tabGroupChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Client::isCurrentTab() const
|
|
|
|
{
|
|
|
|
return !tab_group || tab_group->current() == this;
|
2012-01-15 10:26:38 +00:00
|
|
|
}
|
|
|
|
|
2012-04-22 20:27:04 +00:00
|
|
|
void Client::syncTabGroupFor(QString property, bool fromThisClient)
|
|
|
|
{
|
|
|
|
if (tab_group)
|
|
|
|
tab_group->sync(property.toAscii().data(), fromThisClient ? this : tab_group->current());
|
|
|
|
}
|
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
void Client::dontMoveResize()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
buttonDown = false;
|
|
|
|
stopDelayedMoveResize();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (moveResizeMode)
|
|
|
|
finishMoveResize(false);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::setClientShown(bool shown)
|
|
|
|
{
|
|
|
|
if (deleting)
|
2009-11-16 11:38:26 +00:00
|
|
|
return; // Don't change shown status if this client is being deleted
|
2012-01-12 06:42:55 +00:00
|
|
|
if (shown != hidden)
|
|
|
|
return; // nothing to change
|
|
|
|
hidden = !shown;
|
2012-02-20 09:25:13 +00:00
|
|
|
if (options->isInactiveTabsSkipTaskbar())
|
2012-01-12 06:42:55 +00:00
|
|
|
setSkipTaskbar(hidden, false); // TODO: Causes reshuffle of the taskbar
|
|
|
|
if (shown) {
|
2011-01-30 14:34:42 +00:00
|
|
|
map(Allowed);
|
|
|
|
takeFocus(Allowed);
|
2009-11-15 03:24:04 +00:00
|
|
|
autoRaise();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst);
|
2012-01-12 06:42:55 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
unmap(Allowed);
|
2010-09-24 21:34:20 +00:00
|
|
|
// Don't move tabs to the end of the list when another tab get's activated
|
2012-01-12 06:42:55 +00:00
|
|
|
if (isCurrentTab())
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateFocusChains(this, Workspace::FocusChainMakeLast);
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
2009-11-15 03:24:04 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void Client::getWMHints()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
XWMHints* hints = XGetWMHints(display(), window());
|
2007-04-29 17:35:43 +00:00
|
|
|
input = true;
|
|
|
|
window_group = None;
|
|
|
|
urgency = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (hints) {
|
|
|
|
if (hints->flags & InputHint)
|
2007-04-29 17:35:43 +00:00
|
|
|
input = hints->input;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (hints->flags & WindowGroupHint)
|
2007-04-29 17:35:43 +00:00
|
|
|
window_group = hints->window_group;
|
2011-01-30 14:34:42 +00:00
|
|
|
urgency = !!(hints->flags & UrgencyHint); // Need boolean, it's a uint bitfield
|
|
|
|
XFree((char*)hints);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
checkGroup();
|
|
|
|
updateUrgency();
|
2008-12-18 13:50:57 +00:00
|
|
|
updateAllowedActions(); // Group affects isMinimizable()
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::getMotifHints()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-10-03 14:32:24 +00:00
|
|
|
bool mgot_noborder, mnoborder, mresize, mmove, mminimize, mmaximize, mclose;
|
2011-01-30 14:34:42 +00:00
|
|
|
Motif::readFlags(client, mgot_noborder, mnoborder, mresize, mmove, mminimize, mmaximize, mclose);
|
2012-01-12 18:01:43 +00:00
|
|
|
if (mgot_noborder && motif_noborder != mnoborder) {
|
2009-10-03 14:32:24 +00:00
|
|
|
motif_noborder = mnoborder;
|
|
|
|
// If we just got a hint telling us to hide decorations, we do so.
|
2011-01-30 14:34:42 +00:00
|
|
|
if (motif_noborder)
|
2012-01-12 18:01:43 +00:00
|
|
|
noborder = rules()->checkNoBorder(true);
|
2009-10-03 14:32:24 +00:00
|
|
|
// If the Motif hint is now telling us to show decorations, we only do so if the app didn't
|
|
|
|
// instruct us to hide decorations in some other way, though.
|
2012-01-12 18:01:43 +00:00
|
|
|
else if (!app_noborder)
|
|
|
|
noborder = rules()->checkNoBorder(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (!hasNETSupport()) {
|
|
|
|
// NETWM apps should set type and size constraints
|
2008-12-18 13:50:57 +00:00
|
|
|
motif_may_resize = mresize; // This should be set using minsize==maxsize, but oh well
|
2007-04-29 17:35:43 +00:00
|
|
|
motif_may_move = mmove;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2007-04-29 17:35:43 +00:00
|
|
|
motif_may_resize = motif_may_move = true;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
|
|
|
// mminimize; - Ignore, bogus - E.g. shading or sending to another desktop is "minimizing" too
|
|
|
|
// mmaximize; - Ignore, bogus - Maximizing is basically just resizing
|
2012-01-24 16:02:50 +00:00
|
|
|
const bool closabilityChanged = motif_may_close != mclose;
|
2008-12-18 13:50:57 +00:00
|
|
|
motif_may_close = mclose; // Motif apps like to crash when they set this hint and WM closes them anyway
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isManaged())
|
|
|
|
updateDecoration(true); // Check if noborder state has changed
|
2012-01-24 16:02:50 +00:00
|
|
|
if (decoration && closabilityChanged)
|
|
|
|
decoration->reset(KDecoration::SettingButtons);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::readIcons(Window win, QPixmap* icon, QPixmap* miniicon, QPixmap* bigicon, QPixmap* hugeicon)
|
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
// Get the icons, allow scaling
|
2011-01-30 14:34:42 +00:00
|
|
|
if (icon != NULL)
|
|
|
|
*icon = KWindowSystem::icon(win, 32, 32, true, KWindowSystem::NETWM | KWindowSystem::WMHints);
|
|
|
|
if (miniicon != NULL) {
|
|
|
|
if (icon == NULL || !icon->isNull())
|
|
|
|
*miniicon = KWindowSystem::icon(win, 16, 16, true, KWindowSystem::NETWM | KWindowSystem::WMHints);
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
|
|
|
*miniicon = QPixmap();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (bigicon != NULL) {
|
|
|
|
if (icon == NULL || !icon->isNull())
|
|
|
|
*bigicon = KWindowSystem::icon(win, 64, 64, false, KWindowSystem::NETWM | KWindowSystem::WMHints);
|
2010-06-12 06:56:40 +00:00
|
|
|
else
|
|
|
|
*bigicon = QPixmap();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (hugeicon != NULL) {
|
|
|
|
if (icon == NULL || !icon->isNull())
|
|
|
|
*hugeicon = KWindowSystem::icon(win, 128, 128, false, KWindowSystem::NETWM | KWindowSystem::WMHints);
|
2010-06-12 06:56:40 +00:00
|
|
|
else
|
|
|
|
*hugeicon = QPixmap();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::getIcons()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
// First read icons from the window itself
|
2011-01-30 14:34:42 +00:00
|
|
|
readIcons(window(), &icon_pix, &miniicon_pix, &bigicon_pix, &hugeicon_pix);
|
|
|
|
if (icon_pix.isNull()) {
|
|
|
|
// Then try window group
|
2007-04-29 17:35:43 +00:00
|
|
|
icon_pix = group()->icon();
|
|
|
|
miniicon_pix = group()->miniIcon();
|
2010-06-12 06:56:40 +00:00
|
|
|
bigicon_pix = group()->bigIcon();
|
|
|
|
hugeicon_pix = group()->hugeIcon();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (icon_pix.isNull() && isTransient()) {
|
|
|
|
// Then mainclients
|
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() && icon_pix.isNull();
|
|
|
|
++it) {
|
2007-04-29 17:35:43 +00:00
|
|
|
icon_pix = (*it)->icon();
|
|
|
|
miniicon_pix = (*it)->miniIcon();
|
2010-06-12 06:56:40 +00:00
|
|
|
bigicon_pix = (*it)->bigIcon();
|
|
|
|
hugeicon_pix = (*it)->hugeIcon();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (icon_pix.isNull()) {
|
|
|
|
// And if nothing else, load icon from classhint or xapp icon
|
|
|
|
icon_pix = KWindowSystem::icon(window(), 32, 32, true, KWindowSystem::ClassHint | KWindowSystem::XApp);
|
|
|
|
miniicon_pix = KWindowSystem::icon(window(), 16, 16, true, KWindowSystem::ClassHint | KWindowSystem::XApp);
|
|
|
|
bigicon_pix = KWindowSystem::icon(window(), 64, 64, false, KWindowSystem::ClassHint | KWindowSystem::XApp);
|
|
|
|
hugeicon_pix = KWindowSystem::icon(window(), 128, 128, false, KWindowSystem::ClassHint | KWindowSystem::XApp);
|
|
|
|
}
|
|
|
|
if (isManaged() && decoration != NULL)
|
|
|
|
decoration->iconChange();
|
2011-12-29 09:19:36 +00:00
|
|
|
emit iconChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QPixmap Client::icon(const QSize& size) const
|
|
|
|
{
|
|
|
|
const int iconSize = qMin(size.width(), size.height());
|
|
|
|
if (iconSize <= 16)
|
2010-06-12 06:56:40 +00:00
|
|
|
return miniIcon();
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (iconSize <= 32)
|
2010-06-12 06:56:40 +00:00
|
|
|
return icon();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (iconSize <= 64)
|
2010-06-12 06:56:40 +00:00
|
|
|
return bigIcon();
|
|
|
|
else
|
|
|
|
return hugeIcon();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-06-12 06:56:40 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void Client::getWindowProtocols()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
Atom* p;
|
2011-01-30 14:34:42 +00:00
|
|
|
int i, n;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Pdeletewindow = 0;
|
|
|
|
Ptakefocus = 0;
|
|
|
|
Ptakeactivity = 0;
|
|
|
|
Pcontexthelp = 0;
|
|
|
|
Pping = 0;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XGetWMProtocols(display(), window(), &p, &n)) {
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
if (p[i] == atoms->wm_delete_window)
|
2007-04-29 17:35:43 +00:00
|
|
|
Pdeletewindow = 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p[i] == atoms->wm_take_focus)
|
2007-04-29 17:35:43 +00:00
|
|
|
Ptakefocus = 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p[i] == atoms->net_wm_take_activity)
|
2007-04-29 17:35:43 +00:00
|
|
|
Ptakeactivity = 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p[i] == atoms->net_wm_context_help)
|
2007-04-29 17:35:43 +00:00
|
|
|
Pcontexthelp = 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p[i] == atoms->net_wm_ping)
|
2007-04-29 17:35:43 +00:00
|
|
|
Pping = 1;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (n > 0)
|
|
|
|
XFree(p);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::getSyncCounter()
|
2007-06-25 08:51:44 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_XSYNC
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!Extensions::syncAvailable())
|
2007-06-25 08:51:44 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Atom retType;
|
|
|
|
unsigned long nItemRet;
|
|
|
|
unsigned long byteRet;
|
|
|
|
int formatRet;
|
|
|
|
unsigned char* propRet;
|
2011-01-30 14:34:42 +00:00
|
|
|
int ret = XGetWindowProperty(display(), window(), atoms->net_wm_sync_request_counter,
|
|
|
|
0, 1, false, XA_CARDINAL, &retType, &formatRet, &nItemRet, &byteRet, &propRet);
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (ret == Success && formatRet == 32) {
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.counter = *(long*)(propRet);
|
|
|
|
XSyncIntToValue(&syncRequest.value, 0);
|
2008-12-18 13:50:57 +00:00
|
|
|
XSyncValue zero;
|
2011-01-30 14:34:42 +00:00
|
|
|
XSyncIntToValue(&zero, 0);
|
2011-08-13 14:39:58 +00:00
|
|
|
XSyncSetCounter(display(), syncRequest.counter, zero);
|
|
|
|
if (syncRequest.alarm == None) {
|
2007-06-25 08:51:44 +00:00
|
|
|
XSyncAlarmAttributes attrs;
|
2011-08-13 14:39:58 +00:00
|
|
|
attrs.trigger.counter = syncRequest.counter;
|
2007-06-25 08:51:44 +00:00
|
|
|
attrs.trigger.value_type = XSyncRelative;
|
|
|
|
attrs.trigger.test_type = XSyncPositiveTransition;
|
2011-01-30 14:34:42 +00:00
|
|
|
XSyncIntToValue(&attrs.trigger.wait_value, 1);
|
|
|
|
XSyncIntToValue(&attrs.delta, 1);
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.alarm = XSyncCreateAlarm(display(),
|
2011-01-30 14:34:42 +00:00
|
|
|
XSyncCACounter | XSyncCAValueType | XSyncCATestType | XSyncCADelta | XSyncCAValue,
|
|
|
|
&attrs);
|
2007-06-25 08:51:44 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-12 09:42:03 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (ret == Success)
|
|
|
|
XFree(propRet);
|
2007-06-25 08:51:44 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Send the client a _NET_SYNC_REQUEST
|
|
|
|
*/
|
2007-06-25 08:51:44 +00:00
|
|
|
void Client::sendSyncRequest()
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XSYNC
|
2011-08-13 14:39:58 +00:00
|
|
|
if (syncRequest.counter == None || syncRequest.isPending)
|
|
|
|
return; // do NOT, NEVER send a sync request when there's one on the stack. the clients will just stop respoding. FOREVER! ...
|
|
|
|
|
|
|
|
if (!syncRequest.failsafeTimeout) {
|
|
|
|
syncRequest.failsafeTimeout = new QTimer(this);
|
|
|
|
connect(syncRequest.failsafeTimeout, SIGNAL(timeout()), SLOT(removeSyncSupport()));
|
|
|
|
syncRequest.failsafeTimeout->setSingleShot(true);
|
|
|
|
}
|
|
|
|
// if there's no response within 10 seconds, sth. went wrong and we remove XSYNC support from this client.
|
|
|
|
// see events.cpp Client::syncEvent()
|
|
|
|
syncRequest.failsafeTimeout->start(ready_for_painting ? 10000 : 1000);
|
2007-06-25 08:51:44 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// We increment before the notify so that after the notify
|
2007-06-25 08:51:44 +00:00
|
|
|
// syncCounterSerial will equal the value we are expecting
|
|
|
|
// in the acknowledgement
|
|
|
|
int overflow;
|
|
|
|
XSyncValue one;
|
2011-01-30 14:34:42 +00:00
|
|
|
XSyncIntToValue(&one, 1);
|
2008-12-18 13:50:57 +00:00
|
|
|
#undef XSyncValueAdd // It causes a warning :-/
|
2011-08-13 14:39:58 +00:00
|
|
|
XSyncValueAdd(&syncRequest.value, syncRequest.value, one, &overflow);
|
2007-06-25 08:51:44 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Send the message to client
|
2007-06-25 08:51:44 +00:00
|
|
|
XEvent ev;
|
|
|
|
ev.xclient.type = ClientMessage;
|
|
|
|
ev.xclient.window = window();
|
|
|
|
ev.xclient.format = 32;
|
|
|
|
ev.xclient.message_type = atoms->wm_protocols;
|
2008-12-18 13:50:57 +00:00
|
|
|
ev.xclient.data.l[0] = atoms->net_wm_sync_request;
|
|
|
|
ev.xclient.data.l[1] = xTime();
|
2011-08-13 14:39:58 +00:00
|
|
|
ev.xclient.data.l[2] = XSyncValueLow32(syncRequest.value);
|
|
|
|
ev.xclient.data.l[3] = XSyncValueHigh32(syncRequest.value);
|
2008-12-18 13:50:57 +00:00
|
|
|
ev.xclient.data.l[4] = 0;
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.isPending = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
XSendEvent(display(), window(), False, NoEventMask, &ev);
|
|
|
|
XSync(display(), false);
|
2007-06-25 08:51:44 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-08-13 14:39:58 +00:00
|
|
|
void Client::removeSyncSupport()
|
|
|
|
{
|
|
|
|
if (!ready_for_painting) {
|
2012-01-24 16:00:40 +00:00
|
|
|
setReadyForPainting();
|
2011-08-13 14:39:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-02-26 08:42:17 +00:00
|
|
|
#ifdef HAVE_XSYNC
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.isPending = false;
|
|
|
|
syncRequest.counter = syncRequest.alarm = None;
|
|
|
|
delete syncRequest.timeout; delete syncRequest.failsafeTimeout;
|
|
|
|
syncRequest.timeout = syncRequest.failsafeTimeout = NULL;
|
2012-02-26 08:42:17 +00:00
|
|
|
#endif
|
2011-08-13 14:39:58 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool Client::wantsTabFocus() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return (isNormalWindow() || isDialog()) && wantsInput();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Client::wantsInput() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return rules()->checkAcceptFocus(input || Ptakefocus);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Client::isSpecialWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
// TODO
|
2011-06-24 10:19:47 +00:00
|
|
|
return isDesktop() || isDock() || isSplash() || isToolbar();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Sets an appropriate cursor shape for the logical mouse position \a m
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
2007-05-22 15:46:42 +00:00
|
|
|
void Client::updateCursor()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-05-22 15:46:42 +00:00
|
|
|
Position m = mode;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!isResizable() || isShade())
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionCenter;
|
2007-05-22 15:46:42 +00:00
|
|
|
QCursor c;
|
2011-01-30 14:34:42 +00:00
|
|
|
switch(m) {
|
|
|
|
case PositionTopLeft:
|
|
|
|
case PositionBottomRight:
|
|
|
|
c = Qt::SizeFDiagCursor;
|
|
|
|
break;
|
|
|
|
case PositionBottomLeft:
|
|
|
|
case PositionTopRight:
|
|
|
|
c = Qt::SizeBDiagCursor;
|
|
|
|
break;
|
|
|
|
case PositionTop:
|
|
|
|
case PositionBottom:
|
|
|
|
c = Qt::SizeVerCursor;
|
|
|
|
break;
|
|
|
|
case PositionLeft:
|
|
|
|
case PositionRight:
|
|
|
|
c = Qt::SizeHorCursor;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (moveResizeMode)
|
|
|
|
c = Qt::SizeAllCursor;
|
|
|
|
else
|
|
|
|
c = Qt::ArrowCursor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (c.handle() == cursor.handle())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
cursor = c;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (decoration != NULL)
|
|
|
|
decoration->widget()->setCursor(cursor);
|
|
|
|
XDefineCursor(display(), frameId(), cursor.handle());
|
2011-11-09 19:39:13 +00:00
|
|
|
if (inputId())
|
|
|
|
XDefineCursor(display(), inputId(), cursor.handle());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (moveResizeMode) // XDefineCursor doesn't change cursor if there's pointer grab active
|
|
|
|
XChangeActivePointerGrab(display(),
|
|
|
|
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask,
|
|
|
|
cursor.handle(), xTime());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-03-20 14:42:05 +00:00
|
|
|
void Client::updateCompositeBlocking(bool readProperty)
|
|
|
|
{
|
|
|
|
if (readProperty) {
|
|
|
|
const unsigned long properties[2] = {0, NET::WM2BlockCompositing};
|
|
|
|
NETWinInfo2 i(QX11Info::display(), window(), rootWindow(), properties, 2);
|
2012-03-31 17:09:00 +00:00
|
|
|
setBlockingCompositing(i.isBlockingCompositing());
|
2011-03-20 14:42:05 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-31 17:09:00 +00:00
|
|
|
setBlockingCompositing(blocks_compositing);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::setBlockingCompositing(bool block)
|
|
|
|
{
|
|
|
|
const bool usedToBlock = blocks_compositing;
|
|
|
|
blocks_compositing = rules()->checkBlockCompositing(block);
|
2012-08-23 11:42:59 +00:00
|
|
|
if (usedToBlock != blocks_compositing) {
|
|
|
|
emit blockingCompositingChanged(blocks_compositing ? this : 0);
|
2012-03-31 17:09:00 +00:00
|
|
|
}
|
2011-03-20 14:42:05 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Client::Position Client::mousePosition(const QPoint& p) const
|
|
|
|
{
|
|
|
|
if (decoration != NULL)
|
|
|
|
return decoration->mousePosition(p);
|
2007-04-29 17:35:43 +00:00
|
|
|
return PositionCenter;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::updateAllowedActions(bool force)
|
|
|
|
{
|
|
|
|
if (!isManaged() && !force)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
unsigned long old_allowed_actions = allowed_actions;
|
|
|
|
allowed_actions = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMovable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionMove;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isResizable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionResize;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMinimizable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionMinimize;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShadeable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionShade;
|
2008-12-18 13:50:57 +00:00
|
|
|
// Sticky state not supported
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMaximizable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionMax;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (userCanSetFullScreen())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionFullScreen;
|
2008-12-18 13:50:57 +00:00
|
|
|
allowed_actions |= NET::ActionChangeDesktop; // Always (Pagers shouldn't show Docks etc.)
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isCloseable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionClose;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old_allowed_actions == allowed_actions)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: This could be delayed and compressed - It's only for pagers etc. anyway
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setAllowedActions(allowed_actions);
|
2011-04-23 15:17:25 +00:00
|
|
|
|
|
|
|
// ONLY if relevant features have changed (and the window didn't just get/loose moveresize for maximization state changes)
|
|
|
|
const unsigned long relevant = ~(NET::ActionMove|NET::ActionResize);
|
|
|
|
if (decoration && (allowed_actions & relevant) != (old_allowed_actions & relevant))
|
2011-02-06 15:42:45 +00:00
|
|
|
decoration->reset(KDecoration::SettingButtons);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Client::autoRaise()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
workspace()->raiseClient(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
cancelAutoRaise();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void Client::cancelAutoRaise()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete autoRaiseTimer;
|
|
|
|
autoRaiseTimer = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::debug(QDebug& stream) const
|
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":"
|
|
|
|
<< resourceName() << ";Caption:" << caption() << "\'";
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
QPixmap* kwin_get_menu_pix_hack()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
static QPixmap p;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (p.isNull())
|
|
|
|
p = SmallIcon("bx2");
|
2007-04-29 17:35:43 +00:00
|
|
|
return &p;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-09-24 12:03:22 +00:00
|
|
|
void Client::checkActivities()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-09-24 12:03:22 +00:00
|
|
|
QStringList newActivitiesList;
|
|
|
|
QByteArray prop = getStringProperty(window(), atoms->activities);
|
2010-12-16 20:14:22 +00:00
|
|
|
activitiesDefined = !prop.isEmpty();
|
|
|
|
if (prop == "ALL") {
|
|
|
|
//copied from setOnAllActivities to avoid a redundant XChangeProperty.
|
|
|
|
if (!activityList.isEmpty()) {
|
|
|
|
activityList.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
updateActivities(true);
|
2010-12-16 20:14:22 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (prop.isEmpty()) {
|
|
|
|
//note: this makes it *act* like it's on all activities but doesn't set the property to 'ALL'
|
|
|
|
if (!activityList.isEmpty()) {
|
|
|
|
activityList.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
updateActivities(true);
|
2010-12-16 20:14:22 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2010-09-24 12:03:22 +00:00
|
|
|
|
2010-12-16 20:14:22 +00:00
|
|
|
newActivitiesList = QString(prop).split(',');
|
2010-09-24 12:03:22 +00:00
|
|
|
if (newActivitiesList == activityList)
|
|
|
|
return; //expected change, it's ok.
|
|
|
|
|
|
|
|
//otherwise, somebody else changed it. we need to validate before reacting
|
|
|
|
QStringList allActivities = workspace()->activityList();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (allActivities.isEmpty()) {
|
2010-09-24 12:03:22 +00:00
|
|
|
kDebug() << "no activities!?!?";
|
|
|
|
//don't touch anything, there's probably something bad going on and we don't wanna make it worse
|
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < newActivitiesList.size(); ++i) {
|
|
|
|
if (! allActivities.contains(newActivitiesList.at(i))) {
|
2010-09-24 12:03:22 +00:00
|
|
|
kDebug() << "invalid:" << newActivitiesList.at(i);
|
2011-01-30 14:34:42 +00:00
|
|
|
newActivitiesList.removeAt(i--);
|
2010-09-24 12:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
setOnActivities(newActivitiesList);
|
|
|
|
}
|
2010-09-24 12:03:22 +00:00
|
|
|
|
2010-12-16 20:14:22 +00:00
|
|
|
void Client::setSessionInteract(bool needed)
|
|
|
|
{
|
|
|
|
needsSessionInteract = needed;
|
|
|
|
}
|
|
|
|
|
2011-04-10 19:24:27 +00:00
|
|
|
QRect Client::decorationRect() const
|
|
|
|
{
|
|
|
|
if (decoration && decoration->widget()) {
|
2012-03-10 10:34:56 +00:00
|
|
|
return decoration->widget()->rect().translated(-padding_left, -padding_top);
|
2011-04-10 19:24:27 +00:00
|
|
|
} else {
|
|
|
|
return QRect(0, 0, width(), height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-01 12:15:11 +00:00
|
|
|
void Client::updateFirstInTabBox()
|
|
|
|
{
|
|
|
|
// TODO: move into KWindowInfo
|
|
|
|
Atom type;
|
|
|
|
int format, status;
|
|
|
|
unsigned long nitems = 0;
|
|
|
|
unsigned long extra = 0;
|
|
|
|
unsigned char *data = 0;
|
|
|
|
status = XGetWindowProperty(display(), window(), atoms->kde_first_in_window_list, 0, 1, false, atoms->kde_first_in_window_list, &type, &format, &nitems, &extra, &data);
|
|
|
|
if (status == Success && format == 32 && nitems == 1) {
|
|
|
|
setFirstInTabBox(true);
|
|
|
|
} else {
|
|
|
|
setFirstInTabBox(false);
|
|
|
|
}
|
|
|
|
if (data)
|
|
|
|
XFree(data);
|
|
|
|
}
|
|
|
|
|
2012-01-15 09:51:09 +00:00
|
|
|
bool Client::isClient() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-09 12:44:50 +00:00
|
|
|
#ifdef KWIN_BUILD_KAPPMENU
|
|
|
|
void Client::setAppMenuAvailable()
|
|
|
|
{
|
|
|
|
m_menuAvailable = true;
|
|
|
|
emit appMenuAvailable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::setAppMenuUnavailable()
|
|
|
|
{
|
|
|
|
m_menuAvailable = false;
|
|
|
|
emit appMenuUnavailable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::showApplicationMenu(const QPoint &p)
|
|
|
|
{
|
|
|
|
workspace()->showApplicationMenu(p, window());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-06 07:09:31 +00:00
|
|
|
NET::WindowType Client::windowType(bool direct, int supportedTypes) const
|
|
|
|
{
|
|
|
|
// TODO: does it make sense to cache the returned window type for SUPPORTED_MANAGED_WINDOW_TYPES_MASK?
|
|
|
|
if (supportedTypes == 0) {
|
|
|
|
supportedTypes = SUPPORTED_MANAGED_WINDOW_TYPES_MASK;
|
|
|
|
}
|
|
|
|
NET::WindowType wt = info->windowType(supportedTypes);
|
|
|
|
if (direct) {
|
|
|
|
return wt;
|
|
|
|
}
|
|
|
|
NET::WindowType wt2 = client_rules.checkType(wt);
|
|
|
|
if (wt != wt2) {
|
|
|
|
wt = wt2;
|
|
|
|
info->setWindowType(wt); // force hint change
|
|
|
|
}
|
|
|
|
// hacks here
|
|
|
|
if (wt == NET::Unknown) // this is more or less suggested in NETWM spec
|
|
|
|
wt = isTransient() ? NET::Dialog : NET::Normal;
|
|
|
|
return wt;
|
|
|
|
}
|
|
|
|
|
2012-10-12 09:34:05 +00:00
|
|
|
bool Client::decorationHasAlpha() const
|
|
|
|
{
|
|
|
|
if (!decoration || !workspace()->decorationHasAlpha()) {
|
|
|
|
// either no decoration or decoration has alpha disabled
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (workspace()->decorationSupportsAnnounceAlpha()) {
|
|
|
|
return decoration->isAlphaEnabled();
|
|
|
|
} else {
|
|
|
|
// decoration has alpha enabled and does not support alpha announcement
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "client.moc"
|