From c3cf4482a376a91a98fadb96a486b23db2c8c872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 20 Jul 2011 22:10:03 +0200 Subject: [PATCH 01/12] Move GLX detection from kwinglobals to CompositingPrefs Removes the Extension::glxAvailable() from kwinglobals and implements the functionality in CompositingPrefs, where it is only needed. There used to be one additional check in scene_opengl_glx.cpp which is moved into composite.cpp before the OpenGL Scene is created. REVIEW: 102002 --- composite.cpp | 8 ++++++++ compositingprefs.cpp | 26 ++++++++++++++++++++++---- compositingprefs.h | 10 ++++++++++ libkwineffects/kwinglobals.cpp | 12 ------------ libkwineffects/kwinglobals.h | 4 ---- scene_opengl_glx.cpp | 4 ---- 6 files changed, 40 insertions(+), 24 deletions(-) diff --git a/composite.cpp b/composite.cpp index b309bd9d38..d2c31c0219 100644 --- a/composite.cpp +++ b/composite.cpp @@ -122,6 +122,14 @@ void Workspace::setupCompositing() else { unsafeConfig.writeEntry("OpenGLIsUnsafe", true); unsafeConfig.sync(); +#ifndef KWIN_HAVE_OPENGLES + if (!CompositingPrefs::hasGlx()) { + unsafeConfig.writeEntry("OpenGLIsUnsafe", false); + unsafeConfig.sync(); + kDebug(1212) << "No glx extensions available"; + break; + } +#endif scene = new SceneOpenGL(this); diff --git a/compositingprefs.cpp b/compositingprefs.cpp index 025048e70d..cf3bc1436b 100644 --- a/compositingprefs.cpp +++ b/compositingprefs.cpp @@ -80,7 +80,7 @@ bool CompositingPrefs::compositingPossible() return false; } #ifdef KWIN_HAVE_OPENGL_COMPOSITING - if (Extensions::glxAvailable()) + if (hasGlx()) return true; #endif #ifdef KWIN_HAVE_XRENDER_COMPOSITING @@ -116,14 +116,14 @@ QString CompositingPrefs::compositingNotPossibleReason() return i18n("Required X extensions (XComposite and XDamage) are not available."); } #if defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING ) - if (!Extensions::glxAvailable()) + if (!hasGlx()) return i18n("GLX/OpenGL are not available and only OpenGL support is compiled."); #elif !defined( KWIN_HAVE_OPENGL_COMPOSITING ) && defined( KWIN_HAVE_XRENDER_COMPOSITING ) if (!(Extensions::renderAvailable() && Extensions::fixesAvailable())) return i18n("XRender/XFixes extensions are not available and only XRender support" " is compiled."); #else - if (!(Extensions::glxAvailable() + if (!(hasGlx() || (Extensions::renderAvailable() && Extensions::fixesAvailable()))) { return i18n("GLX/OpenGL and XRender/XFixes are not available."); } @@ -135,6 +135,24 @@ QString CompositingPrefs::compositingNotPossibleReason() #endif } +static bool s_glxDetected = false; +static bool s_hasGlx = false; + +bool CompositingPrefs::hasGlx() +{ + if (s_glxDetected) { + return s_hasGlx; + } +#ifdef KWIN_HAVE_OPENGL_COMPOSITING +#ifndef KWIN_HAVE_OPENGLES + int event_base, error_base; + s_hasGlx = glXQueryExtension(display(), &event_base, &error_base); +#endif +#endif + s_glxDetected = true; + return s_hasGlx; +} + void CompositingPrefs::detect() { if (!compositingPossible() || openGlIsBroken()) { @@ -186,7 +204,7 @@ void CompositingPrefs::detect() if (QProcess::execute(opengl_test) != 0) setenv("LIBGL_ALWAYS_INDIRECT", "1", true); } - if (!Extensions::glxAvailable()) { + if (!hasGlx()) { kDebug(1212) << "No GLX available"; gl_workaround_config.writeEntry("OpenGLIsUnsafe", false); gl_workaround_config.sync(); diff --git a/compositingprefs.h b/compositingprefs.h index 4cfc0095ef..3ecb03b5ce 100644 --- a/compositingprefs.h +++ b/compositingprefs.h @@ -40,6 +40,16 @@ public: static bool compositingPossible(); static QString compositingNotPossibleReason(); static bool openGlIsBroken(); + /** + * Tests whether GLX is supported and returns @c true + * in case KWin is compiled with OpenGL support and GLX + * is available. + * + * If KWin is compiled with OpenGL ES or without OpenGL at + * all, @c false is returned. + * @returns @c true if GLX is available, @c false otherwise and if not build with OpenGL support. + **/ + static bool hasGlx(); bool recommendCompositing() const; bool enableVSync() const { return mEnableVSync; diff --git a/libkwineffects/kwinglobals.cpp b/libkwineffects/kwinglobals.cpp index d126a7cc9a..4b719c34cb 100644 --- a/libkwineffects/kwinglobals.cpp +++ b/libkwineffects/kwinglobals.cpp @@ -49,9 +49,6 @@ along with this program. If not, see . #ifdef HAVE_XCOMPOSITE #include #endif -#ifdef HAVE_OPENGL -#include -#endif #ifdef HAVE_XSYNC #include #endif @@ -68,7 +65,6 @@ int Extensions::damage_event_base = 0; int Extensions::composite_version = 0; int Extensions::fixes_version = 0; int Extensions::render_version = 0; -bool Extensions::has_glx = false; bool Extensions::has_sync = false; int Extensions::sync_event_base = 0; bool Extensions::non_native_pixmaps = false; @@ -145,14 +141,6 @@ void Extensions::init() render_version = major * 0x10 + minor; addData("RENDER"); } -#endif - has_glx = false; -#ifdef HAVE_OPENGL -#ifndef KWIN_HAVE_OPENGLES - has_glx = glXQueryExtension(display(), &event_base, &error_base); - if (has_glx) - addData("GLX"); -#endif #endif #ifdef HAVE_XSYNC if (XSyncQueryExtension(display(), &sync_event_base, &error_base)) { diff --git a/libkwineffects/kwinglobals.h b/libkwineffects/kwinglobals.h index 2a4ea7196d..f34bdba5c5 100644 --- a/libkwineffects/kwinglobals.h +++ b/libkwineffects/kwinglobals.h @@ -165,9 +165,6 @@ public: return fixes_version > 0; } static bool fixesRegionAvailable(); - static bool glxAvailable() { - return has_glx; - } static bool syncAvailable() { return has_sync; } @@ -187,7 +184,6 @@ private: static int composite_version; static int render_version; static int fixes_version; - static bool has_glx; static bool has_sync; static int sync_event_base; static const char* data_extensions[ 32 ]; diff --git a/scene_opengl_glx.cpp b/scene_opengl_glx.cpp index f9358267e2..5eeb5c7406 100644 --- a/scene_opengl_glx.cpp +++ b/scene_opengl_glx.cpp @@ -39,10 +39,6 @@ SceneOpenGL::SceneOpenGL(Workspace* ws) : Scene(ws) , init_ok(false) { - if (!Extensions::glxAvailable()) { - kDebug(1212) << "No glx extensions available"; - return; // error - } initGLX(); // check for FBConfig support if (!hasGLExtension("GLX_SGIX_fbconfig") || !glXGetFBConfigAttrib || !glXGetFBConfigs || From d0664a9c96da4e1a71c5eed2bbcb08e1780ed1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 17 Jul 2011 17:01:27 +0200 Subject: [PATCH 02/12] Ensure logout compiles with GLES --- effects/logout/logout.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index d0a5c1dc28..7f1c50cd11 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -200,6 +200,7 @@ void LogoutEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) effects->paintScreen(mask, region, data); #ifdef KWIN_HAVE_OPENGL_COMPOSITING +#ifndef KWIN_HAVE_OPENGLES if (effects->compositingType() == KWin::OpenGLCompositing && progress > 0.0) { if (!blurSupported) { if (!logoutWindowPassed) @@ -289,6 +290,7 @@ void LogoutEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) } } #endif +#endif } void LogoutEffect::postPaintScreen() @@ -353,6 +355,7 @@ bool LogoutEffect::isLogoutDialog(EffectWindow* w) #ifdef KWIN_HAVE_OPENGL_COMPOSITING void LogoutEffect::renderVignetting() { +#ifndef KWIN_HAVE_OPENGLES glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT); glEnable(GL_BLEND); // If not already (Such as when rendered straight to the screen) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -376,6 +379,7 @@ void LogoutEffect::renderVignetting() glDisable(GL_SCISSOR_TEST); } glPopAttrib(); +#endif } #endif From 7e4e43d203f1caf8a2075ea192768dcac89e0425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 17 Jul 2011 17:09:18 +0200 Subject: [PATCH 03/12] Make ShowFpsEffectConfig build without GL dep Forward declarations to the help! --- effects/showfps/showfps.h | 2 +- effects/showfps/showfps_config.cpp | 1 + effects/showfps/showfps_config.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/effects/showfps/showfps.h b/effects/showfps/showfps.h index 88349566b5..44a4d809b9 100644 --- a/effects/showfps/showfps.h +++ b/effects/showfps/showfps.h @@ -24,11 +24,11 @@ along with this program. If not, see . #include #include -#include namespace KWin { +class GLTexture; class ShowFpsEffect : public Effect diff --git a/effects/showfps/showfps_config.cpp b/effects/showfps/showfps_config.cpp index dcbe93bc05..81dda4f1d1 100644 --- a/effects/showfps/showfps_config.cpp +++ b/effects/showfps/showfps_config.cpp @@ -19,6 +19,7 @@ along with this program. If not, see . *********************************************************************/ #include "showfps_config.h" +#include "showfps.h" #include diff --git a/effects/showfps/showfps_config.h b/effects/showfps/showfps_config.h index b1846222aa..ad79519d4e 100644 --- a/effects/showfps/showfps_config.h +++ b/effects/showfps/showfps_config.h @@ -24,7 +24,6 @@ along with this program. If not, see . #include #include "ui_showfps_config.h" -#include "showfps.h" namespace KWin { From c807e97e0a59d3b58a4b7e60198a2445f19e823d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 17 Jul 2011 16:15:07 +0200 Subject: [PATCH 04/12] Split glutils out of kwineffects All OpenGL related files are build as a kwinglutils library for OpenGL and as a kwinglesutils library for OpenGL ES. The appropriate defines are set using target_properties and removed from kwinconfig.h.cmake. --- libkwineffects/CMakeLists.txt | 58 +++++++++++++++++++++---------- libkwineffects/kwinconfig.h.cmake | 18 ---------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/libkwineffects/CMakeLists.txt b/libkwineffects/CMakeLists.txt index cb9703b6fc..9c3a79ce0f 100644 --- a/libkwineffects/CMakeLists.txt +++ b/libkwineffects/CMakeLists.txt @@ -4,10 +4,6 @@ set(kwin_EFFECTSLIB_SRCS kwinglobals.cpp kwineffects.cpp - kwinglutils.cpp - kwingltexture.cpp - kwinglutils_funcs.cpp - kwinglplatform.cpp kwinxrenderutils.cpp ) @@ -18,21 +14,45 @@ set_target_properties(kwineffects PROPERTIES VERSION 1.0.0 SOVERSION 1 ) install(TARGETS kwineffects EXPORT kdeworkspaceLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) -if(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) - target_link_libraries(kwineffects ${OPENGL_gl_LIBRARY}) - target_link_libraries(kwineffects LINK_INTERFACE_LIBRARIES ${OPENGL_gl_LIBRARY}) -# -ldl used by OpenGL code - find_library(DL_LIBRARY dl) - if (DL_LIBRARY) - target_link_libraries(kwineffects ${DL_LIBRARY}) - endif(DL_LIBRARY) - include_directories(${OPENGL_INCLUDE_DIR}) -endif(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) -if(KWIN_HAVE_OPENGLES_COMPOSITING) - target_link_libraries(kwineffects ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) - target_link_libraries(kwineffects LINK_INTERFACE_LIBRARIES ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) - include_directories(${OPENGLES_INCLUDE_DIR}) -endif(KWIN_HAVE_OPENGLES_COMPOSITING) +if(OPENGL_FOUND OR OPENGLES_FOUND) + + set(kwin_GLUTILSLIB_SRCS + kwinglutils.cpp + kwingltexture.cpp + kwinglutils_funcs.cpp + kwinglplatform.cpp + ) + + macro( KWIN4_ADD_GLUTILS_BACKEND name glinclude ) + include_directories(${glinclude}) + kde4_add_library(${name} SHARED ${kwin_GLUTILSLIB_SRCS}) + target_link_libraries(${name} ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY} ${X11_LIBRARIES} kephal kwineffects) + set_target_properties(${name} PROPERTIES VERSION 1.0.0 SOVERSION 1 ) + target_link_libraries(${name} ${ARGN}) + target_link_libraries(${name} LINK_INTERFACE_LIBRARIES ${ARGN}) + + install(TARGETS ${name} EXPORT kdeworkspaceLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) + endmacro( KWIN4_ADD_GLUTILS_BACKEND ) + + if(OPENGLES_FOUND) + KWIN4_ADD_GLUTILS_BACKEND(kwinglesutils ${OPENGLES_INCLUDE_DIR} ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) + set_target_properties(kwinglesutils PROPERTIES COMPILE_FLAGS "-DKWIN_HAVE_OPENGL -DKWIN_HAVE_OPENGLES") + endif(OPENGLES_FOUND) + if(OPENGL_FOUND) + KWIN4_ADD_GLUTILS_BACKEND(kwinglutils ${OPENGL_INCLUDE_DIR} ${OPENGL_gl_LIBRARY}) + set_target_properties(kwinglutils PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL) + + target_link_libraries(kwinglutils ${OPENGL_gl_LIBRARY}) + target_link_libraries(kwinglutils LINK_INTERFACE_LIBRARIES ${OPENGL_gl_LIBRARY}) + # -ldl used by OpenGL code + find_library(DL_LIBRARY dl) + if (DL_LIBRARY) + target_link_libraries(kwinglutils ${DL_LIBRARY}) + endif(DL_LIBRARY) + endif(OPENGL_FOUND) + +endif(OPENGL_FOUND OR OPENGLES_FOUND) + if (X11_Xrender_FOUND) target_link_libraries(kwineffects ${X11_Xrender_LIB}) endif (X11_Xrender_FOUND) diff --git a/libkwineffects/kwinconfig.h.cmake b/libkwineffects/kwinconfig.h.cmake index 22405a585c..381231908d 100644 --- a/libkwineffects/kwinconfig.h.cmake +++ b/libkwineffects/kwinconfig.h.cmake @@ -9,21 +9,6 @@ #ifndef KWINCONFIG_H #define KWINCONFIG_H -#if ${HAVE_OPENGL} -#define KWIN_HAVE_OPENGL 1 -#else -#undef KWIN_HAVE_OPENGL -#endif - -#if ${KWIN_HAVE_OPENGLES} -#define KWIN_HAVE_OPENGLES 1 -#ifndef KWIN_HAVE_OPENGL -#define KWIN_HAVE_OPENGL 1 -#endif -#else -#undef KWIN_HAVE_OPENGLES -#endif - /* These should be primarily used to detect what kind of compositing @@ -37,9 +22,6 @@ /* KWIN_HAVE_OPENGL_COMPOSITING - whether OpenGL-based compositing support is available */ #cmakedefine KWIN_HAVE_OPENGL_COMPOSITING -/* KWIN_HAVE_OPENGLES_COMPOSITING - whether OpenGL ES-based compositing support is available */ -#cmakedefine KWIN_HAVE_OPENGLES_COMPOSITING - /* KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available */ #cmakedefine KWIN_HAVE_XRENDER_COMPOSITING From 808c29109a79ac9ba5b086b6dd51ab33226790fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 17 Jul 2011 17:27:14 +0200 Subject: [PATCH 05/12] Build effects twice - once with GL, once with GLES --- effects/CMakeLists.txt | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 8683b35779..68b626559d 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -3,15 +3,34 @@ kde4_no_enable_final(kwineffects) # Uncomment to have the test effects built as well #add_subdirectory( _test ) +macro( KWIN4_ADD_EFFECT_BACKEND name ) + kde4_add_plugin( ${name} ${ARGN} ) + target_link_libraries( ${name} kwineffects ${KDE4_KDEUI_LIBS} kephal ${KDE4_PLASMA_LIBS} ${X11_Xfixes_LIB} ${X11_Xcursor_LIB}) + if (X11_Xfixes_FOUND) + target_link_libraries(${name} ${X11_Xfixes_LIB}) + endif (X11_Xfixes_FOUND) +endmacro( KWIN4_ADD_EFFECT_BACKEND ) # Adds effect plugin with given name. Sources are given after the name macro( KWIN4_ADD_EFFECT name ) - kde4_add_plugin( kwin4_effect_${name} ${ARGN} ) - target_link_libraries( kwin4_effect_${name} kwineffects ${KDE4_KDEUI_LIBS} kephal ${KDE4_PLASMA_LIBS} ${X11_Xfixes_LIB} ${X11_Xcursor_LIB}) - if (X11_Xfixes_FOUND) - target_link_libraries(kwin4_effect_${name} ${X11_Xfixes_LIB}) - endif (X11_Xfixes_FOUND) - install( TARGETS kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR} ) + if(OPENGL_FOUND OR NOT(OPENGL_FOUND AND OPENGLES_FOUND)) + # OpenGL or neither OpenGL nor OpenGL ES - default set + KWIN4_ADD_EFFECT_BACKEND(kwin4_effect_${name} ${ARGN}) + if(OPENGL_FOUND) + target_link_libraries(kwin4_effect_${name} kwinglutils) + set_target_properties(kwin4_effect_${name} PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL) + endif(OPENGL_FOUND) + install( TARGETS kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR} ) + endif(OPENGL_FOUND OR NOT(OPENGL_FOUND AND OPENGLES_FOUND)) + + + if(OPENGLES_FOUND) + KWIN4_ADD_EFFECT_BACKEND(kwin4_effect_gles_${name} ${ARGN}) + # OpenGL ES gets into a different library + target_link_libraries(kwin4_effect_gles_${name} kwinglesutils) + set_target_properties(kwin4_effect_gles_${name} PROPERTIES COMPILE_FLAGS "-DKWIN_HAVE_OPENGL -DKWIN_HAVE_OPENGLES") + install( TARGETS kwin4_effect_gles_${name} DESTINATION ${PLUGIN_INSTALL_DIR} ) + endif(OPENGLES_FOUND) endmacro( KWIN4_ADD_EFFECT ) macro( KWIN4_ADD_EFFECT_CONFIG name ) @@ -35,6 +54,12 @@ endmacro( KWIN4_ADD_EFFECT_CONFIG ) macro( KWIN4_EFFECT_LINK_XRENDER name ) if( KWIN_HAVE_XRENDER_COMPOSITING ) target_link_libraries( kwin4_effect_${name} ${X11_Xrender_LIB} ${X11_LIBRARIES} kephal ) + + # if building for OpenGL and OpenGL ES we have two targets + # TODO: if building for OpenGL ES we should not build XRender support + if(OPENGLES_FOUND) + target_link_libraries( kwin4_effect_gles_${name} ${X11_Xrender_LIB} ${X11_LIBRARIES} kephal ) + endif(OPENGLES_FOUND) endif( KWIN_HAVE_XRENDER_COMPOSITING ) endmacro( KWIN4_EFFECT_LINK_XRENDER ) From 680a0bad646035ee2b735f2da799194b1f8e9a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 17 Jul 2011 18:17:43 +0200 Subject: [PATCH 06/12] KCMs need to link kwingl(es)compositing --- kcmkwin/kwincompositing/CMakeLists.txt | 6 ++++-- kcmkwin/kwinscreenedges/CMakeLists.txt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kcmkwin/kwincompositing/CMakeLists.txt b/kcmkwin/kwincompositing/CMakeLists.txt index 57d77506d5..be97b0bd98 100644 --- a/kcmkwin/kwincompositing/CMakeLists.txt +++ b/kcmkwin/kwincompositing/CMakeLists.txt @@ -19,7 +19,8 @@ install(TARGETS kcm_kwincompositing DESTINATION ${PLUGIN_INSTALL_DIR} ) # CompositingPrefs uses OpenGL if(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) - target_link_libraries(kcm_kwincompositing ${OPENGL_gl_LIBRARY}) + target_link_libraries(kcm_kwincompositing kwinglutils ${OPENGL_gl_LIBRARY}) + set_target_properties(kcm_kwincompositing PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL) # -ldl used by OpenGL code find_library(DL_LIBRARY dl) if (DL_LIBRARY) @@ -27,7 +28,8 @@ if(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) endif(DL_LIBRARY) endif(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) if(KWIN_HAVE_OPENGLES_COMPOSITING) - target_link_libraries(kcm_kwincompositing ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) + target_link_libraries(kcm_kwincompositing kwinglesutils ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) + set_target_properties(kcm_kwincompositing PROPERTIES COMPILE_FLAGS "-DKWIN_HAVE_OPENGL -DKWIN_HAVE_OPENGLES") endif(KWIN_HAVE_OPENGLES_COMPOSITING) if (X11_Xrender_FOUND) target_link_libraries(kcm_kwincompositing ${X11_Xrender_LIB}) diff --git a/kcmkwin/kwinscreenedges/CMakeLists.txt b/kcmkwin/kwinscreenedges/CMakeLists.txt index 94e841c2c7..685eed18bb 100644 --- a/kcmkwin/kwinscreenedges/CMakeLists.txt +++ b/kcmkwin/kwinscreenedges/CMakeLists.txt @@ -15,7 +15,8 @@ install( TARGETS kcm_kwinscreenedges DESTINATION ${PLUGIN_INSTALL_DIR} ) # CompositingPrefs uses OpenGL if( OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING ) - target_link_libraries( kcm_kwinscreenedges ${OPENGL_gl_LIBRARY} ) + target_link_libraries( kcm_kwinscreenedges kwinglutils ${OPENGL_gl_LIBRARY} ) + set_target_properties(kcm_kwinscreenedges PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL) # -ldl used by OpenGL code find_library( DL_LIBRARY dl ) if( DL_LIBRARY ) @@ -23,7 +24,8 @@ if( OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING ) endif( DL_LIBRARY ) endif( OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING ) if(KWIN_HAVE_OPENGLES_COMPOSITING) - target_link_libraries(kcm_kwinscreenedges ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) + target_link_libraries(kcm_kwinscreenedges kwinglesutils ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) + set_target_properties(kcm_kwinscreenedges PROPERTIES COMPILE_FLAGS "-DKWIN_HAVE_OPENGL -DKWIN_HAVE_OPENGLES") endif(KWIN_HAVE_OPENGLES_COMPOSITING) if( X11_Xrender_FOUND ) target_link_libraries( kcm_kwinscreenedges ${X11_Xrender_LIB} ) From af27c83d0af7b988b466d3c99b60676781437447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 17 Jul 2011 18:18:22 +0200 Subject: [PATCH 07/12] Build an additional kwin_gles binary KWin gets compiled twice if OpenGL ES is available and a second binary is created. It is linked against the GLES effects and kwinglesutils and does not link against OpenGL. The normal OpenGL variant is still the "kwin" binary. This is an intermediate step till we have the scene as a loadable plugin. Then we will determine whether OpenGL ES is supported in an external application and load it as a plugin, otherwise we load the OpenGL/GLX scene as a plugin. REVIEW: 101979 --- CMakeLists.txt | 62 +++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d28ca9011c..2ef13e59cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,21 +213,40 @@ qt4_add_dbus_interface( kwin_KDEINIT_SRCS qt4_add_resources( kwin_KDEINIT_SRCS resources.qrc ) -kde4_add_kdeinit_executable( kwin ${kwin_KDEINIT_SRCS}) - -target_link_libraries(kdeinit_kwin ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} kephal kworkspace kdecorations kwineffects ${X11_LIBRARIES}) +set(kwinLibs ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} kephal kworkspace kdecorations kwineffects ${X11_LIBRARIES}) if(KWIN_BUILD_SCRIPTING) - target_link_libraries(kdeinit_kwin ${QT_QTSCRIPT_LIBRARY}) + set(kwinLibs ${kwinLibs} ${QT_QTSCRIPT_LIBRARY}) endif(KWIN_BUILD_SCRIPTING) if(KWIN_BUILD_TABBOX) - target_link_libraries(kdeinit_kwin ${QT_QTXML_LIBRARY}) + set(kwinLibs ${kwinLibs} ${QT_QTXML_LIBRARY}) endif(KWIN_BUILD_TABBOX) -if(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) +if (X11_Xrandr_FOUND) + set(kwinLibs ${kwinLibs} ${X11_Xrandr_LIB}) +endif (X11_Xrandr_FOUND) +if (X11_Xcomposite_FOUND) + set(kwinLibs ${kwinLibs} ${X11_Xcomposite_LIB}) +endif (X11_Xcomposite_FOUND) +if (X11_Xdamage_FOUND) + set(kwinLibs ${kwinLibs} ${X11_Xdamage_LIB}) +endif (X11_Xdamage_FOUND) +if (X11_Xrender_FOUND) + set(kwinLibs ${kwinLibs} ${X11_Xrender_LIB}) +endif (X11_Xrender_FOUND) +if (X11_Xfixes_FOUND) + set(kwinLibs ${kwinLibs} ${X11_Xfixes_LIB}) +endif (X11_Xfixes_FOUND) + +kde4_add_kdeinit_executable( kwin ${kwin_KDEINIT_SRCS}) + +target_link_libraries(kdeinit_kwin ${kwinLibs}) + +if(OPENGL_FOUND) + set_target_properties(kdeinit_kwin PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL) add_subdirectory(opengltest) - target_link_libraries(kdeinit_kwin ${OPENGL_gl_LIBRARY}) + target_link_libraries(kdeinit_kwin kwinglutils ${OPENGL_gl_LIBRARY}) # -ldl used by OpenGL code find_library(DL_LIBRARY dl) if (DL_LIBRARY) @@ -235,31 +254,18 @@ if(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) endif(DL_LIBRARY) # must be after opengl, to be initialized first by the linker target_link_libraries(kdeinit_kwin kwinnvidiahack) -endif(OPENGL_FOUND AND NOT KWIN_HAVE_OPENGLES_COMPOSITING) - -if(KWIN_HAVE_OPENGLES_COMPOSITING) - target_link_libraries(kdeinit_kwin ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) -endif(KWIN_HAVE_OPENGLES_COMPOSITING) - -if (X11_Xrandr_FOUND) - target_link_libraries(kdeinit_kwin ${X11_Xrandr_LIB}) -endif (X11_Xrandr_FOUND) -if (X11_Xcomposite_FOUND) - target_link_libraries(kdeinit_kwin ${X11_Xcomposite_LIB}) -endif (X11_Xcomposite_FOUND) -if (X11_Xdamage_FOUND) - target_link_libraries(kdeinit_kwin ${X11_Xdamage_LIB}) -endif (X11_Xdamage_FOUND) -if (X11_Xrender_FOUND) - target_link_libraries(kdeinit_kwin ${X11_Xrender_LIB}) -endif (X11_Xrender_FOUND) -if (X11_Xfixes_FOUND) - target_link_libraries(kdeinit_kwin ${X11_Xfixes_LIB}) -endif (X11_Xfixes_FOUND) +endif(OPENGL_FOUND) install(TARGETS kdeinit_kwin ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS kwin ${INSTALL_TARGETS_DEFAULT_ARGS} ) +if(OPENGLES_FOUND) + kde4_add_kdeinit_executable( kwin_gles ${kwin_KDEINIT_SRCS}) + target_link_libraries(kdeinit_kwin_gles ${kwinLibs} kwinglesutils ${OPENGLES_LIBRARIES} ${OPENGLES_EGL_LIBRARIES}) + set_target_properties(kdeinit_kwin_gles PROPERTIES COMPILE_FLAGS "-DKWIN_HAVE_OPENGL -DKWIN_HAVE_OPENGLES") + install(TARGETS kdeinit_kwin_gles ${INSTALL_TARGETS_DEFAULT_ARGS} ) + install(TARGETS kwin_gles ${INSTALL_TARGETS_DEFAULT_ARGS} ) +endif(OPENGLES_FOUND) ########### next target ############### From 1493dfd94f9f3f1ec8e569ee9dfaf4f5a2df3c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 17 Jul 2011 19:46:16 +0200 Subject: [PATCH 08/12] Load GLES effects instead of GL effects in GLES build Just replacing the library name. --- effects.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/effects.cpp b/effects.cpp index 143b033b9f..45233136f8 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1040,6 +1040,11 @@ unsigned long EffectsHandlerImpl::xrenderBufferPicture() KLibrary* EffectsHandlerImpl::findEffectLibrary(KService* service) { QString libname = service->library(); +#ifdef KWIN_HAVE_OPENGLES + if (libname.startsWith("kwin4_effect_")) { + libname.replace("kwin4_effect_", "kwin4_effect_gles_"); + } +#endif KLibrary* library = new KLibrary(libname); if (!library) { kError(1212) << "couldn't open library for effect '" << From 92d32de087a780b9c08e6994bf1c7e4238aea408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 26 Jul 2011 08:05:09 +0200 Subject: [PATCH 09/12] Effects do not need kephal --- effects/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 68b626559d..25ba57ca35 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -5,7 +5,7 @@ kde4_no_enable_final(kwineffects) #add_subdirectory( _test ) macro( KWIN4_ADD_EFFECT_BACKEND name ) kde4_add_plugin( ${name} ${ARGN} ) - target_link_libraries( ${name} kwineffects ${KDE4_KDEUI_LIBS} kephal ${KDE4_PLASMA_LIBS} ${X11_Xfixes_LIB} ${X11_Xcursor_LIB}) + target_link_libraries( ${name} kwineffects ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} ${X11_Xfixes_LIB} ${X11_Xcursor_LIB}) if (X11_Xfixes_FOUND) target_link_libraries(${name} ${X11_Xfixes_LIB}) endif (X11_Xfixes_FOUND) @@ -47,18 +47,18 @@ macro( KWIN4_ADD_EFFECT_CONFIG name ) kde4_add_ui_files( kwin4_effect_src ${kwin4_effect_ui} ) kde4_add_plugin( kcm_kwin4_effect_${name} ${kwin4_effect_src} ) - target_link_libraries( kcm_kwin4_effect_${name} kwineffects ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS} kephal ) + target_link_libraries( kcm_kwin4_effect_${name} kwineffects ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS} ) install( TARGETS kcm_kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR} ) endmacro( KWIN4_ADD_EFFECT_CONFIG ) macro( KWIN4_EFFECT_LINK_XRENDER name ) if( KWIN_HAVE_XRENDER_COMPOSITING ) - target_link_libraries( kwin4_effect_${name} ${X11_Xrender_LIB} ${X11_LIBRARIES} kephal ) + target_link_libraries( kwin4_effect_${name} ${X11_Xrender_LIB} ${X11_LIBRARIES} ) # if building for OpenGL and OpenGL ES we have two targets # TODO: if building for OpenGL ES we should not build XRender support if(OPENGLES_FOUND) - target_link_libraries( kwin4_effect_gles_${name} ${X11_Xrender_LIB} ${X11_LIBRARIES} kephal ) + target_link_libraries( kwin4_effect_gles_${name} ${X11_Xrender_LIB} ${X11_LIBRARIES} ) endif(OPENGLES_FOUND) endif( KWIN_HAVE_XRENDER_COMPOSITING ) endmacro( KWIN4_EFFECT_LINK_XRENDER ) From 997634c813763c9a25139f363c3084b056b3421d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 26 Jul 2011 08:09:02 +0200 Subject: [PATCH 10/12] Remove a not working include directory The kwin/lib directory does not exist for one release cycle now. --- effects/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 25ba57ca35..416725e5fa 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -63,11 +63,6 @@ macro( KWIN4_EFFECT_LINK_XRENDER name ) endif( KWIN_HAVE_XRENDER_COMPOSITING ) endmacro( KWIN4_EFFECT_LINK_XRENDER ) -# Make sure we can see our libraries -include_directories( - ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/lib - ) - # Install the KWin/Effect service type install( FILES kwineffect.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) From 68bba98e5fea0d7e27fee77d195709fd0eb44935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 26 Jul 2011 08:10:57 +0200 Subject: [PATCH 11/12] Remove duplicated xfixes include --- effects/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 416725e5fa..986f5921c9 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -6,9 +6,6 @@ kde4_no_enable_final(kwineffects) macro( KWIN4_ADD_EFFECT_BACKEND name ) kde4_add_plugin( ${name} ${ARGN} ) target_link_libraries( ${name} kwineffects ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} ${X11_Xfixes_LIB} ${X11_Xcursor_LIB}) - if (X11_Xfixes_FOUND) - target_link_libraries(${name} ${X11_Xfixes_LIB}) - endif (X11_Xfixes_FOUND) endmacro( KWIN4_ADD_EFFECT_BACKEND ) # Adds effect plugin with given name. Sources are given after the name From a2aad27a78098acda015f48ea0fc0953f3322c4a Mon Sep 17 00:00:00 2001 From: Alex Fiestas Date: Wed, 27 Jul 2011 20:10:11 +0200 Subject: [PATCH 12/12] Make sure that not maximized clients are offscreen on xrandr events Added a small check in Client::checkWorkspacePosition which will assure us that no window ("client") is left in a offscreen position. this is more a workaround than a proper fix but is the only thing we can do that will be backportable to the 4.7 branch. --- geometry.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/geometry.cpp b/geometry.cpp index 04c7b9d567..a357162b15 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1154,6 +1154,15 @@ void Client::checkWorkspacePosition(const QRect &geo) newGeom.x() + newGeom.width() - 1)); } + if (newGeom.x() > screenArea.right()) { + int screenWidth = screenArea.width(); + newGeom.moveLeft(screenWidth - (screenWidth / 4)); + } + if (newGeom.y() > screenArea.bottom()) { + int screenHeight = screenArea.height(); + newGeom.moveBottom(screenHeight - (screenHeight / 4)); + } + // Obey size hints. TODO: We really should make sure it stays in the right place newGeom.setSize(adjustedSize(newGeom.size()));