From 10d4c2d2cb5742b214f93ba49aafb703eb86f1bc Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 22 Oct 2012 06:35:02 -0500 Subject: revert to c7ca345 --- compton.h | 198 +++++++------------------------------------------------------- 1 file changed, 22 insertions(+), 176 deletions(-) (limited to 'compton.h') diff --git a/compton.h b/compton.h index 6aac338e9..83b78769e 100644 --- a/compton.h +++ b/compton.h @@ -26,10 +26,6 @@ // #define CONFIG_REGEX_PCRE_JIT 1 // Whether to enable parsing of configuration files using libconfig // #define CONFIG_LIBCONFIG 1 -// Whether to enable DRM VSync support -// #define CONFIG_VSYNC_DRM 1 -// Whether to enable OpenGL VSync support -// #define CONFIG_VSYNC_OPENGL 1 // === Includes === @@ -48,7 +44,6 @@ #include #include #include -#include #include @@ -74,25 +69,10 @@ #include #include #include -#include - -#ifdef CONFIG_VSYNC_DRM -#include -// We references some definitions in drm.h, which could also be found in -// /usr/src/linux/include/drm/drm.h, but that path is probably even less -// reliable than libdrm -#include -#include -#include -#endif - -#ifdef CONFIG_VSYNC_OPENGL -#include -#endif // === Constants === -#if !(COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2) -#error libXcomposite version unsupported +#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2 +#define HAS_NAME_WINDOW_PIXMAP 1 #endif #define ROUNDED_PERCENT 0.05 @@ -109,13 +89,6 @@ extern struct timeval time_start; #define WINDOW_TRANS 1 #define WINDOW_ARGB 2 -#define FADE_DELTA_TOLERANCE 0.2 -#define VSYNC_SW_TOLERANCE 1000 - -#define NS_PER_SEC 1000000000L -#define US_PER_SEC 1000000L -#define MS_PER_SEC 1000 - // Window flags // Window size is changed @@ -183,7 +156,9 @@ typedef struct _win { struct _win *next; Window id; Window client_win; +#if HAS_NAME_WINDOW_PIXMAP Pixmap pixmap; +#endif XWindowAttributes a; #if CAN_DO_USABLE Bool usable; /* mapped and all damaged at one point */ @@ -219,12 +194,10 @@ typedef struct _win { opacity_t opacity; /// Target window opacity. opacity_t opacity_tgt; + /// Opacity of current alpha_pict. + opacity_t opacity_cur; /// Cached value of opacity window attribute. opacity_t opacity_prop; - /// Cached value of opacity window attribute on client window. For - /// broken window managers not transferring client window's - /// _NET_WM_OPACITY value - opacity_t opacity_prop_client; /// Alpha mask Picture to render window with opacity. Picture alpha_pict; @@ -240,6 +213,8 @@ typedef struct _win { // Frame-opacity-related members /// Current window frame opacity. Affected by window opacity. double frame_opacity; + /// Opacity of current frame_alpha_pict. + opacity_t frame_opacity_cur; /// Alpha mask Picture to render window frame with opacity. Picture frame_alpha_pict; /// Frame widths. Determined by client window attributes. @@ -250,6 +225,8 @@ typedef struct _win { Bool shadow; /// Opacity of the shadow. Affected by window opacity and frame opacity. double shadow_opacity; + /// Opacity of current shadow_pict. + double shadow_opacity_cur; /// X offset of shadow. Affected by commandline argument. int shadow_dx; /// Y offset of shadow. Affected by commandline argument. @@ -274,27 +251,10 @@ typedef struct _win { Bool need_configure; XConfigureEvent queue_configure; - /// Region to be ignored when painting. Basically the region where - /// higher opaque windows will paint upon. Depends on window frame - /// opacity state, window geometry, window mapped/unmapped state, - /// window mode, of this and all higher windows. - XserverRegion reg_ignore; struct _win *prev_trans; } win; -typedef enum _vsync_t { - VSYNC_NONE, - VSYNC_SW, - VSYNC_DRM, - VSYNC_OPENGL, -} vsync_t; - -#ifdef CONFIG_VSYNC_OPENGL -typedef int (*f_WaitVideoSync) (int, int, unsigned *); -typedef int (*f_GetVideoSync) (unsigned *); -#endif - typedef struct _options { // General char *display; @@ -309,12 +269,6 @@ typedef struct _options { /// Whether to work under synchronized mode for debugging. Bool synchronize; - // VSync - /// User-specified refresh rate. - int refresh_rate; - /// VSync method to use; - vsync_t vsync; - // Shadow Bool wintype_shadow[NUM_WINTYPES]; /// Red, green and blue tone of the shadow. @@ -348,16 +302,9 @@ typedef struct _options { /// Whether inactive_opacity overrides the opacity set by window /// attributes. Bool inactive_opacity_override; - /// Frame opacity. Relative to window opacity, also affects shadow - /// opacity. double frame_opacity; - /// Whether to detect _NET_WM_OPACITY on client windows. Used on window - /// managers that don't pass _NET_WM_OPACITY to frame windows. - Bool detect_client_opacity; /// How much to dim an inactive window. 0.0 - 1.0, 0 to disable. double inactive_dim; - /// Step for pregenerating alpha pictures. 0.01 - 1.0. - double alpha_step; // Calculated /// Whether compton needs to track focus changes. @@ -407,16 +354,6 @@ set_ignore(Display *dpy, unsigned long sequence); static int should_ignore(Display *dpy, unsigned long sequence); -/** - * Subtract two unsigned long values. - * - * Truncate to 0 if the result is negative. - */ -static inline unsigned long -sub_unslong(unsigned long a, unsigned long b) { - return (a > b) ? a - b : 0; -} - /** * Set a Bool array of all wintypes to true. */ @@ -578,41 +515,6 @@ timeval_subtract(struct timeval *result, return x->tv_sec < y->tv_sec; } -/* - * Subtracting two struct timespec values. - * - * Taken from glibc manual. - * - * Subtract the `struct timespec' values X and Y, - * storing the result in RESULT. - * Return 1 if the difference is negative, otherwise 0. - */ -static inline int -timespec_subtract(struct timespec *result, - struct timespec *x, - struct timespec *y) { - /* Perform the carry for the later subtraction by updating y. */ - if (x->tv_nsec < y->tv_nsec) { - int nsec = (y->tv_nsec - x->tv_nsec) / NS_PER_SEC + 1; - y->tv_nsec -= NS_PER_SEC * nsec; - y->tv_sec += nsec; - } - - if (x->tv_nsec - y->tv_nsec > NS_PER_SEC) { - int nsec = (x->tv_nsec - y->tv_nsec) / NS_PER_SEC; - y->tv_nsec += NS_PER_SEC * nsec; - y->tv_sec -= nsec; - } - - /* Compute the time remaining to wait. - tv_nsec is certainly positive. */ - result->tv_sec = x->tv_sec - y->tv_sec; - result->tv_nsec = x->tv_nsec - y->tv_nsec; - - /* Return 1 if result is negative. */ - return x->tv_sec < y->tv_sec; -} - /** * Print time passed since program starts execution. * @@ -675,7 +577,7 @@ free_damage(Display *dpy, Damage *p) { } static unsigned long -get_time_ms(void); +get_time_in_milliseconds(void); static int fade_timeout(void); @@ -729,7 +631,8 @@ solid_picture(Display *dpy, Bool argb, double a, static inline bool is_normal_win(const win *w) { return (WINTYPE_NORMAL == w->window_type - || WINTYPE_UTILITY == w->window_type); + || WINTYPE_UTILITY == w->window_type + || WINTYPE_UNKNOWN == w->window_type); } /** @@ -858,6 +761,9 @@ repair_win(Display *dpy, win *w); static wintype get_wintype_prop(Display * dpy, Window w); +static wintype +determine_wintype(Display *dpy, Window w); + static void map_win(Display *dpy, Window id, unsigned long sequence, Bool fade, @@ -869,14 +775,16 @@ finish_map_win(Display *dpy, win *w); static void finish_unmap_win(Display *dpy, win *w); +#if HAS_NAME_WINDOW_PIXMAP static void unmap_callback(Display *dpy, win *w); +#endif static void unmap_win(Display *dpy, Window id, Bool fade); static opacity_t -wid_get_opacity_prop(Display *dpy, Window wid, opacity_t def); +get_opacity_prop(Display *dpy, win *w, opacity_t def); static double get_opacity_percent(Display *dpy, win *w); @@ -927,8 +835,10 @@ circulate_win(Display *dpy, XCirculateEvent *ce); static void finish_destroy_win(Display *dpy, Window id); +#if HAS_NAME_WINDOW_PIXMAP static void destroy_callback(Display *dpy, win *w); +#endif static void destroy_win(Display *dpy, Window id, Bool fade); @@ -970,7 +880,7 @@ static void usage(void); static void -register_cm(Bool want_glxct); +register_cm(int scr); inline static void ev_focus_in(XFocusChangeEvent *ev); @@ -1037,39 +947,6 @@ copy_region(Display *dpy, XserverRegion oldregion) { return region; } -/** - * Dump a region. - */ -static inline void -dump_region(Display *dpy, XserverRegion region) { - int nrects = 0, i; - XRectangle *rects = XFixesFetchRegion(dpy, region, &nrects); - if (!rects) - return; - - for (i = 0; i < nrects; ++i) - printf("Rect #%d: %8d, %8d, %8d, %8d\n", i, rects[i].x, rects[i].y, - rects[i].width, rects[i].height); - - XFree(rects); -} - -/** - * Check if a region is empty. - * - * Keith Packard said this is slow: - * http://lists.freedesktop.org/archives/xorg/2007-November/030467.html - */ -static inline Bool -is_region_empty(Display *dpy, XserverRegion region) { - int nrects = 0; - XRectangle *rects = XFixesFetchRegion(dpy, region, &nrects); - - XFree(rects); - - return !nrects; -} - /** * Add a window to damaged area. * @@ -1125,34 +1002,3 @@ get_cfg(int argc, char *const *argv); static void get_atoms(void); - -static void -update_refresh_rate(Display *dpy); - -static Bool -vsync_sw_init(void); - -static struct timespec -vsync_sw_ntimeout(int timeout); - -static Bool -vsync_drm_init(void); - -#ifdef CONFIG_VSYNC_DRM -static int -vsync_drm_wait(void); -#endif - -static Bool -vsync_opengl_init(void); - -#ifdef CONFIG_VSYNC_OPENGL -static void -vsync_opengl_wait(void); -#endif - -static Bool -vsync_wait(Display *dpy, struct pollfd *fd, int timeout); - -static void -init_alpha_picts(Display *dpy); -- cgit v1.2.1