mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
kdeplasma-addons: remove redundant X11 check
side note: X11 library contains the implementation of functions declared in the Xutil header Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
6a60591ff2
commit
7ca60a87c1
4 changed files with 30 additions and 47 deletions
|
@ -1,25 +1,20 @@
|
||||||
project(plasma-kolourpicker)
|
project(plasma-kolourpicker)
|
||||||
|
|
||||||
set(KOLOURPICKER_X11_LIB FALSE)
|
|
||||||
if(X11_FOUND AND X11_Xutil_FOUND)
|
|
||||||
set(KOLOURPICKER_X11_LIB TRUE)
|
|
||||||
include_directories(${X11_Xutil_INCLUDE_PATH})
|
|
||||||
endif(X11_FOUND AND X11_Xutil_FOUND)
|
|
||||||
|
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/config-kolourpicker.h.cmake
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/config-kolourpicker.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(kolourpicker_SRCS
|
set(kolourpicker_SRCS
|
||||||
kolourpicker.cpp
|
kolourpicker.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
kde4_add_plugin(plasma_applet_kolourpicker ${kolourpicker_SRCS})
|
kde4_add_plugin(plasma_applet_kolourpicker ${kolourpicker_SRCS})
|
||||||
target_link_libraries(plasma_applet_kolourpicker KDE4::plasma KDE4::kio)
|
target_link_libraries(plasma_applet_kolourpicker
|
||||||
if(KOLOURPICKER_X11_LIB)
|
KDE4::plasma KDE4::kio
|
||||||
target_link_libraries(plasma_applet_kolourpicker ${X11_X11_LIB})
|
${X11_X11_LIB}
|
||||||
endif(KOLOURPICKER_X11_LIB)
|
)
|
||||||
|
|
||||||
install(TARGETS plasma_applet_kolourpicker DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
install(
|
||||||
install(FILES plasma-kolourpicker-default.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
|
TARGETS plasma_applet_kolourpicker
|
||||||
|
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES plasma-kolourpicker-default.desktop
|
||||||
|
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#ifndef CONFIG_KOLOURPICKER_H
|
|
||||||
#define CONFIG_KOLOURPICKER_H
|
|
||||||
|
|
||||||
#cmakedefine KOLOURPICKER_X11_LIB 1
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -31,12 +31,11 @@
|
||||||
|
|
||||||
#include <plasma/widgets/toolbutton.h>
|
#include <plasma/widgets/toolbutton.h>
|
||||||
|
|
||||||
#include <config-kolourpicker.h>
|
#if defined(Q_WS_X11)
|
||||||
|
# include <X11/Xlib.h>
|
||||||
#if defined(KOLOURPICKER_X11_LIB)
|
# include <X11/Xutil.h>
|
||||||
#include <X11/Xlib.h>
|
# include <fixx11h.h>
|
||||||
#include <X11/Xutil.h>
|
# include <QX11Info>
|
||||||
#include <QX11Info>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static KMenu* buildMenuForColor(const QColor &color)
|
static KMenu* buildMenuForColor(const QColor &color)
|
||||||
|
@ -71,12 +70,8 @@ static KMenu* buildMenuForColor(const QColor &color)
|
||||||
|
|
||||||
static QColor pickColor(const QPoint &point)
|
static QColor pickColor(const QPoint &point)
|
||||||
{
|
{
|
||||||
#if defined(KOLOURPICKER_X11_LIB)
|
#if defined(Q_WS_X11)
|
||||||
/*
|
// use the X11 API directly for performance reasons
|
||||||
It seems the Qt4 stuff returns a null grabbed pixmap when the Display
|
|
||||||
has ARGB visuals.
|
|
||||||
Then, access directly to the screen pixels using the X API.
|
|
||||||
*/
|
|
||||||
Window root = RootWindow(QX11Info::display(), QX11Info::appScreen());
|
Window root = RootWindow(QX11Info::display(), QX11Info::appScreen());
|
||||||
XImage *ximg = XGetImage(QX11Info::display(), root, point.x(), point.y(), 1, 1, -1, ZPixmap);
|
XImage *ximg = XGetImage(QX11Info::display(), root, point.x(), point.y(), 1, 1, -1, ZPixmap);
|
||||||
unsigned long xpixel = XGetPixel(ximg, 0, 0);
|
unsigned long xpixel = XGetPixel(ximg, 0, 0);
|
||||||
|
@ -96,16 +91,16 @@ static QColor pickColor(const QPoint &point)
|
||||||
|
|
||||||
class ColorIconEngine : public QIconEngine
|
class ColorIconEngine : public QIconEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColorIconEngine(const QColor &color);
|
ColorIconEngine(const QColor &color);
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
|
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
|
||||||
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
||||||
|
|
||||||
virtual QIconEngine *clone() const;
|
virtual QIconEngine *clone() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QColor m_color;
|
QColor m_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
ColorIconEngine::ColorIconEngine(const QColor &color)
|
ColorIconEngine::ColorIconEngine(const QColor &color)
|
||||||
|
|
|
@ -14,11 +14,10 @@
|
||||||
|
|
||||||
#include <qcolor.h>
|
#include <qcolor.h>
|
||||||
#include <qhash.h>
|
#include <qhash.h>
|
||||||
#include <QString>
|
#include <qstring.h>
|
||||||
#include <QColor>
|
#include <qcolor.h>
|
||||||
|
#include <qmenu.h>
|
||||||
#include <QMenu>
|
#include <qwidget.h>
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue