summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-15 22:06:56 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-15 22:06:56 +0200
commitc78cb17e2a8055f71d210e719e72ace7e9fb7b2e (patch)
treeb763599952d8ae94f6b32f1f2f5aea87e4f764fa
parentCython side of Windows GDI support (diff)
downloadblueshift-c78cb17e2a8055f71d210e719e72ace7e9fb7b2e.tar.gz
blueshift-c78cb17e2a8055f71d210e719e72ace7e9fb7b2e.tar.bz2
blueshift-c78cb17e2a8055f71d210e719e72ace7e9fb7b2e.tar.xz
fix errors and warnings
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--Makefile10
-rw-r--r--src/blueshift_w32gdi.pyx4
-rw-r--r--src/blueshift_w32gdi_c.c10
-rw-r--r--src/blueshift_w32gdi_c.h2
-rw-r--r--src/fake_w32gdi.c12
5 files changed, 24 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index d0023f3..fa273a3 100644
--- a/Makefile
+++ b/Makefile
@@ -132,6 +132,10 @@ obj/%.o: src/%.c
@mkdir -p obj
$(CC) $(FLAGS) $(CWARN) -c -o $@ $<
+obj/%.o: src/%.c src/%.h
+ @mkdir -p obj
+ $(CC) $(FLAGS) $(CWARN) -c -o $@ $<
+
obj/%_c.o: src/%_c.c src/%_c.h
@mkdir -p obj
$(CC) $(FLAGS) $(CWARN) -c -o $@ $<
@@ -141,9 +145,11 @@ obj/%.o: obj/%.c
$(CC) $(FLAGS) -c -o $@ $<
ifeq ($(FAKE_W32),y)
-obj/blueshift_w32gdi_c.o: FLAGS+=-DFAKE_W32GDI obj/fake_w32gdi.o obj/fake_w32gdi.h
+obj/blueshift_w32gdi_c.o: src/blueshift_w32gdi_c.c src/blueshift_w32gdi_c.h \
+ obj/fake_w32gdi.o src/fake_w32gdi.h
+ @mkdir -p bin
+ $(CC) $(FLAGS) $$($(PKGCONFIG) --libs $($(LIBS_))) -shared -DFAKE_W32GDI -o $@ $^
endif
-obj/fake_w32gdi.o: obj/fake_w32gdi.h
# Build rules for Cython source files
diff --git a/src/blueshift_w32gdi.pyx b/src/blueshift_w32gdi.pyx
index 753bd1c..25e12b8 100644
--- a/src/blueshift_w32gdi.pyx
+++ b/src/blueshift_w32gdi.pyx
@@ -92,7 +92,7 @@ def w32gdi_read(int use_crtc):
'''
cdef uint16_t* got
# Read the current curves
- got = blueshift_w32_read(use_crtc)
+ got = blueshift_w32gdi_read(use_crtc)
if got is NULL:
raise Exception()
# Convert to Python integer lists
@@ -127,7 +127,7 @@ def w32gdi_apply(crtc_indices, r_curve, g_curve, b_curve):
# For each selected CRTC,
for crtc_index in crtc_indices:
# apply curves.
- rc |= blueshift_w32gdi_apply(crtc_index, r_c, g_c, b_c)
+ rc |= blueshift_w32gdi_apply(crtc_index, rgb_c)
return rc
diff --git a/src/blueshift_w32gdi_c.c b/src/blueshift_w32gdi_c.c
index 3b05569..d304b25 100644
--- a/src/blueshift_w32gdi_c.c
+++ b/src/blueshift_w32gdi_c.c
@@ -38,6 +38,7 @@ static HDC* crtcs;
int blueshift_w32gdi_open(void)
{
int c;
+ HDC hDC;
DISPLAY_DEVICE display;
display.cb = sizeof(DISPLAY_DEVICE);
@@ -47,7 +48,7 @@ int blueshift_w32gdi_open(void)
if (crtc_count == 0)
{
- crtcs == NULL;
+ crtcs = NULL;
return 0;
}
@@ -73,8 +74,8 @@ int blueshift_w32gdi_open(void)
crtc_count = c;
return 1;
}
- *(crtcs + c) = CreateDC(TEXT("DISPLAY"), display.DeviceName, NULL, NULL);
- if (*(crtcs + c) == NULL)
+ hDC = *(crtcs + c) = CreateDC(TEXT("DISPLAY"), display.DeviceName, NULL, NULL);
+ if (hDC == NULL)
{
fprintf(stderr, "Unable to open device context\n");
crtc_count = c;
@@ -85,7 +86,7 @@ int blueshift_w32gdi_open(void)
if (GetDeviceCaps(hDC, COLORMGMTCAPS) != CM_GAMMA_RAMP)
{
fprintf(stderr, "CRTC %i does not support gamma ramps\n", c);
- ReleaseDC(NULL, *(crtcs + c));
+ ReleaseDC(NULL, hDC);
crtc_count = c;
return 1;
}
@@ -171,6 +172,7 @@ int blueshift_w32gdi_apply(int use_crtc, uint16_t* rgb_curves)
*/
void blueshift_w32gdi_close(void)
{
+ int c;
for (c = 0; c < crtc_count; c++)
ReleaseDC(NULL, *(crtcs + c));
if (crtcs != NULL)
diff --git a/src/blueshift_w32gdi_c.h b/src/blueshift_w32gdi_c.h
index 4e92632..c6c6909 100644
--- a/src/blueshift_w32gdi_c.h
+++ b/src/blueshift_w32gdi_c.h
@@ -21,7 +21,7 @@
# define WINVER 0x0500
#endif
#ifdef FAKE_W32GDI
-# include "fake-w32gdi.h"
+# include "fake_w32gdi.h"
#else
# include <windows.h>
# include <wingdi.h>
diff --git a/src/fake_w32gdi.c b/src/fake_w32gdi.c
index df8fe7e..de768e7 100644
--- a/src/fake_w32gdi.c
+++ b/src/fake_w32gdi.c
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "fake-w32gdi.h"
+#include "fake_w32gdi.h"
#include <stdio.h>
#include <stdlib.h>
@@ -86,8 +86,7 @@ BOOL SetDeviceGammaRamp(HDC hDC, LPVOID lpRamp)
((uint16_t *)lpRamp) + 0 * GAMMA_RAMP_SIZE,
((uint16_t *)lpRamp) + 1 * GAMMA_RAMP_SIZE,
((uint16_t *)lpRamp) + 2 * GAMMA_RAMP_SIZE);
- xcb_generic_error_t* error = xcb_request_check(conn, gamma_cookie);
- return error == NULL ? TRUE : FALSE;
+ return xcb_request_check(conn, gamma_cookie) == NULL ? TRUE : FALSE;
}
@@ -121,13 +120,15 @@ BOOL GetDeviceGammaRamp(HDC hDC, LPVOID lpRamp)
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd183490(v=vs.85).aspx */
HDC CreateDC(LPCTSTR lpszDriver, LPCTSTR lpszDevice, void *lpszOutput, void *lpInitData)
{
+ int crtc_index;
+
(void) lpszOutput;
(void) lpInitData;
if (strcmp(lpszDriver, "DISPLAY"))
return NULL;
- int crtc_index = atoi(lpszDevice);
+ crtc_index = atoi(lpszDevice);
if (dc_count == 0)
{
@@ -170,9 +171,10 @@ HDC CreateDC(LPCTSTR lpszDriver, LPCTSTR lpszDevice, void *lpszOutput, void *lpI
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd162609(v=vs.85).aspx */
BOOL EnumDisplayDevices(LPCTSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICE lpDisplayDevice, DWORD dwFlags)
{
+ size_t count = (size_t)crtc_count;
+
(void) dwFlags;
- size_t count = (size_t)crtc_count;
if (lpDevice != NULL)
{
fprintf(stderr, "lpDevice (argument 1) for EnumDisplayDevices should be NULL\n");