Skip to content

Commit

Permalink
[x11] better x11 dependency handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jan 21, 2014
1 parent b3d0546 commit 7d24122
Show file tree
Hide file tree
Showing 33 changed files with 531 additions and 375 deletions.
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,33 @@ endif()
macro(qtc_check_x11)
find_package(PkgConfig)
if(NOT PKG_CONFIG_FOUND)
message(WARNING "Cannot find pkg-conig, disable x11 support.")
set(QTC_ENABLE_X11 Off)
if(QTC_ENABLE_X11)
message(WARNING "Cannot find pkg-conig, disable x11 support.")
set(QTC_ENABLE_X11 Off)
endif()
set(QTC_X11_FOUND Off)
return()
endif()
unset(__pkg_config_checked_QTC_X11 CACHE)
# pkg_check_modules(QTC_X11 xcb x11-xcb xrender)
pkg_check_modules(QTC_X11 xcb x11-xcb)
if(NOT QTC_X11_FOUND)
if(QTC_ENABLE_X11)
pkg_check_modules(QTC_X11 xcb x11-xcb)
else()
pkg_check_modules(QTC_X11 xcb)
endif()
if(NOT QTC_X11_FOUND AND QTC_ENABLE_X11)
message(WARNING
"Cannot find required modules for x11, disable x11 support.")
set(QTC_ENABLE_X11 Off)
return()
endif()
endmacro()
if(QTC_ENABLE_X11)
qtc_check_x11()
qtc_check_x11()
if(QTC_X11_FOUND)
include_directories(${QTC_X11_INCLUDE_DIRS})
add_definitions(${QTC_X11_CFLAGS})
else()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/xcb-defs")
endif()

if(NOT ENABLE_QT4)
Expand All @@ -101,11 +112,6 @@ if(NOT ENABLE_QT5)
set(QTC_QT5_ENABLE_KWIN Off)
endif()

if(NOT QTC_ENABLE_X11 AND ENABLE_GTK2)
message(WARNING "Gtk2 style require QTC_ENABLE_X11 to be enabled.")
set(ENABLE_GTK2 Off)
endif()

if(ENABLE_GTK2)
find_package(PkgConfig REQUIRED)
unset(__pkg_config_checked_GTK2 CACHE)
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
26. Improve shadow gradient.
27. Fix chromium background color when non-custom color is used.
28. Only link to X11 libraries in `libqtcurve-utils.so`.
29. `QTC_ENABLE_X11` have not effect on any modules other than
`libqtcurve-utils.so` also making `libqtcurve-utils.so` API and ABI
compatible with and without X11 enabled.

## 1.8.17
1. **Add Qt5 support!!**.
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

3. `ENABLE_GTK2`:

Building QtCurve Gtk2 theme. Require `QTC_ENABLE_X11`.
Building QtCurve Gtk2 theme.

(Default: `On`)

Expand All @@ -31,6 +31,11 @@
Enable X11 support. Require `xcb`, `xlib-xcb`. Will cause
`libqtcurve-utils.so` to link to `libxcb`, `libX11-xcb` and `libX11`.

NOTE: this options will not affect any modules/libraries other than
`libqtcurve-utils.so`. `libqtcurve-utils.so` with/without the option
are API and ABI compatible although some functions will be NO-OP with
X11 disabled.

(Default: `On`)

5. `QTC_INSTALL_PO`:
Expand All @@ -48,7 +53,7 @@
7. `QTC_QT4_ENABLE_KWIN`:

Compile QtCurve qt4 kwin style. This will only have effect when KDE support
is turned on. Also require `QTC_ENABLE_X11`.
is turned on. Also require a X11 build of Qt4 and `libxcb` headers.

(Default: `On` if kwin header is found and KDE support is on,
`Off` otherwise)
Expand Down
12 changes: 4 additions & 8 deletions lib/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@ set(qtcurve_utils_SRCS
timer.c
map.c
fd_utils.c
process.c)
process.c
x11utils.c
x11helpers.c
x11wrap.c)
set(qtcurve_utils_LINKS
m rt dl ${LIBEXECINFO_LIBRARIES} pthread)

include_directories("${CMAKE_CURRENT_BINARY_DIR}")

if(QTC_ENABLE_X11)
set(qtcurve_utils_SRCS
${qtcurve_utils_SRCS}
x11utils.c
x11helpers.c
x11wrap.c)
set(qtcurve_utils_LINKS
${qtcurve_utils_LINKS}
${QTC_X11_LIBRARIES})
include_directories(${QTC_X11_INCLUDE_DIRS})
add_definitions(${QTC_X11_CFLAGS})
endif()

add_definitions("-DQTC_UTILS_INTERNAL -pthread")
Expand Down
85 changes: 84 additions & 1 deletion lib/utils/x11helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@
* see <http://www.gnu.org/licenses/>. *
*****************************************************************************/

#include "config.h"

#include "x11shadow_p.h"
#include "x11wmmove.h"
#include "x11blur.h"
#include "x11qtc.h"
#include "x11wrap.h"
#include "x11utils_p.h"

#ifdef QTC_ENABLE_X11

#include "log.h"
#include "number.h"
#include "shadow_p.h"
#include "x11utils_p.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>

Expand Down Expand Up @@ -267,3 +272,81 @@ qtcX11SetBgnd(xcb_window_t win, uint32_t prop)
XCB_ATOM_CARDINAL, 32, 1, &prop);
qtcX11Flush();
}

#else

QTC_EXPORT void
qtcX11ShadowInstallWithMargin(xcb_window_t win, const int margins[4])
{
QTC_UNUSED(win);
QTC_UNUSED(margins);
}

QTC_EXPORT void
qtcX11ShadowInstall(xcb_window_t win)
{
QTC_UNUSED(win);
}

QTC_EXPORT void
qtcX11ShadowUninstall(xcb_window_t win)
{
QTC_UNUSED(win);
}

// WM Move
QTC_EXPORT void
qtcX11MoveTrigger(xcb_window_t wid, uint32_t x, uint32_t y)
{
QTC_UNUSED(wid);
QTC_UNUSED(x);
QTC_UNUSED(y);
}

// Blur
QTC_EXPORT void
qtcX11BlurTrigger(xcb_window_t wid, bool enable, unsigned prop_num,
const uint32_t *props)
{
QTC_UNUSED(wid);
QTC_UNUSED(enable);
QTC_UNUSED(prop_num);
QTC_UNUSED(props);
}

QTC_EXPORT int32_t
qtcX11GetShortProp(xcb_window_t win, xcb_atom_t atom)
{
QTC_UNUSED(win);
QTC_UNUSED(atom);
return -1;
}

QTC_EXPORT void
qtcX11SetMenubarSize(xcb_window_t win, unsigned short s)
{
QTC_UNUSED(win);
QTC_UNUSED(s);
}

QTC_EXPORT void
qtcX11SetStatusBar(xcb_window_t win)
{
QTC_UNUSED(win);
}

QTC_EXPORT void
qtcX11SetOpacity(xcb_window_t win, unsigned short o)
{
QTC_UNUSED(win);
QTC_UNUSED(o);
}

QTC_EXPORT void
qtcX11SetBgnd(xcb_window_t win, uint32_t prop)
{
QTC_UNUSED(win);
QTC_UNUSED(prop);
}

#endif
125 changes: 114 additions & 11 deletions lib/utils/x11utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@

// TODO multi screen?

#include "x11utils_p.h"
#include "x11wrap.h"
#include "config.h"
#include "x11utils.h"

QTC_EXPORT xcb_atom_t qtc_x11_qtc_menubar_size;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_statusbar;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_titlebar_size;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_active_window;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_toggle_menubar;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_toggle_statusbar;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_opacity;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_bgnd;

#ifdef QTC_ENABLE_X11

#include "x11shadow_p.h"
#include "x11wrap.h"
#include "log.h"

#include "x11utils_p.h"
#include <X11/Xlib-xcb.h>
// #include <X11/Xutil.h>
// #include <X11/extensions/Xrender.h>
Expand All @@ -41,14 +54,6 @@ xcb_atom_t qtc_x11_net_wm_moveresize;
xcb_atom_t qtc_x11_net_wm_cm_s_default;
xcb_atom_t qtc_x11_kde_net_wm_shadow;
xcb_atom_t qtc_x11_kde_net_wm_blur_behind_region;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_menubar_size;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_statusbar;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_titlebar_size;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_active_window;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_toggle_menubar;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_toggle_statusbar;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_opacity;
QTC_EXPORT xcb_atom_t qtc_x11_qtc_bgnd;
static xcb_atom_t qtc_x11_xembed_info;

static const struct {
Expand Down Expand Up @@ -264,3 +269,101 @@ qtcX11RgbaVisual(unsigned long *colormap, int *map_entries, int screen)
return argbVisual;
}
#endif

#else

QTC_EXPORT bool
qtcX11Enabled()
{
return false;
}

QTC_EXPORT xcb_window_t
qtcX11RootWindow(int scrn_no)
{
QTC_UNUSED(scrn_no);
return 0;
}

QTC_EXPORT int
qtcX11DefaultScreenNo()
{
return -1;
}

QTC_EXPORT xcb_screen_t*
qtcX11DefaultScreen()
{
return NULL;
}

QTC_EXPORT xcb_screen_t*
qtcX11GetScreen(int screen_no)
{
QTC_UNUSED(screen_no);
return NULL;
}

QTC_EXPORT void
qtcX11InitXcb(xcb_connection_t *conn, int screen_no)
{
QTC_UNUSED(conn);
QTC_UNUSED(screen_no);
}

QTC_EXPORT void
qtcX11InitXlib(Display *disp)
{
QTC_UNUSED(disp);
}

QTC_EXPORT xcb_connection_t*
qtcX11GetConn()
{
return NULL;
}

QTC_EXPORT Display*
qtcX11GetDisp()
{
return NULL;
}

QTC_EXPORT void
qtcX11MapRaised(xcb_window_t win)
{
QTC_UNUSED(win);
}

QTC_EXPORT bool
qtcX11CompositingActive()
{
return false;
}

QTC_EXPORT bool
qtcX11HasAlpha(xcb_window_t win)
{
QTC_UNUSED(win);
return false;
}

QTC_EXPORT bool
qtcX11IsEmbed(xcb_window_t win)
{
QTC_UNUSED(win);
return false;
}

#if 0
QTC_EXPORT void*
qtcX11RgbaVisual(unsigned long *colormap, int *map_entries, int screen)
{
QTC_UNUSED(colormap);
QTC_UNUSED(map_entries);
QTC_UNUSED(screen);
return NULL;
}
#endif

#endif
Loading

0 comments on commit 7d24122

Please sign in to comment.