summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2012-03-23 23:12:56 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2012-03-23 23:12:56 -0700
commit1a88a58316edda16de7ced6d447c2a6e4c9c9c2d (patch)
treeebfd52f75e0ae110bc9310767e349eb002494dc7
parent5adf599c893e68a3057a6c4af507e4275dc6fca5 (diff)
XCode Formatting
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--hw/xquartz/GL/capabilities.c498
-rw-r--r--hw/xquartz/GL/capabilities.h2
-rw-r--r--hw/xquartz/GL/glcontextmodes.c532
-rw-r--r--hw/xquartz/GL/glcontextmodes.h12
-rw-r--r--hw/xquartz/GL/indirect.c338
-rw-r--r--hw/xquartz/GL/visualConfigs.c18
-rw-r--r--hw/xquartz/X11Application.h59
-rw-r--r--hw/xquartz/X11Application.m727
-rw-r--r--hw/xquartz/X11Controller.h69
-rw-r--r--hw/xquartz/X11Controller.m755
-rw-r--r--hw/xquartz/applewm.c333
-rw-r--r--hw/xquartz/applewmExt.h83
-rw-r--r--hw/xquartz/console_redirect.c227
-rw-r--r--hw/xquartz/console_redirect.h2
-rw-r--r--hw/xquartz/darwin.c274
-rw-r--r--hw/xquartz/darwin.h2
-rw-r--r--hw/xquartz/darwinEvents.c168
-rw-r--r--hw/xquartz/darwinEvents.h4
-rw-r--r--hw/xquartz/darwinXinput.c112
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c57
-rw-r--r--hw/xquartz/mach-startup/launchd_fd.c4
-rw-r--r--hw/xquartz/mach-startup/launchd_fd.h2
-rw-r--r--hw/xquartz/mach-startup/stub.c66
-rw-r--r--hw/xquartz/pbproxy/app-main.m70
-rw-r--r--hw/xquartz/pbproxy/main.m64
-rw-r--r--hw/xquartz/pbproxy/pbproxy.h54
-rw-r--r--hw/xquartz/pbproxy/x-input.m66
-rw-r--r--hw/xquartz/pbproxy/x-selection.h65
-rw-r--r--hw/xquartz/pbproxy/x-selection.m1199
-rw-r--r--hw/xquartz/pseudoramiX.c228
-rw-r--r--hw/xquartz/quartz.c101
-rw-r--r--hw/xquartz/quartz.h1
-rw-r--r--hw/xquartz/quartzCocoa.m14
-rw-r--r--hw/xquartz/quartzKeyboard.c188
-rw-r--r--hw/xquartz/quartzKeyboard.h1
-rw-r--r--hw/xquartz/quartzRandR.c126
-rw-r--r--hw/xquartz/quartzRandR.h2
-rw-r--r--hw/xquartz/quartzStartup.c8
-rw-r--r--hw/xquartz/xpr/appledri.c263
-rw-r--r--hw/xquartz/xpr/appledri.h21
-rw-r--r--hw/xquartz/xpr/appledristr.h249
-rw-r--r--hw/xquartz/xpr/dri.c552
-rw-r--r--hw/xquartz/xpr/dri.h22
-rw-r--r--hw/xquartz/xpr/driWrap.c267
-rw-r--r--hw/xquartz/xpr/driWrap.h49
-rw-r--r--hw/xquartz/xpr/dristruct.h10
-rw-r--r--hw/xquartz/xpr/x-hash.c141
-rw-r--r--hw/xquartz/xpr/x-hash.h68
-rw-r--r--hw/xquartz/xpr/x-hook.c94
-rw-r--r--hw/xquartz/xpr/x-hook.h54
-rw-r--r--hw/xquartz/xpr/x-list.c162
-rw-r--r--hw/xquartz/xpr/x-list.h56
-rw-r--r--hw/xquartz/xpr/xpr.h5
-rw-r--r--hw/xquartz/xpr/xprAppleWM.c48
-rw-r--r--hw/xquartz/xpr/xprCursor.c96
-rw-r--r--hw/xquartz/xpr/xprEvent.c2
-rw-r--r--hw/xquartz/xpr/xprEvent.h2
-rw-r--r--hw/xquartz/xpr/xprFrame.c132
-rw-r--r--hw/xquartz/xpr/xprScreen.c96
59 files changed, 4487 insertions, 4433 deletions
diff --git a/hw/xquartz/GL/capabilities.c b/hw/xquartz/GL/capabilities.c
index b718a4156..4cde1cd66 100644
--- a/hw/xquartz/GL/capabilities.c
+++ b/hw/xquartz/GL/capabilities.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Apple Inc.
+ * Copyright (c) 2008-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -40,13 +40,13 @@
static void handleBufferModes(struct glCapabilitiesConfig *c, GLint bufferModes) {
if(bufferModes & kCGLStereoscopicBit) {
- c->stereo = true;
+ c->stereo = true;
}
-
+
if(bufferModes & kCGLDoubleBufferBit) {
- c->buffers = 2;
+ c->buffers = 2;
} else {
- c->buffers = 1;
+ c->buffers = 1;
}
}
@@ -54,264 +54,264 @@ static void handleStencilModes(struct glCapabilitiesConfig *c, GLint smodes) {
int offset = 0;
if(kCGL0Bit & smodes)
- c->stencil_bit_depths[offset++] = 0;
-
+ c->stencil_bit_depths[offset++] = 0;
+
if(kCGL1Bit & smodes)
- c->stencil_bit_depths[offset++] = 1;
-
+ c->stencil_bit_depths[offset++] = 1;
+
if(kCGL2Bit & smodes)
- c->stencil_bit_depths[offset++] = 2;
+ c->stencil_bit_depths[offset++] = 2;
if(kCGL3Bit & smodes)
- c->stencil_bit_depths[offset++] = 3;
-
+ c->stencil_bit_depths[offset++] = 3;
+
if(kCGL4Bit & smodes)
- c->stencil_bit_depths[offset++] = 4;
-
+ c->stencil_bit_depths[offset++] = 4;
+
if(kCGL5Bit & smodes)
- c->stencil_bit_depths[offset++] = 5;
+ c->stencil_bit_depths[offset++] = 5;
if(kCGL6Bit & smodes)
- c->stencil_bit_depths[offset++] = 6;
-
+ c->stencil_bit_depths[offset++] = 6;
+
if(kCGL8Bit & smodes)
- c->stencil_bit_depths[offset++] = 8;
-
+ c->stencil_bit_depths[offset++] = 8;
+
if(kCGL10Bit & smodes)
- c->stencil_bit_depths[offset++] = 10;
-
+ c->stencil_bit_depths[offset++] = 10;
+
if(kCGL12Bit & smodes)
- c->stencil_bit_depths[offset++] = 12;
-
+ c->stencil_bit_depths[offset++] = 12;
+
if(kCGL16Bit & smodes)
- c->stencil_bit_depths[offset++] = 16;
-
+ c->stencil_bit_depths[offset++] = 16;
+
if(kCGL24Bit & smodes)
- c->stencil_bit_depths[offset++] = 24;
-
+ c->stencil_bit_depths[offset++] = 24;
+
if(kCGL32Bit & smodes)
- c->stencil_bit_depths[offset++] = 32;
+ c->stencil_bit_depths[offset++] = 32;
if(kCGL48Bit & smodes)
- c->stencil_bit_depths[offset++] = 48;
+ c->stencil_bit_depths[offset++] = 48;
if(kCGL64Bit & smodes)
- c->stencil_bit_depths[offset++] = 64;
+ c->stencil_bit_depths[offset++] = 64;
if(kCGL96Bit & smodes)
- c->stencil_bit_depths[offset++] = 96;
+ c->stencil_bit_depths[offset++] = 96;
if(kCGL128Bit & smodes)
- c->stencil_bit_depths[offset++] = 128;
-
+ c->stencil_bit_depths[offset++] = 128;
+
assert(offset < GLCAPS_STENCIL_BIT_DEPTH_BUFFERS);
-
+
c->total_stencil_bit_depths = offset;
}
static int handleColorAndAccumulation(struct glColorBufCapabilities *c,
- GLint cmodes, int forAccum) {
+ GLint cmodes, int forAccum) {
int offset = 0;
-
+
/*1*/
if(kCGLRGB444Bit & cmodes) {
- c[offset].r = 4;
- c[offset].g = 4;
- c[offset].b = 4;
- ++offset;
+ c[offset].r = 4;
+ c[offset].g = 4;
+ c[offset].b = 4;
+ ++offset;
}
/*2*/
if(kCGLARGB4444Bit & cmodes) {
- c[offset].a = 4;
- c[offset].r = 4;
- c[offset].g = 4;
- c[offset].b = 4;
- c[offset].is_argb = true;
- ++offset;
+ c[offset].a = 4;
+ c[offset].r = 4;
+ c[offset].g = 4;
+ c[offset].b = 4;
+ c[offset].is_argb = true;
+ ++offset;
}
/*3*/
if(kCGLRGB444A8Bit & cmodes) {
- c[offset].r = 4;
- c[offset].g = 4;
- c[offset].b = 4;
- c[offset].a = 8;
- ++offset;
+ c[offset].r = 4;
+ c[offset].g = 4;
+ c[offset].b = 4;
+ c[offset].a = 8;
+ ++offset;
}
-
+
/*4*/
if(kCGLRGB555Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 5;
- c[offset].b = 5;
- ++offset;
+ c[offset].r = 5;
+ c[offset].g = 5;
+ c[offset].b = 5;
+ ++offset;
}
-
+
/*5*/
if(kCGLARGB1555Bit & cmodes) {
- c[offset].a = 1;
- c[offset].r = 5;
- c[offset].g = 5;
- c[offset].b = 5;
- c[offset].is_argb = true;
- ++offset;
+ c[offset].a = 1;
+ c[offset].r = 5;
+ c[offset].g = 5;
+ c[offset].b = 5;
+ c[offset].is_argb = true;
+ ++offset;
}
-
+
/*6*/
if(kCGLRGB555A8Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 5;
- c[offset].b = 5;
- c[offset].a = 8;
- ++offset;
+ c[offset].r = 5;
+ c[offset].g = 5;
+ c[offset].b = 5;
+ c[offset].a = 8;
+ ++offset;
}
-
+
/*7*/
if(kCGLRGB565Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 6;
- c[offset].b = 5;
- ++offset;
+ c[offset].r = 5;
+ c[offset].g = 6;
+ c[offset].b = 5;
+ ++offset;
}
-
+
/*8*/
if(kCGLRGB565A8Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 6;
- c[offset].b = 5;
- c[offset].a = 8;
- ++offset;
+ c[offset].r = 5;
+ c[offset].g = 6;
+ c[offset].b = 5;
+ c[offset].a = 8;
+ ++offset;
}
-
+
/*9*/
if(kCGLRGB888Bit & cmodes) {
- c[offset].r = 8;
- c[offset].g = 8;
- c[offset].b = 8;
- ++offset;
+ c[offset].r = 8;
+ c[offset].g = 8;
+ c[offset].b = 8;
+ ++offset;
}
-
+
/*10*/
if(kCGLARGB8888Bit & cmodes) {
- c[offset].a = 8;
- c[offset].r = 8;
- c[offset].g = 8;
- c[offset].b = 8;
- c[offset].is_argb = true;
- ++offset;
+ c[offset].a = 8;
+ c[offset].r = 8;
+ c[offset].g = 8;
+ c[offset].b = 8;
+ c[offset].is_argb = true;
+ ++offset;
}
-
+
/*11*/
if(kCGLRGB888A8Bit & cmodes) {
- c[offset].r = 8;
- c[offset].g = 8;
- c[offset].b = 8;
- c[offset].a = 8;
- ++offset;
+ c[offset].r = 8;
+ c[offset].g = 8;
+ c[offset].b = 8;
+ c[offset].a = 8;
+ ++offset;
}
-
+
if(forAccum) {
-//#if 0
- /* FIXME
- * Disable this path, because some part of libGL, X, or Xplugin
- * doesn't work with sizes greater than 8.
- * When this is enabled and visuals are chosen using depths
- * such as 16, the result is that the windows don't redraw
- * and are often white, until a resize.
- */
-
- /*12*/
- if(kCGLRGB101010Bit & cmodes) {
- c[offset].r = 10;
- c[offset].g = 10;
- c[offset].b = 10;
- ++offset;
- }
-
- /*13*/
- if(kCGLARGB2101010Bit & cmodes) {
- c[offset].a = 2;
- c[offset].r = 10;
- c[offset].g = 10;
- c[offset].b = 10;
- c[offset].is_argb = true;
- ++offset;
- }
-
- /*14*/
- if(kCGLRGB101010_A8Bit & cmodes) {
- c[offset].r = 10;
- c[offset].g = 10;
- c[offset].b = 10;
- c[offset].a = 8;
- ++offset;
- }
-
- /*15*/
- if(kCGLRGB121212Bit & cmodes) {
- c[offset].r = 12;
- c[offset].g = 12;
- c[offset].b = 12;
- ++offset;
- }
-
- /*16*/
- if(kCGLARGB12121212Bit & cmodes) {
- c[offset].a = 12;
- c[offset].r = 12;
- c[offset].g = 12;
- c[offset].b = 12;
- c[offset].is_argb = true;
- ++offset;
- }
-
- /*17*/
- if(kCGLRGB161616Bit & cmodes) {
- c[offset].r = 16;
- c[offset].g = 16;
- c[offset].b = 16;
- ++offset;
- }
-
- /*18*/
- if(kCGLRGBA16161616Bit & cmodes) {
- c[offset].r = 16;
- c[offset].g = 16;
- c[offset].b = 16;
- c[offset].a = 16;
- ++offset;
- }
+ //#if 0
+ /* FIXME
+ * Disable this path, because some part of libGL, X, or Xplugin
+ * doesn't work with sizes greater than 8.
+ * When this is enabled and visuals are chosen using depths
+ * such as 16, the result is that the windows don't redraw
+ * and are often white, until a resize.
+ */
+
+ /*12*/
+ if(kCGLRGB101010Bit & cmodes) {
+ c[offset].r = 10;
+ c[offset].g = 10;
+ c[offset].b = 10;
+ ++offset;
+ }
+
+ /*13*/
+ if(kCGLARGB2101010Bit & cmodes) {
+ c[offset].a = 2;
+ c[offset].r = 10;
+ c[offset].g = 10;
+ c[offset].b = 10;
+ c[offset].is_argb = true;
+ ++offset;
+ }
+
+ /*14*/
+ if(kCGLRGB101010_A8Bit & cmodes) {
+ c[offset].r = 10;
+ c[offset].g = 10;
+ c[offset].b = 10;
+ c[offset].a = 8;
+ ++offset;
+ }
+
+ /*15*/
+ if(kCGLRGB121212Bit & cmodes) {
+ c[offset].r = 12;
+ c[offset].g = 12;
+ c[offset].b = 12;
+ ++offset;
+ }
+
+ /*16*/
+ if(kCGLARGB12121212Bit & cmodes) {
+ c[offset].a = 12;
+ c[offset].r = 12;
+ c[offset].g = 12;
+ c[offset].b = 12;
+ c[offset].is_argb = true;
+ ++offset;
+ }
+
+ /*17*/
+ if(kCGLRGB161616Bit & cmodes) {
+ c[offset].r = 16;
+ c[offset].g = 16;
+ c[offset].b = 16;
+ ++offset;
+ }
+
+ /*18*/
+ if(kCGLRGBA16161616Bit & cmodes) {
+ c[offset].r = 16;
+ c[offset].g = 16;
+ c[offset].b = 16;
+ c[offset].a = 16;
+ ++offset;
+ }
}
-//#endif
-
+ //#endif
+
/* FIXME should we handle the floating point color modes, and if so, how? */
-
+
return offset;
}
static void handleColorModes(struct glCapabilitiesConfig *c, GLint cmodes) {
c->total_color_buffers = handleColorAndAccumulation(c->color_buffers,
- cmodes, 0);
+ cmodes, 0);
assert(c->total_color_buffers < GLCAPS_COLOR_BUFFERS);
}
static void handleAccumulationModes(struct glCapabilitiesConfig *c, GLint cmodes) {
c->total_accum_buffers = handleColorAndAccumulation(c->accum_buffers,
- cmodes, 1);
+ cmodes, 1);
assert(c->total_accum_buffers < GLCAPS_COLOR_BUFFERS);
}
static void handleDepthModes(struct glCapabilitiesConfig *c, GLint dmodes) {
int offset = 0;
#define DEPTH(flag,value) do { \
- if(dmodes & flag) { \
- c->depth_buffers[offset++] = value; \
- } \
- } while(0)
-
+if(dmodes & flag) { \
+c->depth_buffers[offset++] = value; \
+} \
+} while(0)
+
/*1*/
DEPTH(kCGL0Bit, 0);
/*2*/
@@ -346,92 +346,92 @@ static void handleDepthModes(struct glCapabilitiesConfig *c, GLint dmodes) {
DEPTH(kCGL96Bit, 96);
/*17*/
DEPTH(kCGL128Bit, 128);
-
+
#undef DEPTH
-
+
c->total_depth_buffer_depths = offset;
assert(c->total_depth_buffer_depths < GLCAPS_DEPTH_BUFFERS);
}
/* Return non-zero if an error occured. */
static CGLError handleRendererDescriptions(CGLRendererInfoObj info, GLint r,
- struct glCapabilitiesConfig *c) {
+ struct glCapabilitiesConfig *c) {
CGLError err;
GLint accelerated = 0, flags = 0, aux = 0, samplebufs = 0, samples = 0;
-
+
err = CGLDescribeRenderer (info, r, kCGLRPAccelerated, &accelerated);
-
+
if(err)
- return err;
+ return err;
c->accelerated = accelerated;
-
+
/* Buffering modes: single/double, stereo */
err = CGLDescribeRenderer(info, r, kCGLRPBufferModes, &flags);
-
+
if(err)
- return err;
+ return err;
handleBufferModes(c, flags);
/* AUX buffers */
err = CGLDescribeRenderer(info, r, kCGLRPMaxAuxBuffers, &aux);
-
+
if(err)
- return err;
+ return err;
c->aux_buffers = aux;
-
+
/* Depth buffer size */
err = CGLDescribeRenderer(info, r, kCGLRPDepthModes, &flags);
if(err)
- return err;
-
+ return err;
+
handleDepthModes(c, flags);
-
-
+
+
/* Multisample buffers */
err = CGLDescribeRenderer(info, r, kCGLRPMaxSampleBuffers, &samplebufs);
-
+
if(err)
- return err;
-
+ return err;
+
c->multisample_buffers = samplebufs;
-
+
/* Multisample samples per multisample buffer */
err = CGLDescribeRenderer(info, r, kCGLRPMaxSamples, &samples);
-
+
if(err)
- return err;
-
+ return err;
+
c->multisample_samples = samples;
-
-
+
+
/* Stencil bit depths */
err = CGLDescribeRenderer(info, r, kCGLRPStencilModes, &flags);
-
+
if(err)
- return err;
-
+ return err;
+
handleStencilModes(c, flags);
-
-
+
+
/* Color modes (RGB/RGBA depths supported */
err = CGLDescribeRenderer(info, r, kCGLRPColorModes, &flags);
-
+
if(err)
- return err;
+ return err;
handleColorModes(c, flags);
-
+
err = CGLDescribeRenderer(info, r, kCGLRPAccumModes, &flags);
-
+
if(err)
- return err;
-
+ return err;
+
handleAccumulationModes(c, flags);
return kCGLNoError;
@@ -444,45 +444,45 @@ static void initCapabilities(struct glCapabilities *cap) {
static void initConfig(struct glCapabilitiesConfig *c) {
int i;
-
+
c->accelerated = false;
c->stereo = false;
c->aux_buffers = 0;
c->buffers = 0;
-
+
c->total_depth_buffer_depths = 0;
-
+
for(i = 0; i < GLCAPS_DEPTH_BUFFERS; ++i) {
- c->depth_buffers[i] = GLCAPS_INVALID_DEPTH_VALUE;
+ c->depth_buffers[i] = GLCAPS_INVALID_DEPTH_VALUE;
}
-
+
c->multisample_buffers = 0;
c->multisample_samples = 0;
-
+
c->total_stencil_bit_depths = 0;
-
+
for(i = 0; i < GLCAPS_STENCIL_BIT_DEPTH_BUFFERS; ++i) {
- c->stencil_bit_depths[i] = GLCAPS_INVALID_STENCIL_DEPTH;
+ c->stencil_bit_depths[i] = GLCAPS_INVALID_STENCIL_DEPTH;
}
-
+
c->total_color_buffers = 0;
-
+
for(i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
- c->color_buffers[i].r = c->color_buffers[i].g =
+ c->color_buffers[i].r = c->color_buffers[i].g =
c->color_buffers[i].b = c->color_buffers[i].a =
GLCAPS_COLOR_BUF_INVALID_VALUE;
- c->color_buffers[i].is_argb = false;
- }
-
+ c->color_buffers[i].is_argb = false;
+ }
+
c->total_accum_buffers = 0;
-
+
for(i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
- c->accum_buffers[i].r = c->accum_buffers[i].g =
+ c->accum_buffers[i].r = c->accum_buffers[i].g =
c->accum_buffers[i].b = c->accum_buffers[i].a =
GLCAPS_COLOR_BUF_INVALID_VALUE;
- c->accum_buffers[i].is_argb = false;
+ c->accum_buffers[i].is_argb = false;
}
-
+
c->next = NULL;
}
@@ -490,13 +490,13 @@ void freeGlCapabilities(struct glCapabilities *cap) {
struct glCapabilitiesConfig *conf, *next;
conf = cap->configurations;
-
+
while(conf) {
- next = conf->next;
- free(conf);
- conf = next;
+ next = conf->next;
+ free(conf);
+ conf = next;
}
-
+
cap->configurations = NULL;
}
@@ -505,42 +505,42 @@ bool getGlCapabilities(struct glCapabilities *cap) {
CGLRendererInfoObj info;
CGLError err;
GLint numRenderers = 0, r;
-
+
initCapabilities(cap);
-
+
err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
if(err) {
ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
return err;
}
-
+
for(r = 0; r < numRenderers; r++) {
struct glCapabilitiesConfig tmpconf, *conf;
-
+
initConfig(&tmpconf);
-
+
err = handleRendererDescriptions(info, r, &tmpconf);
if(err) {
ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
ErrorF("trying to continue...\n");
continue;
}
-
+
conf = malloc(sizeof(*conf));
if(NULL == conf) {
- FatalError("Unable to allocate memory for OpenGL capabilities\n");
+ FatalError("Unable to allocate memory for OpenGL capabilities\n");
}
-
+
/* Copy the struct. */
*conf = tmpconf;
-
+
/* Now link the configuration into the list. */
conf->next = cap->configurations;
cap->configurations = conf;
}
-
+
CGLDestroyRendererInfo(info);
-
+
/* No error occured. We are done. */
return kCGLNoError;
}
diff --git a/hw/xquartz/GL/capabilities.h b/hw/xquartz/GL/capabilities.h
index 361856b07..3b474a64d 100644
--- a/hw/xquartz/GL/capabilities.h
+++ b/hw/xquartz/GL/capabilities.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Apple Inc.
+ * Copyright (c) 2008-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xquartz/GL/glcontextmodes.c b/hw/xquartz/GL/glcontextmodes.c
index eee7103ae..293fd954c 100644
--- a/hw/xquartz/GL/glcontextmodes.c
+++ b/hw/xquartz/GL/glcontextmodes.c
@@ -81,11 +81,11 @@ GLint
_gl_convert_from_x_visual_type( int visualType )
{
static const int glx_visual_types[ NUM_VISUAL_TYPES ] = {
- GLX_STATIC_GRAY, GLX_GRAY_SCALE,
- GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
- GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+ GLX_STATIC_GRAY, GLX_GRAY_SCALE,
+ GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
+ GLX_TRUE_COLOR, GLX_DIRECT_COLOR
};
-
+
return ( (unsigned) visualType < NUM_VISUAL_TYPES )
? glx_visual_types[ visualType ] : GLX_NONE;
}
@@ -103,11 +103,11 @@ GLint
_gl_convert_to_x_visual_type( int visualType )
{
static const int x_visual_types[ NUM_VISUAL_TYPES ] = {
- TrueColor, DirectColor,
- PseudoColor, StaticColor,
- GrayScale, StaticGray
+ TrueColor, DirectColor,
+ PseudoColor, StaticColor,
+ GrayScale, StaticGray
};
-
+
return ( (unsigned) (visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES )
? x_visual_types[ visualType - GLX_TRUE_COLOR ] : -1;
}
@@ -129,33 +129,33 @@ _gl_convert_to_x_visual_type( int visualType )
*/
void
_gl_copy_visual_to_context_mode( __GLcontextModes * mode,
- const __GLXvisualConfig * config )
+ const __GLXvisualConfig * config )
{
__GLcontextModes * const next = mode->next;
-
+
(void) _mesa_memset( mode, 0, sizeof( __GLcontextModes ) );
mode->next = next;
-
+
mode->visualID = config->vid;
mode->visualType = _gl_convert_from_x_visual_type( config->class );
mode->xRenderable = GL_TRUE;
mode->fbconfigID = config->vid;
mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
-
+
mode->rgbMode = (config->rgba != 0);
mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
-
+
mode->colorIndexMode = !(mode->rgbMode);
mode->doubleBufferMode = (config->doubleBuffer != 0);
mode->stereoMode = (config->stereo != 0);
-
+
mode->haveAccumBuffer = ((config->accumRedSize +
- config->accumGreenSize +
- config->accumBlueSize +
- config->accumAlphaSize) > 0);
+ config->accumGreenSize +
+ config->accumBlueSize +
+ config->accumAlphaSize) > 0);
mode->haveDepthBuffer = (config->depthSize > 0);
mode->haveStencilBuffer = (config->stencilSize > 0);
-
+
mode->redBits = config->redSize;
mode->greenBits = config->greenSize;
mode->blueBits = config->blueSize;
@@ -166,17 +166,17 @@ _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
mode->alphaMask = config->alphaMask;
mode->rgbBits = mode->rgbMode ? config->bufferSize : 0;
mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0;
-
+
mode->accumRedBits = config->accumRedSize;
mode->accumGreenBits = config->accumGreenSize;
mode->accumBlueBits = config->accumBlueSize;
mode->accumAlphaBits = config->accumAlphaSize;
mode->depthBits = config->depthSize;
mode->stencilBits = config->stencilSize;
-
+
mode->numAuxBuffers = config->auxBuffers;
mode->level = config->level;
-
+
mode->visualRating = config->visualRating;
mode->transparentPixel = config->transparentPixel;
mode->transparentRed = config->transparentRed;
@@ -187,9 +187,9 @@ _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
mode->samples = config->multiSampleSize;
mode->sampleBuffers = config->nMultiSampleBuffers;
/* mode->visualSelectGroup = config->visualSelectGroup; ? */
-
+
mode->swapMethod = GLX_SWAP_UNDEFINED_OML;
-
+
mode->bindToTextureRgb = (mode->rgbMode) ? GL_TRUE : GL_FALSE;
mode->bindToTextureRgba = (mode->rgbMode && mode->alphaBits) ?
GL_TRUE : GL_FALSE;
@@ -212,147 +212,147 @@ _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
*/
int
_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
- int *value_return)
+ int *value_return)
{
switch (attribute) {
- case GLX_USE_GL:
- *value_return = GL_TRUE;
- return 0;
- case GLX_BUFFER_SIZE:
- *value_return = mode->rgbBits;
- return 0;
- case GLX_RGBA:
- *value_return = mode->rgbMode;
- return 0;
- case GLX_RED_SIZE:
- *value_return = mode->redBits;
- return 0;
- case GLX_GREEN_SIZE:
- *value_return = mode->greenBits;
- return 0;
- case GLX_BLUE_SIZE:
- *value_return = mode->blueBits;
- return 0;
- case GLX_ALPHA_SIZE:
- *value_return = mode->alphaBits;
- return 0;
- case GLX_DOUBLEBUFFER:
- *value_return = mode->doubleBufferMode;
- return 0;
- case GLX_STEREO:
- *value_return = mode->stereoMode;
- return 0;
- case GLX_AUX_BUFFERS:
- *value_return = mode->numAuxBuffers;
- return 0;
- case GLX_DEPTH_SIZE:
- *value_return = mode->depthBits;
- return 0;
- case GLX_STENCIL_SIZE:
- *value_return = mode->stencilBits;
- return 0;
- case GLX_ACCUM_RED_SIZE:
- *value_return = mode->accumRedBits;
- return 0;
- case GLX_ACCUM_GREEN_SIZE:
- *value_return = mode->accumGreenBits;
- return 0;
- case GLX_ACCUM_BLUE_SIZE:
- *value_return = mode->accumBlueBits;
- return 0;
- case GLX_ACCUM_ALPHA_SIZE:
- *value_return = mode->accumAlphaBits;
- return 0;
- case GLX_LEVEL:
- *value_return = mode->level;
- return 0;
- case GLX_TRANSPARENT_TYPE_EXT:
- *value_return = mode->transparentPixel;
- return 0;
- case GLX_TRANSPARENT_RED_VALUE:
- *value_return = mode->transparentRed;
- return 0;
- case GLX_TRANSPARENT_GREEN_VALUE:
- *value_return = mode->transparentGreen;
- return 0;
- case GLX_TRANSPARENT_BLUE_VALUE:
- *value_return = mode->transparentBlue;
- return 0;
- case GLX_TRANSPARENT_ALPHA_VALUE:
- *value_return = mode->transparentAlpha;
- return 0;
- case GLX_TRANSPARENT_INDEX_VALUE:
- *value_return = mode->transparentIndex;
- return 0;
- case GLX_X_VISUAL_TYPE:
- *value_return = mode->visualType;
- return 0;
- case GLX_CONFIG_CAVEAT:
- *value_return = mode->visualRating;
- return 0;
- case GLX_VISUAL_ID:
- *value_return = mode->visualID;
- return 0;
- case GLX_DRAWABLE_TYPE:
- *value_return = mode->drawableType;
- return 0;
- case GLX_RENDER_TYPE:
- *value_return = mode->renderType;
- return 0;
- case GLX_X_RENDERABLE:
- *value_return = mode->xRenderable;
- return 0;
- case GLX_FBCONFIG_ID:
- *value_return = mode->fbconfigID;
- return 0;
- case GLX_MAX_PBUFFER_WIDTH:
- *value_return = mode->maxPbufferWidth;
- return 0;
- case GLX_MAX_PBUFFER_HEIGHT:
- *value_return = mode->maxPbufferHeight;
- return 0;
- case GLX_MAX_PBUFFER_PIXELS:
- *value_return = mode->maxPbufferPixels;
- return 0;
- case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
- *value_return = mode->optimalPbufferWidth;
- return 0;
- case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
- *value_return = mode->optimalPbufferHeight;
- return 0;
- case GLX_SWAP_METHOD_OML:
- *value_return = mode->swapMethod;
- return 0;
- case GLX_SAMPLE_BUFFERS_SGIS:
- *value_return = mode->sampleBuffers;
- return 0;
- case GLX_SAMPLES_SGIS:
- *value_return = mode->samples;
- return 0;
- case GLX_BIND_TO_TEXTURE_RGB_EXT:
- *value_return = mode->bindToTextureRgb;
- return 0;
- case GLX_BIND_TO_TEXTURE_RGBA_EXT:
- *value_return = mode->bindToTextureRgba;
- return 0;
- case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
- *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
- GL_FALSE;
- return 0;
- case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
- *value_return = mode->bindToTextureTargets;
- return 0;
- case GLX_Y_INVERTED_EXT:
- *value_return = mode->yInverted;
- return 0;
-
- /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX.
- * It is ONLY for communication between the GLX client and the GLX
- * server.
- */
- case GLX_VISUAL_SELECT_GROUP_SGIX:
- default:
- return GLX_BAD_ATTRIBUTE;
+ case GLX_USE_GL:
+ *value_return = GL_TRUE;
+ return 0;
+ case GLX_BUFFER_SIZE:
+ *value_return = mode->rgbBits;
+ return 0;
+ case GLX_RGBA:
+ *value_return = mode->rgbMode;
+ return 0;
+ case GLX_RED_SIZE:
+ *value_return = mode->redBits;
+ return 0;
+ case GLX_GREEN_SIZE:
+ *value_return = mode->greenBits;
+ return 0;
+ case GLX_BLUE_SIZE:
+ *value_return = mode->blueBits;
+ return 0;
+ case GLX_ALPHA_SIZE:
+ *value_return = mode->alphaBits;
+ return 0;
+ case GLX_DOUBLEBUFFER:
+ *value_return = mode->doubleBufferMode;
+ return 0;
+ case GLX_STEREO:
+ *value_return = mode->stereoMode;
+ return 0;
+ case GLX_AUX_BUFFERS:
+ *value_return = mode->numAuxBuffers;
+ return 0;
+ case GLX_DEPTH_SIZE:
+ *value_return = mode->depthBits;
+ return 0;
+ case GLX_STENCIL_SIZE:
+ *value_return = mode->stencilBits;
+ return 0;
+ case GLX_ACCUM_RED_SIZE:
+ *value_return = mode->accumRedBits;
+ return 0;
+ case GLX_ACCUM_GREEN_SIZE:
+ *value_return = mode->accumGreenBits;
+ return 0;
+ case GLX_ACCUM_BLUE_SIZE:
+ *value_return = mode->accumBlueBits;
+ return 0;
+ case GLX_ACCUM_ALPHA_SIZE:
+ *value_return = mode->accumAlphaBits;
+ return 0;
+ case GLX_LEVEL:
+ *value_return = mode->level;
+ return 0;
+ case GLX_TRANSPARENT_TYPE_EXT:
+ *value_return = mode->transparentPixel;
+ return 0;
+ case GLX_TRANSPARENT_RED_VALUE:
+ *value_return = mode->transparentRed;
+ return 0;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ *value_return = mode->transparentGreen;
+ return 0;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ *value_return = mode->transparentBlue;
+ return 0;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ *value_return = mode->transparentAlpha;
+ return 0;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ *value_return = mode->transparentIndex;
+ return 0;
+ case GLX_X_VISUAL_TYPE:
+ *value_return = mode->visualType;
+ return 0;
+ case GLX_CONFIG_CAVEAT:
+ *value_return = mode->visualRating;
+ return 0;
+ case GLX_VISUAL_ID:
+ *value_return = mode->visualID;
+ return 0;
+ case GLX_DRAWABLE_TYPE:
+ *value_return = mode->drawableType;
+ return 0;
+ case GLX_RENDER_TYPE:
+ *value_return = mode->renderType;
+ return 0;
+ case GLX_X_RENDERABLE:
+ *value_return = mode->xRenderable;
+ return 0;
+ case GLX_FBCONFIG_ID:
+ *value_return = mode->fbconfigID;
+ return 0;
+ case GLX_MAX_PBUFFER_WIDTH:
+ *value_return = mode->maxPbufferWidth;
+ return 0;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ *value_return = mode->maxPbufferHeight;
+ return 0;
+ case GLX_MAX_PBUFFER_PIXELS:
+ *value_return = mode->maxPbufferPixels;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ *value_return = mode->optimalPbufferWidth;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ *value_return = mode->optimalPbufferHeight;
+ return 0;
+ case GLX_SWAP_METHOD_OML:
+ *value_return = mode->swapMethod;
+ return 0;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ *value_return = mode->sampleBuffers;
+ return 0;
+ case GLX_SAMPLES_SGIS:
+ *value_return = mode->samples;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_RGB_EXT:
+ *value_return = mode->bindToTextureRgb;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_RGBA_EXT:
+ *value_return = mode->bindToTextureRgba;
+ return 0;
+ case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
+ *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
+ GL_FALSE;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
+ *value_return = mode->bindToTextureTargets;
+ return 0;
+ case GLX_Y_INVERTED_EXT:
+ *value_return = mode->yInverted;
+ return 0;
+
+ /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX.
+ * It is ONLY for communication between the GLX client and the GLX
+ * server.
+ */
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ default:
+ return GLX_BAD_ATTRIBUTE;
}
}
#endif /* !defined(IN_MINI_GLX) */
@@ -387,44 +387,44 @@ _gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
__GLcontextModes *
_gl_context_modes_create( unsigned count, size_t minimum_size )
{
- const size_t size = (minimum_size > sizeof( __GLcontextModes ))
- ? minimum_size : sizeof( __GLcontextModes );
- __GLcontextModes * base = NULL;
- __GLcontextModes ** next;
- unsigned i;
-
- next = & base;
- for ( i = 0 ; i < count ; i++ ) {
- *next = (__GLcontextModes *) _mesa_malloc( size );
- if ( *next == NULL ) {
- _gl_context_modes_destroy( base );
- base = NULL;
- break;
- }
-
- (void) _mesa_memset( *next, 0, size );
- (*next)->visualID = GLX_DONT_CARE;
- (*next)->visualType = GLX_DONT_CARE;
- (*next)->visualRating = GLX_NONE;
- (*next)->transparentPixel = GLX_NONE;
- (*next)->transparentRed = GLX_DONT_CARE;
- (*next)->transparentGreen = GLX_DONT_CARE;
- (*next)->transparentBlue = GLX_DONT_CARE;
- (*next)->transparentAlpha = GLX_DONT_CARE;
- (*next)->transparentIndex = GLX_DONT_CARE;
- (*next)->xRenderable = GLX_DONT_CARE;
- (*next)->fbconfigID = GLX_DONT_CARE;
- (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
- (*next)->bindToTextureRgb = GLX_DONT_CARE;
- (*next)->bindToTextureRgba = GLX_DONT_CARE;
- (*next)->bindToMipmapTexture = GLX_DONT_CARE;
- (*next)->bindToTextureTargets = GLX_DONT_CARE;
- (*next)->yInverted = GLX_DONT_CARE;
-
- next = & ((*next)->next);
- }
-
- return base;
+ const size_t size = (minimum_size > sizeof( __GLcontextModes ))
+ ? minimum_size : sizeof( __GLcontextModes );
+ __GLcontextModes * base = NULL;
+ __GLcontextModes ** next;
+ unsigned i;
+
+ next = & base;
+ for ( i = 0 ; i < count ; i++ ) {
+ *next = (__GLcontextModes *) _mesa_malloc( size );
+ if ( *next == NULL ) {
+ _gl_context_modes_destroy( base );
+ base = NULL;
+ break;
+ }
+
+ (void) _mesa_memset( *next, 0, size );
+ (*next)->visualID = GLX_DONT_CARE;
+ (*next)->visualType = GLX_DONT_CARE;
+ (*next)->visualRating = GLX_NONE;
+ (*next)->transparentPixel = GLX_NONE;
+ (*next)->transparentRed = GLX_DONT_CARE;
+ (*next)->transparentGreen = GLX_DONT_CARE;
+ (*next)->transparentBlue = GLX_DONT_CARE;
+ (*next)->transparentAlpha = GLX_DONT_CARE;
+ (*next)->transparentIndex = GLX_DONT_CARE;
+ (*next)->xRenderable = GLX_DONT_CARE;
+ (*next)->fbconfigID = GLX_DONT_CARE;
+ (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
+ (*next)->bindToTextureRgb = GLX_DONT_CARE;
+ (*next)->bindToTextureRgba = GLX_DONT_CARE;
+ (*next)->bindToMipmapTexture = GLX_DONT_CARE;
+ (*next)->bindToTextureTargets = GLX_DONT_CARE;
+ (*next)->yInverted = GLX_DONT_CARE;
+
+ next = & ((*next)->next);
+ }
+
+ return base;
}
@@ -438,12 +438,12 @@ _gl_context_modes_create( unsigned count, size_t minimum_size )
void
_gl_context_modes_destroy( __GLcontextModes * modes )
{
- while ( modes != NULL ) {
- __GLcontextModes * const next = modes->next;
-
- _mesa_free( modes );
- modes = next;
- }
+ while ( modes != NULL ) {
+ __GLcontextModes * const next = modes->next;
+
+ _mesa_free( modes );
+ modes = next;
+ }
}
@@ -460,11 +460,11 @@ __GLcontextModes *
_gl_context_modes_find_visual(__GLcontextModes *modes, int vid)
{
__GLcontextModes *m;
-
+
for (m = modes; m != NULL; m = m->next)
- if (m->visualID == vid)
- return m;
-
+ if (m->visualID == vid)
+ return m;
+
return NULL;
}
@@ -472,11 +472,11 @@ __GLcontextModes *
_gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid)
{
__GLcontextModes *m;
-
+
for (m = modes; m != NULL; m = m->next)
- if (m->fbconfigID == fbid)
- return m;
-
+ if (m->fbconfigID == fbid)
+ return m;
+
return NULL;
}
@@ -491,60 +491,60 @@ _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid)
*/
GLboolean
_gl_context_modes_are_same( const __GLcontextModes * a,
- const __GLcontextModes * b )
+ const __GLcontextModes * b )
{
return( (a->rgbMode == b->rgbMode) &&
- (a->floatMode == b->floatMode) &&
- (a->colorIndexMode == b->colorIndexMode) &&
- (a->doubleBufferMode == b->doubleBufferMode) &&
- (a->stereoMode == b->stereoMode) &&
- (a->redBits == b->redBits) &&
- (a->greenBits == b->greenBits) &&
- (a->blueBits == b->blueBits) &&
- (a->alphaBits == b->alphaBits) &&
+ (a->floatMode == b->floatMode) &&
+ (a->colorIndexMode == b->colorIndexMode) &&
+ (a->doubleBufferMode == b->doubleBufferMode) &&
+ (a->stereoMode == b->stereoMode) &&
+ (a->redBits == b->redBits) &&
+ (a->greenBits == b->greenBits) &&
+ (a->blueBits == b->blueBits) &&
+ (a->alphaBits == b->alphaBits) &&
#if 0 /* For some reason these don't get set on the client-side in libGL. */
- (a->redMask == b->redMask) &&
- (a->greenMask == b->greenMask) &&
- (a->blueMask == b->blueMask) &&
- (a->alphaMask == b->alphaMask) &&
+ (a->redMask == b->redMask) &&
+ (a->greenMask == b->greenMask) &&
+ (a->blueMask == b->blueMask) &&
+ (a->alphaMask == b->alphaMask) &&
#endif
- (a->rgbBits == b->rgbBits) &&
- (a->indexBits == b->indexBits) &&
- (a->accumRedBits == b->accumRedBits) &&
- (a->accumGreenBits == b->accumGreenBits) &&
- (a->accumBlueBits == b->accumBlueBits) &&
- (a->accumAlphaBits == b->accumAlphaBits) &&
- (a->depthBits == b->depthBits) &&
- (a->stencilBits == b->stencilBits) &&
- (a->numAuxBuffers == b->numAuxBuffers) &&
- (a->level == b->level) &&
- (a->pixmapMode == b->pixmapMode) &&
- (a->visualRating == b->visualRating) &&
-
- (a->transparentPixel == b->transparentPixel) &&
-
- ((a->transparentPixel != GLX_TRANSPARENT_RGB) ||
- ((a->transparentRed == b->transparentRed) &&
- (a->transparentGreen == b->transparentGreen) &&
- (a->transparentBlue == b->transparentBlue) &&
- (a->transparentAlpha == b->transparentAlpha))) &&
-
- ((a->transparentPixel != GLX_TRANSPARENT_INDEX) ||
- (a->transparentIndex == b->transparentIndex)) &&
-
- (a->sampleBuffers == b->sampleBuffers) &&
- (a->samples == b->samples) &&
- ((a->drawableType & b->drawableType) != 0) &&
- (a->renderType == b->renderType) &&
- (a->maxPbufferWidth == b->maxPbufferWidth) &&
- (a->maxPbufferHeight == b->maxPbufferHeight) &&
- (a->maxPbufferPixels == b->maxPbufferPixels) &&
- (a->optimalPbufferWidth == b->optimalPbufferWidth) &&
- (a->optimalPbufferHeight == b->optimalPbufferHeight) &&
- (a->swapMethod == b->swapMethod) &&
- (a->bindToTextureRgb == b->bindToTextureRgb) &&
- (a->bindToTextureRgba == b->bindToTextureRgba) &&
- (a->bindToMipmapTexture == b->bindToMipmapTexture) &&
- (a->bindToTextureTargets == b->bindToTextureTargets) &&
- (a->yInverted == b->yInverted) );
+ (a->rgbBits == b->rgbBits) &&
+ (a->indexBits == b->indexBits) &&
+ (a->accumRedBits == b->accumRedBits) &&
+ (a->accumGreenBits == b->accumGreenBits) &&
+ (a->accumBlueBits == b->accumBlueBits) &&
+ (a->accumAlphaBits == b->accumAlphaBits) &&
+ (a->depthBits == b->depthBits) &&
+ (a->stencilBits == b->stencilBits) &&
+ (a->numAuxBuffers == b->numAuxBuffers) &&
+ (a->level == b->level) &&
+ (a->pixmapMode == b->pixmapMode) &&
+ (a->visualRating == b->visualRating) &&
+
+ (a->transparentPixel == b->transparentPixel) &&
+
+ ((a->transparentPixel != GLX_TRANSPARENT_RGB) ||
+ ((a->transparentRed == b->transparentRed) &&
+ (a->transparentGreen == b->transparentGreen) &&
+ (a->transparentBlue == b->transparentBlue) &&
+ (a->transparentAlpha == b->transparentAlpha))) &&
+
+ ((a->transparentPixel != GLX_TRANSPARENT_INDEX) ||
+ (a->transparentIndex == b->transparentIndex)) &&
+
+ (a->sampleBuffers == b->sampleBuffers) &&
+ (a->samples == b->samples) &&
+ ((a->drawableType & b->drawableType) != 0) &&
+ (a->renderType == b->renderType) &&
+ (a->maxPbufferWidth == b->maxPbufferWidth) &&
+ (a->maxPbufferHeight == b->maxPbufferHeight) &&
+ (a->maxPbufferPixels == b->maxPbufferPixels) &&
+ (a->optimalPbufferWidth == b->optimalPbufferWidth) &&
+ (a->optimalPbufferHeight == b->optimalPbufferHeight) &&
+ (a->swapMethod == b->swapMethod) &&
+ (a->bindToTextureRgb == b->bindToTextureRgb) &&
+ (a->bindToTextureRgba == b->bindToTextureRgba) &&
+ (a->bindToMipmapTexture == b->bindToMipmapTexture) &&
+ (a->bindToTextureTargets == b->bindToTextureTargets) &&
+ (a->yInverted == b->yInverted) );
}
diff --git a/hw/xquartz/GL/glcontextmodes.h b/hw/xquartz/GL/glcontextmodes.h
index afd09cd7f..56d8821e7 100644
--- a/hw/xquartz/GL/glcontextmodes.h
+++ b/hw/xquartz/GL/glcontextmodes.h
@@ -36,19 +36,19 @@
extern GLint _gl_convert_from_x_visual_type( int visualType );
extern GLint _gl_convert_to_x_visual_type( int visualType );
extern void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
- const __GLXvisualConfig * config );
+ const __GLXvisualConfig * config );
extern int _gl_get_context_mode_data( const __GLcontextModes *mode,
- int attribute, int *value_return );
+ int attribute, int *value_return );
#endif /* !defined(IN_MINI_GLX) */
extern __GLcontextModes * _gl_context_modes_create( unsigned count,
- size_t minimum_size );
+ size_t minimum_size );
extern void _gl_context_modes_destroy( __GLcontextModes * modes );
extern __GLcontextModes *
- _gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
+_gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
extern __GLcontextModes *
- _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
+_gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
extern GLboolean _gl_context_modes_are_same( const __GLcontextModes * a,
- const __GLcontextModes * b );
+ const __GLcontextModes * b );
#endif /* GLCONTEXTMODES_H */
diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index e6ff37668..fc67789c9 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -2,7 +2,7 @@
* GLX implementation that uses Apple's OpenGL.framework
* (Indirect rendering path -- it's also used for some direct mode code too)
*
- * Copyright (c) 2007-2011 Apple Inc.
+ * Copyright (c) 2007-2012 Apple Inc.
* Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
* Copyright (c) 2002 Greg Parker. All Rights Reserved.
*
@@ -118,20 +118,20 @@ struct __GLXAquaDrawable {
static __GLXcontext *
__glXAquaScreenCreateContext(__GLXscreen *screen,
- __GLXconfig *conf,
- __GLXcontext *baseShareContext)
+ __GLXconfig *conf,
+ __GLXcontext *baseShareContext)
{
__GLXAquaContext *context;
__GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext;
CGLError gl_err;
-
+
GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
context = calloc(1, sizeof (__GLXAquaContext));
if (context == NULL)
- return NULL;
-
+ return NULL;
+
memset(context, 0, sizeof *context);
context->base.pGlxScreen = screen;
@@ -148,17 +148,17 @@ __glXAquaScreenCreateContext(__GLXscreen *screen,
free(context);
return NULL;
}
-
+
context->ctx = NULL;
gl_err = CGLCreateContext(context->pixelFormat,
- shareContext ? shareContext->ctx : NULL,
- &context->ctx);
+ shareContext ? shareContext->ctx : NULL,
+ &context->ctx);
if (gl_err != 0) {
- ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
- CGLDestroyPixelFormat(context->pixelFormat);
- free(context);
- return NULL;
+ ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
+ CGLDestroyPixelFormat(context->pixelFormat);
+ free(context);
+ return NULL;
}
setup_dispatch_table();
@@ -172,47 +172,47 @@ static x_hash_table *surface_hash;
static void __glXAquaContextDestroy(__GLXcontext *baseContext) {
x_list *lst;
-
+
__GLXAquaContext *context = (__GLXAquaContext *) baseContext;
GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx %p)\n", baseContext);
if (context != NULL) {
- if (context->sid != 0 && surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
- lst = x_list_remove(lst, context);
- x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
- }
-
- if (context->ctx != NULL)
- CGLDestroyContext(context->ctx);
-
- if (context->pixelFormat != NULL)
- CGLDestroyPixelFormat(context->pixelFormat);
-
- free(context);
+ if (context->sid != 0 && surface_hash != NULL) {
+ lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
+ lst = x_list_remove(lst, context);
+ x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
+ }
+
+ if (context->ctx != NULL)
+ CGLDestroyContext(context->ctx);
+
+ if (context->pixelFormat != NULL)
+ CGLDestroyPixelFormat(context->pixelFormat);
+
+ free(context);
}
}
static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext) {
CGLError gl_err;
-
+
GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%p)\n", baseContext);
-
+
gl_err = CGLSetCurrentContext(NULL);
if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+
/*
* There should be no need to set __glXLastContext to NULL here, because
* glxcmds.c does it as part of the context cache flush after calling
* this.
*/
-
+
return GL_TRUE;
}
/* Called when a surface is destroyed as a side effect of destroying
- the window it's attached to. */
+ the window it's attached to. */
static void surface_notify(void *_arg, void *data) {
DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *)_arg;
__GLXAquaDrawable *draw = (__GLXAquaDrawable *)data;
@@ -225,26 +225,26 @@ static void surface_notify(void *_arg, void *data) {
GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data);
switch (arg->kind) {
- case AppleDRISurfaceNotifyDestroyed:
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
- draw->pDraw = NULL;
- draw->sid = 0;
- break;
-
- case AppleDRISurfaceNotifyChanged:
- if (surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL);
- for (; lst != NULL; lst = lst->next)
- {
- context = lst->data;
- xp_update_gl_context(context->ctx);
+ case AppleDRISurfaceNotifyDestroyed:
+ if (surface_hash != NULL)
+ x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
+ draw->pDraw = NULL;
+ draw->sid = 0;
+ break;
+
+ case AppleDRISurfaceNotifyChanged:
+ if (surface_hash != NULL) {
+ lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL);
+ for (; lst != NULL; lst = lst->next)
+ {
+ context = lst->data;
+ xp_update_gl_context(context->ctx);
+ }
}
- }
- break;
- default:
- ErrorF("surface_notify: unknown kind %d\n", arg->kind);
- break;
+ break;
+ default:
+ ErrorF("surface_notify: unknown kind %d\n", arg->kind);
+ break;
}
}
@@ -254,58 +254,58 @@ static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
GLAQUA_DEBUG_MSG("attach(%p, %p)\n", context, draw);
if(NULL == context || NULL == draw)
- return TRUE;
-
+ return TRUE;
+
pDraw = draw->base.pDraw;
-
+
if(NULL == pDraw) {
- ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__);
- return TRUE;
+ ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__);
+ return TRUE;
}
-
+
if (draw->sid == 0) {
- //if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
+ //if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw,
- 0, &draw->sid, NULL,
- surface_notify, draw))
+ 0, &draw->sid, NULL,
+ surface_notify, draw))
return TRUE;
draw->pDraw = pDraw;
}
if (!context->isAttached || context->sid != draw->sid) {
x_list *lst;
-
+
if (xp_attach_gl_context(context->ctx, draw->sid) != Success) {
- //quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw,
+ //quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw,
DRIDestroySurface(pDraw->pScreen, pDraw->id, pDraw,
- surface_notify, draw);
+ surface_notify, draw);
if (surface_hash != NULL)
x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(draw->sid));
-
+
draw->sid = 0;
return TRUE;
}
-
+
context->isAttached = TRUE;
context->sid = draw->sid;
-
+
if (surface_hash == NULL)
surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
-
+
lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
if (x_list_find(lst, context) == NULL) {
lst = x_list_prepend(lst, context);
x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
}
-
-
-
+
+
+
GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
(unsigned int) draw->sid);
}
-
+
draw->context = context;
-
+
return FALSE;
}
@@ -319,13 +319,13 @@ static void unattach(__GLXAquaContext *context) {
}
if (context->isAttached) {
GLAQUA_DEBUG_MSG("unattaching\n");
-
+
if (surface_hash != NULL) {
lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL);
lst = x_list_remove(lst, context);
x_hash_table_insert(surface_hash, (void *) context->sid, lst);
}
-
+
CGLClearDrawable(context->ctx);
context->isAttached = FALSE;
context->sid = 0;
@@ -341,8 +341,8 @@ static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) {
GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%p)\n", baseContext);
if(attach(context, drawPriv))
- return /*error*/ 0;
-
+ return /*error*/ 0;
+
gl_err = CGLSetCurrentContext(context->ctx);
if (gl_err != 0)
ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
@@ -353,16 +353,16 @@ static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) {
static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask)
{
CGLError gl_err;
-
+
__GLXAquaContext *dst = (__GLXAquaContext *) baseDst;
__GLXAquaContext *src = (__GLXAquaContext *) baseSrc;
-
+
GLAQUA_DEBUG_MSG("GLXAquaContextCopy\n");
-
+
gl_err = CGLCopyContext(src->ctx, dst->ctx, mask);
if (gl_err != 0)
ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
-
+
return gl_err == 0;
}
@@ -370,30 +370,30 @@ static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, un
static GLboolean __glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable *base) {
CGLError err;
__GLXAquaDrawable *drawable;
-
+
// GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base);
if(!base) {
- ErrorF("%s passed NULL\n", __func__);
- return GL_FALSE;
+ ErrorF("%s passed NULL\n", __func__);
+ return GL_FALSE;
}
-
+
drawable = (__GLXAquaDrawable *)base;
-
+
if(NULL == drawable->context) {
- ErrorF("%s called with a NULL->context for drawable %p!\n",
- __func__, (void *)drawable);
- return GL_FALSE;
+ ErrorF("%s called with a NULL->context for drawable %p!\n",
+ __func__, (void *)drawable);
+ return GL_FALSE;
}
-
+
err = CGLFlushDrawable(drawable->context->ctx);
-
+
if(kCGLNoError != err) {
- ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err),
- __func__);
- return GL_FALSE;
+ ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err),
+ __func__);
+ return GL_FALSE;
}
-
+
return GL_TRUE;
}
@@ -406,76 +406,76 @@ static CGLPixelFormatObj makeFormat(__GLXconfig *conf) {
int i = 0;
if(conf->doubleBufferMode)
- attr[i++] = kCGLPFADoubleBuffer;
-
+ attr[i++] = kCGLPFADoubleBuffer;
+
if(conf->stereoMode)
- attr[i++] = kCGLPFAStereo;
-
+ attr[i++] = kCGLPFAStereo;
+
attr[i++] = kCGLPFAColorSize;
attr[i++] = conf->redBits + conf->greenBits + conf->blueBits;
attr[i++] = kCGLPFAAlphaSize;
attr[i++] = conf->alphaBits;
-
+
if((conf->accumRedBits + conf->accumGreenBits + conf->accumBlueBits +
- conf->accumAlphaBits) > 0) {
-
- attr[i++] = kCGLPFAAccumSize;
+ conf->accumAlphaBits) > 0) {
+
+ attr[i++] = kCGLPFAAccumSize;
attr[i++] = conf->accumRedBits + conf->accumGreenBits
+ conf->accumBlueBits + conf->accumAlphaBits;
}
attr[i++] = kCGLPFADepthSize;
attr[i++] = conf->depthBits;
-
+
if(conf->stencilBits) {
- attr[i++] = kCGLPFAStencilSize;
+ attr[i++] = kCGLPFAStencilSize;
attr[i++] = conf->stencilBits;
}
if(conf->numAuxBuffers > 0) {
- attr[i++] = kCGLPFAAuxBuffers;
- attr[i++] = conf->numAuxBuffers;
+ attr[i++] = kCGLPFAAuxBuffers;
+ attr[i++] = conf->numAuxBuffers;
}
-
+
if(conf->sampleBuffers > 0) {
- attr[i++] = kCGLPFASampleBuffers;
- attr[i++] = conf->sampleBuffers;
- attr[i++] = kCGLPFASamples;
- attr[i++] = conf->samples;
+ attr[i++] = kCGLPFASampleBuffers;
+ attr[i++] = conf->sampleBuffers;
+ attr[i++] = kCGLPFASamples;
+ attr[i++] = conf->samples;
}
-
+
attr[i] = 0;
-
+
error = CGLChoosePixelFormat(attr, &fobj, &formats);
if(error) {
- ErrorF("error: creating pixel format %s\n", CGLErrorString(error));
- return NULL;
+ ErrorF("error: creating pixel format %s\n", CGLErrorString(error));
+ return NULL;
}
-
+
return fobj;
}
static void __glXAquaScreenDestroy(__GLXscreen *screen) {
-
+
GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen);
__glXScreenDestroy(screen);
-
+
free(screen);
}
/* This is called by __glXInitScreens(). */
static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
__GLXAquaScreen *screen;
-
+
GLAQUA_DEBUG_MSG("glXAquaScreenProbe\n");
-
+
if (pScreen == NULL)
- return NULL;
-
+ return NULL;
+
screen = calloc(1, sizeof *screen);
-
+
if(NULL == screen)
- return NULL;
+ return NULL;
screen->base.destroy = __glXAquaScreenDestroy;
screen->base.createContext = __glXAquaScreenCreateContext;
@@ -484,9 +484,9 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
screen->base.pScreen = pScreen;
screen->base.fbconfigs = __glXAquaCreateVisualConfigs(&screen->base.numFBConfigs, pScreen->myNum);
-
+
__glXScreenInit(&screen->base, pScreen);
-
+
screen->base.GLXmajor = 1;
screen->base.GLXminor = 4;
screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
@@ -502,7 +502,7 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
#if 0 // unused
static void __glXAquaDrawableCopySubBuffer (__GLXdrawable *drawable,
- int x, int y, int w, int h) {
+ int x, int y, int w, int h) {
/*TODO finish me*/
}
#endif
@@ -514,54 +514,54 @@ static void __glXAquaDrawableDestroy(__GLXdrawable *base) {
* does this too...
*/
__GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *)base;
-
+
GLAQUA_DEBUG_MSG("TRACE");
/* It doesn't work to call DRIDestroySurface here, the drawable's
- already gone.. But dri.c notices the window destruction and
- frees the surface itself. */
-
+ already gone.. But dri.c notices the window destruction and
+ frees the surface itself. */
+
/*gstaplin: verify the statement above. The surface destroy
*messages weren't making it through, and may still not be.
*We need a good test case for surface creation and destruction.
*We also need a good way to enable introspection on the server
*to validate the test, beyond using gdb with print.
*/
-
+
free(glxPriv);
}
static __GLXdrawable *
__glXAquaScreenCreateDrawable(ClientPtr client,
__GLXscreen *screen,
- DrawablePtr pDraw,
- XID drawId,
- int type,
- XID glxDrawId,
- __GLXconfig *conf) {
- __GLXAquaDrawable *glxPriv;
-
- glxPriv = malloc(sizeof *glxPriv);
-
- if(glxPriv == NULL)
- return NULL;
-
- memset(glxPriv, 0, sizeof *glxPriv);
-
- if(!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
- free(glxPriv);
- return NULL;
- }
-
- glxPriv->base.destroy = __glXAquaDrawableDestroy;
- glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers;
- glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */
-
- glxPriv->pDraw = pDraw;
- glxPriv->sid = 0;
- glxPriv->context = NULL;
-
- return &glxPriv->base;
+ DrawablePtr pDraw,
+ XID drawId,
+ int type,
+ XID glxDrawId,
+ __GLXconfig *conf) {
+ __GLXAquaDrawable *glxPriv;
+
+ glxPriv = malloc(sizeof *glxPriv);
+
+ if(glxPriv == NULL)
+ return NULL;
+
+ memset(glxPriv, 0, sizeof *glxPriv);
+
+ if(!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
+ free(glxPriv);
+ return NULL;
+ }
+
+ glxPriv->base.destroy = __glXAquaDrawableDestroy;
+ glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers;
+ glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */
+
+ glxPriv->pDraw = pDraw;
+ glxPriv->sid = 0;
+ glxPriv->context = NULL;
+
+ return &glxPriv->base;
}
// Extra goodies for glx
@@ -569,7 +569,7 @@ __glXAquaScreenCreateDrawable(ClientPtr client,
GLuint __glFloorLog2(GLuint val)
{
int c = 0;
-
+
while (val > 1) {
c++;
val >>= 1;
@@ -585,28 +585,28 @@ static void setup_dispatch_table(void) {
static struct _glapi_table *disp = NULL;
static void *handle;
const char *opengl_framework_path;
-
+
if(disp) {
_glapi_set_dispatch(disp);
return;
}
-
+
opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
if (!opengl_framework_path) {
opengl_framework_path = OPENGL_FRAMEWORK_PATH;
}
-
+
(void) dlerror(); /*drain dlerror */
handle = dlopen(opengl_framework_path, RTLD_LOCAL);
-
+
if (!handle) {
ErrorF("unable to dlopen %s : %s, using RTLD_DEFAULT\n",
- opengl_framework_path, dlerror());
+ opengl_framework_path, dlerror());
handle = RTLD_DEFAULT;
}
-
+
disp = _glapi_create_table_from_handle(handle, "gl");
assert(disp);
-
+
_glapi_set_dispatch(disp);
}
diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c
index 2c2a9a29e..8502f35b8 100644
--- a/hw/xquartz/GL/visualConfigs.c
+++ b/hw/xquartz/GL/visualConfigs.c
@@ -139,9 +139,9 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->visualID = -1;
c->visualType = GLX_TRUE_COLOR;
c->next = c + 1;
-
+
c->screen = screenNumber;
-
+
c->level = 0;
c->indexBits = 0;
c->pixmapMode = 0; // TODO: What should this be?
@@ -165,13 +165,13 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
// Stereo
c->stereoMode = stereo ? TRUE : FALSE;
-
+
// Aux buffers
c->numAuxBuffers = aux ? conf->aux_buffers : 0;
// Double Buffered
c->doubleBufferMode = buffers ? TRUE : FALSE;
-
+
// Stencil Buffer
if(conf->total_stencil_bit_depths > 0) {
c->stencilBits = conf->stencil_bit_depths[stencil];
@@ -190,12 +190,12 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->blueBits = conf->color_buffers[color].b;
c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits;
-
+
c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
c->redMask = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
c->blueMask = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
-
+
// Accumulation Buffers
if(conf->total_accum_buffers > 0) {
c->accumRedBits = conf->accum_buffers[accum].r;
@@ -212,7 +212,7 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->accumBlueBits = 0;
c->accumAlphaBits = 0;
}
-
+
// Depth
c->depthBits = conf->depth_buffers[depth];
@@ -272,9 +272,9 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
}
}
}
-
+
(c-1)->next = NULL;
-
+
if (c - visualConfigs != numConfigs) {
FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, (int)(c - visualConfigs));
}
diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 09d196b2b..476b2d341 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -1,31 +1,32 @@
/* X11Application.h -- subclass of NSApplication to multiplex events
-
- Copyright (c) 2002-2007 Apple Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
#ifndef X11APPLICATION_H
#define X11APPLICATION_H 1
@@ -36,7 +37,7 @@
@interface X11Application : NSApplication {
X11Controller *_controller;
-
+
unsigned int _x_active :1;
}
@@ -66,7 +67,7 @@ extern X11Application *X11App;
#endif /* __OBJC__ */
void X11ApplicationSetWindowMenu (int nitems, const char **items,
- const char *shortcuts);
+ const char *shortcuts);
void X11ApplicationSetWindowMenuCheck (int idx);
void X11ApplicationSetFrontProcess (void);
void X11ApplicationSetCanQuit (int state);
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 47ba867a9..18f6f3f49 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1,31 +1,32 @@
/* X11Application.m -- subclass of NSApplication to multiplex events
-
- Copyright (c) 2002-2008 Apple Inc.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
#include "sanitizedCarbon.h"
@@ -113,7 +114,7 @@ struct message_struct {
static mach_port_t _port;
/* Quartz mode initialization routine. This is often dynamically loaded
- but is statically linked into this X server. */
+ but is statically linked into this X server. */
Bool QuartzModeBundleInit(void);
static void init_ports (void) {
@@ -145,7 +146,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
msg.arg = [arg retain];
r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
- 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+ 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
if (r != KERN_SUCCESS)
ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r);
}
@@ -179,15 +180,15 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
infoDict = [[NSBundle mainBundle] infoDictionary];
[dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
- forKey:@"ApplicationName"];
+ forKey:@"ApplicationName"];
tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
[dict setObject:[NSString stringWithFormat:@"XQuartz %@", tem]
- forKey:@"ApplicationVersion"];
-
+ forKey:@"ApplicationVersion"];
+
[dict setObject:[NSString stringWithFormat:@"xorg-server %s", XSERVER_VERSION]
- forKey:@"Version"];
+ forKey:@"Version"];
[self orderFrontStandardAboutPanelWithOptions: dict];
}
@@ -195,7 +196,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
- (void) activateX:(OSX_BOOL)state {
if (_x_active == state)
return;
-
+
DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active);
if (state) {
if(bgMouseLocationUpdated) {
@@ -204,19 +205,19 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
}
DarwinSendDDXEvent(kXquartzActivate, 0);
} else {
-
+
if(darwin_all_modifier_flags)
DarwinUpdateModKeys(0);
-
+
DarwinInputReleaseButtonsAndKeys(darwinKeyboard);
DarwinInputReleaseButtonsAndKeys(darwinPointer);
DarwinInputReleaseButtonsAndKeys(darwinTabletCursor);
DarwinInputReleaseButtonsAndKeys(darwinTabletStylus);
DarwinInputReleaseButtonsAndKeys(darwinTabletEraser);
-
+
DarwinSendDDXEvent(kXquartzDeactivate, 0);
}
-
+
_x_active = state;
}
@@ -248,7 +249,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
[self activateX:YES];
}
}
-
+
/* We want to force sending to appkit if we're over the menu bar */
if(!for_appkit) {
NSPoint NSlocation = [e locationInWindow];
@@ -256,22 +257,22 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
NSRect NSframe, NSvisibleFrame;
CGRect CGframe, CGvisibleFrame;
CGPoint CGlocation;
-
+
if (window != nil) {
NSRect frame = [window frame];
NSlocation.x += frame.origin.x;
NSlocation.y += frame.origin.y;
}
-
+
NSframe = [[NSScreen mainScreen] frame];
NSvisibleFrame = [[NSScreen mainScreen] visibleFrame];
CGframe = CGRectMake(NSframe.origin.x, NSframe.origin.y,
- NSframe.size.width, NSframe.size.height);
+ NSframe.size.width, NSframe.size.height);
CGvisibleFrame = CGRectMake(NSvisibleFrame.origin.x,
- NSvisibleFrame.origin.y,
- NSvisibleFrame.size.width,
- NSvisibleFrame.size.height);
+ NSvisibleFrame.origin.y,
+ NSvisibleFrame.size.width,
+ NSvisibleFrame.size.height);
CGlocation = CGPointMake(NSlocation.x, NSlocation.y);
if(CGRectContainsPoint(CGframe, CGlocation) &&
@@ -290,7 +291,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
if([e type] == NSKeyDown) {
/* Before that though, see if there are any global
* shortcuts bound to it. */
-
+
if(darwinAppKitModMask & [e modifierFlags]) {
/* Override to force sending to Appkit */
swallow_keycode = [e keyCode];
@@ -298,7 +299,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
for_x = NO;
#if XPLUGIN_VERSION >= 1
} else if(XQuartzEnableKeyEquivalents &&
- xp_is_symbolic_hotkey_event([e eventRef])) {
+ xp_is_symbolic_hotkey_event([e eventRef])) {
swallow_keycode = [e keyCode];
do_swallow = YES;
for_x = NO;
@@ -344,27 +345,27 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
case NSAppKitDefined:
switch ([e subtype]) {
- static BOOL x_was_active = NO;
-
+ static BOOL x_was_active = NO;
+
case NSApplicationActivatedEventType:
for_x = NO;
if ([e window] == nil && x_was_active) {
BOOL order_all_windows = YES, workspaces, ok;
for_appkit = NO;
-
+
/* FIXME: This is a hack to avoid passing the event to AppKit which
* would result in it raising one of its windows.
*/
_appFlags._active = YES;
-
+
[self set_front_process:nil];
-
+
/* Get the Spaces preference for SwitchOnActivate */
(void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock"));
workspaces = CFPreferencesGetAppBooleanValue(CFSTR("workspaces"), CFSTR("com.apple.dock"), &ok);
if (!ok)
workspaces = NO;
-
+
if (workspaces) {
(void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
order_all_windows = CFPreferencesGetAppBooleanValue(CFSTR("AppleSpacesSwitchOnActivate"), CFSTR(".GlobalPreferences"), &ok);
@@ -391,7 +392,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
case NSApplicationDeactivatedEventType:
for_x = NO;
-
+
x_was_active = _x_active;
if(_x_active)
[self activateX:NO];
@@ -429,7 +430,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
- (void) set_front_process:unused {
[NSApp activateIgnoringOtherApps:YES];
-
+
if ([self modalWindow] == nil)
[self activateX:YES];
}
@@ -473,27 +474,27 @@ static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
NSObject *ns;
const CFTypeRef *cf;
int i, count;
-
+
memset (&cb, 0, sizeof (cb));
cb.version = 0;
cb.retain = cfretain;
cb.release = cfrelease;
-
+
count = [in count];
out = CFArrayCreateMutable (NULL, count, &cb);
-
+
for (i = 0; i < count; i++) {
ns = [in objectAtIndex:i];
-
+
if ([ns isKindOfClass:[NSArray class]])
cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
else
cf = CFRetain ((CFTypeRef) ns);
-
+
CFArrayAppendValue (out, cf);
CFRelease (cf);
}
-
+
return out;
}
@@ -502,22 +503,22 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
const CFTypeRef *cf;
NSObject *ns;
int i, count;
-
+
count = CFArrayGetCount (in);
out = [[NSMutableArray alloc] initWithCapacity:count];
-
+
for (i = 0; i < count; i++) {
cf = CFArrayGetValueAtIndex (in, i);
-
+
if (CFGetTypeID (cf) == CFArrayGetTypeID ())
ns = cfarray_to_nsarray ((CFArrayRef) cf);
else
ns = [(id)cf retain];
-
+
[out addObject:ns];
[ns release];
}
-
+
return out;
}
@@ -527,90 +528,90 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
value = CFPreferencesCopyAppValue ((CFStringRef) key, app_prefs_domain_cfstr);
if (value == NULL) {
- static CFDictionaryRef defaults;
-
- if (defaults == NULL) {
- CFStringRef error = NULL;
- CFDataRef data;
- CFURLRef url;
- SInt32 error_code;
-
- url = (CFURLCreateFromFileSystemRepresentation
- (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
- if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
- NULL, NULL, &error_code)) {
- defaults = (CFPropertyListCreateFromXMLData
- (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
- if (error != NULL) CFRelease (error);
- CFRelease (data);
- }
- CFRelease (url);
+ static CFDictionaryRef defaults;
+
+ if (defaults == NULL) {
+ CFStringRef error = NULL;
+ CFDataRef data;
+ CFURLRef url;
+ SInt32 error_code;
+
+ url = (CFURLCreateFromFileSystemRepresentation
+ (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
+ if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
+ NULL, NULL, &error_code)) {
+ defaults = (CFPropertyListCreateFromXMLData
+ (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
+ if (error != NULL) CFRelease (error);
+ CFRelease (data);
+ }
+ CFRelease (url);
- if (defaults != NULL) {
- NSMutableArray *apps, *elt;
- int count, i;
- NSString *name, *nname;
-
- /* Localize the names in the default apps menu. */
-
- apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
- if (apps != nil) {
- count = [apps count];
- for (i = 0; i < count; i++) {
- elt = [apps objectAtIndex:i];
- if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
- name = [elt objectAtIndex:0];
- if (name != nil) {
- nname = NSLocalizedString (name, nil);
- if (nname != nil && nname != name)
- [elt replaceObjectAtIndex:0 withObject:nname];
- }
- }
- }
- }
- }
- }
+ if (defaults != NULL) {
+ NSMutableArray *apps, *elt;
+ int count, i;
+ NSString *name, *nname;
+
+ /* Localize the names in the default apps menu. */
+
+ apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
+ if (apps != nil) {
+ count = [apps count];
+ for (i = 0; i < count; i++) {
+ elt = [apps objectAtIndex:i];
+ if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
+ name = [elt objectAtIndex:0];
+ if (name != nil) {
+ nname = NSLocalizedString (name, nil);
+ if (nname != nil && nname != name)
+ [elt replaceObjectAtIndex:0 withObject:nname];
+ }
+ }
+ }
+ }
+ }
+ }
- if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
- if (value != NULL) CFRetain (value);
+ if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
+ if (value != NULL) CFRetain (value);
}
return value;
}
- (int) prefs_get_integer:(NSString *)key default:(int)def {
- CFPropertyListRef value;
- int ret;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
- CFNumberGetValue (value, kCFNumberIntType, &ret);
- else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
- ret = CFStringGetIntValue (value);
- else
- ret = def;
-
- if (value != NULL) CFRelease (value);
-
- return ret;
+ CFPropertyListRef value;
+ int ret;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
+ CFNumberGetValue (value, kCFNumberIntType, &ret);
+ else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+ ret = CFStringGetIntValue (value);
+ else
+ ret = def;
+
+ if (value != NULL) CFRelease (value);
+
+ return ret;
}
- (const char *) prefs_get_string:(NSString *)key default:(const char *)def {
- CFPropertyListRef value;
- const char *ret = NULL;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
- NSString *s = (NSString *) value;
-
- ret = [s UTF8String];
- }
-
- if (value != NULL) CFRelease (value);
-
- return ret != NULL ? ret : def;
+ CFPropertyListRef value;
+ const char *ret = NULL;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
+ NSString *s = (NSString *) value;
+
+ ret = [s UTF8String];
+ }
+
+ if (value != NULL) CFRelease (value);
+
+ return ret != NULL ? ret : def;
}
- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def {
@@ -621,7 +622,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
NSString *s = (NSString *) value;
-
+
ret = [NSURL URLWithString:s];
[ret retain];
}
@@ -632,61 +633,61 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
}
- (float) prefs_get_float:(NSString *)key default:(float)def {
- CFPropertyListRef value;
- float ret = def;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL
- && CFGetTypeID (value) == CFNumberGetTypeID ()
- && CFNumberIsFloatType (value))
- CFNumberGetValue (value, kCFNumberFloatType, &ret);
- else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
- ret = CFStringGetDoubleValue (value);
+ CFPropertyListRef value;
+ float ret = def;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL
+ && CFGetTypeID (value) == CFNumberGetTypeID ()
+ && CFNumberIsFloatType (value))
+ CFNumberGetValue (value, kCFNumberFloatType, &ret);
+ else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+ ret = CFStringGetDoubleValue (value);
- if (value != NULL) CFRelease (value);
-
- return ret;
+ if (value != NULL) CFRelease (value);
+
+ return ret;
}
- (int) prefs_get_boolean:(NSString *)key default:(int)def {
- CFPropertyListRef value;
- int ret = def;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL) {
- if (CFGetTypeID (value) == CFNumberGetTypeID ())
- CFNumberGetValue (value, kCFNumberIntType, &ret);
- else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
- ret = CFBooleanGetValue (value);
- else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
- const char *tem = [(NSString *) value UTF8String];
- if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
- ret = YES;
- else
- ret = NO;
- }
+ CFPropertyListRef value;
+ int ret = def;
- CFRelease (value);
- }
- return ret;
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL) {
+ if (CFGetTypeID (value) == CFNumberGetTypeID ())
+ CFNumberGetValue (value, kCFNumberIntType, &ret);
+ else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
+ ret = CFBooleanGetValue (value);
+ else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
+ const char *tem = [(NSString *) value UTF8String];
+ if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
+ ret = YES;
+ else
+ ret = NO;
+ }
+
+ CFRelease (value);
+ }
+ return ret;
}
- (NSArray *) prefs_get_array:(NSString *)key {
- NSArray *ret = nil;
- CFPropertyListRef value;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL) {
- if (CFGetTypeID (value) == CFArrayGetTypeID ())
- ret = [cfarray_to_nsarray (value) autorelease];
-
- CFRelease (value);
- }
-
- return ret;
+ NSArray *ret = nil;
+ CFPropertyListRef value;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL) {
+ if (CFGetTypeID (value) == CFArrayGetTypeID ())
+ ret = [cfarray_to_nsarray (value) autorelease];
+
+ CFRelease (value);
+ }
+
+ return ret;
}
- (void) prefs_set_integer:(NSString *)key value:(int)value {
@@ -695,7 +696,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
x = CFNumberCreate (NULL, kCFNumberIntType, &value);
CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFRelease (x);
}
@@ -706,34 +707,34 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFRelease (x);
}
- (void) prefs_set_boolean:(NSString *)key value:(int)value {
- CFPreferencesSetValue ((CFStringRef) key,
- (CFTypeRef) (value ? kCFBooleanTrue
- : kCFBooleanFalse), app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-
+ CFPreferencesSetValue ((CFStringRef) key,
+ (CFTypeRef) (value ? kCFBooleanTrue
+ : kCFBooleanFalse), app_prefs_domain_cfstr,
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+
}
- (void) prefs_set_array:(NSString *)key value:(NSArray *)value {
- CFArrayRef cfarray;
-
- cfarray = nsarray_to_cfarray (value);
- CFPreferencesSetValue ((CFStringRef) key,
- (CFTypeRef) cfarray,
- app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
- CFRelease (cfarray);
+ CFArrayRef cfarray;
+
+ cfarray = nsarray_to_cfarray (value);
+ CFPreferencesSetValue ((CFStringRef) key,
+ (CFTypeRef) cfarray,
+ app_prefs_domain_cfstr,
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ CFRelease (cfarray);
}
- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
- CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
- app_prefs_domain_cfstr, kCFPreferencesCurrentUser,
- kCFPreferencesAnyHost);
+ CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
+ app_prefs_domain_cfstr, kCFPreferencesCurrentUser,
+ kCFPreferencesAnyHost);
}
- (void) prefs_synchronize {
@@ -746,26 +747,26 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
const char *tem;
XQuartzRootlessDefault = [self prefs_get_boolean:@PREFS_ROOTLESS
- default:XQuartzRootlessDefault];
+ default:XQuartzRootlessDefault];
XQuartzFullscreenMenu = [self prefs_get_boolean:@PREFS_FULLSCREEN_MENU
- default:XQuartzFullscreenMenu];
+ default:XQuartzFullscreenMenu];
XQuartzFullscreenDisableHotkeys = ![self prefs_get_boolean:@PREFS_FULLSCREEN_HOTKEYS
- default:!XQuartzFullscreenDisableHotkeys];
+ default:!XQuartzFullscreenDisableHotkeys];
darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
default:darwinFakeButtons];
XQuartzOptionSendsAlt = [self prefs_get_boolean:@PREFS_OPTION_SENDS_ALT
- default:XQuartzOptionSendsAlt];
-
+ default:XQuartzOptionSendsAlt];
+
if (darwinFakeButtons) {
const char *fake2, *fake3;
-
+
fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
-
+
if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2, TRUE);
if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3, TRUE);
}
-
+
tem = [self prefs_get_string:@PREFS_APPKIT_MODIFIERS default:NULL];
if (tem != NULL) darwinAppKitModMask = DarwinParseModifierList(tem, TRUE);
@@ -781,13 +782,13 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
}
}
}
-
+
XQuartzEnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
- default:XQuartzEnableKeyEquivalents];
+ default:XQuartzEnableKeyEquivalents];
darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
default:darwinSyncKeymap];
-
+
darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
default:darwinDesiredDepth];
@@ -795,11 +796,11 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
default:FALSE];
noRenderExtension = ![self prefs_get_boolean:@PREFS_RENDER_EXTENSION
- default:TRUE];
+ default:TRUE];
XQuartzScrollInDeviceDirection = [self prefs_get_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION
default:XQuartzScrollInDeviceDirection];
-
+
#if XQUARTZ_SPARKLE
NSURL *url = [self prefs_copy_url:@PREFS_UPDATE_FEED default:nil];
if(url) {
@@ -811,8 +812,8 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
/* This will end up at the end of the responder chain. */
- (void) copy:sender {
- DarwinSendDDXEvent(kXquartzPasteboardNotify, 1,
- AppleWMCopyToPasteboard);
+ DarwinSendDDXEvent(kXquartzPasteboardNotify, 1,
+ AppleWMCopyToPasteboard);
}
- (X11Controller *) controller {
@@ -827,55 +828,55 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
static NSArray *
array_with_strings_and_numbers (int nitems, const char **items,
- const char *numbers) {
- NSMutableArray *array, *subarray;
- NSString *string, *number;
- int i;
+ const char *numbers) {
+ NSMutableArray *array, *subarray;
+ NSString *string, *number;
+ int i;
- /* (Can't autorelease on the X server thread) */
-
- array = [[NSMutableArray alloc] initWithCapacity:nitems];
-
- for (i = 0; i < nitems; i++) {
- subarray = [[NSMutableArray alloc] initWithCapacity:2];
-
- string = [[NSString alloc] initWithUTF8String:items[i]];
- [subarray addObject:string];
- [string release];
+ /* (Can't autorelease on the X server thread) */
+
+ array = [[NSMutableArray alloc] initWithCapacity:nitems];
+
+ for (i = 0; i < nitems; i++) {
+ subarray = [[NSMutableArray alloc] initWithCapacity:2];
+
+ string = [[NSString alloc] initWithUTF8String:items[i]];
+ [subarray addObject:string];
+ [string release];
+
+ if (numbers[i] != 0) {
+ number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
+ [subarray addObject:number];
+ [number release];
+ } else
+ [subarray addObject:@""];
+
+ [array addObject:subarray];
+ [subarray release];
+ }
- if (numbers[i] != 0) {
- number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
- [subarray addObject:number];
- [number release];
- } else
- [subarray addObject:@""];
-
- [array addObject:subarray];
- [subarray release];
- }
-
- return array;
+ return array;
}
void X11ApplicationSetWindowMenu (int nitems, const char **items,
- const char *shortcuts) {
- NSArray *array;
- array = array_with_strings_and_numbers (nitems, items, shortcuts);
-
- /* Send the array of strings over to the appkit thread */
-
- message_kit_thread (@selector (set_window_menu:), array);
- [array release];
+ const char *shortcuts) {
+ NSArray *array;
+ array = array_with_strings_and_numbers (nitems, items, shortcuts);
+
+ /* Send the array of strings over to the appkit thread */
+
+ message_kit_thread (@selector (set_window_menu:), array);
+ [array release];
}
void X11ApplicationSetWindowMenuCheck (int idx) {
- NSNumber *n;
-
- n = [[NSNumber alloc] initWithInt:idx];
-
- message_kit_thread (@selector (set_window_menu_check:), n);
-
- [n release];
+ NSNumber *n;
+
+ n = [[NSNumber alloc] initWithInt:idx];
+
+ message_kit_thread (@selector (set_window_menu_check:), n);
+
+ [n release];
}
void X11ApplicationSetFrontProcess (void) {
@@ -929,7 +930,7 @@ Bool X11ApplicationCanEnterRandR(void) {
title = NSLocalizedString(@"Enter RandR mode?", @"Dialog title when switching to RandR");
msg = NSLocalizedString(@"An application has requested X11 to change the resolution of your display. X11 will restore the display to its previous state when the requesting application requests to return to the previous state. Alternatively, you can use the ⌥⌘A key sequence to force X11 to return to the previous state.",
@"Dialog when switching to RandR");
-
+
if(!XQuartzIsRootless)
QuartzShowFullscreen(FALSE);
@@ -939,7 +940,7 @@ Bool X11ApplicationCanEnterRandR(void) {
[X11App prefs_synchronize];
case NSAlertDefaultReturn:
return YES;
-
+
default:
return NO;
}
@@ -949,7 +950,7 @@ void X11ApplicationFatalError(const char *f, va_list args) {
#ifdef HAVE_LIBDISPATCH
NSString *title, *msg;
char *error_msg;
-
+
/* This is called by FatalError() in the server thread just before
* we would abort. If the server never got off the ground, We should
* inform the user of the error rather than letting the ever-so-friendly
@@ -959,19 +960,19 @@ void X11ApplicationFatalError(const char *f, va_list args) {
* allowing an infinite throttled-restart if the crash occurs before
* we can drain the launchd socket.
*/
-
+
if (serverRunning) {
return;
}
-
+
title = NSLocalizedString(@"The application X11 could not be opened.",
@"Dialog title when encountering a fatal error");
msg = NSLocalizedString(@"An error occurred while starting the X11 server: \"%s\"\n\nClick Quit to quit X11. Click Report to see more details or send a report to Apple.",
@"Dialog when encountering a fatal error");
-
+
vasprintf(&error_msg, f, args);
msg = [NSString stringWithFormat:msg, error_msg];
-
+
/* We want the AppKit thread to actually service the alert or we will race [NSApp run] and create an
* 'NSInternalInconsistencyException', reason: 'NSApp with wrong _running count'
*/
@@ -981,7 +982,7 @@ void X11ApplicationFatalError(const char *f, va_list args) {
exit(EXIT_FAILURE);
}
});
-
+
/* fall back to caller to do the abort() in the DIX */
#endif
}
@@ -1002,25 +1003,25 @@ static void check_xinitrc (void) {
goto done;
msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
-Windows displayed by X11 applications may not have titlebars, or may look \
-different to windows displayed by native applications.\n\n\
-Would you like to move aside the existing file and use the standard X11 \
-environment the next time you start X11?", @"Startup xinitrc dialog");
-
+ Windows displayed by X11 applications may not have titlebars, or may look \
+ different to windows displayed by native applications.\n\n\
+ Would you like to move aside the existing file and use the standard X11 \
+ environment the next time you start X11?", @"Startup xinitrc dialog");
+
if(NSAlertDefaultReturn == NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
NSLocalizedString (@"No", @""), nil)) {
char buf2[1024];
int i = -1;
-
+
snprintf (buf2, sizeof (buf2), "%s.old", buf);
-
+
for(i = 1; access (buf2, F_OK) == 0; i++)
snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
-
+
rename (buf, buf2);
}
- done:
+done:
[X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
[X11App prefs_synchronize];
}
@@ -1040,45 +1041,45 @@ static inline pthread_t create_thread(void *(*func)(void *), void *arg) {
static void *xpbproxy_x_thread(void *args) {
xpbproxy_run();
-
+
ErrorF("xpbproxy thread is terminating unexpectedly.\n");
return NULL;
}
void X11ApplicationMain (int argc, char **argv, char **envp) {
NSAutoreleasePool *pool;
-
+
#ifdef DEBUG
while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
#endif
-
+
pool = [[NSAutoreleasePool alloc] init];
X11App = (X11Application *) [X11Application sharedApplication];
init_ports ();
app_prefs_domain_cfstr = (CFStringRef)[[NSBundle mainBundle] bundleIdentifier];
-
+
if (app_prefs_domain_cfstr == NULL) {
ErrorF("X11ApplicationMain: Unable to determine bundle identifier. Your installation of XQuartz may be broken.\n");
app_prefs_domain_cfstr = CFSTR(BUNDLE_ID_PREFIX".X11");
}
-
+
[NSApp read_defaults];
[NSBundle loadNibNamed:@"main" owner:NSApp];
[[NSNotificationCenter defaultCenter] addObserver:NSApp
- selector:@selector (became_key:)
- name:NSWindowDidBecomeKeyNotification object:nil];
-
+ selector:@selector (became_key:)
+ name:NSWindowDidBecomeKeyNotification object:nil];
+
/*
* The xpr Quartz mode is statically linked into this server.
* Initialize all the Quartz functions.
*/
QuartzModeBundleInit();
-
+
/* Calculate the height of the menubar so we can avoid it. */
aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
NSMaxY([[NSScreen mainScreen] visibleFrame]);
-
+
#ifdef HAVE_LIBDISPATCH
eventTranslationQueue = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL);
assert(eventTranslationQueue != NULL);
@@ -1087,7 +1088,7 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
/* Set the key layout seed before we start the server */
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
-
+
if(!last_key_layout)
ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
#else
@@ -1095,11 +1096,11 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
if(!last_key_layout)
ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
#endif
-
+
if (!QuartsResyncKeymap(FALSE)) {
ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
}
-
+
/* Tell the server thread that it can proceed */
QuartzInitServer(argc, argv, envp);
@@ -1109,13 +1110,13 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
check_xinitrc();
create_thread(xpbproxy_x_thread, NULL);
-
+
#if XQUARTZ_SPARKLE
[[X11App controller] setup_sparkle];
[[SUUpdater sharedUpdater] resetUpdateCycle];
-// [[SUUpdater sharedUpdater] checkForUpdates:X11App];
+ // [[SUUpdater sharedUpdater] checkForUpdates:X11App];
#endif
-
+
[pool release];
[NSApp run];
/* not reached */
@@ -1173,7 +1174,7 @@ static const char *untrusted_str(NSEvent *e) {
DeviceIntPtr pDev;
int modifierFlags;
BOOL isMouseOrTabletEvent, isTabletEvent;
-
+
#ifdef HAVE_LIBDISPATCH
static dispatch_once_t once_pred;
dispatch_once(&once_pred, ^{
@@ -1188,13 +1189,13 @@ static const char *untrusted_str(NSEvent *e) {
#endif
isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown ||
- [e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
- [e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
- [e type] == NSMouseMoved || [e type] == NSTabletPoint || [e type] == NSScrollWheel;
-
+ [e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
+ [e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
+ [e type] == NSMouseMoved || [e type] == NSTabletPoint || [e type] == NSScrollWheel;
+
isTabletEvent = ([e type] == NSTabletPoint) ||
- (isMouseOrTabletEvent && ([e subtype] == NSTabletPointEventSubtype || [e subtype] == NSTabletProximityEventSubtype));
-
+ (isMouseOrTabletEvent && ([e subtype] == NSTabletPointEventSubtype || [e subtype] == NSTabletProximityEventSubtype));
+
if(isMouseOrTabletEvent) {
static NSPoint lastpt;
NSWindow *window = [e window];
@@ -1212,11 +1213,11 @@ static const char *untrusted_str(NSEvent *e) {
// <rdar://problem/7979468> deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS
// http://xquartz.macosforge.org/trac/ticket/389
hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp;
-
+
// The deltaXY for scroll events correspond to the scroll delta, not the pointer delta
// <rdar://problem/7989690> deltaXY for wheel events are being sent as mouse movement
hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSScrollWheel;
-
+
#ifdef DEBUG_UNTRUSTED_POINTER_DELTA
hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSLeftMouseDown || [e type] == NSLeftMouseUp;
#endif
@@ -1236,7 +1237,7 @@ static const char *untrusted_str(NSEvent *e) {
ErrorF(" location: (%0.2f, %0.2f)\n", lastpt.x + [e deltaX], lastpt.y - [e deltaY]);
ErrorF("workaround: (%0.2f, %0.2f)\n", [e locationInWindow].x, [e locationInWindow].y);
ErrorF("--- End Event Debug ---\n");
-
+
location.x = lastpt.x + [e deltaX];
location.y = lastpt.y - [e deltaY];
lastpt = [e locationInWindow];
@@ -1265,9 +1266,9 @@ static const char *untrusted_str(NSEvent *e) {
modifierFlags = ensure_flag(modifierFlags, NX_COMMANDMASK, NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK, NX_DEVICELCMDKEYMASK);
modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK, NX_DEVICELALTKEYMASK);
#endif
-
+
modifierFlags &= darwin_all_modifier_mask;
-
+
/* We don't receive modifier key events while out of focus, and 3button
* emulation mucks this up, so we need to check our modifier flag state
* on every event... ugg
@@ -1291,7 +1292,7 @@ static const char *untrusted_str(NSEvent *e) {
handle_mouse:
pDev = darwinPointer;
-
+
/* NSTabletPoint can have no subtype */
if([e type] != NSTabletPoint &&
[e subtype] == NSTabletProximityEventSubtype) {
@@ -1308,7 +1309,7 @@ static const char *untrusted_str(NSEvent *e) {
darwinTabletCurrent=darwinTabletCursor;
break;
}
-
+
if([e isEnteringProximity])
needsProximityIn = YES;
else
@@ -1317,7 +1318,7 @@ static const char *untrusted_str(NSEvent *e) {
tilt.x, tilt.y);
return;
}
-
+
if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
pressure = [e pressure];
tilt = [e tilt];
@@ -1328,25 +1329,25 @@ static const char *untrusted_str(NSEvent *e) {
DarwinSendProximityEvents(darwinTabletCurrent, ProximityIn,
location.x, location.y, pressure,
tilt.x, tilt.y);
-
+
needsProximityIn = NO;
}
}
-
+
if(!XQuartzServerVisible && noTestExtensions) {
#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
-/* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
+ /* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
xp_window_id wid = 0;
xp_error err;
-
+
/* Sigh. Need to check that we're really over one of
* our windows. (We need to receive pointer events while
* not in the foreground, but we don't want to receive them
* when another window is over us or we might show a tooltip)
*/
-
+
err = xp_find_window(location.x, location.y, 0, &wid);
-
+
if (err != XP_Success || (err == XP_Success && wid == 0))
#endif
{
@@ -1363,7 +1364,7 @@ static const char *untrusted_str(NSEvent *e) {
}
bgMouseLocationUpdated = FALSE;
}
-
+
DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x, location.y,
pressure, tilt.x, tilt.y);
@@ -1393,42 +1394,42 @@ static const char *untrusted_str(NSEvent *e) {
break;
case NSScrollWheel:
- {
- float deltaX = [e deltaX];
- float deltaY = [e deltaY];
+ {
+ float deltaX = [e deltaX];
+ float deltaY = [e deltaY];
#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0
- /* If we're in the background, we need to send a MotionNotify event
- * first, since we aren't getting them on background mouse motion
- */
- if(!XQuartzServerVisible && noTestExtensions) {
- bgMouseLocationUpdated = FALSE;
- DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x,
- location.y, pressure, tilt.x, tilt.y);
- }
+ /* If we're in the background, we need to send a MotionNotify event
+ * first, since we aren't getting them on background mouse motion
+ */
+ if(!XQuartzServerVisible && noTestExtensions) {
+ bgMouseLocationUpdated = FALSE;
+ DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x,
+ location.y, pressure, tilt.x, tilt.y);
+ }
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- // TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
- if(NSAppKitVersionNumber >= 1117 && XQuartzScrollInDeviceDirection && [e isDirectionInvertedFromDevice]) {
- deltaX *= -1;
- deltaY *= -1;
- }
-#endif
- DarwinSendScrollEvents(deltaX, deltaY, location.x, location.y,
- pressure, tilt.x, tilt.y);
- break;
+ // TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
+ if(NSAppKitVersionNumber >= 1117 && XQuartzScrollInDeviceDirection && [e isDirectionInvertedFromDevice]) {
+ deltaX *= -1;
+ deltaY *= -1;
}
+#endif
+ DarwinSendScrollEvents(deltaX, deltaY, location.x, location.y,
+ pressure, tilt.x, tilt.y);
+ break;
+ }
case NSKeyDown: case NSKeyUp:
- {
- /* XKB clobbers our keymap at startup, so we need to force it on the first keypress.
- * TODO: Make this less of a kludge.
- */
- static int force_resync_keymap = YES;
- if(force_resync_keymap) {
- DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
- force_resync_keymap = NO;
- }
+ {
+ /* XKB clobbers our keymap at startup, so we need to force it on the first keypress.
+ * TODO: Make this less of a kludge.
+ */
+ static int force_resync_keymap = YES;
+ if(force_resync_keymap) {
+ DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+ force_resync_keymap = NO;
}
-
+ }
+
if(darwinSyncKeymap) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
TISInputSourceRef key_layout = TISCopyCurrentKeyboardLayoutInputSource();
@@ -1441,23 +1442,23 @@ static const char *untrusted_str(NSEvent *e) {
last_key_layout = key_layout;
CFRelease(clear);
#else
- KeyboardLayoutRef key_layout;
- KLGetCurrentKeyboardLayout(&key_layout);
- if(key_layout != last_key_layout) {
- last_key_layout = key_layout;
+ KeyboardLayoutRef key_layout;
+ KLGetCurrentKeyboardLayout(&key_layout);
+ if(key_layout != last_key_layout) {
+ last_key_layout = key_layout;
#endif
- /* Update keyInfo */
- if (!QuartsResyncKeymap(TRUE)) {
- ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
+ /* Update keyInfo */
+ if (!QuartsResyncKeymap(TRUE)) {
+ ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
+ }
}
}
- }
-
- ev_type = ([e type] == NSKeyDown) ? KeyPress : KeyRelease;
- DarwinSendKeyboardEvents(ev_type, [e keyCode]);
- break;
-
- default: break; /* for gcc */
- }
-}
-@end
+
+ ev_type = ([e type] == NSKeyDown) ? KeyPress : KeyRelease;
+ DarwinSendKeyboardEvents(ev_type, [e keyCode]);
+ break;
+
+ default: break; /* for gcc */
+ }
+ }
+ @end
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index b9b1d4473..7df02b81e 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -1,31 +1,32 @@
/* X11Controller.h -- connect the IB ui
-
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
#ifndef X11CONTROLLER_H
#define X11CONTROLLER_H 1
@@ -61,7 +62,7 @@ typedef unsigned int NSUInteger;
#endif
{
IBOutlet NSPanel *prefs_panel;
-
+
IBOutlet NSButton *fake_buttons;
IBOutlet NSButton *enable_fullscreen;
IBOutlet NSButton *enable_fullscreen_menu;
@@ -83,13 +84,13 @@ typedef unsigned int NSUInteger;
IBOutlet NSTextField *sync_text1;
IBOutlet NSTextField *sync_text2;
IBOutlet NSPopUpButton *depth;
-
+
IBOutlet NSMenuItem *window_separator;
// window_separator is DEPRECATED due to this radar:
// <rdar://problem/7088335> NSApplication releases the separator in the Windows menu even though it's an IBOutlet
// It is kept around for localization compatability and is subject to removal "eventually"
// If it is !NULL (meaning it is in the nib), it is removed from the menu and released
-
+
IBOutlet NSMenuItem *x11_about_item;
IBOutlet NSMenuItem *dock_window_separator;
IBOutlet NSMenuItem *apps_separator;
@@ -100,18 +101,18 @@ typedef unsigned int NSUInteger;
IBOutlet NSMenuItem *copy_menu_item;
IBOutlet NSMenu *dock_apps_menu;
IBOutlet NSTableView *apps_table;
-
+
NSArray *apps;
NSMutableArray *table_apps;
-
+
IBOutlet NSMenu *dock_menu;
// This is where in the Windows menu we'll start (this will be the index of the separator)
NSInteger windows_menu_start;
-
+
int checked_window_item;
x_list *pending_apps;
-
+
OSX_BOOL finished_launching;
OSX_BOOL can_quit;
}
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 3de4e139d..f6c47a15d 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -1,31 +1,32 @@
/* X11Controller.m -- connect the IB ui, also the NSApp delegate
-
- Copyright (c) 2002-2008 Apple Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
#include "sanitizedCarbon.h"
#include <AvailabilityMacros.h>
@@ -57,43 +58,43 @@
- (void) awakeFromNib
{
- X11Application *xapp = NSApp;
- NSArray *array;
+ X11Application *xapp = NSApp;
+ NSArray *array;
- /* Point X11Application at ourself. */
- [xapp set_controller:self];
+ /* Point X11Application at ourself. */
+ [xapp set_controller:self];
- array = [xapp prefs_get_array:@PREFS_APPSMENU];
- if (array != nil)
+ array = [xapp prefs_get_array:@PREFS_APPSMENU];
+ if (array != nil)
{
- int count;
+ int count;
- /* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
- to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
+ /* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
+ to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
- count = [array count];
- if (count > 0
- && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]])
- {
- int i;
- NSMutableArray *copy, *sub;
+ count = [array count];
+ if (count > 0
+ && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]])
+ {
+ int i;
+ NSMutableArray *copy, *sub;
- copy = [NSMutableArray arrayWithCapacity:(count / 2)];
+ copy = [NSMutableArray arrayWithCapacity:(count / 2)];
- for (i = 0; i < count / 2; i++)
- {
- sub = [[NSMutableArray alloc] initWithCapacity:3];
- [sub addObject:[array objectAtIndex:i*2]];
- [sub addObject:[array objectAtIndex:i*2+1]];
- [sub addObject:@""];
- [copy addObject:sub];
- [sub release];
- }
+ for (i = 0; i < count / 2; i++)
+ {
+ sub = [[NSMutableArray alloc] initWithCapacity:3];
+ [sub addObject:[array objectAtIndex:i*2]];
+ [sub addObject:[array objectAtIndex:i*2+1]];
+ [sub addObject:@""];
+ [copy addObject:sub];
+ [sub release];
+ }
- array = copy;
- }
+ array = copy;
+ }
- [self set_apps_menu:array];
+ [self set_apps_menu:array];
}
[[NSNotificationCenter defaultCenter]
@@ -101,7 +102,7 @@
selector: @selector(apps_table_done:)
name: NSWindowWillCloseNotification
object: [apps_table window]];
-
+
// Setup data about our Windows menu
if(window_separator) {
[[window_separator menu] removeItem:window_separator];
@@ -113,220 +114,220 @@
- (void) item_selected:sender
{
- [NSApp activateIgnoringOtherApps:YES];
+ [NSApp activateIgnoringOtherApps:YES];
- DarwinSendDDXEvent(kXquartzControllerNotify, 2,
- AppleWMWindowMenuItem, [sender tag]);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 2,
+ AppleWMWindowMenuItem, [sender tag]);
}
- (void) remove_window_menu
{
- NSMenu *menu;
- int count, i;
-
- /* Work backwards so we don't mess up the indices */
- menu = [X11App windowsMenu];
- count = [menu numberOfItems];
- for (i = count - 1; i >= windows_menu_start; i--)
- [menu removeItemAtIndex:i];
+ NSMenu *menu;
+ int count, i;
+
+ /* Work backwards so we don't mess up the indices */
+ menu = [X11App windowsMenu];
+ count = [menu numberOfItems];
+ for (i = count - 1; i >= windows_menu_start; i--)
+ [menu removeItemAtIndex:i];
- count = [dock_menu indexOfItem:dock_window_separator];
- for (i = 0; i < count; i++)
- [dock_menu removeItemAtIndex:0];
+ count = [dock_menu indexOfItem:dock_window_separator];
+ for (i = 0; i < count; i++)
+ [dock_menu removeItemAtIndex:0];
}
- (void) install_window_menu:(NSArray *)list
{
- NSMenu *menu;
- NSMenuItem *item;
- int first, count, i;
-
- menu = [X11App windowsMenu];
- first = windows_menu_start + 1;
- count = [list count];
-
- // Push a Separator
- if(count) {
- [menu addItem:[NSMenuItem separatorItem]];
- }
-
- for (i = 0; i < count; i++)
+ NSMenu *menu;
+ NSMenuItem *item;
+ int first, count, i;
+
+ menu = [X11App windowsMenu];
+ first = windows_menu_start + 1;
+ count = [list count];
+
+ // Push a Separator
+ if(count) {
+ [menu addItem:[NSMenuItem separatorItem]];
+ }
+
+ for (i = 0; i < count; i++)
{
- NSString *name, *shortcut;
+ NSString *name, *shortcut;
- name = [[list objectAtIndex:i] objectAtIndex:0];
- shortcut = [[list objectAtIndex:i] objectAtIndex:1];
+ name = [[list objectAtIndex:i] objectAtIndex:0];
+ shortcut = [[list objectAtIndex:i] objectAtIndex:1];
+
+ if(windowItemModMask == 0 || windowItemModMask == -1)
+ shortcut = @"";
+
+ item = (NSMenuItem *) [menu addItemWithTitle:name action:@selector
+ (item_selected:) keyEquivalent:shortcut];
+ [item setKeyEquivalentModifierMask:(NSUInteger) windowItemModMask];
+ [item setTarget:self];
+ [item setTag:i];
+ [item setEnabled:YES];
- if(windowItemModMask == 0 || windowItemModMask == -1)
- shortcut = @"";
-
- item = (NSMenuItem *) [menu addItemWithTitle:name action:@selector
- (item_selected:) keyEquivalent:shortcut];
- [item setKeyEquivalentModifierMask:(NSUInteger) windowItemModMask];
- [item setTarget:self];
- [item setTag:i];
- [item setEnabled:YES];
-
- item = (NSMenuItem *) [dock_menu insertItemWithTitle:name
- action:@selector
- (item_selected:) keyEquivalent:shortcut
- atIndex:i];
- [item setKeyEquivalentModifierMask:(NSUInteger) windowItemModMask];
- [item setTarget:self];
- [item setTag:i];
- [item setEnabled:YES];
+ item = (NSMenuItem *) [dock_menu insertItemWithTitle:name
+ action:@selector
+ (item_selected:) keyEquivalent:shortcut
+ atIndex:i];
+ [item setKeyEquivalentModifierMask:(NSUInteger) windowItemModMask];
+ [item setTarget:self];
+ [item setTag:i];
+ [item setEnabled:YES];
}
- if (checked_window_item >= 0 && checked_window_item < count)
+ if (checked_window_item >= 0 && checked_window_item < count)
{
- item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
- [item setState:NSOnState];
- item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
- [item setState:NSOnState];
+ item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
+ [item setState:NSOnState];
+ item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
+ [item setState:NSOnState];
}
}
- (void) remove_apps_menu
{
- NSMenu *menu;
- NSMenuItem *item;
- int i;
+ NSMenu *menu;
+ NSMenuItem *item;
+ int i;
- if (apps == nil || apps_separator == nil) return;
+ if (apps == nil || apps_separator == nil) return;
- menu = [apps_separator menu];
+ menu = [apps_separator menu];
- if (menu != nil)
+ if (menu != nil)
{
- for (i = [menu numberOfItems] - 1; i >= 0; i--)
- {
- item = (NSMenuItem *) [menu itemAtIndex:i];
- if ([item tag] != 0)
- [menu removeItemAtIndex:i];
- }
+ for (i = [menu numberOfItems] - 1; i >= 0; i--)
+ {
+ item = (NSMenuItem *) [menu itemAtIndex:i];
+ if ([item tag] != 0)
+ [menu removeItemAtIndex:i];
+ }
}
- if (dock_apps_menu != nil)
+ if (dock_apps_menu != nil)
{
- for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--)
- {
- item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i];
- if ([item tag] != 0)
- [dock_apps_menu removeItemAtIndex:i];
- }
+ for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--)
+ {
+ item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i];
+ if ([item tag] != 0)
+ [dock_apps_menu removeItemAtIndex:i];
+ }
}
- [apps release];
- apps = nil;
+ [apps release];
+ apps = nil;
}
- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
{
- NSString *title, *shortcut = @"";
- NSArray *group;
- NSMenuItem *item;
+ NSString *title, *shortcut = @"";
+ NSArray *group;
+ NSMenuItem *item;
- group = [list objectAtIndex:i];
- title = [group objectAtIndex:0];
- if ([group count] >= 3)
- shortcut = [group objectAtIndex:2];
+ group = [list objectAtIndex:i];
+ title = [group objectAtIndex:0];
+ if ([group count] >= 3)
+ shortcut = [group objectAtIndex:2];
- if ([title length] != 0)
+ if ([title length] != 0)
{
- item = (NSMenuItem *) [menu insertItemWithTitle:title
- action:@selector (app_selected:)
- keyEquivalent:shortcut atIndex:0];
- [item setTarget:self];
- [item setEnabled:YES];
+ item = (NSMenuItem *) [menu insertItemWithTitle:title
+ action:@selector (app_selected:)
+ keyEquivalent:shortcut atIndex:0];
+ [item setTarget:self];
+ [item setEnabled:YES];
}
- else
+ else
{
- item = (NSMenuItem *) [NSMenuItem separatorItem];
- [menu insertItem:item atIndex:0];
+ item = (NSMenuItem *) [NSMenuItem separatorItem];
+ [menu insertItem:item atIndex:0];
}
- [item setTag:i+1]; /* can't be zero, so add one */
+ [item setTag:i+1]; /* can't be zero, so add one */
}
- (void) install_apps_menu:(NSArray *)list
{
- NSMenu *menu;
- int i, count;
+ NSMenu *menu;
+ int i, count;
- count = [list count];
+ count = [list count];
- if (count == 0 || apps_separator == nil) return;
+ if (count == 0 || apps_separator == nil) return;
- menu = [apps_separator menu];
+ menu = [apps_separator menu];
- for (i = count - 1; i >= 0; i--)
+ for (i = count - 1; i >= 0; i--)
{
- if (menu != nil)
- [self prepend_apps_item:list index:i menu:menu];
- if (dock_apps_menu != nil)
- [self prepend_apps_item:list index:i menu:dock_apps_menu];
+ if (menu != nil)
+ [self prepend_apps_item:list index:i menu:menu];
+ if (dock_apps_menu != nil)
+ [self prepend_apps_item:list index:i menu:dock_apps_menu];
}
- apps = [list retain];
+ apps = [list retain];
}
- (void) set_window_menu:(NSArray *)list
{
- [self remove_window_menu];
- [self install_window_menu:list];
+ [self remove_window_menu];
+ [self install_window_menu:list];
- DarwinSendDDXEvent(kXquartzControllerNotify, 1,
- AppleWMWindowMenuNotify);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1,
+ AppleWMWindowMenuNotify);
}
- (void) set_window_menu_check:(NSNumber *)nn
{
- NSMenu *menu;
- NSMenuItem *item;
- int first, count;
- int n = [nn intValue];
-
- menu = [X11App windowsMenu];
- first = windows_menu_start + 1;
- count = [menu numberOfItems] - first;
+ NSMenu *menu;
+ NSMenuItem *item;
+ int first, count;
+ int n = [nn intValue];
+
+ menu = [X11App windowsMenu];
+ first = windows_menu_start + 1;
+ count = [menu numberOfItems] - first;
- if (checked_window_item >= 0 && checked_window_item < count)
+ if (checked_window_item >= 0 && checked_window_item < count)
{
- item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
- [item setState:NSOffState];
- item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
- [item setState:NSOffState];
+ item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
+ [item setState:NSOffState];
+ item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
+ [item setState:NSOffState];
}
- if (n >= 0 && n < count)
+ if (n >= 0 && n < count)
{
- item = (NSMenuItem *) [menu itemAtIndex:first + n];
- [item setState:NSOnState];
- item = (NSMenuItem *) [dock_menu itemAtIndex:n];
- [item setState:NSOnState];
+ item = (NSMenuItem *) [menu itemAtIndex:first + n];
+ [item setState:NSOnState];
+ item = (NSMenuItem *) [dock_menu itemAtIndex:n];
+ [item setState:NSOnState];
}
- checked_window_item = n;
+ checked_window_item = n;
}
- (void) set_apps_menu:(NSArray *)list
{
- [self remove_apps_menu];
- [self install_apps_menu:list];
+ [self remove_apps_menu];
+ [self install_apps_menu:list];
}
#ifdef XQUARTZ_SPARKLE
- (void) setup_sparkle {
if(check_for_updates_item)
return; // already did it...
-
+
NSMenu *menu = [x11_about_item menu];
-
+
check_for_updates_item = [menu insertItemWithTitle:NSLocalizedString(@"Check for X11 Updates...", @"Check for X11 Updates...")
- action:@selector (checkForUpdates:)
- keyEquivalent:@""
- atIndex:1];
+ action:@selector (checkForUpdates:)
+ keyEquivalent:@""
+ atIndex:1];
[check_for_updates_item setTarget:[SUUpdater sharedUpdater]];
[check_for_updates_item setEnabled:YES];
-
+
// Set X11Controller as the delegate for the updater.
[[SUUpdater sharedUpdater] setDelegate:self];
}
@@ -356,40 +357,40 @@
snprintf(buf, sizeof(buf), ":%s", display);
setenv("DISPLAY", buf, TRUE);
}
-
+
/* Do the fork-twice trick to avoid having to reap zombies */
child1 = fork();
switch (child1) {
case -1: /* error */
break;
-
+
case 0: /* child1 */
child2 = fork();
-
+
switch (child2) {
- int max_files, i;
-
+ int max_files, i;
+
case -1: /* error */
_exit(1);
-
+
case 0: /* child2 */
- /* close all open files except for standard streams */
- max_files = sysconf(_SC_OPEN_MAX);
- for(i = 3; i < max_files; i++)
- close(i);
-
- /* ensure stdin is on /dev/null */
- close(0);
- open("/dev/null", O_RDONLY);
-
- execvp(newargv[0], (char **const) newargv);
- _exit(2);
-
+ /* close all open files except for standard streams */
+ max_files = sysconf(_SC_OPEN_MAX);
+ for(i = 3; i < max_files; i++)
+ close(i);
+
+ /* ensure stdin is on /dev/null */
+ close(0);
+ open("/dev/null", O_RDONLY);
+
+ execvp(newargv[0], (char **const) newargv);
+ _exit(2);
+
default: /* parent (child1) */
- _exit(0);
+ _exit(0);
}
break;
-
+
default: /* parent */
waitpid(child1, &status, 0);
}
@@ -397,237 +398,237 @@
- (void) app_selected:sender
{
- int tag;
- NSString *item;
-
- tag = [sender tag] - 1;
- if (apps == nil || tag < 0 || tag >= [apps count])
- return;
-
- item = [[apps objectAtIndex:tag] objectAtIndex:1];
-
- [self launch_client:item];
+ int tag;
+ NSString *item;
+
+ tag = [sender tag] - 1;
+ if (apps == nil || tag < 0 || tag >= [apps count])
+ return;
+
+ item = [[apps objectAtIndex:tag] objectAtIndex:1];
+
+ [self launch_client:item];
}
- (IBAction) apps_table_show:sender
{
- NSArray *columns;
- NSMutableArray *oldapps = nil;
+ NSArray *columns;
+ NSMutableArray *oldapps = nil;
- if (table_apps != nil)
- oldapps = table_apps;
-
- table_apps = [[NSMutableArray alloc] initWithCapacity:1];
- if(apps != nil)
- [table_apps addObjectsFromArray:apps];
+ if (table_apps != nil)
+ oldapps = table_apps;
+
+ table_apps = [[NSMutableArray alloc] initWithCapacity:1];
+ if(apps != nil)
+ [table_apps addObjectsFromArray:apps];
- columns = [apps_table tableColumns];
- [[columns objectAtIndex:0] setIdentifier:@"0"];
- [[columns objectAtIndex:1] setIdentifier:@"1"];
- [[columns objectAtIndex:2] setIdentifier:@"2"];
+ columns = [apps_table tableColumns];
+ [[columns objectAtIndex:0] setIdentifier:@"0"];
+ [[columns objectAtIndex:1] setIdentifier:@"1"];
+ [[columns objectAtIndex:2] setIdentifier:@"2"];
- [apps_table setDataSource:self];
- [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
-
- [[apps_table window] makeKeyAndOrderFront:sender];
- [apps_table reloadData];
- if(oldapps != nil)
- [oldapps release];
+ [apps_table setDataSource:self];
+ [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
+
+ [[apps_table window] makeKeyAndOrderFront:sender];
+ [apps_table reloadData];
+ if(oldapps != nil)
+ [oldapps release];
}
- (IBAction) apps_table_done:sender
{
- [apps_table deselectAll:sender]; /* flush edits? */
+ [apps_table deselectAll:sender]; /* flush edits? */
- [self remove_apps_menu];
- [self install_apps_menu:table_apps];
+ [self remove_apps_menu];
+ [self install_apps_menu:table_apps];
- [NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
- [NSApp prefs_synchronize];
+ [NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
+ [NSApp prefs_synchronize];
- [[apps_table window] orderOut:sender];
+ [[apps_table window] orderOut:sender];
- [table_apps release];
- table_apps = nil;
+ [table_apps release];
+ table_apps = nil;
}
- (IBAction) apps_table_new:sender
{
- NSMutableArray *item;
+ NSMutableArray *item;
- int row = [apps_table selectedRow], i;
+ int row = [apps_table selectedRow], i;
- if (row < 0) row = 0;
- else row = row + 1;
+ if (row < 0) row = 0;
+ else row = row + 1;
- i = row;
- if (i > [table_apps count])
- return; /* avoid exceptions */
+ i = row;
+ if (i > [table_apps count])
+ return; /* avoid exceptions */
- [apps_table deselectAll:sender];
+ [apps_table deselectAll:sender];
- item = [[NSMutableArray alloc] initWithCapacity:3];
- [item addObject:@""];
- [item addObject:@""];
- [item addObject:@""];
+ item = [[NSMutableArray alloc] initWithCapacity:3];
+ [item addObject:@""];
+ [item addObject:@""];
+ [item addObject:@""];
- [table_apps insertObject:item atIndex:i];
- [item release];
+ [table_apps insertObject:item atIndex:i];
+ [item release];
- [apps_table reloadData];
- [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
+ [apps_table reloadData];
+ [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
}
- (IBAction) apps_table_duplicate:sender
{
- int row = [apps_table selectedRow], i;
- NSObject *item;
+ int row = [apps_table selectedRow], i;
+ NSObject *item;
- if (row < 0) {
- [self apps_table_new:sender];
- return;
- }
+ if (row < 0) {
+ [self apps_table_new:sender];
+ return;
+ }
- i = row;
- if (i > [table_apps count] - 1) return; /* avoid exceptions */
+ i = row;
+ if (i > [table_apps count] - 1) return; /* avoid exceptions */
- [apps_table deselectAll:sender];
+ [apps_table deselectAll:sender];
- item = [[table_apps objectAtIndex:i] mutableCopy];
- [table_apps insertObject:item atIndex:i];
- [item release];
+ item = [[table_apps objectAtIndex:i] mutableCopy];
+ [table_apps insertObject:item atIndex:i];
+ [item release];
- [apps_table reloadData];
- [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row+1] byExtendingSelection:NO];
+ [apps_table reloadData];
+ [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row+1] byExtendingSelection:NO];
}
- (IBAction) apps_table_delete:sender
{
- int row = [apps_table selectedRow];
+ int row = [apps_table selectedRow];
- if (row >= 0)
+ if (row >= 0)
{
- int i = row;
-
- if (i > [table_apps count] - 1) return; /* avoid exceptions */
-
- [apps_table deselectAll:sender];
-
- [table_apps removeObjectAtIndex:i];
+ int i = row;
+
+ if (i > [table_apps count] - 1) return; /* avoid exceptions */
+
+ [apps_table deselectAll:sender];
+
+ [table_apps removeObjectAtIndex:i];
}
- [apps_table reloadData];
+ [apps_table reloadData];
- row = MIN (row, [table_apps count] - 1);
- if (row >= 0)
- [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
+ row = MIN (row, [table_apps count] - 1);
+ if (row >= 0)
+ [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
}
- (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView
{
- if (table_apps == nil) return 0;
-
- return [table_apps count];
+ if (table_apps == nil) return 0;
+
+ return [table_apps count];
}
- (id) tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
- NSArray *item;
- int col;
+ NSArray *item;
+ int col;
- if (table_apps == nil) return nil;
+ if (table_apps == nil) return nil;
- col = [[tableColumn identifier] intValue];
+ col = [[tableColumn identifier] intValue];
- item = [table_apps objectAtIndex:row];
- if ([item count] > col)
- return [item objectAtIndex:col];
- else
- return @"";
+ item = [table_apps objectAtIndex:row];
+ if ([item count] > col)
+ return [item objectAtIndex:col];
+ else
+ return @"";
}
- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
- NSMutableArray *item;
- int col;
+ NSMutableArray *item;
+ int col;
- if (table_apps == nil) return;
+ if (table_apps == nil) return;
- col = [[tableColumn identifier] intValue];
+ col = [[tableColumn identifier] intValue];
- item = [table_apps objectAtIndex:row];
- [item replaceObjectAtIndex:col withObject:object];
+ item = [table_apps objectAtIndex:row];
+ [item replaceObjectAtIndex:col withObject:object];
}
- (void) hide_window:sender
{
- if ([X11App x_active])
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideWindow);
- else
- NSBeep (); /* FIXME: something here */
+ if ([X11App x_active])
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideWindow);
+ else
+ NSBeep (); /* FIXME: something here */
}
- (IBAction)bring_to_front:sender
{
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
}
- (IBAction)close_window:sender
{
- if ([X11App x_active])
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMCloseWindow);
- else
- [[NSApp keyWindow] performClose:sender];
+ if ([X11App x_active])
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMCloseWindow);
+ else
+ [[NSApp keyWindow] performClose:sender];
}
- (IBAction)minimize_window:sender
{
- if ([X11App x_active])
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
- else
- [[NSApp keyWindow] performMiniaturize:sender];
+ if ([X11App x_active])
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
+ else
+ [[NSApp keyWindow] performMiniaturize:sender];
}
- (IBAction)zoom_window:sender
{
- if ([X11App x_active])
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMZoomWindow);
- else
- [[NSApp keyWindow] performZoom:sender];
+ if ([X11App x_active])
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMZoomWindow);
+ else
+ [[NSApp keyWindow] performZoom:sender];
}
- (IBAction) next_window:sender
{
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMNextWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMNextWindow);
}
- (IBAction) previous_window:sender
{
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMPreviousWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMPreviousWindow);
}
- (IBAction) enable_fullscreen_changed:sender {
XQuartzRootlessDefault = ![enable_fullscreen intValue];
-
+
[enable_fullscreen_menu setEnabled:!XQuartzRootlessDefault];
[enable_fullscreen_menu_text setTextColor:XQuartzRootlessDefault ? [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
-
+
DarwinSendDDXEvent(kXquartzSetRootless, 1, XQuartzRootlessDefault);
-
+
[NSApp prefs_set_boolean:@PREFS_ROOTLESS value:XQuartzRootlessDefault];
[NSApp prefs_synchronize];
}
- (IBAction) toggle_fullscreen:sender
{
- DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
+ DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
}
- (void) set_can_quit:(OSX_BOOL)state
{
- can_quit = state;
+ can_quit = state;
}
- (IBAction)prefs_changed:sender
@@ -652,7 +653,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
XQuartzOptionSendsAlt = [option_sends_alt intValue];
[NSApp prefs_set_boolean:@PREFS_OPTION_SENDS_ALT value:XQuartzOptionSendsAlt];
-
+
if(prev_opt_sends_alt != XQuartzOptionSendsAlt)
QuartsResyncKeymap(TRUE);
} else if(sender == click_through) {
@@ -670,12 +671,12 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
} else if(sender == sync_pasteboard) {
BOOL pbproxy_active = [sync_pasteboard intValue];
[NSApp prefs_set_boolean:@PREFS_SYNC_PB value:pbproxy_active];
-
+
[sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
[sync_pasteboard_to_primary setEnabled:pbproxy_active];
[sync_clipboard_to_pasteboard setEnabled:pbproxy_active];
[sync_primary_immediately setEnabled:pbproxy_active];
-
+
// setEnabled doesn't do this...
[sync_text1 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
[sync_text2 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
@@ -691,7 +692,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
XQuartzScrollInDeviceDirection = [scroll_in_device_direction intValue];
[NSApp prefs_set_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION value:XQuartzScrollInDeviceDirection];
}
-
+
[NSApp prefs_synchronize];
DarwinSendDDXEvent(kXquartzReloadPreferences, 0);
@@ -700,7 +701,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
- (IBAction) prefs_show:sender
{
BOOL pbproxy_active = [NSApp prefs_get_boolean:@PREFS_SYNC_PB default:YES];
-
+
// Remove preferences from the GUI which are not supported
// TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
if(scroll_in_device_direction && NSAppKitVersionNumber < 1117) {
@@ -720,20 +721,20 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
[enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
[enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
-
+
[depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
-
+
[sync_pasteboard setIntValue:pbproxy_active];
[sync_pasteboard_to_clipboard setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PB_TO_CLIPBOARD default:YES]];
[sync_pasteboard_to_primary setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PB_TO_PRIMARY default:YES]];
[sync_clipboard_to_pasteboard setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_CLIPBOARD_TO_PB default:YES]];
[sync_primary_immediately setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PRIMARY_ON_SELECT default:NO]];
-
+
[sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
[sync_pasteboard_to_primary setEnabled:pbproxy_active];
[sync_clipboard_to_pasteboard setEnabled:pbproxy_active];
[sync_primary_immediately setEnabled:pbproxy_active];
-
+
// setEnabled doesn't do this...
[sync_text1 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
[sync_text2 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
@@ -742,7 +743,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
[enable_fullscreen_menu setIntValue:XQuartzFullscreenMenu];
[enable_fullscreen_menu setEnabled:!XQuartzRootlessDefault];
[enable_fullscreen_menu_text setTextColor:XQuartzRootlessDefault ? [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
-
+
[prefs_panel makeKeyAndOrderFront:sender];
}
@@ -759,32 +760,32 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
}
- (OSX_BOOL) validateMenuItem:(NSMenuItem *)item {
- NSMenu *menu = [item menu];
+ NSMenu *menu = [item menu];
- if (item == toggle_fullscreen_item)
- return !XQuartzIsRootless;
- else if (menu == [X11App windowsMenu] || menu == dock_menu
- || (menu == [x11_about_item menu] && [item tag] == 42))
- return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0;
- else
- return TRUE;
+ if (item == toggle_fullscreen_item)
+ return !XQuartzIsRootless;
+ else if (menu == [X11App windowsMenu] || menu == dock_menu
+ || (menu == [x11_about_item menu] && [item tag] == 42))
+ return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0;
+ else
+ return TRUE;
}
- (void) applicationDidHide:(NSNotification *)notify
{
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideAll);
-
- /* Toggle off fullscreen mode to leave our non-default video
- * mode and hide our guard window.
- */
- if (!XQuartzIsRootless && XQuartzFullscreenVisible) {
- DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
- }
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideAll);
+
+ /* Toggle off fullscreen mode to leave our non-default video
+ * mode and hide our guard window.
+ */
+ if (!XQuartzIsRootless && XQuartzFullscreenVisible) {
+ DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
+ }
}
- (void) applicationDidUnhide:(NSNotification *)notify
{
- DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMShowAll);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMShowAll);
}
- (NSApplicationTerminateReply) applicationShouldTerminate:sender {
@@ -799,7 +800,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
title = NSLocalizedString(@"Do you really want to quit X11?", @"Dialog title when quitting");
msg = NSLocalizedString(@"Any open X11 applications will stop immediately, and you will lose any unsaved changes.", @"Dialog when quitting");
-
+
/* FIXME: safe to run the alert in here? Or should we return Later
* and then run the alert on a timer? It seems to work here, so..
*/
@@ -811,34 +812,34 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
- (void) applicationWillTerminate:(NSNotification *)aNotification
{
- unsigned remain;
- [X11App prefs_synchronize];
+ unsigned remain;
+ [X11App prefs_synchronize];
- /* shutdown the X server, it will exit () for us. */
- DarwinSendDDXEvent(kXquartzQuit, 0);
+ /* shutdown the X server, it will exit () for us. */
+ DarwinSendDDXEvent(kXquartzQuit, 0);
- /* In case it doesn't, exit anyway after a while. */
- remain = 10000000;
- while((remain = usleep(remain)) > 0);
-
- exit (1);
+ /* In case it doesn't, exit anyway after a while. */
+ remain = 10000000;
+ while((remain = usleep(remain)) > 0);
+
+ exit (1);
}
- (void) server_ready
{
- x_list *node;
+ x_list *node;
- finished_launching = YES;
+ finished_launching = YES;
- for (node = pending_apps; node != NULL; node = node->next)
+ for (node = pending_apps; node != NULL; node = node->next)
{
- NSString *filename = node->data;
- [self launch_client:filename];
- [filename release];
+ NSString *filename = node->data;
+ [self launch_client:filename];
+ [filename release];
}
- x_list_free (pending_apps);
- pending_apps = NULL;
+ x_list_free (pending_apps);
+ pending_apps = NULL;
}
- (OSX_BOOL) application:(NSApplication *)app openFile:(NSString *)filename
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index 55976c454..bc2c3b9f6 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -1,29 +1,32 @@
-/**************************************************************************
-
-Copyright (c) 2002-2007 Apple Inc. All Rights Reserved.
-Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
+/*
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
#include "sanitizedCarbon.h"
@@ -106,36 +109,36 @@ make_box (int x, int y, int w, int h)
/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
void
AppleWMSetScreenOrigin(
- WindowPtr pWin
-)
+ WindowPtr pWin
+ )
{
int32_t data[2];
-
+
data[0] = pWin->drawable.pScreen->x + darwinMainScreenX;
data[1] = pWin->drawable.pScreen->y + darwinMainScreenY;
-
+
dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
- XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
+ XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
}
/* Window managers can set the _APPLE_NO_ORDER_IN property on windows
- that are being genie-restored from the Dock. We want them to
- be mapped but remain ordered-out until the animation
- completes (when the Dock will order them in). */
+ that are being genie-restored from the Dock. We want them to
+ be mapped but remain ordered-out until the animation
+ completes (when the Dock will order them in). */
Bool
AppleWMDoReorderWindow(
- WindowPtr pWin
-)
+ WindowPtr pWin
+ )
{
Atom atom;
PropertyPtr prop;
int rc;
-
+
atom = xa_apple_no_order_in();
rc = dixLookupProperty(&prop, pWin, atom, serverClient, DixReadAccess);
if(Success == rc && prop->type == atom)
- return 0;
+ return 0;
return 1;
}
@@ -143,11 +146,11 @@ AppleWMDoReorderWindow(
static int
ProcAppleWMQueryVersion(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
xAppleWMQueryVersionReply rep;
-
+
REQUEST_SIZE_MATCH(xAppleWMQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
@@ -163,14 +166,14 @@ ProcAppleWMQueryVersion(
return Success;
}
-
+
/* events */
static inline void
updateEventMask (WMEventPtr *pHead)
{
WMEventPtr pCur;
-
+
eventMask = 0;
for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
eventMask |= pCur->mask;
@@ -182,7 +185,7 @@ WMFreeClient (pointer data, XID id) {
WMEventPtr pEvent;
WMEventPtr *pHead, pCur, pPrev;
int i;
-
+
pEvent = (WMEventPtr) data;
i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, serverClient, DixReadAccess | DixWriteAccess | DixDestroyAccess);
if (i == Success && pHead) {
@@ -205,7 +208,7 @@ WMFreeClient (pointer data, XID id) {
static int
WMFreeEvents (pointer data, XID id) {
WMEventPtr *pHead, pCur, pNext;
-
+
pHead = (WMEventPtr *) data;
for (pCur = *pHead; pCur; pCur = pNext) {
pNext = pCur->next;
@@ -224,7 +227,7 @@ ProcAppleWMSelectInput (register ClientPtr client)
WMEventPtr pEvent, pNewEvent, *pHead;
XID clientResource;
int i;
-
+
REQUEST_SIZE_MATCH (xAppleWMSelectInputReq);
i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, client, DixWriteAccess);
if (stuff->mask != 0) {
@@ -240,7 +243,7 @@ ProcAppleWMSelectInput (register ClientPtr client)
}
}
}
-
+
/* build the entry */
pNewEvent = (WMEventPtr) malloc(sizeof (WMEventRec));
if (!pNewEvent)
@@ -311,7 +314,7 @@ AppleWMSendEvent (int type, unsigned int mask, int which, int arg) {
WMEventPtr *pHead, pEvent;
xAppleWMNotifyEvent se;
int i;
-
+
i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, serverClient, DixReadAccess);
if (i != Success || !pHead)
return;
@@ -333,60 +336,60 @@ AppleWMSelectedEvents (void)
return eventMask;
}
-
+
/* general utility functions */
static int
ProcAppleWMDisableUpdate(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST_SIZE_MATCH(xAppleWMDisableUpdateReq);
-
+
appleWMProcs->DisableUpdate();
-
+
return Success;
}
static int
ProcAppleWMReenableUpdate(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST_SIZE_MATCH(xAppleWMReenableUpdateReq);
-
+
appleWMProcs->EnableUpdate();
-
+
return Success;
}
-
+
/* window functions */
static int
ProcAppleWMSetWindowMenu(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
const char *bytes, **items;
char *shortcuts;
int max_len, nitems, i, j;
REQUEST(xAppleWMSetWindowMenuReq);
-
+
REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
-
+
nitems = stuff->nitems;
items = malloc(sizeof (char *) * nitems);
shortcuts = malloc(sizeof (char) * nitems);
-
+
max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
bytes = (char *) &stuff[1];
-
+
for (i = j = 0; i < max_len && j < nitems;)
{
shortcuts[j] = bytes[i++];
items[j++] = bytes + i;
-
+
while (i < max_len)
{
if (bytes[i++] == 0)
@@ -396,17 +399,17 @@ ProcAppleWMSetWindowMenu(
X11ApplicationSetWindowMenu (nitems, items, shortcuts);
free(items);
free(shortcuts);
-
+
return Success;
}
static int
ProcAppleWMSetWindowMenuCheck(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleWMSetWindowMenuCheckReq);
-
+
REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
X11ApplicationSetWindowMenuCheck(stuff->index);
return Success;
@@ -414,11 +417,11 @@ ProcAppleWMSetWindowMenuCheck(
static int
ProcAppleWMSetFrontProcess(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
-
+
X11ApplicationSetFrontProcess();
return Success;
}
@@ -429,22 +432,22 @@ ProcAppleWMSetWindowLevel(register ClientPtr client)
REQUEST(xAppleWMSetWindowLevelReq);
WindowPtr pWin;
int err;
-
+
REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
-
+
if (Success != dixLookupWindow(&pWin, stuff->window, client,
- DixReadAccess))
+ DixReadAccess))
return BadValue;
-
+
if (stuff->level >= AppleWMNumWindowLevels) {
return BadValue;
}
-
- err = appleWMProcs->SetWindowLevel(pWin, stuff->level);
- if (err != Success) {
+
+ err = appleWMProcs->SetWindowLevel(pWin, stuff->level);
+ if (err != Success) {
return err;
}
-
+
return Success;
}
@@ -458,12 +461,12 @@ ProcAppleWMSendPSN(register ClientPtr client)
if(!appleWMProcs->SendPSN)
return BadRequest;
-
+
err = appleWMProcs->SendPSN(stuff->psn_hi, stuff->psn_lo);
if (err != Success) {
return err;
}
-
+
return Success;
}
@@ -478,191 +481,191 @@ ProcAppleWMAttachTransient(register ClientPtr client)
if(!appleWMProcs->AttachTransient)
return BadRequest;
-
+
if (Success != dixLookupWindow(&pWinChild, stuff->child, client, DixReadAccess))
return BadValue;
-
+
if(stuff->parent) {
if(Success != dixLookupWindow(&pWinParent, stuff->parent, client, DixReadAccess))
return BadValue;
} else {
pWinParent = NULL;
}
-
+
err = appleWMProcs->AttachTransient(pWinChild, pWinParent);
if (err != Success) {
return err;
}
-
+
return Success;
}
static int
ProcAppleWMSetCanQuit(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleWMSetCanQuitReq);
-
+
REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
-
+
X11ApplicationSetCanQuit(stuff->state);
return Success;
}
-
+
/* frame functions */
static int
ProcAppleWMFrameGetRect(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
xAppleWMFrameGetRectReply rep;
BoxRec ir, or, rr;
REQUEST(xAppleWMFrameGetRectReq);
-
+
REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
-
+
ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
+
if (appleWMProcs->FrameGetRect(stuff->frame_rect,
stuff->frame_class,
&or, &ir, &rr) != Success)
{
return BadValue;
}
-
+
rep.x = rr.x1;
rep.y = rr.y1;
rep.w = rr.x2 - rr.x1;
rep.h = rr.y2 - rr.y1;
-
+
WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *)&rep);
return Success;
}
static int
ProcAppleWMFrameHitTest(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
xAppleWMFrameHitTestReply rep;
BoxRec ir, or;
int ret;
REQUEST(xAppleWMFrameHitTestReq);
-
+
REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
-
+
ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
+
if (appleWMProcs->FrameHitTest(stuff->frame_class, stuff->px,
stuff->py, &or, &ir, &ret) != Success)
{
return BadValue;
}
-
+
rep.ret = ret;
-
+
WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *)&rep);
return Success;
}
static int
ProcAppleWMFrameDraw(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
BoxRec ir, or;
unsigned int title_length, title_max;
unsigned char *title_bytes;
REQUEST(xAppleWMFrameDrawReq);
WindowPtr pWin;
-
+
REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
-
+
if (Success != dixLookupWindow(&pWin, stuff->window, client,
- DixReadAccess))
+ DixReadAccess))
return BadValue;
-
+
ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
+
title_length = stuff->title_length;
title_max = (stuff->length << 2) - sizeof(xAppleWMFrameDrawReq);
-
+
if (title_max < title_length)
return BadValue;
-
+
title_bytes = (unsigned char *) &stuff[1];
-
+
errno = appleWMProcs->FrameDraw(pWin, stuff->frame_class,
stuff->frame_attr, &or, &ir,
title_length, title_bytes);
if (errno != Success) {
return errno;
}
-
+
return Success;
}
-
+
/* dispatch */
static int
ProcAppleWMDispatch (
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xReq);
-
+
switch (stuff->data)
{
- case X_AppleWMQueryVersion:
- return ProcAppleWMQueryVersion(client);
+ case X_AppleWMQueryVersion:
+ return ProcAppleWMQueryVersion(client);
}
-
+
if (!LocalClient(client))
return WMErrorBase + AppleWMClientNotLocal;
-
+
switch (stuff->data)
{
- case X_AppleWMSelectInput:
- return ProcAppleWMSelectInput(client);
- case X_AppleWMDisableUpdate:
- return ProcAppleWMDisableUpdate(client);
- case X_AppleWMReenableUpdate:
- return ProcAppleWMReenableUpdate(client);
- case X_AppleWMSetWindowMenu:
- return ProcAppleWMSetWindowMenu(client);
- case X_AppleWMSetWindowMenuCheck:
- return ProcAppleWMSetWindowMenuCheck(client);
- case X_AppleWMSetFrontProcess:
- return ProcAppleWMSetFrontProcess(client);
- case X_AppleWMSetWindowLevel:
- return ProcAppleWMSetWindowLevel(client);
- case X_AppleWMSetCanQuit:
- return ProcAppleWMSetCanQuit(client);
- case X_AppleWMFrameGetRect:
- return ProcAppleWMFrameGetRect(client);
- case X_AppleWMFrameHitTest:
- return ProcAppleWMFrameHitTest(client);
- case X_AppleWMFrameDraw:
- return ProcAppleWMFrameDraw(client);
- case X_AppleWMSendPSN:
- return ProcAppleWMSendPSN(client);
- case X_AppleWMAttachTransient:
- return ProcAppleWMAttachTransient(client);
- default:
- return BadRequest;
+ case X_AppleWMSelectInput:
+ return ProcAppleWMSelectInput(client);
+ case X_AppleWMDisableUpdate:
+ return ProcAppleWMDisableUpdate(client);
+ case X_AppleWMReenableUpdate:
+ return ProcAppleWMReenableUpdate(client);
+ case X_AppleWMSetWindowMenu:
+ return ProcAppleWMSetWindowMenu(client);
+ case X_AppleWMSetWindowMenuCheck:
+ return ProcAppleWMSetWindowMenuCheck(client);
+ case X_AppleWMSetFrontProcess:
+ return ProcAppleWMSetFrontProcess(client);
+ case X_AppleWMSetWindowLevel:
+ return ProcAppleWMSetWindowLevel(client);
+ case X_AppleWMSetCanQuit:
+ return ProcAppleWMSetCanQuit(client);
+ case X_AppleWMFrameGetRect:
+ return ProcAppleWMFrameGetRect(client);
+ case X_AppleWMFrameHitTest:
+ return ProcAppleWMFrameHitTest(client);
+ case X_AppleWMFrameDraw:
+ return ProcAppleWMFrameDraw(client);
+ case X_AppleWMSendPSN:
+ return ProcAppleWMSendPSN(client);
+ case X_AppleWMAttachTransient:
+ return ProcAppleWMAttachTransient(client);
+ default:
+ return BadRequest;
}
}
@@ -677,8 +680,8 @@ SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to) {
static int
SProcAppleWMQueryVersion(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleWMQueryVersionReq);
swaps(&stuff->length);
@@ -687,35 +690,35 @@ SProcAppleWMQueryVersion(
static int
SProcAppleWMDispatch (
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xReq);
-
+
/* It is bound to be non-local when there is byte swapping */
if (!LocalClient(client))
return WMErrorBase + AppleWMClientNotLocal;
-
+
/* only local clients are allowed WM access */
switch (stuff->data)
{
- case X_AppleWMQueryVersion:
- return SProcAppleWMQueryVersion(client);
- default:
- return BadRequest;
+ case X_AppleWMQueryVersion:
+ return SProcAppleWMQueryVersion(client);
+ default:
+ return BadRequest;
}
}
void
AppleWMExtensionInit(
- AppleWMProcsPtr procsPtr)
+ AppleWMProcsPtr procsPtr)
{
ExtensionEntry* extEntry;
-
+
ClientType = CreateNewResourceType(WMFreeClient, "WMClient");
EventType = CreateNewResourceType(WMFreeEvents, "WMEvent");
eventResource = FakeClientID(0);
-
+
if (ClientType && EventType &&
(extEntry = AddExtension(APPLEWMNAME,
AppleWMNumberEvents,
diff --git a/hw/xquartz/applewmExt.h b/hw/xquartz/applewmExt.h
index c46a7bde4..6da36cd7b 100644
--- a/hw/xquartz/applewmExt.h
+++ b/hw/xquartz/applewmExt.h
@@ -1,32 +1,33 @@
-/*
- * External interface for the server's AppleWM support
+/* External interface for the server's AppleWM support
+ *
+ * Copyright (c) 2003-2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
*/
-/**************************************************************************
-
-Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
-Copyright (c) 2003-2004 Torrey T. Lyons. All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
#ifndef _APPLEWMEXT_H_
#define _APPLEWMEXT_H_
@@ -70,26 +71,26 @@ typedef struct _AppleWMProcs {
} AppleWMProcsRec, *AppleWMProcsPtr;
void AppleWMExtensionInit(
- AppleWMProcsPtr procsPtr
-);
+ AppleWMProcsPtr procsPtr
+ );
void AppleWMSetScreenOrigin(
- WindowPtr pWin
-);
+ WindowPtr pWin
+ );
Bool AppleWMDoReorderWindow(
- WindowPtr pWin
-);
+ WindowPtr pWin
+ );
void AppleWMSendEvent(
- int /* type */,
- unsigned int /* mask */,
- int /* which */,
- int /* arg */
-);
+ int /* type */,
+ unsigned int /* mask */,
+ int /* which */,
+ int /* arg */
+ );
unsigned int AppleWMSelectedEvents(
- void
-);
+ void
+ );
#endif /* _APPLEWMEXT_H_ */
diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index 70a819e42..0abb1ce32 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2011 Apple Inc.
+/*
+ * Copyright (c) 2011-2012 Apple Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -7,10 +8,10 @@
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -19,7 +20,7 @@
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
- *
+ *
* Except as contained in this notice, the name(s) of the above
* copyright holders shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without
@@ -69,11 +70,11 @@ typedef struct {
int level;
aslclient asl;
aslmsg msg;
-
+
/* Buffered reading */
char *buf;
char *w;
-
+
#ifdef HAVE_LIBDISPATCH
dispatch_source_t read_source;
#endif
@@ -98,16 +99,16 @@ static inline int _read_redirect(int fd, int flush) {
int total_read = 0;
int nbytes;
asl_redirect *aslr = &redirect_fds[fd];
-
+
while((nbytes = read(fd, aslr->w, BUF_SIZE - (aslr->w - aslr->buf) - 1)) > 0) {
char *s, *p;
-
+
/* Increment our returned number read */
total_read += nbytes;
-
+
nbytes += (aslr->w - aslr->buf);
aslr->buf[nbytes] = '\0';
-
+
/* One line at a time */
for(p=aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) {
// Find null or \n
@@ -126,7 +127,7 @@ static inline int _read_redirect(int fd, int flush) {
}
}
}
-
+
/* Flush if requested or we're at EOF */
if(flush || nbytes == 0) {
if(aslr->w > aslr->buf) {
@@ -134,7 +135,7 @@ static inline int _read_redirect(int fd, int flush) {
asl_log(aslr->asl, aslr->msg, aslr->level, "%s", aslr->buf);
}
}
-
+
if(nbytes == 0)
return EOF;
return total_read;
@@ -153,10 +154,10 @@ static void cancel_source(void *_source) {
dispatch_source_t source = (dispatch_source_t)_source;
int fd = dispatch_source_get_handle(source);
asl_redirect *aslr = &redirect_fds[fd];
-
+
/* Flush the buffer */
_read_redirect(fd, 1);
-
+
close(fd);
free(aslr->buf);
memset(aslr, 0, sizeof(*aslr));
@@ -168,10 +169,10 @@ static void cancel_source(void *_source) {
static void *redirect_thread(void *ctx __unused) {
struct kevent ev;
int n;
-
+
while(1) {
n = kevent(kq, NULL, 0, &ev, 1, NULL);
-
+
/* Bail on errors */
if(n < 0) {
asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent failure: %s", strerror(errno));
@@ -181,49 +182,49 @@ static void *redirect_thread(void *ctx __unused) {
/* This should not happen */
if(n == 0)
continue;
-
+
switch(ev.filter) {
case EVFILT_READ:
pthread_mutex_lock(&redirect_fds_lock);
- {
- int fd = ev.ident;
- int close_fd = 0;
- asl_redirect *aslr = &redirect_fds[fd];
-
- if(fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
- asl_log(NULL, NULL, ASL_LEVEL_ERR, "Unexpected file descriptor: %d", fd);
- goto next;
- }
-
- if(ev.flags & EV_EOF) {
- close_fd = 1;
- if(EOF != _read_redirect(fd, 1)) {
- asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent reported EOF on %d, but read doesn't concur.", fd);
- }
- } else {
- close_fd = (EOF == _read_redirect(fd, 0));
- }
-
- if(close_fd) {
- EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
- kevent(kq, &ev, 1, NULL, 0, NULL);
- close(fd);
- free(aslr->buf);
- memset(aslr, 0, sizeof(*aslr));
+ {
+ int fd = ev.ident;
+ int close_fd = 0;
+ asl_redirect *aslr = &redirect_fds[fd];
+
+ if(fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "Unexpected file descriptor: %d", fd);
+ goto next;
+ }
+
+ if(ev.flags & EV_EOF) {
+ close_fd = 1;
+ if(EOF != _read_redirect(fd, 1)) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent reported EOF on %d, but read doesn't concur.", fd);
}
+ } else {
+ close_fd = (EOF == _read_redirect(fd, 0));
+ }
+
+ if(close_fd) {
+ EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+ close(fd);
+ free(aslr->buf);
+ memset(aslr, 0, sizeof(*aslr));
}
- next:
+ }
+ next:
pthread_mutex_unlock(&redirect_fds_lock);
-
+
case EVFILT_TIMER:
if(ev.udata == ASL_REDIRECT_TERMINATE)
return NULL;
-
+
default:
;;
}
}
-
+
return NULL;
}
#endif
@@ -232,27 +233,27 @@ static void redirect_atexit(void) {
/* stdout is linebuffered, so flush the buffer */
if(redirect_fds[STDOUT_FILENO].buf)
fflush(stdout);
-
+
#ifdef HAVE_LIBDISPATCH
{
int i;
-
+
/* Cancel all of our dispatch sources, so they flush to ASL */
for(i=0; i < n_redirect_fds; i++)
if(redirect_fds[i].read_source)
dispatch_source_cancel(redirect_fds[i].read_source);
-
+
/* Wait at least three seconds for our sources to flush to ASL */
dispatch_group_wait(read_source_group, dispatch_time(DISPATCH_TIME_NOW, 3LL * NSEC_PER_SEC));
}
#else
{
struct kevent ev;
-
+
/* Tell our reader thread it is time to pack up and go home */
EV_SET(&ev, 0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 0, ASL_REDIRECT_TERMINATE);
kevent(kq, &ev, 1, NULL, 0, NULL);
-
+
pthread_join(redirect_pthread, NULL);
}
#endif
@@ -266,18 +267,18 @@ static void xq_asl_init(void)
{
assert((redirect_fds = calloc(16, sizeof(*redirect_fds))) != NULL);
n_redirect_fds = 16;
-
+
#ifdef HAVE_LIBDISPATCH
redirect_serial_q = dispatch_queue_create("com.apple.asl-redirect", NULL);
assert(redirect_serial_q != NULL);
-
+
read_source_group = dispatch_group_create();
assert(read_source_group != NULL);
#else
assert((kq = kqueue()) != -1);
assert(pthread_create(&redirect_pthread, NULL, redirect_thread, NULL) == 0);
#endif
-
+
atexit(redirect_atexit);
}
@@ -300,65 +301,65 @@ int xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd) {
dispatch_sync(redirect_serial_q, ^
#else
#define BLOCK_DONE goto done
- assert(pthread_mutex_lock(&redirect_fds_lock) == 0);
+ assert(pthread_mutex_lock(&redirect_fds_lock) == 0);
#endif
- {
- /* Reallocate if we need more space */
- if(fd >= n_redirect_fds) {
- size_t new_n = 1 << (ffs(fd) + 1);
- asl_redirect *new_array = realloc(redirect_fds, new_n * sizeof(*redirect_fds));
- if(!new_array) {
- err = errno;
- BLOCK_DONE;
- }
- redirect_fds = new_array;
- memset(redirect_fds + n_redirect_fds, 0, new_n - n_redirect_fds);
- n_redirect_fds = new_n;
- }
-
- /* If we're already listening on it, return error. */
- if(redirect_fds[fd].buf != NULL) {
- err = EBADF;
- BLOCK_DONE;
- }
-
- /* Initialize our buffer */
- redirect_fds[fd].buf = (char *)malloc(BUF_SIZE);
- if(redirect_fds[fd].buf == NULL) {
- err = errno;
- BLOCK_DONE;
- }
- redirect_fds[fd].w = redirect_fds[fd].buf;
-
- /* Store our ASL settings */
- redirect_fds[fd].level = level;
- redirect_fds[fd].asl = asl;
- redirect_fds[fd].msg = msg;
-
- /* Don't block on reads from this fd */
- fcntl(fd, F_SETFL, O_NONBLOCK);
-
- /* Start listening */
+ {
+ /* Reallocate if we need more space */
+ if(fd >= n_redirect_fds) {
+ size_t new_n = 1 << (ffs(fd) + 1);
+ asl_redirect *new_array = realloc(redirect_fds, new_n * sizeof(*redirect_fds));
+ if(!new_array) {
+ err = errno;
+ BLOCK_DONE;
+ }
+ redirect_fds = new_array;
+ memset(redirect_fds + n_redirect_fds, 0, new_n - n_redirect_fds);
+ n_redirect_fds = new_n;
+ }
+
+ /* If we're already listening on it, return error. */
+ if(redirect_fds[fd].buf != NULL) {
+ err = EBADF;
+ BLOCK_DONE;
+ }
+
+ /* Initialize our buffer */
+ redirect_fds[fd].buf = (char *)malloc(BUF_SIZE);
+ if(redirect_fds[fd].buf == NULL) {
+ err = errno;
+ BLOCK_DONE;
+ }
+ redirect_fds[fd].w = redirect_fds[fd].buf;
+
+ /* Store our ASL settings */
+ redirect_fds[fd].level = level;
+ redirect_fds[fd].asl = asl;
+ redirect_fds[fd].msg = msg;
+
+ /* Don't block on reads from this fd */
+ fcntl(fd, F_SETFL, O_NONBLOCK);
+
+ /* Start listening */
#ifdef HAVE_LIBDISPATCH
- {
- dispatch_source_t read_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, redirect_serial_q);
- redirect_fds[fd].read_source = read_source;
- dispatch_set_context(read_source, read_source);
- dispatch_source_set_event_handler_f(read_source, read_from_source);
- dispatch_source_set_cancel_handler_f(read_source, cancel_source);
- dispatch_group_enter(read_source_group);
- dispatch_resume(read_source);
- }
+ {
+ dispatch_source_t read_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, redirect_serial_q);
+ redirect_fds[fd].read_source = read_source;
+ dispatch_set_context(read_source, read_source);
+ dispatch_source_set_event_handler_f(read_source, read_from_source);
+ dispatch_source_set_cancel_handler_f(read_source, cancel_source);
+ dispatch_group_enter(read_source_group);
+ dispatch_resume(read_source);
+ }
#else
- {
- struct kevent ev;
- EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
- kevent(kq, &ev, 1, NULL, 0, NULL);
- }
+ {
+ struct kevent ev;
+ EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+ }
#endif
- }
+ }
#ifdef HAVE_LIBDISPATCH
- );
+ );
#else
done:
assert(pthread_mutex_unlock(&redirect_fds_lock) == 0);
@@ -378,21 +379,21 @@ int xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd) {
/* Close the read fd but not the write fd on exec */
if(fcntl(pipepair[0], F_SETFD, FD_CLOEXEC) == -1)
return errno;
-
+
/* Replace the existing fd */
if(dup2(pipepair[1], fd) == -1) {
close(pipepair[0]);
close(pipepair[1]);
return errno;
}
-
+
/* If we capture STDOUT_FILENO, make sure we linebuffer stdout */
if(fd == STDOUT_FILENO)
setlinebuf(stdout);
/* Close the duplicate fds since they've been reassigned */
close(pipepair[1]);
-
+
/* Hand off the read end of our pipe to xq_asl_log_fd */
return xq_asl_log_fd(asl, msg, level, pipepair[0]);
}
@@ -401,7 +402,7 @@ int xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd) {
int main(int argc __unused, char **argv __unused) {
xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO);
xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO);
-
+
fprintf(stderr, "TEST ERR1\n");
fprintf(stdout, "TEST OUT1\n");
fprintf(stderr, "TEST ERR2\n");
@@ -412,7 +413,7 @@ int main(int argc __unused, char **argv __unused) {
fprintf(stdout, "TEST OUT4\n");
fprintf(stderr, "TEST ERR3\n");
fprintf(stderr, "TEST ERR4\n");
-
+
exit(0);
}
#endif
diff --git a/hw/xquartz/console_redirect.h b/hw/xquartz/console_redirect.h
index 94520a35c..0b264aa7c 100644
--- a/hw/xquartz/console_redirect.h
+++ b/hw/xquartz/console_redirect.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 Apple Inc.
+/* Copyright (c) 2011-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 4e62daaca..1145ee1ca 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -2,7 +2,7 @@
*
* Xquartz initialization code
*
- * Copyright (c) 2007-2008 Apple Inc.
+ * Copyright (c) 2007-2012 Apple Inc.
* Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -85,10 +85,10 @@ aslclient aslc;
void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...) {
va_list args;
aslmsg msg = asl_new(ASL_TYPE_MSG);
-
+
if(msg) {
char *_line;
-
+
asl_set(msg, "File", file);
asl_set(msg, "Function", function);
asprintf(&_line, "%d", line);
@@ -99,11 +99,11 @@ void xq_asl_log (int level, const char *subsystem, const char *file, const char
if(subsystem)
asl_set(msg, "Subsystem", subsystem);
}
-
+
va_start(args, fmt);
asl_vlog(aslc, msg, level, fmt, args);
va_end(args);
-
+
if(msg)
asl_free(msg);
}
@@ -151,22 +151,22 @@ DeviceIntPtr darwinTabletEraser = NULL;
// Common pixmap formats
static PixmapFormatRec formats[] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 4, 8, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 15, 16, BITMAP_SCANLINE_PAD },
- { 16, 16, BITMAP_SCANLINE_PAD },
- { 24, 32, BITMAP_SCANLINE_PAD },
- { 32, 32, BITMAP_SCANLINE_PAD }
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 4, 8, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 15, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD },
+ { 32, 32, BITMAP_SCANLINE_PAD }
};
const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
void
DarwinPrintBanner(void)
{
- ErrorF("Xquartz starting:\n");
- ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
- ErrorF("Build Date: %s\n", BUILD_DATE );
+ ErrorF("Xquartz starting:\n");
+ ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
+ ErrorF("Build Date: %s\n", BUILD_DATE );
}
@@ -194,103 +194,103 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv
static int foundIndex = 0;
Bool ret;
DarwinFramebufferPtr dfb;
-
+
if (!dixRegisterPrivateKey(&darwinScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
+ return FALSE;
+
// reset index of found screens for each server generation
if (index == 0) {
foundIndex = 0;
-
+
// reset the visual list
miClearVisualTypes();
}
-
+
// allocate space for private per screen storage
dfb = malloc(sizeof(DarwinFramebufferRec));
-
+
// SCREEN_PRIV(pScreen) = dfb;
dixSetPrivate(&pScreen->devPrivates, darwinScreenKey, dfb);
-
+
// setup hardware/mode specific details
ret = QuartzAddScreen(foundIndex, pScreen);
foundIndex++;
if (! ret)
return FALSE;
-
+
// setup a single visual appropriate for our pixel type
if(!miSetVisualTypesAndMasks(dfb->depth, dfb->visuals, dfb->bitsPerRGB,
dfb->preferredCVC, dfb->redMask,
dfb->greenMask, dfb->blueMask)) {
return FALSE;
}
-
-// TODO: Make PseudoColor visuals not suck in TrueColor mode
-// if(dfb->depth > 8)
-// miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
+
+ // TODO: Make PseudoColor visuals not suck in TrueColor mode
+ // if(dfb->depth > 8)
+ // miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
if(dfb->depth > 15)
miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor, RM_ARGB(0,5,5,5), GM_ARGB(0,5,5,5), BM_ARGB(0,5,5,5));
if(dfb->depth > 24)
miSetVisualTypesAndMasks(24, TrueColorMask, 8, TrueColor, RM_ARGB(0,8,8,8), GM_ARGB(0,8,8,8), BM_ARGB(0,8,8,8));
-
+
miSetPixmapDepths();
-
+
// machine independent screen init
// setup _Screen structure in pScreen
if (monitorResolution)
dpi = monitorResolution;
else
dpi = 96;
-
+
// initialize fb
if (! fbScreenInit(pScreen,
- dfb->framebuffer, // pointer to screen bitmap
- dfb->width, dfb->height, // screen size in pixels
- dpi, dpi, // dots per inch
- dfb->pitch/(dfb->bitsPerPixel/8), // pixel width of framebuffer
- dfb->bitsPerPixel)) // bits per pixel for screen
+ dfb->framebuffer, // pointer to screen bitmap
+ dfb->width, dfb->height, // screen size in pixels
+ dpi, dpi, // dots per inch
+ dfb->pitch/(dfb->bitsPerPixel/8), // pixel width of framebuffer
+ dfb->bitsPerPixel)) // bits per pixel for screen
{
return FALSE;
}
-
+
if (! fbPictureInit(pScreen, 0, 0)) {
return FALSE;
}
-
+
#ifdef MITSHM
ShmRegisterFbFuncs(pScreen);
#endif
-
+
// this must be initialized (why doesn't X have a default?)
pScreen->SaveScreen = DarwinSaveScreen;
-
+
// finish mode dependent screen setup including cursor support
if (!QuartzSetupScreen(index, pScreen)) {
return FALSE;
}
-
+
// create and install the default colormap and
// set pScreen->blackPixel / pScreen->white
if (!miCreateDefColormap( pScreen )) {
return FALSE;
}
-
+
pScreen->x = dfb->x;
pScreen->y = dfb->y;
-
+
/* ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
- index, dfb->width, dfb->height, dfb->x, dfb->y); */
-
+ index, dfb->width, dfb->height, dfb->x, dfb->y); */
+
return TRUE;
}
/*
=============================================================================
-
+
mouse and keyboard callbacks
-
+
=============================================================================
-*/
+ */
/*
* DarwinMouseProc: Handle the initialization, etc. of a mouse
@@ -302,11 +302,11 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3, 4, 5, 6, 7};
Atom btn_labels[NBUTTONS] = {0};
Atom axes_labels[NAXES] = {0};
-
+
switch (what) {
case DEVICE_INIT:
pPointer->public.on = FALSE;
-
+
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
@@ -314,11 +314,11 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
-
+
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-
-
+
+
// Set button map.
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
btn_labels,
@@ -350,21 +350,21 @@ static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3};
Atom btn_labels[NBUTTONS] = {0};
Atom axes_labels[NAXES] = {0};
-
+
switch (what) {
case DEVICE_INIT:
pPointer->public.on = FALSE;
-
+
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
-
+
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X);
axes_labels[4] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
-
+
// Set button map.
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
btn_labels,
@@ -372,13 +372,13 @@ static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
GetMotionHistorySize(), NAXES,
axes_labels);
InitProximityClassDeviceStruct(pPointer);
-
+
InitValuatorAxisStruct(pPointer, 0, axes_labels[0], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
InitValuatorAxisStruct(pPointer, 1, axes_labels[1], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
InitValuatorAxisStruct(pPointer, 2, axes_labels[2], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
InitValuatorAxisStruct(pPointer, 3, axes_labels[3], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
InitValuatorAxisStruct(pPointer, 4, axes_labels[4], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
-// pPointer->use = IsXExtensionDevice;
+ // pPointer->use = IsXExtensionDevice;
break;
case DEVICE_ON:
pPointer->public.on = TRUE;
@@ -416,17 +416,17 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
case DEVICE_CLOSE:
break;
}
-
+
return Success;
}
/*
-===========================================================================
-
+ ===========================================================================
+
Utility routines
-
-===========================================================================
-*/
+
+ ===========================================================================
+ */
/*
* DarwinParseModifierList
@@ -435,13 +435,13 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
int DarwinParseModifierList(const char *constmodifiers, int separatelr)
{
int result = 0;
-
+
if (constmodifiers) {
char *modifiers = strdup(constmodifiers);
char *modifier;
int nxkey;
char *p = modifiers;
-
+
while (p) {
modifier = strsep(&p, " ,+&|/"); // allow lots of separators
nxkey = DarwinModifierStringToNXMask(modifier, separatelr);
@@ -456,12 +456,12 @@ int DarwinParseModifierList(const char *constmodifiers, int separatelr)
}
/*
-===========================================================================
-
+ ===========================================================================
+
Functions needed to link against device independent X
-
-===========================================================================
-*/
+
+ ===========================================================================
+ */
/*
* InitInput
@@ -470,41 +470,41 @@ int DarwinParseModifierList(const char *constmodifiers, int separatelr)
void InitInput( int argc, char **argv )
{
XkbRMLVOSet rmlvo = { .rules = "base", .model = "empty", .layout = "empty",
- .variant = NULL, .options = NULL };
+ .variant = NULL, .options = NULL };
/* We need to really have rules... or something... */
XkbSetRulesDflts(&rmlvo);
-
+
darwinKeyboard = AddInputDevice(serverClient, DarwinKeybdProc, TRUE);
darwinKeyboard->name = strdup("keyboard");
-
+
/* here's the snippet from the current gdk sources:
- if (!strcmp (tmp_name, "pointer"))
- gdkdev->info.source = GDK_SOURCE_MOUSE;
- else if (!strcmp (tmp_name, "wacom") ||
- !strcmp (tmp_name, "pen"))
- gdkdev->info.source = GDK_SOURCE_PEN;
- else if (!strcmp (tmp_name, "eraser"))
- gdkdev->info.source = GDK_SOURCE_ERASER;
- else if (!strcmp (tmp_name, "cursor"))
- gdkdev->info.source = GDK_SOURCE_CURSOR;
- else
- gdkdev->info.source = GDK_SOURCE_PEN;
- */
-
+ if (!strcmp (tmp_name, "pointer"))
+ gdkdev->info.source = GDK_SOURCE_MOUSE;
+ else if (!strcmp (tmp_name, "wacom") ||
+ !strcmp (tmp_name, "pen"))
+ gdkdev->info.source = GDK_SOURCE_PEN;
+ else if (!strcmp (tmp_name, "eraser"))
+ gdkdev->info.source = GDK_SOURCE_ERASER;
+ else if (!strcmp (tmp_name, "cursor"))
+ gdkdev->info.source = GDK_SOURCE_CURSOR;
+ else
+ gdkdev->info.source = GDK_SOURCE_PEN;
+ */
+
darwinPointer = AddInputDevice(serverClient, DarwinMouseProc, TRUE);
darwinPointer->name = strdup("pointer");
-
+
darwinTabletStylus = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
darwinTabletStylus->name = strdup("pen");
-
+
darwinTabletCursor = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
darwinTabletCursor->name = strdup("cursor");
-
+
darwinTabletEraser = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
darwinTabletEraser->name = strdup("eraser");
-
+
DarwinEQInit();
-
+
QuartzInitInput(argc, argv);
}
@@ -531,10 +531,10 @@ void
DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
{
int i, left, top;
-
+
left = pScreenInfo->screens[0]->x;
top = pScreenInfo->screens[0]->y;
-
+
/* Find leftmost screen. If there's a tie, take the topmost of the two. */
for (i = 1; i < pScreenInfo->numScreens; i++) {
if (pScreenInfo->screens[i]->x < left ||
@@ -544,17 +544,17 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
top = pScreenInfo->screens[i]->y;
}
}
-
+
darwinMainScreenX = left;
darwinMainScreenY = top;
DEBUG_LOG("top = %d, left=%d\n", top, left);
-
+
/* Shift all screens so that there is a screen whose top left
* is at X11 (0,0) and at global screen coordinate
* (darwinMainScreenX, darwinMainScreenY).
*/
-
+
if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
for (i = 0; i < pScreenInfo->numScreens; i++) {
pScreenInfo->screens[i]->x -= darwinMainScreenX;
@@ -582,25 +582,25 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
{
int i;
-
+
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
-
+
// List how we want common pixmap formats to be padded
pScreenInfo->numPixmapFormats = NUMFORMATS;
for (i = 0; i < NUMFORMATS; i++)
pScreenInfo->formats[i] = formats[i];
-
+
// Discover screens and do mode specific initialization
QuartzInitOutput(argc, argv);
-
+
// Add screens
for (i = 0; i < darwinScreensFound; i++) {
AddScreen(DarwinScreenInit, argc, argv);
}
-
+
DarwinAdjustScreenOrigins(pScreenInfo);
}
@@ -625,31 +625,31 @@ void OsVendorInit(void)
char *home = getenv("HOME");
assert(home);
assert(0 < asprintf(&lf, "%s/Library/Logs/X11", home));
-
+
/* Ignore errors. If EEXIST, we don't care. If anything else,
* LogInit will handle it for us.
*/
(void)mkdir(lf, S_IRWXU | S_IRWXG | S_IRWXO);
free(lf);
-
+
assert(0 < asprintf(&lf, "%s/Library/Logs/X11/%s.log", home, bundle_id_prefix));
LogInit(lf, ".old");
free(lf);
-
+
DarwinPrintBanner();
#ifdef ENABLE_DEBUG_LOG
- {
- char *home_dir=NULL, *log_file_path=NULL;
- home_dir = getenv("HOME");
- if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
- if (log_file_path) {
- if (!access(log_file_path, F_OK)) {
- debug_log_fp = fopen(log_file_path, "a");
- if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
- }
- free(log_file_path);
- }
- }
+ {
+ char *home_dir=NULL, *log_file_path=NULL;
+ home_dir = getenv("HOME");
+ if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
+ if (log_file_path) {
+ if (!access(log_file_path, F_OK)) {
+ debug_log_fp = fopen(log_file_path, "a");
+ if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
+ }
+ free(log_file_path);
+ }
+ }
#endif
}
}
@@ -663,33 +663,33 @@ void OsVendorInit(void)
*/
int ddxProcessArgument( int argc, char *argv[], int i )
{
-// if ( !strcmp( argv[i], "-fullscreen" ) ) {
-// ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
-// return 1;
-// }
-
-// if ( !strcmp( argv[i], "-rootless" ) ) {
-// ErrorF( "Running rootless inside Mac OS X window server.\n" );
-// return 1;
-// }
-
+ // if ( !strcmp( argv[i], "-fullscreen" ) ) {
+ // ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
+ // return 1;
+ // }
+
+ // if ( !strcmp( argv[i], "-rootless" ) ) {
+ // ErrorF( "Running rootless inside Mac OS X window server.\n" );
+ // return 1;
+ // }
+
// This command line arg is passed when launched from the Aqua GUI.
if ( !strncmp( argv[i], "-psn_", 5 ) ) {
return 1;
}
-
+
if ( !strcmp( argv[i], "-fakebuttons" ) ) {
darwinFakeButtons = TRUE;
ErrorF( "Faking a three button mouse\n" );
return 1;
}
-
+
if ( !strcmp( argv[i], "-nofakebuttons" ) ) {
darwinFakeButtons = FALSE;
ErrorF( "Not faking a three button mouse\n" );
return 1;
}
-
+
if (!strcmp( argv[i], "-fakemouse2" ) ) {
if ( i == argc-1 ) {
FatalError( "-fakemouse2 must be followed by a modifer list\n" );
@@ -702,7 +702,7 @@ int ddxProcessArgument( int argc, char *argv[], int i )
darwinFakeMouse2Mask);
return 2;
}
-
+
if (!strcmp( argv[i], "-fakemouse3" ) ) {
if ( i == argc-1 ) {
FatalError( "-fakemouse3 must be followed by a modifer list\n" );
@@ -715,17 +715,17 @@ int ddxProcessArgument( int argc, char *argv[], int i )
darwinFakeMouse3Mask);
return 2;
}
-
+
if ( !strcmp( argv[i], "+synckeymap" ) ) {
darwinSyncKeymap = TRUE;
return 1;
}
-
+
if ( !strcmp( argv[i], "-synckeymap" ) ) {
darwinSyncKeymap = FALSE;
return 1;
}
-
+
if ( !strcmp( argv[i], "-depth" ) ) {
if ( i == argc-1 ) {
FatalError( "-depth must be followed by a number\n" );
@@ -737,16 +737,16 @@ int ddxProcessArgument( int argc, char *argv[], int i )
darwinDesiredDepth != 24) {
FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
}
-
+
ErrorF( "Attempting to use pixel depth of %i\n", darwinDesiredDepth );
return 2;
}
-
+
if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
DarwinPrintBanner();
exit(0);
}
-
+
return 0;
}
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index aafc12fbf..ef98b8e4e 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple, Inc.
+ * Copyright (C) 2008-2012 Apple, Inc.
* Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index c7e637709..843bd7145 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -1,33 +1,41 @@
/*
-Darwin event queue and event handling
-
-Copyright 2007-2008 Apple Inc.
-Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
-Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
-
-This file is based on mieq.c by Keith Packard,
-which contains the following copyright:
-Copyright 1990, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
+ * Darwin event queue and event handling
+ *
+ * Copyright 2007-2008 Apple Inc.
+ * Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+ * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * This file is based on mieq.c by Keith Packard,
+ * which contains the following copyright:
+ * Copyright 1990, 1998 The Open Group
+ *
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
*/
#include "sanitizedCarbon.h"
@@ -97,13 +105,13 @@ static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_t create_thread(void *(*func)(void *), void *arg) {
pthread_attr_t attr;
pthread_t tid;
-
+
pthread_attr_init (&attr);
pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
pthread_create (&tid, &attr, func, arg);
pthread_attr_destroy (&attr);
-
+
return tid;
}
@@ -136,12 +144,12 @@ void darwinEvents_unlock(void) {
*/
static void DarwinPressModifierKey(int pressed, int key) {
int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
-
+
if (keycode == 0) {
ErrorF("DarwinPressModifierKey bad keycode: key=%d\n", key);
return;
}
-
+
DarwinSendKeyboardEvents(pressed, keycode);
}
@@ -166,12 +174,12 @@ static int darwin_x11_modifier_mask_list[] = {
static int darwin_all_modifier_mask_additions[] = { NX_SECONDARYFNMASK, };
static void DarwinUpdateModifiers(
- int pressed, // KeyPress or KeyRelease
- int flags ) // modifier flags that have changed
+ int pressed, // KeyPress or KeyRelease
+ int flags ) // modifier flags that have changed
{
int *f;
int key;
-
+
/* Capslock is special. This mask is the state of capslock (on/off),
* not the state of the button. Hopefully we can find a better solution.
*/
@@ -191,12 +199,12 @@ static void DarwinUpdateModifiers(
}
/* Generic handler for Xquartz-specifc events. When possible, these should
- be moved into their own individual functions and set as handlers using
- mieqSetHandler. */
+ be moved into their own individual functions and set as handlers using
+ mieqSetHandler. */
static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
XQuartzEvent *e = &(ie->xquartz_event);
-
+
switch(e->subtype) {
case kXquartzControllerNotify:
DEBUG_LOG("kXquartzControllerNotify\n");
@@ -229,7 +237,7 @@ static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr de
AppleWMIsInactive, 0);
QuartzHide();
break;
-
+
case kXquartzReloadPreferences:
DEBUG_LOG("kXquartzReloadPreferences\n");
AppleWMSendEvent(AppleWMActivationNotify,
@@ -266,7 +274,7 @@ static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr de
DEBUG_LOG("kXquartzSpaceChanged\n");
QuartzSpaceChanged(e->data[0]);
break;
-
+
case kXquartzListenOnOpenFD:
ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]);
ListenOnOpenFD((int)e->data[0], 1);
@@ -279,7 +287,7 @@ static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr de
case kXquartzDisplayChanged:
DEBUG_LOG("kXquartzDisplayChanged\n");
QuartzUpdateScreens();
-
+
/* Update our RandR info */
QuartzRandRUpdateFakeModes(TRUE);
break;
@@ -298,7 +306,7 @@ void DarwinListenOnOpenFD(int fd) {
fd_add[fd_add_count++] = fd;
else
ErrorF("FD Addition buffer at max. Dropping fd addition request.\n");
-
+
pthread_cond_broadcast(&fd_add_ready_cond);
pthread_mutex_unlock(&fd_add_lock);
}
@@ -313,18 +321,18 @@ static void *DarwinProcessFDAdditionQueue_thread(void *args) {
* ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook
* into it.
*/
-
+
struct timespec sleep_for;
struct timespec sleep_remaining;
-
+
sleep_for.tv_sec = 3;
sleep_for.tv_nsec = 0;
-
+
ErrorF("X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n");
while(nanosleep(&sleep_for, &sleep_remaining) != 0) {
sleep_for = sleep_remaining;
}
-
+
pthread_mutex_lock(&fd_add_lock);
while(true) {
while(fd_add_count) {
@@ -332,13 +340,13 @@ static void *DarwinProcessFDAdditionQueue_thread(void *args) {
}
pthread_cond_wait(&fd_add_ready_cond, &fd_add_lock);
}
-
+
return NULL;
}
Bool DarwinEQInit(void) {
int *p;
-
+
for(p=darwin_x11_modifier_mask_list, darwin_all_modifier_mask=0; *p; p++) {
darwin_x11_modifier_mask |= *p;
}
@@ -349,7 +357,7 @@ Bool DarwinEQInit(void) {
mieqInit();
mieqSetHandler(ET_XQuartz, DarwinEventHandler);
-
+
/* Note that this *could* cause a potential async issue, since we're checking
* darwinEvents without holding the lock, but darwinEvents is only ever set
* here, so I don't bother.
@@ -364,7 +372,7 @@ Bool DarwinEQInit(void) {
pthread_cond_broadcast(&mieq_ready_cond);
darwinEvents_unlock();
}
-
+
if(!fd_add_tid)
fd_add_tid = create_thread(DarwinProcessFDAdditionQueue_thread, NULL);
@@ -384,15 +392,15 @@ void ProcessInputEvents(void) {
int x = sizeof(nullbyte);
mieqProcessInputEvents();
-
+
// Empty the signaling pipe
while (x == sizeof(nullbyte)) {
- x = read(darwinEventReadFD, &nullbyte, sizeof(nullbyte));
+ x = read(darwinEventReadFD, &nullbyte, sizeof(nullbyte));
}
}
/* Sends a null byte down darwinEventWriteFD, which will cause the
- Dispatch() event loop to check out event queue */
+ Dispatch() event loop to check out event queue */
static void DarwinPokeEQ(void) {
char nullbyte=0;
// <daniels> oh, i ... er ... christ.
@@ -406,16 +414,16 @@ static void DarwinPokeEQ(void) {
static void DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask, ScreenPtr screen,
double pointer_x, double pointer_y,
double pressure, double tilt_x, double tilt_y) {
-
+
valuator_mask_zero(pmask);
-
+
/* Fix offset between darwin and X screens */
pointer_x -= darwinMainScreenX + screen->x;
pointer_y -= darwinMainScreenY + screen->y;
-
+
if(pointer_x < 0.0)
pointer_x = 0.0;
-
+
if(pointer_y < 0.0)
pointer_y = 0.0;
@@ -428,10 +436,10 @@ static void DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask, Scree
valuator_mask_set_double(pmask, 2, XQUARTZ_VALUATOR_LIMIT * pressure);
valuator_mask_set_double(pmask, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x);
valuator_mask_set_double(pmask, 4, XQUARTZ_VALUATOR_LIMIT * tilt_y);
- DEBUG_LOG("Pointer (%lf, %lf), Valuators: {%lf,%lf,%lf,%lf,%lf}\n", pointer_x, pointer_y,
- valuator_mask_get_double(pmask, 0), valuator_mask_get_double(pmask, 1),
- valuator_mask_get_double(pmask, 2), valuator_mask_get_double(pmask, 3),
- valuator_mask_get_double(pmask, 4));
+ DEBUG_LOG("Pointer (%lf, %lf), Valuators: {%lf,%lf,%lf,%lf,%lf}\n", pointer_x, pointer_y,
+ valuator_mask_get_double(pmask, 0), valuator_mask_get_double(pmask, 1),
+ valuator_mask_get_double(pmask, 2), valuator_mask_get_double(pmask, 3),
+ valuator_mask_get_double(pmask, 4));
}
}
@@ -445,7 +453,7 @@ void DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev) {
}
}
}
-
+
if (pDev->key) {
for (i = 0; i < NUM_KEYCODES; i++) {
if (BitIsOn(pDev->key->down, i + MIN_KEYCODE)) {
@@ -458,7 +466,7 @@ void DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev) {
}
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, double pointer_x, double pointer_y,
- double pressure, double tilt_x, double tilt_y) {
+ double pressure, double tilt_x, double tilt_y) {
static int darwinFakeMouseButtonDown = 0;
ScreenPtr screen;
ValuatorMask valuators;
@@ -469,13 +477,13 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, doub
DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n");
return;
}
-
+
screen = miPointerGetScreen(pDev);
if(!screen) {
DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
return;
}
-
+
/* Handle fake click */
if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
if(darwinFakeMouseButtonDown != 0) {
@@ -493,21 +501,21 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, doub
DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
}
}
-
+
if (ev_type == ButtonRelease && ev_button == 1) {
if(darwinFakeMouseButtonDown) {
ev_button = darwinFakeMouseButtonDown;
}
-
+
if(darwinFakeMouseButtonDown == 2) {
DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
} else if(darwinFakeMouseButtonDown == 3) {
DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
}
-
+
darwinFakeMouseButtonDown = 0;
}
-
+
DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
darwinEvents_lock(); {
QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &valuators);
@@ -516,12 +524,12 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, doub
}
void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-
+
if(!darwinEvents) {
DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
return;
}
-
+
darwinEvents_lock(); {
QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
DarwinPokeEQ();
@@ -532,9 +540,9 @@ void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
double pressure, double tilt_x, double tilt_y) {
ScreenPtr screen;
ValuatorMask valuators;
-
+
DEBUG_LOG("DarwinSendProximityEvents: %d l:%f,%f p:%f t:%f,%f\n", ev_type, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
-
+
if(!darwinEvents) {
DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
return;
@@ -545,7 +553,7 @@ void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
return;
}
-
+
DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
darwinEvents_lock(); {
QueueProximityEvents(pDev, ev_type, &valuators);
@@ -563,7 +571,7 @@ void DarwinSendScrollEvents(double scroll_x, double scroll_y,
DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n");
return;
}
-
+
sign_x = scroll_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
sign_y = scroll_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
scroll_x = fabs(scroll_x);
@@ -584,7 +592,7 @@ void DarwinSendScrollEvents(double scroll_x, double scroll_y,
}
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
- reflect changing modifier flags (alt, control, meta, etc) */
+ reflect changing modifier flags (alt, control, meta, etc) */
void DarwinUpdateModKeys(int flags) {
DarwinUpdateModifiers(KeyRelease, darwin_all_modifier_flags & ~flags & darwin_x11_modifier_mask);
DarwinUpdateModifiers(KeyPress, ~darwin_all_modifier_flags & flags & darwin_x11_modifier_mask);
@@ -599,21 +607,21 @@ void DarwinSendDDXEvent(int type, int argc, ...) {
XQuartzEvent e;
int i;
va_list args;
-
+
memset(&e, 0, sizeof(e));
e.header = ET_Internal;
e.type = ET_XQuartz;
e.length = sizeof(e);
e.time = GetTimeInMillis();
e.subtype = type;
-
+
if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) {
va_start (args, argc);
for (i = 0; i < argc; i++)
e.data[i] = (uint32_t) va_arg (args, uint32_t);
va_end (args);
}
-
+
darwinEvents_lock(); {
mieqEnqueue(NULL, (InternalEvent*)&e);
DarwinPokeEQ();
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 56cb59bd3..09f72a6d3 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -38,12 +38,12 @@ void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
void DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev);
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, double pointer_x, double pointer_y,
- double pressure, double tilt_x, double tilt_y);
+ double pressure, double tilt_x, double tilt_y);
void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x, double pointer_y,
double pressure, double tilt_x, double tilt_y);
void DarwinSendKeyboardEvents(int ev_type, int keycode);
void DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x, double pointer_y,
- double pressure, double tilt_x, double tilt_y);
+ double pressure, double tilt_x, double tilt_y);
void DarwinUpdateModKeys(int flags);
void DarwinListenOnOpenFD(int fd);
diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index 94c31bb23..35c3af267 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -6,50 +6,50 @@
*/
/************************************************************
-
-Copyright 1989, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Hewlett-Packard not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-********************************************************/
+
+ Copyright 1989, 1998 The Open Group
+
+ Permission to use, copy, modify, distribute, and sell this software and its
+ documentation for any purpose is hereby granted without fee, provided that
+ the above copyright notice appear in all copies and that both that
+ copyright notice and this permission notice appear in supporting
+ documentation.
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name of The Open Group shall not be
+ used in advertising or otherwise to promote the sale, use or other dealings
+ in this Software without prior written authorization from The Open Group.
+
+ Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of Hewlett-Packard not be
+ used in advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+
+ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
@@ -78,7 +78,7 @@ SOFTWARE.
int
SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
{
- DEBUG_LOG("SetDeviceMode(%p, %p, %d)\n", client, dev, mode);
+ DEBUG_LOG("SetDeviceMode(%p, %p, %d)\n", client, dev, mode);
return BadMatch;
}
@@ -96,11 +96,11 @@ SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
int
SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
- int *valuators, int first_valuator, int num_valuators)
+ int *valuators, int first_valuator, int num_valuators)
{
- DEBUG_LOG("SetDeviceValuators(%p, %p, %p, %d, %d)\n", client,
- dev, valuators, first_valuator, num_valuators);
- return BadMatch;
+ DEBUG_LOG("SetDeviceValuators(%p, %p, %p, %d, %d)\n", client,
+ dev, valuators, first_valuator, num_valuators);
+ return BadMatch;
}
/****************************************************************************
@@ -113,11 +113,11 @@ SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
int
ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
- xDeviceCtl * control)
+ xDeviceCtl * control)
{
-
- DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
- return BadMatch;
+
+ DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
+ return BadMatch;
}
@@ -132,8 +132,8 @@ int
NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
DeviceIntPtr *pdev)
{
- DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
- return BadValue;
+ DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
+ return BadValue;
}
/****************************************************************************
@@ -146,6 +146,6 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
void
DeleteInputDeviceRequest(DeviceIntPtr dev)
{
- DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
+ DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
}
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 94c606823..2f3711af6 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -1,32 +1,33 @@
/* main.c -- X application launcher
-
- Copyright (c) 2007 Jeremy Huddleston
- Copyright (c) 2007 Apple Inc
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
+ * Copyright (c) 2007 Jeremy Huddleston
+ * Copyright (c) 2007-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
+
#include <CoreFoundation/CoreFoundation.h>
#include <AvailabilityMacros.h>
diff --git a/hw/xquartz/mach-startup/launchd_fd.c b/hw/xquartz/mach-startup/launchd_fd.c
index 8003dd177..656ee1a3d 100644
--- a/hw/xquartz/mach-startup/launchd_fd.c
+++ b/hw/xquartz/mach-startup/launchd_fd.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008 Apple Inc.
+/* Copyright (c) 2008-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -41,7 +41,7 @@ extern aslclient aslc;
int launchd_display_fd(void) {
launch_data_t sockets_dict, checkin_request, checkin_response;
launch_data_t listening_fd_array, listening_fd;
-
+
/* Get launchd fd */
if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n");
diff --git a/hw/xquartz/mach-startup/launchd_fd.h b/hw/xquartz/mach-startup/launchd_fd.h
index 12caf7193..cbf01c9b4 100644
--- a/hw/xquartz/mach-startup/launchd_fd.h
+++ b/hw/xquartz/mach-startup/launchd_fd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008 Apple Inc.
+/* Copyright (c) 2008-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index d8e4abdd1..b2699449c 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008 Apple Inc.
+/* Copyright (c) 2008-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -60,10 +60,10 @@ aslclient aslc;
static void set_x11_path(void) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-
+
CFURLRef appURL = NULL;
OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL);
-
+
switch (osstatus) {
case noErr:
if (appURL == NULL) {
@@ -71,12 +71,12 @@ static void set_x11_path(void) {
kX11AppBundleId);
exit(1);
}
-
+
if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error resolving URL for %s", kX11AppBundleId);
exit(3);
}
-
+
strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path);
break;
@@ -99,7 +99,7 @@ static int connect_to_socket(const char *filename) {
struct sockaddr *servaddr;
socklen_t servaddr_len;
int ret_fd;
-
+
/* Setup servaddr_un */
memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
servaddr_un.sun_family = AF_UNIX;
@@ -113,7 +113,7 @@ static int connect_to_socket(const char *filename) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to create socket: %s - %s", filename, strerror(errno));
return -1;
}
-
+
if(connect(ret_fd, servaddr, servaddr_len) < 0) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket: %s - %d - %s", filename, errno, strerror(errno));
close(ret_fd);
@@ -134,10 +134,10 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) {
struct msghdr msg;
struct cmsghdr *cmsg;
-
+
iov[0].iov_base = databuf;
iov[0].iov_len = sizeof(databuf);
-
+
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_control = buf.bytes;
@@ -145,12 +145,12 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) {
msg.msg_name = 0;
msg.msg_namelen = 0;
msg.msg_flags = 0;
-
+
cmsg = CMSG_FIRSTHDR (&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
-
+
msg.msg_controllen = cmsg->cmsg_len;
*((int*)CMSG_DATA(cmsg)) = launchd_fd;
@@ -159,7 +159,7 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s", connected_fd, errno, strerror(errno));
return;
}
-
+
asl_log(aslc, NULL, ASL_LEVEL_DEBUG, "Xquartz: Message sent. Closing handoff fd.");
close(connected_fd);
}
@@ -184,22 +184,22 @@ int main(int argc, char **argv, char **envp) {
char *asl_sender;
char *asl_facility;
char *server_bootstrap_name = kX11AppBundleId;
-
+
if(getenv("X11_PREFS_DOMAIN"))
server_bootstrap_name = getenv("X11_PREFS_DOMAIN");
-
+
asprintf(&asl_sender, "%s.stub", server_bootstrap_name);
assert(asl_sender);
-
+
asl_facility = strdup(server_bootstrap_name);
assert(asl_facility);
if(strcmp(asl_facility + strlen(asl_facility) - 4, ".X11") == 0)
asl_facility[strlen(asl_facility) - 4] = '\0';
-
+
assert(aslc = asl_open(asl_sender, asl_facility, ASL_OPT_NO_DELAY));
free(asl_sender);
free(asl_facility);
-
+
/* We don't have a mechanism in place to handle this interrupt driven
* server-start notification, so just send the signal now, so xinit doesn't
* time out waiting for it and will just poll for the server.
@@ -208,28 +208,28 @@ int main(int argc, char **argv, char **envp) {
if(handler == SIG_IGN)
kill(getppid(), SIGUSR1);
signal(SIGUSR1, handler);
-
+
/* Pass on SIGs to X11.app */
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
/* Get the $DISPLAY FD */
launchd_fd = launchd_display_fd();
-
+
kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
if(kr != KERN_SUCCESS) {
pid_t child;
-
+
asl_log(aslc, NULL, ASL_LEVEL_WARNING, "Xquartz: Unable to locate waiting server: %s", server_bootstrap_name);
set_x11_path();
-
+
/* This forking is ugly and will be cleaned up later */
child = fork();
if(child == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s", strerror(errno));
return EXIT_FAILURE;
}
-
+
if(child == 0) {
char *_argv[3];
_argv[0] = x11_path;
@@ -238,7 +238,7 @@ int main(int argc, char **argv, char **envp) {
asl_log(aslc, NULL, ASL_LEVEL_NOTICE, "Xquartz: Starting X server: %s --listenonly", x11_path);
return execvp(x11_path, _argv);
}
-
+
/* Try connecting for 10 seconds */
for(i=0; i < 80; i++) {
usleep(250000);
@@ -246,7 +246,7 @@ int main(int argc, char **argv, char **envp) {
if(kr == KERN_SUCCESS)
break;
}
-
+
if(kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(kr));
@@ -259,31 +259,31 @@ int main(int argc, char **argv, char **envp) {
/* Get X11.app's pid */
request_pid(mp, &x11app_pid);
-
+
/* Handoff the $DISPLAY FD */
if(launchd_fd != -1) {
size_t try, try_max;
int handoff_fd = -1;
-
+
for(try=0, try_max=5; try < try_max; try++) {
if(request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)", (int)try+1, (int)try_max);
continue;
}
-
+
handoff_fd = connect_to_socket(handoff_socket_filename);
if(handoff_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket (try %d of %d)", (int)try+1, (int)try_max);
continue;
}
-
+
asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.", (int)try+1, (int)try_max, handoff_fd, handoff_socket_filename);
send_fd_handoff(handoff_fd, launchd_fd);
close(handoff_fd);
break;
}
}
-
+
/* Count envp */
for(envpc=0; envp[envpc]; envpc++);
@@ -292,7 +292,7 @@ int main(int argc, char **argv, char **envp) {
*/
newargv = (string_array_t)calloc((1 + argc), sizeof(string_t));
newenvp = (string_array_t)calloc((1 + envpc), sizeof(string_t));
-
+
if(!newargv || !newenvp) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Memory allocation failure");
return EXIT_FAILURE;
@@ -304,12 +304,12 @@ int main(int argc, char **argv, char **envp) {
for(i=0; i < envpc; i++) {
strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
}
-
+
kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
-
+
free(newargv);
free(newenvp);
-
+
if (kr != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s", mach_error_string(kr));
return EXIT_FAILURE;
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 772c458a1..4eacc879f 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -1,32 +1,34 @@
/* app-main.m
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
*/
+
#include "pbproxy.h"
#import "x-selection.h"
@@ -57,7 +59,7 @@ void
ErrorF(const char * f, ...)
{
va_list args;
-
+
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
@@ -67,7 +69,7 @@ ErrorF(const char * f, ...)
void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...) {
#ifdef DEBUG
va_list args;
-
+
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
@@ -77,16 +79,16 @@ void xq_asl_log (int level, const char *subsystem, const char *file, const char
int main (int argc, const char *argv[]) {
const char *s;
int i;
-
+
#ifdef DEBUG
ErrorF("pid: %u\n", getpid());
#endif
-
+
xpbproxy_is_standalone = YES;
-
+
if((s = getenv("X11_PREFS_DOMAIN")))
app_prefs_domain = s;
-
+
for (i = 1; i < argc; i++) {
if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
app_prefs_domain = argv[++i];
@@ -98,7 +100,7 @@ int main (int argc, const char *argv[]) {
return 0;
} else {
ErrorF("usage: xpbproxy OPTIONS...\n"
- "Try 'xpbproxy --help' for more information.\n");
+ "Try 'xpbproxy --help' for more information.\n");
return 1;
}
}
@@ -109,6 +111,6 @@ int main (int argc, const char *argv[]) {
signal (SIGTERM, signal_handler);
signal (SIGHUP, signal_handler);
signal (SIGPIPE, SIG_IGN);
-
+
return xpbproxy_run();
}
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 29ce83b35..9f47be515 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -1,32 +1,34 @@
/* main.m
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
*/
+
#include "pbproxy.h"
#import "x-selection.h"
@@ -65,7 +67,7 @@ static int x_io_error_handler (Display *dpy) {
/* We lost our connection to the server. */
TRACE ();
-
+
/* trigger the thread to restart?
* NO - this would be to a "deeper" problem, and restarts would just
* make things worse...
@@ -74,7 +76,7 @@ static int x_io_error_handler (Display *dpy) {
if(xpbproxy_is_standalone)
exit(EXIT_FAILURE);
#endif
-
+
/* Prevent _XIOError from calling exit() */
pthread_exit(NULL);
return 0;
@@ -119,9 +121,9 @@ int xpbproxy_run (void) {
[pool release];
return EXIT_FAILURE;
}
-
+
xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
-
+
XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
AppleWMPasteboardNotifyMask);
@@ -135,7 +137,7 @@ int xpbproxy_run (void) {
[pool release];
CFRunLoopRun();
-
+
return EXIT_SUCCESS;
}
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index c80a660cc..d82b3caad 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -1,31 +1,33 @@
/* pbproxy.h
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
-*/
#ifndef PBPROXY_H
#define PBPROXY_H 1
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index ebb89980f..c4b08f533 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -1,32 +1,34 @@
/* x-input.m -- event handling
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
*/
+
#include "pbproxy.h"
#import "x-selection.h"
@@ -51,15 +53,15 @@ static Time last_activation_time;
static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
int type = e->type - xpbproxy_apple_wm_event_base;
int kind = e->kind;
-
+
/* We want to reload prefs even if we're not active */
if(type == AppleWMActivationNotify &&
kind == AppleWMReloadPreferences)
[xpbproxy_selection_object() reload_preferences];
-
+
if(![xpbproxy_selection_object() is_active])
return;
-
+
switch (type) {
case AppleWMActivationNotify:
switch (kind) {
@@ -131,8 +133,8 @@ static void xpbproxy_process_xevents(void) {
}
static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
- CFSocketCallBack callback, const CFSocketContext *ctx,
- CFRunLoopSourceRef *cf_source) {
+ CFSocketCallBack callback, const CFSocketContext *ctx,
+ CFRunLoopSourceRef *cf_source) {
CFSocketRef cf_sock;
cf_sock = CFSocketCreateWithNative (kCFAllocatorDefault, sock,
@@ -156,7 +158,7 @@ static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
CFDataRef address, const void *data, void *info) {
-
+
#ifdef STANDALONE_XPBPROXY
if(xpbproxy_prefs_reload) {
[xpbproxy_selection_object() reload_preferences];
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index d4a39e58f..86f7f02ad 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -1,32 +1,33 @@
/* x-selection.h -- proxies between NSPasteboard and X11 selections
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
-*/
#ifndef X_SELECTION_H
#define X_SELECTION_H 1
@@ -48,18 +49,18 @@ struct propdata {
struct atom_list {
Atom primary, clipboard, text, utf8_string, string, targets, multiple,
- cstring, image_png, image_jpeg, incr, atom, clipboard_manager,
- compound_text, atom_pair;
+ cstring, image_png, image_jpeg, incr, atom, clipboard_manager,
+ compound_text, atom_pair;
};
@interface x_selection : NSObject
{
@private
-
+
/* The unmapped window we use for fetching selections. */
Window _selection_window;
-
+
Atom request_atom;
struct {
@@ -67,7 +68,7 @@ struct atom_list {
Window requestor;
Atom selection;
} pending;
-
+
/*
* This is the number of times the user has requested a copy.
* Once the copy is completed, we --pending_copy, and if the
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index b5f4dde5c..3cd65ee4c 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -1,32 +1,33 @@
/* x-selection.m -- proxies between NSPasteboard and X11 selections
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
-*/
#import "x-selection.h"
@@ -67,9 +68,9 @@
static struct {
BOOL active ;
BOOL primary_on_grab; /* This is provided as an option for people who
- * want it and has issues that won't ever be
- * addressed to make it *always* work.
- */
+ * want it and has issues that won't ever be
+ * addressed to make it *always* work.
+ */
BOOL clipboard_to_pasteboard;
BOOL pasteboard_to_primary;
BOOL pasteboard_to_clipboard;
@@ -83,17 +84,17 @@ static struct propdata null_propdata = {NULL, 0, 0};
static void
dump_prefs() {
ErrorF(fp,
- "pbproxy preferences:\n"
- "\tactive %u\n"
- "\tprimary_on_grab %u\n"
- "\tclipboard_to_pasteboard %u\n"
- "\tpasteboard_to_primary %u\n"
- "\tpasteboard_to_clipboard %u\n",
- pbproxy_prefs.active,
- pbproxy_prefs.primary_on_grab,
- pbproxy_prefs.clipboard_to_pasteboard,
- pbproxy_prefs.pasteboard_to_primary,
- pbproxy_prefs.pasteboard_to_clipboard);
+ "pbproxy preferences:\n"
+ "\tactive %u\n"
+ "\tprimary_on_grab %u\n"
+ "\tclipboard_to_pasteboard %u\n"
+ "\tpasteboard_to_primary %u\n"
+ "\tpasteboard_to_clipboard %u\n",
+ pbproxy_prefs.active,
+ pbproxy_prefs.primary_on_grab,
+ pbproxy_prefs.clipboard_to_pasteboard,
+ pbproxy_prefs.pasteboard_to_primary,
+ pbproxy_prefs.pasteboard_to_clipboard);
}
#endif
@@ -104,7 +105,7 @@ prefs_get_bool (CFStringRef key, BOOL defaultValue) {
Boolean value, ok;
value = CFPreferencesGetAppBooleanValue (key, app_prefs_domain_cfstr, &ok);
-
+
return ok ? (BOOL) value : defaultValue;
}
@@ -140,85 +141,85 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
unsigned char *buf = NULL, *chunk = NULL;
size_t buflen = 0, chunkbytesize = 0;
int format;
-
+
TRACE ();
if(None == property)
- return True;
+ return True;
do
{
- unsigned long newbuflen = 0;
- unsigned char *newbuf = NULL;
-
+ unsigned long newbuflen = 0;
+ unsigned char *newbuf = NULL;
+
#ifdef TEST
- ErrorF("bytesleft %lu\n", bytesleft);
+ ErrorF("bytesleft %lu\n", bytesleft);
#endif
-
- if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
- offset, length, delete,
- AnyPropertyType,
- type, &format, &numitems,
- &bytesleft, &chunk))
- {
- DebugF ("Error while getting window property.\n");
- *pdata = null_propdata;
- free (buf);
- return True;
- }
-
+
+ if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
+ offset, length, delete,
+ AnyPropertyType,
+ type, &format, &numitems,
+ &bytesleft, &chunk))
+ {
+ DebugF ("Error while getting window property.\n");
+ *pdata = null_propdata;
+ free (buf);
+ return True;
+ }
+
#ifdef TEST
- ErrorF("format %d numitems %lu bytesleft %lu\n",
- format, numitems, bytesleft);
-
- ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
+ ErrorF("format %d numitems %lu bytesleft %lu\n",
+ format, numitems, bytesleft);
+
+ ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
#endif
-
- /* Format is the number of bits. */
- if (format == 8)
- chunkbytesize = numitems;
- else if (format == 16)
- chunkbytesize = numitems * sizeof(short);
- else if (format == 32)
- chunkbytesize = numitems * sizeof(long);
-
+
+ /* Format is the number of bits. */
+ if (format == 8)
+ chunkbytesize = numitems;
+ else if (format == 16)
+ chunkbytesize = numitems * sizeof(short);
+ else if (format == 32)
+ chunkbytesize = numitems * sizeof(long);
+
#ifdef TEST
- ErrorF("chunkbytesize %zu\n", chunkbytesize);
+ ErrorF("chunkbytesize %zu\n", chunkbytesize);
#endif
- newbuflen = buflen + chunkbytesize;
- if (newbuflen > 0)
- {
- newbuf = realloc (buf, newbuflen);
-
- if (NULL == newbuf)
- {
- XFree (chunk);
- free (buf);
- return True;
- }
-
- memcpy (newbuf + buflen, chunk, chunkbytesize);
- XFree (chunk);
- buf = newbuf;
- buflen = newbuflen;
- /* offset is a multiple of 32 bits*/
- offset += chunkbytesize / 4;
- }
- else
- {
- if (chunk)
- XFree (chunk);
- }
-
+ newbuflen = buflen + chunkbytesize;
+ if (newbuflen > 0)
+ {
+ newbuf = realloc (buf, newbuflen);
+
+ if (NULL == newbuf)
+ {
+ XFree (chunk);
+ free (buf);
+ return True;
+ }
+
+ memcpy (newbuf + buflen, chunk, chunkbytesize);
+ XFree (chunk);
+ buf = newbuf;
+ buflen = newbuflen;
+ /* offset is a multiple of 32 bits*/
+ offset += chunkbytesize / 4;
+ }
+ else
+ {
+ if (chunk)
+ XFree (chunk);
+ }
+
#ifdef TEST
- ErrorF("bytesleft %lu\n", bytesleft);
+ ErrorF("bytesleft %lu\n", bytesleft);
#endif
} while (bytesleft > 0);
pdata->data = buf;
pdata->length = buflen;
pdata->format = format;
-
+
return /*success*/ False;
}
@@ -231,59 +232,59 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
Atom a = None;
size_t i, step;
Bool png = False, jpeg = False, utf8 = False, string = False;
-
+
TRACE ();
-
+
if (pdata->format != 32)
{
- ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
- return None;
+ ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
+ return None;
}
-
+
for (i = 0, step = sizeof(long); i < pdata->length; i += step)
{
- a = (Atom)*(long *)(pdata->data + i);
-
- if (a == atoms->image_png)
- {
- png = True;
- }
- else if (a == atoms->image_jpeg)
- {
- jpeg = True;
- }
- else if (a == atoms->utf8_string)
- {
- utf8 = True;
+ a = (Atom)*(long *)(pdata->data + i);
+
+ if (a == atoms->image_png)
+ {
+ png = True;
+ }
+ else if (a == atoms->image_jpeg)
+ {
+ jpeg = True;
+ }
+ else if (a == atoms->utf8_string)
+ {
+ utf8 = True;
}
- else if (a == atoms->string)
- {
- string = True;
- }
- else
- {
- char *type = XGetAtomName(xpbproxy_dpy, a);
- if (type)
- {
- DebugF("Unhandled X11 mime type: %s", type);
- XFree(type);
- }
- }
+ else if (a == atoms->string)
+ {
+ string = True;
+ }
+ else
+ {
+ char *type = XGetAtomName(xpbproxy_dpy, a);
+ if (type)
+ {
+ DebugF("Unhandled X11 mime type: %s", type);
+ XFree(type);
+ }
+ }
}
-
+
/*We prefer PNG over strings, and UTF8 over a Latin-1 string.*/
if (png)
- return atoms->image_png;
-
+ return atoms->image_png;
+
if (jpeg)
- return atoms->image_jpeg;
-
+ return atoms->image_jpeg;
+
if (utf8)
- return atoms->utf8_string;
-
+ return atoms->utf8_string;
+
if (string)
- return atoms->string;
-
+ return atoms->string;
+
/* This is evidently something we don't know how to handle.*/
return None;
}
@@ -295,21 +296,21 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
int format;
unsigned long numitems = 0UL, bytesleft = 0UL;
unsigned char *chunk;
-
+
TRACE ();
-
+
if (Success != XGetWindowProperty (xpbproxy_dpy, e->requestor, e->property,
- /*offset*/ 0L, /*length*/ 4UL,
- /*Delete*/ False,
- AnyPropertyType, &seltype, &format,
- &numitems, &bytesleft, &chunk))
+ /*offset*/ 0L, /*length*/ 4UL,
+ /*Delete*/ False,
+ AnyPropertyType, &seltype, &format,
+ &numitems, &bytesleft, &chunk))
{
- return False;
+ return False;
}
-
+
if(chunk)
- XFree(chunk);
-
+ XFree(chunk);
+
return (seltype == atoms->incr) ? True : False;
}
@@ -320,7 +321,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void) release_pending
{
TRACE ();
-
+
free_propdata (&pending.propdata);
pending.requestor = None;
pending.selection = None;
@@ -337,20 +338,20 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (requestor != pending.requestor)
{
- [self release_pending];
- pending.requestor = requestor;
+ [self release_pending];
+ pending.requestor = requestor;
}
newlength = pending.propdata.length + pdata->length;
newdata = realloc(pending.propdata.data, newlength);
-
+
if(NULL == newdata)
{
- perror("realloc propdata");
- [self release_pending];
+ perror("realloc propdata");
+ [self release_pending];
return True;
}
-
+
memcpy(newdata + pending.propdata.length, pdata->data, pdata->length);
pending.propdata.data = newdata;
pending.propdata.length = newlength;
@@ -366,16 +367,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
static NSInteger changeCount;
NSInteger countNow;
NSPasteboard *pb;
-
+
TRACE ();
-
+
pb = [NSPasteboard generalPasteboard];
-
+
if (nil == pb)
- return;
-
+ return;
+
countNow = [pb changeCount];
-
+
if (countNow != changeCount)
{
DebugF ("changed pasteboard!\n");
@@ -390,18 +391,18 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[self own_clipboard];
}
}
-
+
#if 0
/*gstaplin: we should perhaps investigate something like this branch above...*/
if ([_pasteboard availableTypeFromArray: _known_types] != nil)
{
/* Pasteboard has data we should proxy; I think it makes
- sense to put it on both CLIPBOARD and PRIMARY */
-
+ sense to put it on both CLIPBOARD and PRIMARY */
+
XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard,
- _selection_window, timestamp);
+ _selection_window, timestamp);
XSetSelectionOwner (xpbproxy_dpy, atoms->primary,
- _selection_window, timestamp);
+ _selection_window, timestamp);
}
#endif
}
@@ -416,10 +417,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void) x_copy_request_targets
{
TRACE ();
-
+
request_atom = atoms->targets;
XConvertSelection (xpbproxy_dpy, atoms->primary, atoms->targets,
- atoms->primary, _selection_window, CurrentTime);
+ atoms->primary, _selection_window, CurrentTime);
}
/* Called when the Edit/Copy item on the main X11 menubar is selected
@@ -427,23 +428,23 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void) x_copy:(Time)timestamp
{
Window w;
-
+
TRACE ();
-
+
w = XGetSelectionOwner (xpbproxy_dpy, atoms->primary);
-
+
if (None != w)
{
- ++pending_copy;
-
- if (1 == pending_copy) {
- /*
- * There are no other copy operations in progress, so we
- * can proceed safely. Otherwise the copy_completed method
- * will see that the pending_copy is > 1, and do another copy.
- */
- [self x_copy_request_targets];
- }
+ ++pending_copy;
+
+ if (1 == pending_copy) {
+ /*
+ * There are no other copy operations in progress, so we
+ * can proceed safely. Otherwise the copy_completed method
+ * will see that the pending_copy is > 1, and do another copy.
+ */
+ [self x_copy_request_targets];
+ }
}
}
@@ -454,16 +455,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (BOOL) set_clipboard_manager_status:(BOOL)value
{
TRACE ();
-
+
Window owner = XGetSelectionOwner (xpbproxy_dpy, atoms->clipboard_manager);
-
+
if(value) {
if(owner == _selection_window)
return TRUE;
-
+
if(owner != None) {
ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection. "
- "pbproxy will not sync clipboard to pasteboard.\n", owner);
+ "pbproxy will not sync clipboard to pasteboard.\n", owner);
return FALSE;
}
@@ -472,7 +473,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
} else {
if(owner != _selection_window)
return TRUE;
-
+
XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, None, CurrentTime);
return(None == XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
}
@@ -487,9 +488,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void) clear_event:(XSelectionClearEvent *)e
{
-
+
TRACE ();
-
+
DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
if(e->selection == atoms->clipboard) {
@@ -508,7 +509,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* to avoid a race.
*/
ErrorF("Another clipboard manager was started! "
- "xpbproxy is disabling syncing with clipboard.\n");
+ "xpbproxy is disabling syncing with clipboard.\n");
pbproxy_prefs.clipboard_to_pasteboard = NO;
}
}
@@ -552,16 +553,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* Greedily acquire the clipboard. */
- (void) own_clipboard
{
-
+
TRACE ();
-
+
/* We should perhaps have a boundary limit on the number of iterations... */
do
{
- XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard, _selection_window,
- CurrentTime);
+ XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard, _selection_window,
+ CurrentTime);
} while (_selection_window != XGetSelectionOwner (xpbproxy_dpy,
- atoms->clipboard));
+ atoms->clipboard));
}
- (void) init_reply:(XEvent *)reply request:(XSelectionRequestEvent *)e
@@ -581,7 +582,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* the event, according to the ICCCM.
*/
DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
-
+
XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
XFlush (xpbproxy_dpy);
}
@@ -598,67 +599,67 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
XEvent reply;
NSArray *pbtypes;
-
+
[self init_reply:&reply request:e];
-
+
pbtypes = [pb types];
if (pbtypes)
{
- long list[7]; /* Don't forget to increase this if we handle more types! */
+ long list[7]; /* Don't forget to increase this if we handle more types! */
long count = 0;
-
- /*
- * I'm not sure if this is needed, but some toolkits/clients list
- * TARGETS in response to targets.
- */
- list[count] = atoms->targets;
- ++count;
-
- if ([pbtypes containsObject:NSStringPboardType])
- {
- /* We have a string type that we can convert to UTF8, or Latin-1... */
- DebugF ("NSStringPboardType\n");
- list[count] = atoms->utf8_string;
- ++count;
- list[count] = atoms->string;
- ++count;
- list[count] = atoms->compound_text;
- ++count;
- }
-
- /* TODO add the NSPICTPboardType back again, once we have conversion
- * functionality in send_image.
- */
+
+ /*
+ * I'm not sure if this is needed, but some toolkits/clients list
+ * TARGETS in response to targets.
+ */
+ list[count] = atoms->targets;
+ ++count;
+
+ if ([pbtypes containsObject:NSStringPboardType])
+ {
+ /* We have a string type that we can convert to UTF8, or Latin-1... */
+ DebugF ("NSStringPboardType\n");
+ list[count] = atoms->utf8_string;
+ ++count;
+ list[count] = atoms->string;
+ ++count;
+ list[count] = atoms->compound_text;
+ ++count;
+ }
+
+ /* TODO add the NSPICTPboardType back again, once we have conversion
+ * functionality in send_image.
+ */
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
#endif
-
- if ([pbtypes containsObject:NSPICTPboardType]
- || [pbtypes containsObject:NSTIFFPboardType])
- {
- /* We can convert a TIFF to a PNG or JPEG. */
- DebugF ("NSTIFFPboardType\n");
- list[count] = atoms->image_png;
- ++count;
- list[count] = atoms->image_jpeg;
- ++count;
- }
-
+
+ if ([pbtypes containsObject:NSPICTPboardType]
+ || [pbtypes containsObject:NSTIFFPboardType])
+ {
+ /* We can convert a TIFF to a PNG or JPEG. */
+ DebugF ("NSTIFFPboardType\n");
+ list[count] = atoms->image_png;
+ ++count;
+ list[count] = atoms->image_jpeg;
+ ++count;
+ }
+
#ifdef __clang__
#pragma clang diagnostic pop
#endif
-
- if (count)
- {
- /* We have a list of ATOMs to send. */
- XChangeProperty (xpbproxy_dpy, e->requestor, e->property, atoms->atom, 32,
- PropModeReplace, (unsigned char *) list, count);
-
- reply.xselection.property = e->property;
- }
+
+ if (count)
+ {
+ /* We have a list of ATOMs to send. */
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, atoms->atom, 32,
+ PropModeReplace, (unsigned char *) list, count);
+
+ reply.xselection.property = e->property;
+ }
}
-
+
[self send_reply:&reply];
}
@@ -670,66 +671,66 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
NSString *data;
const char *bytes;
NSUInteger length;
-
+
TRACE ();
-
+
[self init_reply:&reply request:e];
-
+
pbtypes = [pb types];
-
+
if (![pbtypes containsObject:NSStringPboardType])
{
- [self send_reply:&reply];
- return;
+ [self send_reply:&reply];
+ return;
}
-
+
#ifdef __LP64__
DebugF ("pbtypes retainCount after containsObject: %lu\n", [pbtypes retainCount]);
#else
DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
#endif
-
+
data = [pb stringForType:NSStringPboardType];
-
+
if (nil == data)
{
- [self send_reply:&reply];
- return;
+ [self send_reply:&reply];
+ return;
}
-
+
if (utf8)
{
- bytes = [data UTF8String];
- /*
- * We don't want the UTF-8 string length here.
- * We want the length in bytes.
- */
- length = strlen (bytes);
-
- if (length < 50) {
- DebugF ("UTF-8: %s\n", bytes);
+ bytes = [data UTF8String];
+ /*
+ * We don't want the UTF-8 string length here.
+ * We want the length in bytes.
+ */
+ length = strlen (bytes);
+
+ if (length < 50) {
+ DebugF ("UTF-8: %s\n", bytes);
#ifdef __LP64__
- DebugF ("UTF-8 length: %lu\n", length);
+ DebugF ("UTF-8 length: %lu\n", length);
#else
- DebugF ("UTF-8 length: %u\n", length);
+ DebugF ("UTF-8 length: %u\n", length);
#endif
- }
+ }
}
else
{
- DebugF ("Latin-1\n");
- bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
- /*WARNING: bytes is not NUL-terminated. */
- length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
+ DebugF ("Latin-1\n");
+ bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
+ /*WARNING: bytes is not NUL-terminated. */
+ length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
}
-
+
DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
- 8, PropModeReplace, (unsigned char *) bytes, length);
+ 8, PropModeReplace, (unsigned char *) bytes, length);
reply.xselection.property = e->property;
-
+
[self send_reply:&reply];
}
@@ -741,45 +742,45 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE ();
[self init_reply:&reply request:e];
-
+
pbtypes = [pb types];
-
+
if ([pbtypes containsObject: NSStringPboardType])
{
- NSString *data = [pb stringForType:NSStringPboardType];
- if (nil != data)
- {
- /*
- * Cast to (void *) to avoid a const warning.
- * AFAIK Xutf8TextListToTextProperty does not modify the input memory.
- */
- void *utf8 = (void *)[data UTF8String];
- char *list[] = { utf8, NULL };
- XTextProperty textprop;
-
- textprop.value = NULL;
-
- if (Success == Xutf8TextListToTextProperty (xpbproxy_dpy, list, 1,
- XCompoundTextStyle,
- &textprop))
- {
-
- if (8 != textprop.format)
- DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
- textprop.format);
-
- XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
- atoms->compound_text, textprop.format,
- PropModeReplace, textprop.value,
- textprop.nitems);
-
- reply.xselection.property = e->property;
- }
-
- if (textprop.value)
- XFree (textprop.value);
-
- }
+ NSString *data = [pb stringForType:NSStringPboardType];
+ if (nil != data)
+ {
+ /*
+ * Cast to (void *) to avoid a const warning.
+ * AFAIK Xutf8TextListToTextProperty does not modify the input memory.
+ */
+ void *utf8 = (void *)[data UTF8String];
+ char *list[] = { utf8, NULL };
+ XTextProperty textprop;
+
+ textprop.value = NULL;
+
+ if (Success == Xutf8TextListToTextProperty (xpbproxy_dpy, list, 1,
+ XCompoundTextStyle,
+ &textprop))
+ {
+
+ if (8 != textprop.format)
+ DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
+ textprop.format);
+
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
+ atoms->compound_text, textprop.format,
+ PropModeReplace, textprop.value,
+ textprop.nitems);
+
+ reply.xselection.property = e->property;
+ }
+
+ if (textprop.value)
+ XFree (textprop.value);
+
+ }
}
[self send_reply:&reply];
@@ -789,14 +790,14 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void) send_multiple:(XSelectionRequestEvent *)e
{
XEvent reply;
-
+
TRACE ();
-
+
[self init_reply:&reply request:e];
-
+
if (None != e->property)
{
-
+
}
[self send_reply:&reply];
@@ -811,33 +812,33 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
NSBitmapImageRep *bmimage = nil;
NSData *encdata = nil;
NSDictionary *dict = nil;
-
+
bmimage = [[NSBitmapImageRep alloc] initWithData:data];
-
+
if (nil == bmimage)
- return nil;
-
+ return nil;
+
dict = [[NSDictionary alloc] init];
encdata = [bmimage representationUsingType:enctype properties:dict];
-
+
if (nil == encdata)
{
- [dict autorelease];
- [bmimage autorelease];
- return nil;
+ [dict autorelease];
+ [bmimage autorelease];
+ return nil;
}
[dict autorelease];
[bmimage autorelease];
-
+
return encdata;
}
/* Return YES when an error has occured when trying to send the PICT. */
/* The caller should send a default reponse with a property of None when an error occurs. */
- (BOOL) send_image_pict_reply:(XSelectionRequestEvent *)e
- pasteboard:(NSPasteboard *)pb
- type:(NSBitmapImageFileType)imagetype
+ pasteboard:(NSPasteboard *)pb
+ type:(NSBitmapImageFileType)imagetype
{
XEvent reply;
NSImage *img = nil;
@@ -846,77 +847,77 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
const void *bytes = NULL;
img = [[NSImage alloc] initWithPasteboard:pb];
-
+
if (nil == img)
{
- return YES;
+ return YES;
}
-
+
data = [img TIFFRepresentation];
-
+
if (nil == data)
{
- [img autorelease];
- ErrorF("unable to convert PICT to TIFF!\n");
- return YES;
+ [img autorelease];
+ ErrorF("unable to convert PICT to TIFF!\n");
+ return YES;
}
-
+
encdata = [self encode_image_data:data type:imagetype];
if(nil == encdata)
{
- [img autorelease];
- return YES;
+ [img autorelease];
+ return YES;
}
-
+
[self init_reply:&reply request:e];
-
+
length = [encdata length];
bytes = [encdata bytes];
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
- 8, PropModeReplace, bytes, length);
+ 8, PropModeReplace, bytes, length);
reply.xselection.property = e->property;
-
+
[self send_reply:&reply];
-
+
[img autorelease];
-
+
return NO; /*no error*/
}
/* Return YES if an error occured. */
/* The caller should send a reply with a property of None when an error occurs. */
- (BOOL) send_image_tiff_reply:(XSelectionRequestEvent *)e
- pasteboard:(NSPasteboard *)pb
- type:(NSBitmapImageFileType)imagetype
+ pasteboard:(NSPasteboard *)pb
+ type:(NSBitmapImageFileType)imagetype
{
XEvent reply;
NSData *data = nil;
NSData *encdata = nil;
NSUInteger length;
const void *bytes = NULL;
-
+
data = [pb dataForType:NSTIFFPboardType];
-
+
if (nil == data)
- return YES;
-
+ return YES;
+
encdata = [self encode_image_data:data type:imagetype];
-
+
if(nil == encdata)
- return YES;
-
+ return YES;
+
[self init_reply:&reply request:e];
-
+
length = [encdata length];
bytes = [encdata bytes];
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
- 8, PropModeReplace, bytes, length);
+ 8, PropModeReplace, bytes, length);
reply.xselection.property = e->property;
[self send_reply:&reply];
-
+
return NO; /*no error*/
}
@@ -924,27 +925,27 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
NSArray *pbtypes = nil;
NSBitmapImageFileType imagetype = NSPNGFileType;
-
+
TRACE ();
-
+
if (e->target == atoms->image_png)
- imagetype = NSPNGFileType;
+ imagetype = NSPNGFileType;
else if (e->target == atoms->image_jpeg)
- imagetype = NSJPEGFileType;
+ imagetype = NSJPEGFileType;
else
{
- ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
+ ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
}
-
+
pbtypes = [pb types];
-
+
if (pbtypes)
{
- if ([pbtypes containsObject:NSTIFFPboardType])
- {
- if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype])
- return;
- }
+ if ([pbtypes containsObject:NSTIFFPboardType])
+ {
+ if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype])
+ return;
+ }
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
@@ -953,23 +954,23 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
#ifdef __clang__
#pragma clang diagnostic pop
#endif
- {
- if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype])
- return;
-
- /* Fall through intentionally to the send_none: */
- }
+ {
+ if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype])
+ return;
+
+ /* Fall through intentionally to the send_none: */
+ }
}
-
+
[self send_none:e];
}
- (void)send_none:(XSelectionRequestEvent *)e
{
XEvent reply;
-
+
TRACE ();
-
+
[self init_reply:&reply request:e];
[self send_reply:&reply];
}
@@ -979,9 +980,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void)request_event:(XSelectionRequestEvent *)e
{
NSPasteboard *pb;
-
+
TRACE ();
-
+
/* TODO We should also keep track of the time of the selection, and
* according to the ICCCM "refuse the request" if the event timestamp
* is before we owned it.
@@ -991,57 +992,57 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* may be set to CurrentTime or a time, so that makes it a bit different.
* Perhaps we should just punt and ignore races.
*/
-
+
/*TODO we need a COMPOUND_TEXT test app*/
/*TODO we need a MULTIPLE test app*/
-
+
pb = [NSPasteboard generalPasteboard];
if (nil == pb)
{
- [self send_none:e];
- return;
+ [self send_none:e];
+ return;
}
-
+
if (None != e->target)
- DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
-
+ DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
+
if (e->target == atoms->targets)
{
- /* The paste requestor wants to know what TARGETS we support. */
- [self send_targets:e pasteboard:pb];
+ /* The paste requestor wants to know what TARGETS we support. */
+ [self send_targets:e pasteboard:pb];
}
else if (e->target == atoms->multiple)
{
- /*
- * This isn't finished, and may never be, unless I can find
- * a good test app.
- */
- [self send_multiple:e];
+ /*
+ * This isn't finished, and may never be, unless I can find
+ * a good test app.
+ */
+ [self send_multiple:e];
}
else if (e->target == atoms->utf8_string)
{
- [self send_string:e utf8:YES pasteboard:pb];
+ [self send_string:e utf8:YES pasteboard:pb];
}
else if (e->target == atoms->string)
{
- [self send_string:e utf8:NO pasteboard:pb];
+ [self send_string:e utf8:NO pasteboard:pb];
}
else if (e->target == atoms->compound_text)
{
- [self send_compound_text:e pasteboard:pb];
+ [self send_compound_text:e pasteboard:pb];
}
else if (e->target == atoms->multiple)
{
- [self send_multiple:e];
+ [self send_multiple:e];
}
else if (e->target == atoms->image_png || e->target == atoms->image_jpeg)
{
- [self send_image:e pasteboard:pb];
+ [self send_image:e pasteboard:pb];
}
else
{
- [self send_none:e];
+ [self send_none:e];
}
}
@@ -1052,58 +1053,58 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
struct propdata pdata;
TRACE ();
-
+
[self release_pending];
-
+
if (None == e->property) {
- DebugF ("e->property is None.\n");
- [self copy_completed:e->selection];
- /* Nothing is selected. */
- return;
+ DebugF ("e->property is None.\n");
+ [self copy_completed:e->selection];
+ /* Nothing is selected. */
+ return;
}
-
+
#if 0
ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
#endif
-
+
if ([self is_incr_type:e])
{
- /*
- * This is an INCR-style transfer, which means that we
- * will get the data after a series of PropertyNotify events.
- */
- DebugF ("is INCR\n");
-
- if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
- {
- /*
- * An error occured, so we should invoke the copy_completed:, but
- * not handle_selection:type:propdata:
- */
- [self copy_completed:e->selection];
- return;
- }
-
- free_propdata (&pdata);
-
+ /*
+ * This is an INCR-style transfer, which means that we
+ * will get the data after a series of PropertyNotify events.
+ */
+ DebugF ("is INCR\n");
+
+ if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
+ {
+ /*
+ * An error occured, so we should invoke the copy_completed:, but
+ * not handle_selection:type:propdata:
+ */
+ [self copy_completed:e->selection];
+ return;
+ }
+
+ free_propdata (&pdata);
+
pending.requestor = e->requestor;
- pending.selection = e->selection;
-
- DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
+ pending.selection = e->selection;
+
+ DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
}
else
{
- if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
- {
- [self copy_completed:e->selection];
- return;
- }
-
- /* We have the complete selection data.*/
- [self handle_selection:e->selection type:type propdata:&pdata];
-
- DebugF ("handled selection with the first notify_event\n");
+ if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
+ {
+ [self copy_completed:e->selection];
+ return;
+ }
+
+ /* We have the complete selection data.*/
+ [self handle_selection:e->selection type:type propdata:&pdata];
+
+ DebugF ("handled selection with the first notify_event\n");
}
}
@@ -1113,50 +1114,50 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
struct propdata pdata;
Atom type;
-
+
TRACE ();
if (None != e->atom)
{
#ifdef DEBUG
- char *name = XGetAtomName (xpbproxy_dpy, e->atom);
-
- if (name)
- {
- DebugF ("e->atom %s\n", name);
- XFree(name);
- }
+ char *name = XGetAtomName (xpbproxy_dpy, e->atom);
+
+ if (name)
+ {
+ DebugF ("e->atom %s\n", name);
+ XFree(name);
+ }
#endif
}
-
+
if (None != pending.requestor && PropertyNewValue == e->state)
{
- DebugF ("pending.requestor 0x%lx\n", pending.requestor);
-
- if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
+ DebugF ("pending.requestor 0x%lx\n", pending.requestor);
+
+ if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
{
- [self copy_completed:pending.selection];
- [self release_pending];
- return;
- }
-
- if (0 == pdata.length)
- {
- /*
- * We completed the transfer.
- * handle_selection will call copy_completed: for us.
- */
- [self handle_selection:pending.selection type:type propdata:&pending.propdata];
- free_propdata(&pdata);
- pending.propdata = null_propdata;
- pending.requestor = None;
- pending.selection = None;
- }
- else
- {
- [self append_to_pending:&pdata requestor:e->window];
- free_propdata (&pdata);
- }
+ [self copy_completed:pending.selection];
+ [self release_pending];
+ return;
+ }
+
+ if (0 == pdata.length)
+ {
+ /*
+ * We completed the transfer.
+ * handle_selection will call copy_completed: for us.
+ */
+ [self handle_selection:pending.selection type:type propdata:&pending.propdata];
+ free_propdata(&pdata);
+ pending.propdata = null_propdata;
+ pending.requestor = None;
+ pending.selection = None;
+ }
+ else
+ {
+ [self append_to_pending:&pdata requestor:e->window];
+ free_propdata (&pdata);
+ }
}
}
@@ -1169,7 +1170,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if(e->selection == atoms->primary && pbproxy_prefs.primary_on_grab)
[self x_copy:e->timestamp];
break;
-
+
case XFixesSelectionWindowDestroyNotify:
case XFixesSelectionClientCloseNotify:
default:
@@ -1183,32 +1184,32 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* Find a type we can handle and prefer from the list of ATOMs. */
Atom preferred;
char *name;
-
+
TRACE ();
-
+
preferred = [self find_preferred:pdata];
if (None == preferred)
{
- /*
- * This isn't required by the ICCCM, but some apps apparently
- * don't respond to TARGETS properly.
- */
- preferred = atoms->string;
+ /*
+ * This isn't required by the ICCCM, but some apps apparently
+ * don't respond to TARGETS properly.
+ */
+ preferred = atoms->string;
}
-
+
(void)name; /* Avoid a warning with non-debug compiles. */
#ifdef DEBUG
name = XGetAtomName (xpbproxy_dpy, preferred);
-
+
if (name)
{
- DebugF ("requesting %s\n", name);
+ DebugF ("requesting %s\n", name);
}
#endif
request_atom = preferred;
XConvertSelection (xpbproxy_dpy, selection, preferred, selection,
- _selection_window, CurrentTime);
+ _selection_window, CurrentTime);
}
/* This handles the image type of selection (typically in CLIPBOARD). */
@@ -1219,54 +1220,54 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
NSUInteger length;
NSData *data, *tiff;
NSBitmapImageRep *bmimage;
-
+
TRACE ();
-
+
length = pdata->length;
data = [[NSData alloc] initWithBytes:pdata->data length:length];
-
+
if (nil == data)
{
- DebugF ("unable to create NSData object!\n");
- return;
+ DebugF ("unable to create NSData object!\n");
+ return;
}
-
+
#ifdef __LP64__
DebugF ("data retainCount before NSBitmapImageRep initWithData: %lu\n",
- [data retainCount]);
+ [data retainCount]);
#else
DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n",
- [data retainCount]);
+ [data retainCount]);
#endif
-
+
bmimage = [[NSBitmapImageRep alloc] initWithData:data];
-
+
if (nil == bmimage)
{
- [data autorelease];
- DebugF ("unable to create NSBitmapImageRep!\n");
- return;
+ [data autorelease];
+ DebugF ("unable to create NSBitmapImageRep!\n");
+ return;
}
-
+
#ifdef __LP64__
DebugF ("data retainCount after NSBitmapImageRep initWithData: %lu\n",
- [data retainCount]);
+ [data retainCount]);
#else
DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n",
- [data retainCount]);
+ [data retainCount]);
#endif
-
+
@try
{
- tiff = [bmimage TIFFRepresentation];
+ tiff = [bmimage TIFFRepresentation];
}
-
+
@catch (NSException *e)
{
- DebugF ("NSTIFFException!\n");
- [data autorelease];
- [bmimage autorelease];
- return;
+ DebugF ("NSTIFFException!\n");
+ [data autorelease];
+ [bmimage autorelease];
+ return;
}
#ifdef __LP64__
@@ -1274,30 +1275,30 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
#else
DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
#endif
-
+
pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
-
+
if (nil == pbtypes)
{
- [data autorelease];
- [bmimage autorelease];
- return;
+ [data autorelease];
+ [bmimage autorelease];
+ return;
}
-
+
[pb declareTypes:pbtypes owner:nil];
if (YES != [pb setData:tiff forType:NSTIFFPboardType])
{
- DebugF ("writing pasteboard data failed!\n");
+ DebugF ("writing pasteboard data failed!\n");
}
-
+
[data autorelease];
-
+
#ifdef __LP64__
DebugF ("bmimage retainCount before release %lu\n", [bmimage retainCount]);
#else
DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]);
#endif
-
+
[bmimage autorelease];
}
@@ -1306,26 +1307,26 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
NSString *string;
NSArray *pbtypes;
-
+
TRACE ();
-
+
string = [[NSString alloc] initWithBytes:pdata->data length:pdata->length encoding:NSUTF8StringEncoding];
-
+
if (nil == string)
- return;
-
+ return;
+
pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
-
+
if (nil == pbtypes)
{
- [string autorelease];
- return;
+ [string autorelease];
+ return;
}
-
+
[pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) {
- ErrorF("pasteboard setString:forType: failed!\n");
+ ErrorF("pasteboard setString:forType: failed!\n");
}
[string autorelease];
DebugF ("done handling utf8 string\n");
@@ -1336,25 +1337,25 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
NSString *string;
NSArray *pbtypes;
-
+
TRACE ();
-
+
string = [[NSString alloc] initWithBytes:pdata->data length:pdata->length encoding:NSISOLatin1StringEncoding];
if (nil == string)
- return;
-
+ return;
+
pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
-
+
if (nil == pbtypes)
{
- [string autorelease];
- return;
+ [string autorelease];
+ return;
}
-
+
[pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) {
- ErrorF("pasteboard setString:forType failed in handle_string!\n");
+ ErrorF("pasteboard setString:forType failed in handle_string!\n");
}
[string autorelease];
}
@@ -1364,48 +1365,48 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata
{
NSPasteboard *pb;
-
+
TRACE ();
-
+
pb = [NSPasteboard generalPasteboard];
-
+
if (nil == pb)
{
- [self copy_completed:selection];
- free_propdata (pdata);
- return;
+ [self copy_completed:selection];
+ free_propdata (pdata);
+ return;
}
-
+
/*
* Some apps it seems set the type to TARGETS instead of ATOM, such as Eterm.
* These aren't ICCCM compliant apps, but we need these to work...
*/
if (request_atom == atoms->targets
- && (type == atoms->atom || type == atoms->targets))
+ && (type == atoms->atom || type == atoms->targets))
{
- [self handle_targets:selection propdata:pdata];
- free_propdata(pdata);
- return;
+ [self handle_targets:selection propdata:pdata];
+ free_propdata(pdata);
+ return;
}
else if (type == atoms->image_png)
{
- [self handle_image:pdata pasteboard:pb];
+ [self handle_image:pdata pasteboard:pb];
}
else if (type == atoms->image_jpeg)
{
- [self handle_image:pdata pasteboard:pb];
+ [self handle_image:pdata pasteboard:pb];
}
else if (type == atoms->utf8_string)
{
- [self handle_utf8_string:pdata pasteboard:pb];
+ [self handle_utf8_string:pdata pasteboard:pb];
}
else if (type == atoms->string)
{
- [self handle_string:pdata pasteboard:pb];
+ [self handle_string:pdata pasteboard:pb];
}
-
+
free_propdata(pdata);
-
+
[self copy_completed:selection];
}
@@ -1414,42 +1415,42 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
TRACE ();
char *name;
-
+
(void)name; /* Avoid warning with non-debug compiles. */
#ifdef DEBUG
name = XGetAtomName (xpbproxy_dpy, selection);
if (name)
{
- DebugF ("copy_completed: %s\n", name);
- XFree (name);
+ DebugF ("copy_completed: %s\n", name);
+ XFree (name);
}
#endif
-
+
if (selection == atoms->primary && pending_copy > 0)
{
- --pending_copy;
- if (pending_copy > 0)
- {
- /* Copy PRIMARY again. */
- [self x_copy_request_targets];
- return;
- }
+ --pending_copy;
+ if (pending_copy > 0)
+ {
+ /* Copy PRIMARY again. */
+ [self x_copy_request_targets];
+ return;
+ }
}
else if (selection == atoms->clipboard && pending_clipboard > 0)
{
- --pending_clipboard;
- if (pending_clipboard > 0)
- {
- /* Copy CLIPBOARD. */
- [self claim_clipboard];
- return;
- }
- else
- {
- /* We got the final data. Now set pbproxy as the owner. */
- [self own_clipboard];
- return;
- }
+ --pending_clipboard;
+ if (pending_clipboard > 0)
+ {
+ /* Copy CLIPBOARD. */
+ [self claim_clipboard];
+ return;
+ }
+ else
+ {
+ /* We got the final data. Now set pbproxy as the owner. */
+ [self own_clipboard];
+ return;
+ }
}
/*
@@ -1458,7 +1459,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
*/
if (pending_clipboard > 0)
{
- [self claim_clipboard];
+ [self claim_clipboard];
}
}
@@ -1474,20 +1475,20 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pbproxy_prefs.active = YES;
else
#endif
- pbproxy_prefs.active = prefs_get_bool(CFSTR("sync_pasteboard"), pbproxy_prefs.active);
+ pbproxy_prefs.active = prefs_get_bool(CFSTR("sync_pasteboard"), pbproxy_prefs.active);
pbproxy_prefs.primary_on_grab = prefs_get_bool(CFSTR("sync_primary_on_select"), pbproxy_prefs.primary_on_grab);
pbproxy_prefs.clipboard_to_pasteboard = prefs_get_bool(CFSTR("sync_clipboard_to_pasteboard"), pbproxy_prefs.clipboard_to_pasteboard);
pbproxy_prefs.pasteboard_to_primary = prefs_get_bool(CFSTR("sync_pasteboard_to_primary"), pbproxy_prefs.pasteboard_to_primary);
pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
-
+
/* This is used for debugging. */
//dump_prefs();
-
+
if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) {
ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
pbproxy_prefs.primary_on_grab = NO;
}
-
+
/* Claim or release the CLIPBOARD_MANAGER atom */
if(![self set_clipboard_manager_status:(pbproxy_prefs.active && pbproxy_prefs.clipboard_to_pasteboard)])
pbproxy_prefs.clipboard_to_pasteboard = NO;
@@ -1516,7 +1517,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- (void) pasteboardChangedOwner:(NSPasteboard *)pb
{
TRACE ();
-
+
/* Right now we don't care with this. */
}
@@ -1525,11 +1526,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
- init
{
unsigned long pixel;
-
+
self = [super init];
if (self == nil)
- return nil;
-
+ return nil;
+
atoms->primary = XInternAtom (xpbproxy_dpy, "PRIMARY", False);
atoms->clipboard = XInternAtom (xpbproxy_dpy, "CLIPBOARD", False);
atoms->text = XInternAtom (xpbproxy_dpy, "TEXT", False);
@@ -1545,27 +1546,27 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
atoms->clipboard_manager = XInternAtom (xpbproxy_dpy, "CLIPBOARD_MANAGER", False);
atoms->compound_text = XInternAtom (xpbproxy_dpy, "COMPOUND_TEXT", False);
atoms->atom_pair = XInternAtom (xpbproxy_dpy, "ATOM_PAIR", False);
-
+
pixel = BlackPixel (xpbproxy_dpy, DefaultScreen (xpbproxy_dpy));
_selection_window = XCreateSimpleWindow (xpbproxy_dpy, DefaultRootWindow (xpbproxy_dpy),
- 0, 0, 1, 1, 0, pixel, pixel);
-
+ 0, 0, 1, 1, 0, pixel, pixel);
+
/* This is used to get PropertyNotify events when doing INCR transfers. */
XSelectInput (xpbproxy_dpy, _selection_window, PropertyChangeMask);
-
+
request_atom = None;
-
+
init_propdata (&pending.propdata);
pending.requestor = None;
pending.selection = None;
-
+
pending_copy = 0;
pending_clipboard = 0;
-
+
if(xpbproxy_have_xfixes)
XFixesSelectSelectionInput(xpbproxy_dpy, _selection_window, atoms->primary,
XFixesSetSelectionOwnerNotifyMask);
-
+
[self reload_preferences];
return self;
@@ -1575,12 +1576,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
if (None != _selection_window)
{
- XDestroyWindow (xpbproxy_dpy, _selection_window);
- _selection_window = None;
+ XDestroyWindow (xpbproxy_dpy, _selection_window);
+ _selection_window = None;
}
-
+
free_propdata (&pending.propdata);
-
+
[super dealloc];
}
diff --git a/hw/xquartz/pseudoramiX.c b/hw/xquartz/pseudoramiX.c
index 5a5b9c2e7..30cf8c68d 100644
--- a/hw/xquartz/pseudoramiX.c
+++ b/hw/xquartz/pseudoramiX.c
@@ -9,29 +9,29 @@
* following copyright notice:
*/
/*****************************************************************
-Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of Digital Equipment Corporation
-shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital
-Equipment Corporation.
-******************************************************************/
+ Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software.
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+ BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name of Digital Equipment Corporation
+ shall not be used in advertising or otherwise to promote the sale, use or other
+ dealings in this Software without prior written authorization from Digital
+ Equipment Corporation.
+ ******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
@@ -89,18 +89,18 @@ void
PseudoramiXAddScreen(int x, int y, int w, int h)
{
PseudoramiXScreenRec *s;
-
+
if (noPseudoramiXExtension) return;
-
+
if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
pseudoramiXScreens = realloc(pseudoramiXScreens,
- pseudoramiXScreensAllocated *
- sizeof(PseudoramiXScreenRec));
+ pseudoramiXScreensAllocated *
+ sizeof(PseudoramiXScreenRec));
}
-
+
DEBUG_LOG("x: %d, y: %d, w: %d, h: %d\n", x, y, w, h);
-
+
s = &pseudoramiXScreens[pseudoramiXNumScreens++];
s->x = x;
s->y = y;
@@ -115,13 +115,13 @@ void PseudoramiXExtensionInit(int argc, char *argv[])
{
Bool success = FALSE;
ExtensionEntry *extEntry;
-
+
if (noPseudoramiXExtension) return;
-
+
TRACE();
-
+
/* Even with only one screen we need to enable PseudoramiX to allow
- dynamic screen configuration changes. */
+ dynamic screen configuration changes. */
#if 0
if (pseudoramiXNumScreens == 1) {
// Only one screen - disable Xinerama extension.
@@ -129,7 +129,7 @@ void PseudoramiXExtensionInit(int argc, char *argv[])
return;
}
#endif
-
+
if (pseudoramiXGeneration != serverGeneration) {
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcPseudoramiXDispatch,
@@ -143,7 +143,7 @@ void PseudoramiXExtensionInit(int argc, char *argv[])
success = TRUE;
}
}
-
+
if (!success) {
ErrorF("%s Extension (PseudoramiX) failed to initialize\n",
PANORAMIX_PROTOCOL_NAME);
@@ -155,7 +155,7 @@ void PseudoramiXExtensionInit(int argc, char *argv[])
void PseudoramiXResetScreens(void)
{
TRACE();
-
+
pseudoramiXNumScreens = 0;
}
@@ -163,7 +163,7 @@ void PseudoramiXResetScreens(void)
static void PseudoramiXResetProc(ExtensionEntry *extEntry)
{
TRACE();
-
+
PseudoramiXResetScreens();
}
@@ -172,7 +172,7 @@ static void PseudoramiXResetProc(ExtensionEntry *extEntry)
static int ProcPseudoramiXQueryVersion(ClientPtr client)
{
TRACE();
-
+
return ProcPanoramiXQueryVersion(client);
}
@@ -184,14 +184,14 @@ static int ProcPseudoramiXGetState(ClientPtr client)
WindowPtr pWin;
xPanoramiXGetStateReply rep;
register int rc;
-
+
TRACE();
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
- return rc;
-
+ return rc;
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -213,14 +213,14 @@ static int ProcPseudoramiXGetScreenCount(ClientPtr client)
WindowPtr pWin;
xPanoramiXGetScreenCountReply rep;
register int rc;
-
+
TRACE();
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
- return rc;
-
+ return rc;
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -242,14 +242,14 @@ static int ProcPseudoramiXGetScreenSize(ClientPtr client)
WindowPtr pWin;
xPanoramiXGetScreenSizeReply rep;
register int n, rc;
-
+
TRACE();
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
- return rc;
-
+ return rc;
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -274,19 +274,19 @@ static int ProcPseudoramiXIsActive(ClientPtr client)
{
/* REQUEST(xXineramaIsActiveReq); */
xXineramaIsActiveReply rep;
-
+
TRACE();
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
-
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.state = !noPseudoramiXExtension;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.state);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.state);
}
WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep);
return Success;
@@ -298,42 +298,42 @@ static int ProcPseudoramiXQueryScreens(ClientPtr client)
{
/* REQUEST(xXineramaQueryScreensReq); */
xXineramaQueryScreensReply rep;
-
+
DEBUG_LOG("noPseudoramiXExtension=%d, pseudoramiXNumScreens=%d\n", noPseudoramiXExtension, pseudoramiXNumScreens);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
-
+
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.number = noPseudoramiXExtension ? 0 : pseudoramiXNumScreens;
rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.number);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.number);
}
WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep);
-
+
if (!noPseudoramiXExtension) {
- xXineramaScreenInfo scratch;
- int i;
-
- for(i = 0; i < pseudoramiXNumScreens; i++) {
- scratch.x_org = pseudoramiXScreens[i].x;
- scratch.y_org = pseudoramiXScreens[i].y;
- scratch.width = pseudoramiXScreens[i].w;
- scratch.height = pseudoramiXScreens[i].h;
-
- if(client->swapped) {
- swaps(&scratch.x_org);
- swaps(&scratch.y_org);
- swaps(&scratch.width);
- swaps(&scratch.height);
- }
- WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
- }
+ xXineramaScreenInfo scratch;
+ int i;
+
+ for(i = 0; i < pseudoramiXNumScreens; i++) {
+ scratch.x_org = pseudoramiXScreens[i].x;
+ scratch.y_org = pseudoramiXScreens[i].y;
+ scratch.width = pseudoramiXScreens[i].w;
+ scratch.height = pseudoramiXScreens[i].h;
+
+ if(client->swapped) {
+ swaps(&scratch.x_org);
+ swaps(&scratch.y_org);
+ swaps(&scratch.width);
+ swaps(&scratch.height);
+ }
+ WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
+ }
}
-
+
return Success;
}
@@ -344,18 +344,18 @@ static int ProcPseudoramiXDispatch (ClientPtr client)
TRACE();
switch (stuff->data)
{
- case X_PanoramiXQueryVersion:
- return ProcPseudoramiXQueryVersion(client);
- case X_PanoramiXGetState:
- return ProcPseudoramiXGetState(client);
- case X_PanoramiXGetScreenCount:
- return ProcPseudoramiXGetScreenCount(client);
- case X_PanoramiXGetScreenSize:
- return ProcPseudoramiXGetScreenSize(client);
- case X_XineramaIsActive:
- return ProcPseudoramiXIsActive(client);
- case X_XineramaQueryScreens:
- return ProcPseudoramiXQueryScreens(client);
+ case X_PanoramiXQueryVersion:
+ return ProcPseudoramiXQueryVersion(client);
+ case X_PanoramiXGetState:
+ return ProcPseudoramiXGetState(client);
+ case X_PanoramiXGetScreenCount:
+ return ProcPseudoramiXGetScreenCount(client);
+ case X_PanoramiXGetScreenSize:
+ return ProcPseudoramiXGetScreenSize(client);
+ case X_XineramaIsActive:
+ return ProcPseudoramiXIsActive(client);
+ case X_XineramaQueryScreens:
+ return ProcPseudoramiXQueryScreens(client);
}
return BadRequest;
}
@@ -366,9 +366,9 @@ static int
SProcPseudoramiXQueryVersion (ClientPtr client)
{
REQUEST(xPanoramiXQueryVersionReq);
-
+
TRACE();
-
+
swaps(&stuff->length);
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
return ProcPseudoramiXQueryVersion(client);
@@ -378,9 +378,9 @@ static int
SProcPseudoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
-
+
TRACE();
-
+
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
return ProcPseudoramiXGetState(client);
@@ -390,9 +390,9 @@ static int
SProcPseudoramiXGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
-
+
TRACE();
-
+
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
return ProcPseudoramiXGetScreenCount(client);
@@ -402,9 +402,9 @@ static int
SProcPseudoramiXGetScreenSize(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenSizeReq);
-
+
TRACE();
-
+
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
return ProcPseudoramiXGetScreenSize(client);
@@ -415,9 +415,9 @@ static int
SProcPseudoramiXIsActive(ClientPtr client)
{
REQUEST(xXineramaIsActiveReq);
-
+
TRACE();
-
+
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
return ProcPseudoramiXIsActive(client);
@@ -428,9 +428,9 @@ static int
SProcPseudoramiXQueryScreens(ClientPtr client)
{
REQUEST(xXineramaQueryScreensReq);
-
+
TRACE();
-
+
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
return ProcPseudoramiXQueryScreens(client);
@@ -440,23 +440,23 @@ SProcPseudoramiXQueryScreens(ClientPtr client)
static int
SProcPseudoramiXDispatch (ClientPtr client)
{ REQUEST(xReq);
-
+
TRACE();
-
+
switch (stuff->data)
{
- case X_PanoramiXQueryVersion:
- return SProcPseudoramiXQueryVersion(client);
- case X_PanoramiXGetState:
- return SProcPseudoramiXGetState(client);
- case X_PanoramiXGetScreenCount:
- return SProcPseudoramiXGetScreenCount(client);
- case X_PanoramiXGetScreenSize:
- return SProcPseudoramiXGetScreenSize(client);
- case X_XineramaIsActive:
- return SProcPseudoramiXIsActive(client);
- case X_XineramaQueryScreens:
- return SProcPseudoramiXQueryScreens(client);
+ case X_PanoramiXQueryVersion:
+ return SProcPseudoramiXQueryVersion(client);
+ case X_PanoramiXGetState:
+ return SProcPseudoramiXGetState(client);
+ case X_PanoramiXGetScreenCount:
+ return SProcPseudoramiXGetScreenCount(client);
+ case X_PanoramiXGetScreenSize:
+ return SProcPseudoramiXGetScreenSize(client);
+ case X_XineramaIsActive:
+ return SProcPseudoramiXIsActive(client);
+ case X_XineramaQueryScreens:
+ return SProcPseudoramiXQueryScreens(client);
}
return BadRequest;
}
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index c395b42e6..b2a08462c 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -2,6 +2,7 @@
*
* Quartz-specific support for the Darwin X Server
*
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
* Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons.
* All Rights Reserved.
*
@@ -85,27 +86,27 @@ Bool XQuartzFullscreenMenu = FALSE;
int32_t XQuartzShieldingWindowLevel = 0;
/*
-===========================================================================
-
+ ===========================================================================
+
Screen functions
-
-===========================================================================
-*/
+
+ ===========================================================================
+ */
/*
* QuartzAddScreen
* Do mode dependent initialization of each screen for Quartz.
*/
Bool QuartzAddScreen(
- int index,
- ScreenPtr pScreen)
+ int index,
+ ScreenPtr pScreen)
{
// allocate space for private per screen Quartz specific storage
QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1);
-
+
// QUARTZ_PRIV(pScreen) = displayInfo;
dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo);
-
+
// do Quartz mode specific initialization
return quartzProcs->AddScreen(index, pScreen);
}
@@ -116,24 +117,24 @@ Bool QuartzAddScreen(
* Finalize mode specific setup of each screen.
*/
Bool QuartzSetupScreen(
- int index,
- ScreenPtr pScreen)
+ int index,
+ ScreenPtr pScreen)
{
// do Quartz mode specific setup
if (! quartzProcs->SetupScreen(index, pScreen))
return FALSE;
-
+
// setup cursor support
if (! quartzProcs->InitCursor(pScreen))
return FALSE;
-
+
#if defined(RANDR)
if(!QuartzRandRInit(pScreen)) {
DEBUG_LOG("Failed to init RandR extension.\n");
return FALSE;
}
#endif
-
+
return TRUE;
}
@@ -143,8 +144,8 @@ Bool QuartzSetupScreen(
* Quartz display initialization.
*/
void QuartzInitOutput(
- int argc,
- char **argv )
+ int argc,
+ char **argv )
{
/* For XQuartz, we want to just use the default signal handler to work better with CrashTracer */
signal(SIGSEGV, SIG_DFL);
@@ -165,17 +166,17 @@ void QuartzInitOutput(
#ifdef SIGXFSZ
signal(SIGXFSZ, SIG_DFL);
#endif
-
+
if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
QuartzWakeupHandler,
NULL))
{
FatalError("Could not register block and wakeup handlers.");
}
-
+
if (!dixRegisterPrivateKey(&quartzScreenKeyRec, PRIVATE_SCREEN, 0))
- FatalError("Failed to alloc quartz screen private.\n");
-
+ FatalError("Failed to alloc quartz screen private.\n");
+
// Do display mode specific initialization
quartzProcs->DisplayInit();
}
@@ -186,8 +187,8 @@ void QuartzInitOutput(
* Inform the main thread the X server is ready to handle events.
*/
void QuartzInitInput(
- int argc,
- char **argv )
+ int argc,
+ char **argv )
{
X11ApplicationSetCanQuit(0);
X11ApplicationServerReady();
@@ -238,7 +239,7 @@ void QuartzUpdateScreens(void) {
pRoot = pScreen->root;
AppleWMSetScreenOrigin(pRoot);
pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
-
+
/* <rdar://problem/7770779> pointer events are clipped to old display region after display reconfiguration
* http://xquartz.macosforge.org/trac/ticket/346
*/
@@ -249,9 +250,9 @@ void QuartzUpdateScreens(void) {
pScreen->ConstrainCursor(inputInfo.pointer, pScreen, &bounds);
inputInfo.pointer->spriteInfo->sprite->physLimits = bounds;
inputInfo.pointer->spriteInfo->sprite->hotLimits = bounds;
-
+
DEBUG_LOG("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY, x, y, pScreen->x, pScreen->y);
-
+
/* Send an event for the root reconfigure */
e.u.u.type = ConfigureNotify;
e.u.configureNotify.window = pRoot->drawable.id;
@@ -263,12 +264,12 @@ void QuartzUpdateScreens(void) {
e.u.configureNotify.borderWidth = wBorderWidth(pRoot);
e.u.configureNotify.override = pRoot->overrideRedirect;
DeliverEvents(pRoot, &e, 1, NullWindow);
-
+
quartzProcs->UpdateScreen(pScreen);
-
+
/* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */
miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
-
+
/* Tell RandR about the new size, so new connections get the correct info */
RRScreenSizeNotify(pScreen);
}
@@ -281,13 +282,13 @@ static void QuartzScreenSaver(int state) {
static CFRunLoopTimerRef pokeActivityTimer = NULL;
static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL };
static OSSpinLock pokeActivitySpinLock = OS_SPINLOCK_INIT;
-
+
OSSpinLockLock(&pokeActivitySpinLock);
-
+
if(state) {
if(pokeActivityTimer == NULL)
goto QuartzScreenSaverEnd;
-
+
CFRunLoopTimerInvalidate(pokeActivityTimer);
CFRelease(pokeActivityTimer);
pokeActivityTimer = NULL;
@@ -300,7 +301,7 @@ static void QuartzScreenSaver(int state) {
ErrorF("Unable to create pokeActivityTimer.\n");
goto QuartzScreenSaverEnd;
}
-
+
CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
}
QuartzScreenSaverEnd:
@@ -340,7 +341,7 @@ void QuartzShowFullscreen(int state) {
//RootlessUpdateScreenPixmap(pScreen);
}
}
-
+
/* Somehow the menubar manages to interfere with our event stream
* in fullscreen mode, even though it's not visible.
*/
@@ -362,22 +363,22 @@ void QuartzSetRootless(Bool state) {
QuartzShowFullscreen(FALSE);
XQuartzIsRootless = state;
-
+
xp_disable_update();
-
+
/* When in rootless, the menubar is not part of the screen, so we need to update our screens on toggle */
QuartzUpdateScreens();
-
+
if(XQuartzIsRootless) {
RootlessShowAllWindows();
} else {
RootlessHideAllWindows();
}
-
+
X11ApplicationShowHideMenubar(TRUE);
-
+
xp_reenable_update();
-
+
xp_disable_hot_keys(FALSE);
}
@@ -389,7 +390,7 @@ void QuartzSetRootless(Bool state) {
*/
void QuartzShow(void) {
int i;
-
+
if (XQuartzServerVisible)
return;
@@ -414,7 +415,7 @@ void QuartzShow(void) {
void QuartzHide(void)
{
int i;
-
+
if (XQuartzServerVisible) {
for (i = 0; i < screenInfo.numScreens; i++) {
if (screenInfo.screens[i]) {
@@ -422,7 +423,7 @@ void QuartzHide(void)
}
}
}
-
+
if(!XQuartzIsRootless)
QuartzShowFullscreen(FALSE);
XQuartzServerVisible = FALSE;
@@ -434,13 +435,13 @@ void QuartzHide(void)
* Enable or disable rendering to the X screen.
*/
void QuartzSetRootClip(
- BOOL enable)
+ BOOL enable)
{
int i;
-
+
if (!XQuartzServerVisible)
return;
-
+
for (i = 0; i < screenInfo.numScreens; i++) {
if (screenInfo.screens[i]) {
SetRootClip(screenInfo.screens[i], enable);
@@ -465,23 +466,23 @@ void QuartzSpaceChanged(uint32_t space_id) {
void QuartzCopyDisplayIDs(ScreenPtr pScreen,
int displayCount, CGDirectDisplayID *displayIDs) {
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
+
free(pQuartzScreen->displayIDs);
if(displayCount) {
size_t size = displayCount * sizeof(CGDirectDisplayID);
pQuartzScreen->displayIDs = malloc(size);
memcpy(pQuartzScreen->displayIDs, displayIDs, size);
} else {
- pQuartzScreen->displayIDs = NULL;
+ pQuartzScreen->displayIDs = NULL;
}
pQuartzScreen->displayCount = displayCount;
}
void NSBeep(void);
void DDXRingBell(
- int volume, // volume is % of max
- int pitch, // pitch is Hz
- int duration) // duration is milliseconds
+ int volume, // volume is % of max
+ int pitch, // pitch is Hz
+ int duration) // duration is milliseconds
{
if (volume)
NSBeep();
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
index 0a9c47a6b..ee5fa7d76 100644
--- a/hw/xquartz/quartz.h
+++ b/hw/xquartz/quartz.h
@@ -4,6 +4,7 @@
* External interface of the Quartz display modes seen by the generic, mode
* independent parts of the Darwin X server.
*
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
* Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons.
* All Rights Reserved.
*
diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m
index 54c900dfa..64ca79ca1 100644
--- a/hw/xquartz/quartzCocoa.m
+++ b/hw/xquartz/quartzCocoa.m
@@ -48,12 +48,12 @@
* Clean out any autoreleased objects.
*/
void QuartzBlockHandler(
- pointer blockData,
- OSTimePtr pTimeout,
- pointer pReadmask)
+ pointer blockData,
+ OSTimePtr pTimeout,
+ pointer pReadmask)
{
static NSAutoreleasePool *aPool = nil;
-
+
[aPool release];
aPool = [[NSAutoreleasePool alloc] init];
}
@@ -63,9 +63,9 @@ void QuartzBlockHandler(
* QuartzWakeupHandler
*/
void QuartzWakeupHandler(
- pointer blockData,
- int result,
- pointer pReadmask)
+ pointer blockData,
+ int result,
+ pointer pReadmask)
{
// nothing here
}
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index e682f08b6..b8f294aa0 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -1,7 +1,7 @@
/*
quartzKeyboard.c: Keyboard support for Xquartz
- Copyright (c) 2003-2008 Apple Inc.
+ Copyright (c) 2003-2012 Apple Inc.
Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
@@ -78,7 +78,7 @@ enum {
#if HACK_MISSING
/* Table of keycode->keysym mappings we use to fallback on for important
- keys that are often not in the Unicode mapping. */
+ keys that are often not in the Unicode mapping. */
const static struct {
unsigned short keycode;
@@ -89,12 +89,12 @@ const static struct {
{57, XK_Caps_Lock},
{58, XK_Alt_L},
{59, XK_Control_L},
-
+
{60, XK_Shift_R},
{61, XK_Alt_R},
{62, XK_Control_R},
{63, XK_Meta_R},
-
+
{122, XK_F1},
{120, XK_F2},
{99, XK_F3},
@@ -115,7 +115,7 @@ const static struct {
#if HACK_KEYPAD
/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
- keypad entries. */
+ keypad entries. */
const static struct {
unsigned short keycode;
@@ -152,7 +152,7 @@ const static unsigned short keycode_blacklist[] = {66, 70, 72, 77};
#endif
/* Table mapping normal keysyms to their dead equivalents.
- FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
+ FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
const static struct {
KeySym normal, dead;
@@ -161,7 +161,7 @@ const static struct {
{XK_apostrophe, XK_dead_acute}, /* US:"=" on a Czech keyboard */
{XK_acute, XK_dead_acute},
{UKEYSYM (0x384), XK_dead_acute}, /* US:";" on a Greek keyboard */
-// {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
+ // {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
{XK_asciicircum, XK_dead_circumflex},
{UKEYSYM (0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
{XK_asciitilde, XK_dead_tilde},
@@ -177,7 +177,7 @@ const static struct {
{XK_ogonek, XK_dead_ogonek},
{UKEYSYM (0x269), XK_dead_iota}, /* LATIN SMALL LETTER IOTA */
{UKEYSYM (0x2ec), XK_dead_voiced_sound}, /* MODIFIER LETTER VOICING */
-/* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
+ /* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
{UKEYSYM (0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */
{UKEYSYM (0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
{UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */
@@ -209,19 +209,19 @@ static void DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl) {
static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
int i;
KeySym *k;
-
+
memset(info->modMap, NoSymbol, sizeof(info->modMap));
memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
-
+
for (i = 0; i < NUM_KEYCODES; i++) {
k = info->keyMap + i * GLYPHS_PER_KEY;
-
+
switch (*k) {
case XK_Shift_L:
info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
info->modMap[MIN_KEYCODE + i] = ShiftMask;
break;
-
+
case XK_Shift_R:
#ifdef NX_MODIFIERKEY_RSHIFT
info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
@@ -230,12 +230,12 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
#endif
info->modMap[MIN_KEYCODE + i] = ShiftMask;
break;
-
+
case XK_Control_L:
info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
info->modMap[MIN_KEYCODE + i] = ControlMask;
break;
-
+
case XK_Control_R:
#ifdef NX_MODIFIERKEY_RCONTROL
info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
@@ -244,19 +244,19 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
#endif
info->modMap[MIN_KEYCODE + i] = ControlMask;
break;
-
+
case XK_Caps_Lock:
info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
info->modMap[MIN_KEYCODE + i] = LockMask;
break;
-
+
case XK_Alt_L:
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
info->modMap[MIN_KEYCODE + i] = Mod1Mask;
if(!XQuartzOptionSendsAlt)
*k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
break;
-
+
case XK_Alt_R:
#ifdef NX_MODIFIERKEY_RALTERNATE
info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
@@ -267,7 +267,7 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
*k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
info->modMap[MIN_KEYCODE + i] = Mod1Mask;
break;
-
+
case XK_Mode_switch:
ErrorF("DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
@@ -276,12 +276,12 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
#endif
info->modMap[MIN_KEYCODE + i] = Mod1Mask;
break;
-
+
case XK_Meta_L:
info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
info->modMap[MIN_KEYCODE + i] = Mod2Mask;
break;
-
+
case XK_Meta_R:
#ifdef NX_MODIFIERKEY_RCOMMAND
info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
@@ -290,7 +290,7 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
#endif
info->modMap[MIN_KEYCODE + i] = Mod2Mask;
break;
-
+
case XK_Num_Lock:
info->modMap[MIN_KEYCODE + i] = Mod3Mask;
break;
@@ -309,11 +309,11 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
// Note that the Event Status Driver is really just a wrapper
// for a kIOHIDParamConnectType connection.
assert(darwinParamConnect = NXOpenEventStatus());
-
+
InitKeyboardDeviceStruct(pDev, NULL, NULL, DarwinChangeKeyboardControl);
-
+
DarwinKeyboardReloadHandler();
-
+
CopyKeyClass(pDev, inputInfo.keyboard);
}
@@ -328,7 +328,7 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue
int i;
XkbControlsPtr ctrl;
XkbControlsRec old;
-
+
/* Turn on repeats globally */
XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOn);
@@ -338,12 +338,12 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue
ctrl->repeat_delay = initialKeyRepeatValue * 15;
ctrl->repeat_interval = keyRepeatValue * 15;
-
+
/* Turn off key-repeat for modifier keys, on for others */
/* First set them all on */
for(i=0; i < XkbPerKeyBitArraySize; i++)
ctrl->per_key_repeat[i] = -1;
-
+
/* Now turn off the modifiers */
for(i=0; i < 32; i++) {
unsigned char keycode;
@@ -351,20 +351,20 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue
keycode = keyInfo.modifierKeycodes[i][0];
if(keycode)
ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
-
+
keycode = keyInfo.modifierKeycodes[i][1];
if(keycode)
ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
}
-
+
/* Hurray for data duplication */
if (pDev->kbdfeed)
memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
-
+
//ErrorF("per_key_repeat =\n");
//for(i=0; i < XkbPerKeyBitArraySize; i++)
// ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
-
+
/* And now we notify the puppies about the changes */
XkbDDXChangeControls(pDev, &old, ctrl);
}
@@ -379,9 +379,9 @@ void DarwinKeyboardReloadHandler(void) {
const char *sysmodmap = PROJECTROOT "/lib/X11/xinit/.Xmodmap";
const char *homedir = getenv("HOME");
char usermodmap[PATH_MAX], cmd[PATH_MAX];
-
+
DEBUG_LOG("DarwinKeyboardReloadHandler\n");
-
+
/* Get our key repeat settings from GlobalPreferences */
(void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
@@ -399,14 +399,14 @@ void DarwinKeyboardReloadHandler(void) {
keySyms.mapWidth = GLYPHS_PER_KEY;
keySyms.minKeyCode = MIN_KEYCODE;
keySyms.maxKeyCode = MAX_KEYCODE;
-
- // TODO: We should build the entire XkbDescRec and use XkbCopyKeymap
+
+ // TODO: We should build the entire XkbDescRec and use XkbCopyKeymap
/* Apply the mappings to darwinKeyboard */
XkbApplyMappingChange(darwinKeyboard, &keySyms, keySyms.minKeyCode,
keySyms.maxKeyCode - keySyms.minKeyCode + 1,
keyInfo.modMap, serverClient);
DarwinKeyboardSetRepeat(darwinKeyboard, initialKeyRepeatValue, keyRepeatValue);
-
+
/* Apply the mappings to the core keyboard */
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
@@ -417,7 +417,7 @@ void DarwinKeyboardReloadHandler(void) {
}
}
} pthread_mutex_unlock(&keyInfo_mutex);
-
+
/* Modify with xmodmap */
if (access(xmodmap, F_OK) == 0) {
/* Check for system .Xmodmap */
@@ -428,7 +428,7 @@ void DarwinKeyboardReloadHandler(void) {
ErrorF("X11.app: Unable to create / execute xmodmap command line");
}
}
-
+
/* Check for user's local .Xmodmap */
if ((homedir != NULL) && (snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir) < sizeof(usermodmap))) {
if (access(usermodmap, F_OK) == 0) {
@@ -465,7 +465,7 @@ int DarwinModifierNXKeyToNXKeycode(int key, int side) {
pthread_mutex_lock(&keyInfo_mutex);
retval = keyInfo.modifierKeycodes[key][side];
pthread_mutex_unlock(&keyInfo_mutex);
-
+
return retval;
}
@@ -476,9 +476,9 @@ int DarwinModifierNXKeyToNXKeycode(int key, int side) {
*/
int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
int key, side;
-
+
keycode += MIN_KEYCODE;
-
+
// search modifierKeycodes for this keycode+side
pthread_mutex_lock(&keyInfo_mutex);
for (key = 0; key < NX_NUMMODIFIERS; key++) {
@@ -487,12 +487,12 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
}
}
pthread_mutex_unlock(&keyInfo_mutex);
-
+
if (key == NX_NUMMODIFIERS) {
return -1;
}
if (outSide) *outSide = side;
-
+
return key;
}
@@ -620,9 +620,9 @@ Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
static inline UniChar macroman2ucs(unsigned char c) {
/* Precalculated table mapping MacRoman-128 to Unicode. Generated
- by creating single element CFStringRefs then extracting the
- first character. */
-
+ by creating single element CFStringRefs then extracting the
+ first character. */
+
static const unsigned short table[128] = {
0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
@@ -641,17 +641,17 @@ static inline UniChar macroman2ucs(unsigned char c) {
0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
};
-
+
if (c < 128) return c;
else return table[c - 128];
}
static KeySym make_dead_key(KeySym in) {
int i;
-
+
for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
if (dead_keys[i].normal == in) return dead_keys[i].dead;
-
+
return in;
}
@@ -667,22 +667,22 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
OSStatus err;
KeySym *k;
CFDataRef currentKeyLayoutDataRef = NULL;
-
+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
-
+
if (currentKeyLayoutRef) {
- currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
- if (currentKeyLayoutDataRef)
- chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+ currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+ if (currentKeyLayoutDataRef)
+ chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
}
#endif
-
+
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
#endif
-
+
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (chr_data == NULL) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
@@ -690,17 +690,17 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
(unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data);
#endif
-
+
KLGetCurrentKeyboardLayout (&key_layout);
KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
-
+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
if(chr_data != NULL) {
ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
}
#endif
}
-
+
if (chr_data == NULL) {
ErrorF("X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
ErrorF("If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n");
@@ -715,35 +715,35 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
#endif
}
#endif
-
+
#ifdef __clang__
#pragma clang diagnostic pop
#endif
-
+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
if(currentKeyLayoutRef)
CFRelease(currentKeyLayoutRef);
#endif
if (chr_data == NULL) {
- ErrorF ( "Couldn't get uchr or kchr resource\n");
- return FALSE;
+ ErrorF ( "Couldn't get uchr or kchr resource\n");
+ return FALSE;
}
/* Scan the keycode range for the Unicode character that each
- key produces in the four shift states. Then convert that to
- an X11 keysym (which may just the bit that says "this is
- Unicode" if it can't find the real symbol.) */
-
+ key produces in the four shift states. Then convert that to
+ an X11 keysym (which may just the bit that says "this is
+ Unicode" if it can't find the real symbol.) */
+
/* KeyTranslate is not available on 64-bit platforms; UCKeyTranslate
- must be used instead. */
-
+ must be used instead. */
+
for (i = 0; i < num_keycodes; i++) {
static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
- MOD_OPTION | MOD_SHIFT};
-
+ MOD_OPTION | MOD_SHIFT};
+
k = info->keyMap + i * GLYPHS_PER_KEY;
-
+
for (j = 0; j < 4; j++) {
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (is_uchr) {
@@ -751,22 +751,22 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
UniChar s[8];
UniCharCount len;
UInt32 dead_key_state = 0, extra_dead = 0;
-
+
err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
mods[j] >> 8, keyboard_type, 0,
&dead_key_state, 8, &len, s);
if (err != noErr) continue;
-
+
if (len == 0 && dead_key_state != 0) {
/* Found a dead key. Work out which one it is, but
- remembering that it's dead. */
+ remembering that it's dead. */
err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
mods[j] >> 8, keyboard_type,
kUCKeyTranslateNoDeadKeysMask,
&extra_dead, 8, &len, s);
if (err != noErr) continue;
}
-
+
/* Not sure why 0x0010 is there.
* 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ...
*/
@@ -778,45 +778,45 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
} else { // kchr
UInt32 c, state = 0, state2 = 0;
UInt16 code;
-
+
code = i | mods[j];
-
+
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
#endif
-
+
c = KeyTranslate (chr_data, code, &state);
-
+
/* Dead keys are only processed on key-down, so ask
- to translate those events. When we find a dead key,
- translating the matching key up event will give
- us the actual dead character. */
-
+ to translate those events. When we find a dead key,
+ translating the matching key up event will give
+ us the actual dead character. */
+
if (state != 0)
c = KeyTranslate (chr_data, code | 128, &state2);
-
+
#ifdef __clang__
#pragma clang diagnostic pop
#endif
-
+
/* Characters seem to be in MacRoman encoding. */
-
+
if (c != 0 && c != 0x0010) {
k[j] = ucs2keysym (macroman2ucs (c & 255));
-
+
if (state != 0) k[j] = make_dead_key (k[j]);
}
}
#endif
}
-
+
if (k[3] == k[2]) k[3] = NoSymbol;
if (k[1] == k[0]) k[1] = NoSymbol;
if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = NoSymbol;
}
-
+
#if HACK_MISSING
/* Fix up some things that are normally missing.. */
@@ -846,9 +846,9 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
k[0] = k[1] = k[2] = k[3] = NoSymbol;
}
#endif
-
+
DarwinBuildModifierMaps(info);
-
+
return TRUE;
}
@@ -859,10 +859,10 @@ Bool QuartsResyncKeymap(Bool sendDDXEvent) {
memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
retval = QuartzReadSystemKeymap(&keyInfo);
pthread_mutex_unlock(&keyInfo_mutex);
-
+
/* Tell server thread to deal with new keyInfo */
if(sendDDXEvent)
DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
-
+
return retval;
}
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index de4aed868..eb08c43ef 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
* Copyright (c) 2003-2004 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index 98b382d65..e19fff468 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons,
* 2010 Jan Hauffa.
- * 2010-2011 Apple Inc.
+ * 2010-2012 Apple Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -64,17 +64,17 @@ static Bool ignore_next_fake_mode_update = FALSE;
#define CALLBACK_ERROR -1
typedef int (*QuartzModeCallback)
- (ScreenPtr, QuartzModeInfoPtr, void *);
+(ScreenPtr, QuartzModeInfoPtr, void *);
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
static long getDictLong (CFDictionaryRef dictRef, CFStringRef key) {
long value;
-
+
CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
if (!numRef)
return 0;
-
+
if (!CFNumberGetValue(numRef, kCFNumberLongType, &value))
return 0;
return value;
@@ -82,11 +82,11 @@ static long getDictLong (CFDictionaryRef dictRef, CFStringRef key) {
static double getDictDouble (CFDictionaryRef dictRef, CFStringRef key) {
double value;
-
+
CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
if (!numRef)
return 0.0;
-
+
if (!CFNumberGetValue(numRef, kCFNumberDoubleType, &value))
return 0.0;
return value;
@@ -104,11 +104,11 @@ static void QuartzRandRGetModeInfo (CFDictionaryRef modeRef,
}
static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId,
- QuartzModeInfoPtr pMode) {
+ QuartzModeInfoPtr pMode) {
CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId);
if (!curModeRef)
return FALSE;
-
+
QuartzRandRGetModeInfo(curModeRef, pMode);
pMode->ref = (void *)curModeRef;
CFRetain(pMode->ref);
@@ -116,7 +116,7 @@ static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId,
}
static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
- QuartzModeInfoPtr pMode) {
+ QuartzModeInfoPtr pMode) {
CFDictionaryRef modeRef = (CFDictionaryRef) pMode->ref;
return (CGDisplaySwitchToMode(screenId, modeRef) == kCGErrorSuccess);
}
@@ -126,7 +126,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
void *data) {
Bool retval = FALSE;
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
+
/* Just an 800x600 fallback if we have no attached heads */
if(pQuartzScreen->displayIDs) {
CFDictionaryRef curModeRef, modeRef;
@@ -135,27 +135,27 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
QuartzModeInfo modeInfo;
int i;
CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
-
+
curModeRef = CGDisplayCurrentMode(screenId);
if (!curModeRef)
return FALSE;
curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
-
+
modes = CGDisplayAvailableModes(screenId);
if (!modes)
return FALSE;
for (i = 0; i < CFArrayGetCount(modes); i++) {
int cb;
modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
-
+
/* Skip modes that are not usable on the current display or have a
- different pixel encoding than the current mode. */
+ different pixel encoding than the current mode. */
if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
continue;
if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
continue;
-
+
QuartzRandRGetModeInfo(modeRef, &modeInfo);
modeInfo.ref = (void *)modeRef;
cb = callback(pScreen, &modeInfo, data);
@@ -167,7 +167,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
return FALSE;
}
}
-
+
switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
@@ -178,7 +178,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
default:
break;
}
-
+
switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
@@ -189,7 +189,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
default:
break;
}
-
+
return retval;
}
@@ -211,18 +211,18 @@ static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId,
CGDisplayModeRef curModeRef = CGDisplayCopyDisplayMode(screenId);
if (!curModeRef)
return FALSE;
-
+
QuartzRandRGetModeInfo(curModeRef, pMode);
pMode->ref = curModeRef;
return TRUE;
}
static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
- QuartzModeInfoPtr pMode) {
+ QuartzModeInfoPtr pMode) {
CGDisplayModeRef modeRef = (CGDisplayModeRef) pMode->ref;
if (!modeRef)
return FALSE;
-
+
return (CGDisplaySetDisplayMode(screenId, modeRef, NULL) == kCGErrorSuccess);
}
@@ -231,7 +231,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
void *data) {
Bool retval = FALSE;
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
+
/* Just an 800x600 fallback if we have no attached heads */
if(pQuartzScreen->displayIDs) {
CGDisplayModeRef curModeRef, modeRef;
@@ -241,13 +241,13 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
QuartzModeInfo modeInfo;
int i;
CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
-
+
curModeRef = CGDisplayCopyDisplayMode(screenId);
if (!curModeRef)
return FALSE;
curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef);
CGDisplayModeRelease(curModeRef);
-
+
modes = CGDisplayCopyAllDisplayModes(screenId, NULL);
if (!modes) {
CFRelease(curPixelEnc);
@@ -256,9 +256,9 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
for (i = 0; i < CFArrayGetCount(modes); i++) {
int cb;
modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-
+
/* Skip modes that are not usable on the current display or have a
- different pixel encoding than the current mode. */
+ different pixel encoding than the current mode. */
if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
kDisplayModeUsableFlags)
continue;
@@ -267,7 +267,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
CFRelease(pixelEnc);
if (pixelEncEqual != kCFCompareEqualTo)
continue;
-
+
QuartzRandRGetModeInfo(modeRef, &modeInfo);
modeInfo.ref = modeRef;
cb = callback(pScreen, &modeInfo, data);
@@ -283,11 +283,11 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
return FALSE;
}
}
-
+
CFRelease(modes);
CFRelease(curPixelEnc);
}
-
+
switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
@@ -298,7 +298,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
default:
break;
}
-
+
switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
@@ -309,7 +309,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
default:
break;
}
-
+
return retval;
}
@@ -319,32 +319,32 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
static Bool QuartzRandRModesEqual (QuartzModeInfoPtr pMode1,
QuartzModeInfoPtr pMode2) {
return (pMode1->width == pMode2->width) &&
- (pMode1->height == pMode2->height) &&
- (pMode1->refresh == pMode2->refresh);
+ (pMode1->height == pMode2->height) &&
+ (pMode1->refresh == pMode2->refresh);
}
static Bool QuartzRandRRegisterMode (ScreenPtr pScreen,
QuartzModeInfoPtr pMode) {
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
Bool isCurrentMode = QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode);
-
+
/* TODO: DPI */
pMode->pSize = RRRegisterSize(pScreen, pMode->width, pMode->height, pScreen->mmWidth, pScreen->mmHeight);
if (pMode->pSize) {
//DEBUG_LOG("registering: %d x %d @ %d %s\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh, isCurrentMode ? "*" : "");
RRRegisterRate(pScreen, pMode->pSize, pMode->refresh);
-
+
if (isCurrentMode)
RRSetCurrentConfig(pScreen, RR_Rotate_0, pMode->refresh, pMode->pSize);
-
+
return TRUE;
}
return FALSE;
}
static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen,
- QuartzModeInfoPtr pMode,
- void *data __unused) {
+ QuartzModeInfoPtr pMode,
+ void *data __unused) {
if(QuartzRandRRegisterMode(pScreen, pMode)) {
return CALLBACK_CONTINUE;
} else {
@@ -356,10 +356,10 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS);
CGDirectDisplayID screenId;
-
+
if(pQuartzScreen->displayIDs == NULL)
return FALSE;
-
+
screenId = pQuartzScreen->displayIDs[0];
if(XQuartzShieldingWindowLevel == 0 && captureDisplay) {
if(!X11ApplicationCanEnterRandR())
@@ -369,7 +369,7 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
DEBUG_LOG("Display captured. ShieldWindowID: %u, Shield level: %d\n",
CGShieldingWindowID(screenId), XQuartzShieldingWindowLevel);
}
-
+
if (pQuartzScreen->currentMode.ref && CFEqual(pMode->ref, pQuartzScreen->currentMode.ref)) {
DEBUG_LOG("Requested RandR resolution matches current CG mode\n");
} if (QuartzRandRSetCGMode(screenId, pMode)) {
@@ -378,7 +378,7 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
DEBUG_LOG("Error while requesting CG resolution change.\n");
return FALSE;
}
-
+
/* If the client requested the fake rootless mode, switch to rootless.
* Otherwise, force fullscreen mode.
*/
@@ -386,7 +386,7 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
if (pMode->refresh != FAKE_REFRESH_ROOTLESS) {
QuartzShowFullscreen(TRUE);
}
-
+
if(pQuartzScreen->currentMode.ref)
CFRelease(pQuartzScreen->currentMode.ref);
pQuartzScreen->currentMode = *pMode;
@@ -397,7 +397,7 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
CGReleaseAllDisplays();
XQuartzShieldingWindowLevel = 0;
}
-
+
return TRUE;
}
@@ -408,9 +408,9 @@ static int QuartzRandRSetModeCallback (ScreenPtr pScreen,
if (!QuartzRandRModesEqual(pMode, pReqMode))
return CALLBACK_CONTINUE; /* continue enumeration */
-
+
DEBUG_LOG("Found a match for requested RandR resolution (%dx%d@%d).\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh);
-
+
if(QuartzRandRSetMode(pScreen, pMode, FALSE))
return CALLBACK_SUCCESS;
else
@@ -419,7 +419,7 @@ static int QuartzRandRSetModeCallback (ScreenPtr pScreen,
static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
*rotations = RR_Rotate_0; /* TODO: support rotation */
-
+
return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL);
}
@@ -429,15 +429,15 @@ static Bool QuartzRandRSetConfig (ScreenPtr pScreen,
RRScreenSizePtr pSize) {
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
QuartzModeInfo reqMode;
-
+
reqMode.width = pSize->width;
reqMode.height = pSize->height;
reqMode.refresh = rate;
-
+
/* Do not switch modes if requested mode is equal to current mode. */
if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode))
return TRUE;
-
+
if (QuartzRandREnumerateModes(pScreen, QuartzRandRSetModeCallback, &reqMode)) {
return TRUE;
}
@@ -449,7 +449,7 @@ static Bool QuartzRandRSetConfig (ScreenPtr pScreen,
static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
QuartzModeInfo activeMode;
-
+
if(pQuartzScreen->displayCount > 0) {
if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
ErrorF("Unable to determine current display mode.\n");
@@ -461,32 +461,32 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
activeMode.height = 600;
activeMode.refresh = 60;
}
-
+
if(pQuartzScreen->fullscreenMode.ref)
CFRelease(pQuartzScreen->fullscreenMode.ref);
if(pQuartzScreen->currentMode.ref)
CFRelease(pQuartzScreen->currentMode.ref);
-
+
if(pQuartzScreen->displayCount > 1) {
activeMode.width = pScreen->width;
activeMode.height = pScreen->height;
if(XQuartzIsRootless)
activeMode.height += aquaMenuBarHeight;
}
-
+
pQuartzScreen->fullscreenMode = activeMode;
pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN;
-
+
pQuartzScreen->rootlessMode = activeMode;
pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS;
pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight;
-
+
if(XQuartzIsRootless) {
pQuartzScreen->currentMode = pQuartzScreen->rootlessMode;
} else {
pQuartzScreen->currentMode = pQuartzScreen->fullscreenMode;
}
-
+
/* This extra retain is for currentMode's copy.
* fullscreen and rootless share a retain.
*/
@@ -514,7 +514,7 @@ Bool QuartzRandRUpdateFakeModes (BOOL force_update) {
if(force_update)
RRGetInfo(pScreen, TRUE);
-
+
return TRUE;
}
@@ -523,7 +523,7 @@ Bool QuartzRandRInit (ScreenPtr pScreen) {
if (!RRScreenInit (pScreen)) return FALSE;
if (!_QuartzRandRUpdateFakeModes (pScreen)) return FALSE;
-
+
pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = QuartzRandRGetInfo;
pScrPriv->rrSetConfig = QuartzRandRSetConfig;
@@ -538,20 +538,20 @@ void QuartzRandRSetFakeRootless (void) {
for (i=0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
+
QuartzRandRSetMode(pScreen, &pQuartzScreen->rootlessMode, TRUE);
}
}
void QuartzRandRSetFakeFullscreen (BOOL state) {
int i;
-
+
DEBUG_LOG("QuartzRandRSetFakeFullscreen called.\n");
for (i=0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
+
QuartzRandRSetMode(pScreen, &pQuartzScreen->fullscreenMode, TRUE);
}
@@ -566,7 +566,7 @@ void QuartzRandRSetFakeFullscreen (BOOL state) {
void QuartzRandRToggleFullscreen (void) {
ScreenPtr pScreen = screenInfo.screens[0];
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
+
if (pQuartzScreen->currentMode.ref == NULL) {
ErrorF("Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n");
} else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) {
diff --git a/hw/xquartz/quartzRandR.h b/hw/xquartz/quartzRandR.h
index fb0ce0c44..1118c00d5 100644
--- a/hw/xquartz/quartzRandR.h
+++ b/hw/xquartz/quartzRandR.h
@@ -2,7 +2,7 @@
* quartzRandR.h
*
* Copyright (c) 2010 Jan Hauffa.
- * 2010 Apple Inc.
+ * 2010-2012 Apple Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 25ef76efa..bc16fc3e1 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -1,7 +1,7 @@
/**************************************************************
*
* Startup code for the Quartz Darwin X Server
- *
+ * Copyright (c) 2008-2012 Apple Inc. All rights reserved.
* Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -93,7 +93,7 @@ void QuartzInitServer(int argc, char **argv, char **envp) {
int server_main(int argc, char **argv, char **envp) {
int i;
int fd[2];
-
+
/* Unset CFProcessPath, so our children don't inherit this kludge we need
* to load our nib. If an xterm gets this set, then it fails to
* 'open hi.txt' properly.
@@ -105,7 +105,7 @@ int server_main(int argc, char **argv, char **envp) {
darwinEventReadFD = fd[0];
darwinEventWriteFD = fd[1];
fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
-
+
for (i = 1; i < argc; i++) {
// Display version info without starting Mac OS X UI if requested
if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
@@ -113,7 +113,7 @@ int server_main(int argc, char **argv, char **envp) {
exit(0);
}
}
-
+
X11ControllerMain(argc, argv, envp);
exit(0);
}
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index 44c132abc..fcde47a5f 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -2,7 +2,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2009-2011 Apple Inc.
+Copyright (c) 2002, 2009-2012 Apple Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -32,6 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeremy Huddleston <jeremyhu@apple.com>
*
*/
@@ -79,19 +80,19 @@ typedef struct _DRIEvent {
/*ARGSUSED*/
static void
AppleDRIResetProc (
- ExtensionEntry* extEntry
-)
+ ExtensionEntry* extEntry
+ )
{
DRIReset();
}
static int
ProcAppleDRIQueryVersion(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
xAppleDRIQueryVersionReply rep;
-
+
REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
@@ -115,79 +116,79 @@ ProcAppleDRIQueryVersion(
static int
ProcAppleDRIQueryDirectRenderingCapable(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
xAppleDRIQueryDirectRenderingCapableReply rep;
Bool isCapable;
-
+
REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
REQUEST_SIZE_MATCH(xAppleDRIQueryDirectRenderingCapableReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
-
+
if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen],
- &isCapable)) {
+ &isCapable)) {
return BadValue;
}
rep.isCapable = isCapable;
-
+
if (!LocalClient(client))
rep.isCapable = 0;
-
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
-
+
WriteToClient(client,
- sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
+ sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
return Success;
}
static int
ProcAppleDRIAuthConnection(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
xAppleDRIAuthConnectionReply rep;
REQUEST(xAppleDRIAuthConnectionReq);
REQUEST_SIZE_MATCH(xAppleDRIAuthConnectionReq);
-
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.authenticated = 1;
-
+
if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
rep.authenticated = 0;
}
-
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.authenticated); /* Yes, this is a CARD32 ... sigh */
}
-
+
WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
return Success;
}
static void surface_notify(
- void *_arg,
- void *data
-)
+ void *_arg,
+ void *data
+ )
{
DRISurfaceNotifyArg *arg = _arg;
int client_index = (int) x_cvt_vptr_to_uint(data);
xAppleDRINotifyEvent se;
-
+
if (client_index < 0 || client_index >= currentMaxClients)
return;
-
+
se.type = DRIEventBase + AppleDRISurfaceNotify;
se.kind = arg->kind;
se.arg = arg->id;
@@ -197,40 +198,40 @@ static void surface_notify(
static int
ProcAppleDRICreateSurface(
- ClientPtr client
-)
+ ClientPtr client
+ )
{
xAppleDRICreateSurfaceReply rep;
DrawablePtr pDrawable;
xp_surface_id sid;
unsigned int key[2];
int rc;
-
+
REQUEST(xAppleDRICreateSurfaceReq);
REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
-
+
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixReadAccess);
if (rc != Success)
- return rc;
-
+ return rc;
+
rep.key_0 = rep.key_1 = rep.uid = 0;
-
+
if (!DRICreateSurface( screenInfo.screens[stuff->screen],
- (Drawable)stuff->drawable, pDrawable,
- stuff->client_id, &sid, key,
- surface_notify,
- x_cvt_uint_to_vptr(client->index))) {
+ (Drawable)stuff->drawable, pDrawable,
+ stuff->client_id, &sid, key,
+ surface_notify,
+ x_cvt_uint_to_vptr(client->index))) {
return BadValue;
}
-
+
rep.key_0 = key[0];
rep.key_1 = key[1];
rep.uid = sid;
-
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -238,32 +239,32 @@ ProcAppleDRICreateSurface(
swapl(&rep.key_1);
swapl(&rep.uid);
}
-
+
WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
return Success;
}
static int
ProcAppleDRIDestroySurface(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
int rc;
REQUEST(xAppleDRIDestroySurfaceReq);
DrawablePtr pDrawable;
REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
-
+
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixReadAccess);
if (rc != Success)
- return rc;
-
+ return rc;
+
if (!DRIDestroySurface( screenInfo.screens[stuff->screen],
- (Drawable)stuff->drawable,
- pDrawable, NULL, NULL)) {
+ (Drawable)stuff->drawable,
+ pDrawable, NULL, NULL)) {
return BadValue;
}
-
+
return Success;
}
@@ -277,29 +278,29 @@ ProcAppleDRICreatePixmap(ClientPtr client)
xAppleDRICreatePixmapReply rep;
int width, height, pitch, bpp;
void *ptr;
-
+
REQUEST_SIZE_MATCH(xAppleDRICreatePixmapReq);
-
+
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
DixReadAccess);
-
+
if(rc != Success)
return rc;
if(!DRICreatePixmap(screenInfo.screens[stuff->screen],
- (Drawable)stuff->drawable,
- pDrawable,
- path, PATH_MAX)) {
+ (Drawable)stuff->drawable,
+ pDrawable,
+ path, PATH_MAX)) {
return BadValue;
}
-
+
if(!DRIGetPixmapData(pDrawable, &width, &height,
- &pitch, &bpp, &ptr)) {
- return BadValue;
+ &pitch, &bpp, &ptr)) {
+ return BadValue;
}
rep.stringLength = strlen(path) + 1;
-
+
rep.type = X_Reply;
rep.length = bytes_to_int32(rep.stringLength);
rep.sequenceNumber = client->sequence;
@@ -308,9 +309,9 @@ ProcAppleDRICreatePixmap(ClientPtr client)
rep.pitch = pitch;
rep.bpp = bpp;
rep.size = pitch * height;
-
+
if(sizeof(rep) != sz_xAppleDRICreatePixmapReply)
- ErrorF("error sizeof(rep) is %zu\n", sizeof(rep));
+ ErrorF("error sizeof(rep) is %zu\n", sizeof(rep));
if (client->swapped) {
swaps(&rep.sequenceNumber);
@@ -322,10 +323,10 @@ ProcAppleDRICreatePixmap(ClientPtr client)
swapl(&rep.bpp);
swapl(&rep.size);
}
-
+
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, rep.stringLength, path);
-
+
return Success;
}
@@ -336,15 +337,15 @@ ProcAppleDRIDestroyPixmap(ClientPtr client)
int rc;
REQUEST(xAppleDRIDestroyPixmapReq);
REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq);
-
+
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
-
+ DixReadAccess);
+
if(rc != Success)
- return rc;
+ return rc;
DRIDestroyPixmap(pDrawable);
-
+
return Success;
}
@@ -352,45 +353,45 @@ ProcAppleDRIDestroyPixmap(ClientPtr client)
static int
ProcAppleDRIDispatch (
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xReq);
-
+
switch (stuff->data)
{
- case X_AppleDRIQueryVersion:
- return ProcAppleDRIQueryVersion(client);
- case X_AppleDRIQueryDirectRenderingCapable:
- return ProcAppleDRIQueryDirectRenderingCapable(client);
+ case X_AppleDRIQueryVersion:
+ return ProcAppleDRIQueryVersion(client);
+ case X_AppleDRIQueryDirectRenderingCapable:
+ return ProcAppleDRIQueryDirectRenderingCapable(client);
}
-
+
if (!LocalClient(client))
return DRIErrorBase + AppleDRIClientNotLocal;
-
+
switch (stuff->data)
{
- case X_AppleDRIAuthConnection:
- return ProcAppleDRIAuthConnection(client);
- case X_AppleDRICreateSurface:
- return ProcAppleDRICreateSurface(client);
- case X_AppleDRIDestroySurface:
- return ProcAppleDRIDestroySurface(client);
- case X_AppleDRICreatePixmap:
- return ProcAppleDRICreatePixmap(client);
- case X_AppleDRIDestroyPixmap:
- return ProcAppleDRIDestroyPixmap(client);
-
- default:
- return BadRequest;
+ case X_AppleDRIAuthConnection:
+ return ProcAppleDRIAuthConnection(client);
+ case X_AppleDRICreateSurface:
+ return ProcAppleDRICreateSurface(client);
+ case X_AppleDRIDestroySurface:
+ return ProcAppleDRIDestroySurface(client);
+ case X_AppleDRICreatePixmap:
+ return ProcAppleDRICreatePixmap(client);
+ case X_AppleDRIDestroyPixmap:
+ return ProcAppleDRIDestroyPixmap(client);
+
+ default:
+ return BadRequest;
}
}
static void
SNotifyEvent(
- xAppleDRINotifyEvent *from,
- xAppleDRINotifyEvent *to
-)
+ xAppleDRINotifyEvent *from,
+ xAppleDRINotifyEvent *to
+ )
{
to->type = from->type;
to->kind = from->kind;
@@ -401,8 +402,8 @@ SNotifyEvent(
static int
SProcAppleDRIQueryVersion(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleDRIQueryVersionReq);
swaps(&stuff->length);
@@ -411,8 +412,8 @@ SProcAppleDRIQueryVersion(
static int
SProcAppleDRIQueryDirectRenderingCapable(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
swaps(&stuff->length);
@@ -422,8 +423,8 @@ SProcAppleDRIQueryDirectRenderingCapable(
static int
SProcAppleDRIAuthConnection(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleDRIAuthConnectionReq);
swaps(&stuff->length);
@@ -434,8 +435,8 @@ SProcAppleDRIAuthConnection(
static int
SProcAppleDRICreateSurface(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleDRICreateSurfaceReq);
swaps(&stuff->length);
@@ -447,8 +448,8 @@ SProcAppleDRICreateSurface(
static int
SProcAppleDRIDestroySurface(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleDRIDestroySurfaceReq);
swaps(&stuff->length);
@@ -459,8 +460,8 @@ SProcAppleDRIDestroySurface(
static int
SProcAppleDRICreatePixmap(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleDRICreatePixmapReq);
swaps(&stuff->length);
@@ -471,8 +472,8 @@ SProcAppleDRICreatePixmap(
static int
SProcAppleDRIDestroyPixmap(
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xAppleDRIDestroyPixmapReq);
swaps(&stuff->length);
@@ -482,37 +483,37 @@ SProcAppleDRIDestroyPixmap(
static int
SProcAppleDRIDispatch (
- register ClientPtr client
-)
+ register ClientPtr client
+ )
{
REQUEST(xReq);
-
+
switch (stuff->data)
{
- case X_AppleDRIQueryVersion:
- return SProcAppleDRIQueryVersion(client);
- case X_AppleDRIQueryDirectRenderingCapable:
- return SProcAppleDRIQueryDirectRenderingCapable(client);
+ case X_AppleDRIQueryVersion:
+ return SProcAppleDRIQueryVersion(client);
+ case X_AppleDRIQueryDirectRenderingCapable:
+ return SProcAppleDRIQueryDirectRenderingCapable(client);
}
-
+
if (!LocalClient(client))
return DRIErrorBase + AppleDRIClientNotLocal;
-
+
switch (stuff->data)
{
- case X_AppleDRIAuthConnection:
- return SProcAppleDRIAuthConnection(client);
- case X_AppleDRICreateSurface:
- return SProcAppleDRICreateSurface(client);
- case X_AppleDRIDestroySurface:
- return SProcAppleDRIDestroySurface(client);
- case X_AppleDRICreatePixmap:
- return SProcAppleDRICreatePixmap(client);
- case X_AppleDRIDestroyPixmap:
- return SProcAppleDRIDestroyPixmap(client);
-
- default:
- return BadRequest;
+ case X_AppleDRIAuthConnection:
+ return SProcAppleDRIAuthConnection(client);
+ case X_AppleDRICreateSurface:
+ return SProcAppleDRICreateSurface(client);
+ case X_AppleDRIDestroySurface:
+ return SProcAppleDRIDestroySurface(client);
+ case X_AppleDRICreatePixmap:
+ return SProcAppleDRICreatePixmap(client);
+ case X_AppleDRIDestroyPixmap:
+ return SProcAppleDRIDestroyPixmap(client);
+
+ default:
+ return BadRequest;
}
}
@@ -520,7 +521,7 @@ void
AppleDRIExtensionInit(void)
{
ExtensionEntry* extEntry;
-
+
if (DRIExtensionInit() &&
(extEntry = AddExtension(APPLEDRINAME,
AppleDRINumberEvents,
diff --git a/hw/xquartz/xpr/appledri.h b/hw/xquartz/xpr/appledri.h
index 36964c6cd..338ecf184 100644
--- a/hw/xquartz/xpr/appledri.h
+++ b/hw/xquartz/xpr/appledri.h
@@ -3,7 +3,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
+Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -33,6 +33,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeremy Huddleston <jeremyhu@apple.com>
*
*/
@@ -87,33 +88,33 @@ _XFUNCPROTOBEGIN
Bool XAppleDRIQueryExtension (Display *dpy, int *event_base, int *error_base);
Bool XAppleDRIQueryVersion (Display *dpy, int *majorVersion,
- int *minorVersion, int *patchVersion);
+ int *minorVersion, int *patchVersion);
Bool XAppleDRIQueryDirectRenderingCapable (Display *dpy, int screen,
- Bool *isCapable);
+ Bool *isCapable);
void *XAppleDRISetSurfaceNotifyHandler (void (*fun) (Display *dpy,
- unsigned uid, int kind));
+ unsigned uid, int kind));
Bool XAppleDRIAuthConnection (Display *dpy, int screen, unsigned int magic);
Bool XAppleDRICreateSurface (Display *dpy, int screen, Drawable drawable,
- unsigned int client_id, unsigned int key[2],
- unsigned int* uid);
+ unsigned int client_id, unsigned int key[2],
+ unsigned int* uid);
Bool XAppleDRIDestroySurface (Display *dpy, int screen, Drawable drawable);
Bool XAppleDRISynchronizeSurfaces (Display *dpy);
Bool XAppleDRICreateSharedBuffer(Display *dpy, int screen, Drawable drawable,
- Bool doubleSwap, char *path, size_t pathlen,
- int *width, int *height);
+ Bool doubleSwap, char *path, size_t pathlen,
+ int *width, int *height);
Bool XAppleDRISwapBuffers(Display *dpy, int screen, Drawable drawable);
Bool XAppleDRICreatePixmap(Display *dpy, int screen, Drawable drawable,
- int *width, int *height, int *pitch, int *bpp,
- size_t *size, char *bufname, size_t bufnamesize);
+ int *width, int *height, int *pitch, int *bpp,
+ size_t *size, char *bufname, size_t bufnamesize);
Bool XAppleDRIDestroyPixmap(Display *dpy, Pixmap pixmap);
diff --git a/hw/xquartz/xpr/appledristr.h b/hw/xquartz/xpr/appledristr.h
index b5ffe5b46..11d4f9f09 100644
--- a/hw/xquartz/xpr/appledristr.h
+++ b/hw/xquartz/xpr/appledristr.h
@@ -2,7 +2,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
+Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -32,6 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Fiath <faith@valinux.com>
+ * Jeremy Huddleston <jeremyhu@apple.com>
*
*/
@@ -48,205 +49,205 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
typedef struct _AppleDRIQueryVersion
{
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIQueryVersion */
- CARD16 length B16;
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIQueryVersion */
+ CARD16 length B16;
} xAppleDRIQueryVersionReq;
#define sz_xAppleDRIQueryVersionReq 4
typedef struct
{
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD16 majorVersion B16; /* major version of DRI protocol */
- CARD16 minorVersion B16; /* minor version of DRI protocol */
- CARD32 patchVersion B32; /* patch version of DRI protocol */
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of DRI protocol */
+ CARD16 minorVersion B16; /* minor version of DRI protocol */
+ CARD32 patchVersion B32; /* patch version of DRI protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRIQueryVersionReply;
#define sz_xAppleDRIQueryVersionReply 32
typedef struct _AppleDRIQueryDirectRenderingCapable
{
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
- CARD16 length B16;
- CARD32 screen B32;
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
+ CARD16 length B16;
+ CARD32 screen B32;
} xAppleDRIQueryDirectRenderingCapableReq;
#define sz_xAppleDRIQueryDirectRenderingCapableReq 8
typedef struct
{
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- BOOL isCapable;
- BOOL pad2;
- BOOL pad3;
- BOOL pad4;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
- CARD32 pad8 B32;
- CARD32 pad9 B32;
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ BOOL isCapable;
+ BOOL pad2;
+ BOOL pad3;
+ BOOL pad4;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+ CARD32 pad9 B32;
} xAppleDRIQueryDirectRenderingCapableReply;
#define sz_xAppleDRIQueryDirectRenderingCapableReply 32
typedef struct _AppleDRIAuthConnection
{
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseConnection */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 magic B32;
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 magic B32;
} xAppleDRIAuthConnectionReq;
#define sz_xAppleDRIAuthConnectionReq 12
typedef struct
{
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 authenticated B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 authenticated B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRIAuthConnectionReply;
#define zx_xAppleDRIAuthConnectionReply 32
typedef struct _AppleDRICreateSurface
{
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICreateSurface */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
- CARD32 client_id B32;
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateSurface */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+ CARD32 client_id B32;
} xAppleDRICreateSurfaceReq;
#define sz_xAppleDRICreateSurfaceReq 16
typedef struct
{
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 key_0 B32;
- CARD32 key_1 B32;
- CARD32 uid B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 key_0 B32;
+ CARD32 key_1 B32;
+ CARD32 uid B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRICreateSurfaceReply;
#define sz_xAppleDRICreateSurfaceReply 32
typedef struct _AppleDRIDestroySurface
{
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIDestroySurface */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroySurface */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xAppleDRIDestroySurfaceReq;
#define sz_xAppleDRIDestroySurfaceReq 12
typedef struct _AppleDRINotify
{
- BYTE type; /* always eventBase + event type */
- BYTE kind;
- CARD16 sequenceNumber B16;
- CARD32 time B32; /* time of change */
- CARD32 pad1 B32;
- CARD32 arg B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+ BYTE type; /* always eventBase + event type */
+ BYTE kind;
+ CARD16 sequenceNumber B16;
+ CARD32 time B32; /* time of change */
+ CARD32 pad1 B32;
+ CARD32 arg B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xAppleDRINotifyEvent;
#define sz_xAppleDRINotifyEvent 32
typedef struct
{
- CARD8 reqType;
- CARD8 driReqType;
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
- BOOL doubleSwap;
- CARD8 pad1, pad2, pad3;
+ CARD8 reqType;
+ CARD8 driReqType;
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+ BOOL doubleSwap;
+ CARD8 pad1, pad2, pad3;
} xAppleDRICreateSharedBufferReq;
#define sz_xAppleDRICreateSharedBufferReq 16
typedef struct
{
- BYTE type;
- BYTE data1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 stringLength B32; /* 0 on error */
- CARD32 width B32;
- CARD32 height B32;
- CARD32 pad1 B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
+ BYTE type;
+ BYTE data1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 stringLength B32; /* 0 on error */
+ CARD32 width B32;
+ CARD32 height B32;
+ CARD32 pad1 B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
} xAppleDRICreateSharedBufferReply;
#define sz_xAppleDRICreateSharedBufferReply 32
typedef struct
{
- CARD8 reqType;
- CARD8 driReqType;
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+ CARD8 reqType;
+ CARD8 driReqType;
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xAppleDRISwapBuffersReq;
#define sz_xAppleDRISwapBuffersReq 12
typedef struct
{
- CARD8 reqType; /*1 */
- CARD8 driReqType; /*2 */
- CARD16 length B16; /*4 */
- CARD32 screen B32; /*8 */
- CARD32 drawable B32; /*12 */
+ CARD8 reqType; /*1 */
+ CARD8 driReqType; /*2 */
+ CARD16 length B16; /*4 */
+ CARD32 screen B32; /*8 */
+ CARD32 drawable B32; /*12 */
} xAppleDRICreatePixmapReq;
#define sz_xAppleDRICreatePixmapReq 12
typedef struct
{
- BYTE type; /*1 */
- BOOL pad1; /*2 */
- CARD16 sequenceNumber B16; /*4 */
- CARD32 length B32; /*8 */
- CARD32 width B32; /*12 */
- CARD32 height B32; /*16 */
- CARD32 pitch B32; /*20 */
- CARD32 bpp B32; /*24 */
- CARD32 size B32; /*28 */
- CARD32 stringLength B32; /*32 */
+ BYTE type; /*1 */
+ BOOL pad1; /*2 */
+ CARD16 sequenceNumber B16; /*4 */
+ CARD32 length B32; /*8 */
+ CARD32 width B32; /*12 */
+ CARD32 height B32; /*16 */
+ CARD32 pitch B32; /*20 */
+ CARD32 bpp B32; /*24 */
+ CARD32 size B32; /*28 */
+ CARD32 stringLength B32; /*32 */
} xAppleDRICreatePixmapReply;
#define sz_xAppleDRICreatePixmapReply 32
typedef struct
{
- CARD8 reqType; /*1 */
- CARD8 driReqType; /*2 */
- CARD16 length B16; /*4 */
- CARD32 drawable B32; /*8 */
+ CARD8 reqType; /*1 */
+ CARD8 driReqType; /*2 */
+ CARD16 length B16; /*4 */
+ CARD32 drawable B32; /*8 */
} xAppleDRIDestroyPixmapReq;
#define sz_xAppleDRIDestroyPixmapReq 8
@@ -255,12 +256,12 @@ typedef struct
void AppleDRISendEvent(
#if NeedFunctionPrototypes
- int /* type */ ,
- unsigned int /* mask */ ,
- int /* which */ ,
- int /* arg */
+ int /* type */ ,
+ unsigned int /* mask */ ,
+ int /* which */ ,
+ int /* arg */
#endif
- );
+ );
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRISTR_H_ */
diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index a58f2c76d..401658ce3 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -2,7 +2,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2009 Apple Computer, Inc.
+Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -31,7 +31,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Authors:
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
- *
+ * Jeremy Huddleston <jeremyhu@apple.com>
*/
#ifdef HAVE_DIX_CONFIG_H
@@ -106,31 +106,31 @@ DRIScreenInit(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv;
int i;
-
+
if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
+ return FALSE;
if (!dixRegisterPrivateKey(&DRIPixmapPrivKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
+ return FALSE;
if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
-
+ return FALSE;
+
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
return FALSE;
}
-
+
dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
pDRIPriv->directRenderingSupport = TRUE;
pDRIPriv->nrWindows = 0;
-
+
/* Initialize drawable tables */
for (i = 0; i < DRI_MAX_DRAWABLES; i++) {
pDRIPriv->DRIDrawables[i] = NULL;
}
-
+
return TRUE;
}
@@ -138,25 +138,25 @@ Bool
DRIFinishScreenInit(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
+
/* Wrap DRI support */
pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
pScreen->ValidateTree = DRIValidateTree;
-
+
pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
pScreen->PostValidateTree = DRIPostValidateTree;
-
+
pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
pScreen->WindowExposures = DRIWindowExposures;
-
+
pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
pScreen->CopyWindow = DRICopyWindow;
-
+
pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
pScreen->ClipNotify = DRIClipNotify;
-
+
// ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
-
+
return DRIWrapInit(pScreen);
}
@@ -164,10 +164,10 @@ void
DRICloseScreen(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
+
if (pDRIPriv && pDRIPriv->directRenderingSupport) {
free(pDRIPriv);
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
}
}
@@ -175,8 +175,8 @@ Bool
DRIExtensionInit(void)
{
DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
- "DRIDrawable");
-
+ "DRIDrawable");
+
return DRIDrawablePrivResType != 0;
}
@@ -196,12 +196,12 @@ Bool
DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
+
if (pDRIPriv)
*isCapable = pDRIPriv->directRenderingSupport;
else
*isCapable = FALSE;
-
+
return TRUE;
}
@@ -210,9 +210,9 @@ DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
{
#if 0
/* FIXME: something? */
-
+
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
+
if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
#endif
return TRUE;
@@ -223,34 +223,34 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
{
xp_window_changes wc;
unsigned int flags = 0;
-
+
if (pDRIDrawablePriv->sid == 0)
return;
-
+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
: pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
if (wc.depth != XP_DEPTH_NIL)
flags |= XP_DEPTH;
#endif
-
+
if (pDraw->type == DRAWABLE_WINDOW) {
WindowPtr pWin = (WindowPtr) pDraw;
WindowPtr pTopWin = TopLevelParent(pWin);
-
+
wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth);
wc.width = pWin->drawable.width + 2 * pWin->borderWidth;
wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
wc.bit_gravity = XP_GRAVITY_NONE;
-
+
wc.shape_nrects = RegionNumRects(&pWin->clipList);
wc.shape_rects = RegionRects(&pWin->clipList);
wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
-
+
flags |= XP_BOUNDS | XP_SHAPE;
-
+
} else if (pDraw->type == DRAWABLE_PIXMAP) {
wc.x = 0;
wc.y = 0;
@@ -259,7 +259,7 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
wc.bit_gravity = XP_GRAVITY_NONE;
flags |= XP_BOUNDS;
}
-
+
xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
}
@@ -268,60 +268,60 @@ static DRIDrawablePrivPtr
CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) {
DRIDrawablePrivPtr pDRIDrawablePriv;
xp_window_id wid = 0;
-
+
*widPtr = 0;
-
+
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
+
if (pDRIDrawablePriv == NULL) {
- xp_error err;
- xp_window_changes wc;
-
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) {
- return NULL;
- }
-
- pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 0;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->notifiers = NULL;
-
- /* find the physical window */
- wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
-
- if (wid == 0) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* allocate the physical surface */
- err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
-
- if (err != Success) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* Make it visible */
- wc.stack_mode = XP_MAPPED_ABOVE;
- wc.sibling = 0;
- err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
-
- if (err != Success) {
- xp_destroy_surface(pDRIDrawablePriv->sid);
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* save private off of preallocated index */
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
- pDRIDrawablePriv);
+ xp_error err;
+ xp_window_changes wc;
+
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) {
+ return NULL;
+ }
+
+ pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 0;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->notifiers = NULL;
+
+ /* find the physical window */
+ wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
+
+ if (wid == 0) {
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /* allocate the physical surface */
+ err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
+
+ if (err != Success) {
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /* Make it visible */
+ wc.stack_mode = XP_MAPPED_ABOVE;
+ wc.sibling = 0;
+ err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
+
+ if (err != Success) {
+ xp_destroy_surface(pDRIDrawablePriv->sid);
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /* save private off of preallocated index */
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
}
-
+
*widPtr = wid;
-
+
return pDRIDrawablePriv;
}
@@ -329,40 +329,40 @@ CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr)
static DRIDrawablePrivPtr
CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) {
DRIDrawablePrivPtr pDRIDrawablePriv;
-
+
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
-
+
if (pDRIDrawablePriv == NULL) {
- xp_error err;
-
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) {
- return NULL;
- }
-
- pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 0;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->notifiers = NULL;
-
- /* Passing a null window id to Xplugin in 10.3+ asks for
- an accelerated offscreen surface. */
-
- err = xp_create_surface(0, &pDRIDrawablePriv->sid);
- if (err != Success) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /*
- * The DRIUpdateSurface will be called to resize the surface
- * after this function, if the export is successful.
- */
-
- /* save private off of preallocated index */
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
- pDRIDrawablePriv);
+ xp_error err;
+
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) {
+ return NULL;
+ }
+
+ pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 0;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->notifiers = NULL;
+
+ /* Passing a null window id to Xplugin in 10.3+ asks for
+ an accelerated offscreen surface. */
+
+ err = xp_create_surface(0, &pDRIDrawablePriv->sid);
+ if (err != Success) {
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /*
+ * The DRIUpdateSurface will be called to resize the surface
+ * after this function, if the export is successful.
+ */
+
+ /* save private off of preallocated index */
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
+ pDRIDrawablePriv);
}
return pDRIDrawablePriv;
@@ -378,25 +378,25 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
xp_window_id wid = 0;
DRIDrawablePrivPtr pDRIDrawablePriv;
-
+
if (pDrawable->type == DRAWABLE_WINDOW) {
- pDRIDrawablePriv = CreateSurfaceForWindow(pScreen,
- (WindowPtr)pDrawable, &wid);
-
- if(NULL == pDRIDrawablePriv)
- return FALSE; /*error*/
+ pDRIDrawablePriv = CreateSurfaceForWindow(pScreen,
+ (WindowPtr)pDrawable, &wid);
+
+ if(NULL == pDRIDrawablePriv)
+ return FALSE; /*error*/
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
- (PixmapPtr)pDrawable);
-
- if(NULL == pDRIDrawablePriv)
- return FALSE; /*error*/
+ pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
+ (PixmapPtr)pDrawable);
+
+ if(NULL == pDRIDrawablePriv)
+ return FALSE; /*error*/
}
#endif
else {
- /* We handle GLXPbuffers in a different way (via CGL). */
+ /* We handle GLXPbuffers in a different way (via CGL). */
return FALSE;
}
@@ -405,69 +405,69 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
if (pDRIDrawablePriv->refCount == 0) {
unsigned int key[2] = {0};
xp_error err;
-
+
/* try to give the client access to the surface */
if (client_id != 0) {
- /*
- * Xplugin accepts a 0 wid if the surface id is offscreen, such
- * as for a pixmap.
- */
+ /*
+ * Xplugin accepts a 0 wid if the surface id is offscreen, such
+ * as for a pixmap.
+ */
err = xp_export_surface(wid, pDRIDrawablePriv->sid,
client_id, key);
if (err != Success) {
xp_destroy_surface(pDRIDrawablePriv->sid);
free(pDRIDrawablePriv);
-
- /*
- * Now set the dix privates to NULL that were previously set.
- * This prevents reusing an invalid pointer.
- */
- if(pDrawable->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr)pDrawable;
-
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
- } else if(pDrawable->type == DRAWABLE_PIXMAP) {
- PixmapPtr pPix = (PixmapPtr)pDrawable;
-
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
- }
-
+
+ /*
+ * Now set the dix privates to NULL that were previously set.
+ * This prevents reusing an invalid pointer.
+ */
+ if(pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDrawable;
+
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
+ } else if(pDrawable->type == DRAWABLE_PIXMAP) {
+ PixmapPtr pPix = (PixmapPtr)pDrawable;
+
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
+ }
+
return FALSE;
}
}
-
+
pDRIDrawablePriv->key[0] = key[0];
pDRIDrawablePriv->key[1] = key[1];
-
+
++pDRIPriv->nrWindows;
-
+
/* and stash it by surface id */
if (surface_hash == NULL)
surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
x_hash_table_insert(surface_hash,
x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv);
-
+
/* track this in case this window is destroyed */
AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
-
+
/* Initialize shape */
DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
}
-
+
pDRIDrawablePriv->refCount++;
-
+
*surface_id = pDRIDrawablePriv->sid;
-
+
if (ret_key != NULL) {
ret_key[0] = pDRIDrawablePriv->key[0];
ret_key[1] = pDRIDrawablePriv->key[1];
}
-
+
if (notify != NULL) {
pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers,
notify, notify_data);
}
-
+
return TRUE;
}
@@ -476,7 +476,7 @@ DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
void (*notify) (void *, void *), void *notify_data)
{
DRIDrawablePrivPtr pDRIDrawablePriv;
-
+
if (pDrawable->type == DRAWABLE_WINDOW) {
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
} else if (pDrawable->type == DRAWABLE_PIXMAP) {
@@ -484,33 +484,33 @@ DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
} else {
return FALSE;
}
-
+
if (pDRIDrawablePriv != NULL) {
- /*
- * This doesn't seem to be used, because notify is NULL in all callers.
- */
-
+ /*
+ * This doesn't seem to be used, because notify is NULL in all callers.
+ */
+
if (notify != NULL) {
pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers,
notify, notify_data);
}
-
- --pDRIDrawablePriv->refCount;
-
- /*
- * Check if the drawable privates still have a reference to the
- * surface.
- */
-
+
+ --pDRIDrawablePriv->refCount;
+
+ /*
+ * Check if the drawable privates still have a reference to the
+ * surface.
+ */
+
if (pDRIDrawablePriv->refCount <= 0) {
/*
- * This calls back to DRIDrawablePrivDelete which
- * frees the private area and dispatches events, if needed.
- */
+ * This calls back to DRIDrawablePrivDelete which
+ * frees the private area and dispatches events, if needed.
+ */
FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
}
}
-
+
return TRUE;
}
@@ -526,7 +526,7 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
WindowPtr pWin = NULL;
PixmapPtr pPix = NULL;
-
+
if (pDrawable->type == DRAWABLE_WINDOW) {
pWin = (WindowPtr)pDrawable;
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
@@ -534,39 +534,39 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
pPix = (PixmapPtr)pDrawable;
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
}
-
+
if (pDRIDrawablePriv == NULL) {
- /*
- * We reuse __func__ and the resource type for the GLXPixmap code.
- * Attempt to free a pixmap buffer associated with the resource
- * if possible.
- */
- return DRIFreePixmapImp(pDrawable);
+ /*
+ * We reuse __func__ and the resource type for the GLXPixmap code.
+ * Attempt to free a pixmap buffer associated with the resource
+ * if possible.
+ */
+ return DRIFreePixmapImp(pDrawable);
}
if (pDRIDrawablePriv->drawableIndex != -1) {
/* release drawable table entry */
pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
}
-
+
if (pDRIDrawablePriv->sid != 0) {
- DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed);
+ DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed);
}
-
-
+
+
if (pDRIDrawablePriv->notifiers != NULL)
x_hook_free(pDRIDrawablePriv->notifiers);
-
+
free(pDRIDrawablePriv);
-
+
if (pDrawable->type == DRAWABLE_WINDOW) {
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
} else if (pDrawable->type == DRAWABLE_PIXMAP) {
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
}
-
+
--pDRIPriv->nrWindows;
-
+
return TRUE;
}
@@ -576,15 +576,15 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
+
if (pDRIDrawablePriv) {
/* FIXME: something? */
}
-
+
pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
-
+
(*pScreen->WindowExposures)(pWin, prgn, bsreg);
-
+
pScreen->WindowExposures = DRIWindowExposures;
}
@@ -594,20 +594,20 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIDrawablePrivPtr pDRIDrawablePriv;
-
+
if (pDRIPriv->nrWindows > 0) {
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- if (pDRIDrawablePriv != NULL) {
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ if (pDRIDrawablePriv != NULL) {
DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
- }
+ }
}
-
+
/* unwrap */
pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
-
+
/* call lower layers */
(*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
+
/* rewrap */
pScreen->CopyWindow = DRICopyWindow;
}
@@ -618,16 +618,16 @@ DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
ScreenPtr pScreen = pParent->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
int returnValue;
-
+
/* unwrap */
pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
+
/* call lower layers */
returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
-
+
/* rewrap */
pScreen->ValidateTree = DRIValidateTree;
-
+
return returnValue;
}
@@ -636,21 +636,21 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
{
ScreenPtr pScreen;
DRIScreenPrivPtr pDRIPriv;
-
+
if (pParent) {
pScreen = pParent->drawable.pScreen;
} else {
pScreen = pChild->drawable.pScreen;
}
pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
+
if (pDRIPriv->wrap.PostValidateTree) {
/* unwrap */
pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
+
/* call lower layers */
(*pScreen->PostValidateTree)(pParent, pChild, kind);
-
+
/* rewrap */
pScreen->PostValidateTree = DRIPostValidateTree;
}
@@ -662,16 +662,16 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIDrawablePrivPtr pDRIDrawablePriv;
-
+
if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
}
-
+
if (pDRIPriv->wrap.ClipNotify) {
pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
-
+
(*pScreen->ClipNotify)(pWin, dx, dy);
-
+
pScreen->ClipNotify = DRIClipNotify;
}
}
@@ -706,38 +706,38 @@ DRISurfaceNotify(xp_surface_id id, int kind)
{
DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
DRISurfaceNotifyArg arg;
-
+
arg.id = id;
arg.kind = kind;
-
+
if (surface_hash != NULL)
{
pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
x_cvt_uint_to_vptr(id), NULL);
}
-
+
if (pDRIDrawablePriv == NULL)
return;
-
+
if (kind == AppleDRISurfaceNotifyDestroyed)
{
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id));
+ x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id));
}
-
+
x_hook_run(pDRIDrawablePriv->notifiers, &arg);
-
+
if (kind == AppleDRISurfaceNotifyDestroyed)
{
- xp_error error;
-
- error = xp_destroy_surface(pDRIDrawablePriv->sid);
-
- if(error)
- ErrorF("%s: xp_destroy_surface failed: %d\n", __func__, error);
+ xp_error error;
+
+ error = xp_destroy_surface(pDRIDrawablePriv->sid);
+
+ if(error)
+ ErrorF("%s: xp_destroy_surface failed: %d\n", __func__, error);
- /* Guard against reuse, even though we are freeing after this. */
- pDRIDrawablePriv->sid = 0;
-
+ /* Guard against reuse, even though we are freeing after this. */
+ pDRIDrawablePriv->sid = 0;
+
FreeResourceByType(pDRIDrawablePriv->pDraw->id,
DRIDrawablePrivResType, FALSE);
}
@@ -748,29 +748,29 @@ DRISurfaceNotify(xp_surface_id id, int kind)
* and AppleSGLX.
*/
Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
- DrawablePtr pDrawable, char *path,
- size_t pathmax)
+ DrawablePtr pDrawable, char *path,
+ size_t pathmax)
{
DRIPixmapBufferPtr shared;
PixmapPtr pPix;
if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
+ return FALSE;
+
pPix = (PixmapPtr)pDrawable;
-
+
shared = malloc(sizeof(*shared));
if(NULL == shared) {
FatalError("failed to allocate DRIPixmapBuffer in %s\n", __func__);
}
-
+
shared->pDrawable = pDrawable;
shared->refCount = 1;
-
+
if(pDrawable->bitsPerPixel >= 24) {
- shared->bytesPerPixel = 4;
+ shared->bytesPerPixel = 4;
} else if(pDrawable->bitsPerPixel <= 16) {
- shared->bytesPerPixel = 2;
+ shared->bytesPerPixel = 2;
}
shared->width = pDrawable->width;
@@ -787,57 +787,57 @@ Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
if(-1 == shared->fd) {
- free(shared);
+ free(shared);
return FALSE;
}
shared->length = shared->width * shared->height * shared->bytesPerPixel;
if(-1 == ftruncate(shared->fd, shared->length)) {
- ErrorF("failed to ftruncate (extend) file.");
- shm_unlink(shared->shmPath);
- close(shared->fd);
- free(shared);
- return FALSE;
+ ErrorF("failed to ftruncate (extend) file.");
+ shm_unlink(shared->shmPath);
+ close(shared->fd);
+ free(shared);
+ return FALSE;
}
-
+
shared->buffer = mmap(NULL, shared->length,
PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, shared->fd, 0);
if(MAP_FAILED == shared->buffer) {
- ErrorF("failed to mmap shared memory.");
- shm_unlink(shared->shmPath);
- close(shared->fd);
- free(shared);
- return FALSE;
+ ErrorF("failed to mmap shared memory.");
+ shm_unlink(shared->shmPath);
+ close(shared->fd);
+ free(shared);
+ return FALSE;
}
strlcpy(path, shared->shmPath, pathmax);
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
-
+
AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
-
+
return TRUE;
}
Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
- int *pitch, int *bpp, void **ptr) {
+ int *pitch, int *bpp, void **ptr) {
PixmapPtr pPix;
DRIPixmapBufferPtr shared;
-
+
if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
+ return FALSE;
+
pPix = (PixmapPtr)pDrawable;
-
+
shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
-
+
if(NULL == shared)
- return FALSE;
-
+ return FALSE;
+
assert(pDrawable->width == shared->width);
assert(pDrawable->height == shared->height);
@@ -846,7 +846,7 @@ Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
*bpp = shared->bytesPerPixel;
*pitch = shared->width * shared->bytesPerPixel;
*ptr = shared->buffer;
-
+
return TRUE;
}
@@ -854,30 +854,30 @@ static Bool
DRIFreePixmapImp(DrawablePtr pDrawable) {
DRIPixmapBufferPtr shared;
PixmapPtr pPix;
-
+
if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
+ return FALSE;
+
pPix = (PixmapPtr)pDrawable;
-
+
shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
-
+
if(NULL == shared)
- return FALSE;
-
+ return FALSE;
+
close(shared->fd);
munmap(shared->buffer, shared->length);
shm_unlink(shared->shmPath);
free(shared);
-
+
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer)NULL);
-
+
return TRUE;
}
void
DRIDestroyPixmap(DrawablePtr pDrawable) {
if(DRIFreePixmapImp(pDrawable))
- FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE);
-
+ FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE);
+
}
diff --git a/hw/xquartz/xpr/dri.h b/hw/xquartz/xpr/dri.h
index 48fea3668..11675b2b1 100644
--- a/hw/xquartz/xpr/dri.h
+++ b/hw/xquartz/xpr/dri.h
@@ -1,7 +1,7 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright (c) 2002, 2009 Apple Computer, Inc.
+Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Jens Owen <jens@precisioninsight.com>
- *
+ * Jeremy Huddleston <jeremyhu@apple.com>
*/
/* Prototypes for AppleDRI functions */
@@ -89,10 +89,10 @@ extern Bool DRICreateSurface(ScreenPtr pScreen,
void *notify_data);
extern Bool DRIDestroySurface(ScreenPtr pScreen,
- Drawable id,
- DrawablePtr pDrawable,
- void (*notify) (void *arg, void *data),
- void *notify_data);
+ Drawable id,
+ DrawablePtr pDrawable,
+ void (*notify) (void *arg, void *data),
+ void *notify_data);
extern Bool DRIDrawablePrivDelete(pointer pResource,
XID id);
@@ -116,8 +116,8 @@ extern void DRIClipNotify(WindowPtr pWin,
int dy);
extern void DRIWindowExposures(WindowPtr pWin,
- RegionPtr prgn,
- RegionPtr bsreg);
+ RegionPtr prgn,
+ RegionPtr bsreg);
extern void DRISurfaceNotify (xp_surface_id id, int kind);
@@ -126,11 +126,11 @@ extern void DRIQueryVersion(int *majorVersion,
int *patchVersion);
extern Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
- DrawablePtr pDrawable, char *path,
- size_t pathmax);
+ DrawablePtr pDrawable, char *path,
+ size_t pathmax);
extern Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
- int *pitch, int *bpp, void **ptr);
+ int *pitch, int *bpp, void **ptr);
extern void DRIDestroyPixmap(DrawablePtr pDrawable);
diff --git a/hw/xquartz/xpr/driWrap.c b/hw/xquartz/xpr/driWrap.c
index de5c4a2cf..ccc49b786 100644
--- a/hw/xquartz/xpr/driWrap.c
+++ b/hw/xquartz/xpr/driWrap.c
@@ -1,27 +1,32 @@
/*
-Copyright (c) 2009 Apple Computer, Inc.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
+ * Copyright (c) 2009-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -63,13 +68,13 @@ static DevPrivateKeyRec driWrapScreenKeyRec;
static GCOps driGCOps;
#define wrap(priv, real, member, func) { \
- priv->member = real->member; \
- real->member = func; \
- }
+ priv->member = real->member; \
+ real->member = func; \
+}
#define unwrap(priv, real, member) { \
- real->member = priv->member; \
- }
+ real->member = priv->member; \
+}
static DRIGCRec *
DRIGetGCPriv(GCPtr pGC) {
@@ -79,7 +84,7 @@ DRIGetGCPriv(GCPtr pGC) {
static void
DRIUnwrapGC(GCPtr pGC) {
DRIGCRec *pGCPriv = DRIGetGCPriv(pGC);
-
+
pGC->ops = pGCPriv->originalOps;
}
@@ -90,34 +95,34 @@ DRIWrapGC(GCPtr pGC) {
static void
DRISurfaceSetDrawable(DrawablePtr pDraw,
- DRISavedDrawableState *saved) {
+ DRISavedDrawableState *saved) {
saved->didSave = FALSE;
if(pDraw->type == DRAWABLE_PIXMAP) {
- int pitch, width, height, bpp;
- void *buffer;
-
- if(DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp, &buffer)) {
- PixmapPtr pPix = (PixmapPtr)pDraw;
-
- saved->devKind = pPix->devKind;
- saved->devPrivate.ptr = pPix->devPrivate.ptr;
- saved->didSave = TRUE;
-
- pPix->devKind = pitch;
- pPix->devPrivate.ptr = buffer;
- }
+ int pitch, width, height, bpp;
+ void *buffer;
+
+ if(DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp, &buffer)) {
+ PixmapPtr pPix = (PixmapPtr)pDraw;
+
+ saved->devKind = pPix->devKind;
+ saved->devPrivate.ptr = pPix->devPrivate.ptr;
+ saved->didSave = TRUE;
+
+ pPix->devKind = pitch;
+ pPix->devPrivate.ptr = buffer;
+ }
}
}
static void
DRISurfaceRestoreDrawable(DrawablePtr pDraw,
- DRISavedDrawableState *saved) {
+ DRISavedDrawableState *saved) {
PixmapPtr pPix = (PixmapPtr)pDraw;
-
+
if(!saved->didSave)
- return;
-
+ return;
+
pPix->devKind = saved->devKind;
pPix->devPrivate.ptr = saved->devPrivate.ptr;
}
@@ -127,11 +132,11 @@ DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
DDXPointPtr pptInit, int *pwidthInit,
int sorted) {
DRISavedDrawableState saved;
-
+
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted);
DRIWrapGC(pGC);
@@ -146,11 +151,11 @@ DRISetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit, nspans, sorted);
-
+
DRIWrapGC(pGC);
DRISurfaceRestoreDrawable(dst, &saved);
@@ -161,62 +166,62 @@ DRIPutImage(DrawablePtr dst, GCPtr pGC,
int depth, int x, int y, int w, int h,
int leftPad, int format, char *pBits) {
DRISavedDrawableState saved;
-
+
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->PutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pBits);
-
+
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
static RegionPtr
DRICopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
- int srcx, int srcy, int w, int h,
- int dstx, int dsty) {
+ int srcx, int srcy, int w, int h,
+ int dstx, int dsty) {
RegionPtr pReg;
DRISavedDrawableState pSrcSaved, dstSaved;
DRISurfaceSetDrawable(pSrc, &pSrcSaved);
DRISurfaceSetDrawable(dst, &dstSaved);
-
+
DRIUnwrapGC(pGC);
-
+
pReg = pGC->ops->CopyArea(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty);
-
+
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(pSrc, &pSrcSaved);
DRISurfaceRestoreDrawable(dst, &dstSaved);
-
+
return pReg;
}
static RegionPtr
DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst,
- GCPtr pGC, int srcx, int srcy,
- int w, int h, int dstx, int dsty,
- unsigned long plane) {
+ GCPtr pGC, int srcx, int srcy,
+ int w, int h, int dstx, int dsty,
+ unsigned long plane) {
RegionPtr pReg;
DRISavedDrawableState pSrcSaved, dstSaved;
-
+
DRISurfaceSetDrawable(pSrc, &pSrcSaved);
DRISurfaceSetDrawable(dst, &dstSaved);
-
-
+
+
DRIUnwrapGC(pGC);
pReg = pGC->ops->CopyPlane(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty,
- plane);
+ plane);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(pSrc, &pSrcSaved);
DRISurfaceRestoreDrawable(dst, &dstSaved);
-
+
return pReg;
}
@@ -230,9 +235,9 @@ DRIPolyPoint(DrawablePtr dst, GCPtr pGC,
DRIUnwrapGC(pGC);
pGC->ops->PolyPoint(dst, pGC, mode, npt, pptInit);
-
+
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
@@ -242,11 +247,11 @@ DRIPolylines(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
pGC->ops->Polylines(dst, pGC, mode, npt, pptInit);
-
+
DRIWrapGC(pGC);
DRISurfaceRestoreDrawable(dst, &saved);
@@ -258,41 +263,41 @@ DRIPolySegment(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->PolySegment(dst, pGC, nseg, pSeg);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
static void
DRIPolyRectangle(DrawablePtr dst, GCPtr pGC,
- int nRects, xRectangle *pRects) {
+ int nRects, xRectangle *pRects) {
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
DRIUnwrapGC(pGC);
-
+
pGC->ops->PolyRectangle(dst, pGC, nRects, pRects);
-
+
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
static void
DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs) {
DRISavedDrawableState saved;
-
+
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
pGC->ops->PolyArc(dst, pGC, narcs, parcs);
-
+
DRIWrapGC(pGC);
DRISurfaceRestoreDrawable(dst, &saved);
@@ -305,13 +310,13 @@ DRIFillPolygon(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit);
-
+
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
@@ -321,13 +326,13 @@ DRIPolyFillRect(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
@@ -337,24 +342,24 @@ DRIPolyFillArc(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
static int
DRIPolyText8(DrawablePtr dst, GCPtr pGC,
- int x, int y, int count, char *chars) {
+ int x, int y, int count, char *chars) {
int ret;
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
ret = pGC->ops->PolyText8(dst, pGC, x, y, count, chars);
@@ -362,26 +367,26 @@ DRIPolyText8(DrawablePtr dst, GCPtr pGC,
DRIWrapGC(pGC);
DRISurfaceRestoreDrawable(dst, &saved);
-
+
return ret;
}
static int
DRIPolyText16(DrawablePtr dst, GCPtr pGC,
- int x, int y, int count, unsigned short *chars) {
+ int x, int y, int count, unsigned short *chars) {
int ret;
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
ret = pGC->ops->PolyText16(dst, pGC, x, y, count, chars);
-
+
DRIWrapGC(pGC);
DRISurfaceRestoreDrawable(dst, &saved);
-
+
return ret;
}
@@ -391,11 +396,11 @@ DRIImageText8(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
pGC->ops->ImageText8(dst, pGC, x, y, count, chars);
-
+
DRIWrapGC(pGC);
DRISurfaceRestoreDrawable(dst, &saved);
@@ -407,13 +412,13 @@ DRIImageText16(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->ImageText16(dst, pGC, x, y, count, chars);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
@@ -424,29 +429,29 @@ DRIImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
static void DRIPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, pointer pglyphBase) {
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase) {
DRISavedDrawableState saved;
DRISurfaceSetDrawable(dst, &saved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->PolyGlyphBlt(dst, pGC, x, y, nglyph, ppci, pglyphBase);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(dst, &saved);
}
@@ -454,16 +459,16 @@ static void
DRIPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
int dx, int dy, int xOrg, int yOrg) {
DRISavedDrawableState bitMapSaved, dstSaved;
-
+
DRISurfaceSetDrawable(&pBitMap->drawable, &bitMapSaved);
DRISurfaceSetDrawable(dst, &dstSaved);
-
+
DRIUnwrapGC(pGC);
-
+
pGC->ops->PushPixels(pGC, pBitMap, dst, dx, dy, xOrg, yOrg);
DRIWrapGC(pGC);
-
+
DRISurfaceRestoreDrawable(&pBitMap->drawable, &bitMapSaved);
DRISurfaceRestoreDrawable(dst, &dstSaved);
}
@@ -499,19 +504,19 @@ DRICreateGC(GCPtr pGC) {
DRIWrapScreenRec *pScreenPriv;
DRIGCRec *pGCPriv;
Bool ret;
-
+
pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, driWrapScreenKey);
pGCPriv = DRIGetGCPriv(pGC);
-
+
unwrap(pScreenPriv, pScreen, CreateGC);
ret = pScreen->CreateGC(pGC);
-
+
if(ret) {
- pGCPriv->originalOps = pGC->ops;
- pGC->ops = &driGCOps;
+ pGCPriv->originalOps = pGC->ops;
+ pGC->ops = &driGCOps;
}
-
+
wrap(pScreenPriv, pScreen, CreateGC, DRICreateGC);
return ret;
@@ -522,13 +527,13 @@ DRICreateGC(GCPtr pGC) {
Bool
DRIWrapInit(ScreenPtr pScreen) {
DRIWrapScreenRec *pScreenPriv;
-
+
if(!dixRegisterPrivateKey(&driGCKeyRec, PRIVATE_GC, sizeof(DRIGCRec)))
- return FALSE;
-
+ return FALSE;
+
if(!dixRegisterPrivateKey(&driWrapScreenKeyRec, PRIVATE_SCREEN, sizeof(DRIWrapScreenRec)))
- return FALSE;
-
+ return FALSE;
+
pScreenPriv = dixGetPrivateAddr(&pScreen->devPrivates, &driWrapScreenKeyRec);
pScreenPriv->CreateGC = pScreen->CreateGC;
pScreen->CreateGC = DRICreateGC;
diff --git a/hw/xquartz/xpr/driWrap.h b/hw/xquartz/xpr/driWrap.h
index d31d5ddaf..5689dc3ee 100644
--- a/hw/xquartz/xpr/driWrap.h
+++ b/hw/xquartz/xpr/driWrap.h
@@ -1,27 +1,32 @@
/*
-Copyright (c) 2009 Apple Computer, Inc.
-All Rights Reserved.
+ * Copyright (c) 2009-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
#ifndef DRIWRAP_H
#include "scrnintstr.h"
diff --git a/hw/xquartz/xpr/dristruct.h b/hw/xquartz/xpr/dristruct.h
index 19d78a973..3e09fb91a 100644
--- a/hw/xquartz/xpr/dristruct.h
+++ b/hw/xquartz/xpr/dristruct.h
@@ -1,7 +1,7 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright (c) 2002 Apple Computer, Inc.
+Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Jens Owen <jens@precisioninsight.com>
- *
+ * Jeremy Huddleston <jeremyhu@apple.com>
*/
#ifndef DRI_STRUCT_H
@@ -41,10 +41,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DRI_MAX_DRAWABLES 256
#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
+dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pPix)->devPrivates, DRIPixmapPrivKey))
+dixLookupPrivate(&(pPix)->devPrivates, DRIPixmapPrivKey))
typedef struct _DRIDrawablePrivRec
{
@@ -62,7 +62,7 @@ typedef struct _DRIDrawablePrivRec
#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
- DRIScreenPrivKey))
+ DRIScreenPrivKey))
typedef struct _DRIScreenPrivRec
diff --git a/hw/xquartz/xpr/x-hash.c b/hw/xquartz/xpr/x-hash.c
index 7c6a67bd1..647955bd2 100644
--- a/hw/xquartz/xpr/x-hash.c
+++ b/hw/xquartz/xpr/x-hash.c
@@ -1,31 +1,32 @@
/* x-hash.c - basic hash tables
-
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
@@ -40,7 +41,7 @@ struct x_hash_table_struct {
unsigned int bucket_index;
unsigned int total_keys;
x_list **buckets;
-
+
x_hash_fun *hash_key;
x_compare_fun *compare_keys;
x_destroy_fun *destroy_key;
@@ -75,7 +76,7 @@ hash_table_destroy_item (x_hash_table *h, void *k, void *v)
{
if (h->destroy_key != 0)
(*h->destroy_key) (k);
-
+
if (h->destroy_value != 0)
(*h->destroy_value) (v);
}
@@ -106,38 +107,38 @@ hash_table_split (x_hash_table *h)
int new_size, old_size;
size_t b;
int i;
-
+
if (h->bucket_index == N_BUCKET_SIZES - 1)
return;
-
+
old_size = hash_table_total_buckets (h);
old = h->buckets;
-
+
h->bucket_index++;
-
+
new_size = hash_table_total_buckets (h);
new = calloc (new_size, sizeof (x_list *));
-
+
if (new == 0)
{
h->bucket_index--;
return;
}
-
+
for (i = 0; i < old_size; i++)
{
for (node = old[i]; node != 0; node = next)
{
next = node->next;
item = node->data;
-
+
b = hash_table_hash_key (h, ITEM_KEY (item)) % new_size;
-
+
node->next = new[b];
new[b] = node;
}
}
-
+
h->buckets = new;
free (old);
}
@@ -149,14 +150,14 @@ X_PFX (hash_table_new) (x_hash_fun *hash,
x_destroy_fun *value_destroy)
{
x_hash_table *h;
-
+
h = calloc (1, sizeof (x_hash_table));
if (h == 0)
return 0;
-
+
h->bucket_index = 0;
h->buckets = calloc (hash_table_total_buckets (h), sizeof (x_list *));
-
+
if (h->buckets == 0)
{
free (h);
@@ -167,7 +168,7 @@ X_PFX (hash_table_new) (x_hash_fun *hash,
h->compare_keys = compare;
h->destroy_key = key_destroy;
h->destroy_value = value_destroy;
-
+
return h;
}
@@ -176,11 +177,11 @@ X_PFX (hash_table_free) (x_hash_table *h)
{
int n, i;
x_list *node, *item;
-
+
assert (h != NULL);
-
+
n = hash_table_total_buckets (h);
-
+
for (i = 0; i < n; i++)
{
for (node = h->buckets[i]; node != 0; node = node->next)
@@ -191,7 +192,7 @@ X_PFX (hash_table_free) (x_hash_table *h)
}
X_PFX (list_free) (h->buckets[i]);
}
-
+
free (h->buckets);
free (h);
}
@@ -200,7 +201,7 @@ X_EXTERN unsigned int
X_PFX (hash_table_size) (x_hash_table *h)
{
assert (h != NULL);
-
+
return h->total_keys;
}
@@ -209,16 +210,16 @@ hash_table_modify (x_hash_table *h, void *k, void *v, int replace)
{
size_t hash_value;
x_list *node, *item;
-
+
assert (h != NULL);
-
+
hash_value = hash_table_hash_key (h, k);
-
+
for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
node != 0; node = node->next)
{
item = node->data;
-
+
if (hash_table_compare_keys (h, ITEM_KEY (item), k))
{
if (replace)
@@ -236,15 +237,15 @@ hash_table_modify (x_hash_table *h, void *k, void *v, int replace)
return;
}
}
-
+
/* Key isn't already in the table. Insert it. */
-
+
if (h->total_keys + 1
> hash_table_total_buckets (h) * SPLIT_THRESHOLD_FACTOR)
{
hash_table_split (h);
}
-
+
hash_value = hash_value % hash_table_total_buckets (h);
h->buckets[hash_value] = X_PFX (list_prepend) (h->buckets[hash_value],
ITEM_NEW (k, v));
@@ -268,16 +269,16 @@ X_PFX (hash_table_remove) (x_hash_table *h, void *k)
{
size_t hash_value;
x_list **ptr, *item;
-
+
assert (h != NULL);
-
+
hash_value = hash_table_hash_key (h, k);
-
+
for (ptr = &h->buckets[hash_value % hash_table_total_buckets (h)];
*ptr != 0; ptr = &((*ptr)->next))
{
item = (*ptr)->data;
-
+
if (hash_table_compare_keys (h, ITEM_KEY (item), k))
{
hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item));
@@ -296,29 +297,29 @@ X_PFX (hash_table_lookup) (x_hash_table *h, void *k, void **k_ret)
{
size_t hash_value;
x_list *node, *item;
-
+
assert (h != NULL);
-
+
hash_value = hash_table_hash_key (h, k);
-
+
for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
node != 0; node = node->next)
{
item = node->data;
-
+
if (hash_table_compare_keys (h, ITEM_KEY (item), k))
{
if (k_ret != 0)
- *k_ret = ITEM_KEY (item);
-
+ *k_ret = ITEM_KEY (item);
+
return ITEM_VALUE (item);
}
}
-
+
if (k_ret != 0)
*k_ret = 0;
-
- return 0;
+
+ return 0;
}
X_EXTERN void
@@ -327,11 +328,11 @@ X_PFX (hash_table_foreach) (x_hash_table *h,
{
int i, n;
x_list *node, *item;
-
+
assert (h != NULL);
-
+
n = hash_table_total_buckets (h);
-
+
for (i = 0; i < n; i++)
{
for (node = h->buckets[i]; node != 0; node = node->next)
diff --git a/hw/xquartz/xpr/x-hash.h b/hw/xquartz/xpr/x-hash.h
index f876b6b71..a7eb0a642 100644
--- a/hw/xquartz/xpr/x-hash.h
+++ b/hw/xquartz/xpr/x-hash.h
@@ -1,31 +1,33 @@
/* x-hash.h -- basic hash table class
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
#ifndef X_HASH_H
#define X_HASH_H 1
@@ -44,9 +46,9 @@ typedef void (x_hash_foreach_fun) (void *k, void *v, void *data);
#include "x-list.h"
X_EXTERN x_hash_table *X_PFX (hash_table_new) (x_hash_fun *hash,
- x_compare_fun *compare,
- x_destroy_fun *key_destroy,
- x_destroy_fun *value_destroy);
+ x_compare_fun *compare,
+ x_destroy_fun *key_destroy,
+ x_destroy_fun *value_destroy);
X_EXTERN void X_PFX (hash_table_free) (x_hash_table *h);
X_EXTERN unsigned int X_PFX (hash_table_size) (x_hash_table *h);
@@ -55,10 +57,10 @@ X_EXTERN void X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v);
X_EXTERN void X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v);
X_EXTERN void X_PFX (hash_table_remove) (x_hash_table *h, void *k);
X_EXTERN void *X_PFX (hash_table_lookup) (x_hash_table *h,
- void *k, void **k_ret);
+ void *k, void **k_ret);
X_EXTERN void X_PFX (hash_table_foreach) (x_hash_table *h,
- x_hash_foreach_fun *fun,
- void *data);
+ x_hash_foreach_fun *fun,
+ void *data);
/* Conversion between unsigned int (e.g. xp_resource_id) and void pointer */
@@ -82,7 +84,7 @@ X_PFX (cvt_vptr_to_uint) (void * val)
unsigned int uv = (unsigned int)sv;
/* If this assert fails, chances are val actually is a pointer,
- or there's been memory corruption */
+ or there's been memory corruption */
assert(sv == uv);
return uv;
diff --git a/hw/xquartz/xpr/x-hook.c b/hw/xquartz/xpr/x-hook.c
index d9f011553..b7d56ed2c 100644
--- a/hw/xquartz/xpr/x-hook.c
+++ b/hw/xquartz/xpr/x-hook.c
@@ -1,31 +1,33 @@
/* x-hook.c
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
@@ -52,21 +54,21 @@ X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data)
{
x_list *node, *cell;
x_list *to_delete = NULL;
-
+
for (node = lst; node != NULL; node = node->next)
{
- cell = node->data;
- if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data)
- to_delete = X_PFX (list_prepend) (to_delete, cell);
+ cell = node->data;
+ if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data)
+ to_delete = X_PFX (list_prepend) (to_delete, cell);
}
-
+
for (node = to_delete; node != NULL; node = node->next)
{
- cell = node->data;
- lst = X_PFX (list_remove) (lst, cell);
- CELL_FREE (cell);
+ cell = node->data;
+ lst = X_PFX (list_remove) (lst, cell);
+ CELL_FREE (cell);
}
-
+
X_PFX (list_free) (to_delete);
return lst;
}
@@ -78,28 +80,28 @@ X_PFX (hook_run) (x_list *lst, void *arg)
x_hook_function **fun;
void **data;
int length, i;
-
+
if(!lst)
return;
-
+
length = X_PFX (list_length) (lst);
fun = malloc(sizeof (x_hook_function *) * length);
data = malloc(sizeof (void *) * length);
-
+
if(!fun || !data) {
FatalError("Failed to allocate memory in %s\n", __func__);
}
for (i = 0, node = lst; node != NULL; node = node->next, i++)
{
- cell = node->data;
- fun[i] = CELL_FUN (cell);
- data[i] = CELL_DATA (cell);
+ cell = node->data;
+ fun[i] = CELL_FUN (cell);
+ data[i] = CELL_DATA (cell);
}
-
+
for (i = 0; i < length; i++)
{
- (*fun[i]) (arg, data[i]);
+ (*fun[i]) (arg, data[i]);
}
free(fun);
@@ -110,11 +112,11 @@ X_EXTERN void
X_PFX (hook_free) (x_list *lst)
{
x_list *node;
-
+
for (node = lst; node != NULL; node = node->next)
{
- CELL_FREE (node->data);
+ CELL_FREE (node->data);
}
-
+
X_PFX (list_free) (lst);
}
diff --git a/hw/xquartz/xpr/x-hook.h b/hw/xquartz/xpr/x-hook.h
index 392352d50..55d60b7c6 100644
--- a/hw/xquartz/xpr/x-hook.h
+++ b/hw/xquartz/xpr/x-hook.h
@@ -1,31 +1,33 @@
/* x-hook.h -- lists of function,data pairs to call.
+ *
+ * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
#ifndef X_HOOK_H
#define X_HOOK_H 1
diff --git a/hw/xquartz/xpr/x-list.c b/hw/xquartz/xpr/x-list.c
index 77c9309aa..489494a91 100644
--- a/hw/xquartz/xpr/x-list.c
+++ b/hw/xquartz/xpr/x-list.c
@@ -1,31 +1,33 @@
/* x-list.c
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
@@ -60,11 +62,11 @@ X_EXTERN void
X_PFX (list_free_1) (x_list *node)
{
assert (node != NULL);
-
+
pthread_mutex_lock (&freelist_lock);
-
+
list_free_1 (node);
-
+
pthread_mutex_unlock (&freelist_lock);
}
@@ -72,15 +74,15 @@ X_EXTERN void
X_PFX (list_free) (x_list *lst)
{
x_list *next;
-
+
pthread_mutex_lock (&freelist_lock);
-
+
for (; lst != NULL; lst = next)
{
next = lst->next;
list_free_1 (lst);
}
-
+
pthread_mutex_unlock (&freelist_lock);
}
@@ -88,32 +90,32 @@ X_EXTERN x_list *
X_PFX (list_prepend) (x_list *lst, void *data)
{
x_list *node;
-
+
pthread_mutex_lock (&freelist_lock);
-
+
if (freelist == NULL)
{
x_list_block *b;
int i;
-
+
b = malloc (sizeof (x_list_block));
assert(b != NULL);
-
+
for (i = 0; i < NODES_PER_BLOCK - 1; i++)
b->l[i].next = &(b->l[i+1]);
b->l[i].next = NULL;
-
+
freelist = b->l;
}
-
+
node = freelist;
freelist = node->next;
-
+
pthread_mutex_unlock (&freelist_lock);
-
+
node->next = lst;
node->data = data;
-
+
return node;
}
@@ -121,16 +123,16 @@ X_EXTERN x_list *
X_PFX (list_append) (x_list *lst, void *data)
{
x_list *head = lst;
-
+
if (lst == NULL)
return X_PFX (list_prepend) (NULL, data);
-
+
while (lst->next != NULL)
lst = lst->next;
-
- lst->next = X_PFX (list_prepend) (NULL, data);
-
- return head;
+
+ lst->next = X_PFX (list_prepend) (NULL, data);
+
+ return head;
}
X_EXTERN x_list *
@@ -145,7 +147,7 @@ X_PFX (list_reverse) (x_list *lst)
head = lst;
lst = next;
}
-
+
return head;
}
@@ -157,7 +159,7 @@ X_PFX (list_find) (x_list *lst, void *data)
if (lst->data == data)
return lst;
}
-
+
return NULL;
}
@@ -166,15 +168,15 @@ X_PFX (list_nth) (x_list *lst, int n)
{
while (n-- > 0 && lst != NULL)
lst = lst->next;
-
- return lst;
+
+ return lst;
}
X_EXTERN x_list *
X_PFX (list_pop) (x_list *lst, void **data_ret)
{
void *data = NULL;
-
+
if (lst != NULL)
{
x_list *tem = lst;
@@ -182,11 +184,11 @@ X_PFX (list_pop) (x_list *lst, void **data_ret)
lst = lst->next;
X_PFX (list_free_1) (tem);
}
-
+
if (data_ret != NULL)
*data_ret = data;
-
- return lst;
+
+ return lst;
}
X_EXTERN x_list *
@@ -194,13 +196,13 @@ X_PFX (list_filter) (x_list *lst,
int (*pred) (void *item, void *data), void *data)
{
x_list *ret = NULL, *node;
-
+
for (node = lst; node != NULL; node = node->next)
{
if ((*pred) (node->data, data))
ret = X_PFX (list_prepend) (ret, node->data);
}
-
+
return X_PFX (list_reverse) (ret);
}
@@ -209,12 +211,12 @@ X_PFX (list_map) (x_list *lst,
void *(*fun) (void *item, void *data), void *data)
{
x_list *ret = NULL, *node;
-
+
for (node = lst; node != NULL; node = node->next)
{
X_PFX (list_prepend) (ret, fun (node->data, data));
}
-
+
return X_PFX (list_reverse) (ret);
}
@@ -222,12 +224,12 @@ X_EXTERN x_list *
X_PFX (list_copy) (x_list *lst)
{
x_list *copy = NULL;
-
+
for (; lst != NULL; lst = lst->next)
{
copy = X_PFX (list_prepend) (copy, lst->data);
}
-
+
return X_PFX (list_reverse) (copy);
}
@@ -235,11 +237,11 @@ X_EXTERN x_list *
X_PFX (list_remove) (x_list *lst, void *data)
{
x_list **ptr, *node;
-
+
for (ptr = &lst; *ptr != NULL;)
{
node = *ptr;
-
+
if (node->data == data)
{
*ptr = node->next;
@@ -248,7 +250,7 @@ X_PFX (list_remove) (x_list *lst, void *data)
else
ptr = &((*ptr)->next);
}
-
+
return lst;
}
@@ -256,11 +258,11 @@ X_EXTERN unsigned int
X_PFX (list_length) (x_list *lst)
{
unsigned int n;
-
+
n = 0;
for (; lst != NULL; lst = lst->next)
n++;
-
+
return n;
}
@@ -282,35 +284,35 @@ list_sort_1 (x_list *lst, int length,
x_list *mid, *ptr;
x_list *out_head, *out;
int mid_point, i;
-
+
/* This is a standard (stable) list merge sort */
-
+
if (length < 2)
return lst;
-
+
/* Calculate the halfway point. Split the list into two sub-lists. */
-
+
mid_point = length / 2;
ptr = lst;
for (i = mid_point - 1; i > 0; i--)
ptr = ptr->next;
mid = ptr->next;
ptr->next = NULL;
-
+
/* Sort each sub-list. */
-
+
lst = list_sort_1 (lst, mid_point, less);
mid = list_sort_1 (mid, length - mid_point, less);
-
+
/* Then merge them back together. */
-
+
assert (lst != NULL && mid != NULL);
-
+
if ((*less) (mid->data, lst->data))
out = out_head = mid, mid = mid->next;
else
out = out_head = lst, lst = lst->next;
-
+
while (lst != NULL && mid != NULL)
{
if ((*less) (mid->data, lst->data))
@@ -318,12 +320,12 @@ list_sort_1 (x_list *lst, int length,
else
out = out->next = lst, lst = lst->next;
}
-
+
if (lst != NULL)
out->next = lst;
else
out->next = mid;
-
+
return out_head;
}
@@ -331,8 +333,8 @@ X_EXTERN x_list *
X_PFX (list_sort) (x_list *lst, int (*less) (const void *, const void *))
{
int length;
-
+
length = X_PFX (list_length) (lst);
-
+
return list_sort_1 (lst, length, less);
}
diff --git a/hw/xquartz/xpr/x-list.h b/hw/xquartz/xpr/x-list.h
index 04af024a2..fd0bdfb1d 100644
--- a/hw/xquartz/xpr/x-list.h
+++ b/hw/xquartz/xpr/x-list.h
@@ -1,31 +1,33 @@
/* x-list.h -- simple list type
+ *
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization. */
#ifndef X_LIST_H
#define X_LIST_H 1
@@ -72,6 +74,6 @@ X_EXTERN void X_PFX (list_foreach) (x_list *lst, void (*fun)
void *user_data);
X_EXTERN x_list *X_PFX (list_sort) (x_list *lst, int (*less) (const void *,
- const void *));
+ const void *));
#endif /* X_LIST_H */
diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h
index 0b138ddd7..0fe3716e5 100644
--- a/hw/xquartz/xpr/xpr.h
+++ b/hw/xquartz/xpr/xpr.h
@@ -2,6 +2,7 @@
* Xplugin rootless implementation
*
* Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -60,10 +61,10 @@ void QuartzResumeXCursor(ScreenPtr pScreen);
#include <X11/extensions/applewmconst.h>
static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
-0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
+ 0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
};
static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
-20, 21, 22, 23, 19, 18,
+ 20, 21, 22, 23, 19, 18,
};
#endif /* XPR_H */
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index b6b9a5fc8..1239fea35 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -1,7 +1,7 @@
/*
* Xplugin rootless implementation functions for AppleWM extension
*
- * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Apple Computer, Inc. All rights reserved.
* Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -43,14 +43,12 @@
#include "quartz.h"
#include "x-hash.h"
-static int xprSetWindowLevel(
- WindowPtr pWin,
- int level)
+static int xprSetWindowLevel(WindowPtr pWin, int level)
{
xp_window_id wid;
xp_window_changes wc;
RootlessWindowRec *winRec;
-
+
// AppleWMNumWindowLevels is allowed, but is only set by the server
// for the root window.
if (level < 0 || level >= AppleWMNumWindowLevels) {
@@ -60,10 +58,10 @@ static int xprSetWindowLevel(
wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE));
if (wid == 0)
return BadWindow;
-
+
RootlessStopDrawing (pWin, FALSE);
winRec = WINREC(pWin);
-
+
if(!winRec)
return BadWindow;
@@ -77,9 +75,9 @@ static int xprSetWindowLevel(
if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) {
return BadValue;
}
-
+
winRec->level = level;
-
+
return Success;
}
@@ -87,11 +85,11 @@ static int xprSetWindowLevel(
static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) {
xp_window_id child_wid, parent_wid;
xp_window_changes wc;
-
+
child_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinChild, TRUE));
if (child_wid == 0)
return BadWindow;
-
+
if(pWinParent) {
parent_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinParent, TRUE));
if (parent_wid == 0)
@@ -99,40 +97,40 @@ static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) {
} else {
parent_wid = 0;
}
-
+
wc.transient_for = parent_wid;
-
+
RootlessStopDrawing (pWinChild, FALSE);
-
+
if (xp_configure_window(child_wid, XP_ATTACH_TRANSIENT, &wc) != Success) {
return BadValue;
}
-
+
return Success;
}
#endif
static int xprFrameDraw(
- WindowPtr pWin,
- xp_frame_class class,
- xp_frame_attr attr,
- const BoxRec *outer,
- const BoxRec *inner,
- unsigned int title_len,
- const unsigned char *title_bytes)
+ WindowPtr pWin,
+ xp_frame_class class,
+ xp_frame_attr attr,
+ const BoxRec *outer,
+ const BoxRec *inner,
+ unsigned int title_len,
+ const unsigned char *title_bytes)
{
xp_window_id wid;
-
+
wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, FALSE));
if (wid == 0)
return BadWindow;
-
+
if (xp_frame_draw (wid, class, attr, outer, inner,
title_len, title_bytes) != Success)
{
return BadValue;
}
-
+
return Success;
}
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index 2b31865a5..a1260507f 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -70,20 +70,20 @@ load_cursor(CursorPtr src, int screen)
uint32_t rowbytes;
int width, height;
int hot_x, hot_y;
-
+
uint32_t fg_color, bg_color;
uint8_t *srow, *sptr;
uint8_t *mrow, *mptr;
uint32_t *drow, *dptr;
unsigned xcount, ycount;
-
+
xp_error err;
-
+
width = src->bits->width;
height = src->bits->height;
hot_x = src->bits->xhot;
hot_y = src->bits->yhot;
-
+
#ifdef ARGB_CURSOR
if (src->bits->argb != NULL)
{
@@ -110,15 +110,15 @@ load_cursor(CursorPtr src, int screen)
fg_color <<= 16;
fg_color |= src->foreGreen & 0xFF00;
fg_color |= src->foreBlue >> 8;
-
+
bg_color = 0xFF00 | (src->backRed >> 8);
bg_color <<= 16;
bg_color |= src->backGreen & 0xFF00;
bg_color |= src->backBlue >> 8;
-
+
fg_color = htonl(fg_color);
bg_color = htonl(bg_color);
-
+
/* round up to 8 pixel boundary so we can convert whole bytes */
rowbytes = ((src->bits->width * 4) + 31) & ~31;
data = malloc(rowbytes * src->bits->height);
@@ -132,18 +132,18 @@ load_cursor(CursorPtr src, int screen)
ycount = src->bits->height;
srow = src->bits->source; mrow = src->bits->mask;
drow = data;
-
+
while (ycount-- > 0)
{
xcount = bits_to_bytes(src->bits->width);
sptr = srow; mptr = mrow;
dptr = drow;
-
+
while (xcount-- > 0)
{
uint8_t s, m;
int i;
-
+
s = *sptr++; m = *mptr++;
for (i = 0; i < 8; i++)
{
@@ -162,7 +162,7 @@ load_cursor(CursorPtr src, int screen)
#endif
}
}
-
+
srow += BitmapBytePad(src->bits->width);
mrow += BitmapBytePad(src->bits->width);
drow = (uint32_t *) ((char *) drow + rowbytes);
@@ -173,7 +173,7 @@ load_cursor(CursorPtr src, int screen)
memset(data, 0, src->bits->height * rowbytes);
}
}
-
+
err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
if(free_data)
free(data);
@@ -182,12 +182,12 @@ load_cursor(CursorPtr src, int screen)
/*
-===========================================================================
-
+ ===========================================================================
+
Pointer sprite functions
-
-===========================================================================
-*/
+
+ ===========================================================================
+ */
/*
* QuartzRealizeCursor
@@ -198,9 +198,9 @@ QuartzRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
if(pCursor == NULL || pCursor->bits == NULL)
return FALSE;
-
+
/* FIXME: cache ARGB8888 representation? */
-
+
return TRUE;
}
@@ -224,10 +224,10 @@ static void
QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
+
if (!XQuartzServerVisible)
return;
-
+
if (pCursor == NULL)
{
if (ScreenPriv->cursorVisible)
@@ -239,7 +239,7 @@ QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
else
{
load_cursor(pCursor, pScreen->myNum);
-
+
if (!ScreenPriv->cursorVisible)
{
xp_show_cursor();
@@ -258,12 +258,12 @@ QuartzMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
}
/*
-===========================================================================
-
+ ===========================================================================
+
Pointer screen functions
-
-===========================================================================
-*/
+
+ ===========================================================================
+ */
/*
* QuartzCursorOffScreen
@@ -297,13 +297,13 @@ QuartzWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
if (XQuartzServerVisible)
{
int sx, sy;
-
+
sx = pScreen->x + darwinMainScreenX;
sy = pScreen->y + darwinMainScreenY;
-
+
CGWarpMouseCursorPosition(CGPointMake(sx + x, sy + y));
}
-
+
miPointerWarpCursor(pDev, pScreen, x, y);
miPointerUpdateSprite(pDev);
}
@@ -319,12 +319,12 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = {
/*
-===========================================================================
-
+ ===========================================================================
+
Other screen functions
-
-===========================================================================
-*/
+
+ ===========================================================================
+ */
/*
* QuartzCursorQueryBestSize
@@ -335,7 +335,7 @@ QuartzCursorQueryBestSize(int class, unsigned short *width,
unsigned short *height, ScreenPtr pScreen)
{
QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
+
if (class == CursorShape)
{
/* FIXME: query window server? */
@@ -357,29 +357,29 @@ QuartzInitCursor(ScreenPtr pScreen)
{
QuartzCursorScreenPtr ScreenPriv;
miPointerScreenPtr PointPriv;
-
+
/* initialize software cursor handling (always needed as backup) */
if (!miDCInitialize(pScreen, &quartzScreenFuncsRec))
return FALSE;
-
+
if (!dixRegisterPrivateKey(&darwinCursorScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
+ return FALSE;
+
ScreenPriv = calloc(1, sizeof(QuartzCursorScreenRec));
if (ScreenPriv == NULL)
return FALSE;
-
+
/* CURSOR_PRIV(pScreen) = ScreenPriv; */
dixSetPrivate(&pScreen->devPrivates, darwinCursorScreenKey, ScreenPriv);
-
+
/* override some screen procedures */
ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
pScreen->QueryBestSize = QuartzCursorQueryBestSize;
-
+
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
+
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
-
+
PointPriv->spriteFuncs->RealizeCursor = QuartzRealizeCursor;
PointPriv->spriteFuncs->UnrealizeCursor = QuartzUnrealizeCursor;
PointPriv->spriteFuncs->SetCursor = QuartzSetCursor;
@@ -408,16 +408,16 @@ QuartzResumeXCursor(ScreenPtr pScreen)
{
WindowPtr pWin;
CursorPtr pCursor;
-
+
/* TODO: Tablet? */
pWin = GetSpriteWindow(darwinPointer);
if (pWin->drawable.pScreen != pScreen)
return;
-
+
pCursor = GetSpriteCursor(darwinPointer);
if (pCursor == NULL)
return;
-
+
QuartzSetCursor(darwinPointer, pScreen, pCursor, /* x */ 0, /* y */ 0);
}
diff --git a/hw/xquartz/xpr/xprEvent.c b/hw/xquartz/xpr/xprEvent.c
index 4e7ece64f..e8980213a 100644
--- a/hw/xquartz/xpr/xprEvent.c
+++ b/hw/xquartz/xpr/xprEvent.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008 Apple Inc.
+/* Copyright (c) 2008-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/hw/xquartz/xpr/xprEvent.h b/hw/xquartz/xpr/xprEvent.h
index ebfa36bd8..091a1ee39 100644
--- a/hw/xquartz/xpr/xprEvent.h
+++ b/hw/xquartz/xpr/xprEvent.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008 Apple Inc.
+/* Copyright (c) 2008-2012 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 98f1cc3ed..63af57ecd 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -1,7 +1,7 @@
/*
* Xplugin rootless implementation frame functions
*
- * Copyright (c) 2002-2011 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Apple Computer, Inc. All rights reserved.
* Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -74,12 +74,12 @@ static pthread_rwlock_t window_hash_rwlock;
/* Prototypes for static functions */
static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
- int newX, int newY, RegionPtr pShape);
+ int newX, int newY, RegionPtr pShape);
static void xprDestroyFrame(RootlessFrameID wid);
static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
static void xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
- int newX, int newY, unsigned int newW, unsigned int newH,
- unsigned int gravity);
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
static void xprUnmapFrame(RootlessFrameID wid);
@@ -87,13 +87,13 @@ static void xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPer
static void xprStopDrawing(RootlessFrameID wid, Bool flush);
static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage);
static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
- int shift_x, int shift_y);
+ int shift_x, int shift_y);
static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
static Bool xprDoReorderWindow(RootlessWindowPtr pFrame);
static void xprHideWindow(RootlessFrameID wid);
static void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen);
static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
- int dx, int dy);
+ int dx, int dy);
static inline xp_error
@@ -110,15 +110,15 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
xp_error err;
unsigned int native_id;
long data;
-
+
err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id);
if (err == Success)
{
/* FIXME: move this to AppleWM extension */
-
+
data = native_id;
dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(),
- XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
+ XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
}
}
@@ -139,14 +139,14 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
xp_window_changes wc;
unsigned int mask = 0;
xp_error err;
-
+
wc.x = newX;
wc.y = newY;
wc.width = pFrame->width;
wc.height = pFrame->height;
wc.bit_gravity = XP_GRAVITY_NONE;
mask |= XP_BOUNDS;
-
+
if (pWin->drawable.depth == 8)
{
wc.depth = XP_DEPTH_INDEX8;
@@ -161,7 +161,7 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
else
wc.depth = XP_DEPTH_NIL;
mask |= XP_DEPTH;
-
+
if (pShape != NULL)
{
wc.shape_nrects = RegionNumRects(pShape);
@@ -169,9 +169,9 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
wc.shape_tx = wc.shape_ty = 0;
mask |= XP_SHAPE;
}
-
+
pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels;
-
+
if(XQuartzIsRootless)
wc.window_level = normal_window_levels[pFrame->level];
else if(XQuartzShieldingWindowLevel)
@@ -179,14 +179,14 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
else
wc.window_level = rooted_window_levels[pFrame->level];
mask |= XP_WINDOW_LEVEL;
-
+
err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
-
+
if (err != Success)
{
return FALSE;
}
-
+
#ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^{
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
@@ -196,9 +196,9 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
pthread_rwlock_wrlock(&window_hash_rwlock);
#endif
-
+
xprSetNativeProperty(pFrame);
-
+
return TRUE;
}
@@ -210,7 +210,7 @@ static void
xprDestroyFrame(RootlessFrameID wid)
{
xp_error err;
-
+
#ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^{
x_hash_table_remove(window_hash, wid);
@@ -220,7 +220,7 @@ xprDestroyFrame(RootlessFrameID wid)
x_hash_table_remove(window_hash, wid);
pthread_rwlock_unlock(&window_hash_rwlock);
#endif
-
+
err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
if (err != Success)
FatalError("Could not destroy window %d (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
@@ -234,7 +234,7 @@ static void
xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
{
xp_window_changes wc;
-
+
wc.x = newX;
wc.y = newY;
// ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
@@ -251,16 +251,16 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
unsigned int gravity)
{
xp_window_changes wc;
-
+
wc.x = newX;
wc.y = newY;
wc.width = newW;
wc.height = newH;
wc.bit_gravity = gravity;
-
+
/* It's unlikely that being async will save us anything here.
- But it can't hurt. */
-
+ But it can't hurt. */
+
xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_BOUNDS, &wc);
}
@@ -275,10 +275,10 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
__block
#endif
RootlessWindowRec *winRec;
-
+
/* Stack frame below nextWid it if it exists, or raise
- frame above everything otherwise. */
-
+ frame above everything otherwise. */
+
if(nextWid == NULL) {
wc.stack_mode = XP_MAPPED_ABOVE;
wc.sibling = 0;
@@ -286,7 +286,7 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
wc.stack_mode = XP_MAPPED_BELOW;
wc.sibling = x_cvt_vptr_to_uint(nextWid);
}
-
+
#ifdef HAVE_LIBDISPATCH
dispatch_sync(window_hash_serial_q, ^{
winRec = x_hash_table_lookup(window_hash, wid, NULL);
@@ -306,7 +306,7 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
wc.window_level = rooted_window_levels[winRec->level];
mask |= XP_WINDOW_LEVEL;
}
-
+
xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc);
}
@@ -318,7 +318,7 @@ static void
xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
{
xp_window_changes wc;
-
+
if (pShape != NULL)
{
wc.shape_nrects = RegionNumRects(pShape);
@@ -329,9 +329,9 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
wc.shape_nrects = -1;
wc.shape_rects = NULL;
}
-
+
wc.shape_tx = wc.shape_ty = 0;
-
+
xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc);
}
@@ -343,10 +343,10 @@ static void
xprUnmapFrame(RootlessFrameID wid)
{
xp_window_changes wc;
-
+
wc.stack_mode = XP_UNMAPPED;
wc.sibling = 0;
-
+
xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc);
}
@@ -361,11 +361,11 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
void *data[2];
unsigned int rowbytes[2];
xp_error err;
-
+
err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL);
if (err != Success)
FatalError("Could not lock window %d for drawing (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
-
+
*pixelData = data[0];
*bytesPerRow = rowbytes[0];
}
@@ -378,7 +378,7 @@ static void
xprStopDrawing(RootlessFrameID wid, Bool flush)
{
xp_error err;
-
+
err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
/* This should be a FatalError, but we started tripping over it. Make it a
* FatalError after http://xquartz.macosforge.org/trac/ticket/482 is fixed.
@@ -417,7 +417,7 @@ static void
xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
{
DeleteProperty(serverClient, oldWin, xa_native_window_id());
-
+
xprSetNativeProperty(pFrame);
}
@@ -428,7 +428,7 @@ xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
static Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
{
WindowPtr pWin = pFrame->win;
-
+
return AppleWMDoReorderWindow(pWin);
}
@@ -474,10 +474,10 @@ Bool
xprInit(ScreenPtr pScreen)
{
RootlessInit(pScreen, &xprRootlessProcs);
-
+
rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
rootless_CopyWindow_threshold = xp_scroll_area_threshold;
-
+
assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL)));
#ifdef HAVE_LIBDISPATCH
assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL)));
@@ -507,7 +507,7 @@ xprGetXWindow(xp_window_id wid)
winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
pthread_rwlock_unlock(&window_hash_rwlock);
#endif
-
+
return winRec != NULL ? winRec->win : NULL;
}
@@ -520,12 +520,12 @@ xprIsX11Window(int windowNumber)
{
Bool ret;
xp_window_id wid;
-
+
if (xp_lookup_native_window(windowNumber, &wid))
ret = xprGetXWindow(wid) != NULL;
else
ret = FALSE;
-
+
return ret;
}
@@ -541,28 +541,28 @@ xprHideWindows(Bool hide)
{
int screen;
WindowPtr pRoot, pWin;
-
+
for (screen = 0; screen < screenInfo.numScreens; screen++) {
RootlessFrameID prevWid = NULL;
pRoot = screenInfo.screens[screen]->root;
-
+
for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
RootlessWindowRec *winRec = WINREC(pWin);
-
+
if (winRec != NULL) {
if (hide) {
xprUnmapFrame(winRec->wid);
} else {
BoxRec box;
-
+
xprRestackFrame(winRec->wid, prevWid);
prevWid = winRec->wid;
-
+
box.x1 = 0;
box.y1 = 0;
box.x2 = winRec->width;
box.y2 = winRec->height;
-
+
xprDamageRects(winRec->wid, 1, &box, 0, 0);
RootlessQueueRedisplay(screenInfo.screens[screen]);
}
@@ -580,29 +580,29 @@ static inline int
configure_window (xp_window_id id, unsigned int mask,
const xp_window_changes *values)
{
- if (!no_configure_window)
- return xp_configure_window (id, mask, values);
- else
- return XP_Success;
+ if (!no_configure_window)
+ return xp_configure_window (id, mask, values);
+ else
+ return XP_Success;
}
static
void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen)
{
- /* This is how we tell xp that the colormap may have changed. */
- xp_window_changes wc;
- wc.colormap = xprColormapCallback;
- wc.colormap_data = pScreen;
-
- configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc);
+ /* This is how we tell xp that the colormap may have changed. */
+ xp_window_changes wc;
+ wc.colormap = xprColormapCallback;
+ wc.colormap_data = pScreen;
+
+ configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc);
}
static
void xprHideWindow(RootlessFrameID wid)
{
- xp_window_changes wc;
- wc.stack_mode = XP_UNMAPPED;
- wc.sibling = 0;
- configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc);
+ xp_window_changes wc;
+ wc.stack_mode = XP_UNMAPPED;
+ wc.sibling = 0;
+ configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc);
}
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 002355eca..1441a4976 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -1,7 +1,7 @@
/*
* Xplugin rootless implementation screen functions
*
- * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+ * Copyright (c) 2002-2012 Apple Computer, Inc. All Rights Reserved.
* Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -55,7 +55,7 @@
#endif
/* 10.4's deferred update makes X slower.. have to live with the tearing
- for now.. */
+ * for now.. */
#define XP_NO_DEFERRED_UPDATES 8
// Name of GLX bundle for native OpenGL
@@ -80,7 +80,7 @@ static void eventHandler(unsigned int type, const void *arg,
DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state);
DarwinSendDDXEvent(kXquartzWindowState, 2,
- ws_arg->id, ws_arg->state);
+ ws_arg->id, ws_arg->state);
} else {
DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
}
@@ -133,7 +133,7 @@ displayAtIndex(int index)
CGError err;
CGDisplayCount cnt;
CGDirectDisplayID dpy[index+1];
-
+
err = CGGetActiveDisplayList(index + 1, dpy, &cnt);
if (err == kCGErrorSuccess && cnt == index + 1)
return dpy[index];
@@ -149,9 +149,9 @@ static CGRect
displayScreenBounds(CGDirectDisplayID id)
{
CGRect frame;
-
+
frame = CGDisplayBounds(id);
-
+
DEBUG_LOG(" %dx%d @ (%d,%d).\n",
(int)frame.size.width, (int)frame.size.height,
(int)frame.origin.x, (int)frame.origin.y);
@@ -162,11 +162,11 @@ displayScreenBounds(CGDirectDisplayID id)
frame.origin.y += aquaMenuBarHeight;
frame.size.height -= aquaMenuBarHeight;
}
-
+
DEBUG_LOG(" %dx%d @ (%d,%d).\n",
(int)frame.size.width, (int)frame.size.height,
(int)frame.origin.x, (int)frame.origin.y);
-
+
return frame;
}
@@ -181,11 +181,11 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr
CGDisplayCount i, displayCount;
CGDirectDisplayID *displayList = NULL;
CGRect unionRect = CGRectNull, frame;
-
+
// Find all the CoreGraphics displays
CGGetActiveDisplayList(0, NULL, &displayCount);
DEBUG_LOG("displayCount: %d\n", (int)displayCount);
-
+
if(!displayCount) {
ErrorF("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n");
*x = *y = 0;
@@ -195,52 +195,52 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr
QuartzCopyDisplayIDs(pScreen, 0, NULL);
return;
}
-
+
/* If the displays are captured, we are in a RandR game mode
* on the primary display, so we only want to include the first
* display. The others are covered by the shield window.
*/
if (CGDisplayIsCaptured(kCGDirectMainDisplay))
displayCount = 1;
-
+
displayList = malloc(displayCount * sizeof(CGDirectDisplayID));
if(!displayList)
FatalError("Unable to allocate memory for list of displays.\n");
CGGetActiveDisplayList(displayCount, displayList, &displayCount);
QuartzCopyDisplayIDs(pScreen, displayCount, displayList);
-
+
/* Get the union of all screens */
for (i = 0; i < displayCount; i++) {
CGDirectDisplayID dpy = displayList[i];
frame = displayScreenBounds(dpy);
unionRect = CGRectUnion(unionRect, frame);
}
-
+
/* Use unionRect as the screen size for the X server. */
*x = unionRect.origin.x;
*y = unionRect.origin.y;
*width = unionRect.size.width;
*height = unionRect.size.height;
-
+
DEBUG_LOG(" screen union origin: (%d,%d) size: (%d,%d).\n",
*x, *y, *width, *height);
-
+
/* Tell PseudoramiX about the real screens. */
for (i = 0; i < displayCount; i++)
{
CGDirectDisplayID dpy = displayList[i];
-
+
frame = displayScreenBounds(dpy);
frame.origin.x -= unionRect.origin.x;
frame.origin.y -= unionRect.origin.y;
-
+
DEBUG_LOG(" placed at X11 coordinate (%d,%d).\n",
(int)frame.origin.x, (int)frame.origin.y);
-
+
PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
frame.size.width, frame.size.height);
}
-
+
free(displayList);
}
@@ -252,22 +252,22 @@ static void
xprDisplayInit(void)
{
CGDisplayCount displayCount;
-
+
TRACE();
-
+
CGGetActiveDisplayList(0, NULL, &displayCount);
-
+
/* With PseudoramiX, the X server only sees one screen; only PseudoramiX
- itself knows about all of the screens. */
-
+ itself knows about all of the screens. */
+
if (noPseudoramiXExtension)
darwinScreensFound = displayCount;
else
darwinScreensFound = 1;
-
+
if (xp_init(XP_BACKGROUND_EVENTS | XP_NO_DEFERRED_UPDATES) != Success)
FatalError("Could not initialize the Xplugin library.");
-
+
xp_select_events(XP_EVENT_DISPLAY_CHANGED
| XP_EVENT_WINDOW_STATE_CHANGED
| XP_EVENT_WINDOW_MOVED
@@ -277,10 +277,10 @@ xprDisplayInit(void)
| XP_EVENT_SURFACE_CHANGED
| XP_EVENT_SURFACE_DESTROYED,
eventHandler, NULL);
-
+
AppleDRIExtensionInit();
xprAppleWMInit();
-
+
XQuartzIsRootless = XQuartzRootlessDefault;
if (!XQuartzIsRootless)
RootlessHideAllWindows();
@@ -295,7 +295,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
{
DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
int depth = darwinDesiredDepth;
-
+
DEBUG_LOG("index=%d depth=%d\n", index, depth);
if(depth == -1) {
@@ -308,7 +308,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
modeRef = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
if(!modeRef)
goto have_depth;
-
+
encStrRef = CGDisplayModeCopyPixelEncoding(modeRef);
CFRelease(modeRef);
if(!encStrRef)
@@ -321,7 +321,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
} else if(CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
depth = 8;
}
-
+
CFRelease(encStrRef);
#endif
}
@@ -350,7 +350,7 @@ have_depth:
dfb->greenMask = GM_ARGB(0,5,5,5);
dfb->blueMask = BM_ARGB(0,5,5,5);
break;
-// case 24:
+ // case 24:
default:
if(depth != 24)
ErrorF("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", depth, darwinDesiredDepth);
@@ -364,19 +364,19 @@ have_depth:
dfb->blueMask = BM_ARGB(0,8,8,8);
break;
}
-
+
if (noPseudoramiXExtension)
{
CGDirectDisplayID dpy;
CGRect frame;
-
+
ErrorF("Warning: noPseudoramiXExtension!\n");
dpy = displayAtIndex(index);
QuartzCopyDisplayIDs(pScreen, 1, &dpy);
-
+
frame = displayScreenBounds(dpy);
-
+
dfb->x = frame.origin.x;
dfb->y = frame.origin.y;
dfb->width = frame.size.width;
@@ -386,15 +386,15 @@ have_depth:
{
xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height, pScreen);
}
-
+
/* Passing zero width (pitch) makes miCreateScreenResources set the
- screen pixmap to the framebuffer pointer, i.e. NULL. The generic
- rootless code takes care of making this work. */
+ screen pixmap to the framebuffer pointer, i.e. NULL. The generic
+ rootless code takes care of making this work. */
dfb->pitch = 0;
dfb->framebuffer = NULL;
-
+
DRIScreenInit(pScreen);
-
+
return TRUE;
}
@@ -411,11 +411,11 @@ xprSetupScreen(int index, ScreenPtr pScreen)
if (!DamageSetup(pScreen))
return FALSE;
#endif
-
+
// Initialize generic rootless code
if (!xprInit(pScreen))
return FALSE;
-
+
return DRIFinishScreenInit(pScreen);
}
@@ -428,9 +428,9 @@ xprUpdateScreen(ScreenPtr pScreen)
{
rootlessGlobalOffsetX = darwinMainScreenX;
rootlessGlobalOffsetY = darwinMainScreenY;
-
+
AppleWMSetScreenOrigin(pScreen->root);
-
+
RootlessRepositionWindows(pScreen);
RootlessUpdateScreenPixmap(pScreen);
}
@@ -443,10 +443,10 @@ static void
xprInitInput(int argc, char **argv)
{
int i;
-
+
rootlessGlobalOffsetX = darwinMainScreenX;
rootlessGlobalOffsetY = darwinMainScreenY;
-
+
for (i = 0; i < screenInfo.numScreens; i++)
AppleWMSetScreenOrigin(screenInfo.screens[i]->root);
}