XQuartz: Source formatting cleanup

indent butchered Objective-C formatting.  This patch was created by:

1) Reverting the indent changes in hw/xquartz
2) Editing X11Application.m and chaning some #ifdef logic to work
   with uncrustify
3) Hand edited some (c) notifications
4) Opened all XQuartz sources in XCode and re-indented (^I)
5) Ran uncrustify with this configuration
   (as close to the indent rules as I could get):

tok_split_gte=false
utf8_byte=true
utf8_force=true
indent_cmt_with_tabs=false
indent_align_string=false
indent_braces=false
indent_braces_no_func=false
indent_braces_no_class=false
indent_braces_no_struct=false
indent_brace_parent=false
indent_namespace=false
indent_extern=false
indent_class=false
indent_class_colon=false
indent_else_if=false
indent_var_def_cont=false
indent_func_call_param=false
indent_func_def_param=false
indent_func_proto_param=false
indent_func_class_param=false
indent_func_ctor_var_param=false
indent_template_param=false
indent_func_param_double=false
indent_relative_single_line_comments=false
indent_col1_comment=false
indent_access_spec_body=false
indent_paren_nl=false
indent_comma_paren=false
indent_bool_paren=false
indent_first_bool_expr=false
indent_square_nl=false
indent_preserve_sql=false
indent_align_assign=true
sp_balance_nested_parens=false
align_keep_tabs=false
align_with_tabs=false
align_on_tabstop=false
align_number_left=false
align_func_params=false
align_same_func_call_params=false
align_var_def_colon=true
align_var_def_attribute=true
align_var_def_inline=true
align_right_cmt_mix=false
align_on_operator=false
align_mix_var_proto=false
align_single_line_func=false
align_single_line_brace=false
align_nl_cont=false
align_left_shift=true
align_oc_decl_colon=true
nl_collapse_empty_body=true
nl_assign_leave_one_liners=true
nl_class_leave_one_liners=true
nl_enum_leave_one_liners=true
nl_getset_leave_one_liners=true
nl_func_leave_one_liners=true
nl_if_leave_one_liners=true
nl_multi_line_cond=false
nl_multi_line_define=false
nl_before_case=true
nl_after_case=true
nl_after_return=false
nl_after_semicolon=true
nl_after_brace_open=true
nl_after_brace_open_cmt=false
nl_after_vbrace_open=false
nl_after_vbrace_open_empty=false
nl_after_brace_close=false
nl_after_vbrace_close=false
nl_define_macro=false
nl_squeeze_ifdef=false
nl_ds_struct_enum_cmt=false
nl_ds_struct_enum_close_brace=false
nl_create_if_one_liner=false
nl_create_for_one_liner=false
nl_create_while_one_liner=false
ls_for_split_full=false
ls_func_split_full=false
nl_after_multiline_comment=false
eat_blanks_after_open_brace=false
eat_blanks_before_close_brace=false
mod_full_brace_if_chain=false
mod_pawn_semicolon=false
mod_full_paren_if_bool=false
mod_remove_extra_semicolon=false
mod_sort_import=false
mod_sort_using=false
mod_sort_include=false
mod_move_case_break=false
mod_remove_empty_return=false
cmt_indent_multi=true
cmt_c_group=false
cmt_c_nl_start=false
cmt_c_nl_end=false
cmt_cpp_group=false
cmt_cpp_nl_start=false
cmt_cpp_nl_end=false
cmt_cpp_to_c=false
cmt_star_cont=false
cmt_multi_check_last=true
cmt_insert_before_preproc=false
pp_indent_at_level=false
pp_region_indent_code=false
pp_if_indent_code=false
pp_define_at_level=false
indent_columns=4
indent_brace=0
indent_switch_case=0
align_struct_init_span=2
align_pp_define_gap=0
align_pp_define_span=2
align_oc_msg_colon_span=16
nl_end_of_file_min=1
nl_func_var_def_blk=0
code_width=78
nl_max=2
newlines=auto
indent_with_tabs=0
sp_arith=force
sp_assign=force
sp_assign_default=force
sp_before_assign=force
sp_after_assign=force
sp_enum_assign=force
sp_enum_before_assign=force
sp_enum_after_assign=force
sp_pp_stringify=add
sp_bool=force
sp_compare=force
sp_inside_paren=remove
sp_paren_paren=remove
sp_paren_brace=force
sp_before_ptr_star=ignore
sp_before_unnamed_ptr_star=force
sp_before_byref=force
sp_before_unnamed_byref=force
sp_after_byref=remove
sp_after_type=force
sp_before_sparen=force
sp_inside_sparen=remove
sp_inside_sparen_close=remove
sp_after_sparen=force
sp_sparen_brace=force
sp_special_semi=force
sp_before_semi=remove
sp_after_semi=force
sp_after_semi_for=force
sp_after_semi_for_empty=remove
sp_before_square=remove
sp_inside_square=remove
sp_after_comma=force
sp_before_comma=remove
sp_paren_comma=force
sp_before_ellipsis=force
sp_after_class_colon=force
sp_before_class_colon=force
sp_before_case_colon=remove
sp_after_cast=remove
sp_inside_paren_cast=remove
sp_sizeof_paren=remove
sp_inside_braces_enum=force
sp_inside_braces_struct=force
sp_inside_braces=force
sp_inside_braces_empty=remove
sp_func_proto_paren=remove
sp_func_def_paren=remove
sp_inside_fparens=remove
sp_inside_fparen=remove
sp_square_fparen=remove
sp_fparen_brace=force
sp_func_call_paren=remove
sp_func_call_paren_empty=remove
sp_return_paren=force
sp_attribute_paren=remove
sp_defined_paren=remove
sp_macro=force
sp_macro_func=force
sp_else_brace=force
sp_brace_else=force
sp_brace_typedef=force
sp_not=remove
sp_inv=remove
nl_start_of_file=remove
nl_end_of_file=force
nl_assign_square=remove
nl_after_square_assign=remove
nl_fcall_brace=remove
nl_enum_brace=remove
nl_struct_brace=remove
nl_union_brace=remove
nl_if_brace=remove
nl_brace_else=force
nl_elseif_brace=remove
nl_else_brace=remove
nl_else_if=remove
nl_for_brace=remove
nl_do_brace=remove
nl_brace_while=remove
nl_switch_brace=remove
nl_case_colon_brace=force
nl_func_type_name=force
nl_func_type_name_class=force
nl_func_proto_type_name=force
nl_func_paren=remove
nl_func_def_paren=remove
nl_func_decl_start=remove
nl_func_def_start=remove
nl_func_decl_args=remove
nl_func_decl_end=remove
nl_func_def_end=remove
nl_func_decl_end_single=remove
nl_func_def_end_single=remove
nl_func_decl_empty=remove
nl_func_def_empty=remove
nl_fdef_brace=force
nl_return_expr=remove
nl_before_if=ignore
nl_after_if=ignore
nl_before_for=ignore
nl_after_for=ignore
nl_before_while=ignore
nl_after_while=ignore
nl_before_switch=ignore
nl_after_switch=ignore
nl_before_do=ignore
nl_after_do=ignore
pp_space=remove

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston 2012-03-23 19:58:49 -07:00
parent 3505e1faad
commit 5324557c7b
68 changed files with 5176 additions and 4585 deletions

View File

@ -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"),
@ -25,7 +25,7 @@
#include <assert.h>
#define Cursor Mac_Cursor
#define BOOL Mac_BOOL
#define BOOL Mac_BOOL
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
@ -120,7 +120,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
{
int offset = 0;
/*1 */
/*1*/
if (kCGLRGB444Bit & cmodes) {
c[offset].r = 4;
c[offset].g = 4;
@ -128,7 +128,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*2 */
/*2*/
if (kCGLARGB4444Bit & cmodes) {
c[offset].a = 4;
c[offset].r = 4;
@ -138,7 +138,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*3 */
/*3*/
if (kCGLRGB444A8Bit & cmodes) {
c[offset].r = 4;
c[offset].g = 4;
@ -147,7 +147,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*4 */
/*4*/
if (kCGLRGB555Bit & cmodes) {
c[offset].r = 5;
c[offset].g = 5;
@ -155,7 +155,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*5 */
/*5*/
if (kCGLARGB1555Bit & cmodes) {
c[offset].a = 1;
c[offset].r = 5;
@ -165,7 +165,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*6 */
/*6*/
if (kCGLRGB555A8Bit & cmodes) {
c[offset].r = 5;
c[offset].g = 5;
@ -174,7 +174,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*7 */
/*7*/
if (kCGLRGB565Bit & cmodes) {
c[offset].r = 5;
c[offset].g = 6;
@ -182,7 +182,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*8 */
/*8*/
if (kCGLRGB565A8Bit & cmodes) {
c[offset].r = 5;
c[offset].g = 6;
@ -191,7 +191,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*9 */
/*9*/
if (kCGLRGB888Bit & cmodes) {
c[offset].r = 8;
c[offset].g = 8;
@ -199,7 +199,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*10 */
/*10*/
if (kCGLARGB8888Bit & cmodes) {
c[offset].a = 8;
c[offset].r = 8;
@ -209,7 +209,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*11 */
/*11*/
if (kCGLRGB888A8Bit & cmodes) {
c[offset].r = 8;
c[offset].g = 8;
@ -219,16 +219,16 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
}
if (forAccum) {
//#if 0
//#if 0
/* FIXME
* Disable this path, because some part of libGL, X, or Xplugin
* 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 */
/*12*/
if (kCGLRGB101010Bit & cmodes) {
c[offset].r = 10;
c[offset].g = 10;
@ -236,7 +236,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*13 */
/*13*/
if (kCGLARGB2101010Bit & cmodes) {
c[offset].a = 2;
c[offset].r = 10;
@ -246,7 +246,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*14 */
/*14*/
if (kCGLRGB101010_A8Bit & cmodes) {
c[offset].r = 10;
c[offset].g = 10;
@ -255,7 +255,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*15 */
/*15*/
if (kCGLRGB121212Bit & cmodes) {
c[offset].r = 12;
c[offset].g = 12;
@ -263,7 +263,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*16 */
/*16*/
if (kCGLARGB12121212Bit & cmodes) {
c[offset].a = 12;
c[offset].r = 12;
@ -273,7 +273,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*17 */
/*17*/
if (kCGLRGB161616Bit & cmodes) {
c[offset].r = 16;
c[offset].g = 16;
@ -281,7 +281,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
/*18 */
/*18*/
if (kCGLRGBA16161616Bit & cmodes) {
c[offset].r = 16;
c[offset].g = 16;
@ -290,7 +290,7 @@ handleColorAndAccumulation(struct glColorBufCapabilities *c,
++offset;
}
}
//#endif
//#endif
/* FIXME should we handle the floating point color modes, and if so, how? */
@ -318,46 +318,45 @@ 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)
#define DEPTH(flag,value) do { \
if(dmodes & flag) { \
c->depth_buffers[offset++] = value; \
} \
} while(0)
/*1 */
/*1*/
DEPTH(kCGL0Bit, 0);
/*2 */
/*2*/
DEPTH(kCGL1Bit, 1);
/*3 */
/*3*/
DEPTH(kCGL2Bit, 2);
/*4 */
/*4*/
DEPTH(kCGL3Bit, 3);
/*5 */
/*5*/
DEPTH(kCGL4Bit, 4);
/*6 */
/*6*/
DEPTH(kCGL5Bit, 5);
/*7 */
/*7*/
DEPTH(kCGL6Bit, 6);
/*8 */
/*8*/
DEPTH(kCGL8Bit, 8);
/*9 */
/*9*/
DEPTH(kCGL10Bit, 10);
/*10 */
/*10*/
DEPTH(kCGL12Bit, 12);
/*11 */
/*11*/
DEPTH(kCGL16Bit, 16);
/*12 */
/*12*/
DEPTH(kCGL24Bit, 24);
/*13 */
/*13*/
DEPTH(kCGL32Bit, 32);
/*14 */
/*14*/
DEPTH(kCGL48Bit, 48);
/*15 */
/*15*/
DEPTH(kCGL64Bit, 64);
/*16 */
/*16*/
DEPTH(kCGL96Bit, 96);
/*17 */
/*17*/
DEPTH(kCGL128Bit, 128);
#undef DEPTH
@ -483,8 +482,9 @@ initConfig(struct glCapabilitiesConfig *c)
for (i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
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].b =
c->color_buffers[i].a =
GLCAPS_COLOR_BUF_INVALID_VALUE;
c->color_buffers[i].is_argb = false;
}
@ -492,8 +492,9 @@ initConfig(struct glCapabilitiesConfig *c)
for (i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
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].b =
c->accum_buffers[i].a =
GLCAPS_COLOR_BUF_INVALID_VALUE;
c->accum_buffers[i].is_argb = false;
}
@ -540,7 +541,8 @@ getGlCapabilities(struct glCapabilities *cap)
err = handleRendererDescriptions(info, r, &tmpconf);
if (err) {
ErrorF("handleRendererDescriptions returned error: %s\n",
CGLErrorString(err));
CGLErrorString(
err));
ErrorF("trying to continue...\n");
continue;
}

View File

@ -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"),
@ -60,7 +60,9 @@ struct glCapabilities {
int total_configurations;
};
bool getGlCapabilities(struct glCapabilities *cap);
void freeGlCapabilities(struct glCapabilities *cap);
bool
getGlCapabilities(struct glCapabilities *cap);
void
freeGlCapabilities(struct glCapabilities *cap);
#endif

View File

@ -47,31 +47,31 @@
#include <stdlib.h>
#include <string.h>
#define _mesa_malloc(b) malloc(b)
#define _mesa_free(m) free(m)
#define _mesa_memset memset
#define _mesa_free(m) free(m)
#define _mesa_memset memset
#else
#ifdef XFree86Server
#include <os.h>
#include <string.h>
#define _mesa_malloc(b) malloc(b)
#define _mesa_free(m) free(m)
#define _mesa_memset memset
#define _mesa_memset memset
#else
#include <X11/Xlibint.h>
#define _mesa_memset memset
#define _mesa_malloc(b) Xmalloc(b)
#define _mesa_free(m) free(m)
#endif /* XFree86Server */
#endif /* !defined(IN_MINI_GLX) */
#define _mesa_free(m) free(m)
#endif /* XFree86Server */
#endif /* !defined(IN_MINI_GLX) */
#include "glcontextmodes.h"
#if !defined(IN_MINI_GLX)
#define NUM_VISUAL_TYPES 6
#define NUM_VISUAL_TYPES 6
/**
* Convert an X visual type to a GLX visual type.
*
*
* \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.)
* to be converted.
* \return If \c visualType is a valid X visual type, a GLX visual type will
@ -81,19 +81,19 @@ 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_GRAY, GLX_GRAY_SCALE,
GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
GLX_TRUE_COLOR, GLX_DIRECT_COLOR
GLX_TRUE_COLOR, GLX_DIRECT_COLOR
};
return ((unsigned) visualType < NUM_VISUAL_TYPES)
? glx_visual_types[visualType] : GLX_NONE;
return ((unsigned)visualType < NUM_VISUAL_TYPES)
? glx_visual_types[visualType] : GLX_NONE;
}
/**
* Convert a GLX visual type to an X visual type.
*
* \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR,
*
* \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR,
* \c GLX_STATIC_GRAY, etc.) to be converted.
* \return If \c visualType is a valid GLX visual type, an X visual type will
* be returned. Otherwise -1 will be returned.
@ -102,13 +102,13 @@ GLint
_gl_convert_to_x_visual_type(int visualType)
{
static const int x_visual_types[NUM_VISUAL_TYPES] = {
TrueColor, DirectColor,
TrueColor, DirectColor,
PseudoColor, StaticColor,
GrayScale, StaticGray
GrayScale, StaticGray
};
return ((unsigned) (visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES)
? x_visual_types[visualType - GLX_TRUE_COLOR] : -1;
return ((unsigned)(visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES)
? x_visual_types[visualType - GLX_TRUE_COLOR] : -1;
}
/**
@ -117,10 +117,10 @@ _gl_convert_to_x_visual_type(int visualType)
* \c mode that can be derrived from the fields of \c config (i.e.,
* \c haveDepthBuffer) are also filled in. The remaining fields in \c mode
* that cannot be derived are set to default values.
*
*
* \param mode Destination GL context mode.
* \param config Source GLX visual config.
*
*
* \note
* The \c fbconfigID and \c visualID fields of the \c __GLcontextModes
* structure will be set to the \c vid of the \c __GLXvisualConfig structure.
@ -129,9 +129,9 @@ void
_gl_copy_visual_to_context_mode(__GLcontextModes * mode,
const __GLXvisualConfig * config)
{
__GLcontextModes *const next = mode->next;
__GLcontextModes * const next = mode->next;
(void) _mesa_memset(mode, 0, sizeof(__GLcontextModes));
(void)_mesa_memset(mode, 0, sizeof(__GLcontextModes));
mode->next = next;
mode->visualID = config->vid;
@ -190,17 +190,18 @@ _gl_copy_visual_to_context_mode(__GLcontextModes * mode,
mode->bindToTextureRgb = (mode->rgbMode) ? GL_TRUE : GL_FALSE;
mode->bindToTextureRgba = (mode->rgbMode && mode->alphaBits) ?
GL_TRUE : GL_FALSE;
GL_TRUE : GL_FALSE;
mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE;
mode->bindToTextureTargets = mode->rgbMode ?
GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT |
GLX_TEXTURE_RECTANGLE_BIT_EXT : 0;
GLX_TEXTURE_1D_BIT_EXT |
GLX_TEXTURE_2D_BIT_EXT |
GLX_TEXTURE_RECTANGLE_BIT_EXT : 0;
mode->yInverted = GL_FALSE;
}
/**
* Get data from a GL context mode.
*
*
* \param mode GL context mode whose data is to be returned.
* \param attribute Attribute of \c mode that is to be returned.
* \param value_return Location to store the data member of \c mode.
@ -208,151 +209,193 @@ _gl_copy_visual_to_context_mode(__GLcontextModes * mode,
* returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned.
*/
int
_gl_get_context_mode_data(const __GLcontextModes * mode, int attribute,
_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
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;
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.
*/
/* 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) */
#endif /* !defined(IN_MINI_GLX) */
/**
* Allocate a linked list of \c __GLcontextModes structures. The fields of
@ -362,7 +405,7 @@ _gl_get_context_mode_data(const __GLcontextModes * mode, int attribute,
* zero or \c GLX_DONT_CARE (which is -1). As support for additional
* extensions is added, the new values will be initialized to appropriate
* values from the extension specification.
*
*
* \param count Number of structures to allocate.
* \param minimum_size Minimum size of a structure to allocate. This allows
* for differences in the version of the
@ -370,7 +413,7 @@ _gl_get_context_mode_data(const __GLcontextModes * mode, int attribute,
* DRI-based driver.
* \returns A pointer to the first element in a linked list of \c count
* stuctures on success, or \c NULL on failure.
*
*
* \warning Use of \c minimum_size does \b not guarantee binary compatibility.
* The fundamental assumption is that if the \c minimum_size
* specified by the driver and the size of the \c __GLcontextModes
@ -384,21 +427,21 @@ __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;
? minimum_size : sizeof(__GLcontextModes);
__GLcontextModes * base = NULL;
__GLcontextModes ** next;
unsigned i;
next = &base;
for (i = 0; i < count; i++) {
*next = (__GLcontextModes *) _mesa_malloc(size);
*next = (__GLcontextModes *)_mesa_malloc(size);
if (*next == NULL) {
_gl_context_modes_destroy(base);
base = NULL;
break;
}
(void) _mesa_memset(*next, 0, size);
(void)_mesa_memset(*next, 0, size);
(*next)->visualID = GLX_DONT_CARE;
(*next)->visualType = GLX_DONT_CARE;
(*next)->visualRating = GLX_NONE;
@ -426,7 +469,7 @@ _gl_context_modes_create(unsigned count, size_t minimum_size)
/**
* Destroy a linked list of \c __GLcontextModes structures created by
* \c _gl_context_modes_create.
*
*
* \param modes Linked list of structures to be destroyed. All structres
* in the list will be freed.
*/
@ -434,7 +477,7 @@ void
_gl_context_modes_destroy(__GLcontextModes * modes)
{
while (modes != NULL) {
__GLcontextModes *const next = modes->next;
__GLcontextModes * const next = modes->next;
_mesa_free(modes);
modes = next;
@ -451,7 +494,7 @@ _gl_context_modes_destroy(__GLcontextModes * modes)
*/
__GLcontextModes *
_gl_context_modes_find_visual(__GLcontextModes * modes, int vid)
_gl_context_modes_find_visual(__GLcontextModes *modes, int vid)
{
__GLcontextModes *m;
@ -463,7 +506,7 @@ _gl_context_modes_find_visual(__GLcontextModes * modes, int vid)
}
__GLcontextModes *
_gl_context_modes_find_fbconfig(__GLcontextModes * modes, int fbid)
_gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid)
{
__GLcontextModes *m;
@ -477,7 +520,7 @@ _gl_context_modes_find_fbconfig(__GLcontextModes * modes, int fbid)
/**
* Determine if two context-modes are the same. This is intended to be used
* by libGL implementations to compare to sets of driver generated FBconfigs.
*
*
* \param a Context-mode to be compared.
* \param b Context-mode to be compared.
* \returns \c GL_TRUE if the two context-modes are the same. \c GL_FALSE is
@ -494,11 +537,13 @@ _gl_context_modes_are_same(const __GLcontextModes * a,
(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->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->blueMask == b->blueMask) &&
(a->alphaMask == b->alphaMask) &&
#endif
(a->rgbBits == b->rgbBits) &&
(a->indexBits == b->indexBits) &&
@ -512,14 +557,18 @@ _gl_context_modes_are_same(const __GLcontextModes * a,
(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) &&

View File

@ -33,22 +33,28 @@
#include "GL/internal/glcore.h"
#if !defined(IN_MINI_GLX)
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);
extern int _gl_get_context_mode_data(const __GLcontextModes * mode,
int attribute, int *value_return);
#endif /* !defined(IN_MINI_GLX) */
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);
extern int
_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
int *value_return);
#endif /* !defined(IN_MINI_GLX) */
extern __GLcontextModes *_gl_context_modes_create(unsigned count,
size_t minimum_size);
extern void _gl_context_modes_destroy(__GLcontextModes * modes);
extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes * modes,
int vid);
extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes *
modes, int fbid);
extern GLboolean _gl_context_modes_are_same(const __GLcontextModes * a,
const __GLcontextModes * b);
extern __GLcontextModes *
_gl_context_modes_create(unsigned count, size_t minimum_size);
extern void
_gl_context_modes_destroy(__GLcontextModes * modes);
extern __GLcontextModes *
_gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
extern __GLcontextModes *
_gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
extern GLboolean
_gl_context_modes_are_same(const __GLcontextModes * a,
const __GLcontextModes * b);
#endif /* GLCONTEXTMODES_H */
#endif /* GLCONTEXTMODES_H */

View File

@ -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.
*
@ -40,7 +40,7 @@
#include <dlfcn.h>
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h> /* Just to prevent glxserver.h from loading mesa's and colliding with OpenGL.h */
#include <OpenGL/gl.h> /* Just to prevent glxserver.h from loading mesa's and colliding with OpenGL.h */
#include <X11/Xproto.h>
#include <GL/glxproto.h>
@ -56,30 +56,41 @@
#include "dri.h"
#include "darwin.h"
#define GLAQUA_DEBUG_MSG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "GLXAqua", msg, ##args)
#define GLAQUA_DEBUG_MSG(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, "GLXAqua", \
msg, \
## args)
__GLXprovider *GlxGetDRISWrastProvider(void);
__GLXprovider *
GlxGetDRISWrastProvider(void);
static void setup_dispatch_table(void);
GLuint __glFloorLog2(GLuint val);
void warn_func(void *p1, char *format, ...);
static void
setup_dispatch_table(void);
GLuint
__glFloorLog2(GLuint val);
void
warn_func(void * p1, char *format, ...);
// some prototypes
static __GLXscreen *__glXAquaScreenProbe(ScreenPtr pScreen);
static __GLXdrawable *__glXAquaScreenCreateDrawable(ClientPtr client,
__GLXscreen * screen,
DrawablePtr pDraw,
XID drawId, int type,
XID glxDrawId,
__GLXconfig * conf);
static __GLXscreen *
__glXAquaScreenProbe(ScreenPtr pScreen);
static __GLXdrawable *
__glXAquaScreenCreateDrawable(ClientPtr client, __GLXscreen *screen,
DrawablePtr pDraw, XID drawId, int type,
XID glxDrawId,
__GLXconfig *conf);
static void __glXAquaContextDestroy(__GLXcontext * baseContext);
static int __glXAquaContextMakeCurrent(__GLXcontext * baseContext);
static int __glXAquaContextLoseCurrent(__GLXcontext * baseContext);
static int __glXAquaContextCopy(__GLXcontext * baseDst, __GLXcontext * baseSrc,
unsigned long mask);
static void
__glXAquaContextDestroy(__GLXcontext *baseContext);
static int
__glXAquaContextMakeCurrent(__GLXcontext *baseContext);
static int
__glXAquaContextLoseCurrent(__GLXcontext *baseContext);
static int
__glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc,
unsigned long mask);
static CGLPixelFormatObj makeFormat(__GLXconfig * conf);
static CGLPixelFormatObj
makeFormat(__GLXconfig *conf);
__GLXprovider __glXDRISWRastProvider = {
__glXAquaScreenProbe,
@ -94,9 +105,9 @@ typedef struct __GLXAquaDrawable __GLXAquaDrawable;
/*
* The following structs must keep the base as the first member.
* It's used to treat the start of the struct as a different struct
* in GLX.
* in GLX.
*
* Note: these structs should be initialized with xcalloc or memset
* Note: these structs should be initialized with xcalloc or memset
* prior to usage, and some of them require initializing
* the base with function pointers.
*/
@ -111,7 +122,7 @@ struct __GLXAquaContext {
CGLContextObj ctx;
CGLPixelFormatObj pixelFormat;
xp_surface_id sid;
unsigned isAttached:1;
unsigned isAttached : 1;
};
struct __GLXAquaDrawable {
@ -122,12 +133,12 @@ struct __GLXAquaDrawable {
};
static __GLXcontext *
__glXAquaScreenCreateContext(__GLXscreen * screen,
__GLXconfig * conf,
__GLXcontext * baseShareContext)
__glXAquaScreenCreateContext(__GLXscreen *screen,
__GLXconfig *conf,
__GLXcontext *baseShareContext)
{
__GLXAquaContext *context;
__GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext;
__GLXAquaContext *shareContext = (__GLXAquaContext *)baseShareContext;
CGLError gl_err;
GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
@ -176,21 +187,21 @@ __glXAquaScreenCreateContext(__GLXscreen * screen,
static x_hash_table *surface_hash;
static void
__glXAquaContextDestroy(__GLXcontext * baseContext)
__glXAquaContextDestroy(__GLXcontext *baseContext)
{
x_list *lst;
__GLXAquaContext *context = (__GLXAquaContext *) baseContext;
__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);
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);
x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(
context->sid), lst);
}
if (context->ctx != NULL)
@ -204,7 +215,7 @@ __glXAquaContextDestroy(__GLXcontext * baseContext)
}
static int
__glXAquaContextLoseCurrent(__GLXcontext * baseContext)
__glXAquaContextLoseCurrent(__GLXcontext *baseContext)
{
CGLError gl_err;
@ -214,9 +225,9 @@ __glXAquaContextLoseCurrent(__GLXcontext * baseContext)
if (gl_err != 0)
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
* glxcmds.c does it as part of the context cache flush after calling
* this.
*/
@ -228,11 +239,10 @@ __glXAquaContextLoseCurrent(__GLXcontext * baseContext)
static void
surface_notify(void *_arg, void *data)
{
DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *) _arg;
__GLXAquaDrawable *draw = (__GLXAquaDrawable *) data;
DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *)_arg;
__GLXAquaDrawable *draw = (__GLXAquaDrawable *)data;
__GLXAquaContext *context;
x_list *lst;
if (_arg == NULL || data == NULL) {
ErrorF("surface_notify called with bad params");
return;
@ -250,14 +260,15 @@ surface_notify(void *_arg, void *data)
case AppleDRISurfaceNotifyChanged:
if (surface_hash != NULL) {
lst =
x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id),
NULL);
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;
@ -265,7 +276,7 @@ surface_notify(void *_arg, void *data)
}
static BOOL
attach(__GLXAquaContext * context, __GLXAquaDrawable * draw)
attach(__GLXAquaContext *context, __GLXAquaDrawable *draw)
{
DrawablePtr pDraw;
@ -284,7 +295,8 @@ attach(__GLXAquaContext * context, __GLXAquaDrawable * draw)
if (draw->sid == 0) {
//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;
}
@ -311,16 +323,16 @@ attach(__GLXAquaContext * context, __GLXAquaDrawable * draw)
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);
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);
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);
GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int)pDraw->id,
(unsigned int)draw->sid);
}
draw->context = context;
@ -328,12 +340,11 @@ attach(__GLXAquaContext * context, __GLXAquaDrawable * draw)
return FALSE;
}
#if 0 // unused
#if 0 // unused
static void
unattach(__GLXAquaContext * context)
unattach(__GLXAquaContext *context)
{
x_list *lst;
GLAQUA_DEBUG_MSG("unattach\n");
if (context == NULL) {
ErrorF("Tried to unattach a null context\n");
@ -343,10 +354,10 @@ unattach(__GLXAquaContext * context)
GLAQUA_DEBUG_MSG("unattaching\n");
if (surface_hash != NULL) {
lst =
x_hash_table_lookup(surface_hash, (void *) context->sid, 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);
x_hash_table_insert(surface_hash, (void *)context->sid, lst);
}
CGLClearDrawable(context->ctx);
@ -357,16 +368,16 @@ unattach(__GLXAquaContext * context)
#endif
static int
__glXAquaContextMakeCurrent(__GLXcontext * baseContext)
__glXAquaContextMakeCurrent(__GLXcontext *baseContext)
{
CGLError gl_err;
__GLXAquaContext *context = (__GLXAquaContext *) baseContext;
__GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *) context->base.drawPriv;
__GLXAquaContext *context = (__GLXAquaContext *)baseContext;
__GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *)context->base.drawPriv;
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)
@ -376,13 +387,13 @@ __glXAquaContextMakeCurrent(__GLXcontext * baseContext)
}
static int
__glXAquaContextCopy(__GLXcontext * baseDst, __GLXcontext * baseSrc,
__glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc,
unsigned long mask)
{
CGLError gl_err;
__GLXAquaContext *dst = (__GLXAquaContext *) baseDst;
__GLXAquaContext *src = (__GLXAquaContext *) baseSrc;
__GLXAquaContext *dst = (__GLXAquaContext *)baseDst;
__GLXAquaContext *src = (__GLXAquaContext *)baseSrc;
GLAQUA_DEBUG_MSG("GLXAquaContextCopy\n");
@ -395,7 +406,7 @@ __glXAquaContextCopy(__GLXcontext * baseDst, __GLXcontext * baseSrc,
/* Drawing surface notification callbacks */
static GLboolean
__glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable * base)
__glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable *base)
{
CGLError err;
__GLXAquaDrawable *drawable;
@ -407,11 +418,11 @@ __glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable * base)
return GL_FALSE;
}
drawable = (__GLXAquaDrawable *) base;
drawable = (__GLXAquaDrawable *)base;
if (NULL == drawable->context) {
ErrorF("%s called with a NULL->context for drawable %p!\n",
__func__, (void *) drawable);
__func__, (void *)drawable);
return GL_FALSE;
}
@ -427,7 +438,7 @@ __glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable * base)
}
static CGLPixelFormatObj
makeFormat(__GLXconfig * conf)
makeFormat(__GLXconfig *conf)
{
CGLPixelFormatAttribute attr[64];
CGLPixelFormatObj fobj;
@ -451,7 +462,7 @@ makeFormat(__GLXconfig * conf)
attr[i++] = kCGLPFAAccumSize;
attr[i++] = conf->accumRedBits + conf->accumGreenBits
+ conf->accumBlueBits + conf->accumAlphaBits;
+ conf->accumBlueBits + conf->accumAlphaBits;
}
attr[i++] = kCGLPFADepthSize;
@ -486,7 +497,7 @@ makeFormat(__GLXconfig * conf)
}
static void
__glXAquaScreenDestroy(__GLXscreen * screen)
__glXAquaScreenDestroy(__GLXscreen *screen)
{
GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen);
@ -517,9 +528,8 @@ __glXAquaScreenProbe(ScreenPtr pScreen)
screen->base.swapInterval = /*FIXME*/ NULL;
screen->base.pScreen = pScreen;
screen->base.fbconfigs =
__glXAquaCreateVisualConfigs(&screen->base.numFBConfigs,
pScreen->myNum);
screen->base.fbconfigs = __glXAquaCreateVisualConfigs(
&screen->base.numFBConfigs, pScreen->myNum);
__glXScreenInit(&screen->base, pScreen);
@ -536,24 +546,24 @@ __glXAquaScreenProbe(ScreenPtr pScreen)
return &screen->base;
}
#if 0 // unused
#if 0 // unused
static void
__glXAquaDrawableCopySubBuffer(__GLXdrawable * drawable,
__glXAquaDrawableCopySubBuffer(__GLXdrawable *drawable,
int x, int y, int w, int h)
{
/*TODO finish me */
/*TODO finish me*/
}
#endif
static void
__glXAquaDrawableDestroy(__GLXdrawable * base)
__glXAquaDrawableDestroy(__GLXdrawable *base)
{
/* gstaplin: base is the head of the structure, so it's at the same
/* gstaplin: base is the head of the structure, so it's at the same
* offset in memory.
* Is this safe with strict aliasing? I noticed that the other dri code
* does this too...
*/
__GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *) base;
__GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *)base;
GLAQUA_DEBUG_MSG("TRACE");
@ -562,10 +572,10 @@ __glXAquaDrawableDestroy(__GLXdrawable * base)
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.
*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);
@ -573,10 +583,12 @@ __glXAquaDrawableDestroy(__GLXdrawable * base)
static __GLXdrawable *
__glXAquaScreenCreateDrawable(ClientPtr client,
__GLXscreen * screen,
__GLXscreen *screen,
DrawablePtr pDraw,
XID drawId,
int type, XID glxDrawId, __GLXconfig * conf)
int type,
XID glxDrawId,
__GLXconfig *conf)
{
__GLXAquaDrawable *glxPriv;
@ -587,8 +599,8 @@ __glXAquaScreenCreateDrawable(ClientPtr client,
memset(glxPriv, 0, sizeof *glxPriv);
if (!__glXDrawableInit
(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId,
conf)) {
free(glxPriv);
return NULL;
}
@ -619,7 +631,8 @@ __glFloorLog2(GLuint val)
}
#ifndef OPENGL_FRAMEWORK_PATH
#define OPENGL_FRAMEWORK_PATH "/System/Library/Frameworks/OpenGL.framework/OpenGL"
#define OPENGL_FRAMEWORK_PATH \
"/System/Library/Frameworks/OpenGL.framework/OpenGL"
#endif
static void
@ -639,7 +652,7 @@ setup_dispatch_table(void)
opengl_framework_path = OPENGL_FRAMEWORK_PATH;
}
(void) dlerror(); /*drain dlerror */
(void)dlerror(); /*drain dlerror */
handle = dlopen(opengl_framework_path, RTLD_LOCAL);
if (!handle) {

View File

@ -73,7 +73,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
}
/*
conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
so we treat a true conf->stereo as 2.
The depth size is 0 or 24. Thus we do 2 iterations for that.
@ -86,9 +86,9 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
conf->total_color_buffers indicates the RGB/RGBA color depths.
conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
conf->total_depth_buffer_depths
conf->total_depth_buffer_depths
conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
for the 0 multisampling config.
@ -104,14 +104,15 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
continue;
numConfigs += (conf->stereo ? 2 : 1)
* (conf->aux_buffers ? 2 : 1)
* conf->buffers
*
((conf->total_stencil_bit_depths >
0) ? conf->total_stencil_bit_depths : 1)
* conf->total_color_buffers *
((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
* conf->total_depth_buffer_depths * (conf->multisample_buffers + 1);
* (conf->aux_buffers ? 2 : 1)
* conf->buffers
* ((conf->total_stencil_bit_depths >
0) ? conf->total_stencil_bit_depths : 1)
* conf->total_color_buffers
* ((conf->total_accum_buffers >
0) ? conf->total_accum_buffers : 1)
* conf->total_depth_buffer_depths
* (conf->multisample_buffers + 1);
}
if (numConfigsPtr)
@ -125,22 +126,22 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
return NULL;
}
c = visualConfigs; /* current buffer */
c = visualConfigs; /* current buffer */
for (conf = caps.configurations; conf; conf = conf->next) {
for (stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
for (aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
for (buffers = 0; buffers < conf->buffers; ++buffers) {
for (stencil = 0;
stencil <
((conf->total_stencil_bit_depths >
0) ? conf->total_stencil_bit_depths : 1);
stencil < ((conf->total_stencil_bit_depths > 0) ?
conf->
total_stencil_bit_depths : 1);
++stencil) {
for (color = 0; color < conf->total_color_buffers;
++color) {
for (accum = 0;
accum <
((conf->total_accum_buffers >
0) ? conf->total_accum_buffers : 1);
accum < ((conf->total_accum_buffers > 0) ?
conf->
total_accum_buffers : 1);
++accum) {
for (depth = 0;
depth < conf->total_depth_buffer_depths;
@ -159,7 +160,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->level = 0;
c->indexBits = 0;
c->pixmapMode = 0; // TODO: What should this be?
c->pixmapMode = 0; // TODO: What should this be?
if (conf->accelerated) {
c->visualRating = GLX_NONE;
@ -178,7 +179,8 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->visualSelectGroup = 0;
c->swapMethod = GLX_SWAP_UNDEFINED_OML;
c->swapMethod =
GLX_SWAP_UNDEFINED_OML;
// Stereo
c->stereoMode = stereo ? TRUE : FALSE;
@ -192,10 +194,11 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
buffers ? TRUE : FALSE;
// Stencil Buffer
if (conf->total_stencil_bit_depths > 0) {
if (conf->total_stencil_bit_depths >
0) {
c->stencilBits =
conf->
stencil_bit_depths[stencil];
conf->stencil_bit_depths[
stencil];
}
else {
c->stencilBits = 0;
@ -217,22 +220,27 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->blueBits =
conf->color_buffers[color].b;
c->rgbBits =
c->alphaBits + c->redBits +
c->greenBits + c->blueBits;
c->rgbBits = c->alphaBits +
c->redBits +
c->greenBits +
c->blueBits;
c->alphaMask =
AM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits);
c->greenBits,
c->blueBits);
c->redMask =
RM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits);
c->greenBits,
c->blueBits);
c->greenMask =
GM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits);
c->greenBits,
c->blueBits);
c->blueMask =
BM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits);
c->greenBits,
c->blueBits);
// Accumulation Buffers
if (conf->total_accum_buffers > 0) {
@ -242,12 +250,14 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
conf->accum_buffers[accum].g;
c->accumBlueBits =
conf->accum_buffers[accum].b;
if (GLCAPS_COLOR_BUF_INVALID_VALUE
if (
GLCAPS_COLOR_BUF_INVALID_VALUE
!=
conf->accum_buffers[accum].a) {
conf->accum_buffers[accum].a)
{
c->accumAlphaBits =
conf->accum_buffers[accum].
a;
conf->accum_buffers[accum
].a;
}
else {
c->accumAlphaBits = 0;
@ -276,33 +286,33 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->sampleBuffers = 0;
}
/*
* The Apple libGL supports GLXPixmaps and
/*
* The Apple libGL supports GLXPixmaps and
* GLXPbuffers in direct mode.
*/
/* SGIX_fbconfig / GLX 1.3 */
c->drawableType =
GLX_WINDOW_BIT | GLX_PIXMAP_BIT |
GLX_PBUFFER_BIT;
c->drawableType = GLX_WINDOW_BIT |
GLX_PIXMAP_BIT |
GLX_PBUFFER_BIT;
c->renderType = GLX_RGBA_BIT;
c->xRenderable = GL_TRUE;
c->fbconfigID = -1;
/* SGIX_pbuffer / GLX 1.3 */
/*
/*
* The CGL layer provides a way of retrieving
* the maximum pbuffer width/height, but only
* if we create a context and call glGetIntegerv.
*
*
* The following values are from a test program
* that does so.
*/
c->maxPbufferWidth = 8192;
c->maxPbufferHeight = 8192;
c->maxPbufferPixels =
/*Do we need this? */ 0;
/*
/*Do we need this?*/ 0;
/*
* There is no introspection for this sort of thing
* with CGL. What should we do realistically?
*/
@ -330,9 +340,9 @@ __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));
FatalError(
"numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n",
numConfigs, (int)(c - visualConfigs));
}
freeGlCapabilities(&caps);

View File

@ -23,6 +23,7 @@
#ifndef VISUAL_CONFIGS_H
#define VISUAL_CONFIGS_H
__GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber);
__GLXconfig *
__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber);
#endif

View File

@ -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
@ -34,57 +35,37 @@
#import "X11Controller.h"
@ interface X11Application:NSApplication {
@interface X11Application : NSApplication {
X11Controller *_controller;
unsigned int _x_active:1;
unsigned int _x_active : 1;
}
-(void) set_controller:controller;
-(void) set_window_menu:(NSArray *) list;
- (void)set_controller:controller;
- (void)set_window_menu:(NSArray *)list;
-(CFPropertyListRef) prefs_get_copy:(NSString *)
key CF_RETURNS_RETAINED;
- (CFPropertyListRef)prefs_get_copy:(NSString *)key CF_RETURNS_RETAINED;
- (int)prefs_get_integer:(NSString *)key default:(int)def;
- (const char *)prefs_get_string:(NSString *)key default:(const char *)def;
- (float)prefs_get_float:(NSString *)key default:(float)def;
- (int)prefs_get_boolean:(NSString *)key default:(int)def;
- (NSURL *)prefs_copy_url:(NSString *)key default:(NSURL *)def
NS_RETURNS_RETAINED;
- (NSArray *)prefs_get_array:(NSString *)key;
- (void)prefs_set_integer:(NSString *)key value:(int)value;
- (void)prefs_set_float:(NSString *)key value:(float)value;
- (void)prefs_set_boolean:(NSString *)key value:(int)value;
- (void)prefs_set_array:(NSString *)key value:(NSArray *)value;
- (void)prefs_set_string:(NSString *)key value:(NSString *)value;
- (void)prefs_synchronize;
-(int) prefs_get_integer:(NSString *)
key default:(int) def;
- (X11Controller *)controller;
- (OSX_BOOL)x_active;
@end
-(const char *) prefs_get_string:(NSString *)
key default:(const char *) def;
extern X11Application * X11App;
-(float) prefs_get_float:(NSString *)
key default:(float) def;
-(int) prefs_get_boolean:(NSString *)
key default:(int) def;
-(NSURL *) prefs_copy_url:(NSString *)
key default:(NSURL *)
def NS_RETURNS_RETAINED;
-(NSArray *) prefs_get_array:(NSString *) key;
-(void) prefs_set_integer:(NSString *)
key value:(int) value;
-(void) prefs_set_float:(NSString *)
key value:(float) value;
-(void) prefs_set_boolean:(NSString *)
key value:(int) value;
-(void) prefs_set_array:(NSString *)
key value:(NSArray *) value;
-(void) prefs_set_string:(NSString *)
key value:(NSString *) value;
-(void) prefs_synchronize;
-(X11Controller *) controller;
-(OSX_BOOL) x_active;
@end extern X11Application *X11App;
#endif /* __OBJC__ */
#endif /* __OBJC__ */
void
X11ApplicationSetWindowMenu(int nitems, const char **items,
@ -105,38 +86,38 @@ X11ApplicationLaunchClient(const char *cmd);
Bool
X11ApplicationCanEnterRandR(void);
void
X11ApplicationMain(int argc, char **argv, char **envp);
void
X11ApplicationFatalError(const char *f, va_list args) __printflike(1, 0);
#define PREFS_APPSMENU "apps_menu"
#define PREFS_FAKEBUTTONS "enable_fake_buttons"
#define PREFS_KEYEQUIVS "enable_key_equivalents"
#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
#define PREFS_FULLSCREEN_MENU "fullscreen_menu"
#define PREFS_SYNC_KEYMAP "sync_keymap"
#define PREFS_DEPTH "depth"
#define PREFS_NO_AUTH "no_auth"
#define PREFS_NO_TCP "nolisten_tcp"
#define PREFS_DONE_XINIT_CHECK "done_xinit_check"
#define PREFS_NO_QUIT_ALERT "no_quit_alert"
#define PREFS_NO_RANDR_ALERT "no_randr_alert"
#define PREFS_OPTION_SENDS_ALT "option_sends_alt"
#define PREFS_FAKE_BUTTON2 "fake_button2"
#define PREFS_FAKE_BUTTON3 "fake_button3"
#define PREFS_APPKIT_MODIFIERS "appkit_modifiers"
#define PREFS_WINDOW_ITEM_MODIFIERS "window_item_modifiers"
#define PREFS_ROOTLESS "rootless"
#define PREFS_RENDER_EXTENSION "enable_render_extension"
#define PREFS_TEST_EXTENSIONS "enable_test_extensions"
#define PREFS_XP_OPTIONS "xp_options"
#define PREFS_LOGIN_SHELL "login_shell"
#define PREFS_UPDATE_FEED "update_feed"
#define PREFS_CLICK_THROUGH "wm_click_through"
#define PREFS_FFM "wm_ffm"
#define PREFS_FOCUS_ON_NEW_WINDOW "wm_focus_on_new_window"
void
X11ApplicationMain(int argc, char **argv, char **envp);
#define PREFS_APPSMENU "apps_menu"
#define PREFS_FAKEBUTTONS "enable_fake_buttons"
#define PREFS_KEYEQUIVS "enable_key_equivalents"
#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
#define PREFS_FULLSCREEN_MENU "fullscreen_menu"
#define PREFS_SYNC_KEYMAP "sync_keymap"
#define PREFS_DEPTH "depth"
#define PREFS_NO_AUTH "no_auth"
#define PREFS_NO_TCP "nolisten_tcp"
#define PREFS_DONE_XINIT_CHECK "done_xinit_check"
#define PREFS_NO_QUIT_ALERT "no_quit_alert"
#define PREFS_NO_RANDR_ALERT "no_randr_alert"
#define PREFS_OPTION_SENDS_ALT "option_sends_alt"
#define PREFS_FAKE_BUTTON2 "fake_button2"
#define PREFS_FAKE_BUTTON3 "fake_button3"
#define PREFS_APPKIT_MODIFIERS "appkit_modifiers"
#define PREFS_WINDOW_ITEM_MODIFIERS "window_item_modifiers"
#define PREFS_ROOTLESS "rootless"
#define PREFS_RENDER_EXTENSION "enable_render_extension"
#define PREFS_TEST_EXTENSIONS "enable_test_extensions"
#define PREFS_XP_OPTIONS "xp_options"
#define PREFS_LOGIN_SHELL "login_shell"
#define PREFS_UPDATE_FEED "update_feed"
#define PREFS_CLICK_THROUGH "wm_click_through"
#define PREFS_FFM "wm_ffm"
#define PREFS_FOCUS_ON_NEW_WINDOW "wm_focus_on_new_window"
#define PREFS_SCROLL_IN_DEV_DIRECTION "scroll_in_device_direction"
extern Bool XQuartzScrollInDeviceDirection;
@ -147,4 +128,4 @@ extern Bool XQuartzScrollInDeviceDirection;
#define PREFS_SYNC_CLIPBOARD_TO_PB "sync_clipboard_to_pasteboard"
#define PREFS_SYNC_PRIMARY_ON_SELECT "sync_primary_on_select"
#endif /* X11APPLICATION_H */
#endif /* X11APPLICATION_H */

File diff suppressed because it is too large Load Diff

View File

@ -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
@ -55,9 +56,9 @@ typedef unsigned int NSUInteger;
#endif
#endif
@interface X11Controller:NSObject
@interface X11Controller : NSObject
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
< NSTableViewDataSource >
<NSTableViewDataSource>
#endif
{
IBOutlet NSPanel *prefs_panel;
@ -85,7 +86,6 @@ typedef unsigned int NSUInteger;
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"
@ -95,7 +95,6 @@ typedef unsigned int NSUInteger;
IBOutlet NSMenuItem *dock_window_separator;
IBOutlet NSMenuItem *apps_separator;
IBOutlet NSMenuItem *toggle_fullscreen_item;
#ifdef XQUARTZ_SPARKLE
NSMenuItem *check_for_updates_item; // Programatically enabled
#endif
@ -118,40 +117,41 @@ typedef unsigned int NSUInteger;
OSX_BOOL can_quit;
}
-(void) set_window_menu:(NSArray *) list;
-(void) set_window_menu_check:(NSNumber *) n;
-(void) set_apps_menu:(NSArray *) list;
- (void)set_window_menu:(NSArray *)list;
- (void)set_window_menu_check:(NSNumber *)n;
- (void)set_apps_menu:(NSArray *)list;
#ifdef XQUARTZ_SPARKLE
-(void) setup_sparkle;
-(void) updater:(SUUpdater *)
updater willInstallUpdate:(SUAppcastItem *) update;
- (void)setup_sparkle;
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)
update;
#endif
-(void) set_can_quit:(OSX_BOOL) state;
-(void) server_ready;
-(OSX_BOOL) application:(NSApplication *)
app openFile:(NSString *) filename;
- (void)set_can_quit:(OSX_BOOL)state;
- (void)server_ready;
- (OSX_BOOL)application:(NSApplication *)app openFile:(NSString *)filename;
-(IBAction) apps_table_show:(id) sender;
-(IBAction) apps_table_done:(id) sender;
-(IBAction) apps_table_new:(id) sender;
-(IBAction) apps_table_duplicate:(id) sender;
-(IBAction) apps_table_delete:(id) sender;
-(IBAction) bring_to_front:(id) sender;
-(IBAction) close_window:(id) sender;
-(IBAction) minimize_window:(id) sender;
-(IBAction) zoom_window:(id) sender;
-(IBAction) next_window:(id) sender;
-(IBAction) previous_window:(id) sender;
-(IBAction) enable_fullscreen_changed:(id) sender;
-(IBAction) toggle_fullscreen:(id) sender;
-(IBAction) prefs_changed:(id) sender;
-(IBAction) prefs_show:(id) sender;
-(IBAction) quit:(id) sender;
-(IBAction) x11_help:(id) sender;
- (IBAction)apps_table_show:(id)sender;
- (IBAction)apps_table_done:(id)sender;
- (IBAction)apps_table_new:(id)sender;
- (IBAction)apps_table_duplicate:(id)sender;
- (IBAction)apps_table_delete:(id)sender;
- (IBAction)bring_to_front:(id)sender;
- (IBAction)close_window:(id)sender;
- (IBAction)minimize_window:(id)sender;
- (IBAction)zoom_window:(id)sender;
- (IBAction)next_window:(id)sender;
- (IBAction)previous_window:(id)sender;
- (IBAction)enable_fullscreen_changed:(id)sender;
- (IBAction)toggle_fullscreen:(id)sender;
- (IBAction)prefs_changed:(id)sender;
- (IBAction)prefs_show:(id)sender;
- (IBAction)quit:(id)sender;
- (IBAction)x11_help:(id)sender;
@end
#endif /* __OBJC__ */
#endif /* __OBJC__ */
void
X11ControllerMain(int argc, char **argv, char **envp);
#endif /* X11CONTROLLER_H */
#endif /* X11CONTROLLER_H */

File diff suppressed because it is too large Load Diff

View File

@ -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"
@ -52,19 +55,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "X11Application.h"
#include "protocol-versions.h"
#define DEFINE_ATOM_HELPER(func,atom_name) \
static Atom func (void) { \
static int generation; \
static Atom atom; \
if (generation != serverGeneration) { \
generation = serverGeneration; \
atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
} \
return atom; \
}
#define DEFINE_ATOM_HELPER(func, atom_name) \
static Atom func(void) { \
static int generation; \
static Atom atom; \
if (generation != serverGeneration) { \
generation = serverGeneration; \
atom = MakeAtom(atom_name, strlen(atom_name), TRUE); \
} \
return atom; \
}
DEFINE_ATOM_HELPER(xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
DEFINE_ATOM_HELPER(xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
DEFINE_ATOM_HELPER(xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
static AppleWMProcsPtr appleWMProcs;
@ -73,7 +76,7 @@ static int WMErrorBase;
static unsigned char WMReqCode = 0;
static int WMEventBase = 0;
static RESTYPE ClientType, EventType; /* resource types for event masks */
static RESTYPE ClientType, EventType; /* resource types for event masks */
static XID eventResource;
/* Currently selected events */
@ -84,7 +87,7 @@ WMFreeClient(pointer data, XID id);
static int
WMFreeEvents(pointer data, XID id);
static void
SNotifyEvent(xAppleWMNotifyEvent * from, xAppleWMNotifyEvent * to);
SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to);
typedef struct _WMEvent *WMEventPtr;
typedef struct _WMEvent {
@ -98,7 +101,6 @@ static inline BoxRec
make_box(int x, int y, int w, int h)
{
BoxRec r;
r.x1 = x;
r.y1 = y;
r.x2 = x + w;
@ -155,14 +157,14 @@ ProcAppleWMQueryVersion(register ClientPtr client)
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *) &rep);
WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
return Success;
}
/* events */
static inline void
updateEventMask(WMEventPtr * pHead)
updateEventMask(WMEventPtr *pHead)
{
WMEventPtr pCur;
@ -171,18 +173,19 @@ updateEventMask(WMEventPtr * pHead)
eventMask |= pCur->mask;
}
/*ARGSUSED*/ static int
/*ARGSUSED*/
static int
WMFreeClient(pointer data, XID id)
{
WMEventPtr pEvent;
WMEventPtr *pHead, pCur, pPrev;
WMEventPtr *pHead, pCur, pPrev;
int i;
pEvent = (WMEventPtr) data;
i = dixLookupResourceByType((pointer *) &pHead, eventResource, EventType,
serverClient,
DixReadAccess | DixWriteAccess |
DixDestroyAccess);
pEvent = (WMEventPtr)data;
i = dixLookupResourceByType(
(pointer *)&pHead, eventResource, EventType, serverClient,
DixReadAccess |
DixWriteAccess | DixDestroyAccess);
if (i == Success && pHead) {
pPrev = 0;
for (pCur = *pHead; pCur && pCur != pEvent; pCur = pCur->next)
@ -195,22 +198,23 @@ WMFreeClient(pointer data, XID id)
}
updateEventMask(pHead);
}
free((pointer) pEvent);
free((pointer)pEvent);
return 1;
}
/*ARGSUSED*/ static int
/*ARGSUSED*/
static int
WMFreeEvents(pointer data, XID id)
{
WMEventPtr *pHead, pCur, pNext;
WMEventPtr *pHead, pCur, pNext;
pHead = (WMEventPtr *) data;
pHead = (WMEventPtr *)data;
for (pCur = *pHead; pCur; pCur = pNext) {
pNext = pCur->next;
FreeResource(pCur->clientResource, ClientType);
free((pointer) pCur);
free((pointer)pCur);
}
free((pointer) pHead);
free((pointer)pHead);
eventMask = 0;
return 1;
}
@ -224,8 +228,10 @@ ProcAppleWMSelectInput(register ClientPtr client)
int i;
REQUEST_SIZE_MATCH(xAppleWMSelectInputReq);
i = dixLookupResourceByType((pointer *) &pHead, eventResource, EventType,
client, DixWriteAccess);
i =
dixLookupResourceByType((pointer *)&pHead, eventResource, EventType,
client,
DixWriteAccess);
if (stuff->mask != 0) {
if (i == Success && pHead) {
/* check for existing entry. */
@ -239,7 +245,7 @@ ProcAppleWMSelectInput(register ClientPtr client)
}
/* build the entry */
pNewEvent = (WMEventPtr) malloc(sizeof(WMEventRec));
pNewEvent = (WMEventPtr)malloc(sizeof(WMEventRec));
if (!pNewEvent)
return BadAlloc;
pNewEvent->next = 0;
@ -251,7 +257,7 @@ ProcAppleWMSelectInput(register ClientPtr client)
*/
clientResource = FakeClientID(client->index);
pNewEvent->clientResource = clientResource;
if (!AddResource(clientResource, ClientType, (pointer) pNewEvent))
if (!AddResource(clientResource, ClientType, (pointer)pNewEvent))
return BadAlloc;
/*
* create a resource to contain a pointer to the list
@ -260,9 +266,9 @@ ProcAppleWMSelectInput(register ClientPtr client)
* done through the resource database.
*/
if (i != Success || !pHead) {
pHead = (WMEventPtr *) malloc(sizeof(WMEventPtr));
pHead = (WMEventPtr *)malloc(sizeof(WMEventPtr));
if (!pHead ||
!AddResource(eventResource, EventType, (pointer) pHead)) {
!AddResource(eventResource, EventType, (pointer)pHead)) {
FreeResource(clientResource, RT_NONE);
return BadAlloc;
}
@ -306,12 +312,14 @@ ProcAppleWMSelectInput(register ClientPtr client)
void
AppleWMSendEvent(int type, unsigned int mask, int which, int arg)
{
WMEventPtr *pHead, pEvent;
WMEventPtr *pHead, pEvent;
xAppleWMNotifyEvent se;
int i;
i = dixLookupResourceByType((pointer *) &pHead, eventResource, EventType,
serverClient, DixReadAccess);
i =
dixLookupResourceByType((pointer *)&pHead, eventResource, EventType,
serverClient,
DixReadAccess);
if (i != Success || !pHead)
return;
for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
@ -321,7 +329,7 @@ AppleWMSendEvent(int type, unsigned int mask, int which, int arg)
se.kind = which;
se.arg = arg;
se.time = currentTime.milliseconds;
WriteEventsToClient(pEvent->client, 1, (xEvent *) &se);
WriteEventsToClient(pEvent->client, 1, (xEvent *)&se);
}
}
@ -331,7 +339,7 @@ AppleWMSelectedEvents(void)
{
return eventMask;
}
/* general utility functions */
static int
@ -353,7 +361,7 @@ ProcAppleWMReenableUpdate(register ClientPtr client)
return Success;
}
/* window functions */
static int
@ -362,7 +370,6 @@ ProcAppleWMSetWindowMenu(register ClientPtr client)
const char *bytes, **items;
char *shortcuts;
int max_len, nitems, i, j;
REQUEST(xAppleWMSetWindowMenuReq);
REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
@ -372,13 +379,14 @@ ProcAppleWMSetWindowMenu(register ClientPtr client)
shortcuts = malloc(sizeof(char) * nitems);
max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
bytes = (char *) &stuff[1];
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) {
while (i < max_len)
{
if (bytes[i++] == 0)
break;
}
@ -418,7 +426,8 @@ ProcAppleWMSetWindowLevel(register ClientPtr client)
REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
if (Success != dixLookupWindow(&pWin, stuff->window, client, DixReadAccess))
if (Success != dixLookupWindow(&pWin, stuff->window, client,
DixReadAccess))
return BadValue;
if (stuff->level >= AppleWMNumWindowLevels) {
@ -456,7 +465,6 @@ static int
ProcAppleWMAttachTransient(register ClientPtr client)
{
WindowPtr pWinChild, pWinParent;
REQUEST(xAppleWMAttachTransientReq);
int err;
@ -496,7 +504,7 @@ ProcAppleWMSetCanQuit(register ClientPtr client)
X11ApplicationSetCanQuit(stuff->state);
return Success;
}
/* frame functions */
static int
@ -504,7 +512,6 @@ ProcAppleWMFrameGetRect(register ClientPtr client)
{
xAppleWMFrameGetRectReply rep;
BoxRec ir, or, rr;
REQUEST(xAppleWMFrameGetRectReq);
REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
@ -526,7 +533,7 @@ ProcAppleWMFrameGetRect(register ClientPtr client)
rep.w = rr.x2 - rr.x1;
rep.h = rr.y2 - rr.y1;
WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *) &rep);
WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *)&rep);
return Success;
}
@ -536,7 +543,6 @@ ProcAppleWMFrameHitTest(register ClientPtr client)
xAppleWMFrameHitTestReply rep;
BoxRec ir, or;
int ret;
REQUEST(xAppleWMFrameHitTestReq);
REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
@ -554,7 +560,7 @@ ProcAppleWMFrameHitTest(register ClientPtr client)
rep.ret = ret;
WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *) &rep);
WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *)&rep);
return Success;
}
@ -564,13 +570,13 @@ ProcAppleWMFrameDraw(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))
if (Success != dixLookupWindow(&pWin, stuff->window, client,
DixReadAccess))
return BadValue;
ir = make_box(stuff->ix, stuff->iy, stuff->iw, stuff->ih);
@ -582,7 +588,7 @@ ProcAppleWMFrameDraw(register ClientPtr client)
if (title_max < title_length)
return BadValue;
title_bytes = (unsigned char *) &stuff[1];
title_bytes = (unsigned char *)&stuff[1];
errno = appleWMProcs->FrameDraw(pWin, stuff->frame_class,
stuff->frame_attr, &or, &ir,
@ -593,7 +599,7 @@ ProcAppleWMFrameDraw(register ClientPtr client)
return Success;
}
/* dispatch */
static int
@ -612,37 +618,50 @@ ProcAppleWMDispatch(register ClientPtr client)
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;
}
}
static void
SNotifyEvent(xAppleWMNotifyEvent * from, xAppleWMNotifyEvent * to)
SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to)
{
to->type = from->type;
to->kind = from->kind;
@ -672,6 +691,7 @@ SProcAppleWMDispatch(register ClientPtr client)
switch (stuff->data) {
case X_AppleWMQueryVersion:
return SProcAppleWMQueryVersion(client);
default:
return BadRequest;
}
@ -680,7 +700,7 @@ SProcAppleWMDispatch(register ClientPtr client)
void
AppleWMExtensionInit(AppleWMProcsPtr procsPtr)
{
ExtensionEntry *extEntry;
ExtensionEntry* extEntry;
ClientType = CreateNewResourceType(WMFreeClient, "WMClient");
EventType = CreateNewResourceType(WMFreeEvents, "WMEvent");
@ -692,14 +712,14 @@ AppleWMExtensionInit(AppleWMProcsPtr procsPtr)
AppleWMNumberErrors,
ProcAppleWMDispatch,
SProcAppleWMDispatch,
NULL, StandardMinorOpcode))) {
NULL,
StandardMinorOpcode))) {
size_t i;
WMReqCode = (unsigned char) extEntry->base;
WMReqCode = (unsigned char)extEntry->base;
WMErrorBase = extEntry->errorBase;
WMEventBase = extEntry->eventBase;
for (i = 0; i < AppleWMNumberEvents; i++)
EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent;
EventSwapVector[WMEventBase + i] = (EventSwapPtr)SNotifyEvent;
appleWMProcs = procsPtr;
}
}

View File

@ -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_
@ -40,21 +41,22 @@ typedef int xp_frame_class;
typedef int xp_frame_rect;
#endif
typedef int (*DisableUpdateProc) (void);
typedef int (*EnableUpdateProc) (void);
typedef int (*SetWindowLevelProc) (WindowPtr pWin, int level);
typedef int (*FrameGetRectProc) (xp_frame_rect type, xp_frame_class class,
const BoxRec * outer, const BoxRec * inner,
BoxRec * ret);
typedef int (*FrameHitTestProc) (xp_frame_class class, int x, int y,
const BoxRec * outer, const BoxRec * inner,
int *ret);
typedef int (*FrameDrawProc) (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);
typedef int (*SendPSNProc) (uint32_t hi, uint32_t lo);
typedef int (*AttachTransientProc) (WindowPtr pWinChild, WindowPtr pWinParent);
typedef int (*DisableUpdateProc)(void);
typedef int (*EnableUpdateProc)(void);
typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class,
const BoxRec *outer,
const BoxRec *inner, BoxRec *ret);
typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y,
const BoxRec *outer,
const BoxRec *inner, int *ret);
typedef int (*FrameDrawProc)(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);
typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo);
typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent);
/*
* AppleWM implementation function list
@ -70,19 +72,21 @@ typedef struct _AppleWMProcs {
AttachTransientProc AttachTransient;
} AppleWMProcsRec, *AppleWMProcsPtr;
void AppleWMExtensionInit(AppleWMProcsPtr procsPtr);
void
AppleWMExtensionInit(AppleWMProcsPtr procsPtr);
void AppleWMSetScreenOrigin(WindowPtr pWin);
void
AppleWMSetScreenOrigin(WindowPtr pWin);
Bool AppleWMDoReorderWindow(WindowPtr pWin);
Bool
AppleWMDoReorderWindow(WindowPtr pWin);
void AppleWMSendEvent(int /* type */ ,
unsigned int /* mask */ ,
int /* which */ ,
int /* arg */
);
void
AppleWMSendEvent(int /* type */, unsigned int /* mask */, int /* which */,
int /* arg */
);
unsigned int AppleWMSelectedEvents(void
);
unsigned int
AppleWMSelectedEvents(void);
#endif /* _APPLEWMEXT_H_ */
#endif /* _APPLEWMEXT_H_ */

View File

@ -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
@ -30,7 +31,7 @@
#include <dix-config.h>
#else
#define DEBUG_CONSOLE_REDIRECT 1
#define HAVE_LIBDISPATCH 1
#define HAVE_LIBDISPATCH 1
#endif
#include <assert.h>
@ -102,7 +103,8 @@ _read_redirect(int fd, int flush)
asl_redirect *aslr = &redirect_fds[fd];
while ((nbytes =
read(fd, aslr->w, BUF_SIZE - (aslr->w - aslr->buf) - 1)) > 0) {
read(fd, aslr->w,
BUF_SIZE - (aslr->w - aslr->buf) - 1)) > 0) {
char *s, *p;
/* Increment our returned number read */
@ -114,7 +116,7 @@ _read_redirect(int fd, int flush)
/* One line at a time */
for (p = aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) {
// Find null or \n
for (s = p; *s && *s != '\n'; s++);
for (s = p; *s && *s != '\n'; s++) ;
if (*s == '\n') {
*s = '\0';
asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
@ -149,9 +151,8 @@ _read_redirect(int fd, int flush)
static void
read_from_source(void *_source)
{
dispatch_source_t source = (dispatch_source_t) _source;
dispatch_source_t source = (dispatch_source_t)_source;
int fd = dispatch_source_get_handle(source);
if (_read_redirect(fd, 0) == EOF) {
dispatch_source_cancel(source);
}
@ -160,7 +161,7 @@ read_from_source(void *_source)
static void
cancel_source(void *_source)
{
dispatch_source_t source = (dispatch_source_t) _source;
dispatch_source_t source = (dispatch_source_t)_source;
int fd = dispatch_source_get_handle(source);
asl_redirect *aslr = &redirect_fds[fd];
@ -174,7 +175,7 @@ cancel_source(void *_source)
dispatch_group_leave(read_source_group);
}
#else /* !HAVE_LIBDISPATCH */
#else /* !HAVE_LIBDISPATCH */
static void *
redirect_thread(void *ctx __unused)
{
@ -205,16 +206,18 @@ redirect_thread(void *ctx __unused)
if (fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
asl_log(NULL, NULL, ASL_LEVEL_ERR,
"Unexpected file descriptor: %d", fd);
"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);
asl_log(
NULL, NULL, ASL_LEVEL_ERR,
"kevent reported EOF on %d, but read doesn't concur.",
fd);
}
}
else {
@ -229,7 +232,7 @@ redirect_thread(void *ctx __unused)
memset(aslr, 0, sizeof(*aslr));
}
}
next:
next:
pthread_mutex_unlock(&redirect_fds_lock);
case EVFILT_TIMER:
@ -237,7 +240,8 @@ redirect_thread(void *ctx __unused)
return NULL;
default:
;;
;
;
}
}
@ -263,8 +267,8 @@ redirect_atexit(void)
/* 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));
dispatch_time(DISPATCH_TIME_NOW, 3LL *
NSEC_PER_SEC));
}
#else
{
@ -299,7 +303,8 @@ xq_asl_init(void)
assert(read_source_group != NULL);
#else
assert((kq = kqueue()) != -1);
assert(pthread_create(&redirect_pthread, NULL, redirect_thread, NULL) == 0);
assert(pthread_create(&redirect_pthread, NULL, redirect_thread,
NULL) == 0);
#endif
atexit(redirect_atexit);
@ -311,12 +316,10 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
#ifdef HAVE_LIBDISPATCH
int err __block = 0;
static dispatch_once_t once_control;
dispatch_once_f(&once_control, NULL, xq_asl_init);
#else
int err = 0;
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
assert(pthread_once(&once_control, xq_asl_init) == 0);
#endif
@ -330,70 +333,75 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
#define BLOCK_DONE goto done
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;
}
{
/* 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;
}
/* 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;
/* 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;
/* 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);
/* Don't block on reads from this fd */
fcntl(fd, F_SETFL,
O_NONBLOCK);
/* Start listening */
/* 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);
done:
assert(pthread_mutex_unlock(&redirect_fds_lock) == 0);
#endif
#undef BLOCK_DONE
@ -433,7 +441,7 @@ xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd)
#ifdef DEBUG_CONSOLE_REDIRECT
int
main(int argc __unused, char **argv __unused)
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);

View File

@ -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
@ -34,11 +34,13 @@
/* The given fd is replaced with a pipe. Anything written to it will will be
* logged to ASL.
*/
int xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd);
int
xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd);
/* The given fd is read from and passed along to ASL until all write ends of the
* pipe are closed. Once the last writer has closed the pipe, we close our end.
*/
int xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd);
int
xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd);
#endif

View File

@ -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
@ -84,7 +84,8 @@ aslclient aslc;
void
xq_asl_log(int level, const char *subsystem, const char *file,
const char *function, int line, const char *fmt, ...)
const char *function, int line, const char *fmt,
...)
{
va_list args;
aslmsg msg = asl_new(ASL_TYPE_MSG);
@ -119,7 +120,6 @@ DevPrivateKeyRec darwinScreenKeyRec;
io_connect_t darwinParamConnect = 0;
int darwinEventReadFD = -1;
int darwinEventWriteFD = -1;
// int darwinMouseAccelChange = 1;
int darwinFakeButtons = 0;
@ -141,7 +141,7 @@ int darwinFakeMouse3Mask = NX_COMMANDMASK;
#endif
// Modifier mask for overriding event delivery to appkit (might be useful to set this to rcommand for input menu
unsigned int darwinAppKitModMask = 0; // Any of these bits
unsigned int darwinAppKitModMask = 0; // Any of these bits
// Modifier mask for items in the Window menu (0 and -1 cause shortcuts to be disabled)
unsigned int windowItemModMask = NX_COMMANDMASK;
@ -155,15 +155,14 @@ 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
@ -182,12 +181,9 @@ static Bool
DarwinSaveScreen(ScreenPtr pScreen, int on)
{
// FIXME
if (on == SCREEN_SAVER_FORCER) {
}
else if (on == SCREEN_SAVER_ON) {
}
else {
}
if (on == SCREEN_SAVER_FORCER) {}
else if (on == SCREEN_SAVER_ON) {}
else {}
return TRUE;
}
@ -234,16 +230,18 @@ DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
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),
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),
RM_ARGB(0, 8, 8, 8), GM_ARGB(0, 8, 8,
8),
BM_ARGB(0, 8, 8, 8));
miSetPixmapDepths();
@ -256,12 +254,12 @@ DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
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
{
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
return FALSE;
}
@ -297,12 +295,12 @@ DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
}
/*
=============================================================================
=============================================================================
mouse and keyboard callbacks
mouse and keyboard callbacks
=============================================================================
*/
=============================================================================
*/
/*
* DarwinMouseProc: Handle the initialization, etc. of a mouse
@ -311,7 +309,7 @@ static int
DarwinMouseProc(DeviceIntPtr pPointer, int what)
{
#define NBUTTONS 7
#define NAXES 2
#define NAXES 2
// 7 buttons: left, right, middle, then four scroll wheel "buttons"
CARD8 map[NBUTTONS + 1] = { 0, 1, 2, 3, 4, 5, 6, 7 };
Atom btn_labels[NBUTTONS] = { 0 };
@ -333,19 +331,24 @@ DarwinMouseProc(DeviceIntPtr pPointer, int what)
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
// Set button map.
InitPointerDeviceStruct((DevicePtr) pPointer, map, NBUTTONS,
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
btn_labels,
(PtrCtrlProcPtr) NoopDDA,
GetMotionHistorySize(), NAXES, axes_labels);
(PtrCtrlProcPtr)NoopDDA,
GetMotionHistorySize(), NAXES,
axes_labels);
InitValuatorAxisStruct(pPointer, 0, axes_labels[0], NO_AXIS_LIMITS,
NO_AXIS_LIMITS, 1, 0, 1, Relative);
NO_AXIS_LIMITS, 1, 0, 1,
Relative);
InitValuatorAxisStruct(pPointer, 1, axes_labels[1], NO_AXIS_LIMITS,
NO_AXIS_LIMITS, 1, 0, 1, Relative);
NO_AXIS_LIMITS, 1, 0, 1,
Relative);
break;
case DEVICE_ON:
pPointer->public.on = TRUE;
AddEnabledDevice(darwinEventReadFD);
return Success;
case DEVICE_CLOSE:
case DEVICE_OFF:
pPointer->public.on = FALSE;
@ -362,7 +365,7 @@ static int
DarwinTabletProc(DeviceIntPtr pPointer, int what)
{
#define NBUTTONS 3
#define NAXES 5
#define NAXES 5
CARD8 map[NBUTTONS + 1] = { 0, 1, 2, 3 };
Atom btn_labels[NBUTTONS] = { 0 };
Atom axes_labels[NAXES] = { 0 };
@ -382,30 +385,38 @@ DarwinTabletProc(DeviceIntPtr pPointer, int what)
axes_labels[4] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
// Set button map.
InitPointerDeviceStruct((DevicePtr) pPointer, map, NBUTTONS,
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
btn_labels,
(PtrCtrlProcPtr) NoopDDA,
GetMotionHistorySize(), NAXES, axes_labels);
(PtrCtrlProcPtr)NoopDDA,
GetMotionHistorySize(), NAXES,
axes_labels);
InitProximityClassDeviceStruct(pPointer);
InitValuatorAxisStruct(pPointer, 0, axes_labels[0], 0,
XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
XQUARTZ_VALUATOR_LIMIT, 1, 0, 1,
Absolute);
InitValuatorAxisStruct(pPointer, 1, axes_labels[1], 0,
XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
XQUARTZ_VALUATOR_LIMIT, 1, 0, 1,
Absolute);
InitValuatorAxisStruct(pPointer, 2, axes_labels[2], 0,
XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
XQUARTZ_VALUATOR_LIMIT, 1, 0, 1,
Absolute);
InitValuatorAxisStruct(pPointer, 3, axes_labels[3],
-XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT,
1, 0, 1, Absolute);
-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;
-XQUARTZ_VALUATOR_LIMIT,
XQUARTZ_VALUATOR_LIMIT, 1, 0, 1,
Absolute);
// pPointer->use = IsXExtensionDevice;
break;
case DEVICE_ON:
pPointer->public.on = TRUE;
AddEnabledDevice(darwinEventReadFD);
return Success;
case DEVICE_CLOSE:
case DEVICE_OFF:
pPointer->public.on = FALSE;
@ -428,14 +439,17 @@ DarwinKeybdProc(DeviceIntPtr pDev, int onoff)
case DEVICE_INIT:
DarwinKeyboardInit(pDev);
break;
case DEVICE_ON:
pDev->public.on = TRUE;
AddEnabledDevice(darwinEventReadFD);
break;
case DEVICE_OFF:
pDev->public.on = FALSE;
RemoveEnabledDevice(darwinEventReadFD);
break;
case DEVICE_CLOSE:
break;
}
@ -444,12 +458,12 @@ DarwinKeybdProc(DeviceIntPtr pDev, int onoff)
}
/*
===========================================================================
===========================================================================
Utility routines
Utility routines
===========================================================================
*/
===========================================================================
*/
/*
* DarwinParseModifierList
@ -467,7 +481,7 @@ DarwinParseModifierList(const char *constmodifiers, int separatelr)
char *p = modifiers;
while (p) {
modifier = strsep(&p, " ,+&|/"); // allow lots of separators
modifier = strsep(&p, " ,+&|/"); // allow lots of separators
nxkey = DarwinModifierStringToNXMask(modifier, separatelr);
if (nxkey)
result |= nxkey;
@ -480,12 +494,12 @@ DarwinParseModifierList(const char *constmodifiers, int separatelr)
}
/*
===========================================================================
===========================================================================
Functions needed to link against device independent X
Functions needed to link against device independent X
===========================================================================
*/
===========================================================================
*/
/*
* InitInput
@ -494,8 +508,9 @@ DarwinParseModifierList(const char *constmodifiers, int separatelr)
void
InitInput(int argc, char **argv)
{
XkbRMLVOSet rmlvo = {.rules = "base",.model = "empty",.layout = "empty",
.variant = NULL,.options = NULL
XkbRMLVOSet rmlvo = {
.rules = "base", .model = "empty", .layout = "empty",
.variant = NULL, .options = NULL
};
/* We need to really have rules... or something... */
XkbSetRulesDflts(&rmlvo);
@ -555,7 +570,7 @@ CloseInput(void)
* easier target to hit.
*/
void
DarwinAdjustScreenOrigins(ScreenInfo * pScreenInfo)
DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
{
int i, left, top;
@ -607,7 +622,7 @@ DarwinAdjustScreenOrigins(ScreenInfo * pScreenInfo)
* SetupScreen function can be called to finalize screen setup.
*/
void
InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
int i;
@ -651,8 +666,8 @@ OsVendorInit(void)
if (serverGeneration == 1) {
char *lf;
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.
@ -660,7 +675,9 @@ OsVendorInit(void)
(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));
assert(0 <
asprintf(&lf, "%s/Library/Logs/X11/%s.log", home,
bundle_id_prefix));
LogInit(lf, ".old");
free(lf);
@ -668,15 +685,14 @@ OsVendorInit(void)
#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 (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);
if (debug_log_fp) ErrorF("Debug logging enabled to %s\n",
log_file_path);
}
free(log_file_path);
}
@ -694,15 +710,15 @@ 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], "-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], "-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)) {
@ -764,7 +780,8 @@ ddxProcessArgument(int argc, char *argv[], int i)
darwinDesiredDepth = atoi(argv[i + 1]);
if (darwinDesiredDepth != -1 &&
darwinDesiredDepth != 8 &&
darwinDesiredDepth != 15 && darwinDesiredDepth != 24) {
darwinDesiredDepth != 15 &&
darwinDesiredDepth != 24) {
FatalError("Unsupported pixel depth. Use 8, 15, or 24 bits\n");
}
@ -793,15 +810,15 @@ ddxUseMsg(void)
ErrorF("Device Dependent Usage:\n");
ErrorF("\n");
ErrorF("-depth <8,15,24> : use this bit depth.\n");
ErrorF
("-fakebuttons : fake a three button mouse with Command and Option keys.\n");
ErrorF(
"-fakebuttons : fake a three button mouse with Command and Option keys.\n");
ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
ErrorF
("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
ErrorF
("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
ErrorF
(" ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
ErrorF(
"-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
ErrorF(
"-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
ErrorF(
" ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
ErrorF("-version : show the server version.\n");
ErrorF("\n");
}
@ -822,7 +839,8 @@ ddxGiveUp(enum ExitCode error)
* made to restore all original setting of the displays. Also all devices
* are closed.
*/
_X_NORETURN void
_X_NORETURN
void
AbortDDX(enum ExitCode error)
{
ErrorF(" AbortDDX\n");

View File

@ -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
@ -37,18 +37,21 @@
#include "darwinfb.h"
// From darwin.c
void DarwinPrintBanner(void);
int DarwinParseModifierList(const char *constmodifiers, int separatelr);
void DarwinAdjustScreenOrigins(ScreenInfo * pScreenInfo);
void
DarwinPrintBanner(void);
int
DarwinParseModifierList(const char *constmodifiers, int separatelr);
void
DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
#define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \
dixLookupPrivate(&pScreen->devPrivates, darwinScreenKey))
dixLookupPrivate(&pScreen->devPrivates, \
darwinScreenKey))
/*
* Global variables from darwin.c
*/
extern DevPrivateKeyRec darwinScreenKeyRec;
#define darwinScreenKey (&darwinScreenKeyRec)
extern int darwinScreensFound;
extern io_connect_t darwinParamConnect;
@ -80,10 +83,17 @@ extern char *bundle_id_prefix;
_X_ATTRIBUTE_PRINTF(6, 7)
extern void
xq_asl_log(int level, const char *subsystem, const char *file,
const char *function, int line, const char *fmt, ...);
const char *function, int line, const char *fmt,
...);
#define ASL_LOG(level, subsystem, msg, args...) xq_asl_log(level, subsystem, __FILE__, __FUNCTION__, __LINE__, msg, ##args)
#define DEBUG_LOG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "XQuartz", msg, ##args)
#define TRACE() DEBUG_LOG("TRACE")
#define ASL_LOG(level, subsystem, msg, args ...) xq_asl_log(level, subsystem, \
__FILE__, \
__FUNCTION__, \
__LINE__, msg, \
## args)
#define DEBUG_LOG(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, \
"XQuartz", msg, \
## args)
#define TRACE() DEBUG_LOG("TRACE")
#endif /* _DARWIN_H */
#endif /* _DARWIN_H */

View File

@ -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"
@ -75,10 +83,10 @@ in this Software without prior written authorization from The Open Group.
#include "applewmExt.h"
/* FIXME: Abstract this better */
extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent * e,
DeviceIntPtr dev);
extern Bool
QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev);
int darwin_all_modifier_flags = 0; // last known modifier state
int darwin_all_modifier_flags = 0; // last known modifier state
int darwin_all_modifier_mask = 0;
int darwin_x11_modifier_mask = 0;
@ -89,14 +97,14 @@ static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_t fd_add_tid = NULL;
static InternalEvent *darwinEvents = NULL;
static InternalEvent* darwinEvents = NULL;
static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
/*** Pthread Magics ***/
static pthread_t
create_thread(void *(*func) (void *), void *arg)
create_thread(void *(*func)(void *), void *arg)
{
pthread_attr_t attr;
pthread_t tid;
@ -110,12 +118,12 @@ create_thread(void *(*func) (void *), void *arg)
return tid;
}
void darwinEvents_lock(void);
void
darwinEvents_lock(void);
void
darwinEvents_lock(void)
{
int err;
if ((err = pthread_mutex_lock(&mieq_lock))) {
ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n",
__FILE__, __FUNCTION__, __LINE__, err);
@ -126,12 +134,12 @@ darwinEvents_lock(void)
}
}
void darwinEvents_unlock(void);
void
darwinEvents_unlock(void);
void
darwinEvents_unlock(void)
{
int err;
if ((err = pthread_mutex_unlock(&mieq_lock))) {
ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n",
__FILE__, __FUNCTION__, __LINE__, err);
@ -163,12 +171,13 @@ DarwinPressModifierKey(int pressed, int key)
static int darwin_x11_modifier_mask_list[] = {
#ifdef NX_DEVICELCMDKEYMASK
NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK,
NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK,
NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK,
NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK,
#else
NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK,
NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK,
NX_ALTERNATEMASK,
#endif
NX_ALPHASHIFTMASK,
0
@ -177,8 +186,8 @@ 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
DarwinUpdateModifiers(int pressed, // KeyPress or KeyRelease
int flags) // modifier flags that have changed
{
int *f;
int key;
@ -195,7 +204,8 @@ DarwinUpdateModifiers(int pressed, // KeyPress or KeyRelease
if (*f & flags && *f != NX_ALPHASHIFTMASK) {
key = DarwinModifierNXMaskToNXKey(*f);
if (key == -1)
ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f);
ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n",
*f);
else
DarwinPressModifierKey(pressed, key);
}
@ -214,26 +224,32 @@ DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev)
case kXquartzControllerNotify:
DEBUG_LOG("kXquartzControllerNotify\n");
AppleWMSendEvent(AppleWMControllerNotify,
AppleWMControllerNotifyMask, e->data[0], e->data[1]);
AppleWMControllerNotifyMask,
e->data[0],
e->data[1]);
break;
case kXquartzPasteboardNotify:
DEBUG_LOG("kXquartzPasteboardNotify\n");
AppleWMSendEvent(AppleWMPasteboardNotify,
AppleWMPasteboardNotifyMask, e->data[0], e->data[1]);
AppleWMPasteboardNotifyMask,
e->data[0],
e->data[1]);
break;
case kXquartzActivate:
DEBUG_LOG("kXquartzActivate\n");
QuartzShow();
AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask, AppleWMIsActive, 0);
AppleWMActivationNotifyMask,
AppleWMIsActive, 0);
break;
case kXquartzDeactivate:
DEBUG_LOG("kXquartzDeactivate\n");
AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask, AppleWMIsInactive, 0);
AppleWMActivationNotifyMask,
AppleWMIsInactive, 0);
QuartzHide();
break;
@ -247,8 +263,8 @@ DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev)
case kXquartzToggleFullscreen:
DEBUG_LOG("kXquartzToggleFullscreen\n");
if (XQuartzIsRootless)
ErrorF
("Ignoring kXquartzToggleFullscreen because of rootless mode.");
ErrorF(
"Ignoring kXquartzToggleFullscreen because of rootless mode.");
else
QuartzRandRToggleFullscreen();
break;
@ -264,7 +280,7 @@ DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev)
break;
case kXquartzSetRootClip:
QuartzSetRootClip((Bool) e->data[0]);
QuartzSetRootClip((Bool)e->data[0]);
break;
case kXquartzQuit:
@ -277,8 +293,8 @@ DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev)
break;
case kXquartzListenOnOpenFD:
ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int) e->data[0]);
ListenOnOpenFD((int) e->data[0], 1);
ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]);
ListenOnOpenFD((int)e->data[0], 1);
break;
case kXquartzReloadKeymap:
@ -333,8 +349,8 @@ DarwinProcessFDAdditionQueue_thread(void *args)
sleep_for.tv_sec = 3;
sleep_for.tv_nsec = 0;
ErrorF
("X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n");
ErrorF(
"X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n");
while (nanosleep(&sleep_for, &sleep_remaining) != 0) {
sleep_for = sleep_remaining;
}
@ -361,8 +377,9 @@ DarwinEQInit(void)
darwin_x11_modifier_mask |= *p;
}
for (p = darwin_all_modifier_mask_additions, darwin_all_modifier_mask =
darwin_x11_modifier_mask; *p; p++) {
for (p = darwin_all_modifier_mask_additions,
darwin_all_modifier_mask = darwin_x11_modifier_mask;
*p; p++) {
darwin_all_modifier_mask |= *p;
}
@ -374,7 +391,8 @@ DarwinEQInit(void)
* here, so I don't bother.
*/
if (!darwinEvents) {
darwinEvents = InitEventList(GetMaximumEventsNum());;
darwinEvents = InitEventList(GetMaximumEventsNum());
;
if (!darwinEvents)
FatalError("Couldn't allocate event buffer\n");
@ -420,7 +438,6 @@ static void
DarwinPokeEQ(void)
{
char nullbyte = 0;
// <daniels> oh, i ... er ... christ.
write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte));
}
@ -430,10 +447,13 @@ DarwinPokeEQ(void)
* display.
*/
static void
DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask, ScreenPtr screen,
DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask,
ScreenPtr screen,
double pointer_x, double pointer_y,
double pressure, double tilt_x, double tilt_y)
double pressure, double tilt_x,
double tilt_y)
{
valuator_mask_zero(pmask);
/* Fix offset between darwin and X screens */
@ -449,29 +469,40 @@ DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask, ScreenPtr screen,
if (pDev == darwinPointer) {
valuator_mask_set_double(pmask, 0, pointer_x);
valuator_mask_set_double(pmask, 1, pointer_y);
} else {
valuator_mask_set_double(pmask, 0, XQUARTZ_VALUATOR_LIMIT * (pointer_x / (double)screenInfo.screens[0]->width));
valuator_mask_set_double(pmask, 1, XQUARTZ_VALUATOR_LIMIT * (pointer_y / (double)screenInfo.screens[0]->height));
}
else {
valuator_mask_set_double(pmask, 0, XQUARTZ_VALUATOR_LIMIT *
(pointer_x /
(double)screenInfo.screens[0]->width));
valuator_mask_set_double(pmask, 1, XQUARTZ_VALUATOR_LIMIT *
(pointer_y /
(double)screenInfo.screens[0]->height));
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));
}
void
DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
{
darwinEvents_lock(); {
darwinEvents_lock();
{
int i;
if (pDev->button) {
for (i = 0; i < pDev->button->numButtons; i++) {
if (BitIsOn(pDev->button->down, i)) {
QueuePointerEvents(pDev, ButtonRelease, i, POINTER_ABSOLUTE,
QueuePointerEvents(pDev, ButtonRelease, i,
POINTER_ABSOLUTE,
NULL);
}
}
@ -486,14 +517,14 @@ DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
}
}
DarwinPokeEQ();
}
darwinEvents_unlock();
} darwinEvents_unlock();
}
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 pointer_x, double pointer_y,
double pressure, double tilt_x,
double tilt_y)
{
static int darwinFakeMouseButtonDown = 0;
ScreenPtr screen;
@ -502,15 +533,15 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
//DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
if (!darwinEvents) {
DEBUG_LOG
("DarwinSendPointerEvents called before darwinEvents was initialized\n");
DEBUG_LOG(
"DarwinSendPointerEvents called before darwinEvents was initialized\n");
return;
}
screen = miPointerGetScreen(pDev);
if (!screen) {
DEBUG_LOG
("DarwinSendPointerEvents called before screen was initialized\n");
DEBUG_LOG(
"DarwinSendPointerEvents called before screen was initialized\n");
return;
}
@ -520,20 +551,21 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
/* We're currently "down" with another button, so release it first */
DarwinSendPointerEvents(pDev, ButtonRelease,
darwinFakeMouseButtonDown, pointer_x,
pointer_y, pressure, tilt_x, tilt_y);
pointer_y, pressure, tilt_x,
tilt_y);
darwinFakeMouseButtonDown = 0;
}
if (darwin_all_modifier_flags & darwinFakeMouse2Mask) {
ev_button = 2;
darwinFakeMouseButtonDown = 2;
DarwinUpdateModKeys(darwin_all_modifier_flags &
~darwinFakeMouse2Mask);
DarwinUpdateModKeys(
darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
}
else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) {
ev_button = 3;
darwinFakeMouseButtonDown = 3;
DarwinUpdateModKeys(darwin_all_modifier_flags &
~darwinFakeMouse3Mask);
DarwinUpdateModKeys(
darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
}
}
@ -543,21 +575,24 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
}
if (darwinFakeMouseButtonDown == 2) {
DarwinUpdateModKeys(darwin_all_modifier_flags &
~darwinFakeMouse2Mask);
DarwinUpdateModKeys(
darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
}
else if (darwinFakeMouseButtonDown == 3) {
DarwinUpdateModKeys(darwin_all_modifier_flags &
~darwinFakeMouse3Mask);
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);
pressure, tilt_x,
tilt_y);
darwinEvents_lock();
{
QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE,
&valuators);
DarwinPokeEQ();
} darwinEvents_unlock();
}
@ -567,46 +602,50 @@ DarwinSendKeyboardEvents(int ev_type, int keycode)
{
if (!darwinEvents) {
DEBUG_LOG
("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
DEBUG_LOG(
"DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
return;
}
darwinEvents_lock(); {
darwinEvents_lock();
{
QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE,
NULL);
DarwinPokeEQ();
}
darwinEvents_unlock();
} darwinEvents_unlock();
}
void
DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
double pointer_y, double pressure, double tilt_x,
double pointer_y,
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);
pointer_x, pointer_y, pressure, tilt_x,
tilt_y);
if (!darwinEvents) {
DEBUG_LOG
("DarwinSendProximityEvents called before darwinEvents was initialized\n");
DEBUG_LOG(
"DarwinSendProximityEvents called before darwinEvents was initialized\n");
return;
}
screen = miPointerGetScreen(pDev);
if (!screen) {
DEBUG_LOG
("DarwinSendPointerEvents called before screen was initialized\n");
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(); {
pressure, tilt_x,
tilt_y);
darwinEvents_lock();
{
QueueProximityEvents(pDev, ev_type, &valuators);
DarwinPokeEQ();
} darwinEvents_unlock();
@ -614,13 +653,14 @@ DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
/* Send the appropriate number of button clicks to emulate scroll wheel */
void
DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x,
double pointer_y, double pressure, double tilt_x,
double tilt_y)
DarwinSendScrollEvents(double scroll_x, double scroll_y,
double pointer_x, double pointer_y,
double pressure, double tilt_x, double tilt_y)
{
int sign_x, sign_y;
if (!darwinEvents) {
DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n");
DEBUG_LOG(
"DarwinSendScrollEvents called before darwinEvents was initialized\n");
return;
}
@ -632,21 +672,20 @@ DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x,
while ((scroll_x > 0.0f) || (scroll_y > 0.0f)) {
if (scroll_x > 0.0f) {
DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x,
pointer_x, pointer_y, pressure,
tilt_x, tilt_y);
pointer_x, pointer_y, pressure, tilt_x,
tilt_y);
DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x,
pointer_x, pointer_y, pressure,
tilt_x, tilt_y);
pointer_x, pointer_y, pressure, tilt_x,
tilt_y);
scroll_x = scroll_x - 1.0f;
}
if (scroll_y > 0.0f) {
DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y,
pointer_x, pointer_y, pressure,
tilt_x, tilt_y);
DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y,
pointer_x, pointer_y, pressure, tilt_x,
tilt_y);
DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y,
pointer_x, pointer_y, pressure,
tilt_x, tilt_y);
pointer_x, pointer_y, pressure, tilt_x,
tilt_y);
scroll_y = scroll_y - 1.0f;
}
}
@ -657,12 +696,12 @@ DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x,
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);
DarwinUpdateModifiers(
KeyRelease, darwin_all_modifier_flags & ~flags &
darwin_x11_modifier_mask);
DarwinUpdateModifiers(
KeyPress, ~darwin_all_modifier_flags & flags &
darwin_x11_modifier_mask);
darwin_all_modifier_flags = flags;
}
@ -687,12 +726,13 @@ DarwinSendDDXEvent(int type, int argc, ...)
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);
e.data[i] = (uint32_t)va_arg(args, uint32_t);
va_end(args);
}
darwinEvents_lock(); {
mieqEnqueue(NULL, (InternalEvent *) &e);
darwinEvents_lock();
{
mieqEnqueue(NULL, (InternalEvent *)&e);
DarwinPokeEQ();
} darwinEvents_unlock();
}

View File

@ -31,55 +31,69 @@
/* For extra precision of our cursor and other valuators */
#define XQUARTZ_VALUATOR_LIMIT (1 << 16)
Bool DarwinEQInit(void);
void DarwinEQFini(void);
void DarwinEQEnqueue(const xEventPtr e);
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);
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);
void DarwinUpdateModKeys(int flags);
void DarwinListenOnOpenFD(int fd);
Bool
DarwinEQInit(void);
void
DarwinEQFini(void);
void
DarwinEQEnqueue(const xEventPtr e);
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);
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);
void
DarwinUpdateModKeys(int flags);
void
DarwinListenOnOpenFD(int fd);
/*
* Subtypes for the ET_XQuartz event type
*/
enum {
kXquartzReloadKeymap, // Reload system keymap
kXquartzActivate, // restore X drawing and cursor
kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
kXquartzSetRootClip, // enable or disable drawing to the X screen
kXquartzQuit, // kill the X server and release the display
kXquartzBringAllToFront, // bring all X windows to front
kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
kXquartzSetRootless, // Set rootless mode
kXquartzSpaceChanged, // Spaces changed
kXquartzListenOnOpenFD, // Listen to the launchd fd (passed as arg)
kXquartzReloadKeymap, // Reload system keymap
kXquartzActivate, // restore X drawing and cursor
kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
kXquartzSetRootClip, // enable or disable drawing to the X screen
kXquartzQuit, // kill the X server and release the display
kXquartzBringAllToFront, // bring all X windows to front
kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
kXquartzSetRootless, // Set rootless mode
kXquartzSpaceChanged, // Spaces changed
kXquartzListenOnOpenFD, // Listen to the launchd fd (passed as arg)
/*
* AppleWM events
*/
kXquartzControllerNotify, // send an AppleWMControllerNotify event
kXquartzPasteboardNotify, // notify the WM to copy or paste
kXquartzReloadPreferences, // send AppleWMReloadPreferences
kXquartzControllerNotify, // send an AppleWMControllerNotify event
kXquartzPasteboardNotify, // notify the WM to copy or paste
kXquartzReloadPreferences, // send AppleWMReloadPreferences
/*
* Xplugin notification events
*/
kXquartzDisplayChanged, // display configuration has changed
kXquartzWindowState, // window visibility state has changed
kXquartzWindowMoved, // window has moved on screen
kXquartzDisplayChanged, // display configuration has changed
kXquartzWindowState, // window visibility state has changed
kXquartzWindowMoved, // window has moved on screen
};
/* Send one of the above events to the server thread. */
void DarwinSendDDXEvent(int type, int argc, ...);
void
DarwinSendDDXEvent(int type, int argc, ...);
/* A mask of the modifiers that are in our X11 keyboard layout:
* (Fn for example is just useful for 3button mouse emulation) */
@ -92,4 +106,4 @@ extern int darwin_x11_modifier_mask;
/* The current state of the above listed modifiers */
extern int darwin_all_modifier_flags;
#endif /* _DARWIN_EVENTS_H */
#endif /* _DARWIN_EVENTS_H */

View File

@ -7,49 +7,49 @@
/************************************************************
Copyright 1989, 1998 The Open Group
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.
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 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.
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.
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.
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
All Rights Reserved
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.
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.
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>
@ -112,7 +112,8 @@ SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
*/
int
ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, xDeviceCtl * control)
ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
xDeviceCtl * control)
{
DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
@ -127,7 +128,7 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, xDeviceCtl * control)
*
*/
int
NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
DeviceIntPtr *pdev)
{
DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);

View File

@ -31,7 +31,7 @@
#include "scrnintstr.h"
typedef struct {
void *framebuffer;
void *framebuffer;
int x;
int y;
int width;
@ -47,10 +47,11 @@ typedef struct {
Pixel blueMask;
} DarwinFramebufferRec, *DarwinFramebufferPtr;
#define MASK_LH(l,h) (((1 << (1 + (h) - (l))) - 1) << (l))
#define BM_ARGB(a,r,g,b) MASK_LH(0, (b) - 1)
#define GM_ARGB(a,r,g,b) MASK_LH(b, (b) + (g) - 1)
#define RM_ARGB(a,r,g,b) MASK_LH((b) + (g), (b) + (g) + (r) - 1)
#define AM_ARGB(a,r,g,b) MASK_LH((b) + (g) + (r), (b) + (g) + (r) + (a) - 1)
#define MASK_LH(l, h) (((1 << (1 + (h) - (l))) - 1) << (l))
#define BM_ARGB(a, r, g, b) MASK_LH(0, (b) - 1)
#define GM_ARGB(a, r, g, b) MASK_LH(b, (b) + (g) - 1)
#define RM_ARGB(a, r, g, b) MASK_LH((b) + (g), (b) + (g) + (r) - 1)
#define AM_ARGB(a, r, g, b) MASK_LH((b) + (g) + (r), \
(b) + (g) + (r) + (a) - 1)
#endif /* _DARWIN_FB_H */
#endif /* _DARWIN_FB_H */

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,9 @@
#ifndef KEYSYM2UCS_H
#define KEYSYM2UCS_H 1
extern long keysym2ucs(int keysym);
extern int ucs2keysym(long ucs);
extern long
keysym2ucs(int keysym);
extern int
ucs2keysym(long ucs);
#endif /* KEYSYM2UCS_H */
#endif /* KEYSYM2UCS_H */

View File

@ -1,32 +1,32 @@
/* 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>
@ -64,18 +64,16 @@
#include "console_redirect.h"
/* From darwinEvents.c ... but don't want to pull in all the server cruft */
void DarwinListenOnOpenFD(int fd);
void
DarwinListenOnOpenFD(int fd);
extern aslclient aslc;
/* Ditto, from os/log.c */
extern void
ErrorF(const char *f, ...)
_X_ATTRIBUTE_PRINTF(1, 2);
ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2);
extern void
FatalError(const char *f, ...)
_X_ATTRIBUTE_PRINTF(1, 2)
_X_NORETURN;
FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN;
extern int noPanoramiXExtension;
@ -91,14 +89,13 @@ extern int noPanoramiXExtension;
#endif
static char __crashreporter_info_buff__[4096] = { 0 };
static const char *__crashreporter_info__ __attribute__ ((__used__)) =
static const char *__crashreporter_info__ __attribute__((__used__)) =
&__crashreporter_info_buff__[0];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
// This is actually a toolchain requirement, but I'm not sure the correct check,
// but it should be fine to just only include it for Leopard and later. This line
// just tells the linker to never strip this symbol (such as for space optimization)
asm(".desc ___crashreporter_info__, 0x10");
asm (".desc ___crashreporter_info__, 0x10");
#endif
static const char *__crashreporter_info__base =
@ -110,10 +107,13 @@ static char *server_bootstrap_name = NULL;
#define DEBUG 1
/* This is in quartzStartup.c */
int server_main(int argc, char **argv, char **envp);
int
server_main(int argc, char **argv, char **envp);
static int execute(const char *command);
static char *command_from_prefs(const char *key, const char *default_value);
static int
execute(const char *command);
static char *
command_from_prefs(const char *key, const char *default_value);
static char *pref_app_to_run;
static char *pref_login_shell;
@ -122,7 +122,7 @@ static char *pref_startx_script;
#ifndef HAVE_LIBDISPATCH
/*** Pthread Magics ***/
static pthread_t
create_thread(void *(*func) (void *), void *arg)
create_thread(void *(*func)(void *), void *arg)
{
pthread_attr_t attr;
pthread_t tid;
@ -162,8 +162,8 @@ checkin_or_register(char *bname)
exit(EXIT_FAILURE);
}
kr = mach_port_insert_right(mach_task_self(), mp, mp,
MACH_MSG_TYPE_MAKE_SEND);
kr = mach_port_insert_right(
mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
if (kr != KERN_SUCCESS) {
ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE);
@ -171,7 +171,7 @@ checkin_or_register(char *bname)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // bootstrap_register
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // bootstrap_register
#endif
kr = bootstrap_register(bootstrap_port, bname, mp);
#ifdef __clang__
@ -221,16 +221,16 @@ accept_fd_handoff(int connected_fd)
msg.msg_controllen = cmsg->cmsg_len;
*((int *) CMSG_DATA(cmsg)) = -1;
*((int *)CMSG_DATA(cmsg)) = -1;
if (recvmsg(connected_fd, &msg, 0) < 0) {
ErrorF
("X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n",
strerror(errno));
ErrorF(
"X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n",
strerror(errno));
return -1;
}
launchd_fd = *((int *) CMSG_DATA(cmsg));
launchd_fd = *((int *)CMSG_DATA(cmsg));
return launchd_fd;
}
@ -245,13 +245,13 @@ typedef struct {
*/
#ifdef HAVE_LIBDISPATCH
static void
socket_handoff(socket_handoff_t * handoff_data)
socket_handoff(socket_handoff_t *handoff_data)
{
#else
static void *
socket_handoff_thread(void *arg)
{
socket_handoff_t *handoff_data = (socket_handoff_t *) arg;
socket_handoff_t *handoff_data = (socket_handoff_t *)arg;
#endif
int launchd_fd = -1;
@ -263,17 +263,17 @@ socket_handoff_thread(void *arg)
while (launchd_fd == -1) {
connected_fd = accept(handoff_data->fd, NULL, NULL);
if (connected_fd == -1) {
ErrorF
("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n",
handoff_data->fd, strerror(errno));
ErrorF(
"X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n",
handoff_data->fd, strerror(errno));
sleep(2);
continue;
}
launchd_fd = accept_fd_handoff(connected_fd);
if (launchd_fd == -1)
ErrorF
("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
ErrorF(
"X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
close(connected_fd);
}
@ -282,9 +282,9 @@ socket_handoff_thread(void *arg)
unlink(handoff_data->filename);
free(handoff_data);
ErrorF
("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n",
launchd_fd);
ErrorF(
"X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n",
launchd_fd);
DarwinListenOnOpenFD(launchd_fd);
#ifndef HAVE_LIBDISPATCH
@ -310,35 +310,38 @@ create_socket(char *filename_out)
strlcpy(servaddr_un.sun_path, filename_out,
sizeof(servaddr_un.sun_path));
servaddr = (struct sockaddr *) &servaddr_un;
servaddr_len =
sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) +
strlen(filename_out);
servaddr = (struct sockaddr *)&servaddr_un;
servaddr_len = sizeof(struct sockaddr_un) -
sizeof(servaddr_un.sun_path) + strlen(filename_out);
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (ret_fd == -1) {
ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n",
(int) try + 1, (int) try_max, filename_out, strerror(errno));
ErrorF(
"X11.app: Failed to create socket (try %d / %d): %s - %s\n",
(int)try + 1, (int)try_max, filename_out, strerror(errno));
continue;
}
if (bind(ret_fd, servaddr, servaddr_len) != 0) {
ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno,
strerror(errno));
strerror(
errno));
close(ret_fd);
return 0;
}
if (listen(ret_fd, 10) != 0) {
ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n",
filename_out, errno, strerror(errno));
filename_out, errno, strerror(
errno));
close(ret_fd);
return 0;
}
#ifdef DEBUG
ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n",
ret_fd, filename_out);
ret_fd,
filename_out);
#endif
return ret_fd;
@ -356,7 +359,7 @@ do_request_fd_handoff_socket(mach_port_t port, string_t filename)
launchd_socket_handed_off = 1;
handoff_data = (socket_handoff_t *) calloc(1, sizeof(socket_handoff_t));
handoff_data = (socket_handoff_t *)calloc(1, sizeof(socket_handoff_t));
if (!handoff_data) {
ErrorF("X11.app: Error allocating memory for handoff_data\n");
return KERN_FAILURE;
@ -371,17 +374,17 @@ do_request_fd_handoff_socket(mach_port_t port, string_t filename)
strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
#ifdef HAVE_LIBDISPATCH
dispatch_async(dispatch_get_global_queue
(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {
socket_handoff(handoff_data);}
);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0), ^ {
socket_handoff(handoff_data);
});
#else
create_thread(socket_handoff_thread, handoff_data);
#endif
#ifdef DEBUG
ErrorF
("X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
ErrorF(
"X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
#endif
return KERN_SUCCESS;
@ -398,7 +401,8 @@ do_request_pid(mach_port_t port, int *my_pid)
kern_return_t
do_start_x11_server(mach_port_t port, string_array_t argv,
mach_msg_type_number_t argvCnt,
string_array_t envp, mach_msg_type_number_t envpCnt)
string_array_t envp,
mach_msg_type_number_t envpCnt)
{
/* And now back to char ** */
char **_argv = alloca((argvCnt + 1) * sizeof(char *));
@ -420,7 +424,7 @@ do_start_x11_server(mach_port_t port, string_array_t argv,
ErrorF("X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
for (i = 0; i < argvCnt; i++) {
_argv[i] = argv[i];
ErrorF("\targv[%u] = %s\n", (unsigned) i, argv[i]);
ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
}
_argv[argvCnt] = NULL;
@ -451,14 +455,13 @@ startup_trigger(int argc, char **argv, char **envp)
/* We need to count envp */
int envpc;
for (envpc = 0; envp[envpc]; envpc++);
for (envpc = 0; envp[envpc]; envpc++) ;
/* We have fixed-size string lengths due to limitations in IPC,
* so we need to copy our argv and envp.
*/
newargv = (string_array_t) alloca(argc * sizeof(string_t));
newenvp = (string_array_t) alloca(envpc * sizeof(string_t));
newargv = (string_array_t)alloca(argc * sizeof(string_t));
newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
if (!newargv || !newenvp) {
ErrorF("Memory allocation failure\n");
@ -476,10 +479,11 @@ startup_trigger(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name,
bootstrap_strerror(kr));
bootstrap_strerror(
kr));
#else
ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name,
(unsigned long) kr);
(unsigned long)kr);
#endif
exit(EXIT_FAILURE);
}
@ -508,14 +512,14 @@ startup_trigger(int argc, char **argv, char **envp)
/* Start the server */
if ((s = getenv("DISPLAY"))) {
ErrorF
("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n",
s);
ErrorF(
"X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n",
s);
unsetenv("DISPLAY");
}
else {
ErrorF
("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
ErrorF(
"X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
}
return execute(pref_startx_script);
}
@ -530,7 +534,8 @@ ensure_path(const char *dir)
temp = getenv("PATH");
if (temp == NULL || temp[0] == 0) {
snprintf(buf, sizeof(buf),
"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir);
"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s",
dir);
setenv("PATH", buf, TRUE);
}
else if (strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
@ -574,10 +579,8 @@ setup_env(void)
* quartz-wm and the Xquartz stub's MachIPC)
*/
CFBundleRef bundle = CFBundleGetMainBundle();
if (bundle) {
CFStringRef pd = CFBundleGetIdentifier(bundle);
if (pd) {
pds = CFStringGetCStringPtr(pd, 0);
}
@ -609,22 +612,22 @@ setup_env(void)
if (disp) {
/* s = basename(disp) */
const char *d, *s;
for (s = NULL, d = disp; *d; d++) {
if (*d == '/')
s = d + 1;
}
if (s && *s) {
if (strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
ErrorF
("X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
if (strcmp(bundle_id_prefix,
"org.x") == 0 && strcmp(s, ":0") == 0) {
ErrorF(
"X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
}
else {
temp = (char *) malloc(sizeof(char) * len);
temp = (char *)malloc(sizeof(char) * len);
if (!temp) {
ErrorF
("X11.app: Memory allocation error creating space for socket name test.\n");
ErrorF(
"X11.app: Memory allocation error creating space for socket name test.\n");
exit(1);
}
strlcpy(temp, bundle_id_prefix, len);
@ -632,9 +635,9 @@ setup_env(void)
if (strcmp(temp, s) != 0) {
/* If we don't have a match, unset it. */
ErrorF
("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n",
disp, bundle_id_prefix);
ErrorF(
"X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n",
disp, bundle_id_prefix);
unsetenv("DISPLAY");
}
free(temp);
@ -642,8 +645,8 @@ setup_env(void)
}
else {
/* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
ErrorF
("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
ErrorF(
"X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
unsetenv("DISPLAY");
}
}
@ -679,7 +682,7 @@ main(int argc, char **argv, char **envp)
ErrorF("X11.app: main(): argc=%d\n", argc);
for (i = 0; i < argc; i++) {
ErrorF("\targv[%u] = %s\n", (unsigned) i, argv[i]);
ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
if (!strcmp(argv[i], "--listenonly")) {
listenOnly = TRUE;
}
@ -704,26 +707,26 @@ main(int argc, char **argv, char **envp)
pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
assert(pref_login_shell);
pref_startx_script =
command_from_prefs("startx_script", DEFAULT_STARTX);
pref_startx_script = command_from_prefs("startx_script",
DEFAULT_STARTX);
assert(pref_startx_script);
/* Do the fork-twice trick to avoid having to reap zombies */
child1 = fork();
switch (child1) {
case -1: /* error */
case -1: /* error */
FatalError("fork() failed: %s\n", strerror(errno));
case 0: /* child1 */
case 0: /* child1 */
child2 = fork();
switch (child2) {
int max_files;
case -1: /* error */
case -1: /* error */
FatalError("fork() failed: %s\n", strerror(errno));
case 0: /* child2 */
case 0: /* child2 */
/* close all open files except for standard streams */
max_files = sysconf(_SC_OPEN_MAX);
for (i = 3; i < max_files; i++)
@ -735,12 +738,12 @@ main(int argc, char **argv, char **envp)
return startup_trigger(argc, argv, envp);
default: /* parent (child1) */
default: /* parent (child1) */
_exit(0);
}
break;
default: /* parent */
default: /* parent */
waitpid(child1, &status, 0);
}
@ -773,10 +776,10 @@ execute(const char *command)
ErrorF("X11.app: Launching %s:\n", command);
for (p = newargv; *p; p++) {
ErrorF("\targv[%ld] = %s\n", (long int) (p - newargv), *p);
ErrorF("\targv[%ld] = %s\n", (long int)(p - newargv), *p);
}
execvp(newargv[0], (char *const *) newargv);
execvp(newargv[0], (char *const *)newargv);
perror("X11.app: Couldn't exec.");
return 1;
}
@ -797,13 +800,13 @@ command_from_prefs(const char *key, const char *default_value)
if (!cfKey)
return NULL;
PlistRef =
CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
PlistRef = CFPreferencesCopyAppValue(cfKey,
kCFPreferencesCurrentApplication);
if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
CFStringRef cfDefaultValue =
CFStringCreateWithCString(NULL, default_value,
kCFStringEncodingASCII);
if ((PlistRef == NULL) ||
(CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
CFStringRef cfDefaultValue = CFStringCreateWithCString(
NULL, default_value, kCFStringEncodingASCII);
int len = strlen(default_value) + 1;
if (!cfDefaultValue)
@ -814,22 +817,21 @@ command_from_prefs(const char *key, const char *default_value)
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
CFRelease(cfDefaultValue);
command = (char *) malloc(len * sizeof(char));
command = (char *)malloc(len * sizeof(char));
if (!command)
goto command_from_prefs_out;
strcpy(command, default_value);
}
else {
int len = CFStringGetLength((CFStringRef) PlistRef) + 1;
command = (char *) malloc(len * sizeof(char));
int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
command = (char *)malloc(len * sizeof(char));
if (!command)
goto command_from_prefs_out;
CFStringGetCString((CFStringRef) PlistRef, command, len,
CFStringGetCString((CFStringRef)PlistRef, command, len,
kCFStringEncodingASCII);
}
command_from_prefs_out:
command_from_prefs_out:
if (PlistRef)
CFRelease(PlistRef);
if (cfKey)

View File

@ -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
@ -45,30 +45,35 @@ launchd_display_fd(void)
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");
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");
return ERROR_FD;
}
if ((checkin_response = launch_msg(checkin_request)) == NULL) {
asl_log(aslc, NULL, ASL_LEVEL_WARNING,
"launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",
strerror(errno));
strerror(
errno));
return ERROR_FD;
}
if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
// ignore EACCES, which is common if we weren't started by launchd
if (launch_data_get_errno(checkin_response) != EACCES)
asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in failed: %s\n",
strerror(launch_data_get_errno(checkin_response)));
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in failed: %s\n",
strerror(launch_data_get_errno(
checkin_response)));
return ERROR_FD;
}
sockets_dict =
launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS);
sockets_dict = launch_data_dict_lookup(checkin_response,
LAUNCH_JOBKEY_SOCKETS);
if (NULL == sockets_dict) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in: no sockets found to answer requests on!\n");
@ -81,14 +86,15 @@ launchd_display_fd(void)
return ERROR_FD;
}
listening_fd_array =
launch_data_dict_lookup(sockets_dict, BUNDLE_ID_PREFIX ":0");
listening_fd_array = launch_data_dict_lookup(sockets_dict,
BUNDLE_ID_PREFIX ":0");
if (NULL == listening_fd_array) {
listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
if (NULL == listening_fd_array) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n",
BUNDLE_ID_PREFIX);
asl_log(
aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n",
BUNDLE_ID_PREFIX);
return ERROR_FD;
}
}
@ -96,7 +102,8 @@ launchd_display_fd(void)
if (launch_data_array_get_count(listening_fd_array) != 1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in: Expected 1 socket from launchd, got %u)\n",
(unsigned) launch_data_array_get_count(listening_fd_array));
(unsigned)launch_data_array_get_count(
listening_fd_array));
return ERROR_FD;
}

View File

@ -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
@ -31,6 +31,7 @@
#define ERROR_FD -1
int launchd_display_fd(void);
int
launchd_display_fd(void);
#endif /* _XQUARTZ_LAUNCHD_FD_H_ */
#endif /* _XQUARTZ_LAUNCHD_FD_H_ */

View File

@ -4,6 +4,6 @@
#define STRING_T_SIZE 1024
typedef char string_t[STRING_T_SIZE];
typedef string_t *string_array_t;
typedef string_t * string_array_t;
#endif

View File

@ -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
@ -40,7 +40,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#define kX11AppBundleId BUNDLE_ID_PREFIX".X11"
#define kX11AppBundleId BUNDLE_ID_PREFIX ".X11"
#define kX11AppBundlePath "/Contents/MacOS/X11"
#include <mach/mach.h>
@ -65,36 +65,43 @@ set_x11_path(void)
CFURLRef appURL = NULL;
OSStatus osstatus =
LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil,
nil, &appURL);
LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(
kX11AppBundleId), nil, nil, &appURL);
switch (osstatus) {
case noErr:
if (appURL == NULL) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
kX11AppBundleId);
asl_log(
aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
kX11AppBundleId);
exit(1);
}
if (!CFURLGetFileSystemRepresentation
(appURL, true, (unsigned char *) x11_path, sizeof(x11_path))) {
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);
"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;
case kLSApplicationNotFoundErr:
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Unable to find application for %s", kX11AppBundleId);
"Xquartz: Unable to find application for %s",
kX11AppBundleId);
exit(10);
default:
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Unable to find application for %s, error code = %d",
kX11AppBundleId, (int) osstatus);
kX11AppBundleId,
(int)osstatus);
exit(11);
}
#else
@ -117,23 +124,25 @@ connect_to_socket(const char *filename)
servaddr_un.sun_family = AF_UNIX;
strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
servaddr = (struct sockaddr *) &servaddr_un;
servaddr_len =
sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) +
strlen(filename);
servaddr = (struct sockaddr *)&servaddr_un;
servaddr_len = sizeof(struct sockaddr_un) -
sizeof(servaddr_un.sun_path) + strlen(filename);
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (ret_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to create socket: %s - %s", filename,
strerror(errno));
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));
"Xquartz: Failed to connect to socket: %s - %d - %s",
filename, errno,
strerror(
errno));
close(ret_fd);
return -1;
}
@ -173,12 +182,13 @@ send_fd_handoff(int connected_fd, int launchd_fd)
msg.msg_controllen = cmsg->cmsg_len;
*((int *) CMSG_DATA(cmsg)) = launchd_fd;
*((int *)CMSG_DATA(cmsg)) = launchd_fd;
if (sendmsg(connected_fd, &msg, 0) < 0) {
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s",
connected_fd, errno, strerror(errno));
asl_log(
aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s",
connected_fd, errno, strerror(errno));
return;
}
@ -187,7 +197,7 @@ send_fd_handoff(int connected_fd, int launchd_fd)
close(connected_fd);
}
__attribute__ ((__noreturn__))
__attribute__((__noreturn__))
static void
signal_handler(int sig)
{
@ -256,18 +266,19 @@ main(int argc, char **argv, char **envp)
child = fork();
if (child == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s",
strerror(errno));
strerror(
errno));
return EXIT_FAILURE;
}
if (child == 0) {
char *_argv[3];
_argv[0] = x11_path;
_argv[1] = "--listenonly";
_argv[2] = NULL;
asl_log(aslc, NULL, ASL_LEVEL_NOTICE,
"Xquartz: Starting X server: %s --listenonly", x11_path);
"Xquartz: Starting X server: %s --listenonly",
x11_path);
return execvp(x11_path, _argv);
}
@ -282,10 +293,12 @@ main(int argc, char **argv, char **envp)
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));
"Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(
kr));
#else
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: bootstrap_look_up(): %ul", (unsigned long) kr);
"Xquartz: bootstrap_look_up(): %ul",
(unsigned long)kr);
#endif
return EXIT_FAILURE;
}
@ -300,11 +313,13 @@ main(int argc, char **argv, char **envp)
int handoff_fd = -1;
for (try = 0, try_max = 5; try < try_max; try++) {
if (request_fd_handoff_socket(mp, handoff_socket_filename) !=
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);
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;
}
@ -312,14 +327,16 @@ main(int argc, char **argv, char **envp)
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);
(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);
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;
@ -327,13 +344,13 @@ main(int argc, char **argv, char **envp)
}
/* Count envp */
for (envpc = 0; envp[envpc]; envpc++);
for (envpc = 0; envp[envpc]; envpc++) ;
/* We have fixed-size string lengths due to limitations in IPC,
* so we need to copy our argv and envp.
*/
newargv = (string_array_t) calloc((1 + argc), sizeof(string_t));
newenvp = (string_array_t) calloc((1 + envpc), sizeof(string_t));
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,
@ -355,7 +372,8 @@ main(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s",
mach_error_string(kr));
mach_error_string(
kr));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;

View File

@ -1,37 +1,38 @@
/* 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"
#include <pthread.h>
#include <unistd.h> /*for getpid */
#include <unistd.h> /*for getpid*/
#include <Cocoa/Cocoa.h>
static const char *app_prefs_domain = BUNDLE_ID_PREFIX ".xpbproxy";
@ -50,13 +51,14 @@ signal_handler(int sig)
case SIGHUP:
xpbproxy_prefs_reload = YES;
break;
default:
_exit(EXIT_SUCCESS);
}
}
void
ErrorF(const char *f, ...)
ErrorF(const char * f, ...)
{
va_list args;
@ -68,7 +70,8 @@ ErrorF(const char *f, ...)
/* TODO: Have this actually log to ASL */
void
xq_asl_log(int level, const char *subsystem, const char *file,
const char *function, int line, const char *fmt, ...)
const char *function, int line, const char *fmt,
...)
{
#ifdef DEBUG
va_list args;
@ -99,11 +102,12 @@ main(int argc, const char *argv[])
app_prefs_domain = argv[++i];
}
else if (strcmp(argv[i], "--help") == 0) {
ErrorF("usage: xpbproxy OPTIONS\n"
"Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: %s)\n",
app_prefs_domain);
ErrorF(
"usage: xpbproxy OPTIONS\n"
"Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: %s)\n",
app_prefs_domain);
return 0;
}
else {
@ -113,9 +117,8 @@ main(int argc, const char *argv[])
}
}
app_prefs_domain_cfstr =
CFStringCreateWithCString(NULL, app_prefs_domain,
kCFStringEncodingUTF8);
app_prefs_domain_cfstr = CFStringCreateWithCString(NULL, app_prefs_domain,
kCFStringEncodingUTF8);
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);

View File

@ -1,30 +1,31 @@
/* 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"
@ -64,7 +65,7 @@ wait_for_server_init(void)
}
static int
x_io_error_handler(Display * dpy)
x_io_error_handler(Display *dpy)
{
/* We lost our connection to the server. */
@ -85,7 +86,7 @@ x_io_error_handler(Display * dpy)
}
static int
x_error_handler(Display * dpy, XErrorEvent * errevent)
x_error_handler(Display *dpy, XErrorEvent *errevent)
{
return 0;
}
@ -93,7 +94,7 @@ x_error_handler(Display * dpy, XErrorEvent * errevent)
int
xpbproxy_run(void)
{
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
size_t i;
wait_for_server_init();
@ -103,7 +104,6 @@ xpbproxy_run(void)
if (!xpbproxy_dpy && display) {
char _display[32];
snprintf(_display, sizeof(_display), ":%s", display);
setenv("DISPLAY", _display, TRUE);
@ -136,7 +136,7 @@ xpbproxy_run(void)
XAppleWMSelectInput(xpbproxy_dpy, AppleWMActivationNotifyMask |
AppleWMPasteboardNotifyMask);
_selection_object =[[x_selection alloc] init];
_selection_object = [[x_selection alloc] init];
if (!xpbproxy_input_register()) {
[pool release];

View File

@ -1,31 +1,32 @@
/* 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.
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 PBPROXY_H
#define PBPROXY_H 1
@ -65,11 +66,16 @@ extern BOOL xpbproxy_is_standalone;
#endif
/* from main.m */
extern void xpbproxy_set_is_active(BOOL state);
extern BOOL xpbproxy_get_is_active(void);
extern id xpbproxy_selection_object(void);
extern Time xpbproxy_current_timestamp(void);
extern int xpbproxy_run(void);
extern void
xpbproxy_set_is_active(BOOL state);
extern BOOL
xpbproxy_get_is_active(void);
extern id
xpbproxy_selection_object(void);
extern Time
xpbproxy_current_timestamp(void);
extern int
xpbproxy_run(void);
extern Display *xpbproxy_dpy;
extern int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
@ -77,21 +83,28 @@ extern int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
extern BOOL xpbproxy_have_xfixes;
/* from x-input.m */
extern BOOL xpbproxy_input_register(void);
extern BOOL
xpbproxy_input_register(void);
/* os/log.c or app-main.m */
extern void
ErrorF(const char *f, ...)
_X_ATTRIBUTE_PRINTF(1, 2);
ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2);
/* from darwin.h */
_X_ATTRIBUTE_PRINTF(6, 7)
extern void
xq_asl_log(int level, const char *subsystem, const char *file,
const char *function, int line, const char *fmt, ...);
const char *function, int line, const char *fmt,
...);
#define ASL_LOG(level, subsystem, msg, args...) xq_asl_log(level, subsystem, __FILE__, __FUNCTION__, __LINE__, msg, ##args)
#define DebugF(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "xpbproxy", msg, ##args)
#define TRACE() DebugF("TRACE")
#define ASL_LOG(level, subsystem, msg, args ...) xq_asl_log(level, subsystem, \
__FILE__, \
__FUNCTION__, \
__LINE__, msg, \
## args)
#define DebugF(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, \
"xpbproxy", msg, \
## args)
#define TRACE() DebugF("TRACE")
#endif /* PBPROXY_H */
#endif /* PBPROXY_H */

View File

@ -1,30 +1,31 @@
/* 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"
@ -49,16 +50,17 @@ BOOL xpbproxy_prefs_reload = NO;
static Time last_activation_time;
static void
x_event_apple_wm_notify(XAppleWMNotifyEvent * e)
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 (type == AppleWMActivationNotify &&
kind == AppleWMReloadPreferences)
[xpbproxy_selection_object ()reload_preferences];
if (![xpbproxy_selection_object()is_active])
if (![xpbproxy_selection_object ()is_active])
return;
switch (type) {
@ -66,11 +68,11 @@ x_event_apple_wm_notify(XAppleWMNotifyEvent * e)
switch (kind) {
case AppleWMIsActive:
last_activation_time = e->time;
[xpbproxy_selection_object()x_active:e->time];
[xpbproxy_selection_object () x_active:e->time];
break;
case AppleWMIsInactive:
[xpbproxy_selection_object()x_inactive:e->time];
[xpbproxy_selection_object () x_inactive:e->time];
break;
}
break;
@ -78,7 +80,7 @@ x_event_apple_wm_notify(XAppleWMNotifyEvent * e)
case AppleWMPasteboardNotify:
switch (kind) {
case AppleWMCopyToPasteboard:
[xpbproxy_selection_object()x_copy:e->time];
[xpbproxy_selection_object () x_copy:e->time];
}
break;
}
@ -87,7 +89,7 @@ x_event_apple_wm_notify(XAppleWMNotifyEvent * e)
static void
xpbproxy_process_xevents(void)
{
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (pool == nil) {
ErrorF("unable to allocate/init auto release pool!\n");
@ -101,31 +103,32 @@ xpbproxy_process_xevents(void)
switch (e.type) {
case SelectionClear:
if ([xpbproxy_selection_object()is_active])
[xpbproxy_selection_object()clear_event:&e.xselectionclear];
if ([xpbproxy_selection_object ()is_active])
[xpbproxy_selection_object () clear_event:&e.xselectionclear];
break;
case SelectionRequest:
[xpbproxy_selection_object()request_event:&e.xselectionrequest];
[xpbproxy_selection_object () request_event:&e.xselectionrequest];
break;
case SelectionNotify:
[xpbproxy_selection_object()notify_event:&e.xselection];
[xpbproxy_selection_object () notify_event:&e.xselection];
break;
case PropertyNotify:
[xpbproxy_selection_object()property_event:&e.xproperty];
[xpbproxy_selection_object () property_event:&e.xproperty];
break;
default:
if (e.type >= xpbproxy_apple_wm_event_base &&
e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
x_event_apple_wm_notify((XAppleWMNotifyEvent *) & e);
e.type < xpbproxy_apple_wm_event_base +
AppleWMNumberEvents) {
x_event_apple_wm_notify((XAppleWMNotifyEvent *)&e);
}
else if (e.type ==
xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
[xpbproxy_selection_object()xfixes_selection_notify:(XFixesSelectionNotifyEvent *) &
e];
else if (e.type == xpbproxy_xfixes_event_base +
XFixesSelectionNotify) {
[xpbproxy_selection_object () xfixes_selection_notify:(
XFixesSelectionNotifyEvent *)&e];
}
break;
}
@ -138,8 +141,8 @@ 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;
@ -150,7 +153,8 @@ add_input_socket(int sock, CFOptionFlags callback_types,
return FALSE;
}
*cf_source = CFSocketCreateRunLoopSource(kCFAllocatorDefault, cf_sock, 0);
*cf_source = CFSocketCreateRunLoopSource(kCFAllocatorDefault,
cf_sock, 0);
CFRelease(cf_sock);
if (*cf_source == NULL)
@ -168,7 +172,7 @@ x_input_callback(CFSocketRef sock, CFSocketCallBackType type,
#ifdef STANDALONE_XPBPROXY
if (xpbproxy_prefs_reload) {
[xpbproxy_selection_object()reload_preferences];
[xpbproxy_selection_object ()reload_preferences];
xpbproxy_prefs_reload = NO;
}
#endif
@ -179,7 +183,7 @@ x_input_callback(CFSocketRef sock, CFSocketCallBackType type,
BOOL
xpbproxy_input_register(void)
{
return add_input_socket(ConnectionNumber(xpbproxy_dpy),
kCFSocketReadCallBack, x_input_callback, NULL,
&xpbproxy_dpy_source);
return add_input_socket(ConnectionNumber(
xpbproxy_dpy), kCFSocketReadCallBack,
x_input_callback, NULL, &xpbproxy_dpy_source);
}

View File

@ -1,32 +1,32 @@
/* x-selection.h -- proxies between NSPasteboard and X11 selections
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.
*/
#ifndef X_SELECTION_H
#define X_SELECTION_H 1
@ -48,13 +48,15 @@ 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 {
@interface x_selection : NSObject
{
@private
/* The unmapped window we use for fetching selections. */
/* The unmapped window we use for fetching selections. */
Window _selection_window;
Atom request_atom;
@ -65,15 +67,14 @@ struct atom_list {
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
* Once the copy is completed, we --pending_copy, and if the
* pending_copy is > 0 we do it again.
*/
int pending_copy;
/*
* This is used for the same purpose as pending_copy, but for the
/*
* This is used for the same purpose as pending_copy, but for the
* CLIPBOARD. It also prevents a race with INCR transfers.
*/
int pending_clipboard;
@ -81,30 +82,30 @@ struct atom_list {
struct atom_list atoms[1];
}
-(void) x_active:(Time) timestamp;
-(void) x_inactive:(Time) timestamp;
- (void)x_active:(Time)timestamp;
- (void)x_inactive:(Time)timestamp;
-(void) x_copy:(Time) timestamp;
- (void)x_copy:(Time)timestamp;
-(void) clear_event:(XSelectionClearEvent *) e;
-(void) request_event:(XSelectionRequestEvent *) e;
-(void) notify_event:(XSelectionEvent *) e;
-(void) property_event:(XPropertyEvent *) e;
-(void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *) e;
-(void) handle_selection:(Atom)
selection type:(Atom)
type propdata:(struct propdata *) pdata;
- (void)clear_event:(XSelectionClearEvent *)e;
- (void)request_event:(XSelectionRequestEvent *)e;
- (void)notify_event:(XSelectionEvent *)e;
- (void)property_event:(XPropertyEvent *)e;
- (void)xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e;
- (void)handle_selection:(Atom) selection type:(Atom) type propdata:(struct
propdata
*)pdata;
- (void)claim_clipboard;
- (BOOL)set_clipboard_manager_status:(BOOL)value;
- (void)own_clipboard;
- (void)copy_completed:(Atom)selection;
-(void) claim_clipboard;
-(BOOL) set_clipboard_manager_status:(BOOL) value;
-(void) own_clipboard;
-(void) copy_completed:(Atom) selection;
-(void) reload_preferences;
-(BOOL) is_active;
-(void) send_none:(XSelectionRequestEvent *) e;
- (void)reload_preferences;
- (BOOL)is_active;
- (void)send_none:(XSelectionRequestEvent *)e;
@end
/* main.m */
extern x_selection *_selection_object;
#endif /* X_SELECTION_H */
/* main.m */
extern x_selection * _selection_object;
#endif /* X_SELECTION_H */

File diff suppressed because it is too large Load Diff

View File

@ -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.
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 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.
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.
******************************************************************/
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>
@ -47,25 +47,41 @@ Equipment Corporation.
Bool noPseudoramiXExtension = FALSE;
extern int ProcPanoramiXQueryVersion(ClientPtr client);
extern int
ProcPanoramiXQueryVersion(ClientPtr client);
static void PseudoramiXResetProc(ExtensionEntry * extEntry);
static void
PseudoramiXResetProc(ExtensionEntry *extEntry);
static int ProcPseudoramiXQueryVersion(ClientPtr client);
static int ProcPseudoramiXGetState(ClientPtr client);
static int ProcPseudoramiXGetScreenCount(ClientPtr client);
static int ProcPseudoramiXGetScreenSize(ClientPtr client);
static int ProcPseudoramiXIsActive(ClientPtr client);
static int ProcPseudoramiXQueryScreens(ClientPtr client);
static int ProcPseudoramiXDispatch(ClientPtr client);
static int
ProcPseudoramiXQueryVersion(ClientPtr client);
static int
ProcPseudoramiXGetState(ClientPtr client);
static int
ProcPseudoramiXGetScreenCount(ClientPtr client);
static int
ProcPseudoramiXGetScreenSize(ClientPtr client);
static int
ProcPseudoramiXIsActive(ClientPtr client);
static int
ProcPseudoramiXQueryScreens(ClientPtr client);
static int
ProcPseudoramiXDispatch(ClientPtr client);
static int SProcPseudoramiXQueryVersion(ClientPtr client);
static int SProcPseudoramiXGetState(ClientPtr client);
static int SProcPseudoramiXGetScreenCount(ClientPtr client);
static int SProcPseudoramiXGetScreenSize(ClientPtr client);
static int SProcPseudoramiXIsActive(ClientPtr client);
static int SProcPseudoramiXQueryScreens(ClientPtr client);
static int SProcPseudoramiXDispatch(ClientPtr client);
static int
SProcPseudoramiXQueryVersion(ClientPtr client);
static int
SProcPseudoramiXGetState(ClientPtr client);
static int
SProcPseudoramiXGetScreenCount(ClientPtr client);
static int
SProcPseudoramiXGetScreenSize(ClientPtr client);
static int
SProcPseudoramiXIsActive(ClientPtr client);
static int
SProcPseudoramiXQueryScreens(ClientPtr client);
static int
SProcPseudoramiXDispatch(ClientPtr client);
typedef struct {
int x;
@ -88,8 +104,7 @@ PseudoramiXAddScreen(int x, int y, int w, int h)
{
PseudoramiXScreenRec *s;
if (noPseudoramiXExtension)
return;
if (noPseudoramiXExtension) return;
if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
@ -113,10 +128,9 @@ void
PseudoramiXExtensionInit(int argc, char *argv[])
{
Bool success = FALSE;
ExtensionEntry *extEntry;
ExtensionEntry *extEntry;
if (noPseudoramiXExtension)
return;
if (noPseudoramiXExtension) return;
TRACE();
@ -134,7 +148,8 @@ PseudoramiXExtensionInit(int argc, char *argv[])
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcPseudoramiXDispatch,
SProcPseudoramiXDispatch,
PseudoramiXResetProc, StandardMinorOpcode);
PseudoramiXResetProc,
StandardMinorOpcode);
if (!extEntry) {
ErrorF("PseudoramiXExtensionInit(): AddExtension failed\n");
}
@ -160,7 +175,7 @@ PseudoramiXResetScreens(void)
}
static void
PseudoramiXResetProc(ExtensionEntry * extEntry)
PseudoramiXResetProc(ExtensionEntry *extEntry)
{
TRACE();
@ -201,7 +216,7 @@ ProcPseudoramiXGetState(ClientPtr client)
swapl(&rep.length);
swaps(&rep.state);
}
WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *) &rep);
WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep);
return Success;
}
@ -230,7 +245,7 @@ ProcPseudoramiXGetScreenCount(ClientPtr client)
swapl(&rep.length);
swaps(&rep.ScreenCount);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *) &rep);
WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
return Success;
}
@ -264,7 +279,7 @@ ProcPseudoramiXGetScreenSize(ClientPtr client)
swaps(&rep.width);
swaps(&rep.height);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *) &rep);
WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
return Success;
}
@ -288,7 +303,7 @@ ProcPseudoramiXIsActive(ClientPtr client)
swapl(&rep.length);
swapl(&rep.state);
}
WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep);
WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *)&rep);
return Success;
}
@ -300,7 +315,8 @@ ProcPseudoramiXQueryScreens(ClientPtr client)
xXineramaQueryScreensReply rep;
DEBUG_LOG("noPseudoramiXExtension=%d, pseudoramiXNumScreens=%d\n",
noPseudoramiXExtension, pseudoramiXNumScreens);
noPseudoramiXExtension,
pseudoramiXNumScreens);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
@ -313,7 +329,7 @@ ProcPseudoramiXQueryScreens(ClientPtr client)
swapl(&rep.length);
swapl(&rep.number);
}
WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *) &rep);
WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep);
if (!noPseudoramiXExtension) {
xXineramaScreenInfo scratch;
@ -331,7 +347,7 @@ ProcPseudoramiXQueryScreens(ClientPtr client)
swaps(&scratch.width);
swaps(&scratch.height);
}
WriteToClient(client, sz_XineramaScreenInfo, (char *) &scratch);
WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch);
}
}
@ -347,14 +363,19 @@ ProcPseudoramiXDispatch(ClientPtr client)
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);
}
@ -443,14 +464,19 @@ SProcPseudoramiXDispatch(ClientPtr client)
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);
}

View File

@ -4,6 +4,8 @@
extern int noPseudoramiXExtension;
void PseudoramiXAddScreen(int x, int y, int w, int h);
void
PseudoramiXAddScreen(int x, int y, int w, int h);
void PseudoramiXExtensionInit(int argc, char *argv[]);
void PseudoramiXResetScreens(void);
void
PseudoramiXResetScreens(void);

View File

@ -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.
*
@ -71,7 +72,7 @@
DevPrivateKeyRec quartzScreenKeyRec;
int aquaMenuBarHeight = 0;
QuartzModeProcsPtr quartzProcs = NULL;
const char *quartzOpenGLBundle = NULL;
const char *quartzOpenGLBundle = NULL;
Bool XQuartzFullscreenDisableHotkeys = TRUE;
Bool XQuartzOptionSendsAlt = FALSE;
@ -85,19 +86,20 @@ Bool XQuartzFullscreenMenu = FALSE;
int32_t XQuartzShieldingWindowLevel = 0;
/*
===========================================================================
===========================================================================
Screen functions
Screen functions
===========================================================================
*/
===========================================================================
*/
/*
* QuartzAddScreen
* Do mode dependent initialization of each screen for Quartz.
*/
Bool
QuartzAddScreen(int index, ScreenPtr pScreen)
QuartzAddScreen(int index,
ScreenPtr pScreen)
{
// allocate space for private per screen Quartz specific storage
QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1);
@ -114,7 +116,8 @@ QuartzAddScreen(int index, ScreenPtr pScreen)
* Finalize mode specific setup of each screen.
*/
Bool
QuartzSetupScreen(int index, ScreenPtr pScreen)
QuartzSetupScreen(int index,
ScreenPtr pScreen)
{
// do Quartz mode specific setup
if (!quartzProcs->SetupScreen(index, pScreen))
@ -139,7 +142,8 @@ QuartzSetupScreen(int index, ScreenPtr pScreen)
* Quartz display initialization.
*/
void
QuartzInitOutput(int argc, char **argv)
QuartzInitOutput(int argc,
char **argv)
{
/* For XQuartz, we want to just use the default signal handler to work better with CrashTracer */
signal(SIGSEGV, SIG_DFL);
@ -162,7 +166,8 @@ QuartzInitOutput(int argc, char **argv)
#endif
if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
QuartzWakeupHandler, NULL)) {
QuartzWakeupHandler,
NULL)) {
FatalError("Could not register block and wakeup handlers.");
}
@ -178,7 +183,8 @@ QuartzInitOutput(int argc, char **argv)
* Inform the main thread the X server is ready to handle events.
*/
void
QuartzInitInput(int argc, char **argv)
QuartzInitInput(int argc,
char **argv)
{
X11ApplicationSetCanQuit(0);
X11ApplicationServerReady();
@ -212,8 +218,8 @@ QuartzUpdateScreens(void)
pScreen->x = x;
pScreen->y = y;
pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
pScreen->mmWidth = pScreen->mmWidth * ((double)width / pScreen->width);
pScreen->mmHeight = pScreen->mmHeight * ((double)height / pScreen->height);
pScreen->width = width;
pScreen->height = height;
@ -241,10 +247,11 @@ QuartzUpdateScreens(void)
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);
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;
@ -278,7 +285,7 @@ QuartzScreenSaver(int state)
{
static CFRunLoopTimerRef pokeActivityTimer = NULL;
static CFRunLoopTimerContext pokeActivityContext =
{ 0, NULL, NULL, NULL, NULL };
{ 0, NULL, NULL, NULL, NULL };
static OSSpinLock pokeActivitySpinLock = OS_SPINLOCK_INIT;
OSSpinLockLock(&pokeActivitySpinLock);
@ -295,18 +302,20 @@ QuartzScreenSaver(int state)
if (pokeActivityTimer != NULL)
goto QuartzScreenSaverEnd;
pokeActivityTimer =
CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent(), 30, 0, 0,
pokeActivityCallback, &pokeActivityContext);
pokeActivityTimer = CFRunLoopTimerCreate(NULL,
CFAbsoluteTimeGetCurrent(),
30, 0, 0,
pokeActivityCallback,
&pokeActivityContext);
if (pokeActivityTimer == NULL) {
ErrorF("Unable to create pokeActivityTimer.\n");
goto QuartzScreenSaverEnd;
}
CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer,
kCFRunLoopCommonModes);
CFRunLoopAddTimer(
CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
}
QuartzScreenSaverEnd:
QuartzScreenSaverEnd:
OSSpinLockUnlock(&pokeActivitySpinLock);
}
@ -340,7 +349,6 @@ QuartzShowFullscreen(int state)
RootlessShowAllWindows();
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
RootlessRepositionWindows(pScreen);
// JH: I don't think this is necessary, but keeping it here as a reminder
//RootlessUpdateScreenPixmap(pScreen);
@ -348,7 +356,7 @@ QuartzShowFullscreen(int state)
}
/* Somehow the menubar manages to interfere with our event stream
* in fullscreen mode, even though it's not visible.
* in fullscreen mode, even though it's not visible.
*/
X11ApplicationShowHideMenubar(!XQuartzFullscreenVisible);
@ -458,7 +466,7 @@ QuartzSetRootClip(BOOL enable)
}
}
/*
/*
* QuartzSpaceChanged
* Unmap offscreen windows, map onscreen windows
*/
@ -466,7 +474,8 @@ void
QuartzSpaceChanged(uint32_t space_id)
{
/* Do something special here, so we don't depend on quartz-wm for spaces to work... */
DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
DEBUG_LOG("Space Changed (%u) ... do something interesting...\n",
space_id);
}
/*
@ -476,14 +485,13 @@ QuartzSpaceChanged(uint32_t space_id)
*/
void
QuartzCopyDisplayIDs(ScreenPtr pScreen,
int displayCount, CGDirectDisplayID * displayIDs)
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);
}
@ -493,11 +501,12 @@ QuartzCopyDisplayIDs(ScreenPtr pScreen,
pQuartzScreen->displayCount = displayCount;
}
void NSBeep(void);
void
DDXRingBell(int volume, // volume is % of max
int pitch, // pitch is Hz
int duration) // duration is milliseconds
NSBeep(void);
void
DDXRingBell(int volume, // volume is % of max
int pitch, // pitch is Hz
int duration) // duration is milliseconds
{
if (volume)
NSBeep();

View File

@ -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.
*
@ -39,53 +40,53 @@
/*------------------------------------------
Quartz display mode function types
------------------------------------------*/
------------------------------------------*/
/*
* Display mode initialization
*/
typedef void (*DisplayInitProc) (void);
typedef Bool (*AddScreenProc) (int index, ScreenPtr pScreen);
typedef Bool (*SetupScreenProc) (int index, ScreenPtr pScreen);
typedef void (*InitInputProc) (int argc, char **argv);
typedef void (*DisplayInitProc)(void);
typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen);
typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen);
typedef void (*InitInputProc)(int argc, char **argv);
/*
* Cursor functions
*/
typedef Bool (*InitCursorProc) (ScreenPtr pScreen);
typedef Bool (*InitCursorProc)(ScreenPtr pScreen);
/*
* Suspend and resume X11 activity
*/
typedef void (*SuspendScreenProc) (ScreenPtr pScreen);
typedef void (*ResumeScreenProc) (ScreenPtr pScreen);
typedef void (*SuspendScreenProc)(ScreenPtr pScreen);
typedef void (*ResumeScreenProc)(ScreenPtr pScreen);
/*
* Screen state change support
*/
typedef void (*AddPseudoramiXScreensProc)
(int *x, int *y, int *width, int *height, ScreenPtr pScreen);
typedef void (*UpdateScreenProc) (ScreenPtr pScreen);
(int *x, int *y, int *width, int *height, ScreenPtr pScreen);
typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
/*
* Rootless helper functions
*/
typedef Bool (*IsX11WindowProc) (int windowNumber);
typedef void (*HideWindowsProc) (Bool hide);
typedef Bool (*IsX11WindowProc)(int windowNumber);
typedef void (*HideWindowsProc)(Bool hide);
/*
* Rootless functions for optional export to GLX layer
*/
typedef void *(*FrameForWindowProc) (WindowPtr pWin, Bool create);
typedef WindowPtr (*TopLevelParentProc) (WindowPtr pWindow);
typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create);
typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow);
typedef Bool (*CreateSurfaceProc)
(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
unsigned int client_id, unsigned int *surface_id,
unsigned int key[2], void (*notify) (void *arg, void *data),
void *notify_data);
(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
unsigned int client_id, unsigned int *surface_id,
unsigned int key[2], void (*notify)(void *arg, void *data),
void *notify_data);
typedef Bool (*DestroySurfaceProc)
(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
void (*notify) (void *arg, void *data), void *notify_data);
(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
void (*notify)(void *arg, void *data), void *notify_data);
/*
* Quartz display mode function list
@ -115,33 +116,48 @@ typedef struct _QuartzModeProcs {
extern QuartzModeProcsPtr quartzProcs;
extern Bool XQuartzFullscreenVisible; /* Are the windows visible (predicated on !rootless) */
extern Bool XQuartzServerVisible; /* Is the server visible ... TODO: Refactor to "active" */
extern Bool XQuartzFullscreenVisible; /* Are the windows visible (predicated on !rootless) */
extern Bool XQuartzServerVisible; /* Is the server visible ... TODO: Refactor to "active" */
extern Bool XQuartzEnableKeyEquivalents;
extern Bool XQuartzRootlessDefault; /* Is our default mode rootless? */
extern Bool XQuartzIsRootless; /* Is our current mode rootless (or FS)? */
extern Bool XQuartzFullscreenMenu; /* Show the menu bar (autohide) while in FS */
extern Bool XQuartzRootlessDefault; /* Is our default mode rootless? */
extern Bool XQuartzIsRootless; /* Is our current mode rootless (or FS)? */
extern Bool XQuartzFullscreenMenu; /* Show the menu bar (autohide) while in FS */
extern Bool XQuartzFullscreenDisableHotkeys;
extern Bool XQuartzOptionSendsAlt; /* Alt or Mode_switch? */
extern Bool XQuartzOptionSendsAlt; /* Alt or Mode_switch? */
extern int32_t XQuartzShieldingWindowLevel; /* CGShieldingWindowLevel() or 0 */
extern int32_t XQuartzShieldingWindowLevel; /* CGShieldingWindowLevel() or 0 */
Bool QuartzAddScreen(int index, ScreenPtr pScreen);
Bool QuartzSetupScreen(int index, ScreenPtr pScreen);
void QuartzInitOutput(int argc, char **argv);
void QuartzInitInput(int argc, char **argv);
void QuartzInitServer(int argc, char **argv, char **envp);
void QuartzGiveUp(void);
void QuartzProcessEvent(xEvent *xe);
void QuartzUpdateScreens(void);
Bool
QuartzAddScreen(int index, ScreenPtr pScreen);
Bool
QuartzSetupScreen(int index, ScreenPtr pScreen);
void
QuartzInitOutput(int argc, char **argv);
void
QuartzInitInput(int argc, char **argv);
void
QuartzInitServer(int argc, char **argv, char **envp);
void
QuartzGiveUp(void);
void
QuartzProcessEvent(xEvent *xe);
void
QuartzUpdateScreens(void);
void QuartzShow(void);
void QuartzHide(void);
void QuartzSetRootClip(BOOL enable);
void QuartzSpaceChanged(uint32_t space_id);
void
QuartzShow(void);
void
QuartzHide(void);
void
QuartzSetRootClip(BOOL enable);
void
QuartzSpaceChanged(uint32_t space_id);
void QuartzSetRootless(Bool state);
void QuartzShowFullscreen(Bool state);
void
QuartzSetRootless(Bool state);
void
QuartzShowFullscreen(Bool state);
int server_main(int argc, char **argv, char **envp);
int
server_main(int argc, char **argv, char **envp);
#endif

View File

@ -48,19 +48,23 @@
* Clean out any autoreleased objects.
*/
void
QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
QuartzBlockHandler(pointer blockData,
OSTimePtr pTimeout,
pointer pReadmask)
{
static NSAutoreleasePool *aPool = nil;
[aPool release];
aPool =[[NSAutoreleasePool alloc] init];
aPool = [[NSAutoreleasePool alloc] init];
}
/*
* QuartzWakeupHandler
*/
void
QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask)
QuartzWakeupHandler(pointer blockData,
int result,
pointer pReadmask)
{
// nothing here
}

View File

@ -40,15 +40,15 @@
// Other shared data
extern DevPrivateKeyRec quartzScreenKeyRec;
#define quartzScreenKey (&quartzScreenKeyRec)
extern int aquaMenuBarHeight;
// Name of GLX bundle for native OpenGL
extern const char *quartzOpenGLBundle;
extern const char *quartzOpenGLBundle;
void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout,
pointer pReadmask);
void QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask);
void
QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
void
QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask);
#endif /* _QUARTZCOMMON_H */
#endif /* _QUARTZCOMMON_H */

View File

@ -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.
@ -29,7 +29,7 @@
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#include "sanitizedCarbon.h"
@ -37,8 +37,8 @@
#include <dix-config.h>
#endif
#define HACK_MISSING 1
#define HACK_KEYPAD 1
#define HACK_MISSING 1
#define HACK_KEYPAD 1
#define HACK_BLACKLIST 1
#include <unistd.h>
@ -65,7 +65,7 @@
#include "keysym2ucs.h"
extern void
CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
enum {
MOD_COMMAND = 256,
@ -84,31 +84,33 @@ const static struct {
unsigned short keycode;
KeySym keysym;
} known_keys[] = {
{
55, XK_Meta_L}, {
56, XK_Shift_L}, {
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}, {
118, XK_F4}, {
96, XK_F5}, {
97, XK_F6}, {
98, XK_F7}, {
100, XK_F8}, {
101, XK_F9}, {
109, XK_F10}, {
103, XK_F11}, {
111, XK_F12}, {
105, XK_F13}, {
107, XK_F14}, {
113, XK_F15},};
{ 55, XK_Meta_L },
{ 56, XK_Shift_L },
{ 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 },
{ 118, XK_F4 },
{ 96, XK_F5 },
{ 97, XK_F6 },
{ 98, XK_F7 },
{ 100, XK_F8 },
{ 101, XK_F9 },
{ 109, XK_F10 },
{ 103, XK_F11 },
{ 111, XK_F12 },
{ 105, XK_F13 },
{ 107, XK_F14 },
{ 113, XK_F15 },
};
#endif
#if HACK_KEYPAD
@ -119,24 +121,24 @@ const static struct {
unsigned short keycode;
KeySym normal, keypad;
} known_numeric_keys[] = {
{
65, XK_period, XK_KP_Decimal}, {
67, XK_asterisk, XK_KP_Multiply}, {
69, XK_plus, XK_KP_Add}, {
75, XK_slash, XK_KP_Divide}, {
76, 0x01000003, XK_KP_Enter}, {
78, XK_minus, XK_KP_Subtract}, {
81, XK_equal, XK_KP_Equal}, {
82, XK_0, XK_KP_0}, {
83, XK_1, XK_KP_1}, {
84, XK_2, XK_KP_2}, {
85, XK_3, XK_KP_3}, {
86, XK_4, XK_KP_4}, {
87, XK_5, XK_KP_5}, {
88, XK_6, XK_KP_6}, {
89, XK_7, XK_KP_7}, {
91, XK_8, XK_KP_8}, {
92, XK_9, XK_KP_9},};
{ 65, XK_period, XK_KP_Decimal },
{ 67, XK_asterisk, XK_KP_Multiply },
{ 69, XK_plus, XK_KP_Add },
{ 75, XK_slash, XK_KP_Divide },
{ 76, 0x01000003, XK_KP_Enter },
{ 78, XK_minus, XK_KP_Subtract },
{ 81, XK_equal, XK_KP_Equal },
{ 82, XK_0, XK_KP_0 },
{ 83, XK_1, XK_KP_1 },
{ 84, XK_2, XK_KP_2 },
{ 85, XK_3, XK_KP_3 },
{ 86, XK_4, XK_KP_4 },
{ 87, XK_5, XK_KP_5 },
{ 88, XK_6, XK_KP_6 },
{ 89, XK_7, XK_KP_7 },
{ 91, XK_8, XK_KP_8 },
{ 92, XK_9, XK_KP_9 },
};
#endif
#if HACK_BLACKLIST
@ -155,40 +157,30 @@ const static unsigned short keycode_blacklist[] = { 66, 70, 72, 77 };
const static struct {
KeySym normal, dead;
} dead_keys[] = {
{
XK_grave, XK_dead_grave}, {
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_asciicircum, XK_dead_circumflex}, {
UKEYSYM(0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
{
XK_asciitilde, XK_dead_tilde}, {
UKEYSYM(0x2dc), XK_dead_tilde}, /* SMALL TILDE */
{
XK_macron, XK_dead_macron}, {
XK_breve, XK_dead_breve}, {
XK_abovedot, XK_dead_abovedot}, {
XK_diaeresis, XK_dead_diaeresis}, {
UKEYSYM(0x2da), XK_dead_abovering}, /* DOT ABOVE */
{
XK_doubleacute, XK_dead_doubleacute}, {
XK_caron, XK_dead_caron}, {
XK_cedilla, XK_dead_cedilla}, {
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}, */
{
UKEYSYM(0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */
{
UKEYSYM(0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
{
UKEYSYM(0x31b), XK_dead_horn}, /* COMBINING HORN */
{ XK_grave, XK_dead_grave },
{ 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_asciicircum, XK_dead_circumflex },
{ UKEYSYM(0x2c6), XK_dead_circumflex }, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
{ XK_asciitilde, XK_dead_tilde },
{ UKEYSYM(0x2dc), XK_dead_tilde }, /* SMALL TILDE */
{ XK_macron, XK_dead_macron },
{ XK_breve, XK_dead_breve },
{ XK_abovedot, XK_dead_abovedot },
{ XK_diaeresis, XK_dead_diaeresis },
{ UKEYSYM(0x2da), XK_dead_abovering }, /* DOT ABOVE */
{ XK_doubleacute, XK_dead_doubleacute },
{ XK_caron, XK_dead_caron },
{ XK_cedilla, XK_dead_cedilla },
{ 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}, */
{ UKEYSYM(0x323), XK_dead_belowdot }, /* COMBINING DOT BELOW */
{ UKEYSYM(0x309), XK_dead_hook }, /* COMBINING HOOK ABOVE */
{ UKEYSYM(0x31b), XK_dead_horn }, /* COMBINING HORN */
};
typedef struct darwinKeyboardInfo_struct {
@ -201,7 +193,7 @@ darwinKeyboardInfo keyInfo;
pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
static void
DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl * ctrl)
DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl)
{
// FIXME: to be implemented
// keyclick, bell volume / pitch, autorepead, LED's
@ -217,7 +209,7 @@ DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl * ctrl)
* the modMap and modifierKeycodes fields.
*/
static void
DarwinBuildModifierMaps(darwinKeyboardInfo * info)
DarwinBuildModifierMaps(darwinKeyboardInfo *info)
{
int i;
KeySym *k;
@ -266,7 +258,7 @@ DarwinBuildModifierMaps(darwinKeyboardInfo * info)
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.
*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:
@ -276,13 +268,13 @@ DarwinBuildModifierMaps(darwinKeyboardInfo * info)
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
#endif
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.
*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");
ErrorF(
"DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
#ifdef NX_MODIFIERKEY_RALTERNATE
info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
@ -339,7 +331,7 @@ static void
DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue,
int keyRepeatValue)
{
if (initialKeyRepeatValue == 300000) { // off
if (initialKeyRepeatValue == 300000) { // off
/* Turn off repeats globally */
XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff);
}
@ -405,7 +397,7 @@ DarwinKeyboardReloadHandler(void)
DEBUG_LOG("DarwinKeyboardReloadHandler\n");
/* Get our key repeat settings from GlobalPreferences */
(void) CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
(void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
initialKeyRepeatValue =
CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"),
@ -413,13 +405,16 @@ DarwinKeyboardReloadHandler(void)
if (!ok)
initialKeyRepeatValue = 35;
keyRepeatValue =
CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"),
CFSTR(".GlobalPreferences"), &ok);
keyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR(
"KeyRepeat"),
CFSTR(
".GlobalPreferences"),
&ok);
if (!ok)
keyRepeatValue = 6;
pthread_mutex_lock(&keyInfo_mutex); {
pthread_mutex_lock(&keyInfo_mutex);
{
/* Initialize our keySyms */
keySyms.map = keyInfo.keyMap;
keySyms.mapWidth = GLYPHS_PER_KEY;
@ -436,43 +431,45 @@ DarwinKeyboardReloadHandler(void)
/* Apply the mappings to the core keyboard */
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode,
keySyms.maxKeyCode - keySyms.minKeyCode +
1, keyInfo.modMap, serverClient);
if ((pDev->coreEvents ||
pDev == inputInfo.keyboard) && pDev->key) {
XkbApplyMappingChange(
pDev, &keySyms, keySyms.minKeyCode,
keySyms.maxKeyCode -
keySyms.minKeyCode + 1,
keyInfo.modMap, serverClient);
DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue,
keyRepeatValue);
}
}
}
pthread_mutex_unlock(&keyInfo_mutex);
} pthread_mutex_unlock(&keyInfo_mutex);
/* Modify with xmodmap */
if (access(xmodmap, F_OK) == 0) {
/* Check for system .Xmodmap */
if (access(sysmodmap, F_OK) == 0) {
if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap) <
sizeof(cmd)) {
if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap,
sysmodmap) < sizeof(cmd)) {
X11ApplicationLaunchClient(cmd);
}
else {
ErrorF
("X11.app: Unable to create / execute xmodmap command line");
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))) {
(snprintf(usermodmap, sizeof(usermodmap), "%s/.Xmodmap",
homedir) < sizeof(usermodmap))) {
if (access(usermodmap, F_OK) == 0) {
if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap) <
sizeof(cmd)) {
if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap,
usermodmap) < sizeof(cmd)) {
X11ApplicationLaunchClient(cmd);
}
else {
ErrorF
("X11.app: Unable to create / execute xmodmap command line");
ErrorF(
"X11.app: Unable to create / execute xmodmap command line");
}
}
}
@ -502,7 +499,6 @@ int
DarwinModifierNXKeyToNXKeycode(int key, int side)
{
int retval;
pthread_mutex_lock(&keyInfo_mutex);
retval = keyInfo.modifierKeycodes[key][side];
pthread_mutex_unlock(&keyInfo_mutex);
@ -526,8 +522,7 @@ DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
pthread_mutex_lock(&keyInfo_mutex);
for (key = 0; key < NX_NUMMODIFIERS; key++) {
for (side = 0; side <= 1; side++) {
if (keyInfo.modifierKeycodes[key][side] == keycode)
break;
if (keyInfo.modifierKeycodes[key][side] == keycode) break;
}
}
pthread_mutex_unlock(&keyInfo_mutex);
@ -535,8 +530,7 @@ DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
if (key == NX_NUMMODIFIERS) {
return -1;
}
if (outSide)
*outSide = side;
if (outSide) *outSide = side;
return key;
}
@ -551,42 +545,57 @@ DarwinModifierNXMaskToNXKey(int mask)
switch (mask) {
case NX_ALPHASHIFTMASK:
return NX_MODIFIERKEY_ALPHALOCK;
case NX_SHIFTMASK:
return NX_MODIFIERKEY_SHIFT;
#ifdef NX_DEVICELSHIFTKEYMASK
case NX_DEVICELSHIFTKEYMASK:
return NX_MODIFIERKEY_SHIFT;
case NX_DEVICERSHIFTKEYMASK:
return NX_MODIFIERKEY_RSHIFT;
#endif
case NX_CONTROLMASK:
return NX_MODIFIERKEY_CONTROL;
#ifdef NX_DEVICELCTLKEYMASK
case NX_DEVICELCTLKEYMASK:
return NX_MODIFIERKEY_CONTROL;
case NX_DEVICERCTLKEYMASK:
return NX_MODIFIERKEY_RCONTROL;
#endif
case NX_ALTERNATEMASK:
return NX_MODIFIERKEY_ALTERNATE;
#ifdef NX_DEVICELALTKEYMASK
case NX_DEVICELALTKEYMASK:
return NX_MODIFIERKEY_ALTERNATE;
case NX_DEVICERALTKEYMASK:
return NX_MODIFIERKEY_RALTERNATE;
#endif
case NX_COMMANDMASK:
return NX_MODIFIERKEY_COMMAND;
#ifdef NX_DEVICELCMDKEYMASK
case NX_DEVICELCMDKEYMASK:
return NX_MODIFIERKEY_COMMAND;
case NX_DEVICERCMDKEYMASK:
return NX_MODIFIERKEY_RCOMMAND;
#endif
case NX_NUMERICPADMASK:
return NX_MODIFIERKEY_NUMERICPAD;
case NX_HELPMASK:
return NX_MODIFIERKEY_HELP;
case NX_SECONDARYFNMASK:
return NX_MODIFIERKEY_SECONDARYFN;
}
@ -603,37 +612,52 @@ DarwinModifierNXKeyToNXMask(int key)
switch (key) {
case NX_MODIFIERKEY_ALPHALOCK:
return NX_ALPHASHIFTMASK;
#ifdef NX_DEVICELSHIFTKEYMASK
case NX_MODIFIERKEY_SHIFT:
return NX_DEVICELSHIFTKEYMASK;
case NX_MODIFIERKEY_RSHIFT:
return NX_DEVICERSHIFTKEYMASK;
case NX_MODIFIERKEY_CONTROL:
return NX_DEVICELCTLKEYMASK;
case NX_MODIFIERKEY_RCONTROL:
return NX_DEVICERCTLKEYMASK;
case NX_MODIFIERKEY_ALTERNATE:
return NX_DEVICELALTKEYMASK;
case NX_MODIFIERKEY_RALTERNATE:
return NX_DEVICERALTKEYMASK;
case NX_MODIFIERKEY_COMMAND:
return NX_DEVICELCMDKEYMASK;
case NX_MODIFIERKEY_RCOMMAND:
return NX_DEVICERCMDKEYMASK;
#else
case NX_MODIFIERKEY_SHIFT:
return NX_SHIFTMASK;
case NX_MODIFIERKEY_CONTROL:
return NX_CONTROLMASK;
case NX_MODIFIERKEY_ALTERNATE:
return NX_ALTERNATEMASK;
case NX_MODIFIERKEY_COMMAND:
return NX_COMMANDMASK;
#endif
case NX_MODIFIERKEY_NUMERICPAD:
return NX_NUMERICPADMASK;
case NX_MODIFIERKEY_HELP:
return NX_HELPMASK;
case NX_MODIFIERKEY_SECONDARYFN:
return NX_SECONDARYFNMASK;
}
@ -649,80 +673,56 @@ DarwinModifierStringToNXMask(const char *str, int separatelr)
{
#ifdef NX_DEVICELSHIFTKEYMASK
if (separatelr) {
if (!strcasecmp(str, "shift"))
return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK;
if (!strcasecmp(str, "control"))
return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK;
if (!strcasecmp(str, "option"))
return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "alt"))
return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "command"))
return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
if (!strcasecmp(str, "lshift"))
return NX_DEVICELSHIFTKEYMASK;
if (!strcasecmp(str, "rshift"))
return NX_DEVICERSHIFTKEYMASK;
if (!strcasecmp(str, "lcontrol"))
return NX_DEVICELCTLKEYMASK;
if (!strcasecmp(str, "rcontrol"))
return NX_DEVICERCTLKEYMASK;
if (!strcasecmp(str, "loption"))
return NX_DEVICELALTKEYMASK;
if (!strcasecmp(str, "roption"))
return NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "lalt"))
return NX_DEVICELALTKEYMASK;
if (!strcasecmp(str, "ralt"))
return NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "lcommand"))
return NX_DEVICELCMDKEYMASK;
if (!strcasecmp(str, "rcommand"))
return NX_DEVICERCMDKEYMASK;
if (!strcasecmp(str,
"shift")) return NX_DEVICELSHIFTKEYMASK |
NX_DEVICERSHIFTKEYMASK;
if (!strcasecmp(str,
"control")) return NX_DEVICELCTLKEYMASK |
NX_DEVICERCTLKEYMASK;
if (!strcasecmp(str,
"option")) return NX_DEVICELALTKEYMASK |
NX_DEVICERALTKEYMASK;
if (!strcasecmp(str,
"alt")) return NX_DEVICELALTKEYMASK |
NX_DEVICERALTKEYMASK;
if (!strcasecmp(str,
"command")) return NX_DEVICELCMDKEYMASK |
NX_DEVICERCMDKEYMASK;
if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK;
if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK;
if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK;
if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK;
if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK;
if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "lalt")) return NX_DEVICELALTKEYMASK;
if (!strcasecmp(str, "ralt")) return NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK;
if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK;
}
else {
#endif
if (!strcasecmp(str, "shift"))
return NX_SHIFTMASK;
if (!strcasecmp(str, "control"))
return NX_CONTROLMASK;
if (!strcasecmp(str, "option"))
return NX_ALTERNATEMASK;
if (!strcasecmp(str, "alt"))
return NX_ALTERNATEMASK;
if (!strcasecmp(str, "command"))
return NX_COMMANDMASK;
if (!strcasecmp(str, "lshift"))
return NX_SHIFTMASK;
if (!strcasecmp(str, "rshift"))
return NX_SHIFTMASK;
if (!strcasecmp(str, "lcontrol"))
return NX_CONTROLMASK;
if (!strcasecmp(str, "rcontrol"))
return NX_CONTROLMASK;
if (!strcasecmp(str, "loption"))
return NX_ALTERNATEMASK;
if (!strcasecmp(str, "roption"))
return NX_ALTERNATEMASK;
if (!strcasecmp(str, "lalt"))
return NX_ALTERNATEMASK;
if (!strcasecmp(str, "ralt"))
return NX_ALTERNATEMASK;
if (!strcasecmp(str, "lcommand"))
return NX_COMMANDMASK;
if (!strcasecmp(str, "rcommand"))
return NX_COMMANDMASK;
if (!strcasecmp(str, "shift")) return NX_SHIFTMASK;
if (!strcasecmp(str, "control")) return NX_CONTROLMASK;
if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "alt")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "command")) return NX_COMMANDMASK;
if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK;
if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK;
if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK;
if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK;
if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "lalt")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "ralt")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK;
if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK;
#ifdef NX_DEVICELSHIFTKEYMASK
}
}
#endif
if (!strcasecmp(str, "lock"))
return NX_ALPHASHIFTMASK;
if (!strcasecmp(str, "fn"))
return NX_SECONDARYFNMASK;
if (!strcasecmp(str, "help"))
return NX_HELPMASK;
if (!strcasecmp(str, "numlock"))
return NX_NUMERICPADMASK;
if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK;
if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK;
if (!strcasecmp(str, "help")) return NX_HELPMASK;
if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK;
return 0;
}
@ -745,28 +745,42 @@ macroman2ucs(unsigned char c)
first character. */
static const unsigned short table[128] = {
0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc,
0xe1,
0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9,
0xe8,
0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1,
0xf3,
0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb,
0xfc,
0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6,
0xdf,
0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6,
0xd8,
0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202,
0x2211,
0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6,
0xf8,
0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206,
0xab,
0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152,
0x153,
0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7,
0x25ca,
0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01,
0xfb02,
0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca,
0xc1,
0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3,
0xd4,
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];
if (c < 128) return c;
else return table[c - 128];
}
static KeySym
@ -775,14 +789,13 @@ 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;
if (dead_keys[i].normal == in) return dead_keys[i].dead;
return in;
}
static Bool
QuartzReadSystemKeymap(darwinKeyboardInfo * info)
QuartzReadSystemKeymap(darwinKeyboardInfo *info)
{
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
KeyboardLayoutRef key_layout;
@ -801,9 +814,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
TISCopyCurrentKeyboardLayoutInputSource();
if (currentKeyLayoutRef) {
currentKeyLayoutDataRef =
(CFDataRef) TISGetInputSourceProperty(currentKeyLayoutRef,
kTISPropertyUnicodeKeyLayoutData);
currentKeyLayoutDataRef = (CFDataRef)TISGetInputSourceProperty(
currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
if (currentKeyLayoutDataRef)
chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
}
@ -811,18 +823,18 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
#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
ErrorF
("X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
ErrorF
("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
(unsigned) keyboard_type, currentKeyLayoutRef,
currentKeyLayoutDataRef, chr_data);
ErrorF(
"X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
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);
@ -830,25 +842,25 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#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");
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");
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");
KLGetKeyboardLayoutProperty(key_layout, kKLKCHRData, &chr_data);
is_uchr = 0;
num_keycodes = 128;
#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");
ErrorF(
"X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
}
#endif
}
@ -877,7 +889,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
must be used instead. */
for (i = 0; i < num_keycodes; i++) {
static const int mods[4] = { 0, MOD_SHIFT, MOD_OPTION,
static const int mods[4] = {
0, MOD_SHIFT, MOD_OPTION,
MOD_OPTION | MOD_SHIFT
};
@ -887,82 +900,74 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (is_uchr) {
#endif
UniChar s[8];
UniCharCount len;
UInt32 dead_key_state = 0, extra_dead = 0;
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. */
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. */
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' ...
*/
if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
k[j] = ucs2keysym(s[0]);
if (dead_key_state != 0)
k[j] = make_dead_key(k[j]);
}
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
mods[j] >> 8, keyboard_type,
kUCKeyTranslateNoDeadKeysMask,
&extra_dead, 8, &len, s);
if (err != noErr) continue;
}
else { // kchr
UInt32 c, state = 0, state2 = 0;
UInt16 code;
code = i | mods[j];
/* Not sure why 0x0010 is there.
* 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ...
*/
if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
k[j] = ucs2keysym(s[0]);
if (dead_key_state != 0) k[j] = make_dead_key(k[j]);
}
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
}
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
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
#endif
c = KeyTranslate(chr_data, code, &state);
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. */
/* 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. */
if (state != 0)
c = KeyTranslate(chr_data, code | 128, &state2);
if (state != 0)
c = KeyTranslate(chr_data, code | 128, &state2);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
/* Characters seem to be in MacRoman encoding. */
/* Characters seem to be in MacRoman encoding. */
if (c != 0 && c != 0x0010) {
k[j] = ucs2keysym(macroman2ucs(c & 255));
if (c != 0 && c != 0x0010) {
k[j] = ucs2keysym(macroman2ucs(c & 255));
if (state != 0)
k[j] = make_dead_key(k[j]);
}
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 (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
@ -1006,7 +1011,6 @@ Bool
QuartsResyncKeymap(Bool sendDDXEvent)
{
Bool retval;
/* Update keyInfo */
pthread_mutex_lock(&keyInfo_mutex);
memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));

View File

@ -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
@ -27,30 +28,38 @@
#ifndef QUARTZ_KEYBOARD_H
#define QUARTZ_KEYBOARD_H 1
#define XK_TECHNICAL // needed to get XK_Escape
#define XK_TECHNICAL // needed to get XK_Escape
#define XK_PUBLISHING
#include "X11/keysym.h"
#include "inputstr.h"
// Each key can generate 4 glyphs. They are, in order:
// unshifted, shifted, modeswitch unshifted, modeswitch shifted
#define GLYPHS_PER_KEY 4
#define NUM_KEYCODES 248 // NX_NUMKEYCODES might be better
#define MIN_KEYCODE XkbMinLegalKeyCode // unfortunately, this isn't 0...
#define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1
#define GLYPHS_PER_KEY 4
#define NUM_KEYCODES 248 // NX_NUMKEYCODES might be better
#define MIN_KEYCODE XkbMinLegalKeyCode // unfortunately, this isn't 0...
#define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1
/* These functions need to be implemented by Xquartz, XDarwin, etc. */
Bool QuartsResyncKeymap(Bool sendDDXEvent);
Bool
QuartsResyncKeymap(Bool sendDDXEvent);
/* Provided for darwinEvents.c */
void DarwinKeyboardReloadHandler(void);
int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
int DarwinModifierNXKeyToNXKeycode(int key, int side);
int DarwinModifierNXKeyToNXMask(int key);
int DarwinModifierNXMaskToNXKey(int mask);
int DarwinModifierStringToNXMask(const char *string, int separatelr);
void
DarwinKeyboardReloadHandler(void);
int
DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
int
DarwinModifierNXKeyToNXKeycode(int key, int side);
int
DarwinModifierNXKeyToNXMask(int key);
int
DarwinModifierNXMaskToNXKey(int mask);
int
DarwinModifierStringToNXMask(const char *string, int separatelr);
/* Provided for darwin.c */
void DarwinKeyboardInit(DeviceIntPtr pDev);
void
DarwinKeyboardInit(DeviceIntPtr pDev);
#endif /* QUARTZ_KEYBOARD_H */
#endif /* QUARTZ_KEYBOARD_H */

View File

@ -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
@ -53,18 +53,18 @@
*/
static Bool ignore_next_fake_mode_update = FALSE;
#define FAKE_REFRESH_ROOTLESS 1
#define FAKE_REFRESH_ROOTLESS 1
#define FAKE_REFRESH_FULLSCREEN 2
#define DEFAULT_REFRESH 60
#define kDisplayModeUsableFlags (kDisplayModeValidFlag | kDisplayModeSafeFlag)
#define DEFAULT_REFRESH 60
#define kDisplayModeUsableFlags (kDisplayModeValidFlag | kDisplayModeSafeFlag)
#define CALLBACK_SUCCESS 0
#define CALLBACK_CONTINUE 1
#define CALLBACK_ERROR -1
#define CALLBACK_SUCCESS 0
#define CALLBACK_CONTINUE 1
#define CALLBACK_ERROR -1
typedef int (*QuartzModeCallback)
(ScreenPtr, QuartzModeInfoPtr, void *);
(ScreenPtr, QuartzModeInfoPtr, void *);
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
@ -73,8 +73,7 @@ getDictLong(CFDictionaryRef dictRef, CFStringRef key)
{
long value;
CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key);
if (!numRef)
return 0;
@ -88,8 +87,7 @@ getDictDouble(CFDictionaryRef dictRef, CFStringRef key)
{
double value;
CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key);
if (!numRef)
return 0.0;
@ -99,12 +97,13 @@ getDictDouble(CFDictionaryRef dictRef, CFStringRef key)
}
static void
QuartzRandRGetModeInfo(CFDictionaryRef modeRef, QuartzModeInfoPtr pMode)
QuartzRandRGetModeInfo(CFDictionaryRef modeRef,
QuartzModeInfoPtr pMode)
{
pMode->width = (size_t) getDictLong(modeRef, kCGDisplayWidth);
pMode->height = (size_t) getDictLong(modeRef, kCGDisplayHeight);
pMode->width = (size_t)getDictLong(modeRef, kCGDisplayWidth);
pMode->height = (size_t)getDictLong(modeRef, kCGDisplayHeight);
pMode->refresh =
(int) (getDictDouble(modeRef, kCGDisplayRefreshRate) + 0.5);
(int)(getDictDouble(modeRef, kCGDisplayRefreshRate) + 0.5);
if (pMode->refresh == 0)
pMode->refresh = DEFAULT_REFRESH;
pMode->ref = NULL;
@ -116,27 +115,27 @@ QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
QuartzModeInfoPtr pMode)
{
CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId);
if (!curModeRef)
return FALSE;
QuartzRandRGetModeInfo(curModeRef, pMode);
pMode->ref = (void *) curModeRef;
pMode->ref = (void *)curModeRef;
CFRetain(pMode->ref);
return TRUE;
}
static Bool
QuartzRandRSetCGMode(CGDirectDisplayID screenId, QuartzModeInfoPtr pMode)
QuartzRandRSetCGMode(CGDirectDisplayID screenId,
QuartzModeInfoPtr pMode)
{
CFDictionaryRef modeRef = (CFDictionaryRef) pMode->ref;
CFDictionaryRef modeRef = (CFDictionaryRef)pMode->ref;
return (CGDisplaySwitchToMode(screenId, modeRef) == kCGErrorSuccess);
}
static Bool
QuartzRandREnumerateModes(ScreenPtr pScreen,
QuartzModeCallback callback, void *data)
QuartzModeCallback callback,
void *data)
{
Bool retval = FALSE;
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
@ -160,19 +159,18 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
return FALSE;
for (i = 0; i < CFArrayGetCount(modes); i++) {
int cb;
modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
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. */
if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
if (((unsigned long)getDictLong(modeRef, kCGDisplayIOFlags) &
kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
continue;
if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
continue;
QuartzRandRGetModeInfo(modeRef, &modeInfo);
modeInfo.ref = (void *) modeRef;
modeInfo.ref = (void *)modeRef;
cb = callback(pScreen, &modeInfo, data);
if (cb == CALLBACK_CONTINUE)
retval = TRUE;
@ -186,10 +184,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
case CALLBACK_ERROR:
return FALSE;
case CALLBACK_CONTINUE:
retval = TRUE;
default:
break;
}
@ -197,10 +198,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
case CALLBACK_ERROR:
return FALSE;
case CALLBACK_CONTINUE:
retval = TRUE;
default:
break;
}
@ -208,14 +212,15 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
return retval;
}
#else /* we have the new CG APIs from Snow Leopard */
#else /* we have the new CG APIs from Snow Leopard */
static void
QuartzRandRGetModeInfo(CGDisplayModeRef modeRef, QuartzModeInfoPtr pMode)
QuartzRandRGetModeInfo(CGDisplayModeRef modeRef,
QuartzModeInfoPtr pMode)
{
pMode->width = CGDisplayModeGetWidth(modeRef);
pMode->height = CGDisplayModeGetHeight(modeRef);
pMode->refresh = (int) (CGDisplayModeGetRefreshRate(modeRef) + 0.5);
pMode->refresh = (int)(CGDisplayModeGetRefreshRate(modeRef) + 0.5);
if (pMode->refresh == 0)
pMode->refresh = DEFAULT_REFRESH;
pMode->ref = NULL;
@ -227,7 +232,6 @@ QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
QuartzModeInfoPtr pMode)
{
CGDisplayModeRef curModeRef = CGDisplayCopyDisplayMode(screenId);
if (!curModeRef)
return FALSE;
@ -237,20 +241,21 @@ QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
}
static Bool
QuartzRandRSetCGMode(CGDirectDisplayID screenId, QuartzModeInfoPtr pMode)
QuartzRandRSetCGMode(CGDirectDisplayID screenId,
QuartzModeInfoPtr pMode)
{
CGDisplayModeRef modeRef = (CGDisplayModeRef) pMode->ref;
CGDisplayModeRef modeRef = (CGDisplayModeRef)pMode->ref;
if (!modeRef)
return FALSE;
return (CGDisplaySetDisplayMode(screenId, modeRef, NULL) ==
kCGErrorSuccess);
return (CGDisplaySetDisplayMode(screenId, modeRef,
NULL) == kCGErrorSuccess);
}
static Bool
QuartzRandREnumerateModes(ScreenPtr pScreen,
QuartzModeCallback callback, void *data)
QuartzModeCallback callback,
void *data)
{
Bool retval = FALSE;
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
@ -278,12 +283,12 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
}
for (i = 0; i < CFArrayGetCount(modes); i++) {
int cb;
modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
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. */
if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
if ((CGDisplayModeGetIOFlags(modeRef) &
kDisplayModeUsableFlags) !=
kDisplayModeUsableFlags)
continue;
pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
@ -317,10 +322,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
case CALLBACK_ERROR:
return FALSE;
case CALLBACK_CONTINUE:
retval = TRUE;
default:
break;
}
@ -328,10 +336,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
case CALLBACK_SUCCESS:
return TRUE;
case CALLBACK_ERROR:
return FALSE;
case CALLBACK_CONTINUE:
retval = TRUE;
default:
break;
}
@ -339,22 +350,24 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
return retval;
}
#endif /* Snow Leopard CoreGraphics APIs */
#endif /* Snow Leopard CoreGraphics APIs */
static Bool
QuartzRandRModesEqual(QuartzModeInfoPtr pMode1, QuartzModeInfoPtr pMode2)
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)
QuartzRandRRegisterMode(ScreenPtr pScreen,
QuartzModeInfoPtr pMode)
{
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
Bool isCurrentMode =
QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode);
Bool isCurrentMode = QuartzRandRModesEqual(&pQuartzScreen->currentMode,
pMode);
/* TODO: DPI */
pMode->pSize =
@ -375,7 +388,8 @@ QuartzRandRRegisterMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode)
static int
QuartzRandRRegisterModeCallback(ScreenPtr pScreen,
QuartzModeInfoPtr pMode, void *data __unused)
QuartzModeInfoPtr pMode,
void *data __unused)
{
if (QuartzRandRRegisterMode(pScreen, pMode)) {
return CALLBACK_CONTINUE;
@ -386,11 +400,13 @@ QuartzRandRRegisterModeCallback(ScreenPtr pScreen,
}
static Bool
QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister)
QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode,
BOOL doRegister)
{
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN &&
pMode->refresh != FAKE_REFRESH_ROOTLESS);
Bool captureDisplay =
(pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh !=
FAKE_REFRESH_ROOTLESS);
CGDirectDisplayID screenId;
if (pQuartzScreen->displayIDs == NULL)
@ -442,15 +458,16 @@ QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister)
static int
QuartzRandRSetModeCallback(ScreenPtr pScreen,
QuartzModeInfoPtr pMode, void *data)
QuartzModeInfoPtr pMode,
void *data)
{
QuartzModeInfoPtr pReqMode = (QuartzModeInfoPtr) data;
QuartzModeInfoPtr pReqMode = (QuartzModeInfoPtr)data;
if (!QuartzRandRModesEqual(pMode, pReqMode))
return CALLBACK_CONTINUE; /* continue enumeration */
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);
(int)pMode->width, (int)pMode->height, (int)pMode->refresh);
if (QuartzRandRSetMode(pScreen, pMode, FALSE))
return CALLBACK_SUCCESS;
@ -459,9 +476,9 @@ QuartzRandRSetModeCallback(ScreenPtr pScreen,
}
static Bool
QuartzRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
QuartzRandRGetInfo(ScreenPtr pScreen, Rotation *rotations)
{
*rotations = RR_Rotate_0; /* TODO: support rotation */
*rotations = RR_Rotate_0; /* TODO: support rotation */
return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback,
NULL);
@ -469,7 +486,9 @@ QuartzRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
static Bool
QuartzRandRSetConfig(ScreenPtr pScreen,
Rotation randr, int rate, RRScreenSizePtr pSize)
Rotation randr,
int rate,
RRScreenSizePtr pSize)
{
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
QuartzModeInfo reqMode;
@ -482,13 +501,14 @@ QuartzRandRSetConfig(ScreenPtr pScreen,
if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode))
return TRUE;
if (QuartzRandREnumerateModes
(pScreen, QuartzRandRSetModeCallback, &reqMode)) {
if (QuartzRandREnumerateModes(pScreen, QuartzRandRSetModeCallback,
&reqMode)) {
return TRUE;
}
DEBUG_LOG("Unable to find a matching config: %d x %d @ %d\n",
(int) reqMode.width, (int) reqMode.height, (int) reqMode.refresh);
(int)reqMode.width, (int)reqMode.height,
(int)reqMode.refresh);
return FALSE;
}
@ -499,8 +519,8 @@ _QuartzRandRUpdateFakeModes(ScreenPtr pScreen)
QuartzModeInfo activeMode;
if (pQuartzScreen->displayCount > 0) {
if (!QuartzRandRCopyCurrentModeInfo
(pQuartzScreen->displayIDs[0], &activeMode)) {
if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0],
&activeMode)) {
ErrorF("Unable to determine current display mode.\n");
return FALSE;
}
@ -545,13 +565,13 @@ _QuartzRandRUpdateFakeModes(ScreenPtr pScreen)
CFRetain(pQuartzScreen->currentMode.ref);
DEBUG_LOG("rootlessMode: %d x %d\n",
(int) pQuartzScreen->rootlessMode.width,
(int) pQuartzScreen->rootlessMode.height);
(int)pQuartzScreen->rootlessMode.width,
(int)pQuartzScreen->rootlessMode.height);
DEBUG_LOG("fullscreenMode: %d x %d\n",
(int) pQuartzScreen->fullscreenMode.width,
(int) pQuartzScreen->fullscreenMode.height);
DEBUG_LOG("currentMode: %d x %d\n", (int) pQuartzScreen->currentMode.width,
(int) pQuartzScreen->currentMode.height);
(int)pQuartzScreen->fullscreenMode.width,
(int)pQuartzScreen->fullscreenMode.height);
DEBUG_LOG("currentMode: %d x %d\n", (int)pQuartzScreen->currentMode.width,
(int)pQuartzScreen->currentMode.height);
return TRUE;
}
@ -562,8 +582,8 @@ QuartzRandRUpdateFakeModes(BOOL force_update)
ScreenPtr pScreen = screenInfo.screens[0];
if (ignore_next_fake_mode_update) {
DEBUG_LOG
("Ignoring update request caused by RandR resolution change.\n");
DEBUG_LOG(
"Ignoring update request caused by RandR resolution change.\n");
ignore_next_fake_mode_update = FALSE;
return TRUE;
}
@ -582,10 +602,8 @@ QuartzRandRInit(ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
if (!RRScreenInit(pScreen))
return FALSE;
if (!_QuartzRandRUpdateFakeModes(pScreen))
return FALSE;
if (!RRScreenInit(pScreen)) return FALSE;
if (!_QuartzRandRUpdateFakeModes(pScreen)) return FALSE;
pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = QuartzRandRGetInfo;
@ -637,12 +655,12 @@ QuartzRandRToggleFullscreen(void)
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
if (pQuartzScreen->currentMode.ref == NULL) {
ErrorF
("Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n");
ErrorF(
"Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n");
}
else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) {
ErrorF
("Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n");
ErrorF(
"Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n");
}
else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_FULLSCREEN) {
/* Legacy fullscreen mode. Hide/Show */

View File

@ -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
@ -37,7 +37,7 @@ typedef struct {
size_t width, height;
int refresh;
RRScreenSizePtr pSize;
void *ref; /* CGDisplayModeRef or CFDictionaryRef */
void *ref; /* CGDisplayModeRef or CFDictionaryRef */
} QuartzModeInfo, *QuartzModeInfoPtr;
// Quartz specific per screen storage structure
@ -54,11 +54,14 @@ typedef struct {
#define QUARTZ_PRIV(pScreen) \
((QuartzScreenPtr)dixLookupPrivate(&pScreen->devPrivates, quartzScreenKey))
void QuartzCopyDisplayIDs(ScreenPtr pScreen,
int displayCount, CGDirectDisplayID * displayIDs);
void
QuartzCopyDisplayIDs(ScreenPtr pScreen, int displayCount,
CGDirectDisplayID *displayIDs);
Bool QuartzRandRUpdateFakeModes(BOOL force_update);
Bool QuartzRandRInit(ScreenPtr pScreen);
Bool
QuartzRandRUpdateFakeModes(BOOL force_update);
Bool
QuartzRandRInit(ScreenPtr pScreen);
/* These two functions provide functionality expected by the legacy
* mode switching. They are equivalent to a client requesting one
@ -66,14 +69,17 @@ Bool QuartzRandRInit(ScreenPtr pScreen);
* QuartzRandRSetFakeFullscreen takes an argument which is used to determine
* the visibility of the windows after the change.
*/
void QuartzRandRSetFakeRootless(void);
void QuartzRandRSetFakeFullscreen(BOOL state);
void
QuartzRandRSetFakeRootless(void);
void
QuartzRandRSetFakeFullscreen(BOOL state);
/* Toggle fullscreen mode. If "fake" fullscreen is the current mode,
* this will just show/hide the X11 windows. If we are in a RandR fullscreen
* mode, this will toggles us to the default fake mode and hide windows if
* it is fullscreen
*/
void QuartzRandRToggleFullscreen(void);
void
QuartzRandRToggleFullscreen(void);
#endif

View File

@ -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
@ -48,7 +48,8 @@
#include <pthread.h>
int dix_main(int argc, char **argv, char **envp);
int
dix_main(int argc, char **argv, char **envp);
struct arg {
int argc;
@ -56,11 +57,11 @@ struct arg {
char **envp;
};
_X_NORETURN static void
_X_NORETURN
static void
server_thread(void *arg)
{
struct arg args = *((struct arg *) arg);
struct arg args = *((struct arg *)arg);
free(arg);
exit(dix_main(args.argc, args.argv, args.envp));
}
@ -83,8 +84,7 @@ create_thread(void *func, void *arg)
void
QuartzInitServer(int argc, char **argv, char **envp)
{
struct arg *args = (struct arg *) malloc(sizeof(struct arg));
struct arg *args = (struct arg *)malloc(sizeof(struct arg));
if (!args)
FatalError("Could not allocate memory.\n");
@ -117,7 +117,8 @@ server_main(int argc, char **argv, char **envp)
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")) {
if (!strcmp(argv[i],
"-showconfig") || !strcmp(argv[i], "-version")) {
DarwinPrintBanner();
exit(0);
}

View File

@ -10,18 +10,18 @@
// the basic X server headers. Use QD_<name> to use the QuickDraw
// definition of any of these symbols, or the normal name for the
// X11 definition.
#define Cursor QD_Cursor
#define WindowPtr QD_WindowPtr
#define Picture QD_Picture
#define BOOL OSX_BOOL
#define EventType HIT_EventType
#define Cursor QD_Cursor
#define WindowPtr QD_WindowPtr
#define Picture QD_Picture
#define BOOL OSX_BOOL
#define EventType HIT_EventType
#include <ApplicationServices/ApplicationServices.h>
#include <CoreServices/CoreServices.h>
#include <Carbon/Carbon.h>
#include <IOKit/hidsystem/event_status_driver.h>
#include <IOKit/hidsystem/ev_keymap.h>
#include <architecture/byte_order.h> // For the NXSwap*
#include <architecture/byte_order.h> // For the NXSwap*
#undef Cursor
#undef WindowPtr
@ -29,4 +29,4 @@
#undef BOOL
#undef EventType
#endif /* _XQ_SANITIZED_CARBON_H_ */
#endif /* _XQ_SANITIZED_CARBON_H_ */

View File

@ -10,11 +10,11 @@
// the basic X server headers. Use QD_<name> to use the QuickDraw
// definition of any of these symbols, or the normal name for the
// X11 definition.
#define Cursor QD_Cursor
#define WindowPtr QD_WindowPtr
#define Picture QD_Picture
#define BOOL OSX_BOOL
#define EventType HIT_EventType
#define Cursor QD_Cursor
#define WindowPtr QD_WindowPtr
#define Picture QD_Picture
#define BOOL OSX_BOOL
#define EventType HIT_EventType
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@ -26,7 +26,7 @@
#undef EventType
#ifndef __has_feature
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
#ifndef NS_RETURNS_RETAINED
@ -61,4 +61,4 @@
#endif
#endif
#endif /* _XQ_SANITIZED_COCOA_H_ */
#endif /* _XQ_SANITIZED_COCOA_H_ */

View File

@ -1,29 +1,29 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2009-2011 Apple Inc.
All Rights Reserved.
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 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, 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:
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 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.
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.
**************************************************************************/
@ -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>
*
*/
@ -59,14 +60,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
static int DRIErrorBase = 0;
static void AppleDRIResetProc(ExtensionEntry * extEntry);
static int ProcAppleDRICreatePixmap(ClientPtr client);
static void
AppleDRIResetProc(ExtensionEntry* extEntry);
static int
ProcAppleDRICreatePixmap(ClientPtr client);
static unsigned char DRIReqCode = 0;
static int DRIEventBase = 0;
static void SNotifyEvent(xAppleDRINotifyEvent * from,
xAppleDRINotifyEvent * to);
static void
SNotifyEvent(xAppleDRINotifyEvent *from, xAppleDRINotifyEvent *to);
typedef struct _DRIEvent *DRIEventPtr;
typedef struct _DRIEvent {
@ -76,8 +79,9 @@ typedef struct _DRIEvent {
unsigned int mask;
} DRIEventRec;
/*ARGSUSED*/ static void
AppleDRIResetProc(ExtensionEntry * extEntry)
/*ARGSUSED*/
static void
AppleDRIResetProc(ExtensionEntry* extEntry)
{
DRIReset();
}
@ -101,7 +105,7 @@ ProcAppleDRIQueryVersion(register ClientPtr client)
swaps(&rep.minorVersion);
swapl(&rep.patchVersion);
}
WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *) &rep);
WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
return Success;
}
@ -135,7 +139,7 @@ ProcAppleDRIQueryDirectRenderingCapable(register ClientPtr client)
WriteToClient(client,
sizeof(xAppleDRIQueryDirectRenderingCapableReply),
(char *) &rep);
(char *)&rep);
return Success;
}
@ -152,26 +156,28 @@ ProcAppleDRIAuthConnection(register ClientPtr client)
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);
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 */
swapl(&rep.authenticated); /* Yes, this is a CARD32 ... sigh */
}
WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *) &rep);
WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
return Success;
}
static void
surface_notify(void *_arg, void *data)
surface_notify(void *_arg,
void *data)
{
DRISurfaceNotifyArg *arg = _arg;
int client_index = (int) x_cvt_vptr_to_uint(data);
int client_index = (int)x_cvt_vptr_to_uint(data);
xAppleDRINotifyEvent se;
if (client_index < 0 || client_index >= currentMaxClients)
@ -181,7 +187,7 @@ surface_notify(void *_arg, void *data)
se.kind = arg->kind;
se.arg = arg->id;
se.time = currentTime.milliseconds;
WriteEventsToClient(clients[client_index], 1, (xEvent *) &se);
WriteEventsToClient(clients[client_index], 1, (xEvent *)&se);
}
static int
@ -207,9 +213,10 @@ ProcAppleDRICreateSurface(ClientPtr client)
rep.key_0 = rep.key_1 = rep.uid = 0;
if (!DRICreateSurface(screenInfo.screens[stuff->screen],
(Drawable) stuff->drawable, pDrawable,
(Drawable)stuff->drawable, pDrawable,
stuff->client_id, &sid, key,
surface_notify, x_cvt_uint_to_vptr(client->index))) {
surface_notify,
x_cvt_uint_to_vptr(client->index))) {
return BadValue;
}
@ -225,7 +232,7 @@ ProcAppleDRICreateSurface(ClientPtr client)
swapl(&rep.uid);
}
WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *) &rep);
WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
return Success;
}
@ -233,10 +240,8 @@ static int
ProcAppleDRIDestroySurface(register ClientPtr client)
{
int rc;
REQUEST(xAppleDRIDestroySurfaceReq);
DrawablePtr pDrawable;
REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
@ -245,7 +250,8 @@ ProcAppleDRIDestroySurface(register ClientPtr client)
return rc;
if (!DRIDestroySurface(screenInfo.screens[stuff->screen],
(Drawable) stuff->drawable, pDrawable, NULL, NULL)) {
(Drawable)stuff->drawable,
pDrawable, NULL, NULL)) {
return BadValue;
}
@ -272,12 +278,14 @@ ProcAppleDRICreatePixmap(ClientPtr client)
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)) {
if (!DRIGetPixmapData(pDrawable, &width, &height,
&pitch, &bpp, &ptr)) {
return BadValue;
}
@ -317,7 +325,6 @@ ProcAppleDRIDestroyPixmap(ClientPtr client)
{
DrawablePtr pDrawable;
int rc;
REQUEST(xAppleDRIDestroyPixmapReq);
REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq);
@ -342,6 +349,7 @@ ProcAppleDRIDispatch(register ClientPtr client)
switch (stuff->data) {
case X_AppleDRIQueryVersion:
return ProcAppleDRIQueryVersion(client);
case X_AppleDRIQueryDirectRenderingCapable:
return ProcAppleDRIQueryDirectRenderingCapable(client);
}
@ -352,12 +360,16 @@ ProcAppleDRIDispatch(register ClientPtr client)
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);
@ -367,7 +379,8 @@ ProcAppleDRIDispatch(register ClientPtr client)
}
static void
SNotifyEvent(xAppleDRINotifyEvent * from, xAppleDRINotifyEvent * to)
SNotifyEvent(xAppleDRINotifyEvent *from,
xAppleDRINotifyEvent *to)
{
to->type = from->type;
to->kind = from->kind;
@ -451,6 +464,7 @@ SProcAppleDRIDispatch(register ClientPtr client)
switch (stuff->data) {
case X_AppleDRIQueryVersion:
return SProcAppleDRIQueryVersion(client);
case X_AppleDRIQueryDirectRenderingCapable:
return SProcAppleDRIQueryDirectRenderingCapable(client);
}
@ -461,12 +475,16 @@ SProcAppleDRIDispatch(register ClientPtr client)
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);
@ -478,7 +496,7 @@ SProcAppleDRIDispatch(register ClientPtr client)
void
AppleDRIExtensionInit(void)
{
ExtensionEntry *extEntry;
ExtensionEntry* extEntry;
if (DRIExtensionInit() &&
(extEntry = AddExtension(APPLEDRINAME,
@ -486,13 +504,13 @@ AppleDRIExtensionInit(void)
AppleDRINumberErrors,
ProcAppleDRIDispatch,
SProcAppleDRIDispatch,
AppleDRIResetProc, StandardMinorOpcode))) {
AppleDRIResetProc,
StandardMinorOpcode))) {
size_t i;
DRIReqCode = (unsigned char) extEntry->base;
DRIReqCode = (unsigned char)extEntry->base;
DRIErrorBase = extEntry->errorBase;
DRIEventBase = extEntry->eventBase;
for (i = 0; i < AppleDRINumberEvents; i++)
EventSwapVector[DRIEventBase + i] = (EventSwapPtr) SNotifyEvent;
EventSwapVector[DRIEventBase + i] = (EventSwapPtr)SNotifyEvent;
}
}

View File

@ -1,30 +1,30 @@
/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
All Rights Reserved.
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002-2012 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:
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 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.
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.
**************************************************************************/
@ -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>
*
*/
@ -41,82 +42,96 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/Xfuncproto.h>
#define X_AppleDRIQueryVersion 0
#define X_AppleDRIQueryDirectRenderingCapable 1
#define X_AppleDRICreateSurface 2
#define X_AppleDRIDestroySurface 3
#define X_AppleDRIAuthConnection 4
#define X_AppleDRICreateSharedBuffer 5
#define X_AppleDRISwapBuffers 6
#define X_AppleDRICreatePixmap 7
#define X_AppleDRIDestroyPixmap 8
#define X_AppleDRIQueryVersion 0
#define X_AppleDRIQueryDirectRenderingCapable 1
#define X_AppleDRICreateSurface 2
#define X_AppleDRIDestroySurface 3
#define X_AppleDRIAuthConnection 4
#define X_AppleDRICreateSharedBuffer 5
#define X_AppleDRISwapBuffers 6
#define X_AppleDRICreatePixmap 7
#define X_AppleDRIDestroyPixmap 8
/* Requests up to and including 18 were used in a previous version */
/* Events */
#define AppleDRIObsoleteEvent1 0
#define AppleDRIObsoleteEvent2 1
#define AppleDRIObsoleteEvent3 2
#define AppleDRISurfaceNotify 3
#define AppleDRINumberEvents 4
#define AppleDRIObsoleteEvent1 0
#define AppleDRIObsoleteEvent2 1
#define AppleDRIObsoleteEvent3 2
#define AppleDRISurfaceNotify 3
#define AppleDRINumberEvents 4
/* Errors */
#define AppleDRIClientNotLocal 0
#define AppleDRIOperationNotSupported 1
#define AppleDRINumberErrors (AppleDRIOperationNotSupported + 1)
#define AppleDRIClientNotLocal 0
#define AppleDRIOperationNotSupported 1
#define AppleDRINumberErrors (AppleDRIOperationNotSupported + 1)
/* Kinds of SurfaceNotify events: */
#define AppleDRISurfaceNotifyChanged 0
#define AppleDRISurfaceNotifyDestroyed 1
#define AppleDRISurfaceNotifyChanged 0
#define AppleDRISurfaceNotifyDestroyed 1
#ifndef _APPLEDRI_SERVER_
typedef struct {
int type; /* of event */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came frome a SendEvent request */
Display *display; /* Display the event was read from */
Window window; /* window of event */
Time time; /* server timestamp when event happened */
int kind; /* subtype of event */
int type; /* of event */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came frome a SendEvent request */
Display *display; /* Display the event was read from */
Window window; /* window of event */
Time time; /* server timestamp when event happened */
int kind; /* subtype of event */
int arg;
} XAppleDRINotifyEvent;
_XFUNCPROTOBEGIN
Bool XAppleDRIQueryExtension(Display * dpy, int *event_base, int *error_base);
Bool
XAppleDRIQueryExtension(Display *dpy, int *event_base, int *error_base);
Bool XAppleDRIQueryVersion(Display * dpy, int *majorVersion,
int *minorVersion, int *patchVersion);
Bool
XAppleDRIQueryVersion(Display *dpy, int *majorVersion, int *minorVersion,
int *patchVersion);
Bool XAppleDRIQueryDirectRenderingCapable(Display * dpy, int screen,
Bool *isCapable);
Bool
XAppleDRIQueryDirectRenderingCapable(Display *dpy, int screen,
Bool *isCapable);
void *XAppleDRISetSurfaceNotifyHandler(void (*fun) (Display * dpy,
unsigned uid, int kind));
void *
XAppleDRISetSurfaceNotifyHandler(void (*fun)(Display *dpy, unsigned uid,
int kind));
Bool XAppleDRIAuthConnection(Display * dpy, int screen, unsigned int magic);
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* uid);
Bool XAppleDRIDestroySurface(Display * dpy, int screen, Drawable drawable);
Bool
XAppleDRIDestroySurface(Display *dpy, int screen, Drawable drawable);
Bool XAppleDRISynchronizeSurfaces(Display * dpy);
Bool
XAppleDRISynchronizeSurfaces(Display *dpy);
Bool XAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
Bool doubleSwap, char *path, size_t pathlen,
int *width, int *height);
Bool
XAppleDRICreateSharedBuffer(Display *dpy, int screen, Drawable drawable,
Bool doubleSwap, char *path, size_t pathlen,
int *width,
int *height);
Bool XAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable);
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);
Bool
XAppleDRICreatePixmap(Display *dpy, int screen, Drawable drawable, int *width,
int *height, int *pitch, int *bpp, size_t *size,
char *bufname,
size_t bufnamesize);
Bool XAppleDRIDestroyPixmap(Display * dpy, Pixmap pixmap);
Bool
XAppleDRIDestroyPixmap(Display *dpy, Pixmap pixmap);
_XFUNCPROTOEND
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRI_H_ */
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRI_H_ */

View File

@ -1,29 +1,29 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
All Rights Reserved.
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002-2012 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:
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 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.
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.
**************************************************************************/
@ -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>
*
*/
@ -40,47 +41,44 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "appledri.h"
#define APPLEDRINAME "Apple-DRI"
#define APPLEDRINAME "Apple-DRI"
#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */
#define APPLE_DRI_MINOR_VERSION 0
#define APPLE_DRI_PATCH_VERSION 0
#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */
#define APPLE_DRI_MINOR_VERSION 0
#define APPLE_DRI_PATCH_VERSION 0
typedef struct _AppleDRIQueryVersion {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIQueryVersion */
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIQueryVersion */
CARD16 length B16;
} xAppleDRIQueryVersionReq;
#define sz_xAppleDRIQueryVersionReq 4
#define sz_xAppleDRIQueryVersionReq 4
typedef struct {
BYTE type; /* X_Reply */
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 */
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
#define sz_xAppleDRIQueryVersionReply 32
typedef struct _AppleDRIQueryDirectRenderingCapable {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
CARD16 length B16;
CARD32 screen B32;
} xAppleDRIQueryDirectRenderingCapableReq;
#define sz_xAppleDRIQueryDirectRenderingCapableReq 8
#define sz_xAppleDRIQueryDirectRenderingCapableReq 8
typedef struct {
BYTE type; /* X_Reply */
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
@ -94,18 +92,16 @@ typedef struct {
CARD32 pad8 B32;
CARD32 pad9 B32;
} xAppleDRIQueryDirectRenderingCapableReply;
#define sz_xAppleDRIQueryDirectRenderingCapableReply 32
#define sz_xAppleDRIQueryDirectRenderingCapableReply 32
typedef struct _AppleDRIAuthConnection {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD16 length B16;
CARD32 screen B32;
CARD32 magic B32;
} xAppleDRIAuthConnectionReq;
#define sz_xAppleDRIAuthConnectionReq 12
#define sz_xAppleDRIAuthConnectionReq 12
typedef struct {
BYTE type;
@ -119,22 +115,20 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRIAuthConnectionReply;
#define zx_xAppleDRIAuthConnectionReply 32
#define zx_xAppleDRIAuthConnectionReply 32
typedef struct _AppleDRICreateSurface {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICreateSurface */
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
#define sz_xAppleDRICreateSurfaceReq 16
typedef struct {
BYTE type; /* X_Reply */
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
@ -145,24 +139,22 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRICreateSurfaceReply;
#define sz_xAppleDRICreateSurfaceReply 32
#define sz_xAppleDRICreateSurfaceReply 32
typedef struct _AppleDRIDestroySurface {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroySurface */
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroySurface */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xAppleDRIDestroySurfaceReq;
#define sz_xAppleDRIDestroySurfaceReq 12
#define sz_xAppleDRIDestroySurfaceReq 12
typedef struct _AppleDRINotify {
BYTE type; /* always eventBase + event type */
BYTE type; /* always eventBase + event type */
BYTE kind;
CARD16 sequenceNumber B16;
CARD32 time B32; /* time of change */
CARD32 time B32; /* time of change */
CARD32 pad1 B32;
CARD32 arg B32;
CARD32 pad3 B32;
@ -170,8 +162,7 @@ typedef struct _AppleDRINotify {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRINotifyEvent;
#define sz_xAppleDRINotifyEvent 32
#define sz_xAppleDRINotifyEvent 32
typedef struct {
CARD8 reqType;
@ -190,7 +181,7 @@ typedef struct {
BYTE data1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 stringLength B32; /* 0 on error */
CARD32 stringLength B32; /* 0 on error */
CARD32 width B32;
CARD32 height B32;
CARD32 pad1 B32;
@ -211,35 +202,35 @@ typedef struct {
#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
@ -248,12 +239,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_ */
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRISTR_H_ */

View File

@ -1,29 +1,29 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2009 Apple Computer, Inc.
All Rights Reserved.
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002-2012 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:
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 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.
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.
**************************************************************************/
@ -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
@ -75,23 +75,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <AvailabilityMacros.h>
static DevPrivateKeyRec DRIScreenPrivKeyRec;
#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
static DevPrivateKeyRec DRIWindowPrivKeyRec;
#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
static DevPrivateKeyRec DRIPixmapPrivKeyRec;
#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec)
#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec)
static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec;
#define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec)
static RESTYPE DRIDrawablePrivResType;
static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
static Bool DRIFreePixmapImp(DrawablePtr pDrawable);
static Bool
DRIFreePixmapImp(DrawablePtr pDrawable);
typedef struct {
DrawablePtr pDrawable;
@ -100,8 +97,8 @@ typedef struct {
int width;
int height;
char shmPath[PATH_MAX];
int fd; /* From shm_open (for now) */
size_t length; /* length of buffer */
int fd; /* From shm_open (for now) */
size_t length; /* length of buffer */
void *buffer;
} DRIPixmapBuffer, *DRIPixmapBufferPtr;
@ -120,7 +117,7 @@ DRIScreenInit(ScreenPtr pScreen)
if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0))
return FALSE;
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
pDRIPriv = (DRIScreenPrivPtr)calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
return FALSE;
@ -197,7 +194,7 @@ DRIReset(void)
}
Bool
DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable)
DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
@ -217,8 +214,7 @@ DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (drmAuthMagic(pDRIPriv->drmFD, magic))
return FALSE;
if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
#endif
return TRUE;
}
@ -240,7 +236,7 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
#endif
if (pDraw->type == DRAWABLE_WINDOW) {
WindowPtr pWin = (WindowPtr) pDraw;
WindowPtr pWin = (WindowPtr)pDraw;
WindowPtr pTopWin = TopLevelParent(pWin);
wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
@ -271,7 +267,8 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
/* Return NULL if an error occurs. */
static DRIDrawablePrivPtr
CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id * widPtr)
CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin,
xp_window_id *widPtr)
{
DRIDrawablePrivPtr pDRIDrawablePriv;
xp_window_id wid = 0;
@ -289,7 +286,7 @@ CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id * widPtr)
return NULL;
}
pDRIDrawablePriv->pDraw = (DrawablePtr) pWin;
pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
pDRIDrawablePriv->pScreen = pScreen;
pDRIDrawablePriv->refCount = 0;
pDRIDrawablePriv->drawableIndex = -1;
@ -323,7 +320,8 @@ CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id * widPtr)
}
/* save private off of preallocated index */
dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, pDRIDrawablePriv);
dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
pDRIDrawablePriv);
}
*widPtr = wid;
@ -347,7 +345,7 @@ CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix)
return NULL;
}
pDRIDrawablePriv->pDraw = (DrawablePtr) pPix;
pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
pDRIDrawablePriv->pScreen = pScreen;
pDRIDrawablePriv->refCount = 0;
pDRIDrawablePriv->drawableIndex = -1;
@ -362,13 +360,14 @@ CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix)
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);
dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
pDRIDrawablePriv);
}
return pDRIDrawablePriv;
@ -377,8 +376,8 @@ CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix)
Bool
DRICreateSurface(ScreenPtr pScreen, Drawable id,
DrawablePtr pDrawable, xp_client_id client_id,
xp_surface_id * surface_id, unsigned int ret_key[2],
void (*notify) (void *arg, void *data), void *notify_data)
xp_surface_id *surface_id, unsigned int ret_key[2],
void (*notify)(void *arg, void *data), void *notify_data)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
xp_window_id wid = 0;
@ -386,18 +385,18 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
if (pDrawable->type == DRAWABLE_WINDOW) {
pDRIDrawablePriv = CreateSurfaceForWindow(pScreen,
(WindowPtr) pDrawable, &wid);
(WindowPtr)pDrawable, &wid);
if (NULL == pDRIDrawablePriv)
return FALSE; /*error */
return FALSE; /*error*/
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
else if (pDrawable->type == DRAWABLE_PIXMAP) {
pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
(PixmapPtr) pDrawable);
(PixmapPtr)pDrawable);
if (NULL == pDRIDrawablePriv)
return FALSE; /*error */
return FALSE; /*error*/
}
#endif
else {
@ -413,25 +412,26 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
/* 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
* 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);
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;
WindowPtr pWin = (WindowPtr)pDrawable;
dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
}
else if (pDrawable->type == DRAWABLE_PIXMAP) {
PixmapPtr pPix = (PixmapPtr) pDrawable;
PixmapPtr pPix = (PixmapPtr)pDrawable;
dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
}
@ -449,11 +449,11 @@ DRICreateSurface(ScreenPtr pScreen, Drawable 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);
x_cvt_uint_to_vptr(
pDRIDrawablePriv->sid), pDRIDrawablePriv);
/* track this in case this window is destroyed */
AddResource(id, DRIDrawablePrivResType, (pointer) pDrawable);
AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
/* Initialize shape */
DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
@ -478,15 +478,15 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
Bool
DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
void (*notify) (void *, void *), void *notify_data)
void (*notify)(void *, void *), void *notify_data)
{
DRIDrawablePrivPtr pDRIDrawablePriv;
if (pDrawable->type == DRAWABLE_WINDOW) {
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr) pDrawable);
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
}
else if (pDrawable->type == DRAWABLE_PIXMAP) {
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr) pDrawable);
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable);
}
else {
return FALSE;
@ -498,13 +498,14 @@ DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
*/
if (notify != NULL) {
pDRIDrawablePriv->notifiers =
x_hook_remove(pDRIDrawablePriv->notifiers, notify, notify_data);
pDRIDrawablePriv->notifiers = x_hook_remove(
pDRIDrawablePriv->notifiers,
notify, notify_data);
}
--pDRIDrawablePriv->refCount;
/*
/*
* Check if the drawable privates still have a reference to the
* surface.
*/
@ -512,7 +513,7 @@ DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
if (pDRIDrawablePriv->refCount <= 0) {
/*
* This calls back to DRIDrawablePrivDelete which
* frees the private area and dispatches events, if needed.
* frees the private area and dispatches events, if needed.
*/
FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
}
@ -521,30 +522,30 @@ DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
return TRUE;
}
/*
/*
* The assumption is that this is called when the refCount of a surface
* drops to <= 0, or the window/pixmap is destroyed.
* drops to <= 0, or the window/pixmap is destroyed.
*/
Bool
DRIDrawablePrivDelete(pointer pResource, XID id)
{
DrawablePtr pDrawable = (DrawablePtr) pResource;
DrawablePtr pDrawable = (DrawablePtr)pResource;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
WindowPtr pWin = NULL;
PixmapPtr pPix = NULL;
if (pDrawable->type == DRAWABLE_WINDOW) {
pWin = (WindowPtr) pDrawable;
pWin = (WindowPtr)pDrawable;
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
}
else if (pDrawable->type == DRAWABLE_PIXMAP) {
pPix = (PixmapPtr) pDrawable;
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.
@ -558,7 +559,8 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
}
if (pDRIDrawablePriv->sid != 0) {
DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed);
DRISurfaceNotify(pDRIDrawablePriv->sid,
AppleDRISurfaceNotifyDestroyed);
}
if (pDRIDrawablePriv->notifiers != NULL)
@ -591,7 +593,7 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
(*pScreen->WindowExposures) (pWin, prgn, bsreg);
(*pScreen->WindowExposures)(pWin, prgn, bsreg);
pScreen->WindowExposures = DRIWindowExposures;
}
@ -614,7 +616,7 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
/* call lower layers */
(*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
(*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
/* rewrap */
pScreen->CopyWindow = DRICopyWindow;
@ -631,7 +633,7 @@ DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
/* call lower layers */
returnValue = (*pScreen->ValidateTree) (pParent, pChild, kind);
returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
/* rewrap */
pScreen->ValidateTree = DRIValidateTree;
@ -658,7 +660,7 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
/* call lower layers */
(*pScreen->PostValidateTree) (pParent, pChild, kind);
(*pScreen->PostValidateTree)(pParent, pChild, kind);
/* rewrap */
pScreen->PostValidateTree = DRIPostValidateTree;
@ -679,7 +681,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
if (pDRIPriv->wrap.ClipNotify) {
pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
(*pScreen->ClipNotify) (pWin, dx, dy);
(*pScreen->ClipNotify)(pWin, dx, dy);
pScreen->ClipNotify = DRIClipNotify;
}
@ -696,14 +698,16 @@ DRIGetWrappedFuncs(ScreenPtr pScreen)
}
void
DRIQueryVersion(int *majorVersion, int *minorVersion, int *patchVersion)
DRIQueryVersion(int *majorVersion,
int *minorVersion,
int *patchVersion)
{
*majorVersion = APPLE_DRI_MAJOR_VERSION;
*minorVersion = APPLE_DRI_MINOR_VERSION;
*patchVersion = APPLE_DRI_PATCH_VERSION;
}
/*
/*
* Note: this also cleans up the hash table in addition to notifying clients.
* The sid/surface-id should not be used after this, because it will be
* invalid.
@ -753,7 +757,8 @@ DRISurfaceNotify(xp_surface_id id, int kind)
*/
Bool
DRICreatePixmap(ScreenPtr pScreen, Drawable id,
DrawablePtr pDrawable, char *path, size_t pathmax)
DrawablePtr pDrawable, char *path,
size_t pathmax)
{
DRIPixmapBufferPtr shared;
PixmapPtr pPix;
@ -761,7 +766,7 @@ DRICreatePixmap(ScreenPtr pScreen, Drawable id,
if (pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
pPix = (PixmapPtr) pDrawable;
pPix = (PixmapPtr)pDrawable;
shared = malloc(sizeof(*shared));
if (NULL == shared) {
@ -782,7 +787,8 @@ DRICreatePixmap(ScreenPtr pScreen, Drawable id,
shared->height = pDrawable->height;
if (-1 == snprintf(shared->shmPath, sizeof(shared->shmPath),
"%d_0x%lx", getpid(), (unsigned long) id)) {
"%d_0x%lx", getpid(),
(unsigned long)id)) {
FatalError("buffer overflow in %s\n", __func__);
}
@ -821,7 +827,7 @@ DRICreatePixmap(ScreenPtr pScreen, Drawable id,
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
AddResource(id, DRIDrawablePrivResType, (pointer) pDrawable);
AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
return TRUE;
}
@ -836,7 +842,7 @@ DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
if (pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
pPix = (PixmapPtr) pDrawable;
pPix = (PixmapPtr)pDrawable;
shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
@ -864,7 +870,7 @@ DRIFreePixmapImp(DrawablePtr pDrawable)
if (pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
pPix = (PixmapPtr) pDrawable;
pPix = (PixmapPtr)pDrawable;
shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
@ -876,7 +882,7 @@ DRIFreePixmapImp(DrawablePtr pDrawable)
shm_unlink(shared->shmPath);
free(shared);
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer) NULL);
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer)NULL);
return TRUE;
}

View File

@ -1,35 +1,35 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright (c) 2002, 2009 Apple Computer, Inc.
All Rights Reserved.
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright (c) 2002-2012 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:
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 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.
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.
**************************************************************************/
/*
* Authors:
* Jens Owen <jens@precisioninsight.com>
*
* Jeremy Huddleston <jeremyhu@apple.com>
*/
/* Prototypes for AppleDRI functions */
@ -43,7 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "appledri.h"
#include <Xplugin.h>
typedef void (*ClipNotifyPtr) (WindowPtr, int, int);
typedef void (*ClipNotifyPtr)(WindowPtr, int, int);
/*
* These functions can be wrapped by the DRI. Each of these have
@ -63,19 +63,26 @@ typedef struct {
int kind;
} DRISurfaceNotifyArg;
extern Bool DRIScreenInit(ScreenPtr pScreen);
extern Bool
DRIScreenInit(ScreenPtr pScreen);
extern Bool DRIFinishScreenInit(ScreenPtr pScreen);
extern Bool
DRIFinishScreenInit(ScreenPtr pScreen);
extern void DRICloseScreen(ScreenPtr pScreen);
extern void
DRICloseScreen(ScreenPtr pScreen);
extern Bool DRIExtensionInit(void);
extern Bool
DRIExtensionInit(void);
extern void DRIReset(void);
extern void
DRIReset(void);
extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable);
extern Bool
DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable);
extern Bool DRIAuthConnection(ScreenPtr pScreen, unsigned int magic);
extern Bool
DRIAuthConnection(ScreenPtr pScreen, unsigned int magic);
extern Bool DRICreateSurface(ScreenPtr pScreen,
Drawable id,
@ -83,42 +90,52 @@ extern Bool DRICreateSurface(ScreenPtr pScreen,
xp_client_id client_id,
xp_surface_id * surface_id,
unsigned int key[2],
void (*notify) (void *arg, void *data),
void (*notify)(void *arg, void *data),
void *notify_data);
extern Bool DRIDestroySurface(ScreenPtr pScreen,
Drawable id,
DrawablePtr pDrawable,
void (*notify) (void *arg, void *data),
void *notify_data);
extern Bool
DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
void (*notify)(void *arg,
void *data), void *notify_data);
extern Bool DRIDrawablePrivDelete(pointer pResource, XID id);
extern Bool
DRIDrawablePrivDelete(pointer pResource, XID id);
extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
extern DRIWrappedFuncsRec *
DRIGetWrappedFuncs(ScreenPtr pScreen);
extern void DRICopyWindow(WindowPtr pWin,
DDXPointRec ptOldOrg, RegionPtr prgnSrc);
extern void
DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
extern int DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind);
extern int
DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind);
extern void DRIPostValidateTree(WindowPtr pParent,
WindowPtr pChild, VTKind kind);
extern void
DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind);
extern void DRIClipNotify(WindowPtr pWin, int dx, int dy);
extern void
DRIClipNotify(WindowPtr pWin, int dx, int dy);
extern void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg);
extern void
DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg);
extern void DRISurfaceNotify(xp_surface_id id, int kind);
extern void
DRISurfaceNotify(xp_surface_id id, int kind);
extern void DRIQueryVersion(int *majorVersion,
int *minorVersion, int *patchVersion);
extern void
DRIQueryVersion(int *majorVersion, int *minorVersion, int *patchVersion);
extern Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
DrawablePtr pDrawable, char *path, size_t pathmax);
extern Bool
DRICreatePixmap(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
char *path,
size_t pathmax);
extern Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
int *pitch, int *bpp, void **ptr);
extern Bool
DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height, int *pitch,
int *bpp,
void **ptr);
extern void DRIDestroyPixmap(DrawablePtr pDrawable);
extern void
DRIDestroyPixmap(DrawablePtr pDrawable);
#endif

View File

@ -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.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@ -55,23 +60,21 @@ typedef struct {
} DRISavedDrawableState;
static DevPrivateKeyRec driGCKeyRec;
#define driGCKey (&driGCKeyRec)
static DevPrivateKeyRec driWrapScreenKeyRec;
#define driWrapScreenKey (&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; \
}
#define unwrap(priv, real, member) { \
real->member = priv->member; \
}
static DRIGCRec *
DRIGetGCPriv(GCPtr pGC)
@ -94,7 +97,8 @@ DRIWrapGC(GCPtr pGC)
}
static void
DRISurfaceSetDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
DRISurfaceSetDrawable(DrawablePtr pDraw,
DRISavedDrawableState *saved)
{
saved->didSave = FALSE;
@ -102,8 +106,9 @@ DRISurfaceSetDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
int pitch, width, height, bpp;
void *buffer;
if (DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp, &buffer)) {
PixmapPtr pPix = (PixmapPtr) pDraw;
if (DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp,
&buffer)) {
PixmapPtr pPix = (PixmapPtr)pDraw;
saved->devKind = pPix->devKind;
saved->devPrivate.ptr = pPix->devPrivate.ptr;
@ -116,9 +121,10 @@ DRISurfaceSetDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
}
static void
DRISurfaceRestoreDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
DRISurfaceRestoreDrawable(DrawablePtr pDraw,
DRISavedDrawableState *saved)
{
PixmapPtr pPix = (PixmapPtr) pDraw;
PixmapPtr pPix = (PixmapPtr)pDraw;
if (!saved->didSave)
return;
@ -129,7 +135,8 @@ DRISurfaceRestoreDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
static void
DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
DDXPointPtr pptInit, int *pwidthInit, int sorted)
DDXPointPtr pptInit, int *pwidthInit,
int sorted)
{
DRISavedDrawableState saved;
@ -146,7 +153,8 @@ DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
static void
DRISetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
DDXPointPtr pptInit, int *pwidthInit, int nspans, int sorted)
DDXPointPtr pptInit, int *pwidthInit,
int nspans, int sorted)
{
DRISavedDrawableState saved;
@ -181,7 +189,8 @@ DRIPutImage(DrawablePtr dst, GCPtr pGC,
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;
@ -204,7 +213,8 @@ DRICopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
static RegionPtr
DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst,
GCPtr pGC, int srcx, int srcy,
int w, int h, int dstx, int dsty, unsigned long plane)
int w, int h, int dstx, int dsty,
unsigned long plane)
{
RegionPtr pReg;
DRISavedDrawableState pSrcSaved, dstSaved;
@ -226,7 +236,8 @@ DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst,
}
static void
DRIPolyPoint(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
DRIPolyPoint(DrawablePtr dst, GCPtr pGC,
int mode, int npt, DDXPointPtr pptInit)
{
DRISavedDrawableState saved;
@ -242,7 +253,8 @@ DRIPolyPoint(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
}
static void
DRIPolylines(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
DRIPolylines(DrawablePtr dst, GCPtr pGC,
int mode, int npt, DDXPointPtr pptInit)
{
DRISavedDrawableState saved;
@ -258,7 +270,8 @@ DRIPolylines(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
}
static void
DRIPolySegment(DrawablePtr dst, GCPtr pGC, int nseg, xSegment * pSeg)
DRIPolySegment(DrawablePtr dst, GCPtr pGC,
int nseg, xSegment *pSeg)
{
DRISavedDrawableState saved;
@ -274,7 +287,8 @@ DRIPolySegment(DrawablePtr dst, GCPtr pGC, int nseg, xSegment * pSeg)
}
static void
DRIPolyRectangle(DrawablePtr dst, GCPtr pGC, int nRects, xRectangle *pRects)
DRIPolyRectangle(DrawablePtr dst, GCPtr pGC,
int nRects, xRectangle *pRects)
{
DRISavedDrawableState saved;
@ -288,9 +302,8 @@ DRIPolyRectangle(DrawablePtr dst, GCPtr pGC, int nRects, xRectangle *pRects)
DRISurfaceRestoreDrawable(dst, &saved);
}
static void
DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc * parcs)
DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
{
DRISavedDrawableState saved;
@ -307,7 +320,8 @@ DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc * parcs)
static void
DRIFillPolygon(DrawablePtr dst, GCPtr pGC,
int shape, int mode, int count, DDXPointPtr pptInit)
int shape, int mode, int count,
DDXPointPtr pptInit)
{
DRISavedDrawableState saved;
@ -340,7 +354,8 @@ DRIPolyFillRect(DrawablePtr dst, GCPtr pGC,
}
static void
DRIPolyFillArc(DrawablePtr dst, GCPtr pGC, int narcsInit, xArc * parcsInit)
DRIPolyFillArc(DrawablePtr dst, GCPtr pGC,
int narcsInit, xArc *parcsInit)
{
DRISavedDrawableState saved;
@ -356,7 +371,8 @@ DRIPolyFillArc(DrawablePtr dst, GCPtr pGC, int narcsInit, xArc * parcsInit)
}
static int
DRIPolyText8(DrawablePtr dst, GCPtr pGC, int x, int y, int count, char *chars)
DRIPolyText8(DrawablePtr dst, GCPtr pGC,
int x, int y, int count, char *chars)
{
int ret;
DRISavedDrawableState saved;
@ -395,7 +411,8 @@ DRIPolyText16(DrawablePtr dst, GCPtr pGC,
}
static void
DRIImageText8(DrawablePtr dst, GCPtr pGC, int x, int y, int count, char *chars)
DRIImageText8(DrawablePtr dst, GCPtr pGC,
int x, int y, int count, char *chars)
{
DRISavedDrawableState saved;
@ -430,7 +447,7 @@ DRIImageText16(DrawablePtr dst, GCPtr pGC,
static void
DRIImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
int x, int y, unsigned int nglyphInit,
CharInfoPtr * ppciInit, pointer unused)
CharInfoPtr *ppciInit, pointer unused)
{
DRISavedDrawableState saved;
@ -448,7 +465,7 @@ DRIImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
static void
DRIPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
int x, int y, unsigned int nglyph,
CharInfoPtr * ppci, pointer pglyphBase)
CharInfoPtr *ppci, pointer pglyphBase)
{
DRISavedDrawableState saved;
@ -539,12 +556,12 @@ DRIWrapInit(ScreenPtr pScreen)
if (!dixRegisterPrivateKey(&driGCKeyRec, PRIVATE_GC, sizeof(DRIGCRec)))
return FALSE;
if (!dixRegisterPrivateKey
(&driWrapScreenKeyRec, PRIVATE_SCREEN, sizeof(DRIWrapScreenRec)))
if (!dixRegisterPrivateKey(&driWrapScreenKeyRec, PRIVATE_SCREEN,
sizeof(DRIWrapScreenRec)))
return FALSE;
pScreenPriv =
dixGetPrivateAddr(&pScreen->devPrivates, &driWrapScreenKeyRec);
pScreenPriv = dixGetPrivateAddr(&pScreen->devPrivates,
&driWrapScreenKeyRec);
pScreenPriv->CreateGC = pScreen->CreateGC;
pScreen->CreateGC = DRICreateGC;

View File

@ -1,31 +1,36 @@
/*
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.
*/
#ifndef DRIWRAP_H
#include "scrnintstr.h"
Bool DRIWrapInit(ScreenPtr pScreen);
Bool
DRIWrapInit(ScreenPtr pScreen);
#endif /*DRIWRAP_H */
#endif /*DRIWRAP_H*/

View File

@ -1,35 +1,35 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright (c) 2002 Apple Computer, Inc.
All Rights Reserved.
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright (c) 2002-2012 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:
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 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.
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.
**************************************************************************/
/*
* Authors:
* Jens Owen <jens@precisioninsight.com>
*
* Jeremy Huddleston <jeremyhu@apple.com>
*/
#ifndef DRI_STRUCT_H
@ -41,10 +41,14 @@ 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 {
xp_surface_id sid;
@ -53,15 +57,22 @@ typedef struct _DRIDrawablePrivRec {
ScreenPtr pScreen;
int refCount;
unsigned int key[2];
x_list *notifiers; /* list of (FUN . DATA) */
x_list *notifiers; /* list of (FUN . DATA) */
} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey))
#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
dixLookupPrivate(&(pScreen) \
-> \
devPrivates, \
DRIScreenPrivKey))
#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
DRIScreenPrivKey))
dixLookupPrivate(&screenInfo \
.screens[ \
screenIndex \
]-> \
devPrivates, \
DRIScreenPrivKey))
typedef struct _DRIScreenPrivRec {
Bool directRenderingSupport;
@ -70,4 +81,4 @@ typedef struct _DRIScreenPrivRec {
DrawablePtr DRIDrawables[DRI_MAX_DRAWABLES];
} DRIScreenPrivRec, *DRIScreenPrivPtr;
#endif /* DRI_STRUCT_H */
#endif /* DRI_STRUCT_H */

View File

@ -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>
@ -47,59 +48,61 @@ struct x_hash_table_struct {
x_destroy_fun *destroy_value;
};
#define ITEM_NEW(k, v) X_PFX (list_prepend) ((x_list *) (k), v)
#define ITEM_FREE(i) X_PFX (list_free_1) (i)
#define ITEM_KEY(i) ((void *) (i)->next)
#define ITEM_VALUE(i) ((i)->data)
#define ITEM_NEW(k, v) X_PFX(list_prepend) ((x_list *)(k), v)
#define ITEM_FREE(i) X_PFX(list_free_1) (i)
#define ITEM_KEY(i) ((void *)(i)->next)
#define ITEM_VALUE(i) ((i)->data)
#define SPLIT_THRESHOLD_FACTOR 2
/* http://planetmath.org/?op=getobj&from=objects&name=GoodHashTablePrimes */
static const unsigned int bucket_sizes[] = {
29, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157,
98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917,
29, 53, 97, 193, 389, 769, 1543,
3079, 6151, 12289, 24593, 49157,
98317, 196613, 393241, 786433, 1572869, 3145739, 6291469,
12582917,
25165843, 50331653, 100663319, 201326611, 402653189, 805306457,
1610612741
};
#define N_BUCKET_SIZES (sizeof (bucket_sizes) / sizeof (bucket_sizes[0]))
#define N_BUCKET_SIZES (sizeof(bucket_sizes) / sizeof(bucket_sizes[0]))
static inline unsigned int
hash_table_total_buckets(x_hash_table * h)
hash_table_total_buckets(x_hash_table *h)
{
return bucket_sizes[h->bucket_index];
}
static inline void
hash_table_destroy_item(x_hash_table * h, void *k, void *v)
hash_table_destroy_item(x_hash_table *h, void *k, void *v)
{
if (h->destroy_key != 0)
(*h->destroy_key) (k);
(*h->destroy_key)(k);
if (h->destroy_value != 0)
(*h->destroy_value) (v);
(*h->destroy_value)(v);
}
static inline size_t
hash_table_hash_key(x_hash_table * h, void *k)
hash_table_hash_key(x_hash_table *h, void *k)
{
if (h->hash_key != 0)
return (*h->hash_key) (k);
return (*h->hash_key)(k);
else
return (size_t) k;
return (size_t)k;
}
static inline int
hash_table_compare_keys(x_hash_table * h, void *k1, void *k2)
hash_table_compare_keys(x_hash_table *h, void *k1, void *k2)
{
if (h->compare_keys == 0)
return k1 == k2;
else
return (*h->compare_keys) (k1, k2) == 0;
return (*h->compare_keys)(k1, k2) == 0;
}
static void
hash_table_split(x_hash_table * h)
hash_table_split(x_hash_table *h)
{
x_list **new, **old;
x_list *node, *item, *next;
@ -139,10 +142,11 @@ hash_table_split(x_hash_table * h)
free(old);
}
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_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_hash_table *h;
h = calloc(1, sizeof(x_hash_table));
@ -166,7 +170,7 @@ X_EXTERN x_hash_table *X_PFX(hash_table_new) (x_hash_fun * hash,
}
X_EXTERN void
X_PFX(hash_table_free) (x_hash_table * h) {
X_PFX(hash_table_free) (x_hash_table * h) {
int n, i;
x_list *node, *item;
@ -188,14 +192,14 @@ X_EXTERN void
}
X_EXTERN unsigned int
X_PFX(hash_table_size) (x_hash_table * h) {
X_PFX(hash_table_size) (x_hash_table * h) {
assert(h != NULL);
return h->total_keys;
}
static void
hash_table_modify(x_hash_table * h, void *k, void *v, int replace)
hash_table_modify(x_hash_table *h, void *k, void *v, int replace)
{
size_t hash_value;
x_list *node, *item;
@ -210,7 +214,8 @@ hash_table_modify(x_hash_table * h, void *k, void *v, int replace)
if (hash_table_compare_keys(h, ITEM_KEY(item), k)) {
if (replace) {
hash_table_destroy_item(h, ITEM_KEY(item), ITEM_VALUE(item));
hash_table_destroy_item(h, ITEM_KEY(item),
ITEM_VALUE(item));
item->next = k;
ITEM_VALUE(item) = v;
}
@ -236,17 +241,17 @@ hash_table_modify(x_hash_table * h, void *k, void *v, int replace)
}
X_EXTERN void
X_PFX(hash_table_insert) (x_hash_table * h, void *k, void *v) {
X_PFX(hash_table_insert) (x_hash_table * h, void *k, void *v) {
hash_table_modify(h, k, v, 0);
}
X_EXTERN void
X_PFX(hash_table_replace) (x_hash_table * h, void *k, void *v) {
X_PFX(hash_table_replace) (x_hash_table * h, void *k, void *v) {
hash_table_modify(h, k, v, 1);
}
X_EXTERN void
X_PFX(hash_table_remove) (x_hash_table * h, void *k) {
X_PFX(hash_table_remove) (x_hash_table * h, void *k) {
size_t hash_value;
x_list **ptr, *item;
@ -270,8 +275,8 @@ X_EXTERN void
}
}
X_EXTERN void *X_PFX(hash_table_lookup) (x_hash_table * h, void *k,
void **k_ret) {
X_EXTERN void *
X_PFX(hash_table_lookup) (x_hash_table * h, void *k, void **k_ret) {
size_t hash_value;
x_list *node, *item;
@ -298,7 +303,6 @@ X_EXTERN void *X_PFX(hash_table_lookup) (x_hash_table * h, void *k,
}
X_EXTERN void
X_PFX(hash_table_foreach) (x_hash_table * h,
x_hash_foreach_fun * fun, void *data) {
int i, n;
@ -311,7 +315,7 @@ X_PFX(hash_table_foreach) (x_hash_table * h,
for (i = 0; i < n; i++) {
for (node = h->buckets[i]; node != 0; node = node->next) {
item = node->data;
(*fun) (ITEM_KEY(item), ITEM_VALUE(item), data);
(*fun)(ITEM_KEY(item), ITEM_VALUE(item), data);
}
}
}

View File

@ -1,31 +1,32 @@
/* x-hash.h -- basic hash table class
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 X_HASH_H
#define X_HASH_H 1
@ -35,10 +36,10 @@
typedef struct x_hash_table_struct x_hash_table;
typedef int (x_compare_fun) (const void *a, const void *b);
typedef unsigned int (x_hash_fun) (const void *k);
typedef void (x_destroy_fun) (void *x);
typedef void (x_hash_foreach_fun) (void *k, void *v, void *data);
typedef int (x_compare_fun)(const void *a, const void *b);
typedef unsigned int (x_hash_fun)(const void *k);
typedef void (x_destroy_fun)(void *x);
typedef void (x_hash_foreach_fun)(void *k, void *v, void *data);
/* for X_PFX and X_EXTERN */
#include "x-list.h"
@ -57,25 +58,27 @@ 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);
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 */
/* Forward declarations */
static __inline__ void *X_PFX(cvt_uint_to_vptr) (unsigned int val)
__attribute__ ((always_inline));
static __inline__ void *
X_PFX(cvt_uint_to_vptr) (unsigned int val) __attribute__((always_inline));
static __inline__ unsigned int
X_PFX(cvt_vptr_to_uint) (void *val) __attribute__ ((always_inline));
X_PFX(cvt_vptr_to_uint) (void * val) __attribute__((always_inline));
/* Implementations */
static __inline__ void *X_PFX(cvt_uint_to_vptr) (unsigned int val) {
return (void *) ((unsigned long) (val));
static __inline__ void *
X_PFX(cvt_uint_to_vptr) (unsigned int val) {
return (void *)((unsigned long)(val));
}
static __inline__ unsigned int
X_PFX(cvt_vptr_to_uint) (void *val) {
size_t sv = (size_t) val;
unsigned int uv = (unsigned int) sv;
X_PFX(cvt_vptr_to_uint) (void * val) {
size_t sv = (size_t)val;
unsigned int uv = (unsigned int)sv;
/* If this assert fails, chances are val actually is a pointer,
or there's been memory corruption */
@ -84,4 +87,4 @@ static __inline__ unsigned int
return uv;
}
#endif /* X_HASH_H */
#endif /* X_HASH_H */

View File

@ -1,31 +1,32 @@
/* x-hook.c
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. */
*
* 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>
@ -36,18 +37,18 @@
#include <assert.h>
#include "os.h"
#define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d))
#define CELL_FREE(c) X_PFX (list_free_1) (c)
#define CELL_FUN(c) ((x_hook_function *) ((c)->next))
#define CELL_DATA(c) ((c)->data)
#define CELL_NEW(f, d) X_PFX(list_prepend) ((x_list *)(f), (d))
#define CELL_FREE(c) X_PFX(list_free_1) (c)
#define CELL_FUN(c) ((x_hook_function *)((c)->next))
#define CELL_DATA(c) ((c)->data)
X_EXTERN x_list *X_PFX(hook_add) (x_list * lst, x_hook_function * fun,
void *data) {
X_EXTERN x_list *
X_PFX(hook_add) (x_list * lst, x_hook_function * fun, void *data) {
return X_PFX(list_prepend) (lst, CELL_NEW(fun, data));
}
X_EXTERN x_list *X_PFX(hook_remove) (x_list * lst, x_hook_function * fun,
void *data) {
X_EXTERN x_list *
X_PFX(hook_remove) (x_list * lst, x_hook_function * fun, void *data) {
x_list *node, *cell;
x_list *to_delete = NULL;
@ -68,7 +69,7 @@ X_EXTERN x_list *X_PFX(hook_remove) (x_list * lst, x_hook_function * fun,
}
X_EXTERN void
X_PFX(hook_run) (x_list * lst, void *arg) {
X_PFX(hook_run) (x_list * lst, void *arg) {
x_list *node, *cell;
x_hook_function **fun;
void **data;
@ -92,7 +93,7 @@ X_EXTERN void
}
for (i = 0; i < length; i++) {
(*fun[i]) (arg, data[i]);
(*fun[i])(arg, data[i]);
}
free(fun);
@ -100,7 +101,7 @@ X_EXTERN void
}
X_EXTERN void
X_PFX(hook_free) (x_list * lst) {
X_PFX(hook_free) (x_list * lst) {
x_list *node;
for (node = lst; node != NULL; node = node->next) {

View File

@ -1,38 +1,39 @@
/* x-hook.h -- lists of function,data pairs to call.
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. */
*
* 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.
*/
#ifndef X_HOOK_H
#define X_HOOK_H 1
#include "x-list.h"
typedef void x_hook_function(void *arg, void *data);
typedef void x_hook_function (void *arg, void *data);
X_EXTERN x_list *X_PFX(hook_add) (x_list * lst, x_hook_function * fun,
void *data);
@ -41,4 +42,4 @@ X_EXTERN x_list *X_PFX(hook_remove) (x_list * lst, x_hook_function * fun,
X_EXTERN void X_PFX(hook_run) (x_list * lst, void *arg);
X_EXTERN void X_PFX(hook_free) (x_list * lst);
#endif /* X_HOOK_H */
#endif /* X_HOOK_H */

View File

@ -1,31 +1,32 @@
/* x-list.c
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>
@ -50,14 +51,14 @@ static x_list *freelist;
static pthread_mutex_t freelist_lock = PTHREAD_MUTEX_INITIALIZER;
static inline void
list_free_1(x_list * node)
list_free_1(x_list *node)
{
node->next = freelist;
freelist = node;
}
X_EXTERN void
X_PFX(list_free_1) (x_list * node) {
X_PFX(list_free_1) (x_list * node) {
assert(node != NULL);
pthread_mutex_lock(&freelist_lock);
@ -68,7 +69,7 @@ X_EXTERN void
}
X_EXTERN void
X_PFX(list_free) (x_list * lst) {
X_PFX(list_free) (x_list * lst) {
x_list *next;
pthread_mutex_lock(&freelist_lock);
@ -81,7 +82,8 @@ X_EXTERN void
pthread_mutex_unlock(&freelist_lock);
}
X_EXTERN x_list *X_PFX(list_prepend) (x_list * lst, void *data) {
X_EXTERN x_list *
X_PFX(list_prepend) (x_list * lst, void *data) {
x_list *node;
pthread_mutex_lock(&freelist_lock);
@ -111,7 +113,8 @@ X_EXTERN x_list *X_PFX(list_prepend) (x_list * lst, void *data) {
return node;
}
X_EXTERN x_list *X_PFX(list_append) (x_list * lst, void *data) {
X_EXTERN x_list *
X_PFX(list_append) (x_list * lst, void *data) {
x_list *head = lst;
if (lst == NULL)
@ -125,10 +128,12 @@ X_EXTERN x_list *X_PFX(list_append) (x_list * lst, void *data) {
return head;
}
X_EXTERN x_list *X_PFX(list_reverse) (x_list * lst) {
X_EXTERN x_list *
X_PFX(list_reverse) (x_list * lst) {
x_list *head = NULL, *next;
while (lst != NULL) {
while (lst != NULL)
{
next = lst->next;
lst->next = head;
head = lst;
@ -138,7 +143,8 @@ X_EXTERN x_list *X_PFX(list_reverse) (x_list * lst) {
return head;
}
X_EXTERN x_list *X_PFX(list_find) (x_list * lst, void *data) {
X_EXTERN x_list *
X_PFX(list_find) (x_list * lst, void *data) {
for (; lst != NULL; lst = lst->next) {
if (lst->data == data)
return lst;
@ -147,19 +153,20 @@ X_EXTERN x_list *X_PFX(list_find) (x_list * lst, void *data) {
return NULL;
}
X_EXTERN x_list *X_PFX(list_nth) (x_list * lst, int n) {
X_EXTERN x_list *
X_PFX(list_nth) (x_list * lst, int n) {
while (n-- > 0 && lst != NULL)
lst = lst->next;
return lst;
}
X_EXTERN x_list *X_PFX(list_pop) (x_list * lst, void **data_ret) {
X_EXTERN x_list *
X_PFX(list_pop) (x_list * lst, void **data_ret) {
void *data = NULL;
if (lst != NULL) {
x_list *tem = lst;
data = lst->data;
lst = lst->next;
X_PFX(list_free_1) (tem);
@ -171,22 +178,22 @@ X_EXTERN x_list *X_PFX(list_pop) (x_list * lst, void **data_ret) {
return lst;
}
X_EXTERN x_list *X_PFX(list_filter) (x_list * lst,
int (*pred) (void *item, void *data),
void *data) {
X_EXTERN x_list *
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))
if ((*pred)(node->data, data))
ret = X_PFX(list_prepend) (ret, node->data);
}
return X_PFX(list_reverse) (ret);
}
X_EXTERN x_list *X_PFX(list_map) (x_list * lst,
void *(*fun) (void *item, void *data),
void *data) {
X_EXTERN x_list *
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) {
@ -196,7 +203,8 @@ X_EXTERN x_list *X_PFX(list_map) (x_list * lst,
return X_PFX(list_reverse) (ret);
}
X_EXTERN x_list *X_PFX(list_copy) (x_list * lst) {
X_EXTERN x_list *
X_PFX(list_copy) (x_list * lst) {
x_list *copy = NULL;
for (; lst != NULL; lst = lst->next) {
@ -206,7 +214,8 @@ X_EXTERN x_list *X_PFX(list_copy) (x_list * lst) {
return X_PFX(list_reverse) (copy);
}
X_EXTERN x_list *X_PFX(list_remove) (x_list * lst, void *data) {
X_EXTERN x_list *
X_PFX(list_remove) (x_list * lst, void *data) {
x_list **ptr, *node;
for (ptr = &lst; *ptr != NULL;) {
@ -224,7 +233,7 @@ X_EXTERN x_list *X_PFX(list_remove) (x_list * lst, void *data) {
}
X_EXTERN unsigned int
X_PFX(list_length) (x_list * lst) {
X_PFX(list_length) (x_list * lst) {
unsigned int n;
n = 0;
@ -235,17 +244,17 @@ X_EXTERN unsigned int
}
X_EXTERN void
X_PFX(list_foreach) (x_list * lst,
void (*fun) (void *data, void *user_data),
void (*fun)(void *data, void *user_data),
void *user_data) {
for (; lst != NULL; lst = lst->next) {
(*fun) (lst->data, user_data);
(*fun)(lst->data, user_data);
}
}
static x_list *
list_sort_1(x_list * lst, int length, int (*less) (const void *, const void *))
list_sort_1(x_list *lst, int length,
int (*less)(const void *, const void *))
{
x_list *mid, *ptr;
x_list *out_head, *out;
@ -274,13 +283,14 @@ list_sort_1(x_list * lst, int length, int (*less) (const void *, const void *))
assert(lst != NULL && mid != NULL);
if ((*less) (mid->data, lst->data))
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))
while (lst != NULL && mid != NULL)
{
if ((*less)(mid->data, lst->data))
out = out->next = mid, mid = mid->next;
else
out = out->next = lst, lst = lst->next;
@ -294,8 +304,8 @@ list_sort_1(x_list * lst, int length, int (*less) (const void *, const void *))
return out_head;
}
X_EXTERN x_list *X_PFX(list_sort) (x_list * lst,
int (*less) (const void *, const void *)) {
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);

View File

@ -1,31 +1,32 @@
/* x-list.h -- simple list type
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 X_LIST_H
#define X_LIST_H 1
@ -60,18 +61,18 @@ X_EXTERN x_list *X_PFX(list_reverse) (x_list * lst);
X_EXTERN x_list *X_PFX(list_find) (x_list * lst, void *data);
X_EXTERN x_list *X_PFX(list_nth) (x_list * lst, int n);
X_EXTERN x_list *X_PFX(list_filter) (x_list * src,
int (*pred) (void *item, void *data),
int (*pred)(void *item, void *data),
void *data);
X_EXTERN x_list *X_PFX(list_map) (x_list * src,
void *(*fun) (void *item, void *data),
void *(*fun)(void *item, void *data),
void *data);
X_EXTERN unsigned int X_PFX(list_length) (x_list * lst);
X_EXTERN void X_PFX(list_foreach) (x_list * lst, void (*fun)
(void *data, void *user_data),
(void *data, void *user_data),
void *user_data);
X_EXTERN x_list *X_PFX(list_sort) (x_list * lst, int (*less) (const void *,
const void *));
X_EXTERN x_list *X_PFX(list_sort) (x_list * lst,
int (*less)(const void *, const void *));
#endif /* X_LIST_H */
#endif /* X_LIST_H */

View File

@ -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"),
@ -36,21 +37,31 @@
#include "darwin.h"
#undef DEBUG_LOG
#define DEBUG_LOG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "xpr", msg, ##args)
#define DEBUG_LOG(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, "xpr", msg, ## args)
Bool QuartzModeBundleInit(void);
Bool
QuartzModeBundleInit(void);
void AppleDRIExtensionInit(void);
void xprAppleWMInit(void);
Bool xprInit(ScreenPtr pScreen);
Bool xprIsX11Window(int windowNumber);
WindowPtr xprGetXWindow(xp_window_id wid);
void
AppleDRIExtensionInit(void);
void
xprAppleWMInit(void);
Bool
xprInit(ScreenPtr pScreen);
Bool
xprIsX11Window(int windowNumber);
WindowPtr
xprGetXWindow(xp_window_id wid);
void xprHideWindows(Bool hide);
void
xprHideWindows(Bool hide);
Bool QuartzInitCursor(ScreenPtr pScreen);
void QuartzSuspendXCursor(ScreenPtr pScreen);
void QuartzResumeXCursor(ScreenPtr pScreen);
Bool
QuartzInitCursor(ScreenPtr pScreen);
void
QuartzSuspendXCursor(ScreenPtr pScreen);
void
QuartzResumeXCursor(ScreenPtr pScreen);
/* If we are rooted, we need the root window and desktop levels to be below
* the menubar (24) but above native windows. Normal window level is 0.
@ -62,9 +73,8 @@ void QuartzResumeXCursor(ScreenPtr pScreen);
static const int normal_window_levels[AppleWMNumWindowLevels + 1] = {
0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
};
static const int rooted_window_levels[AppleWMNumWindowLevels + 1] = {
20, 21, 22, 23, 19, 18,
};
#endif /* XPR_H */
#endif /* XPR_H */

View File

@ -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
@ -107,7 +107,8 @@ xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent)
RootlessStopDrawing(pWinChild, FALSE);
if (xp_configure_window(child_wid, XP_ATTACH_TRANSIENT, &wc) != Success) {
if (xp_configure_window(child_wid, XP_ATTACH_TRANSIENT,
&wc) != Success) {
return BadValue;
}
@ -119,9 +120,10 @@ 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)
const BoxRec *outer,
const BoxRec *inner,
unsigned int title_len,
const unsigned char *title_bytes)
{
xp_window_id wid;

View File

@ -57,11 +57,11 @@ typedef struct {
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
static DevPrivateKeyRec darwinCursorScreenKeyRec;
#define darwinCursorScreenKey (&darwinCursorScreenKeyRec)
#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
dixLookupPrivate(&pScreen->devPrivates, \
darwinCursorScreenKey))
static Bool
load_cursor(CursorPtr src, int screen)
@ -89,11 +89,10 @@ load_cursor(CursorPtr src, int screen)
if (src->bits->argb != NULL) {
#if BITMAP_BIT_ORDER == MSBFirst
rowbytes = src->bits->width * sizeof(CARD32);
data = (uint32_t *) src->bits->argb;
data = (uint32_t *)src->bits->argb;
#else
const uint32_t *be_data = (uint32_t *) src->bits->argb;
const uint32_t *be_data = (uint32_t *)src->bits->argb;
unsigned i;
rowbytes = src->bits->width * sizeof(CARD32);
data = malloc(rowbytes * src->bits->height);
free_data = TRUE;
@ -134,13 +133,15 @@ load_cursor(CursorPtr src, int screen)
mrow = src->bits->mask;
drow = data;
while (ycount-- > 0) {
while (ycount-- > 0)
{
xcount = bits_to_bytes(src->bits->width);
sptr = srow;
mptr = mrow;
dptr = drow;
while (xcount-- > 0) {
while (xcount-- > 0)
{
uint8_t s, m;
int i;
@ -167,7 +168,7 @@ load_cursor(CursorPtr src, int screen)
srow += BitmapBytePad(src->bits->width);
mrow += BitmapBytePad(src->bits->width);
drow = (uint32_t *) ((char *) drow + rowbytes);
drow = (uint32_t *)((char *)drow + rowbytes);
}
}
else {
@ -182,12 +183,12 @@ load_cursor(CursorPtr src, int screen)
}
/*
===========================================================================
===========================================================================
Pointer sprite functions
Pointer sprite functions
===========================================================================
*/
===========================================================================
*/
/*
* QuartzRealizeCursor
@ -219,7 +220,8 @@ QuartzUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
* Set the cursor sprite and position.
*/
static void
QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
int x,
int y)
{
QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
@ -249,16 +251,15 @@ QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
*/
static void
QuartzMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
}
{}
/*
===========================================================================
===========================================================================
Pointer screen functions
Pointer screen functions
===========================================================================
*/
===========================================================================
*/
/*
* QuartzCursorOffScreen
@ -309,12 +310,12 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = {
};
/*
===========================================================================
===========================================================================
Other screen functions
Other screen functions
===========================================================================
*/
===========================================================================
*/
/*
* QuartzCursorQueryBestSize
@ -332,7 +333,7 @@ QuartzCursorQueryBestSize(int class, unsigned short *width,
*height = 32;
}
else {
(*ScreenPriv->QueryBestSize) (class, width, height, pScreen);
(*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
}
}
@ -383,8 +384,7 @@ QuartzInitCursor(ScreenPtr pScreen)
*/
void
QuartzSuspendXCursor(ScreenPtr pScreen)
{
}
{}
/*
* QuartzResumeXCursor

View File

@ -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
@ -56,12 +56,13 @@
#include "xprEvent.h"
Bool
QuartzModeEventHandler(int screenNum, XQuartzEvent * e, DeviceIntPtr dev)
QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev)
{
switch (e->subtype) {
case kXquartzWindowState:
DEBUG_LOG("kXquartzWindowState\n");
RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]), e->data[1]);
RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]),
e->data[1]);
return TRUE;
case kXquartzWindowMoved:
@ -73,6 +74,7 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent * e, DeviceIntPtr dev)
DEBUG_LOG("kXquartzBringAllToFront\n");
RootlessOrderAllWindows(e->data[0]);
return TRUE;
default:
return FALSE;
}

View File

@ -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
@ -29,6 +29,7 @@
#ifndef __XPR_EVENT_H__
#define __XPR_EVENT_H__
Bool QuartzModeEventHandler(int screenNum, XQuartzEvent * e, DeviceIntPtr dev);
Bool
QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev);
#endif

View File

@ -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
@ -49,21 +49,21 @@
#include <pthread.h>
#endif
#define DEFINE_ATOM_HELPER(func,atom_name) \
static Atom func (void) { \
static int generation; \
static Atom atom; \
if (generation != serverGeneration) { \
generation = serverGeneration; \
atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
} \
return atom; \
}
#define DEFINE_ATOM_HELPER(func, atom_name) \
static Atom func(void) { \
static int generation; \
static Atom atom; \
if (generation != serverGeneration) { \
generation = serverGeneration; \
atom = MakeAtom(atom_name, strlen(atom_name), TRUE); \
} \
return atom; \
}
DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
/* Maps xp_window_id -> RootlessWindowRec */
static x_hash_table *window_hash;
static x_hash_table * window_hash;
/* Need to guard window_hash since xprIsX11Window can be called from any thread. */
#ifdef HAVE_LIBDISPATCH
@ -74,15 +74,16 @@ static pthread_rwlock_t window_hash_rwlock;
/* Prototypes for static functions */
static Bool
xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
int newX, int newY, RegionPtr pShape);
xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, 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,
xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY,
unsigned int newW, unsigned int newH,
unsigned int gravity);
static void
xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
@ -97,8 +98,9 @@ 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);
xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
int shift_x,
int shift_y);
static void
xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
static Bool
@ -108,12 +110,13 @@ xprHideWindow(RootlessFrameID wid);
static void
xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen);
static void
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec * dstRects,
int dx, int dy);
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
int dx,
int dy);
static inline xp_error
xprConfigureWindow(xp_window_id id, unsigned int mask,
const xp_window_changes * values)
const xp_window_changes *values)
{
return xp_configure_window(id, mask, values);
}
@ -131,17 +134,18 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
data = native_id;
dixChangeWindowProperty(serverClient, pFrame->win,
xa_native_window_id(), XA_INTEGER, 32,
PropModeReplace, 1, &data, TRUE);
xa_native_window_id(),
XA_INTEGER, 32, PropModeReplace, 1, &data,
TRUE);
}
}
static xp_error
xprColormapCallback(void *data, int first_color, int n_colors,
uint32_t * colors)
uint32_t *colors)
{
return (RootlessResolveColormap(data, first_color, n_colors, colors) ?
XP_Success : XP_BadMatch);
return (RootlessResolveColormap(data, first_color, n_colors,
colors) ? XP_Success : XP_BadMatch);
}
/*
@ -195,7 +199,7 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
wc.window_level = rooted_window_levels[pFrame->level];
mask |= XP_WINDOW_LEVEL;
err = xp_create_window(mask, &wc, (xp_window_id *) & pFrame->wid);
err = xp_create_window(mask, &wc, (xp_window_id *)&pFrame->wid);
if (err != Success) {
return FALSE;
@ -203,8 +207,8 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
#ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^ {
x_hash_table_insert(window_hash, pFrame->wid, pFrame);}
);
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
});
#else
pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
@ -226,7 +230,8 @@ xprDestroyFrame(RootlessFrameID wid)
#ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^ {
x_hash_table_remove(window_hash, wid);});
x_hash_table_remove(window_hash, wid);
});
#else
pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_remove(window_hash, wid);
@ -236,7 +241,8 @@ xprDestroyFrame(RootlessFrameID wid)
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);
(int)x_cvt_vptr_to_uint(
wid), (int)err);
}
/*
@ -283,11 +289,10 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
{
xp_window_changes wc;
unsigned int mask = XP_STACKING;
#ifdef HAVE_LIBDISPATCH
__block
#endif
RootlessWindowRec * winRec;
RootlessWindowRec * winRec;
/* Stack frame below nextWid it if it exists, or raise
frame above everything otherwise. */
@ -303,8 +308,8 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
#ifdef HAVE_LIBDISPATCH
dispatch_sync(window_hash_serial_q, ^ {
winRec = x_hash_table_lookup(window_hash, wid, NULL);}
);
winRec = x_hash_table_lookup(window_hash, wid, NULL);
});
#else
pthread_rwlock_rdlock(&window_hash_rwlock);
winRec = x_hash_table_lookup(window_hash, wid, NULL);
@ -371,12 +376,12 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
unsigned int rowbytes[2];
xp_error err;
err =
xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes,
NULL);
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);
(int)x_cvt_vptr_to_uint(
wid), (int)err);
*pixelData = data[0];
*bytesPerRow = rowbytes[0];
@ -396,7 +401,8 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
*/
if (err != Success)
ErrorF("Could not unlock window %d after drawing (%d).",
(int) x_cvt_vptr_to_uint(wid), (int) err);
(int)x_cvt_vptr_to_uint(
wid), (int)err);
}
/*
@ -412,7 +418,7 @@ xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
* Mark damaged rectangles as requiring redisplay to screen.
*/
static void
xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec * rects,
xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
int shift_x, int shift_y)
{
xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y);
@ -446,7 +452,7 @@ xprDoReorderWindow(RootlessWindowPtr pFrame)
* Used to accelerate scrolling.
*/
static void
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec * dstRects,
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
int dx, int dy)
{
xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid),
@ -487,8 +493,8 @@ xprInit(ScreenPtr pScreen)
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)));
dispatch_queue_create(BUNDLE_ID_PREFIX ".X11.xpr_window_hash",
NULL)));
#else
assert(0 == pthread_rwlock_init(&window_hash_rwlock, NULL));
#endif
@ -505,14 +511,13 @@ xprGetXWindow(xp_window_id wid)
{
#ifdef HAVE_LIBDISPATCH
RootlessWindowRec *winRec __block;
dispatch_sync(window_hash_serial_q, ^ {
winRec =
x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid),
NULL);});
winRec =
x_hash_table_lookup(window_hash,
x_cvt_uint_to_vptr(wid), NULL);
});
#else
RootlessWindowRec *winRec;
pthread_rwlock_rdlock(&window_hash_rwlock);
winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
pthread_rwlock_unlock(&window_hash_rwlock);
@ -553,7 +558,6 @@ xprHideWindows(Bool hide)
for (screen = 0; screen < screenInfo.numScreens; screen++) {
RootlessFrameID prevWid = NULL;
pRoot = screenInfo.screens[screen]->root;
for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
@ -583,13 +587,13 @@ xprHideWindows(Bool hide)
}
// XXX: identical to x_cvt_vptr_to_uint ?
#define MAKE_WINDOW_ID(x) ((xp_window_id)((size_t)(x)))
#define MAKE_WINDOW_ID(x) ((xp_window_id)((size_t)(x)))
Bool no_configure_window;
static inline int
configure_window(xp_window_id id, unsigned int mask,
const xp_window_changes * values)
const xp_window_changes *values)
{
if (!no_configure_window)
return xp_configure_window(id, mask, values);
@ -598,12 +602,11 @@ configure_window(xp_window_id id, unsigned int mask,
}
static
void
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;
@ -611,11 +614,10 @@ xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen)
}
static
void
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);

View File

@ -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
@ -81,9 +81,10 @@ eventHandler(unsigned int type, const void *arg,
const xp_window_state_event *ws_arg = 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);
DarwinSendDDXEvent(kXquartzWindowState, 2,
ws_arg->id, ws_arg->state);
}
else {
DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
@ -93,14 +94,14 @@ eventHandler(unsigned int type, const void *arg,
case XP_EVENT_WINDOW_MOVED:
DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
if (arg_size == sizeof(xp_window_id)) {
xp_window_id id = *(xp_window_id *) arg;
xp_window_id id = *(xp_window_id *)arg;
DarwinSendDDXEvent(kXquartzWindowMoved, 1, id);
}
break;
case XP_EVENT_SURFACE_DESTROYED:
DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
case XP_EVENT_SURFACE_CHANGED:
DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
if (arg_size == sizeof(xp_surface_id)) {
@ -111,18 +112,19 @@ eventHandler(unsigned int type, const void *arg,
else
kind = AppleDRISurfaceNotifyChanged;
DRISurfaceNotify(*(xp_surface_id *) arg, kind);
DRISurfaceNotify(*(xp_surface_id *)arg, kind);
}
break;
#ifdef XP_EVENT_SPACE_CHANGED
case XP_EVENT_SPACE_CHANGED:
case XP_EVENT_SPACE_CHANGED:
DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n");
if (arg_size == sizeof(uint32_t)) {
uint32_t space_id = *(uint32_t *) arg;
uint32_t space_id = *(uint32_t *)arg;
DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id);
}
break;
#endif
default:
ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type);
@ -159,18 +161,19 @@ displayScreenBounds(CGDirectDisplayID id)
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);
(int)frame.size.width, (int)frame.size.height,
(int)frame.origin.x, (int)frame.origin.y);
/* Remove menubar to help standard X11 window managers. */
if (XQuartzIsRootless && frame.origin.x == 0 && frame.origin.y == 0) {
if (XQuartzIsRootless &&
frame.origin.x == 0 && frame.origin.y == 0) {
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);
(int)frame.size.width, (int)frame.size.height,
(int)frame.origin.x, (int)frame.origin.y);
return frame;
}
@ -190,11 +193,11 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height,
// Find all the CoreGraphics displays
CGGetActiveDisplayList(0, NULL, &displayCount);
DEBUG_LOG("displayCount: %d\n", (int) displayCount);
DEBUG_LOG("displayCount: %d\n", (int)displayCount);
if (!displayCount) {
ErrorF
("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n");
ErrorF(
"CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n");
*x = *y = 0;
*width = 800;
*height = 600;
@ -219,7 +222,6 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height,
/* Get the union of all screens */
for (i = 0; i < displayCount; i++) {
CGDirectDisplayID dpy = displayList[i];
frame = displayScreenBounds(dpy);
unionRect = CGRectUnion(unionRect, frame);
}
@ -242,7 +244,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height,
frame.origin.y -= unionRect.origin.y;
DEBUG_LOG(" placed at X11 coordinate (%d,%d).\n",
(int) frame.origin.x, (int) frame.origin.y);
(int)frame.origin.x, (int)frame.origin.y);
PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
frame.size.width, frame.size.height);
@ -276,12 +278,14 @@ xprDisplayInit(void)
FatalError("Could not initialize the Xplugin library.");
xp_select_events(XP_EVENT_DISPLAY_CHANGED
| XP_EVENT_WINDOW_STATE_CHANGED | XP_EVENT_WINDOW_MOVED
| XP_EVENT_WINDOW_STATE_CHANGED
| XP_EVENT_WINDOW_MOVED
#ifdef XP_EVENT_SPACE_CHANGED
| XP_EVENT_SPACE_CHANGED
#endif
| XP_EVENT_SURFACE_CHANGED
| XP_EVENT_SURFACE_DESTROYED, eventHandler, NULL);
| XP_EVENT_SURFACE_DESTROYED,
eventHandler, NULL);
AppleDRIExtensionInit();
xprAppleWMInit();
@ -305,9 +309,8 @@ xprAddScreen(int index, ScreenPtr pScreen)
if (depth == -1) {
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
depth =
CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
CGDisplayBitsPerSample(kCGDirectMainDisplay);
depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
CGDisplayBitsPerSample(kCGDirectMainDisplay);
#else
CGDisplayModeRef modeRef;
CFStringRef encStrRef;
@ -321,19 +324,19 @@ xprAddScreen(int index, ScreenPtr pScreen)
if (!encStrRef)
goto have_depth;
if (CFStringCompare
(encStrRef, CFSTR(IO32BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
if (CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels),
kCFCompareCaseInsensitive) ==
kCFCompareEqualTo) {
depth = 24;
}
else if (CFStringCompare
(encStrRef, CFSTR(IO16BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
else if (CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels),
kCFCompareCaseInsensitive) ==
kCFCompareEqualTo) {
depth = 15;
}
else if (CFStringCompare
(encStrRef, CFSTR(IO8BitIndexedPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
else if (CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels),
kCFCompareCaseInsensitive) ==
kCFCompareEqualTo) {
depth = 8;
}
@ -342,10 +345,10 @@ xprAddScreen(int index, ScreenPtr pScreen)
}
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
have_depth:
have_depth:
#endif
switch (depth) {
case 8: // pseudo-working
case 8: // pseudo-working
dfb->visuals = PseudoColorMask;
dfb->preferredCVC = PseudoColor;
dfb->depth = 8;
@ -355,8 +358,9 @@ xprAddScreen(int index, ScreenPtr pScreen)
dfb->greenMask = 0;
dfb->blueMask = 0;
break;
case 15:
dfb->visuals = TrueColorMask; //LARGE_VISUALS;
dfb->visuals = TrueColorMask; //LARGE_VISUALS;
dfb->preferredCVC = TrueColor;
dfb->depth = 15;
dfb->bitsPerRGB = 5;
@ -365,13 +369,14 @@ xprAddScreen(int index, ScreenPtr pScreen)
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);
dfb->visuals = TrueColorMask; //LARGE_VISUALS;
ErrorF(
"Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n",
depth, darwinDesiredDepth);
dfb->visuals = TrueColorMask; //LARGE_VISUALS;
dfb->preferredCVC = TrueColor;
dfb->depth = 24;
dfb->bitsPerRGB = 8;