summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blueshift_randr.pyx33
-rw-r--r--src/blueshift_randr_c.c38
-rw-r--r--src/blueshift_randr_c.h12
-rw-r--r--src/monitor.py2
4 files changed, 40 insertions, 45 deletions
diff --git a/src/blueshift_randr.pyx b/src/blueshift_randr.pyx
index de6c54f..7de1d13 100644
--- a/src/blueshift_randr.pyx
+++ b/src/blueshift_randr.pyx
@@ -40,16 +40,15 @@ Gets the current colour curves
needs to be free:d. `NULL` on error.
'''
-cdef extern int blueshift_randr_apply(unsigned long long int use_crtcs,
- uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve)
+cdef extern int blueshift_randr_apply(int use_crtc, uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve)
'''
Apply stage of colour curve control
-@param use_crtcs Mask of CRTC:s to use
-@param r_curve The red colour curve
-@param g_curve The green colour curve
-@param b_curve The blue colour curve
-@return Zero on success
+@param use_crtc The CRTC to use, -1 for all
+@param r_curve The red colour curve
+@param g_curve The green colour curve
+@param b_curve The blue colour curve
+@return Zero on success
'''
cdef extern void blueshift_randr_close()
@@ -126,23 +125,27 @@ def randr_read(int use_crtc):
return (r, g, b)
-def randr_apply(unsigned long long use_crtcs, r_curve, g_curve, b_curve):
+def randr_apply(crtc_indices, r_curve, g_curve, b_curve):
'''
Apply stage of colour curve control
- @param use_crtcs Mask of CRTC:s to use
- @param r_curve:list<int> The red colour curve
- @param g_curve:list<int> The green colour curve
- @param b_curve:list<int> The blue colour curve
- @return Zero on success
+ @param crtc_indices:list<int> The indices of the CRTC:s to control, -1 for all
+ @param r_curve:list<int> The red colour curve
+ @param g_curve:list<int> The green colour curve
+ @param b_curve:list<int> The blue colour curve
+ @return Zero on success
'''
# Convert curves to 16-bit C integers
for i in range(256):
r_c[i] = r_curve[i] & 0xFFFF
g_c[i] = g_curve[i] & 0xFFFF
b_c[i] = b_curve[i] & 0xFFFF
- # Apply curves
- return blueshift_randr_apply(use_crtcs, r_c, g_c, b_c)
+ rc = 0
+ # For each selected CRTC,
+ for crtc_index in crtc_indices:
+ # apply curves.
+ rc |= blueshift_randr_apply(crtc_index, r_c, g_c, b_c)
+ return rc
def randr_close():
diff --git a/src/blueshift_randr_c.c b/src/blueshift_randr_c.c
index 0c99533..23035a3 100644
--- a/src/blueshift_randr_c.c
+++ b/src/blueshift_randr_c.c
@@ -232,32 +232,31 @@ uint16_t* blueshift_randr_read(int use_crtc)
/**
* Apply stage of colour curve control
*
- * @param use_crtcs Mask of CRTC:s to use
- * @param r_curve The red colour curve
- * @param g_curve The green colour curve
- * @param b_curve The blue colour curve
- * @return Zero on success
+ * @param use_crtc The CRTC to use, -1 of all
+ * @param r_curve The red colour curve
+ * @param g_curve The green colour curve
+ * @param b_curve The blue colour curve
+ * @return Zero on success
*/
-int blueshift_randr_apply(uint64_t use_crtcs, uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve)
+int blueshift_randr_apply(int use_crtc, uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve)
{
- blueshift_randr_crtc_t* crtcs_ = crtcs;
+ /* Select first CRTC */
+ blueshift_randr_crtc_t* crtc_start = crtcs + (use_crtc < 0 ? 0 : use_crtc);
+ /* Select exclusive last CRTC */
+ blueshift_randr_crtc_t* crtc_end = use_crtc < 0 ? crtcs_end : (crtc_start + 1);
+
+ blueshift_randr_crtc_t* crtc;
xcb_void_cookie_t gamma_set_cookie;
- /* Use CRTC:s */
+ /* Apply for all selected CRTC:s */
- while (crtcs_ != crtcs_end)
+ for (crtc = crtc_start; crtc != crtc_end; crtc++)
{
- /* Check whether we should use the CRTC */
-
- if ((use_crtcs & 1) == 0)
- goto next_crtc;
-
-
/* Apply curves */
- gamma_set_cookie = xcb_randr_set_crtc_gamma_checked(connection, *(crtcs_->crtc), crtcs_->curve_size,
+ gamma_set_cookie = xcb_randr_set_crtc_gamma_checked(connection, *(crtc->crtc), crtc->curve_size,
r_curve, g_curve, b_curve);
error = xcb_request_check(connection, gamma_set_cookie);
@@ -266,13 +265,6 @@ int blueshift_randr_apply(uint64_t use_crtcs, uint16_t* r_curve, uint16_t* g_cur
fprintf(stderr, "RandR CRTC control returned %i\n", error->error_code);
return 1;
}
-
-
- /* Next CRTC */
-
- next_crtc:
- crtcs_++;
- use_crtcs >>= 1;
}
return 0;
diff --git a/src/blueshift_randr_c.h b/src/blueshift_randr_c.h
index db12770..8ab21f3 100644
--- a/src/blueshift_randr_c.h
+++ b/src/blueshift_randr_c.h
@@ -81,13 +81,13 @@ uint16_t* blueshift_randr_read(int use_crtc);
/**
* Apply stage of colour curve control
*
- * @param use_crtcs Mask of CRTC:s to use
- * @param r_curve The red colour curve
- * @param g_curve The green colour curve
- * @param b_curve The blue colour curve
- * @return Zero on success
+ * @param use_crtc The CRTC to use, -1 for all
+ * @param r_curve The red colour curve
+ * @param g_curve The green colour curve
+ * @param b_curve The blue colour curve
+ * @return Zero on success
*/
-int blueshift_randr_apply(uint64_t use_crtcs, uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve);
+int blueshift_randr_apply(int use_crtc, uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve);
/**
* Resource freeing stage of colour curve control
diff --git a/src/monitor.py b/src/monitor.py
index e94c1e8..fa3d4c5 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -152,7 +152,7 @@ def randr(*crtcs, screen = 0, display = None):
from blueshift_randr import randr_open, randr_apply, randr_close
global randr_opened
# Select CRTC:s
- crtcs = sum([1 << i for i in crtcs]) if len(crtcs) > 0 else ((1 << 64) - 1)
+ crtcs = list(crtcs) if len(crtcs) > 0 else [-1]
# Convert curves to [0, 0xFFFF] integer lists
(R_curve, G_curve, B_curve) = translate_to_integers()