Commit Graph

918 Commits (26cf3195bea8ed92a00c4cbb9bf08537b400ac2d)

Author SHA1 Message Date
Martin Gräßlin 0f7a990316 Use Protocol support in NETWinInfo instead of fetching them ourselves
Client does no longer need to track the protocols as this is also
provided by NETWinInfo as of version 5.3.

REVIEW: 120255
2014-11-24 10:37:18 +01:00
Volker Krause 5db2d5a556 Make constants const, saves a few symbols in the .data section. 2014-09-27 20:30:49 +02:00
Martin Gräßlin 9fae34f86f Remove Client::getWMHints in favor of functionality in NETWinInfo
We are only using the UrgencyHint, InputHint and GroupLeader from
WMHints. Those are provided by NETWinInfo, so we can use the
functionality provided by NETWinInfo instead of calling XGetWMHints.

REVIEW: 120162
2014-09-15 16:29:47 +02:00
Martin Gräßlin f0e1e3187e Add a script to enforce window decorations for GTK windows
This is going to be a controversal change. It enforces KWin decorations
on all client side decorated windows from GTK+. Unfortunately we are
caught between a rock and a hard place. Keeping the status quo means
having broken windows and a more or less broken window manager due to
GTK+ including the shadow in the windows. This is no solution.
Enforcing server side decorations visually breaks the windows. This is
also no solution. So why do it?

It's our task to provide the best possible user experience and KWin is
a window manager which has always done great efforts to fix misbehaving
windows. One can think of the focus stealing prevention, the window rules
and lately the scripts. The best possible window management experience is
our aim. This means we cannot leave the users with the broken windows
from GTK.

The issues we noticed were reported to GTK+ about 2 months ago and we are
working on improving the situation. Unfortunately several issues are not
yet addressed and others will only be addressed in the next GTK+ release.
We are working on improving the NETWM spec (see [1]) to ensure that the
client side decorated windows are not in a broken state. This means the
enforcment is a temporary solution and will be re-evaluated with the next
GTK release. I would prefer to not have to do such a change, if some of
the bugs were fixed or GTK+ would not use client-side-decos on wms not
yet supporting those all of this would be a no issue.

For a complete list of the problems caused by GTK's decos see bug [2] and
the linked bug reports from there.

The change is done in a least inversive way in KWin. We just check for
the property _GTK_FRAME_EXTENTS and create a Q_PROPERTY in Client for it.
If we add support for the frame extents in future we would also need
this. So it's not a change just for enforcing the decoration.

The actual enforcing is done through a KWin script so users can still
disable it.

REVIEW: 119062

[1] https://mail.gnome.org/archives/wm-spec-list/2014-June/msg00002.html
[2] https://bugzilla.gnome.org/show_bug.cgi?id=729721
2014-07-03 16:03:22 +02:00
Martin Gräßlin 76b05f241b Only reparent qwidget based deco to a QWindow wrapper
This partially reverts 8543033d59 which
caused major issues with QWindow based decorations.

BUG: 335762
2014-06-04 09:09:37 +02:00
Martin Gräßlin 8543033d59 Reparent decoration window by using a QWindow wrapper for the frame
Qt doesn't like that we reparent the decoration using low level xcb
calls. So let's use a QWindow wrapper for the frame and let Qt do
the reparenting itself.

BUG: 334768
REVIEW: 118159
2014-06-03 09:22:18 +02:00
Martin Gräßlin 25e221ae00 Fix invocation of kwin_killer_helper
Path needs to be hard coded as it's in libexec.

REVIEW: 117999
2014-05-13 09:20:10 +02:00
Martin Gräßlin d2bbb42feb Install event filter for QWindow based decorations
Also with QWindow based decorations the event filter is needed to
properly react on mouse button release and mouse move. Those are not
passed through KDecoration unlike the button press.

The event filter is adjusted to handle both filters installed on QWidget
and QWindow while QWindow only gets to see a subset of the events.

This fixes mouse interaction in Aurorae.

REVIEW: 117879
2014-05-05 08:12:00 +02:00
Martin Gräßlin 0643bafd2b Use Client::sendClientMessage from Client::sendSyncRequest
Less code duplication and port to XCB.

REVIEW: 117768
2014-05-05 08:09:17 +02:00
Martin Gräßlin 068ee6d39c Use uint32_t instead of long in Client::sendClientMessage 2014-05-05 08:09:10 +02:00
Martin Gräßlin 0ac4e4e419 Port reading net_wm_sync_request_counter to XCB
Using the new Xcb::Property wrapper.
2014-05-05 08:09:10 +02:00
Martin Gräßlin 7d302b9039 Keep timestamp of last syncRequest and update with xTime on each sync
The sync protocol with e.g. Qt 4 windows is broken if our app time is
older than the one of the last sync alarm event. Thus we keep a timestamp
in the syncRequest struct of the last sent sync request. If the timestamp
is newer than our xTime when sending the next request, we update the
xTime to ensure that we have a new timestamp again.

BUG: 333512
REVIEW: 117734
2014-04-28 07:45:53 +02:00
Martin Gräßlin b45eeae352 [Xcb::Wrapper] Introduce a Property and StringProperty Wrapper subclass
The Xcb::Property can wrap the xcb_get_property call and provides
convenient access methods to read the value of the reply with checks
applied. For this it provides a templated ::value method for reading a
single value or reading an array. There's also a ::toBool and
::toByteArray which performs the conversion directly with default values
for the type and format checks.

Xcb::TransientFor is changed to be derived from Property instead of
Wrapper directly, so that the reading of the property value can be
shared.

Xcb::StringProperty is a convenient wrapper derived from Property to
handle the reading of a string property providing a cast to QByteArray
operator. This replaces the ::getStringProperty from utils. Though the
separator functionality from ::getStringProperty is not provided as that
is only used in one function and handled there.

All the custom usages of xcb_get_property or getStringProperty are
replaced to use this new wrapper. That simplifies the code and ensures
that all properties are read in the same way.

REVIEW: 117574
2014-04-17 07:41:33 +02:00
Martin Gräßlin 93e5ebac63 Try to wait for DESTROY_NOTIFY before releasing an Unmanaged
So far the Unmanaged got released after an XCB_UNMAP_NOTIFY. This event
gets created after xcb_unmap_window or after xcb_destroy_window. In the
latter case the window is already distroyed and any of KWin's cleanup
calls will cause a BadWindow (or similar) error.

The idea to circumvent these errors is to try to wait for the
DESTROY_NOTIFY event. To do so the processing of the release is slightly
delayed. If KWin gets the destroy notify before the delay times out the
Unamanged gets released immediately but with a Destroy flag. For this a
new enum ReleaseToplevel is introduced and Unmanage::release takes this
as an argument instead of the bool which indicated OnShutdown. Also this
enum is added to Toplevel::finishCompositing so that it can ignore the
destroyed case and not generate an error.

REVIEW: 117422
2014-04-16 13:32:11 +02:00
Martin Gräßlin fd0fd82ad6 Use NETWM to get updates on blocking compositing
Adds NET::WM2BlockCompositing to the Client's properties which allows to
read the state from the NETWinInfo object and get updates without having
to resolve the atom ourselve.

REVIEW: 117561
2014-04-14 15:34:39 +02:00
Martin Gräßlin c390a94261 Use new connect syntax in client.cpp
Excluded are the signals to Appmenu as that's currently excluded from
build.

Private slots with only one connection are turned into lambdas.

REVIEW: 117355
2014-04-04 12:10:56 +02:00
Martin Gräßlin bc0a9cb53a [kwin] Use std::find_if and lambda functions for Workspace::findClient
Instead of passing the macro based Predicate to findClient it now
expects a function which can be passed to std::find_if.

Existing code like:
xcb_window_t window; // our test window
Client *c = findClient(WindowMatchPredicated(window));

becomes:
Client *c = findClient([window](const Client *c) {
    return c->window() == window;
});

The advantage is that it is way more flexible and has the logic what
to check for directly with the code and not hidden in the macro
definition.

In addition there is a simplified overload for the very common case of
matching a window id against one of Client's windows. This overloaded
method takes a Predicate and the window id.

Above example becomes:
Client *c = findClient(Predicate::WindowMatch, w);

Existing code is migrated to use the simplified method taking
MatchPredicate and window id. The very few cases where a more complex
condition is tested the lambda function is used. As these are very
local tests only used in one function it's not worthwhile to add further
overloads to the findClient method in Workspace.

With this change all the Predicate macro definitions are removed from
utils.h as they are now completely unused.

REVIEW: 116916
2014-03-25 15:17:11 +01:00
Martin Gräßlin 970e8765f0 [kwin] Remove support for _NET_WM_TAKE_ACTIVITY protocol
As can be seen in [1] the patches to KWin were in CVS HEAD before the
protocol got standardized and it never got any adoption. It's neither in
the NETWM spec, nor implemented in Qt4 nor in Qt5. KWin did not even add
the protocol to the NET::Supported property.

Thus it doesn't make much sense to keep a protocol which nobody speaks.

Still the code around the protocol is kept and also the names are kept.
Only difference is that Client::takeActivity got removed and the code
moved to the only calling place in Workspace. Motivated by that change
the enum defined in utils.h is moved into Workspace, it's turned into
a proper QFlags class and used as a type in the method argument instead
of a generic long.

[1] https://mail.gnome.org/archives/wm-spec-list/2004-April/msg00013.html

REVIEW: 116922
2014-03-25 15:03:21 +01:00
Martin Gräßlin 1bc624f9f7 [kwin] Move Client specific code from utils.h to client.(h|cpp)
* Motif to client.cpp
* ClientWinMask to client.cpp
* ForceGeometry_t to Client

REVIEW: 116901
2014-03-19 18:54:00 +01:00
Martin Gräßlin 6baf794f88 InputRedirection for keyboard events
Major new functionality is xkbcommon support. InputRedirection holds an
instance to a small wrapper class which has the xkb context, keymap and
state. The keymap is initialied from the file descriptor we get from the
Wayland backend.

InputRedirection uses this to translate the keycodes into keysymbols and
to QString and to track the modifiers as provided by the
Qt::KeybordModifiers flags.

This provides us enough information for internal usage (e.g. pass through
effects if they have "grabbed" the keyboard).

If KWin doesn't filter out the key events, it passes them on to the
currently active Client respectively an unmanaged on top of the stack.
This needs still some improvement (not each unmanaged should get the
event). The Client/Unmnaged still uses xtest extension to send the key
events to the window. So keylogging is still possible.
2014-03-18 09:00:50 +01:00
Martin Gräßlin 7d48b92e2b Redirect pointer events to the Toplevel
InputRedirection keeps track of the Toplevel which is currently the one
which should get pointer events. This is determined by checking whether
there is an Unmanaged or a Client at the pointer position. At the moment
this is still slightly incorrect, e.g. pointer grabs are ignored,
unmanaged are not checked whether they are output only and input shapes
are not yet tracked.

The pointer events are delivered to the Toplevel as:
* enter
* leave
* move
* button press
* axis event

Nevertheless move events are still generated in InputRedirection through
xcb test for simplicity. They are still send to the root window, so all
windows get mouse move.

Button press and axis are generated only in the implementations of the
event handlers and delivered directly to the window, so other windows
won't see it.
2014-03-18 09:00:50 +01:00
Aleix Pol c72e519d9c Remove KDE/ prefix in include directories
It's unneeded and deprecated since KF5.
2014-03-17 16:24:10 +01:00
Martin Gräßlin b0c0e81661 Adjust kde-workspace to changes in NETWMClient
ctor changed to take NET::Properties and NET::Properties2.
2014-03-17 08:13:14 +01:00
Martin Gräßlin aee20b4a5a Hide the OnAllDesktops button if there is only one virtual desktop
In KCommonDecoration the OnAllDesktops button gets hidden or shown
depending on the number of desktops. For that KDecoration is extended
by a new property which delegates to the bridge to return whether
onAllDesktops is available. In KWin Core this is implemented using
the number of desktops.

FEATURE: 321611
FIXED-IN: 5.0.0
REVIEW: 116076
2014-03-05 13:02:32 +01:00
Martin Gräßlin 4dff7888e3 [kwin] Drop build option to build without scripting
Scripting has proved it's point of being useful so it's time to turn it
into a mandatory part of KWin.

Also I start to use features provided by Scripting in more and more
parts of KWin core (e.g. sharing QQmlEngine) which makes it in the
long to complicated to have a build option and ifdefs for it.

REVIEW: 116587
2014-03-04 08:19:55 +01:00
Martin Gräßlin ed4a0d0319 Screenedge show support for Clients
This provides a new protocol intended to be used by auto-hiding panels
to make use of the centralized screen edges. To use it a Client can
set an X11 property of type _KDE_NET_WM_SCREEN_EDGE_SHOW to KWin.
As value it takes:
* 0: top edge
* 1: right edge
* 2: bottom edge
* 3: left edge

KWin will hide the Client (hide because unmap or minimize would break
it) and create an Edge. If that Edge gets triggered the Client is shown
again and the property gets deleted. If the Client doesn't border the
specified screen edge the Client gets shown immediately so that we
never end in a situation that we cannot unhide the auto-hidden panel
again. The exact process is described in the documentation of
ScreenEdges. The Client can request to be shown again by deleting the
property.

If KWin gets restarted the state is read from the property and it is
tried to create the edge as described.

As this is a KWin specific extension we need to discuss what it means
for Clients using this feature with other WMs: it does nothing. As
the Client gets hidden by KWin and not by the Client, it just doesn't
get hidden if the WM doesn't provide the feature. In case of an
auto-hiding panel this seems like a good solution given that we don't
want to hide it if we cannot unhide it. Of course there's the option
for the Client to provide that feature itself and if that's wanted we
would need to announce the feature in the _NET_SUPPORTED atom. At the
moment that doesn't sound like being needed as Plasma doesn't want to
provide an own implementation.

The implementation comes with a small test application showing how
the feature is intended to be used.

REVIEW: 115910
2014-02-26 12:54:00 +01:00
Martin Klapetek 70fd9d6b58 [kwin] Client of type NET::Notification should have no borders
Reviewed-by: Martin Gräßlin
2014-02-12 10:53:33 +01:00
Martin Gräßlin fdee4ea8c8 Adjust kde-workspace to introduction of flags in NET classes 2014-02-05 17:40:19 +01:00
Thomas Lübking 66375ad741 Merge branch 'KDE/4.11'
Conflicts:
	kwin/effects/mouseclick/mouseclick.cpp
	plasma/generic/scriptengines/python/plasma-scriptengine-dataengine-python.desktop
	plasma/generic/scriptengines/python/plasma-scriptengine-runner-python.desktop
	plasma/generic/scriptengines/ruby/plasma-scriptengine-ruby-applet.desktop
	plasma/generic/scriptengines/ruby/plasma-scriptengine-ruby-dataengine.desktop
2014-01-30 20:55:35 +01:00
Thomas Lübking 62b277ad9f depend noborder on motif_noborder after reshape
app_noborder shall be the determined noborder (shape, type)
but relevant noborder shall be determined by rules and respect the
motif hint

BUG: 330573
FIXED-IN: 4.11.6
REVIEW: 115402
2014-01-30 20:25:09 +01:00
Thomas Lübking 4bb88df714 Merge branch 'KDE/4.11' 2014-01-14 22:51:24 +01:00
Thomas Lübking c378bf4f7c emit desktopPresenceChanged from Client:setDesktop
and forward it to scripted effects

CCBUG: 326903
REVIEW: 114080
2014-01-14 22:23:49 +01:00
Martin Gräßlin 2372e02752 [kwin] Use a QIcon in Client for the icons instead of Pixmaps
Client used to have dedicated methods for different icon sizes instead
of combining all pixmaps into one QIcon. This resulted in various parts
of KWin having different access to the icons:
* effects only got one pixmap of size 32x32
* decorations only got the 16x16 and 32x32 pixmaps combined into a QIcon
* tabbox could request all icon sizes, but only as pixmap

Now all sizes are available in one QIcon allowing to easily access the
best fitting icon in a given UI.
2013-12-06 14:41:23 +01:00
Martin Gräßlin 7aeec8ef89 [kwin] Drop dead code
kwin_get_menu_pix_hack was no longer used anywhere.
2013-12-06 11:21:07 +01:00
Martin Gräßlin 49cf996aa7 [kwin] Window specific rule for decoration color scheme
Adds a new force rule to specify the color scheme to use on the window
decoration. The scheme is stored by the name of the .colors file name.
So for Oxygen.colors the value is Oxygen.

When loaded the scheme is located and the full path to the colors file
is used. This is because the X property also uses the full path.
2013-11-25 09:44:23 +01:00
Martin Gräßlin 302271ce97 [kwin] Client supports an X property for color scheme
The X property _KDE_NET_WM_COLOR_SCHEME can be set on a window and
specifies the absolute path to a .color file describing the color
scheme of the managed client.

The Client reads this property and creates a QPalette from it. If
the property is not set or the value is incorrect, the Client uses
KWin's default palette.

The idea behind this property is to allow an application with a
custom color scheme to tell KWin which color scheme the window
decoration should use. So that the window looks as a solid pattern
again.
2013-11-25 09:41:24 +01:00
Martin Gräßlin ba66fd9ef6 [kwin] NETWinInfo2 becomes NETWinInfo
And takes a xcb_connection_t instead of Display. Also our own class
is adjusted to no longer need the connection being passed in.
2013-11-18 13:56:28 +01:00
Martin Gräßlin 2c9e21a983 [kwin] Use XCB Atom enum definition instead of XLib's one 2013-11-18 13:48:31 +01:00
Martin Gräßlin 695697ebbd [decorations] Allow Client to use QWindow based decorations
Shared implementation using the delegating methods in KDecoration
which uses either QWindow or QWidget where possible.
2013-11-14 09:41:51 +01:00
Martin Gräßlin 8ecb69cd8c [decorations] Add a KDecoration::window() returning the QWindow
KWin core can access the QWindow of the decoration instead of the
QWidget. This is a preparation step to allow QWidget based window
decorations without any QWidgets at all.

KWin core makes already use of this new accessor to get the window Id
which is also on QWidgets provided through the QWindow.
2013-11-14 09:41:50 +01:00
Martin Gräßlin 1deea69170 [paintredirector] Pass KDecoration to PaintRedirector
Gives us more power in the future.
2013-11-14 09:41:50 +01:00
Martin Gräßlin c32ec9b32b [kwin] Work around broken xcb_sync_create_alarm
The xcb sync protocol is incorrectly defined (see [1]) which results in
xcb_sync_create_alarm not creating a valid alarm. To work around this
issue we only create the alarm without setting the int64 values. For
those we use the XLib XSyncChangeAlarm call after we verified that the
alarm got created. This unfortunately reintroduces linking against
libxext. But at least resizing works again.

[1] http://lists.freedesktop.org/archives/xcb/2013-June/008375.html
2013-11-11 11:36:26 +01:00
Bhushan Shah 935851a2b5 kDebug -> qDebug in kwin 2013-11-01 17:00:41 +05:30
Thomas Lübking 3594550b14 Merge branch 'KDE/4.11'
Conflicts:
	kwin/eglonxbackend.cpp
	kwin/glxbackend.cpp
2013-09-25 23:21:36 +02:00
Thomas Lübking 06b482f725 pack to client, not deco
this makes packing following the snapping behavior

REVIEW: 112807
2013-09-25 23:09:08 +02:00
Martin Gräßlin 969e6b85e7 Merge branch 'master' into frameworks-scratch
Conflicts:
	CMakeLists.txt
	kwin/client.cpp
	kwin/effects/highlightwindow/highlightwindow.cpp
	kwin/libkwineffects/kwingltexture.cpp
	kwin/libkwineffects/kwinxrenderutils.cpp
	kwin/scene_opengl.cpp
	kwin/workspace.cpp
	plasma/desktop/applets/kickoff/CMakeLists.txt
	plasma/desktop/applets/taskmanager/package/contents/code/tools.js
	plasma/desktop/applets/taskmanager/package/contents/ui/Task.qml
	plasma/desktop/applets/taskmanager/package/contents/ui/main.qml
	plasma/desktop/applets/taskmanager/package/metadata.desktop
	plasma/desktop/applets/taskmanager/plugin/textlabel.h
	plasma/desktop/applets/tasks/CMakeLists.txt
	plasma/desktop/applets/tasks/package/metadata.desktop
	plasma/desktop/applets/tasks/tasks.cpp
	plasma/desktop/toolboxes/plasma-toolbox-desktoptoolbox.desktop
	plasma/generic/applets/activitybar/activitybar.cpp
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
2013-09-24 11:28:38 +02:00
Thomas Lübking 66ffd9f0f6 input window: ensure input shaping is supported
BUG: 320459
FIXED-IN: 4.11.2
REVIEW: 112623
2013-09-24 00:50:54 +02:00
Martin Gräßlin e553d2869d Move the decoration window back to the padding position after each resize
Behavior seems to have changed in Qt 5. Without doing the move the deco
has a wrong position and all mouse interaction is broken after the first
resize.

And with this change Oxygen windeco in compositing is fully functional!
2013-09-13 13:56:09 +02:00
Martin Gräßlin 7aadeaa310 Add maximized property and changed signal to KDecoration
Replaces the pure virtual method which the Decoration had to
implement. Instead the Decoration can now connect to the signal.

For KCommonDecoration there is no change at all except that the
invoked method is turned into a slot.

The property is of type bool and maps to isMaximized and not to
maximizeMode.
2013-09-12 09:27:39 +02:00
Martin Gräßlin 22e4476777 Add icon property and changed signal to KDecoration
Replaces the pure virtual method which the Decoration had to
implement. Instead the Decoration can now connect to the signal.

For KCommonDecoration there is no change at all except that the
invoked method is turned into a slot.
2013-09-12 09:27:39 +02:00