# uncomment to enable bootstrap mode
#global bootstrap 1

%if !0%{?bootstrap}
# avoid slow arm arch for now
%ifnarch %{arm}
%global tests 1
%endif
%endif

Name:           kwin
Version:        5.15.4
Release:        2
Summary:        KDE Window manager

# all sources are effectively GPLv2+, except for:
# scripts/enforcedeco/contents/code/main.js
# KDE e.V. may determine that future GPL versions are accepted
License:        GPLv2 or GPLv3
URL:            https://userbase.kde.org/KWin
%global revision %(echo %{version} | cut -d. -f3)
%if %{revision} >= 50
%global majmin_ver %(echo %{version} | cut -d. -f1,2).50
%global stable unstable
%else
%global majmin_ver %(echo %{version} | cut -d. -f1,2)
%global stable stable
%endif
Source0:        http://download.kde.org/%{stable}/plasma/%{version}/%{name}-%{version}.tar.xz

Patch0:         support-_GTK_SHOW_WINDOW_MENU.patch

# Base
BuildRequires:  extra-cmake-modules  kf5-rpm-macros  qt5-qtbase-devel  qt5-qtbase-static  qt5-qtbase-private-devel  qt5-qtsensors-devel  qt5-qtscript-devel  qt5-qttools-devel  qt5-qttools-static  qt5-qtx11extras-devel  mesa-libGL-devel  mesa-libEGL-devel  mesa-libgbm-devel  libxkbcommon-devel  libX11-devel  libXi-devel  libxcb-devel  libICE-devel  libSM-devel  libXcursor-devel  xcb-util-wm-devel  xcb-util-image-devel  xcb-util-keysyms-devel  xcb-util-cursor-devel  libepoxy-devel  libcap-devel kf5-kwayland-devel  wayland-devel  libxkbcommon-devel >= 0.4  pkgconfig(libinput) >= 0.10  pkgconfig(libudev)  kf5-kcompletion-devel  kf5-kconfig-devel  kf5-kconfigwidgets-devel  kf5-kcoreaddons-devel  kf5-kcrash-devel  kf5-kglobalaccel-devel  kf5-ki18n-devel  kf5-kinit-devel >= 5.10.0-3  kf5-kio-devel  kf5-knotifications-devel  kf5-kservice-devel  kf5-plasma-devel  kf5-kwidgetsaddons-devel  kf5-kwindowsystem-devel  kf5-kdoctools-devel  kf5-kcmutils-devel  kf5-knewstuff-devel  kf5-kactivities-devel  kf5-kdoctools-devel  kf5-kdeclarative-devel  kf5-kiconthemes-devel  kf5-kidletime-devel  kf5-ktextwidgets-devel  kdecoration-devel >= %{majmin_ver}  kscreenlocker-devel >= %{majmin_ver}  plasma-breeze-devel >= %{majmin_ver}
%if 0%{?tests}
BuildRequires:  dbus-x11 openbox xorg-x11-server-Xvfb
%endif
%if ! 0%{?bootstrap}
BuildRequires:  qt5-qtmultimedia-devel  qt5-qtvirtualkeyboard
%endif
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}       %{name}-common%{?_isa} = %{version}-%{release}       kdecoration%{?_isa} >= %{majmin_ver}       kscreenlocker%{?_isa} >= %{majmin_ver} qt5-qtmultimedia%{?_isa}
Recommends:     qt5-qtvirtualkeyboard%{?_isa}
# libkdeinit5_kwin*
%{?kf5_kinit_requires}

# Before kwin was split out from kde-workspace into a subpackage
Conflicts:      kde-workspace%{?_isa} < 4.11.14-2

Obsoletes:      kwin-gles < 5
Obsoletes:      kwin-gles-libs < 5

# http://bugzilla.redhat.com/605675
Provides: firstboot(windowmanager) = kwin_x11
# and kwin too (#1197135), until initial-setup fixed
Provides: firstboot(windowmanager) = kwin


%description
%{summary}.

%package        wayland
Summary:        KDE Window Manager with experimental Wayland support
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}       %{name}-common%{?_isa} = %{version}-%{release}       kwayland-integration%{?_isa} >= %{majmin_ver}  xorg-x11-server-Xwayland
%if ! 0%{?bootstrap}
BuildRequires:  xorg-x11-server-Xwayland
%endif
# KWinQpaPlugin (and others?)
%{?_qt5:Requires: %{_qt5}%{?_isa} = %{_qt5_version}}
# libkdeinit5_kwin*
%{?kf5_kinit_requires}

%description    wayland
%{summary}.

%package        common
Summary:        Common files for KWin X11 and KWin Wayland
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}       kf5-kwayland%{?_isa} 

%description    common
%{summary}.

%package        libs
Summary:        KWin runtime libraries
# Before kwin-libs was split out from kde-workspace into a subpackage
Conflicts:      kde-workspace-libs%{?_isa} < 4.11.14-2

%description    libs
%{summary}.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}       %{name}-common%{?_isa} = %{version}-%{release}       kf5-kconfig-devel       kf5-kservice-devel       kf5-kwindowsystem-devel
Conflicts:      kde-workspace-devel < 5.0.0-1

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%package        help
Summary:        User manual for %{name}
Requires:       %{name} = %{version}-%{release}
BuildArch:      noarch

%description    help
%{summary}.


%prep
%autosetup -n %{name}-%{version} -p1

sed -i \
  -e 's|^find_package(Breeze ${PROJECT_VERSION} CONFIG)|find_package(Breeze 5.9 CONFIG)|' \
  CMakeLists.txt


%build
mkdir %{_target_platform}
pushd %{_target_platform}
%{cmake_kf5} .. \
  -DBUILD_TESTING:BOOL=%{?tests:ON}%{!?tests:OFF}
popd

%make_build -C %{_target_platform}


%install
make install/fast DESTDIR=%{buildroot} -C %{_target_platform}

%find_lang %{name} --with-html --all-name
grep "%{_kf5_docdir}" %{name}.lang > %{name}-doc.lang
cat %{name}.lang %{name}-doc.lang | sort | uniq -u > kwin5.lang

# temporary(?) hack to allow initial-setup to use /usr/bin/kwin too
ln -s kwin_x11 %{buildroot}%{_bindir}/kwin


%check
%if 0%{?tests}
# using low timeout to avoid extending buildtimes too much for now -- rex
export CTEST_OUTPUT_ON_FAILURE=1
xvfb-run -a \
dbus-launch --exit-with-session \
make test ARGS="--output-on-failure --timeout 10" -C %{_target_platform} ||:
%endif

%files
%{_bindir}/kwin
%{_bindir}/kwin_x11
%{_kf5_libdir}/libkdeinit5_kwin_x11.so

%files common -f kwin5.lang
%{_kf5_libdir}/libkdeinit5_kwin_rules_dialog.so
%{_datadir}/kwin
%{_kf5_qtplugindir}/*.so
%{_kf5_qtplugindir}/kwin/
%{_kf5_qtplugindir}/org.kde.kdecoration2/*.so
%{_kf5_qtplugindir}/org.kde.kwin.platforms/
%{_kf5_qtplugindir}/kpackage/packagestructure/kwin_packagestructure*.so
%{_kf5_qtplugindir}/org.kde.kwin.scenes/*.so
%{_qt5_qmldir}/org/kde/kwin
%{_kf5_libdir}/kconf_update_bin/kwin5_update_default_rules
%{_libexecdir}/kwin_killer_helper
%{_libexecdir}/kwin_rules_dialog
%{_libexecdir}/org_kde_kwin_xclipboard_syncer
%{_datadir}/kwincompositing
%{_datadir}/kconf_update/kwin.upd
%{_kf5_datadir}/kservices5/*.desktop
%{_kf5_datadir}/kservices5/kwin
%{_kf5_datadir}/kservicetypes5/*.desktop
%{_kf5_datadir}/kpackage/kcms/kcm_kwin_virtualdesktops/*
%{_kf5_datadir}/knotifications5/kwin.notifyrc
%{_kf5_datadir}/config.kcfg/kwin.kcfg
%{_kf5_datadir}/config.kcfg/kwin_colorcorrect.kcfg
%{_datadir}/icons/hicolor/*/apps/kwin.*
# note: these are for reference (to express config defaults), they are
# not config files themselves (so don't use %%config tag)
%{_sysconfdir}/xdg/*.knsrc

%files wayland
%{_kf5_bindir}/kwin_wayland
%{_kf5_qtplugindir}/platforms/KWinQpaPlugin.so
%{_kf5_qtplugindir}/org.kde.kglobalaccel5.platforms/KF5GlobalAccelPrivateKWin.so
%{_kf5_qtplugindir}/org.kde.kwin.waylandbackends/KWinWaylandDrmBackend.so
%{_kf5_qtplugindir}/org.kde.kwin.waylandbackends/KWinWaylandFbdevBackend.so
%{_kf5_qtplugindir}/org.kde.kwin.waylandbackends/KWinWaylandWaylandBackend.so
%{_kf5_qtplugindir}/org.kde.kwin.waylandbackends/KWinWaylandX11Backend.so
%{_kf5_qtplugindir}/org.kde.kwin.waylandbackends/KWinWaylandVirtualBackend.so
%{_kf5_plugindir}/org.kde.kidletime.platforms/KF5IdleTimeKWinWaylandPrivatePlugin.so

%ldconfig_scriptlets libs

%files libs
%{_sysconfdir}/xdg/org_kde_kwin.categories
%{_libdir}/libkwin.so.*
%{_libdir}/libkwinxrenderutils.so.*
%{_libdir}/libkwineffects.so.*
%{_libdir}/libkwinglutils.so.*
%{_libdir}/libkwin4_effect_builtins.so.*
%{_libdir}/libkcmkwincommon.so.*
%{_qt5_plugindir}/kcms/kcm_kwin_virtualdesktops.so

%files devel
%{_datadir}/dbus-1/interfaces/*.xml
%{_libdir}/cmake/KWinDBusInterface
%{_libdir}/libkwinxrenderutils.so
%{_libdir}/libkwineffects.so
%{_libdir}/libkwinglutils.so
%{_libdir}/libkwin4_effect_builtins.so
%{_includedir}/kwin*.h

%files help -f %{name}-doc.lang
%license COPYING*


%changelog
* Mon Feb 07 2022 herengui <herengui@uniontech.com> - 5.15.4-2
- support _GTK_SHOW_WINDOW_MENU

* Fri Aug 7 2020 weidong <weidong@uniontech.com> - 5.15.4-1
- Initial release for OpenEuler

