twin/compton-tde: make XRandR support optional in compot-tde

pull/2/head
Alexander Golubev 11 years ago committed by Slávek Banko
parent 30252262ce
commit 7c55134dee

@ -12,8 +12,6 @@
if( NOT WITH_XRENDER ) if( NOT WITH_XRENDER )
tde_message_fatal( "xrender support is needed to build compton-tde.\n Pass -DWITH_XRENDER=ON to cmake arguments." ) tde_message_fatal( "xrender support is needed to build compton-tde.\n Pass -DWITH_XRENDER=ON to cmake arguments." )
elseif( NOT WITH_XRANDR )
tde_message_fatal( "xrandr support is needed to build compton-tde.\n Pass -DWITH_XRANDR=ON to cmake arguments." )
elseif( NOT WITH_XFIXES ) elseif( NOT WITH_XFIXES )
tde_message_fatal( "xfixes support is needed to build compton-tde.\n Pass -DWITH_XFIXES=ON to cmake arguments." ) tde_message_fatal( "xfixes support is needed to build compton-tde.\n Pass -DWITH_XFIXES=ON to cmake arguments." )
endif( ) endif( )
@ -29,6 +27,7 @@ include_directories(
# TDE to compton config option map # TDE to compton config option map
# WITH_XINNERAMA -> CONFIG_XINERAMA # WITH_XINNERAMA -> CONFIG_XINERAMA
# WITH_XRANDR -> CONFIG_XANDR
# WITH_OPENGL -> CONFIG_VSYNC_OPENGL # WITH_OPENGL -> CONFIG_VSYNC_OPENGL
# WITH_OPENGL -> CONFIG_VSYNC_OPENGL_GLSL # WITH_OPENGL -> CONFIG_VSYNC_OPENGL_GLSL
# WITH_OPENGL -> CONFIG_VSYNC_OPENGL_FBO # WITH_OPENGL -> CONFIG_VSYNC_OPENGL_FBO
@ -68,6 +67,11 @@ if( WITH_XINERAMA )
list( APPEND compton_LIBRARIES ${XINERAMA_LIBRARIES} ) list( APPEND compton_LIBRARIES ${XINERAMA_LIBRARIES} )
endif( ) endif( )
if( WITH_XRANDR )
set( CONFIG_XRANDR ${WITH_XRANDR} )
list( APPEND compton_LIBRARIES ${XRANDR_LIBRARIES} )
endif( )
if( WITH_PCRE ) if( WITH_PCRE )
set( CONFIG_REGEX_PCRE ${WITH_PCRE} ) set( CONFIG_REGEX_PCRE ${WITH_PCRE} )
set( CONFIG_REGEX_PCRE_JIT ${WITH_PCRE} ) set( CONFIG_REGEX_PCRE_JIT ${WITH_PCRE} )
@ -82,8 +86,7 @@ list( APPEND compton_LIBRARIES ${DBUS_LIBRARIES} )
tde_add_executable( compton-tde tde_add_executable( compton-tde
SOURCES ${compton_SRCS} SOURCES ${compton_SRCS}
LINK m ${compton_LIBRARIES} ${XRENDER_LIBRARIES} LINK m ${compton_LIBRARIES} ${XRENDER_LIBRARIES} ${XFIXES_LIBRARIES}
${XRANDR_LIBRARIES} ${XFIXES_LIBRARIES} ${XDAMAGE_LIBRARIES} ${XDAMAGE_LIBRARIES} ${XEXT_LIBRARIES} ${XCOMPOSITE_LIBRARIES}
${XEXT_LIBRARIES} ${XCOMPOSITE_LIBRARIES}
DESTINATION ${BIN_INSTALL_DIR} DESTINATION ${BIN_INSTALL_DIR}
) )

@ -106,12 +106,15 @@
#include <X11/extensions/Xdamage.h> #include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xrender.h> #include <X11/extensions/Xrender.h>
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/Xdbe.h> #include <X11/extensions/Xdbe.h>
#ifdef CONFIG_XSYNC #ifdef CONFIG_XSYNC
#include <X11/extensions/sync.h> #include <X11/extensions/sync.h>
#endif #endif
#ifdef CONFIG_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
#ifdef CONFIG_XINERAMA #ifdef CONFIG_XINERAMA
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#endif #endif
@ -921,12 +924,14 @@ typedef struct _session_t {
int shape_event; int shape_event;
/// Error base number for X Shape extension. /// Error base number for X Shape extension.
int shape_error; int shape_error;
#ifdef CONFIG_XRANDR
/// Whether X RandR extension exists. /// Whether X RandR extension exists.
bool randr_exists; bool randr_exists;
/// Event base number for X RandR extension. /// Event base number for X RandR extension.
int randr_event; int randr_event;
/// Error base number for X RandR extension. /// Error base number for X RandR extension.
int randr_error; int randr_error;
#endif // CONFIG_XRANDR
#ifdef CONFIG_VSYNC_OPENGL #ifdef CONFIG_VSYNC_OPENGL
/// Whether X GLX extension exists. /// Whether X GLX extension exists.
bool glx_exists; bool glx_exists;

@ -4543,6 +4543,7 @@ ev_shape_notify(session_t *ps, XShapeEvent *ev) {
update_reg_ignore_expire(ps, w); update_reg_ignore_expire(ps, w);
} }
#ifdef CONFIG_XRANDR
/** /**
* Handle ScreenChangeNotify events from X RandR extension. * Handle ScreenChangeNotify events from X RandR extension.
*/ */
@ -4561,6 +4562,7 @@ ev_screen_change_notify(session_t *ps,
} }
} }
} }
#endif // CONFIG_XRANDR
#if defined(DEBUG_EVENTS) || defined(DEBUG_RESTACK) #if defined(DEBUG_EVENTS) || defined(DEBUG_RESTACK)
/** /**
@ -4659,10 +4661,12 @@ ev_handle(session_t *ps, XEvent *ev) {
ev_shape_notify(ps, (XShapeEvent *) ev); ev_shape_notify(ps, (XShapeEvent *) ev);
break; break;
} }
#ifdef CONFIG_XRANDR
if (ps->randr_exists && ev->type == (ps->randr_event + RRScreenChangeNotify)) { if (ps->randr_exists && ev->type == (ps->randr_event + RRScreenChangeNotify)) {
ev_screen_change_notify(ps, (XRRScreenChangeNotifyEvent *) ev); ev_screen_change_notify(ps, (XRRScreenChangeNotifyEvent *) ev);
break; break;
} }
#endif // CONFIG_XRANDR
if (isdamagenotify(ps, ev)) { if (isdamagenotify(ps, ev)) {
ev_damage_notify(ps, (XDamageNotifyEvent *) ev); ev_damage_notify(ps, (XDamageNotifyEvent *) ev);
break; break;
@ -4762,9 +4766,14 @@ usage(int ret) {
" Detect _NET_WM_OPACITY on client windows, useful for window\n" " Detect _NET_WM_OPACITY on client windows, useful for window\n"
" managers not passing _NET_WM_OPACITY of client windows to frame\n" " managers not passing _NET_WM_OPACITY of client windows to frame\n"
" windows.\n" " windows.\n"
#ifndef CONFIG_XRANDR
#define WARNING " (AUTODETECTION DISABLED AT COMPILE TIME)"
#else
#define WARNING
#endif
"--refresh-rate val\n" "--refresh-rate val\n"
" Specify refresh rate of the screen. If not specified or 0, compton\n" " Specify refresh rate of the screen. If not specified or 0, compton\n"
" will try detecting this with X RandR extension.\n" " will try detecting this with X RandR extension."WARNING"\n"
"--vsync vsync-method\n" "--vsync vsync-method\n"
" Set VSync method. There are up to 4 VSync methods currently available.\n" " Set VSync method. There are up to 4 VSync methods currently available.\n"
" none = No VSync\n" " none = No VSync\n"
@ -6259,6 +6268,7 @@ init_atoms(session_t *ps) {
ps->atom_win_type_tde_transparent_to_desktop = get_atom(ps, "_TDE_TRANSPARENT_TO_DESKTOP"); ps->atom_win_type_tde_transparent_to_desktop = get_atom(ps, "_TDE_TRANSPARENT_TO_DESKTOP");
} }
#ifdef CONFIG_XRANDR
/** /**
* Update refresh rate info with X Randr extension. * Update refresh rate info with X Randr extension.
*/ */
@ -6277,6 +6287,7 @@ update_refresh_rate(session_t *ps) {
else else
ps->refresh_intv = 0; ps->refresh_intv = 0;
} }
#endif // CONFIG_XRANDR
/** /**
* Initialize refresh-rated based software optimization. * Initialize refresh-rated based software optimization.
@ -6291,10 +6302,12 @@ swopti_init(session_t *ps) {
if (ps->refresh_rate) if (ps->refresh_rate)
ps->refresh_intv = US_PER_SEC / ps->refresh_rate; ps->refresh_intv = US_PER_SEC / ps->refresh_rate;
#ifdef CONFIG_XRANDR
// Auto-detect refresh rate otherwise // Auto-detect refresh rate otherwise
if (!ps->refresh_rate && ps->randr_exists) { if (!ps->refresh_rate && ps->randr_exists) {
update_refresh_rate(ps); update_refresh_rate(ps);
} }
#endif // CONFIG_XRANDR
// Turn off vsync_sw if we can't get the refresh rate // Turn off vsync_sw if we can't get the refresh rate
if (!ps->refresh_rate) if (!ps->refresh_rate)
@ -7196,9 +7209,11 @@ session_init(session_t *ps_old, int argc, char **argv) {
.shape_exists = false, .shape_exists = false,
.shape_event = 0, .shape_event = 0,
.shape_error = 0, .shape_error = 0,
#ifdef CONFIG_XRANDR
.randr_exists = 0, .randr_exists = 0,
.randr_event = 0, .randr_event = 0,
.randr_error = 0, .randr_error = 0,
#endif // CONFIG_XRANDR
#ifdef CONFIG_VSYNC_OPENGL #ifdef CONFIG_VSYNC_OPENGL
.glx_exists = false, .glx_exists = false,
.glx_event = 0, .glx_event = 0,
@ -7371,11 +7386,15 @@ session_init(session_t *ps_old, int argc, char **argv) {
// Query X RandR // Query X RandR
if ((ps->o.sw_opti && !ps->o.refresh_rate) || ps->o.xinerama_shadow_crop) { if ((ps->o.sw_opti && !ps->o.refresh_rate) || ps->o.xinerama_shadow_crop) {
if (XRRQueryExtension(ps->dpy, &ps->randr_event, &ps->randr_error)) #ifdef CONFIG_XRANDR
ps->randr_exists = true; if (XRRQueryExtension(ps->dpy, &ps->randr_event, &ps->randr_error))
else ps->randr_exists = true;
printf_errf("(): No XRandR extension, automatic screen change " else
"detection impossible."); printf_errf("(): No XRandR extension, automatic screen change "
"detection impossible.");
#else // CONFIG_XRANDR
printf_errf("(): Xrandr support not compiled in.");
#endif // CONFIG_XRANDR
} }
// Query X DBE extension // Query X DBE extension
@ -7435,11 +7454,21 @@ session_init(session_t *ps_old, int argc, char **argv) {
if (ps->o.sw_opti) if (ps->o.sw_opti)
ps->o.sw_opti = swopti_init(ps); ps->o.sw_opti = swopti_init(ps);
#ifdef CONFIG_XRANDR
// Monitor screen changes if vsync_sw is enabled and we are using // Monitor screen changes if vsync_sw is enabled and we are using
// an auto-detected refresh rate, or when Xinerama features are enabled // an auto-detected refresh rate, or when Xinerama features are enabled
if (ps->randr_exists && ((ps->o.sw_opti && !ps->o.refresh_rate) if (ps->randr_exists && ((ps->o.sw_opti && !ps->o.refresh_rate)
|| ps->o.xinerama_shadow_crop)) || ps->o.xinerama_shadow_crop))
XRRSelectInput(ps->dpy, ps->root, RRScreenChangeNotifyMask); XRRSelectInput(ps->dpy, ps->root, RRScreenChangeNotifyMask);
#else
if( (ps->o.sw_opti && !ps->o.refresh_rate) ) {
printf_errf("(): Xrandr support not compiled in. Plese specify --refrash-rate manually");
}
if (ps->o.xinerama_shadow_crop) {
printf_errf("(): due to Xrandr support not compiled in."
" Xinerama features may malfunction on changing screen size.");
}
#endif // CONFIG_XRANDR
// Initialize VSync // Initialize VSync
if (!vsync_init(ps)) if (!vsync_init(ps))

@ -32,5 +32,7 @@
// Whether to enable GLX Sync support. // Whether to enable GLX Sync support.
#cmakedefine CONFIG_GLX_XSYNC 1 #cmakedefine CONFIG_GLX_XSYNC 1
// Whether to enable Xranr support
#cmakedefine CONFIG_XRANDR 1
// Whether to enable Xinerama support // Whether to enable Xinerama support
#cmakedefine CONFIG_XINERAMA 1 #cmakedefine CONFIG_XINERAMA 1

Loading…
Cancel
Save