kcontrol: cleanup screensaver module

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-03-25 22:21:16 +00:00
parent 4359faa67d
commit 66d83b1ba9
7 changed files with 10 additions and 170 deletions

View file

@ -1,17 +1,10 @@
if(WITH_OpenGL)
check_library_exists(GL glXChooseVisual "" HAVE_GLXCHOOSEVISUAL)
endif(WITH_OpenGL)
configure_file (config-screensaver.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-screensaver.h )
########### next target ############### ########### next target ###############
set(kcm_screensaver_PART_SRCS set(kcm_screensaver_PART_SRCS
scrnsave.cpp scrnsave.cpp
testwin.cpp testwin.cpp
saverconfig.cpp saverconfig.cpp
kswidget.cpp )
screensaver.ui)
set(kscreensaver_xml ${CMAKE_SOURCE_DIR}/ksmserver/screenlocker/dbus/org.kde.screensaver.xml) set(kscreensaver_xml ${CMAKE_SOURCE_DIR}/ksmserver/screenlocker/dbus/org.kde.screensaver.xml)
QT4_ADD_DBUS_INTERFACE( kcm_screensaver_PART_SRCS ${kscreensaver_xml} kscreensaver_interface ) QT4_ADD_DBUS_INTERFACE( kcm_screensaver_PART_SRCS ${kscreensaver_xml} kscreensaver_interface )
@ -26,11 +19,6 @@ if (DL_LIBRARY)
target_link_libraries(kcm_screensaver ${DL_LIBRARY}) target_link_libraries(kcm_screensaver ${DL_LIBRARY})
endif(DL_LIBRARY) endif(DL_LIBRARY)
if(HAVE_GLXCHOOSEVISUAL)
target_link_libraries(kcm_screensaver ${OPENGL_gl_LIBRARY})
endif(HAVE_GLXCHOOSEVISUAL)
install(TARGETS kcm_screensaver DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kcm_screensaver DESTINATION ${PLUGIN_INSTALL_DIR} )

View file

@ -1,3 +0,0 @@
/* Define if you have glXChooseVisual() */
#cmakedefine HAVE_GLXCHOOSEVISUAL 1

View file

@ -26,12 +26,12 @@
#ifndef KSSMONITOR_H #ifndef KSSMONITOR_H
#define KSSMONITOR_H #define KSSMONITOR_H
#include "kswidget.h" #include <QWidget>
class KSSMonitor : public KSWidget class KSSMonitor : public QWidget
{ {
public: public:
KSSMonitor( QWidget *parent ) : KSWidget( parent ) {} KSSMonitor( QWidget *parent ) : QWidget( parent ) {}
// we don't want no steenking palette change // we don't want no steenking palette change
virtual void setPalette( const QPalette & ) {} virtual void setPalette( const QPalette & ) {}

View file

@ -1,103 +0,0 @@
/*
* ksmwidget.cpp
* Copyright 1997 Matthias Hoelzer
* Copyright 1996,1999,2002 Martin R. Jones
* Copyright 2004 Chris Howells
* Copyright 2007-2008 Benjamin Meyer <ben@meyerhome.net>
* Copyright 2007-2008 Hamish Rodda <rodda@kde.org>
*
* 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) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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/>.
*/
#include <config-screensaver.h>
#include "testwin.h"
#include <QtGui/qx11info_x11.h>
#ifdef HAVE_GLXCHOOSEVISUAL
#include <GL/glx.h>
#include <fixx11h.h>
#endif
KSWidget::KSWidget( QWidget* parent, Qt::WindowFlags wf )
: QWidget( parent, wf ), colormap( None )
{
// use visual with support for double-buffering, for opengl
// this code is (partially) duplicated in kdebase/workspace/krunner/lock/
#ifdef HAVE_GLXCHOOSEVISUAL
Visual* visual = CopyFromParent;
int depth = CopyFromParent;
XSetWindowAttributes attrs;
int flags = parentWidget() ? 0 : CWOverrideRedirect;
if( true /*mOpenGLVisual*/ )
{
static const int attribs[][ 15 ] =
{
#define R GLX_RED_SIZE
#define G GLX_GREEN_SIZE
#define B GLX_BLUE_SIZE
{ GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
{ GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
{ GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
{ GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, None },
{ GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
{ GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_STENCIL_SIZE, 1, None },
{ GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, None },
{ GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, None },
{ GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
{ GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
{ GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
{ GLX_RGBA, GLX_DEPTH_SIZE, 8, None }
#undef R
#undef G
#undef B
};
for( unsigned int i = 0;
i < sizeof( attribs ) / sizeof( attribs[ 0 ] );
++i )
{
if( XVisualInfo* info = glXChooseVisual( x11Info().display(), x11Info().screen(), const_cast<int*>(attribs[ i ]) ))
{
visual = info->visual;
depth = info->depth;
colormap = XCreateColormap( x11Info().display(), RootWindow( x11Info().display(), x11Info().screen()), visual, AllocNone );
attrs.colormap = colormap;
flags |= CWColormap;
XFree( info );
break;
}
}
}
attrs.override_redirect = 1;
Window w = XCreateWindow( x11Info().display(), RootWindow( x11Info().display(), x11Info().screen()),
x(), y(), width(), height(), 0, depth, InputOutput, visual, flags, &attrs );
if( parentWidget())
XReparentWindow( x11Info().display(), w, parentWidget()->winId(), 0, 0 );
create( w, false, true );
#endif
}
KSWidget::~KSWidget()
{
#ifdef HAVE_GLXCHOOSEVISUAL
if( colormap != None )
XFreeColormap( x11Info().display(), colormap );
#endif
}
#include "moc_kswidget.cpp"

View file

@ -1,42 +0,0 @@
/*
* ksmwidget.h
* Copyright 1997 Matthias Hoelzer
* Copyright 1996,1999,2002 Martin R. Jones
* Copyright 2004 Chris Howells
* Copyright 2007-2008 Benjamin Meyer <ben@meyerhome.net>
* Copyright 2007-2008 Hamish Rodda <rodda@kde.org>
*
* 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) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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/>.
*/
#ifndef KSWIDGET_H
#define KSWIDGET_H
#include <QWidget>
#include <X11/X.h>
class KSWidget : public QWidget
{
Q_OBJECT
public:
explicit KSWidget( QWidget *parent = NULL, Qt::WindowFlags flags = 0 );
virtual ~KSWidget();
private:
Colormap colormap;
};
#endif

View file

@ -26,7 +26,7 @@
#include "testwin.h" #include "testwin.h"
TestWin::TestWin() TestWin::TestWin()
: KSWidget(0, Qt::X11BypassWindowManagerHint) : QWidget(0, Qt::X11BypassWindowManagerHint)
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
} }

View file

@ -26,9 +26,9 @@
#ifndef TESTWIN_H #ifndef TESTWIN_H
#define TESTWIN_H #define TESTWIN_H
#include "kswidget.h" #include <QWidget>
class TestWin : public KSWidget class TestWin : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public: