Changeset View
Changeset View
Standalone View
Standalone View
scene.cpp
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> | 5 | Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> | ||
6 | Copyright (C) 2019 Vlad Zahorodnii <vladzzag@gmail.com> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 716 Lines • ▼ Show 20 Line(s) | |||||
730 | { | 731 | { | ||
731 | if (m_bufferShapeIsValid) { | 732 | if (m_bufferShapeIsValid) { | ||
732 | return m_bufferShape; | 733 | return m_bufferShape; | ||
733 | } | 734 | } | ||
734 | 735 | | |||
735 | const QRect bufferGeometry = toplevel->bufferGeometry(); | 736 | const QRect bufferGeometry = toplevel->bufferGeometry(); | ||
736 | 737 | | |||
737 | if (toplevel->shape()) { | 738 | if (toplevel->shape()) { | ||
738 | auto cookie = xcb_shape_get_rectangles_unchecked(connection(), toplevel->frameId(), XCB_SHAPE_SK_BOUNDING); | 739 | auto cookie = xcb_shape_get_rectangles_unchecked(connection(), toplevel->windowId(), XCB_SHAPE_SK_BOUNDING); | ||
739 | ScopedCPointer<xcb_shape_get_rectangles_reply_t> reply(xcb_shape_get_rectangles_reply(connection(), cookie, nullptr)); | 740 | ScopedCPointer<xcb_shape_get_rectangles_reply_t> reply(xcb_shape_get_rectangles_reply(connection(), cookie, nullptr)); | ||
740 | if (!reply.isNull()) { | 741 | if (!reply.isNull()) { | ||
741 | m_bufferShape = QRegion(); | 742 | m_bufferShape = QRegion(); | ||
742 | const xcb_rectangle_t *rects = xcb_shape_get_rectangles_rectangles(reply.data()); | 743 | const xcb_rectangle_t *rects = xcb_shape_get_rectangles_rectangles(reply.data()); | ||
743 | const int rectCount = xcb_shape_get_rectangles_rectangles_length(reply.data()); | 744 | const int rectCount = xcb_shape_get_rectangles_rectangles_length(reply.data()); | ||
744 | for (int i = 0; i < rectCount; ++i) { | 745 | for (int i = 0; i < rectCount; ++i) { | ||
745 | m_bufferShape += QRegion(rects[i].x, rects[i].y, rects[i].width, rects[i].height); | 746 | m_bufferShape += QRegion(rects[i].x, rects[i].y, rects[i].width, rects[i].height); | ||
746 | } | 747 | } | ||
Show All 13 Lines | |||||
760 | 761 | | |||
761 | QRegion Scene::Window::clientShape() const | 762 | QRegion Scene::Window::clientShape() const | ||
762 | { | 763 | { | ||
763 | if (AbstractClient *client = qobject_cast<AbstractClient *>(toplevel)) { | 764 | if (AbstractClient *client = qobject_cast<AbstractClient *>(toplevel)) { | ||
764 | if (client->isShade()) { | 765 | if (client->isShade()) { | ||
765 | return QRegion(); | 766 | return QRegion(); | ||
766 | } | 767 | } | ||
767 | } | 768 | } | ||
768 | 769 | return bufferShape(); | |||
769 | const QRegion shape = bufferShape(); | | |||
770 | const QMargins bufferMargins = toplevel->bufferMargins(); | | |||
771 | if (bufferMargins.isNull()) { | | |||
772 | return shape; | | |||
773 | } | | |||
774 | | ||||
775 | const QRect clippingRect = QRect(QPoint(0, 0), toplevel->bufferGeometry().size()) - toplevel->bufferMargins(); | | |||
776 | return shape & clippingRect; | | |||
777 | } | 770 | } | ||
778 | 771 | | |||
779 | QRegion Scene::Window::decorationShape() const | 772 | QRegion Scene::Window::decorationShape() const | ||
780 | { | 773 | { | ||
781 | return QRegion(toplevel->decorationRect()) - toplevel->transparentRect(); | 774 | return QRegion(toplevel->decorationRect()) - toplevel->transparentRect(); | ||
782 | } | 775 | } | ||
783 | 776 | | |||
784 | QPoint Scene::Window::bufferOffset() const | 777 | QPoint Scene::Window::bufferOffset() const | ||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Line(s) | 1025 | if (kwinApp()->shouldUseWaylandForCompositing()) { | |||
1034 | updateBuffer(); | 1027 | updateBuffer(); | ||
1035 | if ((m_buffer || !m_fbo.isNull()) && m_subSurface.isNull()) { | 1028 | if ((m_buffer || !m_fbo.isNull()) && m_subSurface.isNull()) { | ||
1036 | m_window->unreferencePreviousPixmap(); | 1029 | m_window->unreferencePreviousPixmap(); | ||
1037 | } | 1030 | } | ||
1038 | return; | 1031 | return; | ||
1039 | } | 1032 | } | ||
1040 | XServerGrabber grabber; | 1033 | XServerGrabber grabber; | ||
1041 | xcb_pixmap_t pix = xcb_generate_id(connection()); | 1034 | xcb_pixmap_t pix = xcb_generate_id(connection()); | ||
1042 | xcb_void_cookie_t namePixmapCookie = xcb_composite_name_window_pixmap_checked(connection(), toplevel()->frameId(), pix); | 1035 | xcb_void_cookie_t namePixmapCookie = xcb_composite_name_window_pixmap_checked(connection(), toplevel()->windowId(), pix); | ||
1043 | Xcb::WindowAttributes windowAttributes(toplevel()->frameId()); | 1036 | Xcb::WindowAttributes windowAttributes(toplevel()->windowId()); | ||
1044 | Xcb::WindowGeometry windowGeometry(toplevel()->frameId()); | 1037 | Xcb::WindowGeometry windowGeometry(toplevel()->windowId()); | ||
1045 | if (xcb_generic_error_t *error = xcb_request_check(connection(), namePixmapCookie)) { | 1038 | if (xcb_generic_error_t *error = xcb_request_check(connection(), namePixmapCookie)) { | ||
1046 | qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << error->error_code; | 1039 | qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << error->error_code; | ||
1047 | free(error); | 1040 | free(error); | ||
1048 | return; | 1041 | return; | ||
1049 | } | 1042 | } | ||
1050 | // check that the received pixmap is valid and actually matches what we | 1043 | // check that the received pixmap is valid and actually matches what we | ||
1051 | // know about the window (i.e. size) | 1044 | // know about the window (i.e. size) | ||
1052 | if (!windowAttributes || windowAttributes->map_state != XCB_MAP_STATE_VIEWABLE) { | 1045 | if (!windowAttributes || windowAttributes->map_state != XCB_MAP_STATE_VIEWABLE) { | ||
1053 | qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << this; | 1046 | qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << this; | ||
1054 | xcb_free_pixmap(connection(), pix); | 1047 | xcb_free_pixmap(connection(), pix); | ||
1055 | return; | 1048 | return; | ||
1056 | } | 1049 | } | ||
1057 | const QRect bufferGeometry = toplevel()->bufferGeometry(); | 1050 | const QRect bufferGeometry = toplevel()->bufferGeometry(); | ||
1058 | if (windowGeometry.size() != bufferGeometry.size()) { | 1051 | if (windowGeometry.size() != bufferGeometry.size()) { | ||
1059 | qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << this; | 1052 | qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << this; | ||
1060 | xcb_free_pixmap(connection(), pix); | 1053 | xcb_free_pixmap(connection(), pix); | ||
1061 | return; | 1054 | return; | ||
1062 | } | 1055 | } | ||
1063 | m_pixmap = pix; | 1056 | m_pixmap = pix; | ||
1064 | m_pixmapSize = bufferGeometry.size(); | 1057 | m_pixmapSize = bufferGeometry.size(); | ||
1065 | m_contentsRect = QRect(toplevel()->clientPos(), toplevel()->clientSize()); | | |||
1066 | m_window->unreferencePreviousPixmap(); | 1058 | m_window->unreferencePreviousPixmap(); | ||
1067 | } | 1059 | } | ||
1068 | 1060 | | |||
1069 | WindowPixmap *WindowPixmap::createChild(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface) | 1061 | WindowPixmap *WindowPixmap::createChild(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface) | ||
1070 | { | 1062 | { | ||
1071 | Q_UNUSED(subSurface) | 1063 | Q_UNUSED(subSurface) | ||
1072 | return nullptr; | 1064 | return nullptr; | ||
1073 | } | 1065 | } | ||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |