summaryrefslogtreecommitdiffstats
path: root/compton.h
diff options
context:
space:
mode:
authorRichard Grenville <[email protected]>2012-09-11 22:22:58 +0800
committerRichard Grenville <[email protected]>2012-09-11 22:22:58 +0800
commit00d29b07488415661f9306b9cd5fffc855c9c358 (patch)
tree16de17251ad876b8aeceb148f162f41f4bac6abf /compton.h
parentbbf35f81556f3309b320705db1cd98830b4cf552 (diff)
downloadtdebase-00d29b07488415661f9306b9cd5fffc855c9c358.tar.gz
tdebase-00d29b07488415661f9306b9cd5fffc855c9c358.zip
Bug fix: Issue #37, fix 5 opacity-related bugs
More details in the bug report. - Rewritten much of the opacity calculation, code cleanup. - Commandline switch --inactive_opacity_override to restore the old behavior in which inactive_opacity has higher priority than _NET_WM_OPACITY.
Diffstat (limited to 'compton.h')
-rw-r--r--compton.h41
1 files changed, 36 insertions, 5 deletions
diff --git a/compton.h b/compton.h
index 517dc462e..21cccd826 100644
--- a/compton.h
+++ b/compton.h
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <inttypes.h>
#include <math.h>
#include <sys/poll.h>
#include <sys/time.h>
@@ -44,6 +45,8 @@
* Types
*/
+typedef uint32_t opacity_t;
+
typedef enum {
WINTYPE_UNKNOWN,
WINTYPE_DESKTOP,
@@ -94,8 +97,12 @@ typedef struct _win {
int shadow_dy;
int shadow_width;
int shadow_height;
- unsigned int opacity;
+ opacity_t opacity;
+ /// Cached value of opacity window attribute.
+ opacity_t opacity_prop;
wintype window_type;
+ /// Whether the window is focused.
+ Bool focused;
unsigned long damage_sequence; /* sequence when damage was created */
Bool destroyed;
unsigned int left_width;
@@ -127,6 +134,7 @@ typedef struct _fade {
} fade;
extern int root_height, root_width;
+
/**
* Functions
*/
@@ -134,6 +142,11 @@ extern int root_height, root_width;
// inline functions must be made static to compile correctly under clang:
// http://clang.llvm.org/compatibility.html#inline
+/**
+ * Normalize a double value to 0.\ 0 - 1.\ 0.
+ *
+ * @param d double value to normalize
+ */
static inline double normalize_d(double d) {
if (d > 1.0)
return 1.0;
@@ -143,6 +156,23 @@ static inline double normalize_d(double d) {
return d;
}
+/**
+ * Check if a window ID exists in an array of window IDs.
+ *
+ * @param arr the array of window IDs
+ * @param count amount of elements in the array
+ * @param wid window ID to search for
+ */
+static inline Bool array_wid_exists(const Window *arr,
+ int count, Window wid) {
+ while (count--) {
+ if (arr[count] == wid)
+ return True;
+ }
+
+ return False;
+}
+
static int
get_time_in_milliseconds();
@@ -263,8 +293,8 @@ unmap_callback(Display *dpy, win *w);
static void
unmap_win(Display *dpy, Window id, Bool fade);
-static unsigned int
-get_opacity_prop(Display *dpy, win *w, unsigned int def);
+opacity_t
+get_opacity_prop(Display *dpy, win *w, opacity_t def);
static double
get_opacity_percent(Display *dpy, win *w);
@@ -272,8 +302,9 @@ get_opacity_percent(Display *dpy, win *w);
static void
determine_mode(Display *dpy, win *w);
-static void
-set_opacity(Display *dpy, win *w, unsigned long opacity);
+void set_opacity(Display *dpy, win *w, opacity_t opacity);
+
+void calc_opacity(Display *dpy, win *w, Bool refetch_prop);
static void
add_win(Display *dpy, Window id, Window prev, Bool override_redirect);