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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -318,7 +318,6 @@ static void
handleDepthModes(struct glCapabilitiesConfig *c, GLint dmodes) handleDepthModes(struct glCapabilitiesConfig *c, GLint dmodes)
{ {
int offset = 0; int offset = 0;
#define DEPTH(flag, value) do { \ #define DEPTH(flag, value) do { \
if (dmodes & flag) { \ if (dmodes & flag) { \
c->depth_buffers[offset++] = value; \ c->depth_buffers[offset++] = value; \
@ -483,7 +482,8 @@ initConfig(struct glCapabilitiesConfig *c)
for (i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) { for (i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
c->color_buffers[i].r = c->color_buffers[i].g = c->color_buffers[i].r = c->color_buffers[i].g =
c->color_buffers[i].b = c->color_buffers[i].a = c->color_buffers[i].b =
c->color_buffers[i].a =
GLCAPS_COLOR_BUF_INVALID_VALUE; GLCAPS_COLOR_BUF_INVALID_VALUE;
c->color_buffers[i].is_argb = false; c->color_buffers[i].is_argb = false;
} }
@ -492,7 +492,8 @@ initConfig(struct glCapabilitiesConfig *c)
for (i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) { for (i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
c->accum_buffers[i].r = c->accum_buffers[i].g = c->accum_buffers[i].r = c->accum_buffers[i].g =
c->accum_buffers[i].b = c->accum_buffers[i].a = c->accum_buffers[i].b =
c->accum_buffers[i].a =
GLCAPS_COLOR_BUF_INVALID_VALUE; GLCAPS_COLOR_BUF_INVALID_VALUE;
c->accum_buffers[i].is_argb = false; c->accum_buffers[i].is_argb = false;
} }
@ -540,7 +541,8 @@ getGlCapabilities(struct glCapabilities *cap)
err = handleRendererDescriptions(info, r, &tmpconf); err = handleRendererDescriptions(info, r, &tmpconf);
if (err) { if (err) {
ErrorF("handleRendererDescriptions returned error: %s\n", ErrorF("handleRendererDescriptions returned error: %s\n",
CGLErrorString(err)); CGLErrorString(
err));
ErrorF("trying to continue...\n"); ErrorF("trying to continue...\n");
continue; 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -60,7 +60,9 @@ struct glCapabilities {
int total_configurations; int total_configurations;
}; };
bool getGlCapabilities(struct glCapabilities *cap); bool
void freeGlCapabilities(struct glCapabilities *cap); getGlCapabilities(struct glCapabilities *cap);
void
freeGlCapabilities(struct glCapabilities *cap);
#endif #endif

View File

@ -193,7 +193,8 @@ _gl_copy_visual_to_context_mode(__GLcontextModes * mode,
GL_TRUE : GL_FALSE; GL_TRUE : GL_FALSE;
mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE; mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE;
mode->bindToTextureTargets = mode->rgbMode ? mode->bindToTextureTargets = mode->rgbMode ?
GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT | GLX_TEXTURE_1D_BIT_EXT |
GLX_TEXTURE_2D_BIT_EXT |
GLX_TEXTURE_RECTANGLE_BIT_EXT : 0; GLX_TEXTURE_RECTANGLE_BIT_EXT : 0;
mode->yInverted = GL_FALSE; mode->yInverted = GL_FALSE;
} }
@ -215,130 +216,172 @@ _gl_get_context_mode_data(const __GLcontextModes * mode, int attribute,
case GLX_USE_GL: case GLX_USE_GL:
*value_return = GL_TRUE; *value_return = GL_TRUE;
return 0; return 0;
case GLX_BUFFER_SIZE: case GLX_BUFFER_SIZE:
*value_return = mode->rgbBits; *value_return = mode->rgbBits;
return 0; return 0;
case GLX_RGBA: case GLX_RGBA:
*value_return = mode->rgbMode; *value_return = mode->rgbMode;
return 0; return 0;
case GLX_RED_SIZE: case GLX_RED_SIZE:
*value_return = mode->redBits; *value_return = mode->redBits;
return 0; return 0;
case GLX_GREEN_SIZE: case GLX_GREEN_SIZE:
*value_return = mode->greenBits; *value_return = mode->greenBits;
return 0; return 0;
case GLX_BLUE_SIZE: case GLX_BLUE_SIZE:
*value_return = mode->blueBits; *value_return = mode->blueBits;
return 0; return 0;
case GLX_ALPHA_SIZE: case GLX_ALPHA_SIZE:
*value_return = mode->alphaBits; *value_return = mode->alphaBits;
return 0; return 0;
case GLX_DOUBLEBUFFER: case GLX_DOUBLEBUFFER:
*value_return = mode->doubleBufferMode; *value_return = mode->doubleBufferMode;
return 0; return 0;
case GLX_STEREO: case GLX_STEREO:
*value_return = mode->stereoMode; *value_return = mode->stereoMode;
return 0; return 0;
case GLX_AUX_BUFFERS: case GLX_AUX_BUFFERS:
*value_return = mode->numAuxBuffers; *value_return = mode->numAuxBuffers;
return 0; return 0;
case GLX_DEPTH_SIZE: case GLX_DEPTH_SIZE:
*value_return = mode->depthBits; *value_return = mode->depthBits;
return 0; return 0;
case GLX_STENCIL_SIZE: case GLX_STENCIL_SIZE:
*value_return = mode->stencilBits; *value_return = mode->stencilBits;
return 0; return 0;
case GLX_ACCUM_RED_SIZE: case GLX_ACCUM_RED_SIZE:
*value_return = mode->accumRedBits; *value_return = mode->accumRedBits;
return 0; return 0;
case GLX_ACCUM_GREEN_SIZE: case GLX_ACCUM_GREEN_SIZE:
*value_return = mode->accumGreenBits; *value_return = mode->accumGreenBits;
return 0; return 0;
case GLX_ACCUM_BLUE_SIZE: case GLX_ACCUM_BLUE_SIZE:
*value_return = mode->accumBlueBits; *value_return = mode->accumBlueBits;
return 0; return 0;
case GLX_ACCUM_ALPHA_SIZE: case GLX_ACCUM_ALPHA_SIZE:
*value_return = mode->accumAlphaBits; *value_return = mode->accumAlphaBits;
return 0; return 0;
case GLX_LEVEL: case GLX_LEVEL:
*value_return = mode->level; *value_return = mode->level;
return 0; return 0;
case GLX_TRANSPARENT_TYPE_EXT: case GLX_TRANSPARENT_TYPE_EXT:
*value_return = mode->transparentPixel; *value_return = mode->transparentPixel;
return 0; return 0;
case GLX_TRANSPARENT_RED_VALUE: case GLX_TRANSPARENT_RED_VALUE:
*value_return = mode->transparentRed; *value_return = mode->transparentRed;
return 0; return 0;
case GLX_TRANSPARENT_GREEN_VALUE: case GLX_TRANSPARENT_GREEN_VALUE:
*value_return = mode->transparentGreen; *value_return = mode->transparentGreen;
return 0; return 0;
case GLX_TRANSPARENT_BLUE_VALUE: case GLX_TRANSPARENT_BLUE_VALUE:
*value_return = mode->transparentBlue; *value_return = mode->transparentBlue;
return 0; return 0;
case GLX_TRANSPARENT_ALPHA_VALUE: case GLX_TRANSPARENT_ALPHA_VALUE:
*value_return = mode->transparentAlpha; *value_return = mode->transparentAlpha;
return 0; return 0;
case GLX_TRANSPARENT_INDEX_VALUE: case GLX_TRANSPARENT_INDEX_VALUE:
*value_return = mode->transparentIndex; *value_return = mode->transparentIndex;
return 0; return 0;
case GLX_X_VISUAL_TYPE: case GLX_X_VISUAL_TYPE:
*value_return = mode->visualType; *value_return = mode->visualType;
return 0; return 0;
case GLX_CONFIG_CAVEAT: case GLX_CONFIG_CAVEAT:
*value_return = mode->visualRating; *value_return = mode->visualRating;
return 0; return 0;
case GLX_VISUAL_ID: case GLX_VISUAL_ID:
*value_return = mode->visualID; *value_return = mode->visualID;
return 0; return 0;
case GLX_DRAWABLE_TYPE: case GLX_DRAWABLE_TYPE:
*value_return = mode->drawableType; *value_return = mode->drawableType;
return 0; return 0;
case GLX_RENDER_TYPE: case GLX_RENDER_TYPE:
*value_return = mode->renderType; *value_return = mode->renderType;
return 0; return 0;
case GLX_X_RENDERABLE: case GLX_X_RENDERABLE:
*value_return = mode->xRenderable; *value_return = mode->xRenderable;
return 0; return 0;
case GLX_FBCONFIG_ID: case GLX_FBCONFIG_ID:
*value_return = mode->fbconfigID; *value_return = mode->fbconfigID;
return 0; return 0;
case GLX_MAX_PBUFFER_WIDTH: case GLX_MAX_PBUFFER_WIDTH:
*value_return = mode->maxPbufferWidth; *value_return = mode->maxPbufferWidth;
return 0; return 0;
case GLX_MAX_PBUFFER_HEIGHT: case GLX_MAX_PBUFFER_HEIGHT:
*value_return = mode->maxPbufferHeight; *value_return = mode->maxPbufferHeight;
return 0; return 0;
case GLX_MAX_PBUFFER_PIXELS: case GLX_MAX_PBUFFER_PIXELS:
*value_return = mode->maxPbufferPixels; *value_return = mode->maxPbufferPixels;
return 0; return 0;
case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
*value_return = mode->optimalPbufferWidth; *value_return = mode->optimalPbufferWidth;
return 0; return 0;
case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
*value_return = mode->optimalPbufferHeight; *value_return = mode->optimalPbufferHeight;
return 0; return 0;
case GLX_SWAP_METHOD_OML: case GLX_SWAP_METHOD_OML:
*value_return = mode->swapMethod; *value_return = mode->swapMethod;
return 0; return 0;
case GLX_SAMPLE_BUFFERS_SGIS: case GLX_SAMPLE_BUFFERS_SGIS:
*value_return = mode->sampleBuffers; *value_return = mode->sampleBuffers;
return 0; return 0;
case GLX_SAMPLES_SGIS: case GLX_SAMPLES_SGIS:
*value_return = mode->samples; *value_return = mode->samples;
return 0; return 0;
case GLX_BIND_TO_TEXTURE_RGB_EXT: case GLX_BIND_TO_TEXTURE_RGB_EXT:
*value_return = mode->bindToTextureRgb; *value_return = mode->bindToTextureRgb;
return 0; return 0;
case GLX_BIND_TO_TEXTURE_RGBA_EXT: case GLX_BIND_TO_TEXTURE_RGBA_EXT:
*value_return = mode->bindToTextureRgba; *value_return = mode->bindToTextureRgba;
return 0; return 0;
case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
*value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE : *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
GL_FALSE; GL_FALSE;
return 0; return 0;
case GLX_BIND_TO_TEXTURE_TARGETS_EXT: case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
*value_return = mode->bindToTextureTargets; *value_return = mode->bindToTextureTargets;
return 0; return 0;
case GLX_Y_INVERTED_EXT: case GLX_Y_INVERTED_EXT:
*value_return = mode->yInverted; *value_return = mode->yInverted;
return 0; return 0;
@ -494,11 +537,13 @@ _gl_context_modes_are_same(const __GLcontextModes * a,
(a->stereoMode == b->stereoMode) && (a->stereoMode == b->stereoMode) &&
(a->redBits == b->redBits) && (a->redBits == b->redBits) &&
(a->greenBits == b->greenBits) && (a->greenBits == b->greenBits) &&
(a->blueBits == b->blueBits) && (a->alphaBits == b->alphaBits) && (a->blueBits == b->blueBits) &&
(a->alphaBits == b->alphaBits) &&
#if 0 /* For some reason these don't get set on the client-side in libGL. */ #if 0 /* For some reason these don't get set on the client-side in libGL. */
(a->redMask == b->redMask) && (a->redMask == b->redMask) &&
(a->greenMask == b->greenMask) && (a->greenMask == b->greenMask) &&
(a->blueMask == b->blueMask) && (a->alphaMask == b->alphaMask) && (a->blueMask == b->blueMask) &&
(a->alphaMask == b->alphaMask) &&
#endif #endif
(a->rgbBits == b->rgbBits) && (a->rgbBits == b->rgbBits) &&
(a->indexBits == b->indexBits) && (a->indexBits == b->indexBits) &&
@ -512,14 +557,18 @@ _gl_context_modes_are_same(const __GLcontextModes * a,
(a->level == b->level) && (a->level == b->level) &&
(a->pixmapMode == b->pixmapMode) && (a->pixmapMode == b->pixmapMode) &&
(a->visualRating == b->visualRating) && (a->visualRating == b->visualRating) &&
(a->transparentPixel == b->transparentPixel) && (a->transparentPixel == b->transparentPixel) &&
((a->transparentPixel != GLX_TRANSPARENT_RGB) || ((a->transparentPixel != GLX_TRANSPARENT_RGB) ||
((a->transparentRed == b->transparentRed) && ((a->transparentRed == b->transparentRed) &&
(a->transparentGreen == b->transparentGreen) && (a->transparentGreen == b->transparentGreen) &&
(a->transparentBlue == b->transparentBlue) && (a->transparentBlue == b->transparentBlue) &&
(a->transparentAlpha == b->transparentAlpha))) && (a->transparentAlpha == b->transparentAlpha))) &&
((a->transparentPixel != GLX_TRANSPARENT_INDEX) || ((a->transparentPixel != GLX_TRANSPARENT_INDEX) ||
(a->transparentIndex == b->transparentIndex)) && (a->transparentIndex == b->transparentIndex)) &&
(a->sampleBuffers == b->sampleBuffers) && (a->sampleBuffers == b->sampleBuffers) &&
(a->samples == b->samples) && (a->samples == b->samples) &&
((a->drawableType & b->drawableType) != 0) && ((a->drawableType & b->drawableType) != 0) &&

View File

@ -33,22 +33,28 @@
#include "GL/internal/glcore.h" #include "GL/internal/glcore.h"
#if !defined(IN_MINI_GLX) #if !defined(IN_MINI_GLX)
extern GLint _gl_convert_from_x_visual_type(int visualType); extern GLint
extern GLint _gl_convert_to_x_visual_type(int visualType); _gl_convert_from_x_visual_type(int visualType);
extern void _gl_copy_visual_to_context_mode(__GLcontextModes * mode, extern GLint
_gl_convert_to_x_visual_type(int visualType);
extern void
_gl_copy_visual_to_context_mode(__GLcontextModes * mode,
const __GLXvisualConfig * config); const __GLXvisualConfig * config);
extern int _gl_get_context_mode_data(const __GLcontextModes * mode, extern int
int attribute, int *value_return); _gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
int *value_return);
#endif /* !defined(IN_MINI_GLX) */ #endif /* !defined(IN_MINI_GLX) */
extern __GLcontextModes *_gl_context_modes_create(unsigned count, extern __GLcontextModes *
size_t minimum_size); _gl_context_modes_create(unsigned count, size_t minimum_size);
extern void _gl_context_modes_destroy(__GLcontextModes * modes); extern void
extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes * modes, _gl_context_modes_destroy(__GLcontextModes * modes);
int vid); extern __GLcontextModes *
extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes * _gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
modes, int fbid); extern __GLcontextModes *
extern GLboolean _gl_context_modes_are_same(const __GLcontextModes * a, _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
extern GLboolean
_gl_context_modes_are_same(const __GLcontextModes * a,
const __GLcontextModes * b); const __GLcontextModes * b);
#endif /* GLCONTEXTMODES_H */ #endif /* GLCONTEXTMODES_H */

View File

@ -2,7 +2,7 @@
* GLX implementation that uses Apple's OpenGL.framework * GLX implementation that uses Apple's OpenGL.framework
* (Indirect rendering path -- it's also used for some direct mode code too) * (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) 2004 Torrey T. Lyons. All Rights Reserved.
* Copyright (c) 2002 Greg Parker. All Rights Reserved. * Copyright (c) 2002 Greg Parker. All Rights Reserved.
* *
@ -56,30 +56,41 @@
#include "dri.h" #include "dri.h"
#include "darwin.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); static void
GLuint __glFloorLog2(GLuint val); setup_dispatch_table(void);
void warn_func(void *p1, char *format, ...); GLuint
__glFloorLog2(GLuint val);
void
warn_func(void * p1, char *format, ...);
// some prototypes // some prototypes
static __GLXscreen *__glXAquaScreenProbe(ScreenPtr pScreen); static __GLXscreen *
static __GLXdrawable *__glXAquaScreenCreateDrawable(ClientPtr client, __glXAquaScreenProbe(ScreenPtr pScreen);
__GLXscreen * screen, static __GLXdrawable *
DrawablePtr pDraw, __glXAquaScreenCreateDrawable(ClientPtr client, __GLXscreen *screen,
XID drawId, int type, DrawablePtr pDraw, XID drawId, int type,
XID glxDrawId, XID glxDrawId,
__GLXconfig *conf); __GLXconfig *conf);
static void __glXAquaContextDestroy(__GLXcontext * baseContext); static void
static int __glXAquaContextMakeCurrent(__GLXcontext * baseContext); __glXAquaContextDestroy(__GLXcontext *baseContext);
static int __glXAquaContextLoseCurrent(__GLXcontext * baseContext); static int
static int __glXAquaContextCopy(__GLXcontext * baseDst, __GLXcontext * baseSrc, __glXAquaContextMakeCurrent(__GLXcontext *baseContext);
static int
__glXAquaContextLoseCurrent(__GLXcontext *baseContext);
static int
__glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc,
unsigned long mask); unsigned long mask);
static CGLPixelFormatObj makeFormat(__GLXconfig * conf); static CGLPixelFormatObj
makeFormat(__GLXconfig *conf);
__GLXprovider __glXDRISWRastProvider = { __GLXprovider __glXDRISWRastProvider = {
__glXAquaScreenProbe, __glXAquaScreenProbe,
@ -186,11 +197,11 @@ __glXAquaContextDestroy(__GLXcontext * baseContext)
if (context != NULL) { if (context != NULL) {
if (context->sid != 0 && surface_hash != NULL) { if (context->sid != 0 && surface_hash != NULL) {
lst = lst =
x_hash_table_lookup(surface_hash, x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(
x_cvt_uint_to_vptr(context->sid), NULL); context->sid), NULL);
lst = x_list_remove(lst, context); lst = x_list_remove(lst, context);
x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(
lst); context->sid), lst);
} }
if (context->ctx != NULL) if (context->ctx != NULL)
@ -232,7 +243,6 @@ surface_notify(void *_arg, void *data)
__GLXAquaDrawable *draw = (__GLXAquaDrawable *)data; __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data;
__GLXAquaContext *context; __GLXAquaContext *context;
x_list *lst; x_list *lst;
if (_arg == NULL || data == NULL) { if (_arg == NULL || data == NULL) {
ErrorF("surface_notify called with bad params"); ErrorF("surface_notify called with bad params");
return; return;
@ -250,14 +260,15 @@ surface_notify(void *_arg, void *data)
case AppleDRISurfaceNotifyChanged: case AppleDRISurfaceNotifyChanged:
if (surface_hash != NULL) { if (surface_hash != NULL) {
lst = lst =
x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(
NULL); arg->id), NULL);
for (; lst != NULL; lst = lst->next) { for (; lst != NULL; lst = lst->next) {
context = lst->data; context = lst->data;
xp_update_gl_context(context->ctx); xp_update_gl_context(context->ctx);
} }
} }
break; break;
default: default:
ErrorF("surface_notify: unknown kind %d\n", arg->kind); ErrorF("surface_notify: unknown kind %d\n", arg->kind);
break; break;
@ -284,7 +295,8 @@ attach(__GLXAquaContext * context, __GLXAquaDrawable * draw)
if (draw->sid == 0) { if (draw->sid == 0) {
//if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw, //if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw, if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw,
0, &draw->sid, NULL, surface_notify, draw)) 0, &draw->sid, NULL,
surface_notify, draw))
return TRUE; return TRUE;
draw->pDraw = pDraw; draw->pDraw = pDraw;
} }
@ -311,12 +323,12 @@ attach(__GLXAquaContext * context, __GLXAquaDrawable * draw)
surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
lst = lst =
x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(
NULL); context->sid), NULL);
if (x_list_find(lst, context) == NULL) { if (x_list_find(lst, context) == NULL) {
lst = x_list_prepend(lst, context); lst = x_list_prepend(lst, context);
x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(
lst); context->sid), lst);
} }
GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int)pDraw->id, GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int)pDraw->id,
@ -333,7 +345,6 @@ static void
unattach(__GLXAquaContext *context) unattach(__GLXAquaContext *context)
{ {
x_list *lst; x_list *lst;
GLAQUA_DEBUG_MSG("unattach\n"); GLAQUA_DEBUG_MSG("unattach\n");
if (context == NULL) { if (context == NULL) {
ErrorF("Tried to unattach a null context\n"); ErrorF("Tried to unattach a null context\n");
@ -343,8 +354,8 @@ unattach(__GLXAquaContext * context)
GLAQUA_DEBUG_MSG("unattaching\n"); GLAQUA_DEBUG_MSG("unattaching\n");
if (surface_hash != NULL) { if (surface_hash != NULL) {
lst = lst = x_hash_table_lookup(surface_hash, (void *)context->sid,
x_hash_table_lookup(surface_hash, (void *) context->sid, NULL); NULL);
lst = x_list_remove(lst, context); 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);
} }
@ -517,9 +528,8 @@ __glXAquaScreenProbe(ScreenPtr pScreen)
screen->base.swapInterval = /*FIXME*/ NULL; screen->base.swapInterval = /*FIXME*/ NULL;
screen->base.pScreen = pScreen; screen->base.pScreen = pScreen;
screen->base.fbconfigs = screen->base.fbconfigs = __glXAquaCreateVisualConfigs(
__glXAquaCreateVisualConfigs(&screen->base.numFBConfigs, &screen->base.numFBConfigs, pScreen->myNum);
pScreen->myNum);
__glXScreenInit(&screen->base, pScreen); __glXScreenInit(&screen->base, pScreen);
@ -576,7 +586,9 @@ __glXAquaScreenCreateDrawable(ClientPtr client,
__GLXscreen *screen, __GLXscreen *screen,
DrawablePtr pDraw, DrawablePtr pDraw,
XID drawId, XID drawId,
int type, XID glxDrawId, __GLXconfig * conf) int type,
XID glxDrawId,
__GLXconfig *conf)
{ {
__GLXAquaDrawable *glxPriv; __GLXAquaDrawable *glxPriv;
@ -587,8 +599,8 @@ __glXAquaScreenCreateDrawable(ClientPtr client,
memset(glxPriv, 0, sizeof *glxPriv); memset(glxPriv, 0, sizeof *glxPriv);
if (!__glXDrawableInit if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId,
(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) { conf)) {
free(glxPriv); free(glxPriv);
return NULL; return NULL;
} }
@ -619,7 +631,8 @@ __glFloorLog2(GLuint val)
} }
#ifndef OPENGL_FRAMEWORK_PATH #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 #endif
static void static void

View File

@ -106,12 +106,13 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
numConfigs += (conf->stereo ? 2 : 1) numConfigs += (conf->stereo ? 2 : 1)
* (conf->aux_buffers ? 2 : 1) * (conf->aux_buffers ? 2 : 1)
* conf->buffers * conf->buffers
* * ((conf->total_stencil_bit_depths >
((conf->total_stencil_bit_depths >
0) ? conf->total_stencil_bit_depths : 1) 0) ? conf->total_stencil_bit_depths : 1)
* conf->total_color_buffers * * conf->total_color_buffers
((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1) * ((conf->total_accum_buffers >
* conf->total_depth_buffer_depths * (conf->multisample_buffers + 1); 0) ? conf->total_accum_buffers : 1)
* conf->total_depth_buffer_depths
* (conf->multisample_buffers + 1);
} }
if (numConfigsPtr) if (numConfigsPtr)
@ -131,16 +132,16 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
for (aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) { for (aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
for (buffers = 0; buffers < conf->buffers; ++buffers) { for (buffers = 0; buffers < conf->buffers; ++buffers) {
for (stencil = 0; for (stencil = 0;
stencil < stencil < ((conf->total_stencil_bit_depths > 0) ?
((conf->total_stencil_bit_depths > conf->
0) ? conf->total_stencil_bit_depths : 1); total_stencil_bit_depths : 1);
++stencil) { ++stencil) {
for (color = 0; color < conf->total_color_buffers; for (color = 0; color < conf->total_color_buffers;
++color) { ++color) {
for (accum = 0; for (accum = 0;
accum < accum < ((conf->total_accum_buffers > 0) ?
((conf->total_accum_buffers > conf->
0) ? conf->total_accum_buffers : 1); total_accum_buffers : 1);
++accum) { ++accum) {
for (depth = 0; for (depth = 0;
depth < conf->total_depth_buffer_depths; depth < conf->total_depth_buffer_depths;
@ -178,7 +179,8 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->visualSelectGroup = 0; c->visualSelectGroup = 0;
c->swapMethod = GLX_SWAP_UNDEFINED_OML; c->swapMethod =
GLX_SWAP_UNDEFINED_OML;
// Stereo // Stereo
c->stereoMode = stereo ? TRUE : FALSE; c->stereoMode = stereo ? TRUE : FALSE;
@ -192,10 +194,11 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
buffers ? TRUE : FALSE; buffers ? TRUE : FALSE;
// Stencil Buffer // Stencil Buffer
if (conf->total_stencil_bit_depths > 0) { if (conf->total_stencil_bit_depths >
0) {
c->stencilBits = c->stencilBits =
conf-> conf->stencil_bit_depths[
stencil_bit_depths[stencil]; stencil];
} }
else { else {
c->stencilBits = 0; c->stencilBits = 0;
@ -217,22 +220,27 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
c->blueBits = c->blueBits =
conf->color_buffers[color].b; conf->color_buffers[color].b;
c->rgbBits = c->rgbBits = c->alphaBits +
c->alphaBits + c->redBits + c->redBits +
c->greenBits + c->blueBits; c->greenBits +
c->blueBits;
c->alphaMask = c->alphaMask =
AM_ARGB(c->alphaBits, c->redBits, AM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits); c->greenBits,
c->blueBits);
c->redMask = c->redMask =
RM_ARGB(c->alphaBits, c->redBits, RM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits); c->greenBits,
c->blueBits);
c->greenMask = c->greenMask =
GM_ARGB(c->alphaBits, c->redBits, GM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits); c->greenBits,
c->blueBits);
c->blueMask = c->blueMask =
BM_ARGB(c->alphaBits, c->redBits, BM_ARGB(c->alphaBits, c->redBits,
c->greenBits, c->blueBits); c->greenBits,
c->blueBits);
// Accumulation Buffers // Accumulation Buffers
if (conf->total_accum_buffers > 0) { if (conf->total_accum_buffers > 0) {
@ -242,12 +250,14 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
conf->accum_buffers[accum].g; conf->accum_buffers[accum].g;
c->accumBlueBits = c->accumBlueBits =
conf->accum_buffers[accum].b; 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 = c->accumAlphaBits =
conf->accum_buffers[accum]. conf->accum_buffers[accum
a; ].a;
} }
else { else {
c->accumAlphaBits = 0; c->accumAlphaBits = 0;
@ -281,8 +291,8 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
* GLXPbuffers in direct mode. * GLXPbuffers in direct mode.
*/ */
/* SGIX_fbconfig / GLX 1.3 */ /* SGIX_fbconfig / GLX 1.3 */
c->drawableType = c->drawableType = GLX_WINDOW_BIT |
GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PIXMAP_BIT |
GLX_PBUFFER_BIT; GLX_PBUFFER_BIT;
c->renderType = GLX_RGBA_BIT; c->renderType = GLX_RGBA_BIT;
c->xRenderable = GL_TRUE; c->xRenderable = GL_TRUE;
@ -330,8 +340,8 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
(c - 1)->next = NULL; (c - 1)->next = NULL;
if (c - visualConfigs != numConfigs) { if (c - visualConfigs != numConfigs) {
FatalError FatalError(
("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", "numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n",
numConfigs, (int)(c - visualConfigs)); numConfigs, (int)(c - visualConfigs));
} }

View File

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

View File

@ -1,31 +1,32 @@
/* X11Application.h -- subclass of NSApplication to multiplex events /* X11Application.h -- subclass of NSApplication to multiplex events
*
Copyright (c) 2002-2007 Apple Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifndef X11APPLICATION_H #ifndef X11APPLICATION_H
#define X11APPLICATION_H 1 #define X11APPLICATION_H 1
@ -43,46 +44,26 @@
- (void)set_controller:controller; - (void)set_controller:controller;
- (void)set_window_menu:(NSArray *)list; - (void)set_window_menu:(NSArray *)list;
-(CFPropertyListRef) prefs_get_copy:(NSString *) - (CFPropertyListRef)prefs_get_copy:(NSString *)key CF_RETURNS_RETAINED;
key CF_RETURNS_RETAINED; - (int)prefs_get_integer:(NSString *)key default:(int)def;
- (const char *)prefs_get_string:(NSString *)key default:(const char *)def;
-(int) prefs_get_integer:(NSString *) - (float)prefs_get_float:(NSString *)key default:(float)def;
key default:(int) def; - (int)prefs_get_boolean:(NSString *)key default:(int)def;
- (NSURL *)prefs_copy_url:(NSString *)key default:(NSURL *)def
-(const char *) prefs_get_string:(NSString *) NS_RETURNS_RETAINED;
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; - (NSArray *)prefs_get_array:(NSString *)key;
-(void) prefs_set_integer:(NSString *) - (void)prefs_set_integer:(NSString *)key value:(int)value;
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_float:(NSString *) - (void)prefs_set_array:(NSString *)key value:(NSArray *)value;
key value:(float) value; - (void)prefs_set_string:(NSString *)key value:(NSString *)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; - (void)prefs_synchronize;
- (X11Controller *)controller; - (X11Controller *)controller;
- (OSX_BOOL)x_active; - (OSX_BOOL)x_active;
@end extern X11Application *X11App; @end
extern X11Application * X11App;
#endif /* __OBJC__ */ #endif /* __OBJC__ */
@ -106,10 +87,10 @@ Bool
X11ApplicationCanEnterRandR(void); X11ApplicationCanEnterRandR(void);
void void
X11ApplicationMain(int argc, char **argv, char **envp); X11ApplicationFatalError(const char *f, va_list args) __printflike(1, 0);
void void
X11ApplicationFatalError(const char *f, va_list args) __printflike(1, 0); X11ApplicationMain(int argc, char **argv, char **envp);
#define PREFS_APPSMENU "apps_menu" #define PREFS_APPSMENU "apps_menu"
#define PREFS_FAKEBUTTONS "enable_fake_buttons" #define PREFS_FAKEBUTTONS "enable_fake_buttons"

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,32 @@
/* X11Controller.h -- connect the IB ui /* X11Controller.h -- connect the IB ui
*
Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifndef X11CONTROLLER_H #ifndef X11CONTROLLER_H
#define X11CONTROLLER_H 1 #define X11CONTROLLER_H 1
@ -85,7 +86,6 @@ typedef unsigned int NSUInteger;
IBOutlet NSPopUpButton *depth; IBOutlet NSPopUpButton *depth;
IBOutlet NSMenuItem *window_separator; IBOutlet NSMenuItem *window_separator;
// window_separator is DEPRECATED due to this radar: // 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 // <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" // 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 *dock_window_separator;
IBOutlet NSMenuItem *apps_separator; IBOutlet NSMenuItem *apps_separator;
IBOutlet NSMenuItem *toggle_fullscreen_item; IBOutlet NSMenuItem *toggle_fullscreen_item;
#ifdef XQUARTZ_SPARKLE #ifdef XQUARTZ_SPARKLE
NSMenuItem *check_for_updates_item; // Programatically enabled NSMenuItem *check_for_updates_item; // Programatically enabled
#endif #endif
@ -123,13 +122,12 @@ typedef unsigned int NSUInteger;
- (void)set_apps_menu:(NSArray *)list; - (void)set_apps_menu:(NSArray *)list;
#ifdef XQUARTZ_SPARKLE #ifdef XQUARTZ_SPARKLE
- (void)setup_sparkle; - (void)setup_sparkle;
-(void) updater:(SUUpdater *) - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)
updater willInstallUpdate:(SUAppcastItem *) update; update;
#endif #endif
- (void)set_can_quit:(OSX_BOOL)state; - (void)set_can_quit:(OSX_BOOL)state;
- (void)server_ready; - (void)server_ready;
-(OSX_BOOL) application:(NSApplication *) - (OSX_BOOL)application:(NSApplication *)app openFile:(NSString *)filename;
app openFile:(NSString *) filename;
- (IBAction)apps_table_show:(id)sender; - (IBAction)apps_table_show:(id)sender;
- (IBAction)apps_table_done:(id)sender; - (IBAction)apps_table_done:(id)sender;
@ -150,7 +148,9 @@ app openFile:(NSString *) filename;
- (IBAction)x11_help:(id)sender; - (IBAction)x11_help:(id)sender;
@end @end
#endif /* __OBJC__ */ #endif /* __OBJC__ */
void void
X11ControllerMain(int argc, char **argv, char **envp); X11ControllerMain(int argc, char **argv, char **envp);

View File

@ -1,31 +1,32 @@
/* X11Controller.m -- connect the IB ui, also the NSApp delegate /* X11Controller.m -- connect the IB ui, also the NSApp delegate
*
Copyright (c) 2002-2008 Apple Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#include "sanitizedCarbon.h" #include "sanitizedCarbon.h"
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
@ -53,7 +54,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
@ implementation X11Controller - (void) awakeFromNib { @implementation X11Controller
- (void) awakeFromNib
{
X11Application *xapp = NSApp; X11Application *xapp = NSApp;
NSArray *array; NSArray *array;
@ -68,8 +72,8 @@
to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */ to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
count = [array count]; count = [array count];
if (count > 0 && ![[array objectAtIndex: 0] isKindOfClass:[NSArray class]]) if (count > 0
{ && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]]) {
int i; int i;
NSMutableArray *copy, *sub; NSMutableArray *copy, *sub;
@ -91,8 +95,10 @@
} }
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver: self selector: @selector(apps_table_done:) addObserver: self
name: NSWindowWillCloseNotification object:[apps_table window]]; selector: @selector(apps_table_done:)
name: NSWindowWillCloseNotification
object: [apps_table window]];
// Setup data about our Windows menu // Setup data about our Windows menu
if (window_separator) { if (window_separator) {
@ -103,14 +109,16 @@
windows_menu_start = [[X11App windowsMenu] numberOfItems]; windows_menu_start = [[X11App windowsMenu] numberOfItems];
} }
-(void) item_selected:sender { - (void) item_selected:sender
{
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
DarwinSendDDXEvent(kXquartzControllerNotify, 2, DarwinSendDDXEvent(kXquartzControllerNotify, 2,
AppleWMWindowMenuItem, [sender tag]); AppleWMWindowMenuItem, [sender tag]);
} }
-(void) remove_window_menu { - (void) remove_window_menu
{
NSMenu *menu; NSMenu *menu;
int count, i; int count, i;
@ -125,7 +133,8 @@
[dock_menu removeItemAtIndex:0]; [dock_menu removeItemAtIndex:0];
} }
-(void) install_window_menu:(NSArray *) list { - (void) install_window_menu:(NSArray *)list
{
NSMenu *menu; NSMenu *menu;
NSMenuItem *item; NSMenuItem *item;
int first, count, i; int first, count, i;
@ -148,13 +157,19 @@
if (windowItemModMask == 0 || windowItemModMask == -1) if (windowItemModMask == 0 || windowItemModMask == -1)
shortcut = @""; shortcut = @"";
item = (NSMenuItem *)[menu addItemWithTitle: name action: @selector(item_selected: )keyEquivalent:shortcut]; item =
(NSMenuItem *)[menu addItemWithTitle:name action:
@selector
(item_selected:) keyEquivalent:shortcut];
[item setKeyEquivalentModifierMask:(NSUInteger)windowItemModMask]; [item setKeyEquivalentModifierMask:(NSUInteger)windowItemModMask];
[item setTarget:self]; [item setTarget:self];
[item setTag:i]; [item setTag:i];
[item setEnabled:YES]; [item setEnabled:YES];
item = (NSMenuItem *)[dock_menu insertItemWithTitle: name action: @selector(item_selected: )keyEquivalent: shortcut atIndex:i]; item = (NSMenuItem *)[dock_menu insertItemWithTitle:name
action:@selector
(item_selected:) keyEquivalent:shortcut
atIndex:i];
[item setKeyEquivalentModifierMask:(NSUInteger)windowItemModMask]; [item setKeyEquivalentModifierMask:(NSUInteger)windowItemModMask];
[item setTarget:self]; [item setTarget:self];
[item setTag:i]; [item setTag:i];
@ -169,13 +184,13 @@
} }
} }
-(void) remove_apps_menu { - (void) remove_apps_menu
{
NSMenu *menu; NSMenu *menu;
NSMenuItem *item; NSMenuItem *item;
int i; int i;
if (apps == nil || apps_separator == nil) if (apps == nil || apps_separator == nil) return;
return;
menu = [apps_separator menu]; menu = [apps_separator menu];
@ -199,9 +214,7 @@
apps = nil; apps = nil;
} }
-(void) prepend_apps_item:(NSArray *) - (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
list index:(int)
i menu:(NSMenu *) menu
{ {
NSString *title, *shortcut = @""; NSString *title, *shortcut = @"";
NSArray *group; NSArray *group;
@ -213,7 +226,9 @@ i menu:(NSMenu *) menu
shortcut = [group objectAtIndex:2]; shortcut = [group objectAtIndex:2];
if ([title length] != 0) { if ([title length] != 0) {
item = (NSMenuItem *)[menu insertItemWithTitle: title action: @selector(app_selected:) item = (NSMenuItem *)[menu insertItemWithTitle:title
action:@selector (
app_selected:)
keyEquivalent:shortcut atIndex:0]; keyEquivalent:shortcut atIndex:0];
[item setTarget:self]; [item setTarget:self];
[item setEnabled:YES]; [item setEnabled:YES];
@ -226,14 +241,14 @@ i menu:(NSMenu *) menu
[item setTag:i + 1]; /* can't be zero, so add one */ [item setTag:i + 1]; /* can't be zero, so add one */
} }
-(void) install_apps_menu:(NSArray *) list { - (void) install_apps_menu:(NSArray *)list
{
NSMenu *menu; NSMenu *menu;
int i, count; int i, count;
count = [list count]; count = [list count];
if (count == 0 || apps_separator == nil) if (count == 0 || apps_separator == nil) return;
return;
menu = [apps_separator menu]; menu = [apps_separator menu];
@ -247,14 +262,17 @@ i menu:(NSMenu *) menu
apps = [list retain]; apps = [list retain];
} }
-(void) set_window_menu:(NSArray *) list { - (void) set_window_menu:(NSArray *)list
{
[self remove_window_menu]; [self remove_window_menu];
[self install_window_menu:list]; [self install_window_menu:list];
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMWindowMenuNotify); DarwinSendDDXEvent(kXquartzControllerNotify, 1,
AppleWMWindowMenuNotify);
} }
-(void) set_window_menu_check:(NSNumber *) nn { - (void) set_window_menu_check:(NSNumber *)nn
{
NSMenu *menu; NSMenu *menu;
NSMenuItem *item; NSMenuItem *item;
int first, count; int first, count;
@ -279,22 +297,28 @@ i menu:(NSMenu *) menu
checked_window_item = n; checked_window_item = n;
} }
-(void) set_apps_menu:(NSArray *) list { - (void) set_apps_menu:(NSArray *)list
{
[self remove_apps_menu]; [self remove_apps_menu];
[self install_apps_menu:list]; [self install_apps_menu:list];
} }
#ifdef XQUARTZ_SPARKLE #ifdef XQUARTZ_SPARKLE
-(void) setup_sparkle { - (void) setup_sparkle
{
if (check_for_updates_item) if (check_for_updates_item)
return; // already did it... return; // already did it...
NSMenu *menu = [x11_about_item menu]; NSMenu *menu = [x11_about_item menu];
check_for_updates_item =[menu insertItemWithTitle:NSLocalizedString(@"Check for X11 Updates...", check_for_updates_item =
[menu insertItemWithTitle:NSLocalizedString(
@"Check for X11 Updates...",
@"Check for X11 Updates...") @"Check for X11 Updates...")
action: @selector(checkForUpdates:) action:@selector (
keyEquivalent: @"" atIndex:1]; checkForUpdates:)
keyEquivalent:@""
atIndex:1];
[check_for_updates_item setTarget:[SUUpdater sharedUpdater]]; [check_for_updates_item setTarget:[SUUpdater sharedUpdater]];
[check_for_updates_item setEnabled:YES]; [check_for_updates_item setEnabled:YES];
@ -303,23 +327,24 @@ i menu:(NSMenu *) menu
} }
// Sent immediately before installing the specified update. // Sent immediately before installing the specified update.
-(void) updater:(SUUpdater *) - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)
updater willInstallUpdate:(SUAppcastItem *) update update
{ {
//[self set_can_quit:YES]; //[self set_can_quit:YES];
} }
#endif #endif
-(void) launch_client:(NSString *) filename { - (void) launch_client:(NSString *)filename
{
int child1, child2 = 0; int child1, child2 = 0;
int status; int status;
const char *newargv[4]; const char *newargv[4];
char buf[128]; char buf[128];
char *s; char *s;
newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default: newargv[0] =
"/bin/sh"]; [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
newargv[1] = "-c"; newargv[1] = "-c";
newargv[2] = [filename UTF8String]; newargv[2] = [filename UTF8String];
newargv[3] = NULL; newargv[3] = NULL;
@ -368,7 +393,8 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
} }
} }
-(void) app_selected:sender { - (void) app_selected:sender
{
int tag; int tag;
NSString *item; NSString *item;
@ -381,7 +407,8 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
[self launch_client:item]; [self launch_client:item];
} }
-(IBAction) apps_table_show:sender { - (IBAction) apps_table_show:sender
{
NSArray *columns; NSArray *columns;
NSMutableArray *oldapps = nil; NSMutableArray *oldapps = nil;
@ -398,7 +425,8 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
[[columns objectAtIndex:2] setIdentifier:@"2"]; [[columns objectAtIndex:2] setIdentifier:@"2"];
[apps_table setDataSource:self]; [apps_table setDataSource:self];
[apps_table selectRowIndexes: [NSIndexSet indexSetWithIndex: 0] byExtendingSelection:NO]; [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:0]
byExtendingSelection:NO];
[[apps_table window] makeKeyAndOrderFront:sender]; [[apps_table window] makeKeyAndOrderFront:sender];
[apps_table reloadData]; [apps_table reloadData];
@ -406,9 +434,9 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
[oldapps release]; [oldapps release];
} }
-(IBAction) apps_table_done:sender { - (IBAction) apps_table_done:sender
[apps_table deselectAll:sender]; {
/* flush edits? */ [apps_table deselectAll:sender]; /* flush edits? */
[self remove_apps_menu]; [self remove_apps_menu];
[self install_apps_menu:table_apps]; [self install_apps_menu:table_apps];
@ -422,15 +450,14 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
table_apps = nil; table_apps = nil;
} }
-(IBAction) apps_table_new:sender { - (IBAction) apps_table_new:sender
{
NSMutableArray *item; NSMutableArray *item;
int row = [apps_table selectedRow], i; int row = [apps_table selectedRow], i;
if (row < 0) if (row < 0) row = 0;
row = 0; else row = row + 1;
else
row = row + 1;
i = row; i = row;
if (i > [table_apps count]) if (i > [table_apps count])
@ -447,10 +474,12 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
[item release]; [item release];
[apps_table reloadData]; [apps_table reloadData];
[apps_table selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection:NO]; [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
byExtendingSelection:NO];
} }
-(IBAction) apps_table_duplicate:sender { - (IBAction) apps_table_duplicate:sender
{
int row = [apps_table selectedRow], i; int row = [apps_table selectedRow], i;
NSObject *item; NSObject *item;
@ -460,8 +489,7 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
} }
i = row; i = row;
if (i >[table_apps count] - 1) if (i > [table_apps count] - 1) return; /* avoid exceptions */
return; /* avoid exceptions */
[apps_table deselectAll:sender]; [apps_table deselectAll:sender];
@ -470,17 +498,18 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
[item release]; [item release];
[apps_table reloadData]; [apps_table reloadData];
[apps_table selectRowIndexes: [NSIndexSet indexSetWithIndex: row + 1] byExtendingSelection:NO]; [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row +
1] byExtendingSelection:NO];
} }
-(IBAction) apps_table_delete:sender { - (IBAction) apps_table_delete:sender
{
int row = [apps_table selectedRow]; int row = [apps_table selectedRow];
if (row >= 0) { if (row >= 0) {
int i = row; int i = row;
if (i >[table_apps count] - 1) if (i > [table_apps count] - 1) return; /* avoid exceptions */
return; /* avoid exceptions */
[apps_table deselectAll:sender]; [apps_table deselectAll:sender];
@ -491,25 +520,24 @@ newargv[0] =[X11App prefs_get_string: @PREFS_LOGIN_SHELL default:
row = MIN(row, [table_apps count] - 1); row = MIN(row, [table_apps count] - 1);
if (row >= 0) if (row >= 0)
[apps_table selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection:NO]; [apps_table selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
byExtendingSelection:NO];
} }
-(NSInteger) numberOfRowsInTableView:(NSTableView *) tableView { - (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView
if (table_apps == nil) {
return 0; if (table_apps == nil) return 0;
return [table_apps count]; return [table_apps count];
} }
-(id) tableView: (NSTableView *) tableView objectValueForTableColumn:(NSTableColumn - (id) tableView:(NSTableView *)tableView
*) objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
tableColumn row:(NSInteger) row
{ {
NSArray *item; NSArray *item;
int col; int col;
if (table_apps == nil) if (table_apps == nil) return nil;
return nil;
col = [[tableColumn identifier] intValue]; col = [[tableColumn identifier] intValue];
@ -520,15 +548,13 @@ tableColumn row:(NSInteger) row
return @""; return @"";
} }
-(void) tableView:(NSTableView *) - (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
tableView setObjectValue:(id) object forTableColumn:(NSTableColumn *) forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
tableColumn row:(NSInteger) row
{ {
NSMutableArray *item; NSMutableArray *item;
int col; int col;
if (table_apps == nil) if (table_apps == nil) return;
return;
col = [[tableColumn identifier] intValue]; col = [[tableColumn identifier] intValue];
@ -536,52 +562,60 @@ tableColumn row:(NSInteger) row
[item replaceObjectAtIndex:col withObject:object]; [item replaceObjectAtIndex:col withObject:object];
} }
-(void) hide_window:sender { - (void) hide_window:sender
{
if ([X11App x_active]) if ([X11App x_active])
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideWindow); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideWindow);
else else
NSBeep(); /* FIXME: something here */ NSBeep(); /* FIXME: something here */
} }
-(IBAction) bring_to_front:sender { - (IBAction)bring_to_front:sender
{
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMBringAllToFront); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
} }
-(IBAction) close_window:sender { - (IBAction)close_window:sender
{
if ([X11App x_active]) if ([X11App x_active])
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMCloseWindow); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMCloseWindow);
else else
[[NSApp keyWindow] performClose:sender]; [[NSApp keyWindow] performClose:sender];
} }
-(IBAction) minimize_window:sender { - (IBAction)minimize_window:sender
{
if ([X11App x_active]) if ([X11App x_active])
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMMinimizeWindow); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
else else
[[NSApp keyWindow] performMiniaturize:sender]; [[NSApp keyWindow] performMiniaturize:sender];
} }
-(IBAction) zoom_window:sender { - (IBAction)zoom_window:sender
{
if ([X11App x_active]) if ([X11App x_active])
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMZoomWindow); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMZoomWindow);
else else
[[NSApp keyWindow] performZoom:sender]; [[NSApp keyWindow] performZoom:sender];
} }
-(IBAction) next_window:sender { - (IBAction) next_window:sender
{
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMNextWindow); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMNextWindow);
} }
-(IBAction) previous_window:sender { - (IBAction) previous_window:sender
{
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMPreviousWindow); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMPreviousWindow);
} }
-(IBAction) enable_fullscreen_changed:sender { - (IBAction) enable_fullscreen_changed:sender
{
XQuartzRootlessDefault = ![enable_fullscreen intValue]; XQuartzRootlessDefault = ![enable_fullscreen intValue];
[enable_fullscreen_menu setEnabled:!XQuartzRootlessDefault]; [enable_fullscreen_menu setEnabled:!XQuartzRootlessDefault];
[enable_fullscreen_menu_text setTextColor:XQuartzRootlessDefault ?[NSColor disabledControlTextColor] :[NSColor [enable_fullscreen_menu_text setTextColor:XQuartzRootlessDefault ?[
controlTextColor]]; NSColor disabledControlTextColor] : [NSColor controlTextColor]];
DarwinSendDDXEvent(kXquartzSetRootless, 1, XQuartzRootlessDefault); DarwinSendDDXEvent(kXquartzSetRootless, 1, XQuartzRootlessDefault);
@ -589,15 +623,18 @@ tableColumn row:(NSInteger) row
[NSApp prefs_synchronize]; [NSApp prefs_synchronize];
} }
-(IBAction) toggle_fullscreen:sender { - (IBAction) toggle_fullscreen:sender
{
DarwinSendDDXEvent(kXquartzToggleFullscreen, 0); DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
} }
-(void) set_can_quit:(OSX_BOOL) state { - (void) set_can_quit:(OSX_BOOL)state
{
can_quit = state; can_quit = state;
} }
-(IBAction) prefs_changed:sender { - (IBAction)prefs_changed:sender
{
if (!sender) if (!sender)
return; return;
@ -607,7 +644,8 @@ tableColumn row:(NSInteger) row
} }
else if (sender == enable_keyequivs) { else if (sender == enable_keyequivs) {
XQuartzEnableKeyEquivalents = [enable_keyequivs intValue]; XQuartzEnableKeyEquivalents = [enable_keyequivs intValue];
[NSApp prefs_set_boolean: @PREFS_KEYEQUIVS value:XQuartzEnableKeyEquivalents]; [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:
XQuartzEnableKeyEquivalents];
} }
else if (sender == sync_keymap) { else if (sender == sync_keymap) {
darwinSyncKeymap = [sync_keymap intValue]; darwinSyncKeymap = [sync_keymap intValue];
@ -615,13 +653,15 @@ tableColumn row:(NSInteger) row
} }
else if (sender == enable_fullscreen_menu) { else if (sender == enable_fullscreen_menu) {
XQuartzFullscreenMenu = [enable_fullscreen_menu intValue]; XQuartzFullscreenMenu = [enable_fullscreen_menu intValue];
[NSApp prefs_set_boolean: @PREFS_FULLSCREEN_MENU value:XQuartzFullscreenMenu]; [NSApp prefs_set_boolean:@PREFS_FULLSCREEN_MENU value:
XQuartzFullscreenMenu];
} }
else if (sender == option_sends_alt) { else if (sender == option_sends_alt) {
BOOL prev_opt_sends_alt = XQuartzOptionSendsAlt; BOOL prev_opt_sends_alt = XQuartzOptionSendsAlt;
XQuartzOptionSendsAlt = [option_sends_alt intValue]; XQuartzOptionSendsAlt = [option_sends_alt intValue];
[NSApp prefs_set_boolean: @PREFS_OPTION_SENDS_ALT value:XQuartzOptionSendsAlt]; [NSApp prefs_set_boolean:@PREFS_OPTION_SENDS_ALT value:
XQuartzOptionSendsAlt];
if (prev_opt_sends_alt != XQuartzOptionSendsAlt) if (prev_opt_sends_alt != XQuartzOptionSendsAlt)
QuartsResyncKeymap(TRUE); QuartsResyncKeymap(TRUE);
@ -635,12 +675,12 @@ tableColumn row:(NSInteger) row
intValue]]; intValue]];
} }
else if (sender == focus_on_new_window) { else if (sender == focus_on_new_window) {
[NSApp prefs_set_boolean: @PREFS_FOCUS_ON_NEW_WINDOW value:[focus_on_new_window [NSApp prefs_set_boolean:@PREFS_FOCUS_ON_NEW_WINDOW value:[
intValue]]; focus_on_new_window intValue]];
} }
else if (sender == enable_auth) { else if (sender == enable_auth) {
[NSApp prefs_set_boolean: @PREFS_NO_AUTH value:![enable_auth [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]
intValue]]; ];
} }
else if (sender == enable_tcp) { else if (sender == enable_tcp) {
[NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]]; [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
@ -650,7 +690,6 @@ tableColumn row:(NSInteger) row
} }
else if (sender == sync_pasteboard) { else if (sender == sync_pasteboard) {
BOOL pbproxy_active = [sync_pasteboard intValue]; BOOL pbproxy_active = [sync_pasteboard intValue];
[NSApp prefs_set_boolean:@PREFS_SYNC_PB value:pbproxy_active]; [NSApp prefs_set_boolean:@PREFS_SYNC_PB value:pbproxy_active];
[sync_pasteboard_to_clipboard setEnabled:pbproxy_active]; [sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
@ -659,30 +698,32 @@ tableColumn row:(NSInteger) row
[sync_primary_immediately setEnabled:pbproxy_active]; [sync_primary_immediately setEnabled:pbproxy_active];
// setEnabled doesn't do this... // setEnabled doesn't do this...
[sync_text1 setTextColor:pbproxy_active ?[NSColor controlTextColor] :[NSColor [sync_text1 setTextColor:pbproxy_active ?[NSColor controlTextColor] :
disabledControlTextColor]]; [NSColor disabledControlTextColor]];
[sync_text2 setTextColor:pbproxy_active ?[NSColor controlTextColor] :[NSColor [sync_text2 setTextColor:pbproxy_active ?[NSColor controlTextColor] :
disabledControlTextColor]]; [NSColor disabledControlTextColor]];
} }
else if (sender == sync_pasteboard_to_clipboard) { else if (sender == sync_pasteboard_to_clipboard) {
[NSApp prefs_set_boolean: @PREFS_SYNC_PB_TO_CLIPBOARD value:[sync_pasteboard_to_clipboard [NSApp prefs_set_boolean:@PREFS_SYNC_PB_TO_CLIPBOARD value:[
intValue]]; sync_pasteboard_to_clipboard intValue]];
} }
else if (sender == sync_pasteboard_to_primary) { else if (sender == sync_pasteboard_to_primary) {
[NSApp prefs_set_boolean: @PREFS_SYNC_PB_TO_PRIMARY value:[sync_pasteboard_to_primary [NSApp prefs_set_boolean:@PREFS_SYNC_PB_TO_PRIMARY value:[
intValue]]; sync_pasteboard_to_primary intValue]];
} }
else if (sender == sync_clipboard_to_pasteboard) { else if (sender == sync_clipboard_to_pasteboard) {
[NSApp prefs_set_boolean: @PREFS_SYNC_CLIPBOARD_TO_PB value:[sync_clipboard_to_pasteboard [NSApp prefs_set_boolean:@PREFS_SYNC_CLIPBOARD_TO_PB value:[
intValue]]; sync_clipboard_to_pasteboard intValue]];
} }
else if (sender == sync_primary_immediately) { else if (sender == sync_primary_immediately) {
[NSApp prefs_set_boolean: @PREFS_SYNC_PRIMARY_ON_SELECT value:[sync_primary_immediately [NSApp prefs_set_boolean:@PREFS_SYNC_PRIMARY_ON_SELECT value:[
intValue]]; sync_primary_immediately intValue]];
} }
else if (sender == scroll_in_device_direction) { else if (sender == scroll_in_device_direction) {
XQuartzScrollInDeviceDirection =[scroll_in_device_direction intValue]; XQuartzScrollInDeviceDirection =
[NSApp prefs_set_boolean: @PREFS_SCROLL_IN_DEV_DIRECTION value:XQuartzScrollInDeviceDirection]; [scroll_in_device_direction intValue];
[NSApp prefs_set_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION value:
XQuartzScrollInDeviceDirection];
} }
[NSApp prefs_synchronize]; [NSApp prefs_synchronize];
@ -690,9 +731,10 @@ tableColumn row:(NSInteger) row
DarwinSendDDXEvent(kXquartzReloadPreferences, 0); DarwinSendDDXEvent(kXquartzReloadPreferences, 0);
} }
-(IBAction) prefs_show:sender { - (IBAction) prefs_show:sender
BOOL pbproxy_active =[NSApp prefs_get_boolean: @PREFS_SYNC_PB default: {
YES]; BOOL pbproxy_active =
[NSApp prefs_get_boolean:@PREFS_SYNC_PB default:YES];
// Remove preferences from the GUI which are not supported // Remove preferences from the GUI which are not supported
// TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined // TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
@ -701,37 +743,45 @@ YES];
scroll_in_device_direction = nil; scroll_in_device_direction = nil;
} }
else { else {
[scroll_in_device_direction setIntValue:XQuartzScrollInDeviceDirection]; [scroll_in_device_direction setIntValue:
XQuartzScrollInDeviceDirection];
} }
[fake_buttons setIntValue:darwinFakeButtons]; [fake_buttons setIntValue:darwinFakeButtons];
[enable_keyequivs setIntValue:XQuartzEnableKeyEquivalents]; [enable_keyequivs setIntValue:XQuartzEnableKeyEquivalents];
[sync_keymap setIntValue:darwinSyncKeymap]; [sync_keymap setIntValue:darwinSyncKeymap];
[option_sends_alt setIntValue:XQuartzOptionSendsAlt]; [option_sends_alt setIntValue:XQuartzOptionSendsAlt];
[click_through setIntValue: [NSApp prefs_get_boolean: @PREFS_CLICK_THROUGH default: [click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_CLICK_THROUGH
NO]]; default:NO]];
[focus_follows_mouse setIntValue: [NSApp prefs_get_boolean: @PREFS_FFM default: [focus_follows_mouse setIntValue:[NSApp prefs_get_boolean:@PREFS_FFM
NO]]; default:NO]];
[focus_on_new_window setIntValue: [NSApp prefs_get_boolean: @PREFS_FOCUS_ON_NEW_WINDOW default: [focus_on_new_window setIntValue:[NSApp prefs_get_boolean:
YES]]; @PREFS_FOCUS_ON_NEW_WINDOW default:YES]
];
[enable_auth setIntValue: ![NSApp prefs_get_boolean: @PREFS_NO_AUTH default: [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default
NO]]; :NO]];
[enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default: [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:
NO]]; NO]];
[depth selectItemAtIndex: [depth indexOfItemWithTag: [NSApp prefs_get_integer: @PREFS_DEPTH default: [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp
prefs_get_integer:
@PREFS_DEPTH default:
-1]]]; -1]]];
[sync_pasteboard setIntValue:pbproxy_active]; [sync_pasteboard setIntValue:pbproxy_active];
[sync_pasteboard_to_clipboard setIntValue: [NSApp prefs_get_boolean: @PREFS_SYNC_PB_TO_CLIPBOARD default: [sync_pasteboard_to_clipboard setIntValue:[NSApp prefs_get_boolean:
YES]]; @PREFS_SYNC_PB_TO_CLIPBOARD
[sync_pasteboard_to_primary setIntValue: [NSApp prefs_get_boolean: @PREFS_SYNC_PB_TO_PRIMARY default: default:YES]];
YES]]; [sync_pasteboard_to_primary setIntValue:[NSApp prefs_get_boolean:
[sync_clipboard_to_pasteboard setIntValue: [NSApp prefs_get_boolean: @PREFS_SYNC_CLIPBOARD_TO_PB default: @PREFS_SYNC_PB_TO_PRIMARY
YES]]; default:YES]];
[sync_primary_immediately setIntValue: [NSApp prefs_get_boolean: @PREFS_SYNC_PRIMARY_ON_SELECT default: [sync_clipboard_to_pasteboard setIntValue:[NSApp prefs_get_boolean:
NO]]; @PREFS_SYNC_CLIPBOARD_TO_PB
default:YES]];
[sync_primary_immediately setIntValue:[NSApp prefs_get_boolean:
@PREFS_SYNC_PRIMARY_ON_SELECT
default:NO]];
[sync_pasteboard_to_clipboard setEnabled:pbproxy_active]; [sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
[sync_pasteboard_to_primary setEnabled:pbproxy_active]; [sync_pasteboard_to_primary setEnabled:pbproxy_active];
@ -739,34 +789,38 @@ NO]];
[sync_primary_immediately setEnabled:pbproxy_active]; [sync_primary_immediately setEnabled:pbproxy_active];
// setEnabled doesn't do this... // setEnabled doesn't do this...
[sync_text1 setTextColor:pbproxy_active ?[NSColor controlTextColor] :[NSColor [sync_text1 setTextColor:pbproxy_active ?[NSColor controlTextColor] : [
disabledControlTextColor]]; NSColor disabledControlTextColor]];
[sync_text2 setTextColor:pbproxy_active ?[NSColor controlTextColor] :[NSColor [sync_text2 setTextColor:pbproxy_active ?[NSColor controlTextColor] : [
disabledControlTextColor]]; NSColor disabledControlTextColor]];
[enable_fullscreen setIntValue:!XQuartzRootlessDefault]; [enable_fullscreen setIntValue:!XQuartzRootlessDefault];
[enable_fullscreen_menu setIntValue:XQuartzFullscreenMenu]; [enable_fullscreen_menu setIntValue:XQuartzFullscreenMenu];
[enable_fullscreen_menu setEnabled:!XQuartzRootlessDefault]; [enable_fullscreen_menu setEnabled:!XQuartzRootlessDefault];
[enable_fullscreen_menu_text setTextColor:XQuartzRootlessDefault ?[NSColor disabledControlTextColor] :[NSColor [enable_fullscreen_menu_text setTextColor:XQuartzRootlessDefault ?[
controlTextColor]]; NSColor disabledControlTextColor] : [NSColor controlTextColor]];
[prefs_panel makeKeyAndOrderFront:sender]; [prefs_panel makeKeyAndOrderFront:sender];
} }
-(IBAction) quit:sender { - (IBAction) quit:sender
{
DarwinSendDDXEvent(kXquartzQuit, 0); DarwinSendDDXEvent(kXquartzQuit, 0);
} }
-(IBAction) x11_help:sender { - (IBAction) x11_help:sender
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
AHLookupAnchor((CFStringRef) NSLocalizedString(@"Mac Help", no comment), AHLookupAnchor((CFStringRef)NSLocalizedString(@"Mac Help",
no comment),
CFSTR("mchlp2276")); CFSTR("mchlp2276"));
#else #else
AHLookupAnchor(CFSTR("com.apple.machelp"), CFSTR("mchlp2276")); AHLookupAnchor(CFSTR("com.apple.machelp"), CFSTR("mchlp2276"));
#endif #endif
} }
-(OSX_BOOL) validateMenuItem:(NSMenuItem *) item { - (OSX_BOOL) validateMenuItem:(NSMenuItem *)item
{
NSMenu *menu = [item menu]; NSMenu *menu = [item menu];
if (item == toggle_fullscreen_item) if (item == toggle_fullscreen_item)
@ -778,7 +832,8 @@ NO]];
return TRUE; return TRUE;
} }
-(void) applicationDidHide:(NSNotification *) notify { - (void) applicationDidHide:(NSNotification *)notify
{
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideAll); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideAll);
/* Toggle off fullscreen mode to leave our non-default video /* Toggle off fullscreen mode to leave our non-default video
@ -789,27 +844,27 @@ NO]];
} }
} }
-(void) applicationDidUnhide:(NSNotification *) notify { - (void) applicationDidUnhide:(NSNotification *)notify
{
DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMShowAll); DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMShowAll);
} }
-(NSApplicationTerminateReply) applicationShouldTerminate:sender { - (NSApplicationTerminateReply) applicationShouldTerminate:sender
{
NSString *msg; NSString *msg;
NSString *title; NSString *title;
if (can_quit ||[X11App prefs_get_boolean: @PREFS_NO_QUIT_ALERT default: if (can_quit ||
NO]) [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
return NSTerminateNow; return NSTerminateNow;
/* Make sure we're frontmost. */ /* Make sure we're frontmost. */
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
title = title = NSLocalizedString(@"Do you really want to quit X11?",
NSLocalizedString(@"Do you really want to quit X11?",
@"Dialog title when quitting"); @"Dialog title when quitting");
msg = msg = NSLocalizedString(
NSLocalizedString @"Any open X11 applications will stop immediately, and you will lose any unsaved changes.",
(@"Any open X11 applications will stop immediately, and you will lose any unsaved changes.",
@"Dialog when quitting"); @"Dialog when quitting");
/* FIXME: safe to run the alert in here? Or should we return Later /* FIXME: safe to run the alert in here? Or should we return Later
@ -821,9 +876,9 @@ NO])
== NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel; == NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
} }
-(void) applicationWillTerminate:(NSNotification *) aNotification { - (void) applicationWillTerminate:(NSNotification *)aNotification
{
unsigned remain; unsigned remain;
[X11App prefs_synchronize]; [X11App prefs_synchronize];
/* shutdown the X server, it will exit () for us. */ /* shutdown the X server, it will exit () for us. */
@ -836,14 +891,14 @@ NO])
exit(1); exit(1);
} }
-(void) server_ready { - (void) server_ready
{
x_list *node; x_list *node;
finished_launching = YES; finished_launching = YES;
for (node = pending_apps; node != NULL; node = node->next) { for (node = pending_apps; node != NULL; node = node->next) {
NSString *filename = node->data; NSString *filename = node->data;
[self launch_client:filename]; [self launch_client:filename];
[filename release]; [filename release];
} }
@ -852,8 +907,7 @@ NO])
pending_apps = NULL; pending_apps = NULL;
} }
-(OSX_BOOL) application:(NSApplication *) - (OSX_BOOL) application:(NSApplication *)app openFile:(NSString *)filename
app openFile:(NSString *) filename
{ {
const char *name = [filename UTF8String]; const char *name = [filename UTF8String];
@ -866,7 +920,9 @@ app openFile:(NSString *) filename
return YES; return YES;
} }
@end void @end
void
X11ControllerMain(int argc, char **argv, char **envp) X11ControllerMain(int argc, char **argv, char **envp)
{ {
X11ApplicationMain(argc, argv, envp); X11ApplicationMain(argc, argv, envp);

View File

@ -1,29 +1,32 @@
/************************************************************************** /*
* Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
Copyright (c) 2002-2007 Apple Inc. All Rights Reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved. *
* Permission is hereby granted, free of charge, to any person
Permission is hereby granted, free of charge, to any person obtaining a * obtaining a copy of this software and associated documentation files
copy of this software and associated documentation files (the * (the "Software"), to deal in the Software without restriction,
"Software"), to deal in the Software without restriction, including * including without limitation the rights to use, copy, modify, merge,
without limitation the rights to use, copy, modify, merge, publish, * publish, distribute, sublicense, and/or sell copies of the Software,
distribute, sub license, and/or sell copies of the Software, and to * and to permit persons to whom the Software is furnished to do so,
permit persons to whom the Software is furnished to do so, subject to * subject to the following conditions:
the following conditions: *
* The above copyright notice and this permission notice shall be
The above copyright notice and this permission notice (including the * included in all copies or substantial portions of the Software.
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
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* Except as contained in this notice, the name(s) of the above
**************************************************************************/ * copyright holders shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without
* prior written authorization.
*/
#include "sanitizedCarbon.h" #include "sanitizedCarbon.h"
@ -98,7 +101,6 @@ static inline BoxRec
make_box(int x, int y, int w, int h) make_box(int x, int y, int w, int h)
{ {
BoxRec r; BoxRec r;
r.x1 = x; r.x1 = x;
r.y1 = y; r.y1 = y;
r.x2 = x + w; r.x2 = x + w;
@ -158,7 +160,7 @@ ProcAppleWMQueryVersion(register ClientPtr client)
WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep); WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
return Success; return Success;
} }
/* events */ /* events */
static inline void static inline void
@ -171,7 +173,8 @@ updateEventMask(WMEventPtr * pHead)
eventMask |= pCur->mask; eventMask |= pCur->mask;
} }
/*ARGSUSED*/ static int /*ARGSUSED*/
static int
WMFreeClient(pointer data, XID id) WMFreeClient(pointer data, XID id)
{ {
WMEventPtr pEvent; WMEventPtr pEvent;
@ -179,10 +182,10 @@ WMFreeClient(pointer data, XID id)
int i; int i;
pEvent = (WMEventPtr)data; pEvent = (WMEventPtr)data;
i = dixLookupResourceByType((pointer *) &pHead, eventResource, EventType, i = dixLookupResourceByType(
serverClient, (pointer *)&pHead, eventResource, EventType, serverClient,
DixReadAccess | DixWriteAccess | DixReadAccess |
DixDestroyAccess); DixWriteAccess | DixDestroyAccess);
if (i == Success && pHead) { if (i == Success && pHead) {
pPrev = 0; pPrev = 0;
for (pCur = *pHead; pCur && pCur != pEvent; pCur = pCur->next) for (pCur = *pHead; pCur && pCur != pEvent; pCur = pCur->next)
@ -199,7 +202,8 @@ WMFreeClient(pointer data, XID id)
return 1; return 1;
} }
/*ARGSUSED*/ static int /*ARGSUSED*/
static int
WMFreeEvents(pointer data, XID id) WMFreeEvents(pointer data, XID id)
{ {
WMEventPtr *pHead, pCur, pNext; WMEventPtr *pHead, pCur, pNext;
@ -224,8 +228,10 @@ ProcAppleWMSelectInput(register ClientPtr client)
int i; int i;
REQUEST_SIZE_MATCH(xAppleWMSelectInputReq); REQUEST_SIZE_MATCH(xAppleWMSelectInputReq);
i = dixLookupResourceByType((pointer *) &pHead, eventResource, EventType, i =
client, DixWriteAccess); dixLookupResourceByType((pointer *)&pHead, eventResource, EventType,
client,
DixWriteAccess);
if (stuff->mask != 0) { if (stuff->mask != 0) {
if (i == Success && pHead) { if (i == Success && pHead) {
/* check for existing entry. */ /* check for existing entry. */
@ -310,8 +316,10 @@ AppleWMSendEvent(int type, unsigned int mask, int which, int arg)
xAppleWMNotifyEvent se; xAppleWMNotifyEvent se;
int i; int i;
i = dixLookupResourceByType((pointer *) &pHead, eventResource, EventType, i =
serverClient, DixReadAccess); dixLookupResourceByType((pointer *)&pHead, eventResource, EventType,
serverClient,
DixReadAccess);
if (i != Success || !pHead) if (i != Success || !pHead)
return; return;
for (pEvent = *pHead; pEvent; pEvent = pEvent->next) { for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
@ -331,7 +339,7 @@ AppleWMSelectedEvents(void)
{ {
return eventMask; return eventMask;
} }
/* general utility functions */ /* general utility functions */
static int static int
@ -353,7 +361,7 @@ ProcAppleWMReenableUpdate(register ClientPtr client)
return Success; return Success;
} }
/* window functions */ /* window functions */
static int static int
@ -362,7 +370,6 @@ ProcAppleWMSetWindowMenu(register ClientPtr client)
const char *bytes, **items; const char *bytes, **items;
char *shortcuts; char *shortcuts;
int max_len, nitems, i, j; int max_len, nitems, i, j;
REQUEST(xAppleWMSetWindowMenuReq); REQUEST(xAppleWMSetWindowMenuReq);
REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq); REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
@ -378,7 +385,8 @@ ProcAppleWMSetWindowMenu(register ClientPtr client)
shortcuts[j] = bytes[i++]; shortcuts[j] = bytes[i++];
items[j++] = bytes + i; items[j++] = bytes + i;
while (i < max_len) { while (i < max_len)
{
if (bytes[i++] == 0) if (bytes[i++] == 0)
break; break;
} }
@ -418,7 +426,8 @@ ProcAppleWMSetWindowLevel(register ClientPtr client)
REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq); REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
if (Success != dixLookupWindow(&pWin, stuff->window, client, DixReadAccess)) if (Success != dixLookupWindow(&pWin, stuff->window, client,
DixReadAccess))
return BadValue; return BadValue;
if (stuff->level >= AppleWMNumWindowLevels) { if (stuff->level >= AppleWMNumWindowLevels) {
@ -456,7 +465,6 @@ static int
ProcAppleWMAttachTransient(register ClientPtr client) ProcAppleWMAttachTransient(register ClientPtr client)
{ {
WindowPtr pWinChild, pWinParent; WindowPtr pWinChild, pWinParent;
REQUEST(xAppleWMAttachTransientReq); REQUEST(xAppleWMAttachTransientReq);
int err; int err;
@ -496,7 +504,7 @@ ProcAppleWMSetCanQuit(register ClientPtr client)
X11ApplicationSetCanQuit(stuff->state); X11ApplicationSetCanQuit(stuff->state);
return Success; return Success;
} }
/* frame functions */ /* frame functions */
static int static int
@ -504,7 +512,6 @@ ProcAppleWMFrameGetRect(register ClientPtr client)
{ {
xAppleWMFrameGetRectReply rep; xAppleWMFrameGetRectReply rep;
BoxRec ir, or, rr; BoxRec ir, or, rr;
REQUEST(xAppleWMFrameGetRectReq); REQUEST(xAppleWMFrameGetRectReq);
REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq); REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
@ -536,7 +543,6 @@ ProcAppleWMFrameHitTest(register ClientPtr client)
xAppleWMFrameHitTestReply rep; xAppleWMFrameHitTestReply rep;
BoxRec ir, or; BoxRec ir, or;
int ret; int ret;
REQUEST(xAppleWMFrameHitTestReq); REQUEST(xAppleWMFrameHitTestReq);
REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq); REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
@ -564,13 +570,13 @@ ProcAppleWMFrameDraw(register ClientPtr client)
BoxRec ir, or; BoxRec ir, or;
unsigned int title_length, title_max; unsigned int title_length, title_max;
unsigned char *title_bytes; unsigned char *title_bytes;
REQUEST(xAppleWMFrameDrawReq); REQUEST(xAppleWMFrameDrawReq);
WindowPtr pWin; WindowPtr pWin;
REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq); REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
if (Success != dixLookupWindow(&pWin, stuff->window, client, DixReadAccess)) if (Success != dixLookupWindow(&pWin, stuff->window, client,
DixReadAccess))
return BadValue; return BadValue;
ir = make_box(stuff->ix, stuff->iy, stuff->iw, stuff->ih); ir = make_box(stuff->ix, stuff->iy, stuff->iw, stuff->ih);
@ -593,7 +599,7 @@ ProcAppleWMFrameDraw(register ClientPtr client)
return Success; return Success;
} }
/* dispatch */ /* dispatch */
static int static int
@ -612,30 +618,43 @@ ProcAppleWMDispatch(register ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_AppleWMSelectInput: case X_AppleWMSelectInput:
return ProcAppleWMSelectInput(client); return ProcAppleWMSelectInput(client);
case X_AppleWMDisableUpdate: case X_AppleWMDisableUpdate:
return ProcAppleWMDisableUpdate(client); return ProcAppleWMDisableUpdate(client);
case X_AppleWMReenableUpdate: case X_AppleWMReenableUpdate:
return ProcAppleWMReenableUpdate(client); return ProcAppleWMReenableUpdate(client);
case X_AppleWMSetWindowMenu: case X_AppleWMSetWindowMenu:
return ProcAppleWMSetWindowMenu(client); return ProcAppleWMSetWindowMenu(client);
case X_AppleWMSetWindowMenuCheck: case X_AppleWMSetWindowMenuCheck:
return ProcAppleWMSetWindowMenuCheck(client); return ProcAppleWMSetWindowMenuCheck(client);
case X_AppleWMSetFrontProcess: case X_AppleWMSetFrontProcess:
return ProcAppleWMSetFrontProcess(client); return ProcAppleWMSetFrontProcess(client);
case X_AppleWMSetWindowLevel: case X_AppleWMSetWindowLevel:
return ProcAppleWMSetWindowLevel(client); return ProcAppleWMSetWindowLevel(client);
case X_AppleWMSetCanQuit: case X_AppleWMSetCanQuit:
return ProcAppleWMSetCanQuit(client); return ProcAppleWMSetCanQuit(client);
case X_AppleWMFrameGetRect: case X_AppleWMFrameGetRect:
return ProcAppleWMFrameGetRect(client); return ProcAppleWMFrameGetRect(client);
case X_AppleWMFrameHitTest: case X_AppleWMFrameHitTest:
return ProcAppleWMFrameHitTest(client); return ProcAppleWMFrameHitTest(client);
case X_AppleWMFrameDraw: case X_AppleWMFrameDraw:
return ProcAppleWMFrameDraw(client); return ProcAppleWMFrameDraw(client);
case X_AppleWMSendPSN: case X_AppleWMSendPSN:
return ProcAppleWMSendPSN(client); return ProcAppleWMSendPSN(client);
case X_AppleWMAttachTransient: case X_AppleWMAttachTransient:
return ProcAppleWMAttachTransient(client); return ProcAppleWMAttachTransient(client);
default: default:
return BadRequest; return BadRequest;
} }
@ -672,6 +691,7 @@ SProcAppleWMDispatch(register ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_AppleWMQueryVersion: case X_AppleWMQueryVersion:
return SProcAppleWMQueryVersion(client); return SProcAppleWMQueryVersion(client);
default: default:
return BadRequest; return BadRequest;
} }
@ -692,9 +712,9 @@ AppleWMExtensionInit(AppleWMProcsPtr procsPtr)
AppleWMNumberErrors, AppleWMNumberErrors,
ProcAppleWMDispatch, ProcAppleWMDispatch,
SProcAppleWMDispatch, SProcAppleWMDispatch,
NULL, StandardMinorOpcode))) { NULL,
StandardMinorOpcode))) {
size_t i; size_t i;
WMReqCode = (unsigned char)extEntry->base; WMReqCode = (unsigned char)extEntry->base;
WMErrorBase = extEntry->errorBase; WMErrorBase = extEntry->errorBase;
WMEventBase = extEntry->eventBase; WMEventBase = extEntry->eventBase;

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_ #ifndef _APPLEWMEXT_H_
#define _APPLEWMEXT_H_ #define _APPLEWMEXT_H_
@ -44,14 +45,15 @@ typedef int (*DisableUpdateProc) (void);
typedef int (*EnableUpdateProc)(void); typedef int (*EnableUpdateProc)(void);
typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level); typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class, typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class,
const BoxRec * outer, const BoxRec * inner, const BoxRec *outer,
BoxRec * ret); const BoxRec *inner, BoxRec *ret);
typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y, typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y,
const BoxRec * outer, const BoxRec * inner, const BoxRec *outer,
int *ret); const BoxRec *inner, int *ret);
typedef int (*FrameDrawProc)(WindowPtr pWin, xp_frame_class class, typedef int (*FrameDrawProc)(WindowPtr pWin, xp_frame_class class,
xp_frame_attr attr, const BoxRec * outer, xp_frame_attr attr,
const BoxRec * inner, unsigned int title_len, const BoxRec *outer, const BoxRec *inner,
unsigned int title_len,
const unsigned char *title_bytes); const unsigned char *title_bytes);
typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo); typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo);
typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent); typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent);
@ -70,19 +72,21 @@ typedef struct _AppleWMProcs {
AttachTransientProc AttachTransient; AttachTransientProc AttachTransient;
} AppleWMProcsRec, *AppleWMProcsPtr; } 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 */ , void
unsigned int /* mask */ , AppleWMSendEvent(int /* type */, unsigned int /* mask */, int /* which */,
int /* which */ ,
int /* arg */ 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 * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
@ -102,7 +103,8 @@ _read_redirect(int fd, int flush)
asl_redirect *aslr = &redirect_fds[fd]; asl_redirect *aslr = &redirect_fds[fd];
while ((nbytes = 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; char *s, *p;
/* Increment our returned number read */ /* Increment our returned number read */
@ -151,7 +153,6 @@ 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); int fd = dispatch_source_get_handle(source);
if (_read_redirect(fd, 0) == EOF) { if (_read_redirect(fd, 0) == EOF) {
dispatch_source_cancel(source); dispatch_source_cancel(source);
} }
@ -205,14 +206,16 @@ redirect_thread(void *ctx __unused)
if (fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) { if (fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
asl_log(NULL, NULL, ASL_LEVEL_ERR, asl_log(NULL, NULL, ASL_LEVEL_ERR,
"Unexpected file descriptor: %d", fd); "Unexpected file descriptor: %d",
fd);
goto next; goto next;
} }
if (ev.flags & EV_EOF) { if (ev.flags & EV_EOF) {
close_fd = 1; close_fd = 1;
if (EOF != _read_redirect(fd, 1)) { if (EOF != _read_redirect(fd, 1)) {
asl_log(NULL, NULL, ASL_LEVEL_ERR, asl_log(
NULL, NULL, ASL_LEVEL_ERR,
"kevent reported EOF on %d, but read doesn't concur.", "kevent reported EOF on %d, but read doesn't concur.",
fd); fd);
} }
@ -237,7 +240,8 @@ redirect_thread(void *ctx __unused)
return NULL; return NULL;
default: default:
;; ;
;
} }
} }
@ -263,8 +267,8 @@ redirect_atexit(void)
/* Wait at least three seconds for our sources to flush to ASL */ /* Wait at least three seconds for our sources to flush to ASL */
dispatch_group_wait(read_source_group, dispatch_group_wait(read_source_group,
dispatch_time(DISPATCH_TIME_NOW, dispatch_time(DISPATCH_TIME_NOW, 3LL *
3LL * NSEC_PER_SEC)); NSEC_PER_SEC));
} }
#else #else
{ {
@ -299,7 +303,8 @@ xq_asl_init(void)
assert(read_source_group != NULL); assert(read_source_group != NULL);
#else #else
assert((kq = kqueue()) != -1); 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 #endif
atexit(redirect_atexit); atexit(redirect_atexit);
@ -311,12 +316,10 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
int err __block = 0; int err __block = 0;
static dispatch_once_t once_control; static dispatch_once_t once_control;
dispatch_once_f(&once_control, NULL, xq_asl_init); dispatch_once_f(&once_control, NULL, xq_asl_init);
#else #else
int err = 0; int err = 0;
static pthread_once_t once_control = PTHREAD_ONCE_INIT; static pthread_once_t once_control = PTHREAD_ONCE_INIT;
assert(pthread_once(&once_control, xq_asl_init) == 0); assert(pthread_once(&once_control, xq_asl_init) == 0);
#endif #endif
@ -335,13 +338,15 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
if (fd >= n_redirect_fds) { if (fd >= n_redirect_fds) {
size_t new_n = 1 << (ffs(fd) + 1); size_t new_n = 1 << (ffs(fd) + 1);
asl_redirect *new_array = asl_redirect *new_array =
realloc(redirect_fds, new_n * sizeof(*redirect_fds)); realloc(redirect_fds, new_n *
sizeof(*redirect_fds));
if (!new_array) { if (!new_array) {
err = errno; err = errno;
BLOCK_DONE; BLOCK_DONE;
} }
redirect_fds = new_array; redirect_fds = new_array;
memset(redirect_fds + n_redirect_fds, 0, new_n - n_redirect_fds); memset(redirect_fds + n_redirect_fds, 0, new_n -
n_redirect_fds);
n_redirect_fds = new_n; n_redirect_fds = new_n;
} }
@ -365,25 +370,28 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
redirect_fds[fd].msg = msg; redirect_fds[fd].msg = msg;
/* Don't block on reads from this fd */ /* Don't block on reads from this fd */
fcntl(fd, F_SETFL, O_NONBLOCK); fcntl(fd, F_SETFL,
O_NONBLOCK);
/* Start listening */ /* Start listening */
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
{ {
dispatch_source_t read_source = dispatch_source_t read_source =
dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, dispatch_source_create(
DISPATCH_SOURCE_TYPE_READ, fd, 0,
redirect_serial_q); redirect_serial_q);
redirect_fds[fd].read_source = read_source; redirect_fds[fd].read_source = read_source;
dispatch_set_context(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_event_handler_f(read_source,
dispatch_source_set_cancel_handler_f(read_source, cancel_source); read_from_source);
dispatch_source_set_cancel_handler_f(read_source,
cancel_source);
dispatch_group_enter(read_source_group); dispatch_group_enter(read_source_group);
dispatch_resume(read_source); dispatch_resume(read_source);
} }
#else #else
{ {
struct kevent ev; struct kevent ev;
EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0); EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
kevent(kq, &ev, 1, NULL, 0, NULL); kevent(kq, &ev, 1, NULL, 0, NULL);
} }

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 * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files * 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 /* The given fd is replaced with a pipe. Anything written to it will will be
* logged to ASL. * 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 /* 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. * 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 #endif

View File

@ -2,7 +2,7 @@
* *
* Xquartz initialization code * 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. * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -84,7 +84,8 @@ aslclient aslc;
void void
xq_asl_log(int level, const char *subsystem, const char *file, 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; va_list args;
aslmsg msg = asl_new(ASL_TYPE_MSG); aslmsg msg = asl_new(ASL_TYPE_MSG);
@ -119,7 +120,6 @@ DevPrivateKeyRec darwinScreenKeyRec;
io_connect_t darwinParamConnect = 0; io_connect_t darwinParamConnect = 0;
int darwinEventReadFD = -1; int darwinEventReadFD = -1;
int darwinEventWriteFD = -1; int darwinEventWriteFD = -1;
// int darwinMouseAccelChange = 1; // int darwinMouseAccelChange = 1;
int darwinFakeButtons = 0; int darwinFakeButtons = 0;
@ -163,7 +163,6 @@ static PixmapFormatRec formats[] = {
{ 24, 32, BITMAP_SCANLINE_PAD }, { 24, 32, BITMAP_SCANLINE_PAD },
{ 32, 32, BITMAP_SCANLINE_PAD } { 32, 32, BITMAP_SCANLINE_PAD }
}; };
const int NUMFORMATS = sizeof(formats) / sizeof(formats[0]); const int NUMFORMATS = sizeof(formats) / sizeof(formats[0]);
void void
@ -182,12 +181,9 @@ static Bool
DarwinSaveScreen(ScreenPtr pScreen, int on) DarwinSaveScreen(ScreenPtr pScreen, int on)
{ {
// FIXME // FIXME
if (on == SCREEN_SAVER_FORCER) { if (on == SCREEN_SAVER_FORCER) {}
} else if (on == SCREEN_SAVER_ON) {}
else if (on == SCREEN_SAVER_ON) { else {}
}
else {
}
return TRUE; return TRUE;
} }
@ -239,11 +235,13 @@ DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
// miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0); // miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
if (dfb->depth > 15) if (dfb->depth > 15)
miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor, 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)); BM_ARGB(0, 5, 5, 5));
if (dfb->depth > 24) if (dfb->depth > 24)
miSetVisualTypesAndMasks(24, TrueColorMask, 8, TrueColor, 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)); BM_ARGB(0, 8, 8, 8));
miSetPixmapDepths(); miSetPixmapDepths();
@ -256,12 +254,12 @@ DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
dpi = 96; dpi = 96;
// initialize fb // initialize fb
if (!fbScreenInit(pScreen, dfb->framebuffer, // pointer to screen bitmap if (!fbScreenInit(pScreen,
dfb->framebuffer, // pointer to screen bitmap
dfb->width, dfb->height, // screen size in pixels dfb->width, dfb->height, // screen size in pixels
dpi, dpi, // dots per inch dpi, dpi, // dots per inch
dfb->pitch / (dfb->bitsPerPixel / 8), // pixel width of framebuffer dfb->pitch / (dfb->bitsPerPixel / 8), // pixel width of framebuffer
dfb->bitsPerPixel)) // bits per pixel for screen dfb->bitsPerPixel)) { // bits per pixel for screen
{
return FALSE; return FALSE;
} }
@ -336,16 +334,21 @@ DarwinMouseProc(DeviceIntPtr pPointer, int what)
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS, InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
btn_labels, btn_labels,
(PtrCtrlProcPtr)NoopDDA, (PtrCtrlProcPtr)NoopDDA,
GetMotionHistorySize(), NAXES, axes_labels); GetMotionHistorySize(), NAXES,
axes_labels);
InitValuatorAxisStruct(pPointer, 0, axes_labels[0], NO_AXIS_LIMITS, 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, InitValuatorAxisStruct(pPointer, 1, axes_labels[1], NO_AXIS_LIMITS,
NO_AXIS_LIMITS, 1, 0, 1, Relative); NO_AXIS_LIMITS, 1, 0, 1,
Relative);
break; break;
case DEVICE_ON: case DEVICE_ON:
pPointer->public.on = TRUE; pPointer->public.on = TRUE;
AddEnabledDevice(darwinEventReadFD); AddEnabledDevice(darwinEventReadFD);
return Success; return Success;
case DEVICE_CLOSE: case DEVICE_CLOSE:
case DEVICE_OFF: case DEVICE_OFF:
pPointer->public.on = FALSE; pPointer->public.on = FALSE;
@ -385,27 +388,35 @@ DarwinTabletProc(DeviceIntPtr pPointer, int what)
InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS, InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
btn_labels, btn_labels,
(PtrCtrlProcPtr)NoopDDA, (PtrCtrlProcPtr)NoopDDA,
GetMotionHistorySize(), NAXES, axes_labels); GetMotionHistorySize(), NAXES,
axes_labels);
InitProximityClassDeviceStruct(pPointer); InitProximityClassDeviceStruct(pPointer);
InitValuatorAxisStruct(pPointer, 0, axes_labels[0], 0, 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, 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, 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], InitValuatorAxisStruct(pPointer, 3, axes_labels[3],
-XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, -XQUARTZ_VALUATOR_LIMIT,
1, 0, 1, Absolute); XQUARTZ_VALUATOR_LIMIT, 1, 0, 1,
Absolute);
InitValuatorAxisStruct(pPointer, 4, axes_labels[4], InitValuatorAxisStruct(pPointer, 4, axes_labels[4],
-XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, -XQUARTZ_VALUATOR_LIMIT,
1, 0, 1, Absolute); XQUARTZ_VALUATOR_LIMIT, 1, 0, 1,
Absolute);
// pPointer->use = IsXExtensionDevice; // pPointer->use = IsXExtensionDevice;
break; break;
case DEVICE_ON: case DEVICE_ON:
pPointer->public.on = TRUE; pPointer->public.on = TRUE;
AddEnabledDevice(darwinEventReadFD); AddEnabledDevice(darwinEventReadFD);
return Success; return Success;
case DEVICE_CLOSE: case DEVICE_CLOSE:
case DEVICE_OFF: case DEVICE_OFF:
pPointer->public.on = FALSE; pPointer->public.on = FALSE;
@ -428,14 +439,17 @@ DarwinKeybdProc(DeviceIntPtr pDev, int onoff)
case DEVICE_INIT: case DEVICE_INIT:
DarwinKeyboardInit(pDev); DarwinKeyboardInit(pDev);
break; break;
case DEVICE_ON: case DEVICE_ON:
pDev->public.on = TRUE; pDev->public.on = TRUE;
AddEnabledDevice(darwinEventReadFD); AddEnabledDevice(darwinEventReadFD);
break; break;
case DEVICE_OFF: case DEVICE_OFF:
pDev->public.on = FALSE; pDev->public.on = FALSE;
RemoveEnabledDevice(darwinEventReadFD); RemoveEnabledDevice(darwinEventReadFD);
break; break;
case DEVICE_CLOSE: case DEVICE_CLOSE:
break; break;
} }
@ -494,7 +508,8 @@ DarwinParseModifierList(const char *constmodifiers, int separatelr)
void void
InitInput(int argc, char **argv) InitInput(int argc, char **argv)
{ {
XkbRMLVOSet rmlvo = {.rules = "base",.model = "empty",.layout = "empty", XkbRMLVOSet rmlvo = {
.rules = "base", .model = "empty", .layout = "empty",
.variant = NULL, .options = NULL .variant = NULL, .options = NULL
}; };
/* We need to really have rules... or something... */ /* We need to really have rules... or something... */
@ -651,8 +666,8 @@ OsVendorInit(void)
if (serverGeneration == 1) { if (serverGeneration == 1) {
char *lf; char *lf;
char *home = getenv("HOME"); char *home = getenv("HOME");
assert(home); assert(home);
assert(0 < asprintf(&lf, "%s/Library/Logs/X11", home));
/* Ignore errors. If EEXIST, we don't care. If anything else, /* Ignore errors. If EEXIST, we don't care. If anything else,
* LogInit will handle it for us. * LogInit will handle it for us.
@ -660,7 +675,9 @@ OsVendorInit(void)
(void)mkdir(lf, S_IRWXU | S_IRWXG | S_IRWXO); (void)mkdir(lf, S_IRWXU | S_IRWXG | S_IRWXO);
free(lf); 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"); LogInit(lf, ".old");
free(lf); free(lf);
@ -668,15 +685,14 @@ OsVendorInit(void)
#ifdef ENABLE_DEBUG_LOG #ifdef ENABLE_DEBUG_LOG
{ {
char *home_dir = NULL, *log_file_path = NULL; char *home_dir = NULL, *log_file_path = NULL;
home_dir = getenv("HOME"); home_dir = getenv("HOME");
if (home_dir) if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir,
asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME); DEBUG_LOG_NAME);
if (log_file_path) { if (log_file_path) {
if (!access(log_file_path, F_OK)) { if (!access(log_file_path, F_OK)) {
debug_log_fp = fopen(log_file_path, "a"); debug_log_fp = fopen(log_file_path, "a");
if (debug_log_fp) if (debug_log_fp) ErrorF("Debug logging enabled to %s\n",
ErrorF("Debug logging enabled to %s\n", log_file_path); log_file_path);
} }
free(log_file_path); free(log_file_path);
} }
@ -764,7 +780,8 @@ ddxProcessArgument(int argc, char *argv[], int i)
darwinDesiredDepth = atoi(argv[i + 1]); darwinDesiredDepth = atoi(argv[i + 1]);
if (darwinDesiredDepth != -1 && if (darwinDesiredDepth != -1 &&
darwinDesiredDepth != 8 && darwinDesiredDepth != 8 &&
darwinDesiredDepth != 15 && darwinDesiredDepth != 24) { darwinDesiredDepth != 15 &&
darwinDesiredDepth != 24) {
FatalError("Unsupported pixel depth. Use 8, 15, or 24 bits\n"); FatalError("Unsupported pixel depth. Use 8, 15, or 24 bits\n");
} }
@ -793,15 +810,15 @@ ddxUseMsg(void)
ErrorF("Device Dependent Usage:\n"); ErrorF("Device Dependent Usage:\n");
ErrorF("\n"); ErrorF("\n");
ErrorF("-depth <8,15,24> : use this bit depth.\n"); ErrorF("-depth <8,15,24> : use this bit depth.\n");
ErrorF ErrorF(
("-fakebuttons : fake a three button mouse with Command and Option keys.\n"); "-fakebuttons : fake a three button mouse with Command and Option keys.\n");
ErrorF("-nofakebuttons : don't fake a three button mouse.\n"); ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
ErrorF ErrorF(
("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n"); "-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
ErrorF ErrorF(
("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n"); "-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
ErrorF ErrorF(
(" ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n"); " ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
ErrorF("-version : show the server version.\n"); ErrorF("-version : show the server version.\n");
ErrorF("\n"); ErrorF("\n");
} }
@ -822,7 +839,8 @@ ddxGiveUp(enum ExitCode error)
* made to restore all original setting of the displays. Also all devices * made to restore all original setting of the displays. Also all devices
* are closed. * are closed.
*/ */
_X_NORETURN void _X_NORETURN
void
AbortDDX(enum ExitCode error) AbortDDX(enum ExitCode error)
{ {
ErrorF(" AbortDDX\n"); 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. * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -37,18 +37,21 @@
#include "darwinfb.h" #include "darwinfb.h"
// From darwin.c // From darwin.c
void DarwinPrintBanner(void); void
int DarwinParseModifierList(const char *constmodifiers, int separatelr); DarwinPrintBanner(void);
void DarwinAdjustScreenOrigins(ScreenInfo * pScreenInfo); int
DarwinParseModifierList(const char *constmodifiers, int separatelr);
void
DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
#define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \ #define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \
dixLookupPrivate(&pScreen->devPrivates, darwinScreenKey)) dixLookupPrivate(&pScreen->devPrivates, \
darwinScreenKey))
/* /*
* Global variables from darwin.c * Global variables from darwin.c
*/ */
extern DevPrivateKeyRec darwinScreenKeyRec; extern DevPrivateKeyRec darwinScreenKeyRec;
#define darwinScreenKey (&darwinScreenKeyRec) #define darwinScreenKey (&darwinScreenKeyRec)
extern int darwinScreensFound; extern int darwinScreensFound;
extern io_connect_t darwinParamConnect; extern io_connect_t darwinParamConnect;
@ -80,10 +83,17 @@ extern char *bundle_id_prefix;
_X_ATTRIBUTE_PRINTF(6, 7) _X_ATTRIBUTE_PRINTF(6, 7)
extern void extern void
xq_asl_log(int level, const char *subsystem, const char *file, 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 ASL_LOG(level, subsystem, msg, args ...) xq_asl_log(level, subsystem, \
#define DEBUG_LOG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "XQuartz", msg, ##args) __FILE__, \
__FUNCTION__, \
__LINE__, msg, \
## args)
#define DEBUG_LOG(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, \
"XQuartz", msg, \
## args)
#define TRACE() DEBUG_LOG("TRACE") #define TRACE() DEBUG_LOG("TRACE")
#endif /* _DARWIN_H */ #endif /* _DARWIN_H */

View File

@ -1,33 +1,41 @@
/* /*
Darwin event queue and event handling * Darwin event queue and event handling
*
Copyright 2007-2008 Apple Inc. * Copyright 2007-2008 Apple Inc.
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved. * Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
*
This file is based on mieq.c by Keith Packard, * This file is based on mieq.c by Keith Packard,
which contains the following copyright: * which contains the following copyright:
Copyright 1990, 1998 The Open Group * 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 * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
the above copyright notice appear in all copies and that both that *
copyright notice and this permission notice appear in supporting * Permission is hereby granted, free of charge, to any person
documentation. * obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
The above copyright notice and this permission notice shall be included in * including without limitation the rights to use, copy, modify, merge,
all copies or substantial portions of the Software. * publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * subject to the following conditions:
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * The above copyright notice and this permission notice shall be
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * included in all copies or substantial portions of the Software.
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
Except as contained in this notice, the name of The Open Group shall not be * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
used in advertising or otherwise to promote the sale, use or other dealings * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
in this Software without prior written authorization from The Open Group. * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above
* copyright holders shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without
* prior written authorization.
*/ */
#include "sanitizedCarbon.h" #include "sanitizedCarbon.h"
@ -75,8 +83,8 @@ in this Software without prior written authorization from The Open Group.
#include "applewmExt.h" #include "applewmExt.h"
/* FIXME: Abstract this better */ /* FIXME: Abstract this better */
extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent * e, extern Bool
DeviceIntPtr dev); 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_all_modifier_mask = 0;
@ -110,12 +118,12 @@ create_thread(void *(*func) (void *), void *arg)
return tid; return tid;
} }
void darwinEvents_lock(void); void
darwinEvents_lock(void);
void void
darwinEvents_lock(void) darwinEvents_lock(void)
{ {
int err; int err;
if ((err = pthread_mutex_lock(&mieq_lock))) { if ((err = pthread_mutex_lock(&mieq_lock))) {
ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n", ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n",
__FILE__, __FUNCTION__, __LINE__, err); __FILE__, __FUNCTION__, __LINE__, err);
@ -126,12 +134,12 @@ darwinEvents_lock(void)
} }
} }
void darwinEvents_unlock(void); void
darwinEvents_unlock(void);
void void
darwinEvents_unlock(void) darwinEvents_unlock(void)
{ {
int err; int err;
if ((err = pthread_mutex_unlock(&mieq_lock))) { if ((err = pthread_mutex_unlock(&mieq_lock))) {
ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n", ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n",
__FILE__, __FUNCTION__, __LINE__, err); __FILE__, __FUNCTION__, __LINE__, err);
@ -168,7 +176,8 @@ static int darwin_x11_modifier_mask_list[] = {
NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK, NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK,
NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK, NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK,
#else #else
NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK, NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK,
NX_ALTERNATEMASK,
#endif #endif
NX_ALPHASHIFTMASK, NX_ALPHASHIFTMASK,
0 0
@ -195,7 +204,8 @@ DarwinUpdateModifiers(int pressed, // KeyPress or KeyRelease
if (*f & flags && *f != NX_ALPHASHIFTMASK) { if (*f & flags && *f != NX_ALPHASHIFTMASK) {
key = DarwinModifierNXMaskToNXKey(*f); key = DarwinModifierNXMaskToNXKey(*f);
if (key == -1) if (key == -1)
ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f); ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n",
*f);
else else
DarwinPressModifierKey(pressed, key); DarwinPressModifierKey(pressed, key);
} }
@ -214,26 +224,32 @@ DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev)
case kXquartzControllerNotify: case kXquartzControllerNotify:
DEBUG_LOG("kXquartzControllerNotify\n"); DEBUG_LOG("kXquartzControllerNotify\n");
AppleWMSendEvent(AppleWMControllerNotify, AppleWMSendEvent(AppleWMControllerNotify,
AppleWMControllerNotifyMask, e->data[0], e->data[1]); AppleWMControllerNotifyMask,
e->data[0],
e->data[1]);
break; break;
case kXquartzPasteboardNotify: case kXquartzPasteboardNotify:
DEBUG_LOG("kXquartzPasteboardNotify\n"); DEBUG_LOG("kXquartzPasteboardNotify\n");
AppleWMSendEvent(AppleWMPasteboardNotify, AppleWMSendEvent(AppleWMPasteboardNotify,
AppleWMPasteboardNotifyMask, e->data[0], e->data[1]); AppleWMPasteboardNotifyMask,
e->data[0],
e->data[1]);
break; break;
case kXquartzActivate: case kXquartzActivate:
DEBUG_LOG("kXquartzActivate\n"); DEBUG_LOG("kXquartzActivate\n");
QuartzShow(); QuartzShow();
AppleWMSendEvent(AppleWMActivationNotify, AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask, AppleWMIsActive, 0); AppleWMActivationNotifyMask,
AppleWMIsActive, 0);
break; break;
case kXquartzDeactivate: case kXquartzDeactivate:
DEBUG_LOG("kXquartzDeactivate\n"); DEBUG_LOG("kXquartzDeactivate\n");
AppleWMSendEvent(AppleWMActivationNotify, AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask, AppleWMIsInactive, 0); AppleWMActivationNotifyMask,
AppleWMIsInactive, 0);
QuartzHide(); QuartzHide();
break; break;
@ -247,8 +263,8 @@ DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev)
case kXquartzToggleFullscreen: case kXquartzToggleFullscreen:
DEBUG_LOG("kXquartzToggleFullscreen\n"); DEBUG_LOG("kXquartzToggleFullscreen\n");
if (XQuartzIsRootless) if (XQuartzIsRootless)
ErrorF ErrorF(
("Ignoring kXquartzToggleFullscreen because of rootless mode."); "Ignoring kXquartzToggleFullscreen because of rootless mode.");
else else
QuartzRandRToggleFullscreen(); QuartzRandRToggleFullscreen();
break; break;
@ -333,8 +349,8 @@ DarwinProcessFDAdditionQueue_thread(void *args)
sleep_for.tv_sec = 3; sleep_for.tv_sec = 3;
sleep_for.tv_nsec = 0; sleep_for.tv_nsec = 0;
ErrorF ErrorF(
("X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n"); "X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n");
while (nanosleep(&sleep_for, &sleep_remaining) != 0) { while (nanosleep(&sleep_for, &sleep_remaining) != 0) {
sleep_for = sleep_remaining; sleep_for = sleep_remaining;
} }
@ -361,8 +377,9 @@ DarwinEQInit(void)
darwin_x11_modifier_mask |= *p; darwin_x11_modifier_mask |= *p;
} }
for (p = darwin_all_modifier_mask_additions, darwin_all_modifier_mask = for (p = darwin_all_modifier_mask_additions,
darwin_x11_modifier_mask; *p; p++) { darwin_all_modifier_mask = darwin_x11_modifier_mask;
*p; p++) {
darwin_all_modifier_mask |= *p; darwin_all_modifier_mask |= *p;
} }
@ -374,7 +391,8 @@ DarwinEQInit(void)
* here, so I don't bother. * here, so I don't bother.
*/ */
if (!darwinEvents) { if (!darwinEvents) {
darwinEvents = InitEventList(GetMaximumEventsNum());; darwinEvents = InitEventList(GetMaximumEventsNum());
;
if (!darwinEvents) if (!darwinEvents)
FatalError("Couldn't allocate event buffer\n"); FatalError("Couldn't allocate event buffer\n");
@ -420,7 +438,6 @@ static void
DarwinPokeEQ(void) DarwinPokeEQ(void)
{ {
char nullbyte = 0; char nullbyte = 0;
// <daniels> oh, i ... er ... christ. // <daniels> oh, i ... er ... christ.
write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte)); write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte));
} }
@ -430,10 +447,13 @@ DarwinPokeEQ(void)
* display. * display.
*/ */
static void static void
DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask, ScreenPtr screen, DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask,
ScreenPtr screen,
double pointer_x, double pointer_y, 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); valuator_mask_zero(pmask);
/* Fix offset between darwin and X screens */ /* Fix offset between darwin and X screens */
@ -449,29 +469,40 @@ DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask, ScreenPtr screen,
if (pDev == darwinPointer) { if (pDev == darwinPointer) {
valuator_mask_set_double(pmask, 0, pointer_x); valuator_mask_set_double(pmask, 0, pointer_x);
valuator_mask_set_double(pmask, 1, pointer_y); 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)); else {
valuator_mask_set_double(pmask, 1, XQUARTZ_VALUATOR_LIMIT * (pointer_y / (double)screenInfo.screens[0]->height)); 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, 2, XQUARTZ_VALUATOR_LIMIT * pressure);
valuator_mask_set_double(pmask, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x); valuator_mask_set_double(pmask, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x);
valuator_mask_set_double(pmask, 4, XQUARTZ_VALUATOR_LIMIT * tilt_y); 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 void
DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev) DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
{ {
darwinEvents_lock(); { darwinEvents_lock();
{
int i; int i;
if (pDev->button) { if (pDev->button) {
for (i = 0; i < pDev->button->numButtons; i++) { for (i = 0; i < pDev->button->numButtons; i++) {
if (BitIsOn(pDev->button->down, i)) { if (BitIsOn(pDev->button->down, i)) {
QueuePointerEvents(pDev, ButtonRelease, i, POINTER_ABSOLUTE, QueuePointerEvents(pDev, ButtonRelease, i,
POINTER_ABSOLUTE,
NULL); NULL);
} }
} }
@ -486,14 +517,14 @@ DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
} }
} }
DarwinPokeEQ(); DarwinPokeEQ();
} } darwinEvents_unlock();
darwinEvents_unlock();
} }
void void
DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
double pointer_x, double pointer_y, double pressure, double pointer_x, double pointer_y,
double tilt_x, double tilt_y) double pressure, double tilt_x,
double tilt_y)
{ {
static int darwinFakeMouseButtonDown = 0; static int darwinFakeMouseButtonDown = 0;
ScreenPtr screen; 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); //DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
if (!darwinEvents) { if (!darwinEvents) {
DEBUG_LOG DEBUG_LOG(
("DarwinSendPointerEvents called before darwinEvents was initialized\n"); "DarwinSendPointerEvents called before darwinEvents was initialized\n");
return; return;
} }
screen = miPointerGetScreen(pDev); screen = miPointerGetScreen(pDev);
if (!screen) { if (!screen) {
DEBUG_LOG DEBUG_LOG(
("DarwinSendPointerEvents called before screen was initialized\n"); "DarwinSendPointerEvents called before screen was initialized\n");
return; 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 */ /* We're currently "down" with another button, so release it first */
DarwinSendPointerEvents(pDev, ButtonRelease, DarwinSendPointerEvents(pDev, ButtonRelease,
darwinFakeMouseButtonDown, pointer_x, darwinFakeMouseButtonDown, pointer_x,
pointer_y, pressure, tilt_x, tilt_y); pointer_y, pressure, tilt_x,
tilt_y);
darwinFakeMouseButtonDown = 0; darwinFakeMouseButtonDown = 0;
} }
if (darwin_all_modifier_flags & darwinFakeMouse2Mask) { if (darwin_all_modifier_flags & darwinFakeMouse2Mask) {
ev_button = 2; ev_button = 2;
darwinFakeMouseButtonDown = 2; darwinFakeMouseButtonDown = 2;
DarwinUpdateModKeys(darwin_all_modifier_flags & DarwinUpdateModKeys(
~darwinFakeMouse2Mask); darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
} }
else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) { else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) {
ev_button = 3; ev_button = 3;
darwinFakeMouseButtonDown = 3; darwinFakeMouseButtonDown = 3;
DarwinUpdateModKeys(darwin_all_modifier_flags & DarwinUpdateModKeys(
~darwinFakeMouse3Mask); darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
} }
} }
@ -543,21 +575,24 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
} }
if (darwinFakeMouseButtonDown == 2) { if (darwinFakeMouseButtonDown == 2) {
DarwinUpdateModKeys(darwin_all_modifier_flags & DarwinUpdateModKeys(
~darwinFakeMouse2Mask); darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
} }
else if (darwinFakeMouseButtonDown == 3) { else if (darwinFakeMouseButtonDown == 3) {
DarwinUpdateModKeys(darwin_all_modifier_flags & DarwinUpdateModKeys(
~darwinFakeMouse3Mask); darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
} }
darwinFakeMouseButtonDown = 0; darwinFakeMouseButtonDown = 0;
} }
DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y, DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y,
pressure, tilt_x, tilt_y); pressure, tilt_x,
darwinEvents_lock(); { tilt_y);
QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &valuators); darwinEvents_lock();
{
QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE,
&valuators);
DarwinPokeEQ(); DarwinPokeEQ();
} darwinEvents_unlock(); } darwinEvents_unlock();
} }
@ -567,46 +602,50 @@ DarwinSendKeyboardEvents(int ev_type, int keycode)
{ {
if (!darwinEvents) { if (!darwinEvents) {
DEBUG_LOG DEBUG_LOG(
("DarwinSendKeyboardEvents called before darwinEvents was initialized\n"); "DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
return; return;
} }
darwinEvents_lock(); { darwinEvents_lock();
{
QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE, QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE,
NULL); NULL);
DarwinPokeEQ(); DarwinPokeEQ();
} } darwinEvents_unlock();
darwinEvents_unlock();
} }
void void
DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x, 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) double tilt_y)
{ {
ScreenPtr screen; ScreenPtr screen;
ValuatorMask valuators; ValuatorMask valuators;
DEBUG_LOG("DarwinSendProximityEvents: %d l:%f,%f p:%f t:%f,%f\n", ev_type, 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) { if (!darwinEvents) {
DEBUG_LOG DEBUG_LOG(
("DarwinSendProximityEvents called before darwinEvents was initialized\n"); "DarwinSendProximityEvents called before darwinEvents was initialized\n");
return; return;
} }
screen = miPointerGetScreen(pDev); screen = miPointerGetScreen(pDev);
if (!screen) { if (!screen) {
DEBUG_LOG DEBUG_LOG(
("DarwinSendPointerEvents called before screen was initialized\n"); "DarwinSendPointerEvents called before screen was initialized\n");
return; return;
} }
DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y, DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y,
pressure, tilt_x, tilt_y); pressure, tilt_x,
darwinEvents_lock(); { tilt_y);
darwinEvents_lock();
{
QueueProximityEvents(pDev, ev_type, &valuators); QueueProximityEvents(pDev, ev_type, &valuators);
DarwinPokeEQ(); DarwinPokeEQ();
} darwinEvents_unlock(); } 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 */ /* Send the appropriate number of button clicks to emulate scroll wheel */
void void
DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x, DarwinSendScrollEvents(double scroll_x, double scroll_y,
double pointer_y, double pressure, double tilt_x, double pointer_x, double pointer_y,
double tilt_y) double pressure, double tilt_x, double tilt_y)
{ {
int sign_x, sign_y; int sign_x, sign_y;
if (!darwinEvents) { if (!darwinEvents) {
DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n"); DEBUG_LOG(
"DarwinSendScrollEvents called before darwinEvents was initialized\n");
return; return;
} }
@ -632,21 +672,20 @@ DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x,
while ((scroll_x > 0.0f) || (scroll_y > 0.0f)) { while ((scroll_x > 0.0f) || (scroll_y > 0.0f)) {
if (scroll_x > 0.0f) { if (scroll_x > 0.0f) {
DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x, DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x,
pointer_x, pointer_y, pressure, pointer_x, pointer_y, pressure, tilt_x,
tilt_x, tilt_y); tilt_y);
DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x, DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x,
pointer_x, pointer_y, pressure, pointer_x, pointer_y, pressure, tilt_x,
tilt_x, tilt_y); tilt_y);
scroll_x = scroll_x - 1.0f; scroll_x = scroll_x - 1.0f;
} }
if (scroll_y > 0.0f) { if (scroll_y > 0.0f) {
DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y, DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y,
pointer_x, pointer_y, pressure, pointer_x, pointer_y, pressure, tilt_x,
tilt_x, tilt_y); tilt_y);
DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y, DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y,
pointer_x, pointer_y, pressure, pointer_x, pointer_y, pressure, tilt_x,
tilt_x, tilt_y); tilt_y);
scroll_y = scroll_y - 1.0f; scroll_y = scroll_y - 1.0f;
} }
} }
@ -657,11 +696,11 @@ DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x,
void void
DarwinUpdateModKeys(int flags) DarwinUpdateModKeys(int flags)
{ {
DarwinUpdateModifiers(KeyRelease, DarwinUpdateModifiers(
darwin_all_modifier_flags & ~flags & KeyRelease, darwin_all_modifier_flags & ~flags &
darwin_x11_modifier_mask); darwin_x11_modifier_mask);
DarwinUpdateModifiers(KeyPress, DarwinUpdateModifiers(
~darwin_all_modifier_flags & flags & KeyPress, ~darwin_all_modifier_flags & flags &
darwin_x11_modifier_mask); darwin_x11_modifier_mask);
darwin_all_modifier_flags = flags; darwin_all_modifier_flags = flags;
} }
@ -691,7 +730,8 @@ DarwinSendDDXEvent(int type, int argc, ...)
va_end(args); va_end(args);
} }
darwinEvents_lock(); { darwinEvents_lock();
{
mieqEnqueue(NULL, (InternalEvent *)&e); mieqEnqueue(NULL, (InternalEvent *)&e);
DarwinPokeEQ(); DarwinPokeEQ();
} darwinEvents_unlock(); } darwinEvents_unlock();

View File

@ -31,24 +31,37 @@
/* For extra precision of our cursor and other valuators */ /* For extra precision of our cursor and other valuators */
#define XQUARTZ_VALUATOR_LIMIT (1 << 16) #define XQUARTZ_VALUATOR_LIMIT (1 << 16)
Bool DarwinEQInit(void); Bool
void DarwinEQFini(void); DarwinEQInit(void);
void DarwinEQEnqueue(const xEventPtr e); void
void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e); DarwinEQFini(void);
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX); void
void DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev); DarwinEQEnqueue(const xEventPtr e);
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, 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 pointer_x, double pointer_y, double pressure,
double tilt_x, double tilt_y); double tilt_x,
void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x, double tilt_y);
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); double tilt_y);
void DarwinSendKeyboardEvents(int ev_type, int keycode); void
void DarwinSendScrollEvents(double scroll_x, double scroll_y, double pointer_x, 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 pointer_y, double pressure, double tilt_x,
double tilt_y); double tilt_y);
void DarwinUpdateModKeys(int flags); void
void DarwinListenOnOpenFD(int fd); DarwinUpdateModKeys(int flags);
void
DarwinListenOnOpenFD(int fd);
/* /*
* Subtypes for the ET_XQuartz event type * Subtypes for the ET_XQuartz event type
@ -79,7 +92,8 @@ enum {
}; };
/* Send one of the above events to the server thread. */ /* 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: /* A mask of the modifiers that are in our X11 keyboard layout:
* (Fn for example is just useful for 3button mouse emulation) */ * (Fn for example is just useful for 3button mouse emulation) */

View File

@ -112,7 +112,8 @@ SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
*/ */
int 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); DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);

View File

@ -51,6 +51,7 @@ typedef struct {
#define BM_ARGB(a, r, g, b) MASK_LH(0, (b) - 1) #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 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 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 AM_ARGB(a, r, g, b) MASK_LH((b) + (g) + (r), \
(b) + (g) + (r) + (a) - 1)
#endif /* _DARWIN_FB_H */ #endif /* _DARWIN_FB_H */

View File

@ -884,11 +884,13 @@ ucs2keysym(long ucs)
qsort(reverse_keysymtab, qsort(reverse_keysymtab,
sizeof(keysymtab) / sizeof(struct codepair), sizeof(keysymtab) / sizeof(struct codepair),
sizeof(struct codepair), reverse_compare); sizeof(struct codepair),
reverse_compare);
} }
/* first check for Latin-1 characters (1:1 mapping) */ /* first check for Latin-1 characters (1:1 mapping) */
if ((ucs >= 0x0020 && ucs <= 0x007e) || (ucs >= 0x00a0 && ucs <= 0x00ff)) if ((ucs >= 0x0020 && ucs <= 0x007e) ||
(ucs >= 0x00a0 && ucs <= 0x00ff))
return ucs; return ucs;
/* binary search in table */ /* binary search in table */

View File

@ -30,7 +30,9 @@
#ifndef KEYSYM2UCS_H #ifndef KEYSYM2UCS_H
#define KEYSYM2UCS_H 1 #define KEYSYM2UCS_H 1
extern long keysym2ucs(int keysym); extern long
extern int ucs2keysym(long ucs); 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 /* main.c -- X application launcher
* Copyright (c) 2007 Jeremy Huddleston
Copyright (c) 2007 Jeremy Huddleston * Copyright (c) 2007-2012 Apple Inc. All rights reserved.
Copyright (c) 2007 Apple Inc *
* Permission is hereby granted, free of charge, to any person
Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files
obtaining a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction,
(the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge,
including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software,
publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so,
and to permit persons to whom the Software is furnished to do so, * subject to the following conditions:
subject to the following conditions: *
* The above copyright notice and this permission notice shall be
The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software.
included in all copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE.
DEALINGS IN THE SOFTWARE. *
* Except as contained in this notice, the name(s) of the above
Except as contained in this notice, the name(s) of the above * copyright holders shall not be used in advertising or otherwise to
copyright holders shall not be used in advertising or otherwise to * promote the sale, use or other dealings in this Software without
promote the sale, use or other dealings in this Software without * prior written authorization.
prior written authorization. */ */
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
@ -64,18 +64,16 @@
#include "console_redirect.h" #include "console_redirect.h"
/* From darwinEvents.c ... but don't want to pull in all the server cruft */ /* 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; extern aslclient aslc;
/* Ditto, from os/log.c */ /* Ditto, from os/log.c */
extern void extern void
ErrorF(const char *f, ...) ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2);
_X_ATTRIBUTE_PRINTF(1, 2);
extern void extern void
FatalError(const char *f, ...) FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN;
_X_ATTRIBUTE_PRINTF(1, 2)
_X_NORETURN;
extern int noPanoramiXExtension; extern int noPanoramiXExtension;
@ -91,7 +89,6 @@ extern int noPanoramiXExtension;
#endif #endif
static char __crashreporter_info_buff__[4096] = { 0 }; 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]; &__crashreporter_info_buff__[0];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
@ -110,10 +107,13 @@ static char *server_bootstrap_name = NULL;
#define DEBUG 1 #define DEBUG 1
/* This is in quartzStartup.c */ /* 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 int
static char *command_from_prefs(const char *key, const char *default_value); 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_app_to_run;
static char *pref_login_shell; static char *pref_login_shell;
@ -162,8 +162,8 @@ checkin_or_register(char *bname)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
kr = mach_port_insert_right(mach_task_self(), mp, mp, kr = mach_port_insert_right(
MACH_MSG_TYPE_MAKE_SEND); mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr)); ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -224,8 +224,8 @@ accept_fd_handoff(int connected_fd)
*((int *)CMSG_DATA(cmsg)) = -1; *((int *)CMSG_DATA(cmsg)) = -1;
if (recvmsg(connected_fd, &msg, 0) < 0) { if (recvmsg(connected_fd, &msg, 0) < 0) {
ErrorF ErrorF(
("X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", "X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n",
strerror(errno)); strerror(errno));
return -1; return -1;
} }
@ -263,8 +263,8 @@ socket_handoff_thread(void *arg)
while (launchd_fd == -1) { while (launchd_fd == -1) {
connected_fd = accept(handoff_data->fd, NULL, NULL); connected_fd = accept(handoff_data->fd, NULL, NULL);
if (connected_fd == -1) { if (connected_fd == -1) {
ErrorF ErrorF(
("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n",
handoff_data->fd, strerror(errno)); handoff_data->fd, strerror(errno));
sleep(2); sleep(2);
continue; continue;
@ -272,8 +272,8 @@ socket_handoff_thread(void *arg)
launchd_fd = accept_fd_handoff(connected_fd); launchd_fd = accept_fd_handoff(connected_fd);
if (launchd_fd == -1) if (launchd_fd == -1)
ErrorF ErrorF(
("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n"); "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
close(connected_fd); close(connected_fd);
} }
@ -282,8 +282,8 @@ socket_handoff_thread(void *arg)
unlink(handoff_data->filename); unlink(handoff_data->filename);
free(handoff_data); free(handoff_data);
ErrorF ErrorF(
("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n",
launchd_fd); launchd_fd);
DarwinListenOnOpenFD(launchd_fd); DarwinListenOnOpenFD(launchd_fd);
@ -311,34 +311,37 @@ create_socket(char *filename_out)
sizeof(servaddr_un.sun_path)); sizeof(servaddr_un.sun_path));
servaddr = (struct sockaddr *)&servaddr_un; servaddr = (struct sockaddr *)&servaddr_un;
servaddr_len = servaddr_len = sizeof(struct sockaddr_un) -
sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + sizeof(servaddr_un.sun_path) + strlen(filename_out);
strlen(filename_out);
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (ret_fd == -1) { if (ret_fd == -1) {
ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n", ErrorF(
"X11.app: Failed to create socket (try %d / %d): %s - %s\n",
(int)try + 1, (int)try_max, filename_out, strerror(errno)); (int)try + 1, (int)try_max, filename_out, strerror(errno));
continue; continue;
} }
if (bind(ret_fd, servaddr, servaddr_len) != 0) { if (bind(ret_fd, servaddr, servaddr_len) != 0) {
ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno, ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno,
strerror(errno)); strerror(
errno));
close(ret_fd); close(ret_fd);
return 0; return 0;
} }
if (listen(ret_fd, 10) != 0) { if (listen(ret_fd, 10) != 0) {
ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n", 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); close(ret_fd);
return 0; return 0;
} }
#ifdef DEBUG #ifdef DEBUG
ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n", ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n",
ret_fd, filename_out); ret_fd,
filename_out);
#endif #endif
return ret_fd; return ret_fd;
@ -371,17 +374,17 @@ do_request_fd_handoff_socket(mach_port_t port, string_t filename)
strlcpy(filename, handoff_data->filename, STRING_T_SIZE); strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
dispatch_async(dispatch_get_global_queue dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ { 0), ^ {
socket_handoff(handoff_data);} socket_handoff(handoff_data);
); });
#else #else
create_thread(socket_handoff_thread, handoff_data); create_thread(socket_handoff_thread, handoff_data);
#endif #endif
#ifdef DEBUG #ifdef DEBUG
ErrorF ErrorF(
("X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n"); "X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
#endif #endif
return KERN_SUCCESS; return KERN_SUCCESS;
@ -398,7 +401,8 @@ do_request_pid(mach_port_t port, int *my_pid)
kern_return_t kern_return_t
do_start_x11_server(mach_port_t port, string_array_t argv, do_start_x11_server(mach_port_t port, string_array_t argv,
mach_msg_type_number_t argvCnt, 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 ** */ /* And now back to char ** */
char **_argv = alloca((argvCnt + 1) * sizeof(char *)); char **_argv = alloca((argvCnt + 1) * sizeof(char *));
@ -451,7 +455,6 @@ startup_trigger(int argc, char **argv, char **envp)
/* We need to count envp */ /* We need to count envp */
int envpc; 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, /* We have fixed-size string lengths due to limitations in IPC,
@ -476,7 +479,8 @@ startup_trigger(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name, ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name,
bootstrap_strerror(kr)); bootstrap_strerror(
kr));
#else #else
ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name, ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name,
(unsigned long)kr); (unsigned long)kr);
@ -508,14 +512,14 @@ startup_trigger(int argc, char **argv, char **envp)
/* Start the server */ /* Start the server */
if ((s = getenv("DISPLAY"))) { if ((s = getenv("DISPLAY"))) {
ErrorF ErrorF(
("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n",
s); s);
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
else { else {
ErrorF ErrorF(
("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
} }
return execute(pref_startx_script); return execute(pref_startx_script);
} }
@ -530,7 +534,8 @@ ensure_path(const char *dir)
temp = getenv("PATH"); temp = getenv("PATH");
if (temp == NULL || temp[0] == 0) { if (temp == NULL || temp[0] == 0) {
snprintf(buf, sizeof(buf), 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); setenv("PATH", buf, TRUE);
} }
else if (strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) { else if (strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
@ -574,10 +579,8 @@ setup_env(void)
* quartz-wm and the Xquartz stub's MachIPC) * quartz-wm and the Xquartz stub's MachIPC)
*/ */
CFBundleRef bundle = CFBundleGetMainBundle(); CFBundleRef bundle = CFBundleGetMainBundle();
if (bundle) { if (bundle) {
CFStringRef pd = CFBundleGetIdentifier(bundle); CFStringRef pd = CFBundleGetIdentifier(bundle);
if (pd) { if (pd) {
pds = CFStringGetCStringPtr(pd, 0); pds = CFStringGetCStringPtr(pd, 0);
} }
@ -609,22 +612,22 @@ setup_env(void)
if (disp) { if (disp) {
/* s = basename(disp) */ /* s = basename(disp) */
const char *d, *s; const char *d, *s;
for (s = NULL, d = disp; *d; d++) { for (s = NULL, d = disp; *d; d++) {
if (*d == '/') if (*d == '/')
s = d + 1; s = d + 1;
} }
if (s && *s) { if (s && *s) {
if (strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) { if (strcmp(bundle_id_prefix,
ErrorF "org.x") == 0 && strcmp(s, ":0") == 0) {
("X11.app: Detected old style launchd DISPLAY, please update xinit.\n"); ErrorF(
"X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
} }
else { else {
temp = (char *)malloc(sizeof(char) * len); temp = (char *)malloc(sizeof(char) * len);
if (!temp) { if (!temp) {
ErrorF ErrorF(
("X11.app: Memory allocation error creating space for socket name test.\n"); "X11.app: Memory allocation error creating space for socket name test.\n");
exit(1); exit(1);
} }
strlcpy(temp, bundle_id_prefix, len); strlcpy(temp, bundle_id_prefix, len);
@ -632,8 +635,8 @@ setup_env(void)
if (strcmp(temp, s) != 0) { if (strcmp(temp, s) != 0) {
/* If we don't have a match, unset it. */ /* If we don't have a match, unset it. */
ErrorF ErrorF(
("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n",
disp, bundle_id_prefix); disp, bundle_id_prefix);
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
@ -642,8 +645,8 @@ setup_env(void)
} }
else { else {
/* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */ /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
ErrorF ErrorF(
("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n"); "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
} }
@ -704,8 +707,8 @@ main(int argc, char **argv, char **envp)
pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL); pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
assert(pref_login_shell); assert(pref_login_shell);
pref_startx_script = pref_startx_script = command_from_prefs("startx_script",
command_from_prefs("startx_script", DEFAULT_STARTX); DEFAULT_STARTX);
assert(pref_startx_script); assert(pref_startx_script);
/* Do the fork-twice trick to avoid having to reap zombies */ /* Do the fork-twice trick to avoid having to reap zombies */
@ -797,13 +800,13 @@ command_from_prefs(const char *key, const char *default_value)
if (!cfKey) if (!cfKey)
return NULL; return NULL;
PlistRef = PlistRef = CFPreferencesCopyAppValue(cfKey,
CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication); kCFPreferencesCurrentApplication);
if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) { if ((PlistRef == NULL) ||
CFStringRef cfDefaultValue = (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
CFStringCreateWithCString(NULL, default_value, CFStringRef cfDefaultValue = CFStringCreateWithCString(
kCFStringEncodingASCII); NULL, default_value, kCFStringEncodingASCII);
int len = strlen(default_value) + 1; int len = strlen(default_value) + 1;
if (!cfDefaultValue) if (!cfDefaultValue)
@ -821,7 +824,6 @@ command_from_prefs(const char *key, const char *default_value)
} }
else { else {
int len = CFStringGetLength((CFStringRef)PlistRef) + 1; int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
command = (char *)malloc(len * sizeof(char)); command = (char *)malloc(len * sizeof(char));
if (!command) if (!command)
goto command_from_prefs_out; goto command_from_prefs_out;

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 * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
@ -45,8 +45,10 @@ launchd_display_fd(void)
launch_data_t listening_fd_array, listening_fd; launch_data_t listening_fd_array, listening_fd;
/* Get launchd fd */ /* Get launchd fd */
if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) { if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) ==
asl_log(aslc, NULL, ASL_LEVEL_ERR, NULL) {
asl_log(
aslc, NULL, ASL_LEVEL_ERR,
"launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "launch_data_new_string(\"" LAUNCH_KEY_CHECKIN
"\") Unable to create string.\n"); "\") Unable to create string.\n");
return ERROR_FD; return ERROR_FD;
@ -55,20 +57,23 @@ launchd_display_fd(void)
if ((checkin_response = launch_msg(checkin_request)) == NULL) { if ((checkin_response = launch_msg(checkin_request)) == NULL) {
asl_log(aslc, NULL, ASL_LEVEL_WARNING, asl_log(aslc, NULL, ASL_LEVEL_WARNING,
"launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n", "launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",
strerror(errno)); strerror(
errno));
return ERROR_FD; return ERROR_FD;
} }
if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) { if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
// ignore EACCES, which is common if we weren't started by launchd // ignore EACCES, which is common if we weren't started by launchd
if (launch_data_get_errno(checkin_response) != EACCES) if (launch_data_get_errno(checkin_response) != EACCES)
asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in failed: %s\n", asl_log(aslc, NULL, ASL_LEVEL_ERR,
strerror(launch_data_get_errno(checkin_response))); "launchd check-in failed: %s\n",
strerror(launch_data_get_errno(
checkin_response)));
return ERROR_FD; return ERROR_FD;
} }
sockets_dict = sockets_dict = launch_data_dict_lookup(checkin_response,
launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS); LAUNCH_JOBKEY_SOCKETS);
if (NULL == sockets_dict) { if (NULL == sockets_dict) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in: no sockets found to answer requests on!\n"); "launchd check-in: no sockets found to answer requests on!\n");
@ -81,12 +86,13 @@ launchd_display_fd(void)
return ERROR_FD; return ERROR_FD;
} }
listening_fd_array = listening_fd_array = launch_data_dict_lookup(sockets_dict,
launch_data_dict_lookup(sockets_dict, BUNDLE_ID_PREFIX ":0"); BUNDLE_ID_PREFIX ":0");
if (NULL == listening_fd_array) { if (NULL == listening_fd_array) {
listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0"); listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
if (NULL == listening_fd_array) { if (NULL == listening_fd_array) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(
aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", "launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n",
BUNDLE_ID_PREFIX); BUNDLE_ID_PREFIX);
return ERROR_FD; return ERROR_FD;
@ -96,7 +102,8 @@ launchd_display_fd(void)
if (launch_data_array_get_count(listening_fd_array) != 1) { if (launch_data_array_get_count(listening_fd_array) != 1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"launchd check-in: Expected 1 socket from launchd, got %u)\n", "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; 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 * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
@ -31,6 +31,7 @@
#define ERROR_FD -1 #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

@ -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 * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
@ -65,36 +65,43 @@ set_x11_path(void)
CFURLRef appURL = NULL; CFURLRef appURL = NULL;
OSStatus osstatus = OSStatus osstatus =
LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(
nil, &appURL); kX11AppBundleId), nil, nil, &appURL);
switch (osstatus) { switch (osstatus) {
case noErr: case noErr:
if (appURL == NULL) { if (appURL == NULL) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(
aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Invalid response from LSFindApplicationForInfo(%s)", "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
kX11AppBundleId); kX11AppBundleId);
exit(1); exit(1);
} }
if (!CFURLGetFileSystemRepresentation if (!CFURLGetFileSystemRepresentation(appURL, true,
(appURL, true, (unsigned char *) x11_path, sizeof(x11_path))) { (unsigned char *)x11_path,
sizeof(x11_path))) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Error resolving URL for %s", kX11AppBundleId); "Xquartz: Error resolving URL for %s",
kX11AppBundleId);
exit(3); exit(3);
} }
strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path)); strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path); asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path);
break; break;
case kLSApplicationNotFoundErr: case kLSApplicationNotFoundErr:
asl_log(aslc, NULL, ASL_LEVEL_ERR, 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); exit(10);
default: default:
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Unable to find application for %s, error code = %d", "Xquartz: Unable to find application for %s, error code = %d",
kX11AppBundleId, (int) osstatus); kX11AppBundleId,
(int)osstatus);
exit(11); exit(11);
} }
#else #else
@ -118,22 +125,24 @@ connect_to_socket(const char *filename)
strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path)); strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
servaddr = (struct sockaddr *)&servaddr_un; servaddr = (struct sockaddr *)&servaddr_un;
servaddr_len = servaddr_len = sizeof(struct sockaddr_un) -
sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + sizeof(servaddr_un.sun_path) + strlen(filename);
strlen(filename);
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (ret_fd == -1) { if (ret_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to create socket: %s - %s", filename, "Xquartz: Failed to create socket: %s - %s", filename,
strerror(errno)); strerror(
errno));
return -1; return -1;
} }
if (connect(ret_fd, servaddr, servaddr_len) < 0) { if (connect(ret_fd, servaddr, servaddr_len) < 0) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to connect to socket: %s - %d - %s", filename, "Xquartz: Failed to connect to socket: %s - %d - %s",
errno, strerror(errno)); filename, errno,
strerror(
errno));
close(ret_fd); close(ret_fd);
return -1; return -1;
} }
@ -176,7 +185,8 @@ send_fd_handoff(int connected_fd, int launchd_fd)
*((int *)CMSG_DATA(cmsg)) = launchd_fd; *((int *)CMSG_DATA(cmsg)) = launchd_fd;
if (sendmsg(connected_fd, &msg, 0) < 0) { if (sendmsg(connected_fd, &msg, 0) < 0) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(
aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s", "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s",
connected_fd, errno, strerror(errno)); connected_fd, errno, strerror(errno));
return; return;
@ -256,18 +266,19 @@ main(int argc, char **argv, char **envp)
child = fork(); child = fork();
if (child == -1) { if (child == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s", asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s",
strerror(errno)); strerror(
errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (child == 0) { if (child == 0) {
char *_argv[3]; char *_argv[3];
_argv[0] = x11_path; _argv[0] = x11_path;
_argv[1] = "--listenonly"; _argv[1] = "--listenonly";
_argv[2] = NULL; _argv[2] = NULL;
asl_log(aslc, NULL, ASL_LEVEL_NOTICE, 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); return execvp(x11_path, _argv);
} }
@ -282,10 +293,12 @@ main(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(kr)); "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(
kr));
#else #else
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: bootstrap_look_up(): %ul", (unsigned long) kr); "Xquartz: bootstrap_look_up(): %ul",
(unsigned long)kr);
#endif #endif
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -300,9 +313,11 @@ main(int argc, char **argv, char **envp)
int handoff_fd = -1; int handoff_fd = -1;
for (try = 0, try_max = 5; try < try_max; try++) { 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) { KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_INFO, 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)", "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); (int)try + 1, (int)try_max);
continue; continue;
@ -312,11 +327,13 @@ main(int argc, char **argv, char **envp)
if (handoff_fd == -1) { if (handoff_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to connect to socket (try %d of %d)", "Xquartz: Failed to connect to socket (try %d of %d)",
(int) try + 1, (int) try_max); (int)try + 1,
(int)try_max);
continue; continue;
} }
asl_log(aslc, NULL, ASL_LEVEL_INFO, asl_log(
aslc, NULL, ASL_LEVEL_INFO,
"Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.", "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.",
(int)try + 1, (int)try_max, handoff_fd, (int)try + 1, (int)try_max, handoff_fd,
handoff_socket_filename); handoff_socket_filename);
@ -355,7 +372,8 @@ main(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s", 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_FAILURE;
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -1,30 +1,31 @@
/* app-main.m /* app-main.m
Copyright (c) 2002, 2008 Apple Computer, Inc. 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 * Permission is hereby granted, free of charge, to any person
(the "Software"), to deal in the Software without restriction, * obtaining a copy of this software and associated documentation files
including without limitation the rights to use, copy, modify, merge, * (the "Software"), to deal in the Software without restriction,
publish, distribute, sublicense, and/or sell copies of the Software, * including without limitation the rights to use, copy, modify, merge,
and to permit persons to whom the Software is furnished to do so, * publish, distribute, sublicense, and/or sell copies of the Software,
subject to the following conditions: * 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 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DEALINGS IN THE SOFTWARE. * 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 * Except as contained in this notice, the name(s) of the above
promote the sale, use or other dealings in this Software without * copyright holders shall not be used in advertising or otherwise to
prior written authorization. * promote the sale, use or other dealings in this Software without
* prior written authorization.
*/ */
#include "pbproxy.h" #include "pbproxy.h"
@ -50,6 +51,7 @@ signal_handler(int sig)
case SIGHUP: case SIGHUP:
xpbproxy_prefs_reload = YES; xpbproxy_prefs_reload = YES;
break; break;
default: default:
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
} }
@ -68,7 +70,8 @@ ErrorF(const char *f, ...)
/* TODO: Have this actually log to ASL */ /* TODO: Have this actually log to ASL */
void void
xq_asl_log(int level, const char *subsystem, const char *file, 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 #ifdef DEBUG
va_list args; va_list args;
@ -99,7 +102,8 @@ main(int argc, const char *argv[])
app_prefs_domain = argv[++i]; app_prefs_domain = argv[++i];
} }
else if (strcmp(argv[i], "--help") == 0) { else if (strcmp(argv[i], "--help") == 0) {
ErrorF("usage: xpbproxy OPTIONS\n" ErrorF(
"usage: xpbproxy OPTIONS\n"
"Pasteboard proxying for X11.\n\n" "Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n" "--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: %s)\n", " (default: %s)\n",
@ -113,8 +117,7 @@ main(int argc, const char *argv[])
} }
} }
app_prefs_domain_cfstr = app_prefs_domain_cfstr = CFStringCreateWithCString(NULL, app_prefs_domain,
CFStringCreateWithCString(NULL, app_prefs_domain,
kCFStringEncodingUTF8); kCFStringEncodingUTF8);
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);

View File

@ -1,30 +1,31 @@
/* main.m /* main.m
Copyright (c) 2002, 2008 Apple Computer, Inc. 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 * Permission is hereby granted, free of charge, to any person
(the "Software"), to deal in the Software without restriction, * obtaining a copy of this software and associated documentation files
including without limitation the rights to use, copy, modify, merge, * (the "Software"), to deal in the Software without restriction,
publish, distribute, sublicense, and/or sell copies of the Software, * including without limitation the rights to use, copy, modify, merge,
and to permit persons to whom the Software is furnished to do so, * publish, distribute, sublicense, and/or sell copies of the Software,
subject to the following conditions: * 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 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DEALINGS IN THE SOFTWARE. * 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 * Except as contained in this notice, the name(s) of the above
promote the sale, use or other dealings in this Software without * copyright holders shall not be used in advertising or otherwise to
prior written authorization. * promote the sale, use or other dealings in this Software without
* prior written authorization.
*/ */
#include "pbproxy.h" #include "pbproxy.h"
@ -103,7 +104,6 @@ xpbproxy_run(void)
if (!xpbproxy_dpy && display) { if (!xpbproxy_dpy && display) {
char _display[32]; char _display[32];
snprintf(_display, sizeof(_display), ":%s", display); snprintf(_display, sizeof(_display), ":%s", display);
setenv("DISPLAY", _display, TRUE); setenv("DISPLAY", _display, TRUE);

View File

@ -1,30 +1,31 @@
/* pbproxy.h /* pbproxy.h
Copyright (c) 2002, 2008 Apple Computer, Inc. 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 * Permission is hereby granted, free of charge, to any person
(the "Software"), to deal in the Software without restriction, * obtaining a copy of this software and associated documentation files
including without limitation the rights to use, copy, modify, merge, * (the "Software"), to deal in the Software without restriction,
publish, distribute, sublicense, and/or sell copies of the Software, * including without limitation the rights to use, copy, modify, merge,
and to permit persons to whom the Software is furnished to do so, * publish, distribute, sublicense, and/or sell copies of the Software,
subject to the following conditions: * 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 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DEALINGS IN THE SOFTWARE. * 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 * Except as contained in this notice, the name(s) of the above
promote the sale, use or other dealings in this Software without * copyright holders shall not be used in advertising or otherwise to
prior written authorization. * promote the sale, use or other dealings in this Software without
* prior written authorization.
*/ */
#ifndef PBPROXY_H #ifndef PBPROXY_H
@ -65,11 +66,16 @@ extern BOOL xpbproxy_is_standalone;
#endif #endif
/* from main.m */ /* from main.m */
extern void xpbproxy_set_is_active(BOOL state); extern void
extern BOOL xpbproxy_get_is_active(void); xpbproxy_set_is_active(BOOL state);
extern id xpbproxy_selection_object(void); extern BOOL
extern Time xpbproxy_current_timestamp(void); xpbproxy_get_is_active(void);
extern int xpbproxy_run(void); extern id
xpbproxy_selection_object(void);
extern Time
xpbproxy_current_timestamp(void);
extern int
xpbproxy_run(void);
extern Display *xpbproxy_dpy; extern Display *xpbproxy_dpy;
extern int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base; 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; extern BOOL xpbproxy_have_xfixes;
/* from x-input.m */ /* from x-input.m */
extern BOOL xpbproxy_input_register(void); extern BOOL
xpbproxy_input_register(void);
/* os/log.c or app-main.m */ /* os/log.c or app-main.m */
extern void extern void
ErrorF(const char *f, ...) ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2);
_X_ATTRIBUTE_PRINTF(1, 2);
/* from darwin.h */ /* from darwin.h */
_X_ATTRIBUTE_PRINTF(6, 7) _X_ATTRIBUTE_PRINTF(6, 7)
extern void extern void
xq_asl_log(int level, const char *subsystem, const char *file, 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 ASL_LOG(level, subsystem, msg, args ...) xq_asl_log(level, subsystem, \
#define DebugF(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "xpbproxy", msg, ##args) __FILE__, \
__FUNCTION__, \
__LINE__, msg, \
## args)
#define DebugF(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, \
"xpbproxy", msg, \
## args)
#define TRACE() DebugF("TRACE") #define TRACE() DebugF("TRACE")
#endif /* PBPROXY_H */ #endif /* PBPROXY_H */

View File

@ -1,30 +1,31 @@
/* x-input.m -- event handling /* x-input.m -- event handling
Copyright (c) 2002, 2008 Apple Computer, Inc. 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 * Permission is hereby granted, free of charge, to any person
(the "Software"), to deal in the Software without restriction, * obtaining a copy of this software and associated documentation files
including without limitation the rights to use, copy, modify, merge, * (the "Software"), to deal in the Software without restriction,
publish, distribute, sublicense, and/or sell copies of the Software, * including without limitation the rights to use, copy, modify, merge,
and to permit persons to whom the Software is furnished to do so, * publish, distribute, sublicense, and/or sell copies of the Software,
subject to the following conditions: * 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 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DEALINGS IN THE SOFTWARE. * 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 * Except as contained in this notice, the name(s) of the above
promote the sale, use or other dealings in this Software without * copyright holders shall not be used in advertising or otherwise to
prior written authorization. * promote the sale, use or other dealings in this Software without
* prior written authorization.
*/ */
#include "pbproxy.h" #include "pbproxy.h"
@ -55,7 +56,8 @@ x_event_apple_wm_notify(XAppleWMNotifyEvent * e)
int kind = e->kind; int kind = e->kind;
/* We want to reload prefs even if we're not active */ /* We want to reload prefs even if we're not active */
if (type == AppleWMActivationNotify && kind == AppleWMReloadPreferences) if (type == AppleWMActivationNotify &&
kind == AppleWMReloadPreferences)
[xpbproxy_selection_object ()reload_preferences]; [xpbproxy_selection_object ()reload_preferences];
if (![xpbproxy_selection_object ()is_active]) if (![xpbproxy_selection_object ()is_active])
@ -119,13 +121,14 @@ xpbproxy_process_xevents(void)
default: default:
if (e.type >= xpbproxy_apple_wm_event_base && if (e.type >= xpbproxy_apple_wm_event_base &&
e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) { e.type < xpbproxy_apple_wm_event_base +
AppleWMNumberEvents) {
x_event_apple_wm_notify((XAppleWMNotifyEvent *)&e); x_event_apple_wm_notify((XAppleWMNotifyEvent *)&e);
} }
else if (e.type == else if (e.type == xpbproxy_xfixes_event_base +
xpbproxy_xfixes_event_base + XFixesSelectionNotify) { XFixesSelectionNotify) {
[xpbproxy_selection_object()xfixes_selection_notify:(XFixesSelectionNotifyEvent *) & [xpbproxy_selection_object () xfixes_selection_notify:(
e]; XFixesSelectionNotifyEvent *)&e];
} }
break; break;
} }
@ -150,7 +153,8 @@ add_input_socket(int sock, CFOptionFlags callback_types,
return FALSE; return FALSE;
} }
*cf_source = CFSocketCreateRunLoopSource(kCFAllocatorDefault, cf_sock, 0); *cf_source = CFSocketCreateRunLoopSource(kCFAllocatorDefault,
cf_sock, 0);
CFRelease(cf_sock); CFRelease(cf_sock);
if (*cf_source == NULL) if (*cf_source == NULL)
@ -179,7 +183,7 @@ x_input_callback(CFSocketRef sock, CFSocketCallBackType type,
BOOL BOOL
xpbproxy_input_register(void) xpbproxy_input_register(void)
{ {
return add_input_socket(ConnectionNumber(xpbproxy_dpy), return add_input_socket(ConnectionNumber(
kCFSocketReadCallBack, x_input_callback, NULL, xpbproxy_dpy), kCFSocketReadCallBack,
&xpbproxy_dpy_source); x_input_callback, NULL, &xpbproxy_dpy_source);
} }

View File

@ -1,31 +1,31 @@
/* x-selection.h -- proxies between NSPasteboard and X11 selections /* x-selection.h -- proxies between NSPasteboard and X11 selections
*
Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. * prior written authorization.
*/ */
#ifndef X_SELECTION_H #ifndef X_SELECTION_H
@ -52,8 +52,10 @@ struct atom_list {
compound_text, atom_pair; compound_text, atom_pair;
}; };
@interface x_selection:NSObject { @interface x_selection : NSObject
{
@private @private
/* The unmapped window we use for fetching selections. */ /* The unmapped window we use for fetching selections. */
Window _selection_window; Window _selection_window;
@ -71,7 +73,6 @@ struct atom_list {
* pending_copy is > 0 we do it again. * pending_copy is > 0 we do it again.
*/ */
int pending_copy; 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. * CLIPBOARD. It also prevents a race with INCR transfers.
@ -91,10 +92,9 @@ struct atom_list {
- (void)notify_event:(XSelectionEvent *)e; - (void)notify_event:(XSelectionEvent *)e;
- (void)property_event:(XPropertyEvent *)e; - (void)property_event:(XPropertyEvent *)e;
- (void)xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e; - (void)xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e;
-(void) handle_selection:(Atom) - (void)handle_selection:(Atom) selection type:(Atom) type propdata:(struct
selection type:(Atom) propdata
type propdata:(struct propdata *) pdata; *)pdata;
- (void)claim_clipboard; - (void)claim_clipboard;
- (BOOL)set_clipboard_manager_status:(BOOL)value; - (BOOL)set_clipboard_manager_status:(BOOL)value;
- (void)own_clipboard; - (void)own_clipboard;
@ -104,6 +104,7 @@ type propdata:(struct propdata *) pdata;
- (BOOL)is_active; - (BOOL)is_active;
- (void)send_none:(XSelectionRequestEvent *)e; - (void)send_none:(XSelectionRequestEvent *)e;
@end @end
/* main.m */ /* main.m */
extern x_selection * _selection_object; extern x_selection * _selection_object;

View File

@ -1,31 +1,31 @@
/* x-selection.m -- proxies between NSPasteboard and X11 selections /* x-selection.m -- proxies between NSPasteboard and X11 selections
*
Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. * prior written authorization.
*/ */
#import "x-selection.h" #import "x-selection.h"
@ -73,11 +73,13 @@ static struct {
BOOL clipboard_to_pasteboard; BOOL clipboard_to_pasteboard;
BOOL pasteboard_to_primary; BOOL pasteboard_to_primary;
BOOL pasteboard_to_clipboard; BOOL pasteboard_to_clipboard;
} pbproxy_prefs = { } pbproxy_prefs = { YES, NO, YES, YES, YES };
YES, NO, YES, YES, YES};
@implementation x_selection @implementation x_selection
static struct propdata null_propdata = { NULL, 0, 0 };
static struct propdata null_propdata = {
NULL, 0, 0
};
#ifdef DEBUG #ifdef DEBUG
static void static void
@ -134,7 +136,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
{ {
long offset = 0; long offset = 0;
unsigned long numitems, bytesleft = 0; unsigned long numitems, bytesleft = 0;
#ifdef TEST #ifdef TEST
/* This is used to test the growth handling. */ /* This is used to test the growth handling. */
unsigned long length = 4UL; unsigned long length = 4UL;
@ -224,7 +225,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
/* Implementation methods */ /* Implementation methods */
/* This finds the preferred type from a TARGETS list.*/ /* This finds the preferred type from a TARGETS list.*/
-(Atom) find_preferred:(struct propdata *) pdata { - (Atom) find_preferred:(struct propdata *)pdata
{
Atom a = None; Atom a = None;
size_t i, step; size_t i, step;
Bool png = False, jpeg = False, utf8 = False, string = False; Bool png = False, jpeg = False, utf8 = False, string = False;
@ -232,8 +234,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
TRACE(); TRACE();
if (pdata->format != 32) { if (pdata->format != 32) {
ErrorF ErrorF(
("Atom list is expected to be formatted as an array of 32bit values.\n"); "Atom list is expected to be formatted as an array of 32bit values.\n");
return None; return None;
} }
@ -254,7 +256,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
} }
else { else {
char *type = XGetAtomName(xpbproxy_dpy, a); char *type = XGetAtomName(xpbproxy_dpy, a);
if (type) { if (type) {
DebugF("Unhandled X11 mime type: %s", type); DebugF("Unhandled X11 mime type: %s", type);
XFree(type); XFree(type);
@ -280,7 +281,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
} }
/* Return True if this is an INCR-style transfer. */ /* Return True if this is an INCR-style transfer. */
-(Bool) is_incr_type:(XSelectionEvent *) e { - (Bool) is_incr_type:(XSelectionEvent *)e
{
Atom seltype; Atom seltype;
int format; int format;
unsigned long numitems = 0UL, bytesleft = 0UL; unsigned long numitems = 0UL, bytesleft = 0UL;
@ -306,7 +308,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
* This should be called after a selection has been copied, * This should be called after a selection has been copied,
* or when the selection is unfinished before a transfer completes. * or when the selection is unfinished before a transfer completes.
*/ */
-(void) release_pending { - (void) release_pending
{
TRACE(); TRACE();
free_propdata(&pending.propdata); free_propdata(&pending.propdata);
@ -316,8 +319,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
/* Return True if an error occurs during an append.*/ /* Return True if an error occurs during an append.*/
/* Return False if the append succeeds. */ /* Return False if the append succeeds. */
-(Bool) append_to_pending:(struct propdata *) - (Bool) append_to_pending:(struct propdata *)pdata requestor:(Window)
pdata requestor:(Window) requestor requestor
{ {
unsigned char *newdata; unsigned char *newdata;
size_t newlength; size_t newlength;
@ -346,7 +349,8 @@ pdata requestor:(Window) requestor
} }
/* Called when X11 becomes active (i.e. has key focus) */ /* Called when X11 becomes active (i.e. has key focus) */
-(void) x_active:(Time) timestamp { - (void) x_active:(Time)timestamp
{
static NSInteger changeCount; static NSInteger changeCount;
NSInteger countNow; NSInteger countNow;
NSPasteboard *pb; NSPasteboard *pb;
@ -365,7 +369,8 @@ pdata requestor:(Window) requestor
changeCount = countNow; changeCount = countNow;
if (pbproxy_prefs.pasteboard_to_primary) { if (pbproxy_prefs.pasteboard_to_primary) {
XSetSelectionOwner(xpbproxy_dpy, atoms->primary, _selection_window, XSetSelectionOwner(xpbproxy_dpy, atoms->primary,
_selection_window,
CurrentTime); CurrentTime);
} }
@ -389,12 +394,14 @@ pdata requestor:(Window) requestor
} }
/* Called when X11 loses key focus */ /* Called when X11 loses key focus */
-(void) x_inactive:(Time) timestamp { - (void) x_inactive:(Time)timestamp
{
TRACE(); TRACE();
} }
/* This requests the TARGETS list from the PRIMARY selection owner. */ /* This requests the TARGETS list from the PRIMARY selection owner. */
-(void) x_copy_request_targets { - (void) x_copy_request_targets
{
TRACE(); TRACE();
request_atom = atoms->targets; request_atom = atoms->targets;
@ -404,7 +411,8 @@ pdata requestor:(Window) requestor
/* Called when the Edit/Copy item on the main X11 menubar is selected /* Called when the Edit/Copy item on the main X11 menubar is selected
* and no appkit window claims it. */ * and no appkit window claims it. */
-(void) x_copy:(Time) timestamp { - (void) x_copy:(Time)timestamp
{
Window w; Window w;
TRACE(); TRACE();
@ -429,7 +437,8 @@ pdata requestor:(Window) requestor
* This prevents tools like xclipboard from causing havoc. * This prevents tools like xclipboard from causing havoc.
* Returns TRUE on success * Returns TRUE on success
*/ */
-(BOOL) set_clipboard_manager_status:(BOOL) value { - (BOOL) set_clipboard_manager_status:(BOOL)value
{
TRACE(); TRACE();
Window owner = XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager); Window owner = XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager);
@ -439,14 +448,15 @@ pdata requestor:(Window) requestor
return TRUE; return TRUE;
if (owner != None) { if (owner != None) {
ErrorF ErrorF(
("A clipboard manager using window 0x%lx already owns the clipboard selection. " "A clipboard manager using window 0x%lx already owns the clipboard selection. "
"pbproxy will not sync clipboard to pasteboard.\n", owner); "pbproxy will not sync clipboard to pasteboard.\n", owner);
return FALSE; return FALSE;
} }
XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager,
_selection_window, CurrentTime); _selection_window,
CurrentTime);
return (_selection_window == return (_selection_window ==
XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager)); XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
} }
@ -467,7 +477,8 @@ pdata requestor:(Window) requestor
* This occurs when we previously owned a selection, * This occurs when we previously owned a selection,
* and then lost it from another client. * and then lost it from another client.
*/ */
-(void) clear_event:(XSelectionClearEvent *) e { - (void) clear_event:(XSelectionClearEvent *)e
{
TRACE(); TRACE();
@ -499,7 +510,8 @@ pdata requestor:(Window) requestor
/* /*
* We greedily acquire the clipboard after it changes, and on startup. * We greedily acquire the clipboard after it changes, and on startup.
*/ */
-(void) claim_clipboard { - (void) claim_clipboard
{
Window owner; Window owner;
TRACE(); TRACE();
@ -532,7 +544,8 @@ pdata requestor:(Window) requestor
} }
/* Greedily acquire the clipboard. */ /* Greedily acquire the clipboard. */
-(void) own_clipboard { - (void) own_clipboard
{
TRACE(); TRACE();
@ -544,8 +557,7 @@ pdata requestor:(Window) requestor
atoms->clipboard)); atoms->clipboard));
} }
-(void) init_reply:(XEvent *) - (void) init_reply:(XEvent *)reply request:(XSelectionRequestEvent *)e
reply request:(XSelectionRequestEvent *) e
{ {
reply->xselection.type = SelectionNotify; reply->xselection.type = SelectionNotify;
reply->xselection.selection = e->selection; reply->xselection.selection = e->selection;
@ -555,7 +567,8 @@ reply request:(XSelectionRequestEvent *) e
reply->xselection.property = None; reply->xselection.property = None;
} }
-(void) send_reply:(XEvent *) reply { - (void) send_reply:(XEvent *)reply
{
/* /*
* We are supposed to use an empty event mask, and not propagate * We are supposed to use an empty event mask, and not propagate
* the event, according to the ICCCM. * the event, according to the ICCCM.
@ -574,8 +587,8 @@ reply request:(XSelectionRequestEvent *) e
* (in Latin-1 encoding). The requestor can then make the choice based on * (in Latin-1 encoding). The requestor can then make the choice based on
* the list. * the list.
*/ */
-(void) send_targets:(XSelectionRequestEvent *) - (void) send_targets:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)
e pasteboard:(NSPasteboard *) pb pb
{ {
XEvent reply; XEvent reply;
NSArray *pbtypes; NSArray *pbtypes;
@ -630,8 +643,9 @@ e pasteboard:(NSPasteboard *) pb
if (count) { if (count) {
/* We have a list of ATOMs to send. */ /* We have a list of ATOMs to send. */
XChangeProperty(xpbproxy_dpy, e->requestor, e->property, XChangeProperty(xpbproxy_dpy, e->requestor, e->property,
atoms->atom, 32, PropModeReplace, atoms->atom, 32,
(unsigned char *) list, count); PropModeReplace, (unsigned char *)list,
count);
reply.xselection.property = e->property; reply.xselection.property = e->property;
} }
@ -640,9 +654,8 @@ e pasteboard:(NSPasteboard *) pb
[self send_reply:&reply]; [self send_reply:&reply];
} }
-(void) send_string:(XSelectionRequestEvent *) - (void) send_string:(XSelectionRequestEvent *)e utf8:(BOOL)utf8 pasteboard:(
e utf8:(BOOL) NSPasteboard *)pb
utf8 pasteboard:(NSPasteboard *) pb
{ {
XEvent reply; XEvent reply;
NSArray *pbtypes; NSArray *pbtypes;
@ -710,8 +723,8 @@ utf8 pasteboard:(NSPasteboard *) pb
[self send_reply:&reply]; [self send_reply:&reply];
} }
-(void) send_compound_text:(XSelectionRequestEvent *) - (void) send_compound_text:(XSelectionRequestEvent *)e pasteboard:(
e pasteboard:(NSPasteboard *) pb NSPasteboard *)pb
{ {
XEvent reply; XEvent reply;
NSArray *pbtypes; NSArray *pbtypes;
@ -724,7 +737,6 @@ e pasteboard:(NSPasteboard *) pb
if ([pbtypes containsObject: NSStringPboardType]) { if ([pbtypes containsObject: NSStringPboardType]) {
NSString *data = [pb stringForType:NSStringPboardType]; NSString *data = [pb stringForType:NSStringPboardType];
if (nil != data) { if (nil != data) {
/* /*
* Cast to (void *) to avoid a const warning. * Cast to (void *) to avoid a const warning.
@ -741,8 +753,8 @@ e pasteboard:(NSPasteboard *) pb
&textprop)) { &textprop)) {
if (8 != textprop.format) if (8 != textprop.format)
DebugF DebugF(
("textprop.format is unexpectedly not 8 - it's %d instead\n", "textprop.format is unexpectedly not 8 - it's %d instead\n",
textprop.format); textprop.format);
XChangeProperty(xpbproxy_dpy, e->requestor, e->property, XChangeProperty(xpbproxy_dpy, e->requestor, e->property,
@ -763,16 +775,15 @@ e pasteboard:(NSPasteboard *) pb
} }
/* Finding a test application that uses MULTIPLE has proven to be difficult. */ /* Finding a test application that uses MULTIPLE has proven to be difficult. */
-(void) send_multiple:(XSelectionRequestEvent *) e { - (void) send_multiple:(XSelectionRequestEvent *)e
{
XEvent reply; XEvent reply;
TRACE(); TRACE();
[self init_reply:&reply request:e]; [self init_reply:&reply request:e];
if (None != e->property) { if (None != e->property) {}
}
[self send_reply:&reply]; [self send_reply:&reply];
} }
@ -781,8 +792,8 @@ e pasteboard:(NSPasteboard *) pb
/* DO NOT retain the encdata for longer than the length of an event response. /* DO NOT retain the encdata for longer than the length of an event response.
* The autorelease pool will reuse/free it. * The autorelease pool will reuse/free it.
*/ */
-(NSData *) encode_image_data:(NSData *) - (NSData *) encode_image_data:(NSData *)data type:(NSBitmapImageFileType)
data type:(NSBitmapImageFileType) enctype enctype
{ {
NSBitmapImageRep *bmimage = nil; NSBitmapImageRep *bmimage = nil;
NSData *encdata = nil; NSData *encdata = nil;
@ -810,7 +821,9 @@ data type:(NSBitmapImageFileType) enctype
/* Return YES when an error has occured when trying to send the PICT. */ /* Return YES when an error has occured when trying to send the PICT. */
/* The caller should send a default reponse with a property of None when an error occurs. */ /* The caller should send a default reponse with a property of None when an error occurs. */
-(BOOL) send_image_pict_reply: (XSelectionRequestEvent *) e pasteboard: (NSPasteboard *) pb type:(NSBitmapImageFileType) imagetype - (BOOL) send_image_pict_reply:(XSelectionRequestEvent *)e
pasteboard:(NSPasteboard *)pb
type:(NSBitmapImageFileType)imagetype
{ {
XEvent reply; XEvent reply;
NSImage *img = nil; NSImage *img = nil;
@ -856,7 +869,9 @@ data type:(NSBitmapImageFileType) enctype
/* Return YES if an error occured. */ /* Return YES if an error occured. */
/* The caller should send a reply with a property of None when an error occurs. */ /* The caller should send a reply with a property of None when an error occurs. */
-(BOOL) send_image_tiff_reply: (XSelectionRequestEvent *) e pasteboard: (NSPasteboard *) pb type:(NSBitmapImageFileType) imagetype - (BOOL) send_image_tiff_reply:(XSelectionRequestEvent *)e
pasteboard:(NSPasteboard *)pb
type:(NSBitmapImageFileType)imagetype
{ {
XEvent reply; XEvent reply;
NSData *data = nil; NSData *data = nil;
@ -888,8 +903,7 @@ data type:(NSBitmapImageFileType) enctype
return NO; /*no error*/ return NO; /*no error*/
} }
-(void) send_image:(XSelectionRequestEvent *) - (void) send_image:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
e pasteboard:(NSPasteboard *) pb
{ {
NSArray *pbtypes = nil; NSArray *pbtypes = nil;
NSBitmapImageFileType imagetype = NSPNGFileType; NSBitmapImageFileType imagetype = NSPNGFileType;
@ -901,15 +915,16 @@ e pasteboard:(NSPasteboard *) pb
else if (e->target == atoms->image_jpeg) else if (e->target == atoms->image_jpeg)
imagetype = NSJPEGFileType; imagetype = NSJPEGFileType;
else { else {
ErrorF ErrorF(
("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n"); "internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
} }
pbtypes = [pb types]; pbtypes = [pb types];
if (pbtypes) { if (pbtypes) {
if ([pbtypes containsObject:NSTIFFPboardType]) { if ([pbtypes containsObject:NSTIFFPboardType]) {
if (NO ==[self send_image_tiff_reply: e pasteboard: pb type:imagetype]) if (NO ==
[self send_image_tiff_reply:e pasteboard:pb type:imagetype])
return; return;
} }
#ifdef __clang__ #ifdef __clang__
@ -921,7 +936,8 @@ e pasteboard:(NSPasteboard *) pb
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
{ {
if (NO ==[self send_image_pict_reply: e pasteboard: pb type:imagetype]) if (NO ==
[self send_image_pict_reply:e pasteboard:pb type:imagetype])
return; return;
/* Fall through intentionally to the send_none: */ /* Fall through intentionally to the send_none: */
@ -931,7 +947,8 @@ e pasteboard:(NSPasteboard *) pb
[self send_none:e]; [self send_none:e];
} }
-(void) send_none:(XSelectionRequestEvent *) e { - (void)send_none:(XSelectionRequestEvent *)e
{
XEvent reply; XEvent reply;
TRACE(); TRACE();
@ -941,7 +958,8 @@ e pasteboard:(NSPasteboard *) pb
} }
/* Another client requested the data or targets of data available from the clipboard. */ /* Another client requested the data or targets of data available from the clipboard. */
-(void) request_event:(XSelectionRequestEvent *) e { - (void)request_event:(XSelectionRequestEvent *)e
{
NSPasteboard *pb; NSPasteboard *pb;
TRACE(); TRACE();
@ -991,7 +1009,8 @@ e pasteboard:(NSPasteboard *) pb
else if (e->target == atoms->multiple) { else if (e->target == atoms->multiple) {
[self send_multiple:e]; [self send_multiple:e];
} }
else if (e->target == atoms->image_png || e->target == atoms->image_jpeg) { else if (e->target == atoms->image_png || e->target ==
atoms->image_jpeg) {
[self send_image:e pasteboard:pb]; [self send_image:e pasteboard:pb];
} }
else { else {
@ -1000,7 +1019,8 @@ e pasteboard:(NSPasteboard *) pb
} }
/* This handles the events resulting from an XConvertSelection request. */ /* This handles the events resulting from an XConvertSelection request. */
-(void) notify_event:(XSelectionEvent *) e { - (void) notify_event:(XSelectionEvent *)e
{
Atom type; Atom type;
struct propdata pdata; struct propdata pdata;
@ -1027,8 +1047,8 @@ e pasteboard:(NSPasteboard *) pb
*/ */
DebugF("is INCR\n"); DebugF("is INCR\n");
if (get_property if (get_property(e->requestor, e->property, &pdata, /*Delete*/ True,
(e->requestor, e->property, &pdata, /*Delete */ True, &type)) { &type)) {
/* /*
* An error occured, so we should invoke the copy_completed:, but * An error occured, so we should invoke the copy_completed:, but
* not handle_selection:type:propdata: * not handle_selection:type:propdata:
@ -1045,8 +1065,8 @@ e pasteboard:(NSPasteboard *) pb
DebugF("set pending.requestor to 0x%lx\n", pending.requestor); DebugF("set pending.requestor to 0x%lx\n", pending.requestor);
} }
else { else {
if (get_property if (get_property(e->requestor, e->property, &pdata, /*Delete*/ True,
(e->requestor, e->property, &pdata, /*Delete */ True, &type)) { &type)) {
[self copy_completed:e->selection]; [self copy_completed:e->selection];
return; return;
} }
@ -1060,7 +1080,8 @@ e pasteboard:(NSPasteboard *) pb
/* This is used for INCR transfers. See the ICCCM for the details. */ /* This is used for INCR transfers. See the ICCCM for the details. */
/* This is used to retrieve PRIMARY and CLIPBOARD selections. */ /* This is used to retrieve PRIMARY and CLIPBOARD selections. */
-(void) property_event:(XPropertyEvent *) e { - (void) property_event:(XPropertyEvent *)e
{
struct propdata pdata; struct propdata pdata;
Atom type; Atom type;
@ -1080,7 +1101,8 @@ e pasteboard:(NSPasteboard *) pb
if (None != pending.requestor && PropertyNewValue == e->state) { if (None != pending.requestor && PropertyNewValue == e->state) {
DebugF("pending.requestor 0x%lx\n", pending.requestor); DebugF("pending.requestor 0x%lx\n", pending.requestor);
if (get_property(e->window, e->atom, &pdata, /*Delete */ True, &type)) { if (get_property(e->window, e->atom, &pdata, /*Delete*/ True,
&type)) {
[self copy_completed:pending.selection]; [self copy_completed:pending.selection];
[self release_pending]; [self release_pending];
return; return;
@ -1091,8 +1113,8 @@ e pasteboard:(NSPasteboard *) pb
* We completed the transfer. * We completed the transfer.
* handle_selection will call copy_completed: for us. * handle_selection will call copy_completed: for us.
*/ */
[self handle_selection: pending.selection type: type propdata:&pending. [self handle_selection:pending.selection type:type propdata:&
propdata]; pending.propdata];
free_propdata(&pdata); free_propdata(&pdata);
pending.propdata = null_propdata; pending.propdata = null_propdata;
pending.requestor = None; pending.requestor = None;
@ -1105,7 +1127,8 @@ e pasteboard:(NSPasteboard *) pb
} }
} }
-(void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *) e { - (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e
{
if (!pbproxy_prefs.active) if (!pbproxy_prefs.active)
return; return;
@ -1124,8 +1147,7 @@ e pasteboard:(NSPasteboard *) pb
} }
} }
-(void) handle_targets:(Atom) - (void) handle_targets: (Atom)selection propdata:(struct propdata *)pdata
selection propdata:(struct propdata *) pdata
{ {
/* Find a type we can handle and prefer from the list of ATOMs. */ /* Find a type we can handle and prefer from the list of ATOMs. */
Atom preferred; Atom preferred;
@ -1158,8 +1180,7 @@ selection propdata:(struct propdata *) pdata
/* This handles the image type of selection (typically in CLIPBOARD). */ /* This handles the image type of selection (typically in CLIPBOARD). */
/* We convert to a TIFF, so that other applications can paste more easily. */ /* We convert to a TIFF, so that other applications can paste more easily. */
-(void) handle_image:(struct propdata *) - (void) handle_image: (struct propdata *)pdata pasteboard:(NSPasteboard *)pb
pdata pasteboard:(NSPasteboard *) pb
{ {
NSArray *pbtypes; NSArray *pbtypes;
NSUInteger length; NSUInteger length;
@ -1200,11 +1221,13 @@ pdata pasteboard:(NSPasteboard *) pb
[data retainCount]); [data retainCount]);
#endif #endif
@try { @try
{
tiff = [bmimage TIFFRepresentation]; tiff = [bmimage TIFFRepresentation];
} }
@catch(NSException * e) { @catch (NSException *e)
{
DebugF("NSTIFFException!\n"); DebugF("NSTIFFException!\n");
[data autorelease]; [data autorelease];
[bmimage autorelease]; [bmimage autorelease];
@ -1244,15 +1267,18 @@ pdata pasteboard:(NSPasteboard *) pb
} }
/* This handles the UTF8_STRING type of selection. */ /* This handles the UTF8_STRING type of selection. */
-(void) handle_utf8_string:(struct propdata *) - (void) handle_utf8_string:(struct propdata *)pdata pasteboard:(NSPasteboard
pdata pasteboard:(NSPasteboard *) pb *)pb
{ {
NSString *string; NSString *string;
NSArray *pbtypes; NSArray *pbtypes;
TRACE(); TRACE();
string =[[NSString alloc] initWithBytes: pdata->data length: pdata->length encoding:NSUTF8StringEncoding]; string =
[[NSString alloc] initWithBytes:pdata->data length:pdata->length
encoding:
NSUTF8StringEncoding];
if (nil == string) if (nil == string)
return; return;
@ -1274,15 +1300,18 @@ pdata pasteboard:(NSPasteboard *) pb
} }
/* This handles the STRING type, which should be in Latin-1. */ /* This handles the STRING type, which should be in Latin-1. */
-(void) handle_string:(struct propdata *) - (void) handle_string: (struct propdata *)pdata pasteboard:(NSPasteboard *)
pdata pasteboard:(NSPasteboard *) pb pb
{ {
NSString *string; NSString *string;
NSArray *pbtypes; NSArray *pbtypes;
TRACE(); TRACE();
string =[[NSString alloc] initWithBytes: pdata->data length: pdata->length encoding:NSISOLatin1StringEncoding]; string =
[[NSString alloc] initWithBytes:pdata->data length:pdata->length
encoding:
NSISOLatin1StringEncoding];
if (nil == string) if (nil == string)
return; return;
@ -1303,9 +1332,9 @@ pdata pasteboard:(NSPasteboard *) pb
/* This is called when the selection is completely retrieved from another client. */ /* This is called when the selection is completely retrieved from another client. */
/* Warning: this frees the propdata. */ /* Warning: this frees the propdata. */
-(void) handle_selection:(Atom) - (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct
selection type:(Atom) propdata
type propdata:(struct propdata *) pdata *)pdata
{ {
NSPasteboard *pb; NSPasteboard *pb;
@ -1347,7 +1376,8 @@ type propdata:(struct propdata *) pdata
[self copy_completed:selection]; [self copy_completed:selection];
} }
-(void) copy_completed:(Atom) selection { - (void) copy_completed:(Atom)selection
{
TRACE(); TRACE();
char *name; char *name;
@ -1391,7 +1421,8 @@ type propdata:(struct propdata *) pdata
} }
} }
-(void) reload_preferences { - (void) reload_preferences
{
/* /*
* It's uncertain how we could handle the synchronization failing, so cast to void. * It's uncertain how we could handle the synchronization failing, so cast to void.
* The prefs_get_bool should fall back to defaults if the org.x.X11 plist doesn't exist or is invalid. * The prefs_get_bool should fall back to defaults if the org.x.X11 plist doesn't exist or is invalid.
@ -1402,19 +1433,24 @@ type propdata:(struct propdata *) pdata
pbproxy_prefs.active = YES; pbproxy_prefs.active = YES;
else else
#endif #endif
pbproxy_prefs.active = pbproxy_prefs.active = prefs_get_bool(CFSTR(
prefs_get_bool(CFSTR("sync_pasteboard"), pbproxy_prefs.active); "sync_pasteboard"),
pbproxy_prefs.active);
pbproxy_prefs.primary_on_grab = pbproxy_prefs.primary_on_grab =
prefs_get_bool(CFSTR("sync_primary_on_select"), prefs_get_bool(CFSTR(
"sync_primary_on_select"),
pbproxy_prefs.primary_on_grab); pbproxy_prefs.primary_on_grab);
pbproxy_prefs.clipboard_to_pasteboard = pbproxy_prefs.clipboard_to_pasteboard =
prefs_get_bool(CFSTR("sync_clipboard_to_pasteboard"), prefs_get_bool(CFSTR(
"sync_clipboard_to_pasteboard"),
pbproxy_prefs.clipboard_to_pasteboard); pbproxy_prefs.clipboard_to_pasteboard);
pbproxy_prefs.pasteboard_to_primary = pbproxy_prefs.pasteboard_to_primary =
prefs_get_bool(CFSTR("sync_pasteboard_to_primary"), prefs_get_bool(CFSTR(
"sync_pasteboard_to_primary"),
pbproxy_prefs.pasteboard_to_primary); pbproxy_prefs.pasteboard_to_primary);
pbproxy_prefs.pasteboard_to_clipboard = pbproxy_prefs.pasteboard_to_clipboard =
prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), prefs_get_bool(CFSTR(
"sync_pasteboard_to_clipboard"),
pbproxy_prefs.pasteboard_to_clipboard); pbproxy_prefs.pasteboard_to_clipboard);
/* This is used for debugging. */ /* This is used for debugging. */
@ -1422,8 +1458,8 @@ type propdata:(struct propdata *) pdata
if (pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && if (pbproxy_prefs.active && pbproxy_prefs.primary_on_grab &&
!xpbproxy_have_xfixes) { !xpbproxy_have_xfixes) {
ErrorF ErrorF(
("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n"); "Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
pbproxy_prefs.primary_on_grab = NO; pbproxy_prefs.primary_on_grab = NO;
} }
@ -1437,23 +1473,25 @@ type propdata:(struct propdata *) pdata
[self claim_clipboard]; [self claim_clipboard];
} }
-(BOOL) is_active { - (BOOL) is_active
{
return pbproxy_prefs.active; return pbproxy_prefs.active;
} }
/* NSPasteboard-required methods */ /* NSPasteboard-required methods */
-(void) paste:(id) sender { - (void) paste:(id)sender
TRACE();
}
-(void) pasteboard:(NSPasteboard *)
pb provideDataForType:(NSString *) type
{ {
TRACE(); TRACE();
} }
-(void) pasteboardChangedOwner:(NSPasteboard *) pb { - (void) pasteboard:(NSPasteboard *)pb provideDataForType:(NSString *)type
{
TRACE();
}
- (void) pasteboardChangedOwner:(NSPasteboard *)pb
{
TRACE(); TRACE();
/* Right now we don't care with this. */ /* Right now we don't care with this. */
@ -1461,7 +1499,8 @@ pb provideDataForType:(NSString *) type
/* Allocation */ /* Allocation */
-init { - init
{
unsigned long pixel; unsigned long pixel;
self = [super init]; self = [super init];
@ -1480,15 +1519,15 @@ pb provideDataForType:(NSString *) type
atoms->image_jpeg = XInternAtom(xpbproxy_dpy, "image/jpeg", False); atoms->image_jpeg = XInternAtom(xpbproxy_dpy, "image/jpeg", False);
atoms->incr = XInternAtom(xpbproxy_dpy, "INCR", False); atoms->incr = XInternAtom(xpbproxy_dpy, "INCR", False);
atoms->atom = XInternAtom(xpbproxy_dpy, "ATOM", False); atoms->atom = XInternAtom(xpbproxy_dpy, "ATOM", False);
atoms->clipboard_manager = atoms->clipboard_manager = XInternAtom(xpbproxy_dpy, "CLIPBOARD_MANAGER",
XInternAtom(xpbproxy_dpy, "CLIPBOARD_MANAGER", False); False);
atoms->compound_text = XInternAtom(xpbproxy_dpy, "COMPOUND_TEXT", False); atoms->compound_text = XInternAtom(xpbproxy_dpy, "COMPOUND_TEXT", False);
atoms->atom_pair = XInternAtom(xpbproxy_dpy, "ATOM_PAIR", False); atoms->atom_pair = XInternAtom(xpbproxy_dpy, "ATOM_PAIR", False);
pixel = BlackPixel(xpbproxy_dpy, DefaultScreen(xpbproxy_dpy)); pixel = BlackPixel(xpbproxy_dpy, DefaultScreen(xpbproxy_dpy));
_selection_window = _selection_window =
XCreateSimpleWindow(xpbproxy_dpy, DefaultRootWindow(xpbproxy_dpy), 0, 0, XCreateSimpleWindow(xpbproxy_dpy, DefaultRootWindow(xpbproxy_dpy),
1, 1, 0, pixel, pixel); 0, 0, 1, 1, 0, pixel, pixel);
/* This is used to get PropertyNotify events when doing INCR transfers. */ /* This is used to get PropertyNotify events when doing INCR transfers. */
XSelectInput(xpbproxy_dpy, _selection_window, PropertyChangeMask); XSelectInput(xpbproxy_dpy, _selection_window, PropertyChangeMask);
@ -1512,7 +1551,8 @@ pb provideDataForType:(NSString *) type
return self; return self;
} }
-(void) dealloc { - (void) dealloc
{
if (None != _selection_window) { if (None != _selection_window) {
XDestroyWindow(xpbproxy_dpy, _selection_window); XDestroyWindow(xpbproxy_dpy, _selection_window);
_selection_window = None; _selection_window = None;

View File

@ -47,25 +47,41 @@ Equipment Corporation.
Bool noPseudoramiXExtension = FALSE; 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
static int ProcPseudoramiXGetState(ClientPtr client); ProcPseudoramiXQueryVersion(ClientPtr client);
static int ProcPseudoramiXGetScreenCount(ClientPtr client); static int
static int ProcPseudoramiXGetScreenSize(ClientPtr client); ProcPseudoramiXGetState(ClientPtr client);
static int ProcPseudoramiXIsActive(ClientPtr client); static int
static int ProcPseudoramiXQueryScreens(ClientPtr client); ProcPseudoramiXGetScreenCount(ClientPtr client);
static int ProcPseudoramiXDispatch(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
static int SProcPseudoramiXGetState(ClientPtr client); SProcPseudoramiXQueryVersion(ClientPtr client);
static int SProcPseudoramiXGetScreenCount(ClientPtr client); static int
static int SProcPseudoramiXGetScreenSize(ClientPtr client); SProcPseudoramiXGetState(ClientPtr client);
static int SProcPseudoramiXIsActive(ClientPtr client); static int
static int SProcPseudoramiXQueryScreens(ClientPtr client); SProcPseudoramiXGetScreenCount(ClientPtr client);
static int SProcPseudoramiXDispatch(ClientPtr client); static int
SProcPseudoramiXGetScreenSize(ClientPtr client);
static int
SProcPseudoramiXIsActive(ClientPtr client);
static int
SProcPseudoramiXQueryScreens(ClientPtr client);
static int
SProcPseudoramiXDispatch(ClientPtr client);
typedef struct { typedef struct {
int x; int x;
@ -88,8 +104,7 @@ PseudoramiXAddScreen(int x, int y, int w, int h)
{ {
PseudoramiXScreenRec *s; PseudoramiXScreenRec *s;
if (noPseudoramiXExtension) if (noPseudoramiXExtension) return;
return;
if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) { if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1; pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
@ -115,8 +130,7 @@ PseudoramiXExtensionInit(int argc, char *argv[])
Bool success = FALSE; Bool success = FALSE;
ExtensionEntry *extEntry; ExtensionEntry *extEntry;
if (noPseudoramiXExtension) if (noPseudoramiXExtension) return;
return;
TRACE(); TRACE();
@ -134,7 +148,8 @@ PseudoramiXExtensionInit(int argc, char *argv[])
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0, extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcPseudoramiXDispatch, ProcPseudoramiXDispatch,
SProcPseudoramiXDispatch, SProcPseudoramiXDispatch,
PseudoramiXResetProc, StandardMinorOpcode); PseudoramiXResetProc,
StandardMinorOpcode);
if (!extEntry) { if (!extEntry) {
ErrorF("PseudoramiXExtensionInit(): AddExtension failed\n"); ErrorF("PseudoramiXExtensionInit(): AddExtension failed\n");
} }
@ -300,7 +315,8 @@ ProcPseudoramiXQueryScreens(ClientPtr client)
xXineramaQueryScreensReply rep; xXineramaQueryScreensReply rep;
DEBUG_LOG("noPseudoramiXExtension=%d, pseudoramiXNumScreens=%d\n", DEBUG_LOG("noPseudoramiXExtension=%d, pseudoramiXNumScreens=%d\n",
noPseudoramiXExtension, pseudoramiXNumScreens); noPseudoramiXExtension,
pseudoramiXNumScreens);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
@ -347,14 +363,19 @@ ProcPseudoramiXDispatch(ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_PanoramiXQueryVersion: case X_PanoramiXQueryVersion:
return ProcPseudoramiXQueryVersion(client); return ProcPseudoramiXQueryVersion(client);
case X_PanoramiXGetState: case X_PanoramiXGetState:
return ProcPseudoramiXGetState(client); return ProcPseudoramiXGetState(client);
case X_PanoramiXGetScreenCount: case X_PanoramiXGetScreenCount:
return ProcPseudoramiXGetScreenCount(client); return ProcPseudoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize: case X_PanoramiXGetScreenSize:
return ProcPseudoramiXGetScreenSize(client); return ProcPseudoramiXGetScreenSize(client);
case X_XineramaIsActive: case X_XineramaIsActive:
return ProcPseudoramiXIsActive(client); return ProcPseudoramiXIsActive(client);
case X_XineramaQueryScreens: case X_XineramaQueryScreens:
return ProcPseudoramiXQueryScreens(client); return ProcPseudoramiXQueryScreens(client);
} }
@ -443,14 +464,19 @@ SProcPseudoramiXDispatch(ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_PanoramiXQueryVersion: case X_PanoramiXQueryVersion:
return SProcPseudoramiXQueryVersion(client); return SProcPseudoramiXQueryVersion(client);
case X_PanoramiXGetState: case X_PanoramiXGetState:
return SProcPseudoramiXGetState(client); return SProcPseudoramiXGetState(client);
case X_PanoramiXGetScreenCount: case X_PanoramiXGetScreenCount:
return SProcPseudoramiXGetScreenCount(client); return SProcPseudoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize: case X_PanoramiXGetScreenSize:
return SProcPseudoramiXGetScreenSize(client); return SProcPseudoramiXGetScreenSize(client);
case X_XineramaIsActive: case X_XineramaIsActive:
return SProcPseudoramiXIsActive(client); return SProcPseudoramiXIsActive(client);
case X_XineramaQueryScreens: case X_XineramaQueryScreens:
return SProcPseudoramiXQueryScreens(client); return SProcPseudoramiXQueryScreens(client);
} }

View File

@ -4,6 +4,8 @@
extern int noPseudoramiXExtension; 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 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 * 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. * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons.
* All Rights Reserved. * All Rights Reserved.
* *
@ -97,7 +98,8 @@ int32_t XQuartzShieldingWindowLevel = 0;
* Do mode dependent initialization of each screen for Quartz. * Do mode dependent initialization of each screen for Quartz.
*/ */
Bool Bool
QuartzAddScreen(int index, ScreenPtr pScreen) QuartzAddScreen(int index,
ScreenPtr pScreen)
{ {
// allocate space for private per screen Quartz specific storage // allocate space for private per screen Quartz specific storage
QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1); QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1);
@ -114,7 +116,8 @@ QuartzAddScreen(int index, ScreenPtr pScreen)
* Finalize mode specific setup of each screen. * Finalize mode specific setup of each screen.
*/ */
Bool Bool
QuartzSetupScreen(int index, ScreenPtr pScreen) QuartzSetupScreen(int index,
ScreenPtr pScreen)
{ {
// do Quartz mode specific setup // do Quartz mode specific setup
if (!quartzProcs->SetupScreen(index, pScreen)) if (!quartzProcs->SetupScreen(index, pScreen))
@ -139,7 +142,8 @@ QuartzSetupScreen(int index, ScreenPtr pScreen)
* Quartz display initialization. * Quartz display initialization.
*/ */
void 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 */ /* For XQuartz, we want to just use the default signal handler to work better with CrashTracer */
signal(SIGSEGV, SIG_DFL); signal(SIGSEGV, SIG_DFL);
@ -162,7 +166,8 @@ QuartzInitOutput(int argc, char **argv)
#endif #endif
if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler, if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
QuartzWakeupHandler, NULL)) { QuartzWakeupHandler,
NULL)) {
FatalError("Could not register block and wakeup handlers."); 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. * Inform the main thread the X server is ready to handle events.
*/ */
void void
QuartzInitInput(int argc, char **argv) QuartzInitInput(int argc,
char **argv)
{ {
X11ApplicationSetCanQuit(0); X11ApplicationSetCanQuit(0);
X11ApplicationServerReady(); X11ApplicationServerReady();
@ -241,10 +247,11 @@ QuartzUpdateScreens(void)
inputInfo.pointer->spriteInfo->sprite->physLimits = bounds; inputInfo.pointer->spriteInfo->sprite->physLimits = bounds;
inputInfo.pointer->spriteInfo->sprite->hotLimits = bounds; inputInfo.pointer->spriteInfo->sprite->hotLimits = bounds;
DEBUG_LOG DEBUG_LOG(
("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", "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, width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY,
y, pScreen->x, pScreen->y); x, y,
pScreen->x, pScreen->y);
/* Send an event for the root reconfigure */ /* Send an event for the root reconfigure */
e.u.u.type = ConfigureNotify; e.u.u.type = ConfigureNotify;
@ -295,16 +302,18 @@ QuartzScreenSaver(int state)
if (pokeActivityTimer != NULL) if (pokeActivityTimer != NULL)
goto QuartzScreenSaverEnd; goto QuartzScreenSaverEnd;
pokeActivityTimer = pokeActivityTimer = CFRunLoopTimerCreate(NULL,
CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent(), 30, 0, 0, CFAbsoluteTimeGetCurrent(),
pokeActivityCallback, &pokeActivityContext); 30, 0, 0,
pokeActivityCallback,
&pokeActivityContext);
if (pokeActivityTimer == NULL) { if (pokeActivityTimer == NULL) {
ErrorF("Unable to create pokeActivityTimer.\n"); ErrorF("Unable to create pokeActivityTimer.\n");
goto QuartzScreenSaverEnd; goto QuartzScreenSaverEnd;
} }
CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, CFRunLoopAddTimer(
kCFRunLoopCommonModes); CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
} }
QuartzScreenSaverEnd: QuartzScreenSaverEnd:
OSSpinLockUnlock(&pokeActivitySpinLock); OSSpinLockUnlock(&pokeActivitySpinLock);
@ -340,7 +349,6 @@ QuartzShowFullscreen(int state)
RootlessShowAllWindows(); RootlessShowAllWindows();
for (i = 0; i < screenInfo.numScreens; i++) { for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i]; ScreenPtr pScreen = screenInfo.screens[i];
RootlessRepositionWindows(pScreen); RootlessRepositionWindows(pScreen);
// JH: I don't think this is necessary, but keeping it here as a reminder // JH: I don't think this is necessary, but keeping it here as a reminder
//RootlessUpdateScreenPixmap(pScreen); //RootlessUpdateScreenPixmap(pScreen);
@ -466,7 +474,8 @@ void
QuartzSpaceChanged(uint32_t space_id) QuartzSpaceChanged(uint32_t space_id)
{ {
/* Do something special here, so we don't depend on quartz-wm for spaces to work... */ /* 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);
} }
/* /*
@ -483,7 +492,6 @@ QuartzCopyDisplayIDs(ScreenPtr pScreen,
free(pQuartzScreen->displayIDs); free(pQuartzScreen->displayIDs);
if (displayCount) { if (displayCount) {
size_t size = displayCount * sizeof(CGDirectDisplayID); size_t size = displayCount * sizeof(CGDirectDisplayID);
pQuartzScreen->displayIDs = malloc(size); pQuartzScreen->displayIDs = malloc(size);
memcpy(pQuartzScreen->displayIDs, displayIDs, size); memcpy(pQuartzScreen->displayIDs, displayIDs, size);
} }
@ -493,7 +501,8 @@ QuartzCopyDisplayIDs(ScreenPtr pScreen,
pQuartzScreen->displayCount = displayCount; pQuartzScreen->displayCount = displayCount;
} }
void NSBeep(void); void
NSBeep(void);
void void
DDXRingBell(int volume, // volume is % of max DDXRingBell(int volume, // volume is % of max
int pitch, // pitch is Hz int pitch, // pitch is Hz

View File

@ -4,6 +4,7 @@
* External interface of the Quartz display modes seen by the generic, mode * External interface of the Quartz display modes seen by the generic, mode
* independent parts of the Darwin X server. * 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. * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons.
* All Rights Reserved. * All Rights Reserved.
* *
@ -126,22 +127,37 @@ 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
Bool QuartzSetupScreen(int index, ScreenPtr pScreen); QuartzAddScreen(int index, ScreenPtr pScreen);
void QuartzInitOutput(int argc, char **argv); Bool
void QuartzInitInput(int argc, char **argv); QuartzSetupScreen(int index, ScreenPtr pScreen);
void QuartzInitServer(int argc, char **argv, char **envp); void
void QuartzGiveUp(void); QuartzInitOutput(int argc, char **argv);
void QuartzProcessEvent(xEvent *xe); void
void QuartzUpdateScreens(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
void QuartzHide(void); QuartzShow(void);
void QuartzSetRootClip(BOOL enable); void
void QuartzSpaceChanged(uint32_t space_id); QuartzHide(void);
void
QuartzSetRootClip(BOOL enable);
void
QuartzSpaceChanged(uint32_t space_id);
void QuartzSetRootless(Bool state); void
void QuartzShowFullscreen(Bool state); 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 #endif

View File

@ -48,7 +48,9 @@
* Clean out any autoreleased objects. * Clean out any autoreleased objects.
*/ */
void void
QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) QuartzBlockHandler(pointer blockData,
OSTimePtr pTimeout,
pointer pReadmask)
{ {
static NSAutoreleasePool *aPool = nil; static NSAutoreleasePool *aPool = nil;
@ -60,7 +62,9 @@ QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
* QuartzWakeupHandler * QuartzWakeupHandler
*/ */
void void
QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask) QuartzWakeupHandler(pointer blockData,
int result,
pointer pReadmask)
{ {
// nothing here // nothing here
} }

View File

@ -40,15 +40,15 @@
// Other shared data // Other shared data
extern DevPrivateKeyRec quartzScreenKeyRec; extern DevPrivateKeyRec quartzScreenKeyRec;
#define quartzScreenKey (&quartzScreenKeyRec) #define quartzScreenKey (&quartzScreenKeyRec)
extern int aquaMenuBarHeight; extern int aquaMenuBarHeight;
// Name of GLX bundle for native OpenGL // Name of GLX bundle for native OpenGL
extern const char *quartzOpenGLBundle; extern const char *quartzOpenGLBundle;
void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, void
pointer pReadmask); QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
void QuartzWakeupHandler(pointer blockData, int result, 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 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 (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved. Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
@ -84,31 +84,33 @@ const static struct {
unsigned short keycode; unsigned short keycode;
KeySym keysym; KeySym keysym;
} known_keys[] = { } known_keys[] = {
{ { 55, XK_Meta_L },
55, XK_Meta_L}, { { 56, XK_Shift_L },
56, XK_Shift_L}, { { 57, XK_Caps_Lock },
57, XK_Caps_Lock}, { { 58, XK_Alt_L },
58, XK_Alt_L}, { { 59, XK_Control_L },
59, XK_Control_L}, {
60, XK_Shift_R}, { { 60, XK_Shift_R },
61, XK_Alt_R}, { { 61, XK_Alt_R },
62, XK_Control_R}, { { 62, XK_Control_R },
63, XK_Meta_R}, { { 63, XK_Meta_R },
122, XK_F1}, {
120, XK_F2}, { { 122, XK_F1 },
99, XK_F3}, { { 120, XK_F2 },
118, XK_F4}, { { 99, XK_F3 },
96, XK_F5}, { { 118, XK_F4 },
97, XK_F6}, { { 96, XK_F5 },
98, XK_F7}, { { 97, XK_F6 },
100, XK_F8}, { { 98, XK_F7 },
101, XK_F9}, { { 100, XK_F8 },
109, XK_F10}, { { 101, XK_F9 },
103, XK_F11}, { { 109, XK_F10 },
111, XK_F12}, { { 103, XK_F11 },
105, XK_F13}, { { 111, XK_F12 },
107, XK_F14}, { { 105, XK_F13 },
113, XK_F15},}; { 107, XK_F14 },
{ 113, XK_F15 },
};
#endif #endif
#if HACK_KEYPAD #if HACK_KEYPAD
@ -119,24 +121,24 @@ const static struct {
unsigned short keycode; unsigned short keycode;
KeySym normal, keypad; KeySym normal, keypad;
} known_numeric_keys[] = { } known_numeric_keys[] = {
{ { 65, XK_period, XK_KP_Decimal },
65, XK_period, XK_KP_Decimal}, { { 67, XK_asterisk, XK_KP_Multiply },
67, XK_asterisk, XK_KP_Multiply}, { { 69, XK_plus, XK_KP_Add },
69, XK_plus, XK_KP_Add}, { { 75, XK_slash, XK_KP_Divide },
75, XK_slash, XK_KP_Divide}, { { 76, 0x01000003, XK_KP_Enter },
76, 0x01000003, XK_KP_Enter}, { { 78, XK_minus, XK_KP_Subtract },
78, XK_minus, XK_KP_Subtract}, { { 81, XK_equal, XK_KP_Equal },
81, XK_equal, XK_KP_Equal}, { { 82, XK_0, XK_KP_0 },
82, XK_0, XK_KP_0}, { { 83, XK_1, XK_KP_1 },
83, XK_1, XK_KP_1}, { { 84, XK_2, XK_KP_2 },
84, XK_2, XK_KP_2}, { { 85, XK_3, XK_KP_3 },
85, XK_3, XK_KP_3}, { { 86, XK_4, XK_KP_4 },
86, XK_4, XK_KP_4}, { { 87, XK_5, XK_KP_5 },
87, XK_5, XK_KP_5}, { { 88, XK_6, XK_KP_6 },
88, XK_6, XK_KP_6}, { { 89, XK_7, XK_KP_7 },
89, XK_7, XK_KP_7}, { { 91, XK_8, XK_KP_8 },
91, XK_8, XK_KP_8}, { { 92, XK_9, XK_KP_9 },
92, XK_9, XK_KP_9},}; };
#endif #endif
#if HACK_BLACKLIST #if HACK_BLACKLIST
@ -155,40 +157,30 @@ const static unsigned short keycode_blacklist[] = { 66, 70, 72, 77 };
const static struct { const static struct {
KeySym normal, dead; KeySym normal, dead;
} dead_keys[] = { } dead_keys[] = {
{ { XK_grave, XK_dead_grave },
XK_grave, XK_dead_grave}, { { XK_apostrophe, XK_dead_acute }, /* US:"=" on a Czech keyboard */
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_acute, XK_dead_acute}, {
UKEYSYM(0x384), XK_dead_acute}, /* US:";" on a Greek keyboard */
// {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */ // {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
{ { XK_asciicircum, XK_dead_circumflex },
XK_asciicircum, XK_dead_circumflex}, { { UKEYSYM(0x2c6), XK_dead_circumflex }, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
UKEYSYM(0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */ { XK_asciitilde, XK_dead_tilde },
{ { UKEYSYM(0x2dc), XK_dead_tilde }, /* SMALL TILDE */
XK_asciitilde, XK_dead_tilde}, { { XK_macron, XK_dead_macron },
UKEYSYM(0x2dc), XK_dead_tilde}, /* SMALL TILDE */ { XK_breve, XK_dead_breve },
{ { XK_abovedot, XK_dead_abovedot },
XK_macron, XK_dead_macron}, { { XK_diaeresis, XK_dead_diaeresis },
XK_breve, XK_dead_breve}, { { UKEYSYM(0x2da), XK_dead_abovering }, /* DOT ABOVE */
XK_abovedot, XK_dead_abovedot}, { { XK_doubleacute, XK_dead_doubleacute },
XK_diaeresis, XK_dead_diaeresis}, { { XK_caron, XK_dead_caron },
UKEYSYM(0x2da), XK_dead_abovering}, /* DOT ABOVE */ { XK_cedilla, XK_dead_cedilla },
{ { XK_ogonek, XK_dead_ogonek },
XK_doubleacute, XK_dead_doubleacute}, { { UKEYSYM(0x269), XK_dead_iota }, /* LATIN SMALL LETTER IOTA */
XK_caron, XK_dead_caron}, { { UKEYSYM(0x2ec), XK_dead_voiced_sound }, /* MODIFIER LETTER VOICING */
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}, */ /* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
{ { UKEYSYM(0x323), XK_dead_belowdot }, /* COMBINING DOT BELOW */
UKEYSYM(0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */ { UKEYSYM(0x309), XK_dead_hook }, /* COMBINING HOOK ABOVE */
{ { UKEYSYM(0x31b), XK_dead_horn }, /* COMBINING HORN */
UKEYSYM(0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
{
UKEYSYM(0x31b), XK_dead_horn}, /* COMBINING HORN */
}; };
typedef struct darwinKeyboardInfo_struct { typedef struct darwinKeyboardInfo_struct {
@ -281,8 +273,8 @@ DarwinBuildModifierMaps(darwinKeyboardInfo * info)
break; break;
case XK_Mode_switch: case XK_Mode_switch:
ErrorF ErrorF(
("DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n"); "DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i; info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
#ifdef NX_MODIFIERKEY_RALTERNATE #ifdef NX_MODIFIERKEY_RALTERNATE
info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i; info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
@ -413,13 +405,16 @@ DarwinKeyboardReloadHandler(void)
if (!ok) if (!ok)
initialKeyRepeatValue = 35; initialKeyRepeatValue = 35;
keyRepeatValue = keyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR(
CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"), "KeyRepeat"),
CFSTR(".GlobalPreferences"), &ok); CFSTR(
".GlobalPreferences"),
&ok);
if (!ok) if (!ok)
keyRepeatValue = 6; keyRepeatValue = 6;
pthread_mutex_lock(&keyInfo_mutex); { pthread_mutex_lock(&keyInfo_mutex);
{
/* Initialize our keySyms */ /* Initialize our keySyms */
keySyms.map = keyInfo.keyMap; keySyms.map = keyInfo.keyMap;
keySyms.mapWidth = GLYPHS_PER_KEY; keySyms.mapWidth = GLYPHS_PER_KEY;
@ -436,43 +431,45 @@ DarwinKeyboardReloadHandler(void)
/* Apply the mappings to the core keyboard */ /* Apply the mappings to the core keyboard */
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) { if ((pDev->coreEvents ||
XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode, pDev == inputInfo.keyboard) && pDev->key) {
keySyms.maxKeyCode - keySyms.minKeyCode + XkbApplyMappingChange(
1, keyInfo.modMap, serverClient); pDev, &keySyms, keySyms.minKeyCode,
keySyms.maxKeyCode -
keySyms.minKeyCode + 1,
keyInfo.modMap, serverClient);
DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue, DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue,
keyRepeatValue); keyRepeatValue);
} }
} }
} } pthread_mutex_unlock(&keyInfo_mutex);
pthread_mutex_unlock(&keyInfo_mutex);
/* Modify with xmodmap */ /* Modify with xmodmap */
if (access(xmodmap, F_OK) == 0) { if (access(xmodmap, F_OK) == 0) {
/* Check for system .Xmodmap */ /* Check for system .Xmodmap */
if (access(sysmodmap, F_OK) == 0) { if (access(sysmodmap, F_OK) == 0) {
if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap) < if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap,
sizeof(cmd)) { sysmodmap) < sizeof(cmd)) {
X11ApplicationLaunchClient(cmd); X11ApplicationLaunchClient(cmd);
} }
else { else {
ErrorF ErrorF(
("X11.app: Unable to create / execute xmodmap command line"); "X11.app: Unable to create / execute xmodmap command line");
} }
} }
/* Check for user's local .Xmodmap */ /* Check for user's local .Xmodmap */
if ((homedir != NULL) && if ((homedir != NULL) &&
(snprintf(usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir) < (snprintf(usermodmap, sizeof(usermodmap), "%s/.Xmodmap",
sizeof(usermodmap))) { homedir) < sizeof(usermodmap))) {
if (access(usermodmap, F_OK) == 0) { if (access(usermodmap, F_OK) == 0) {
if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap) < if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap,
sizeof(cmd)) { usermodmap) < sizeof(cmd)) {
X11ApplicationLaunchClient(cmd); X11ApplicationLaunchClient(cmd);
} }
else { else {
ErrorF ErrorF(
("X11.app: Unable to create / execute xmodmap command line"); "X11.app: Unable to create / execute xmodmap command line");
} }
} }
} }
@ -502,7 +499,6 @@ int
DarwinModifierNXKeyToNXKeycode(int key, int side) DarwinModifierNXKeyToNXKeycode(int key, int side)
{ {
int retval; int retval;
pthread_mutex_lock(&keyInfo_mutex); pthread_mutex_lock(&keyInfo_mutex);
retval = keyInfo.modifierKeycodes[key][side]; retval = keyInfo.modifierKeycodes[key][side];
pthread_mutex_unlock(&keyInfo_mutex); pthread_mutex_unlock(&keyInfo_mutex);
@ -526,8 +522,7 @@ DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
pthread_mutex_lock(&keyInfo_mutex); pthread_mutex_lock(&keyInfo_mutex);
for (key = 0; key < NX_NUMMODIFIERS; key++) { for (key = 0; key < NX_NUMMODIFIERS; key++) {
for (side = 0; side <= 1; side++) { for (side = 0; side <= 1; side++) {
if (keyInfo.modifierKeycodes[key][side] == keycode) if (keyInfo.modifierKeycodes[key][side] == keycode) break;
break;
} }
} }
pthread_mutex_unlock(&keyInfo_mutex); pthread_mutex_unlock(&keyInfo_mutex);
@ -535,8 +530,7 @@ DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
if (key == NX_NUMMODIFIERS) { if (key == NX_NUMMODIFIERS) {
return -1; return -1;
} }
if (outSide) if (outSide) *outSide = side;
*outSide = side;
return key; return key;
} }
@ -551,42 +545,57 @@ DarwinModifierNXMaskToNXKey(int mask)
switch (mask) { switch (mask) {
case NX_ALPHASHIFTMASK: case NX_ALPHASHIFTMASK:
return NX_MODIFIERKEY_ALPHALOCK; return NX_MODIFIERKEY_ALPHALOCK;
case NX_SHIFTMASK: case NX_SHIFTMASK:
return NX_MODIFIERKEY_SHIFT; return NX_MODIFIERKEY_SHIFT;
#ifdef NX_DEVICELSHIFTKEYMASK #ifdef NX_DEVICELSHIFTKEYMASK
case NX_DEVICELSHIFTKEYMASK: case NX_DEVICELSHIFTKEYMASK:
return NX_MODIFIERKEY_SHIFT; return NX_MODIFIERKEY_SHIFT;
case NX_DEVICERSHIFTKEYMASK: case NX_DEVICERSHIFTKEYMASK:
return NX_MODIFIERKEY_RSHIFT; return NX_MODIFIERKEY_RSHIFT;
#endif #endif
case NX_CONTROLMASK: case NX_CONTROLMASK:
return NX_MODIFIERKEY_CONTROL; return NX_MODIFIERKEY_CONTROL;
#ifdef NX_DEVICELCTLKEYMASK #ifdef NX_DEVICELCTLKEYMASK
case NX_DEVICELCTLKEYMASK: case NX_DEVICELCTLKEYMASK:
return NX_MODIFIERKEY_CONTROL; return NX_MODIFIERKEY_CONTROL;
case NX_DEVICERCTLKEYMASK: case NX_DEVICERCTLKEYMASK:
return NX_MODIFIERKEY_RCONTROL; return NX_MODIFIERKEY_RCONTROL;
#endif #endif
case NX_ALTERNATEMASK: case NX_ALTERNATEMASK:
return NX_MODIFIERKEY_ALTERNATE; return NX_MODIFIERKEY_ALTERNATE;
#ifdef NX_DEVICELALTKEYMASK #ifdef NX_DEVICELALTKEYMASK
case NX_DEVICELALTKEYMASK: case NX_DEVICELALTKEYMASK:
return NX_MODIFIERKEY_ALTERNATE; return NX_MODIFIERKEY_ALTERNATE;
case NX_DEVICERALTKEYMASK: case NX_DEVICERALTKEYMASK:
return NX_MODIFIERKEY_RALTERNATE; return NX_MODIFIERKEY_RALTERNATE;
#endif #endif
case NX_COMMANDMASK: case NX_COMMANDMASK:
return NX_MODIFIERKEY_COMMAND; return NX_MODIFIERKEY_COMMAND;
#ifdef NX_DEVICELCMDKEYMASK #ifdef NX_DEVICELCMDKEYMASK
case NX_DEVICELCMDKEYMASK: case NX_DEVICELCMDKEYMASK:
return NX_MODIFIERKEY_COMMAND; return NX_MODIFIERKEY_COMMAND;
case NX_DEVICERCMDKEYMASK: case NX_DEVICERCMDKEYMASK:
return NX_MODIFIERKEY_RCOMMAND; return NX_MODIFIERKEY_RCOMMAND;
#endif #endif
case NX_NUMERICPADMASK: case NX_NUMERICPADMASK:
return NX_MODIFIERKEY_NUMERICPAD; return NX_MODIFIERKEY_NUMERICPAD;
case NX_HELPMASK: case NX_HELPMASK:
return NX_MODIFIERKEY_HELP; return NX_MODIFIERKEY_HELP;
case NX_SECONDARYFNMASK: case NX_SECONDARYFNMASK:
return NX_MODIFIERKEY_SECONDARYFN; return NX_MODIFIERKEY_SECONDARYFN;
} }
@ -603,37 +612,52 @@ DarwinModifierNXKeyToNXMask(int key)
switch (key) { switch (key) {
case NX_MODIFIERKEY_ALPHALOCK: case NX_MODIFIERKEY_ALPHALOCK:
return NX_ALPHASHIFTMASK; return NX_ALPHASHIFTMASK;
#ifdef NX_DEVICELSHIFTKEYMASK #ifdef NX_DEVICELSHIFTKEYMASK
case NX_MODIFIERKEY_SHIFT: case NX_MODIFIERKEY_SHIFT:
return NX_DEVICELSHIFTKEYMASK; return NX_DEVICELSHIFTKEYMASK;
case NX_MODIFIERKEY_RSHIFT: case NX_MODIFIERKEY_RSHIFT:
return NX_DEVICERSHIFTKEYMASK; return NX_DEVICERSHIFTKEYMASK;
case NX_MODIFIERKEY_CONTROL: case NX_MODIFIERKEY_CONTROL:
return NX_DEVICELCTLKEYMASK; return NX_DEVICELCTLKEYMASK;
case NX_MODIFIERKEY_RCONTROL: case NX_MODIFIERKEY_RCONTROL:
return NX_DEVICERCTLKEYMASK; return NX_DEVICERCTLKEYMASK;
case NX_MODIFIERKEY_ALTERNATE: case NX_MODIFIERKEY_ALTERNATE:
return NX_DEVICELALTKEYMASK; return NX_DEVICELALTKEYMASK;
case NX_MODIFIERKEY_RALTERNATE: case NX_MODIFIERKEY_RALTERNATE:
return NX_DEVICERALTKEYMASK; return NX_DEVICERALTKEYMASK;
case NX_MODIFIERKEY_COMMAND: case NX_MODIFIERKEY_COMMAND:
return NX_DEVICELCMDKEYMASK; return NX_DEVICELCMDKEYMASK;
case NX_MODIFIERKEY_RCOMMAND: case NX_MODIFIERKEY_RCOMMAND:
return NX_DEVICERCMDKEYMASK; return NX_DEVICERCMDKEYMASK;
#else #else
case NX_MODIFIERKEY_SHIFT: case NX_MODIFIERKEY_SHIFT:
return NX_SHIFTMASK; return NX_SHIFTMASK;
case NX_MODIFIERKEY_CONTROL: case NX_MODIFIERKEY_CONTROL:
return NX_CONTROLMASK; return NX_CONTROLMASK;
case NX_MODIFIERKEY_ALTERNATE: case NX_MODIFIERKEY_ALTERNATE:
return NX_ALTERNATEMASK; return NX_ALTERNATEMASK;
case NX_MODIFIERKEY_COMMAND: case NX_MODIFIERKEY_COMMAND:
return NX_COMMANDMASK; return NX_COMMANDMASK;
#endif #endif
case NX_MODIFIERKEY_NUMERICPAD: case NX_MODIFIERKEY_NUMERICPAD:
return NX_NUMERICPADMASK; return NX_NUMERICPADMASK;
case NX_MODIFIERKEY_HELP: case NX_MODIFIERKEY_HELP:
return NX_HELPMASK; return NX_HELPMASK;
case NX_MODIFIERKEY_SECONDARYFN: case NX_MODIFIERKEY_SECONDARYFN:
return NX_SECONDARYFNMASK; return NX_SECONDARYFNMASK;
} }
@ -649,80 +673,56 @@ DarwinModifierStringToNXMask(const char *str, int separatelr)
{ {
#ifdef NX_DEVICELSHIFTKEYMASK #ifdef NX_DEVICELSHIFTKEYMASK
if (separatelr) { if (separatelr) {
if (!strcasecmp(str, "shift")) if (!strcasecmp(str,
return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK; "shift")) return NX_DEVICELSHIFTKEYMASK |
if (!strcasecmp(str, "control")) NX_DEVICERSHIFTKEYMASK;
return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK; if (!strcasecmp(str,
if (!strcasecmp(str, "option")) "control")) return NX_DEVICELCTLKEYMASK |
return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK; NX_DEVICERCTLKEYMASK;
if (!strcasecmp(str, "alt")) if (!strcasecmp(str,
return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK; "option")) return NX_DEVICELALTKEYMASK |
if (!strcasecmp(str, "command")) NX_DEVICERALTKEYMASK;
return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK; if (!strcasecmp(str,
if (!strcasecmp(str, "lshift")) "alt")) return NX_DEVICELALTKEYMASK |
return NX_DEVICELSHIFTKEYMASK; NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "rshift")) if (!strcasecmp(str,
return NX_DEVICERSHIFTKEYMASK; "command")) return NX_DEVICELCMDKEYMASK |
if (!strcasecmp(str, "lcontrol")) NX_DEVICERCMDKEYMASK;
return NX_DEVICELCTLKEYMASK; if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK;
if (!strcasecmp(str, "rcontrol")) if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK;
return NX_DEVICERCTLKEYMASK; if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK;
if (!strcasecmp(str, "loption")) if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK;
return NX_DEVICELALTKEYMASK; if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK;
if (!strcasecmp(str, "roption")) if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK;
return NX_DEVICERALTKEYMASK; if (!strcasecmp(str, "lalt")) return NX_DEVICELALTKEYMASK;
if (!strcasecmp(str, "lalt")) if (!strcasecmp(str, "ralt")) return NX_DEVICERALTKEYMASK;
return NX_DEVICELALTKEYMASK; if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK;
if (!strcasecmp(str, "ralt")) if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK;
return NX_DEVICERALTKEYMASK;
if (!strcasecmp(str, "lcommand"))
return NX_DEVICELCMDKEYMASK;
if (!strcasecmp(str, "rcommand"))
return NX_DEVICERCMDKEYMASK;
} }
else { else {
#endif #endif
if (!strcasecmp(str, "shift")) if (!strcasecmp(str, "shift")) return NX_SHIFTMASK;
return NX_SHIFTMASK; if (!strcasecmp(str, "control")) return NX_CONTROLMASK;
if (!strcasecmp(str, "control")) if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK;
return NX_CONTROLMASK; if (!strcasecmp(str, "alt")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "option")) if (!strcasecmp(str, "command")) return NX_COMMANDMASK;
return NX_ALTERNATEMASK; if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK;
if (!strcasecmp(str, "alt")) if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK;
return NX_ALTERNATEMASK; if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK;
if (!strcasecmp(str, "command")) if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK;
return NX_COMMANDMASK; if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "lshift")) if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK;
return NX_SHIFTMASK; if (!strcasecmp(str, "lalt")) return NX_ALTERNATEMASK;
if (!strcasecmp(str, "rshift")) if (!strcasecmp(str, "ralt")) return NX_ALTERNATEMASK;
return NX_SHIFTMASK; if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK;
if (!strcasecmp(str, "lcontrol")) if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK;
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 #ifdef NX_DEVICELSHIFTKEYMASK
} }
#endif #endif
if (!strcasecmp(str, "lock")) if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK;
return NX_ALPHASHIFTMASK; if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK;
if (!strcasecmp(str, "fn")) if (!strcasecmp(str, "help")) return NX_HELPMASK;
return NX_SECONDARYFNMASK; if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK;
if (!strcasecmp(str, "help"))
return NX_HELPMASK;
if (!strcasecmp(str, "numlock"))
return NX_NUMERICPADMASK;
return 0; return 0;
} }
@ -745,28 +745,42 @@ macroman2ucs(unsigned char c)
first character. */ first character. */
static const unsigned short table[128] = { static const unsigned short table[128] = {
0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1, 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc,
0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8, 0xe1,
0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3, 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9,
0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc, 0xe8,
0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf, 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1,
0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8, 0xf3,
0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211, 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb,
0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8, 0xfc,
0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab, 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6,
0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153, 0xdf,
0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca, 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6,
0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02, 0xd8,
0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1, 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202,
0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4, 0x2211,
0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc, 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6,
0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7, 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) if (c < 128) return c;
return c; else return table[c - 128];
else
return table[c - 128];
} }
static KeySym static KeySym
@ -775,8 +789,7 @@ make_dead_key(KeySym in)
int i; int i;
for (i = 0; i < sizeof(dead_keys) / sizeof(dead_keys[0]); i++) for (i = 0; i < sizeof(dead_keys) / sizeof(dead_keys[0]); i++)
if (dead_keys[i].normal == in) if (dead_keys[i].normal == in) return dead_keys[i].dead;
return dead_keys[i].dead;
return in; return in;
} }
@ -801,9 +814,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
TISCopyCurrentKeyboardLayoutInputSource(); TISCopyCurrentKeyboardLayoutInputSource();
if (currentKeyLayoutRef) { if (currentKeyLayoutRef) {
currentKeyLayoutDataRef = currentKeyLayoutDataRef = (CFDataRef)TISGetInputSourceProperty(
(CFDataRef) TISGetInputSourceProperty(currentKeyLayoutRef, currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
kTISPropertyUnicodeKeyLayoutData);
if (currentKeyLayoutDataRef) if (currentKeyLayoutDataRef)
chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef); chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
} }
@ -817,10 +829,10 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 #if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (chr_data == NULL) { if (chr_data == NULL) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
ErrorF 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"); "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 ErrorF(
("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n", "X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
(unsigned)keyboard_type, currentKeyLayoutRef, (unsigned)keyboard_type, currentKeyLayoutRef,
currentKeyLayoutDataRef, chr_data); currentKeyLayoutDataRef, chr_data);
#endif #endif
@ -830,25 +842,25 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
if (chr_data != NULL) { if (chr_data != NULL) {
ErrorF ErrorF(
("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n"); "X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
} }
#endif #endif
} }
if (chr_data == NULL) { if (chr_data == NULL) {
ErrorF ErrorF(
("X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n"); "X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
ErrorF ErrorF(
("If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n"); "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); KLGetKeyboardLayoutProperty(key_layout, kKLKCHRData, &chr_data);
is_uchr = 0; is_uchr = 0;
num_keycodes = 128; num_keycodes = 128;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
if (chr_data != NULL) { if (chr_data != NULL) {
ErrorF ErrorF(
("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n"); "X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
} }
#endif #endif
} }
@ -877,7 +889,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
must be used instead. */ must be used instead. */
for (i = 0; i < num_keycodes; i++) { 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 MOD_OPTION | MOD_SHIFT
}; };
@ -894,8 +907,7 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
err = UCKeyTranslate(chr_data, i, kUCKeyActionDown, err = UCKeyTranslate(chr_data, i, kUCKeyActionDown,
mods[j] >> 8, keyboard_type, 0, mods[j] >> 8, keyboard_type, 0,
&dead_key_state, 8, &len, s); &dead_key_state, 8, &len, s);
if (err != noErr) if (err != noErr) continue;
continue;
if (len == 0 && dead_key_state != 0) { if (len == 0 && dead_key_state != 0) {
/* Found a dead key. Work out which one it is, but /* Found a dead key. Work out which one it is, but
@ -904,8 +916,7 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
mods[j] >> 8, keyboard_type, mods[j] >> 8, keyboard_type,
kUCKeyTranslateNoDeadKeysMask, kUCKeyTranslateNoDeadKeysMask,
&extra_dead, 8, &len, s); &extra_dead, 8, &len, s);
if (err != noErr) if (err != noErr) continue;
continue;
} }
/* Not sure why 0x0010 is there. /* Not sure why 0x0010 is there.
@ -913,8 +924,7 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
*/ */
if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) { if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
k[j] = ucs2keysym(s[0]); k[j] = ucs2keysym(s[0]);
if (dead_key_state != 0) if (dead_key_state != 0) k[j] = make_dead_key(k[j]);
k[j] = make_dead_key(k[j]);
} }
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 #if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
} }
@ -948,21 +958,16 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
if (c != 0 && c != 0x0010) { if (c != 0 && c != 0x0010) {
k[j] = ucs2keysym(macroman2ucs(c & 255)); k[j] = ucs2keysym(macroman2ucs(c & 255));
if (state != 0) if (state != 0) k[j] = make_dead_key(k[j]);
k[j] = make_dead_key(k[j]);
} }
} }
#endif #endif
} }
if (k[3] == k[2]) if (k[3] == k[2]) k[3] = NoSymbol;
k[3] = NoSymbol; if (k[1] == k[0]) k[1] = NoSymbol;
if (k[1] == k[0]) if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
k[1] = NoSymbol; if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = 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 #if HACK_MISSING
@ -1006,7 +1011,6 @@ Bool
QuartsResyncKeymap(Bool sendDDXEvent) QuartsResyncKeymap(Bool sendDDXEvent)
{ {
Bool retval; Bool retval;
/* Update keyInfo */ /* Update keyInfo */
pthread_mutex_lock(&keyInfo_mutex); pthread_mutex_lock(&keyInfo_mutex);
memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap)); 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. * Copyright (c) 2003-2004 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -40,17 +41,25 @@
#define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1 #define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1
/* These functions need to be implemented by Xquartz, XDarwin, etc. */ /* These functions need to be implemented by Xquartz, XDarwin, etc. */
Bool QuartsResyncKeymap(Bool sendDDXEvent); Bool
QuartsResyncKeymap(Bool sendDDXEvent);
/* Provided for darwinEvents.c */ /* Provided for darwinEvents.c */
void DarwinKeyboardReloadHandler(void); void
int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide); DarwinKeyboardReloadHandler(void);
int DarwinModifierNXKeyToNXKeycode(int key, int side); int
int DarwinModifierNXKeyToNXMask(int key); DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
int DarwinModifierNXMaskToNXKey(int mask); int
int DarwinModifierStringToNXMask(const char *string, int separatelr); DarwinModifierNXKeyToNXKeycode(int key, int side);
int
DarwinModifierNXKeyToNXMask(int key);
int
DarwinModifierNXMaskToNXKey(int mask);
int
DarwinModifierStringToNXMask(const char *string, int separatelr);
/* Provided for darwin.c */ /* 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, * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons,
* 2010 Jan Hauffa. * 2010 Jan Hauffa.
* 2010-2011 Apple Inc. * 2010-2012 Apple Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -74,7 +74,6 @@ getDictLong(CFDictionaryRef dictRef, CFStringRef key)
long value; long value;
CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key); CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key);
if (!numRef) if (!numRef)
return 0; return 0;
@ -89,7 +88,6 @@ getDictDouble(CFDictionaryRef dictRef, CFStringRef key)
double value; double value;
CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key); CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key);
if (!numRef) if (!numRef)
return 0.0; return 0.0;
@ -99,7 +97,8 @@ getDictDouble(CFDictionaryRef dictRef, CFStringRef key)
} }
static void static void
QuartzRandRGetModeInfo(CFDictionaryRef modeRef, QuartzModeInfoPtr pMode) QuartzRandRGetModeInfo(CFDictionaryRef modeRef,
QuartzModeInfoPtr pMode)
{ {
pMode->width = (size_t)getDictLong(modeRef, kCGDisplayWidth); pMode->width = (size_t)getDictLong(modeRef, kCGDisplayWidth);
pMode->height = (size_t)getDictLong(modeRef, kCGDisplayHeight); pMode->height = (size_t)getDictLong(modeRef, kCGDisplayHeight);
@ -116,7 +115,6 @@ QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
QuartzModeInfoPtr pMode) QuartzModeInfoPtr pMode)
{ {
CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId); CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId);
if (!curModeRef) if (!curModeRef)
return FALSE; return FALSE;
@ -127,16 +125,17 @@ QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
} }
static Bool 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); return (CGDisplaySwitchToMode(screenId, modeRef) == kCGErrorSuccess);
} }
static Bool static Bool
QuartzRandREnumerateModes(ScreenPtr pScreen, QuartzRandREnumerateModes(ScreenPtr pScreen,
QuartzModeCallback callback, void *data) QuartzModeCallback callback,
void *data)
{ {
Bool retval = FALSE; Bool retval = FALSE;
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
@ -160,7 +159,6 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
return FALSE; return FALSE;
for (i = 0; i < CFArrayGetCount(modes); i++) { for (i = 0; i < CFArrayGetCount(modes); i++) {
int cb; 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 /* Skip modes that are not usable on the current display or have a
@ -186,10 +184,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) { switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
case CALLBACK_SUCCESS: case CALLBACK_SUCCESS:
return TRUE; return TRUE;
case CALLBACK_ERROR: case CALLBACK_ERROR:
return FALSE; return FALSE;
case CALLBACK_CONTINUE: case CALLBACK_CONTINUE:
retval = TRUE; retval = TRUE;
default: default:
break; break;
} }
@ -197,10 +198,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
case CALLBACK_SUCCESS: case CALLBACK_SUCCESS:
return TRUE; return TRUE;
case CALLBACK_ERROR: case CALLBACK_ERROR:
return FALSE; return FALSE;
case CALLBACK_CONTINUE: case CALLBACK_CONTINUE:
retval = TRUE; retval = TRUE;
default: default:
break; break;
} }
@ -211,7 +215,8 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
#else /* we have the new CG APIs from Snow Leopard */ #else /* we have the new CG APIs from Snow Leopard */
static void static void
QuartzRandRGetModeInfo(CGDisplayModeRef modeRef, QuartzModeInfoPtr pMode) QuartzRandRGetModeInfo(CGDisplayModeRef modeRef,
QuartzModeInfoPtr pMode)
{ {
pMode->width = CGDisplayModeGetWidth(modeRef); pMode->width = CGDisplayModeGetWidth(modeRef);
pMode->height = CGDisplayModeGetHeight(modeRef); pMode->height = CGDisplayModeGetHeight(modeRef);
@ -227,7 +232,6 @@ QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
QuartzModeInfoPtr pMode) QuartzModeInfoPtr pMode)
{ {
CGDisplayModeRef curModeRef = CGDisplayCopyDisplayMode(screenId); CGDisplayModeRef curModeRef = CGDisplayCopyDisplayMode(screenId);
if (!curModeRef) if (!curModeRef)
return FALSE; return FALSE;
@ -237,20 +241,21 @@ QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
} }
static Bool static Bool
QuartzRandRSetCGMode(CGDirectDisplayID screenId, QuartzModeInfoPtr pMode) QuartzRandRSetCGMode(CGDirectDisplayID screenId,
QuartzModeInfoPtr pMode)
{ {
CGDisplayModeRef modeRef = (CGDisplayModeRef)pMode->ref; CGDisplayModeRef modeRef = (CGDisplayModeRef)pMode->ref;
if (!modeRef) if (!modeRef)
return FALSE; return FALSE;
return (CGDisplaySetDisplayMode(screenId, modeRef, NULL) == return (CGDisplaySetDisplayMode(screenId, modeRef,
kCGErrorSuccess); NULL) == kCGErrorSuccess);
} }
static Bool static Bool
QuartzRandREnumerateModes(ScreenPtr pScreen, QuartzRandREnumerateModes(ScreenPtr pScreen,
QuartzModeCallback callback, void *data) QuartzModeCallback callback,
void *data)
{ {
Bool retval = FALSE; Bool retval = FALSE;
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
@ -278,12 +283,12 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
} }
for (i = 0; i < CFArrayGetCount(modes); i++) { for (i = 0; i < CFArrayGetCount(modes); i++) {
int cb; 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 /* Skip modes that are not usable on the current display or have a
different pixel encoding than the current mode. */ different pixel encoding than the current mode. */
if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) != if ((CGDisplayModeGetIOFlags(modeRef) &
kDisplayModeUsableFlags) !=
kDisplayModeUsableFlags) kDisplayModeUsableFlags)
continue; continue;
pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef); pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
@ -317,10 +322,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) { switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
case CALLBACK_SUCCESS: case CALLBACK_SUCCESS:
return TRUE; return TRUE;
case CALLBACK_ERROR: case CALLBACK_ERROR:
return FALSE; return FALSE;
case CALLBACK_CONTINUE: case CALLBACK_CONTINUE:
retval = TRUE; retval = TRUE;
default: default:
break; break;
} }
@ -328,10 +336,13 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
case CALLBACK_SUCCESS: case CALLBACK_SUCCESS:
return TRUE; return TRUE;
case CALLBACK_ERROR: case CALLBACK_ERROR:
return FALSE; return FALSE;
case CALLBACK_CONTINUE: case CALLBACK_CONTINUE:
retval = TRUE; retval = TRUE;
default: default:
break; break;
} }
@ -342,7 +353,8 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
#endif /* Snow Leopard CoreGraphics APIs */ #endif /* Snow Leopard CoreGraphics APIs */
static Bool static Bool
QuartzRandRModesEqual(QuartzModeInfoPtr pMode1, QuartzModeInfoPtr pMode2) QuartzRandRModesEqual(QuartzModeInfoPtr pMode1,
QuartzModeInfoPtr pMode2)
{ {
return (pMode1->width == pMode2->width) && return (pMode1->width == pMode2->width) &&
(pMode1->height == pMode2->height) && (pMode1->height == pMode2->height) &&
@ -350,11 +362,12 @@ QuartzRandRModesEqual(QuartzModeInfoPtr pMode1, QuartzModeInfoPtr pMode2)
} }
static Bool static Bool
QuartzRandRRegisterMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode) QuartzRandRRegisterMode(ScreenPtr pScreen,
QuartzModeInfoPtr pMode)
{ {
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
Bool isCurrentMode = Bool isCurrentMode = QuartzRandRModesEqual(&pQuartzScreen->currentMode,
QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode); pMode);
/* TODO: DPI */ /* TODO: DPI */
pMode->pSize = pMode->pSize =
@ -375,7 +388,8 @@ QuartzRandRRegisterMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode)
static int static int
QuartzRandRRegisterModeCallback(ScreenPtr pScreen, QuartzRandRRegisterModeCallback(ScreenPtr pScreen,
QuartzModeInfoPtr pMode, void *data __unused) QuartzModeInfoPtr pMode,
void *data __unused)
{ {
if (QuartzRandRRegisterMode(pScreen, pMode)) { if (QuartzRandRRegisterMode(pScreen, pMode)) {
return CALLBACK_CONTINUE; return CALLBACK_CONTINUE;
@ -386,11 +400,13 @@ QuartzRandRRegisterModeCallback(ScreenPtr pScreen,
} }
static Bool static Bool
QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode,
BOOL doRegister)
{ {
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && Bool captureDisplay =
pMode->refresh != FAKE_REFRESH_ROOTLESS); (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh !=
FAKE_REFRESH_ROOTLESS);
CGDirectDisplayID screenId; CGDirectDisplayID screenId;
if (pQuartzScreen->displayIDs == NULL) if (pQuartzScreen->displayIDs == NULL)
@ -442,7 +458,8 @@ QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister)
static int static int
QuartzRandRSetModeCallback(ScreenPtr pScreen, QuartzRandRSetModeCallback(ScreenPtr pScreen,
QuartzModeInfoPtr pMode, void *data) QuartzModeInfoPtr pMode,
void *data)
{ {
QuartzModeInfoPtr pReqMode = (QuartzModeInfoPtr)data; QuartzModeInfoPtr pReqMode = (QuartzModeInfoPtr)data;
@ -469,7 +486,9 @@ QuartzRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
static Bool static Bool
QuartzRandRSetConfig(ScreenPtr pScreen, QuartzRandRSetConfig(ScreenPtr pScreen,
Rotation randr, int rate, RRScreenSizePtr pSize) Rotation randr,
int rate,
RRScreenSizePtr pSize)
{ {
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
QuartzModeInfo reqMode; QuartzModeInfo reqMode;
@ -482,13 +501,14 @@ QuartzRandRSetConfig(ScreenPtr pScreen,
if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode)) if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode))
return TRUE; return TRUE;
if (QuartzRandREnumerateModes if (QuartzRandREnumerateModes(pScreen, QuartzRandRSetModeCallback,
(pScreen, QuartzRandRSetModeCallback, &reqMode)) { &reqMode)) {
return TRUE; return TRUE;
} }
DEBUG_LOG("Unable to find a matching config: %d x %d @ %d\n", 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; return FALSE;
} }
@ -499,8 +519,8 @@ _QuartzRandRUpdateFakeModes(ScreenPtr pScreen)
QuartzModeInfo activeMode; QuartzModeInfo activeMode;
if (pQuartzScreen->displayCount > 0) { if (pQuartzScreen->displayCount > 0) {
if (!QuartzRandRCopyCurrentModeInfo if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0],
(pQuartzScreen->displayIDs[0], &activeMode)) { &activeMode)) {
ErrorF("Unable to determine current display mode.\n"); ErrorF("Unable to determine current display mode.\n");
return FALSE; return FALSE;
} }
@ -562,8 +582,8 @@ QuartzRandRUpdateFakeModes(BOOL force_update)
ScreenPtr pScreen = screenInfo.screens[0]; ScreenPtr pScreen = screenInfo.screens[0];
if (ignore_next_fake_mode_update) { if (ignore_next_fake_mode_update) {
DEBUG_LOG DEBUG_LOG(
("Ignoring update request caused by RandR resolution change.\n"); "Ignoring update request caused by RandR resolution change.\n");
ignore_next_fake_mode_update = FALSE; ignore_next_fake_mode_update = FALSE;
return TRUE; return TRUE;
} }
@ -582,10 +602,8 @@ QuartzRandRInit(ScreenPtr pScreen)
{ {
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
if (!RRScreenInit(pScreen)) if (!RRScreenInit(pScreen)) return FALSE;
return FALSE; if (!_QuartzRandRUpdateFakeModes(pScreen)) return FALSE;
if (!_QuartzRandRUpdateFakeModes(pScreen))
return FALSE;
pScrPriv = rrGetScrPriv(pScreen); pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = QuartzRandRGetInfo; pScrPriv->rrGetInfo = QuartzRandRGetInfo;
@ -637,12 +655,12 @@ QuartzRandRToggleFullscreen(void)
QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
if (pQuartzScreen->currentMode.ref == NULL) { if (pQuartzScreen->currentMode.ref == NULL) {
ErrorF ErrorF(
("Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n"); "Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n");
} }
else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) { else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) {
ErrorF ErrorF(
("Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n"); "Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n");
} }
else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_FULLSCREEN) { else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_FULLSCREEN) {
/* Legacy fullscreen mode. Hide/Show */ /* Legacy fullscreen mode. Hide/Show */

View File

@ -2,7 +2,7 @@
* quartzRandR.h * quartzRandR.h
* *
* Copyright (c) 2010 Jan Hauffa. * Copyright (c) 2010 Jan Hauffa.
* 2010 Apple Inc. * 2010-2012 Apple Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -54,11 +54,14 @@ typedef struct {
#define QUARTZ_PRIV(pScreen) \ #define QUARTZ_PRIV(pScreen) \
((QuartzScreenPtr)dixLookupPrivate(&pScreen->devPrivates, quartzScreenKey)) ((QuartzScreenPtr)dixLookupPrivate(&pScreen->devPrivates, quartzScreenKey))
void QuartzCopyDisplayIDs(ScreenPtr pScreen, void
int displayCount, CGDirectDisplayID * displayIDs); QuartzCopyDisplayIDs(ScreenPtr pScreen, int displayCount,
CGDirectDisplayID *displayIDs);
Bool QuartzRandRUpdateFakeModes(BOOL force_update); Bool
Bool QuartzRandRInit(ScreenPtr pScreen); QuartzRandRUpdateFakeModes(BOOL force_update);
Bool
QuartzRandRInit(ScreenPtr pScreen);
/* These two functions provide functionality expected by the legacy /* These two functions provide functionality expected by the legacy
* mode switching. They are equivalent to a client requesting one * 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 * QuartzRandRSetFakeFullscreen takes an argument which is used to determine
* the visibility of the windows after the change. * the visibility of the windows after the change.
*/ */
void QuartzRandRSetFakeRootless(void); void
void QuartzRandRSetFakeFullscreen(BOOL state); QuartzRandRSetFakeRootless(void);
void
QuartzRandRSetFakeFullscreen(BOOL state);
/* Toggle fullscreen mode. If "fake" fullscreen is the current mode, /* 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 * 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 * mode, this will toggles us to the default fake mode and hide windows if
* it is fullscreen * it is fullscreen
*/ */
void QuartzRandRToggleFullscreen(void); void
QuartzRandRToggleFullscreen(void);
#endif #endif

View File

@ -1,7 +1,7 @@
/************************************************************** /**************************************************************
* *
* Startup code for the Quartz Darwin X Server * 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. * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -48,7 +48,8 @@
#include <pthread.h> #include <pthread.h>
int dix_main(int argc, char **argv, char **envp); int
dix_main(int argc, char **argv, char **envp);
struct arg { struct arg {
int argc; int argc;
@ -56,11 +57,11 @@ struct arg {
char **envp; char **envp;
}; };
_X_NORETURN static void _X_NORETURN
static void
server_thread(void *arg) server_thread(void *arg)
{ {
struct arg args = *((struct arg *)arg); struct arg args = *((struct arg *)arg);
free(arg); free(arg);
exit(dix_main(args.argc, args.argv, args.envp)); exit(dix_main(args.argc, args.argv, args.envp));
} }
@ -84,7 +85,6 @@ void
QuartzInitServer(int argc, char **argv, char **envp) 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) if (!args)
FatalError("Could not allocate memory.\n"); FatalError("Could not allocate memory.\n");
@ -117,7 +117,8 @@ server_main(int argc, char **argv, char **envp)
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
// Display version info without starting Mac OS X UI if requested // 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(); DarwinPrintBanner();
exit(0); exit(0);
} }

View File

@ -2,7 +2,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc. Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2009-2011 Apple Inc. Copyright (c) 2002, 2009-2012 Apple Inc.
All Rights Reserved. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -32,6 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Kevin E. Martin <martin@valinux.com> * Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com> * Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@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 int DRIErrorBase = 0;
static void AppleDRIResetProc(ExtensionEntry * extEntry); static void
static int ProcAppleDRICreatePixmap(ClientPtr client); AppleDRIResetProc(ExtensionEntry* extEntry);
static int
ProcAppleDRICreatePixmap(ClientPtr client);
static unsigned char DRIReqCode = 0; static unsigned char DRIReqCode = 0;
static int DRIEventBase = 0; static int DRIEventBase = 0;
static void SNotifyEvent(xAppleDRINotifyEvent * from, static void
xAppleDRINotifyEvent * to); SNotifyEvent(xAppleDRINotifyEvent *from, xAppleDRINotifyEvent *to);
typedef struct _DRIEvent *DRIEventPtr; typedef struct _DRIEvent *DRIEventPtr;
typedef struct _DRIEvent { typedef struct _DRIEvent {
@ -76,7 +79,8 @@ typedef struct _DRIEvent {
unsigned int mask; unsigned int mask;
} DRIEventRec; } DRIEventRec;
/*ARGSUSED*/ static void /*ARGSUSED*/
static void
AppleDRIResetProc(ExtensionEntry* extEntry) AppleDRIResetProc(ExtensionEntry* extEntry)
{ {
DRIReset(); DRIReset();
@ -152,7 +156,8 @@ ProcAppleDRIAuthConnection(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.authenticated = 1; rep.authenticated = 1;
if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) { if (!DRIAuthConnection(screenInfo.screens[stuff->screen],
stuff->magic)) {
ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic); ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
rep.authenticated = 0; rep.authenticated = 0;
} }
@ -168,7 +173,8 @@ ProcAppleDRIAuthConnection(register ClientPtr client)
} }
static void static void
surface_notify(void *_arg, void *data) surface_notify(void *_arg,
void *data)
{ {
DRISurfaceNotifyArg *arg = _arg; DRISurfaceNotifyArg *arg = _arg;
int client_index = (int)x_cvt_vptr_to_uint(data); int client_index = (int)x_cvt_vptr_to_uint(data);
@ -209,7 +215,8 @@ ProcAppleDRICreateSurface(ClientPtr client)
if (!DRICreateSurface(screenInfo.screens[stuff->screen], if (!DRICreateSurface(screenInfo.screens[stuff->screen],
(Drawable)stuff->drawable, pDrawable, (Drawable)stuff->drawable, pDrawable,
stuff->client_id, &sid, key, 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; return BadValue;
} }
@ -233,10 +240,8 @@ static int
ProcAppleDRIDestroySurface(register ClientPtr client) ProcAppleDRIDestroySurface(register ClientPtr client)
{ {
int rc; int rc;
REQUEST(xAppleDRIDestroySurfaceReq); REQUEST(xAppleDRIDestroySurfaceReq);
DrawablePtr pDrawable; DrawablePtr pDrawable;
REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq); REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
@ -245,7 +250,8 @@ ProcAppleDRIDestroySurface(register ClientPtr client)
return rc; return rc;
if (!DRIDestroySurface(screenInfo.screens[stuff->screen], if (!DRIDestroySurface(screenInfo.screens[stuff->screen],
(Drawable) stuff->drawable, pDrawable, NULL, NULL)) { (Drawable)stuff->drawable,
pDrawable, NULL, NULL)) {
return BadValue; return BadValue;
} }
@ -273,11 +279,13 @@ ProcAppleDRICreatePixmap(ClientPtr client)
if (!DRICreatePixmap(screenInfo.screens[stuff->screen], if (!DRICreatePixmap(screenInfo.screens[stuff->screen],
(Drawable)stuff->drawable, (Drawable)stuff->drawable,
pDrawable, path, PATH_MAX)) { pDrawable,
path, PATH_MAX)) {
return BadValue; return BadValue;
} }
if (!DRIGetPixmapData(pDrawable, &width, &height, &pitch, &bpp, &ptr)) { if (!DRIGetPixmapData(pDrawable, &width, &height,
&pitch, &bpp, &ptr)) {
return BadValue; return BadValue;
} }
@ -317,7 +325,6 @@ ProcAppleDRIDestroyPixmap(ClientPtr client)
{ {
DrawablePtr pDrawable; DrawablePtr pDrawable;
int rc; int rc;
REQUEST(xAppleDRIDestroyPixmapReq); REQUEST(xAppleDRIDestroyPixmapReq);
REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq); REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq);
@ -342,6 +349,7 @@ ProcAppleDRIDispatch(register ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_AppleDRIQueryVersion: case X_AppleDRIQueryVersion:
return ProcAppleDRIQueryVersion(client); return ProcAppleDRIQueryVersion(client);
case X_AppleDRIQueryDirectRenderingCapable: case X_AppleDRIQueryDirectRenderingCapable:
return ProcAppleDRIQueryDirectRenderingCapable(client); return ProcAppleDRIQueryDirectRenderingCapable(client);
} }
@ -352,12 +360,16 @@ ProcAppleDRIDispatch(register ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_AppleDRIAuthConnection: case X_AppleDRIAuthConnection:
return ProcAppleDRIAuthConnection(client); return ProcAppleDRIAuthConnection(client);
case X_AppleDRICreateSurface: case X_AppleDRICreateSurface:
return ProcAppleDRICreateSurface(client); return ProcAppleDRICreateSurface(client);
case X_AppleDRIDestroySurface: case X_AppleDRIDestroySurface:
return ProcAppleDRIDestroySurface(client); return ProcAppleDRIDestroySurface(client);
case X_AppleDRICreatePixmap: case X_AppleDRICreatePixmap:
return ProcAppleDRICreatePixmap(client); return ProcAppleDRICreatePixmap(client);
case X_AppleDRIDestroyPixmap: case X_AppleDRIDestroyPixmap:
return ProcAppleDRIDestroyPixmap(client); return ProcAppleDRIDestroyPixmap(client);
@ -367,7 +379,8 @@ ProcAppleDRIDispatch(register ClientPtr client)
} }
static void static void
SNotifyEvent(xAppleDRINotifyEvent * from, xAppleDRINotifyEvent * to) SNotifyEvent(xAppleDRINotifyEvent *from,
xAppleDRINotifyEvent *to)
{ {
to->type = from->type; to->type = from->type;
to->kind = from->kind; to->kind = from->kind;
@ -451,6 +464,7 @@ SProcAppleDRIDispatch(register ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_AppleDRIQueryVersion: case X_AppleDRIQueryVersion:
return SProcAppleDRIQueryVersion(client); return SProcAppleDRIQueryVersion(client);
case X_AppleDRIQueryDirectRenderingCapable: case X_AppleDRIQueryDirectRenderingCapable:
return SProcAppleDRIQueryDirectRenderingCapable(client); return SProcAppleDRIQueryDirectRenderingCapable(client);
} }
@ -461,12 +475,16 @@ SProcAppleDRIDispatch(register ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_AppleDRIAuthConnection: case X_AppleDRIAuthConnection:
return SProcAppleDRIAuthConnection(client); return SProcAppleDRIAuthConnection(client);
case X_AppleDRICreateSurface: case X_AppleDRICreateSurface:
return SProcAppleDRICreateSurface(client); return SProcAppleDRICreateSurface(client);
case X_AppleDRIDestroySurface: case X_AppleDRIDestroySurface:
return SProcAppleDRIDestroySurface(client); return SProcAppleDRIDestroySurface(client);
case X_AppleDRICreatePixmap: case X_AppleDRICreatePixmap:
return SProcAppleDRICreatePixmap(client); return SProcAppleDRICreatePixmap(client);
case X_AppleDRIDestroyPixmap: case X_AppleDRIDestroyPixmap:
return SProcAppleDRIDestroyPixmap(client); return SProcAppleDRIDestroyPixmap(client);
@ -486,9 +504,9 @@ AppleDRIExtensionInit(void)
AppleDRINumberErrors, AppleDRINumberErrors,
ProcAppleDRIDispatch, ProcAppleDRIDispatch,
SProcAppleDRIDispatch, SProcAppleDRIDispatch,
AppleDRIResetProc, StandardMinorOpcode))) { AppleDRIResetProc,
StandardMinorOpcode))) {
size_t i; size_t i;
DRIReqCode = (unsigned char)extEntry->base; DRIReqCode = (unsigned char)extEntry->base;
DRIErrorBase = extEntry->errorBase; DRIErrorBase = extEntry->errorBase;
DRIEventBase = extEntry->eventBase; DRIEventBase = extEntry->eventBase;

View File

@ -3,7 +3,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc. Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc. Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -33,6 +33,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Kevin E. Martin <martin@valinux.com> * Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com> * Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com> * Rickard E. (Rik) Faith <faith@valinux.com>
* Jeremy Huddleston <jeremyhu@apple.com>
* *
*/ */
@ -84,39 +85,53 @@ typedef struct {
_XFUNCPROTOBEGIN _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, Bool
int *minorVersion, int *patchVersion); XAppleDRIQueryVersion(Display *dpy, int *majorVersion, int *minorVersion,
int *patchVersion);
Bool XAppleDRIQueryDirectRenderingCapable(Display * dpy, int screen, Bool
XAppleDRIQueryDirectRenderingCapable(Display *dpy, int screen,
Bool *isCapable); Bool *isCapable);
void *XAppleDRISetSurfaceNotifyHandler(void (*fun) (Display * dpy, void *
unsigned uid, int kind)); 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, Bool XAppleDRICreateSurface(Display * dpy, int screen, Drawable drawable,
unsigned int client_id, unsigned int key[2], 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
XAppleDRICreateSharedBuffer(Display *dpy, int screen, Drawable drawable,
Bool doubleSwap, char *path, size_t pathlen, Bool doubleSwap, char *path, size_t pathlen,
int *width, int *height); 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, Bool
int *width, int *height, int *pitch, int *bpp, XAppleDRICreatePixmap(Display *dpy, int screen, Drawable drawable, int *width,
size_t * size, char *bufname, size_t bufnamesize); 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 _XFUNCPROTOEND
#endif /* _APPLEDRI_SERVER_ */ #endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRI_H_ */ #endif /* _APPLEDRI_H_ */

View File

@ -2,7 +2,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc. Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc. Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -32,6 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Kevin E. Martin <martin@valinux.com> * Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com> * Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Fiath <faith@valinux.com> * Rickard E. (Rik) Fiath <faith@valinux.com>
* Jeremy Huddleston <jeremyhu@apple.com>
* *
*/ */
@ -51,7 +52,6 @@ typedef struct _AppleDRIQueryVersion {
CARD8 driReqType; /* always X_DRIQueryVersion */ CARD8 driReqType; /* always X_DRIQueryVersion */
CARD16 length B16; CARD16 length B16;
} xAppleDRIQueryVersionReq; } xAppleDRIQueryVersionReq;
#define sz_xAppleDRIQueryVersionReq 4 #define sz_xAppleDRIQueryVersionReq 4
typedef struct { typedef struct {
@ -67,7 +67,6 @@ typedef struct {
CARD32 pad5 B32; CARD32 pad5 B32;
CARD32 pad6 B32; CARD32 pad6 B32;
} xAppleDRIQueryVersionReply; } xAppleDRIQueryVersionReply;
#define sz_xAppleDRIQueryVersionReply 32 #define sz_xAppleDRIQueryVersionReply 32
typedef struct _AppleDRIQueryDirectRenderingCapable { typedef struct _AppleDRIQueryDirectRenderingCapable {
@ -76,7 +75,6 @@ typedef struct _AppleDRIQueryDirectRenderingCapable {
CARD16 length B16; CARD16 length B16;
CARD32 screen B32; CARD32 screen B32;
} xAppleDRIQueryDirectRenderingCapableReq; } xAppleDRIQueryDirectRenderingCapableReq;
#define sz_xAppleDRIQueryDirectRenderingCapableReq 8 #define sz_xAppleDRIQueryDirectRenderingCapableReq 8
typedef struct { typedef struct {
@ -94,7 +92,6 @@ typedef struct {
CARD32 pad8 B32; CARD32 pad8 B32;
CARD32 pad9 B32; CARD32 pad9 B32;
} xAppleDRIQueryDirectRenderingCapableReply; } xAppleDRIQueryDirectRenderingCapableReply;
#define sz_xAppleDRIQueryDirectRenderingCapableReply 32 #define sz_xAppleDRIQueryDirectRenderingCapableReply 32
typedef struct _AppleDRIAuthConnection { typedef struct _AppleDRIAuthConnection {
@ -104,7 +101,6 @@ typedef struct _AppleDRIAuthConnection {
CARD32 screen B32; CARD32 screen B32;
CARD32 magic B32; CARD32 magic B32;
} xAppleDRIAuthConnectionReq; } xAppleDRIAuthConnectionReq;
#define sz_xAppleDRIAuthConnectionReq 12 #define sz_xAppleDRIAuthConnectionReq 12
typedef struct { typedef struct {
@ -119,7 +115,6 @@ typedef struct {
CARD32 pad5 B32; CARD32 pad5 B32;
CARD32 pad6 B32; CARD32 pad6 B32;
} xAppleDRIAuthConnectionReply; } xAppleDRIAuthConnectionReply;
#define zx_xAppleDRIAuthConnectionReply 32 #define zx_xAppleDRIAuthConnectionReply 32
typedef struct _AppleDRICreateSurface { typedef struct _AppleDRICreateSurface {
@ -130,7 +125,6 @@ typedef struct _AppleDRICreateSurface {
CARD32 drawable B32; CARD32 drawable B32;
CARD32 client_id B32; CARD32 client_id B32;
} xAppleDRICreateSurfaceReq; } xAppleDRICreateSurfaceReq;
#define sz_xAppleDRICreateSurfaceReq 16 #define sz_xAppleDRICreateSurfaceReq 16
typedef struct { typedef struct {
@ -145,7 +139,6 @@ typedef struct {
CARD32 pad5 B32; CARD32 pad5 B32;
CARD32 pad6 B32; CARD32 pad6 B32;
} xAppleDRICreateSurfaceReply; } xAppleDRICreateSurfaceReply;
#define sz_xAppleDRICreateSurfaceReply 32 #define sz_xAppleDRICreateSurfaceReply 32
typedef struct _AppleDRIDestroySurface { typedef struct _AppleDRIDestroySurface {
@ -155,7 +148,6 @@ typedef struct _AppleDRIDestroySurface {
CARD32 screen B32; CARD32 screen B32;
CARD32 drawable B32; CARD32 drawable B32;
} xAppleDRIDestroySurfaceReq; } xAppleDRIDestroySurfaceReq;
#define sz_xAppleDRIDestroySurfaceReq 12 #define sz_xAppleDRIDestroySurfaceReq 12
typedef struct _AppleDRINotify { typedef struct _AppleDRINotify {
@ -170,7 +162,6 @@ typedef struct _AppleDRINotify {
CARD32 pad5 B32; CARD32 pad5 B32;
CARD32 pad6 B32; CARD32 pad6 B32;
} xAppleDRINotifyEvent; } xAppleDRINotifyEvent;
#define sz_xAppleDRINotifyEvent 32 #define sz_xAppleDRINotifyEvent 32
typedef struct { typedef struct {

View File

@ -2,7 +2,7 @@
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc. Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2009 Apple Computer, Inc. Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -31,7 +31,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Authors: * Authors:
* Jens Owen <jens@valinux.com> * Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com> * Rickard E. (Rik) Faith <faith@valinux.com>
* * Jeremy Huddleston <jeremyhu@apple.com>
*/ */
#ifdef HAVE_DIX_CONFIG_H #ifdef HAVE_DIX_CONFIG_H
@ -75,23 +75,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
static DevPrivateKeyRec DRIScreenPrivKeyRec; static DevPrivateKeyRec DRIScreenPrivKeyRec;
#define DRIScreenPrivKey (&DRIScreenPrivKeyRec) #define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
static DevPrivateKeyRec DRIWindowPrivKeyRec; static DevPrivateKeyRec DRIWindowPrivKeyRec;
#define DRIWindowPrivKey (&DRIWindowPrivKeyRec) #define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
static DevPrivateKeyRec DRIPixmapPrivKeyRec; static DevPrivateKeyRec DRIPixmapPrivKeyRec;
#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec) #define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec)
static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec; static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec;
#define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec) #define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec)
static RESTYPE DRIDrawablePrivResType; static RESTYPE DRIDrawablePrivResType;
static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */ static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
static Bool DRIFreePixmapImp(DrawablePtr pDrawable); static Bool
DRIFreePixmapImp(DrawablePtr pDrawable);
typedef struct { typedef struct {
DrawablePtr pDrawable; DrawablePtr pDrawable;
@ -217,8 +214,7 @@ DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (drmAuthMagic(pDRIPriv->drmFD, magic)) if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
return FALSE;
#endif #endif
return TRUE; return TRUE;
} }
@ -271,7 +267,8 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
/* Return NULL if an error occurs. */ /* Return NULL if an error occurs. */
static DRIDrawablePrivPtr static DRIDrawablePrivPtr
CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id * widPtr) CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin,
xp_window_id *widPtr)
{ {
DRIDrawablePrivPtr pDRIDrawablePriv; DRIDrawablePrivPtr pDRIDrawablePriv;
xp_window_id wid = 0; xp_window_id wid = 0;
@ -323,7 +320,8 @@ CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id * widPtr)
} }
/* save private off of preallocated index */ /* save private off of preallocated index */
dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, pDRIDrawablePriv); dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
pDRIDrawablePriv);
} }
*widPtr = wid; *widPtr = wid;
@ -368,7 +366,8 @@ CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix)
*/ */
/* save private off of preallocated index */ /* save private off of preallocated index */
dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, pDRIDrawablePriv); dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
pDRIDrawablePriv);
} }
return pDRIDrawablePriv; return pDRIDrawablePriv;
@ -416,7 +415,8 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
* 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. * 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) { if (err != Success) {
xp_destroy_surface(pDRIDrawablePriv->sid); xp_destroy_surface(pDRIDrawablePriv->sid);
free(pDRIDrawablePriv); free(pDRIDrawablePriv);
@ -449,8 +449,8 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
if (surface_hash == NULL) if (surface_hash == NULL)
surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
x_hash_table_insert(surface_hash, x_hash_table_insert(surface_hash,
x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), x_cvt_uint_to_vptr(
pDRIDrawablePriv); pDRIDrawablePriv->sid), pDRIDrawablePriv);
/* track this in case this window is destroyed */ /* track this in case this window is destroyed */
AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
@ -498,8 +498,9 @@ DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
*/ */
if (notify != NULL) { if (notify != NULL) {
pDRIDrawablePriv->notifiers = pDRIDrawablePriv->notifiers = x_hook_remove(
x_hook_remove(pDRIDrawablePriv->notifiers, notify, notify_data); pDRIDrawablePriv->notifiers,
notify, notify_data);
} }
--pDRIDrawablePriv->refCount; --pDRIDrawablePriv->refCount;
@ -558,7 +559,8 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
} }
if (pDRIDrawablePriv->sid != 0) { if (pDRIDrawablePriv->sid != 0) {
DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed); DRISurfaceNotify(pDRIDrawablePriv->sid,
AppleDRISurfaceNotifyDestroyed);
} }
if (pDRIDrawablePriv->notifiers != NULL) if (pDRIDrawablePriv->notifiers != NULL)
@ -696,7 +698,9 @@ DRIGetWrappedFuncs(ScreenPtr pScreen)
} }
void void
DRIQueryVersion(int *majorVersion, int *minorVersion, int *patchVersion) DRIQueryVersion(int *majorVersion,
int *minorVersion,
int *patchVersion)
{ {
*majorVersion = APPLE_DRI_MAJOR_VERSION; *majorVersion = APPLE_DRI_MAJOR_VERSION;
*minorVersion = APPLE_DRI_MINOR_VERSION; *minorVersion = APPLE_DRI_MINOR_VERSION;
@ -753,7 +757,8 @@ DRISurfaceNotify(xp_surface_id id, int kind)
*/ */
Bool Bool
DRICreatePixmap(ScreenPtr pScreen, Drawable id, DRICreatePixmap(ScreenPtr pScreen, Drawable id,
DrawablePtr pDrawable, char *path, size_t pathmax) DrawablePtr pDrawable, char *path,
size_t pathmax)
{ {
DRIPixmapBufferPtr shared; DRIPixmapBufferPtr shared;
PixmapPtr pPix; PixmapPtr pPix;
@ -782,7 +787,8 @@ DRICreatePixmap(ScreenPtr pScreen, Drawable id,
shared->height = pDrawable->height; shared->height = pDrawable->height;
if (-1 == snprintf(shared->shmPath, sizeof(shared->shmPath), 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__); FatalError("buffer overflow in %s\n", __func__);
} }

View File

@ -1,7 +1,7 @@
/************************************************************************** /**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright (c) 2002, 2009 Apple Computer, Inc. Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* /*
* Authors: * Authors:
* Jens Owen <jens@precisioninsight.com> * Jens Owen <jens@precisioninsight.com>
* * Jeremy Huddleston <jeremyhu@apple.com>
*/ */
/* Prototypes for AppleDRI functions */ /* Prototypes for AppleDRI functions */
@ -63,19 +63,26 @@ typedef struct {
int kind; int kind;
} DRISurfaceNotifyArg; } 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, extern Bool DRICreateSurface(ScreenPtr pScreen,
Drawable id, Drawable id,
@ -86,39 +93,49 @@ extern Bool DRICreateSurface(ScreenPtr pScreen,
void (*notify)(void *arg, void *data), void (*notify)(void *arg, void *data),
void *notify_data); void *notify_data);
extern Bool DRIDestroySurface(ScreenPtr pScreen, extern Bool
Drawable id, DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
DrawablePtr pDrawable, void (*notify)(void *arg,
void (*notify) (void *arg, void *data), void *data), void *notify_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, extern void
DDXPointRec ptOldOrg, RegionPtr prgnSrc); 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, extern void
WindowPtr pChild, VTKind kind); 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, extern void
int *minorVersion, int *patchVersion); DRIQueryVersion(int *majorVersion, int *minorVersion, int *patchVersion);
extern Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id, extern Bool
DrawablePtr pDrawable, char *path, size_t pathmax); DRICreatePixmap(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
char *path,
size_t pathmax);
extern Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height, extern Bool
int *pitch, int *bpp, void **ptr); DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height, int *pitch,
int *bpp,
void **ptr);
extern void DRIDestroyPixmap(DrawablePtr pDrawable); extern void
DRIDestroyPixmap(DrawablePtr pDrawable);
#endif #endif

View File

@ -1,27 +1,32 @@
/* /*
Copyright (c) 2009 Apple Computer, Inc. * Copyright (c) 2009-2012 Apple Inc. All rights reserved.
All Rights Reserved. *
* Permission is hereby granted, free of charge, to any person
Permission is hereby granted, free of charge, to any person obtaining a * obtaining a copy of this software and associated documentation files
copy of this software and associated documentation files (the * (the "Software"), to deal in the Software without restriction,
"Software"), to deal in the Software without restriction, including * including without limitation the rights to use, copy, modify, merge,
without limitation the rights to use, copy, modify, merge, publish, * publish, distribute, sublicense, and/or sell copies of the Software,
distribute, sub license, and/or sell copies of the Software, and to * and to permit persons to whom the Software is furnished to do so,
permit persons to whom the Software is furnished to do so, subject to * subject to the following conditions:
the following conditions: *
* The above copyright notice and this permission notice shall be
The above copyright notice and this permission notice (including the * included in all copies or substantial portions of the Software.
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
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * DEALINGS IN THE SOFTWARE.
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 #ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif #endif
@ -55,11 +60,9 @@ typedef struct {
} DRISavedDrawableState; } DRISavedDrawableState;
static DevPrivateKeyRec driGCKeyRec; static DevPrivateKeyRec driGCKeyRec;
#define driGCKey (&driGCKeyRec) #define driGCKey (&driGCKeyRec)
static DevPrivateKeyRec driWrapScreenKeyRec; static DevPrivateKeyRec driWrapScreenKeyRec;
#define driWrapScreenKey (&driWrapScreenKeyRec) #define driWrapScreenKey (&driWrapScreenKeyRec)
static GCOps driGCOps; static GCOps driGCOps;
@ -94,7 +97,8 @@ DRIWrapGC(GCPtr pGC)
} }
static void static void
DRISurfaceSetDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved) DRISurfaceSetDrawable(DrawablePtr pDraw,
DRISavedDrawableState *saved)
{ {
saved->didSave = FALSE; saved->didSave = FALSE;
@ -102,7 +106,8 @@ DRISurfaceSetDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
int pitch, width, height, bpp; int pitch, width, height, bpp;
void *buffer; void *buffer;
if (DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp, &buffer)) { if (DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp,
&buffer)) {
PixmapPtr pPix = (PixmapPtr)pDraw; PixmapPtr pPix = (PixmapPtr)pDraw;
saved->devKind = pPix->devKind; saved->devKind = pPix->devKind;
@ -116,7 +121,8 @@ DRISurfaceSetDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
} }
static void static void
DRISurfaceRestoreDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved) DRISurfaceRestoreDrawable(DrawablePtr pDraw,
DRISavedDrawableState *saved)
{ {
PixmapPtr pPix = (PixmapPtr)pDraw; PixmapPtr pPix = (PixmapPtr)pDraw;
@ -129,7 +135,8 @@ DRISurfaceRestoreDrawable(DrawablePtr pDraw, DRISavedDrawableState * saved)
static void static void
DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit, DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
DDXPointPtr pptInit, int *pwidthInit, int sorted) DDXPointPtr pptInit, int *pwidthInit,
int sorted)
{ {
DRISavedDrawableState saved; DRISavedDrawableState saved;
@ -146,7 +153,8 @@ DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
static void static void
DRISetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc, 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; DRISavedDrawableState saved;
@ -181,7 +189,8 @@ DRIPutImage(DrawablePtr dst, GCPtr pGC,
static RegionPtr static RegionPtr
DRICopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC, 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; RegionPtr pReg;
DRISavedDrawableState pSrcSaved, dstSaved; DRISavedDrawableState pSrcSaved, dstSaved;
@ -204,7 +213,8 @@ DRICopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
static RegionPtr static RegionPtr
DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst, DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst,
GCPtr pGC, int srcx, int srcy, 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; RegionPtr pReg;
DRISavedDrawableState pSrcSaved, dstSaved; DRISavedDrawableState pSrcSaved, dstSaved;
@ -226,7 +236,8 @@ DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst,
} }
static void 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; DRISavedDrawableState saved;
@ -242,7 +253,8 @@ DRIPolyPoint(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
} }
static void 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; DRISavedDrawableState saved;
@ -258,7 +270,8 @@ DRIPolylines(DrawablePtr dst, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
} }
static void static void
DRIPolySegment(DrawablePtr dst, GCPtr pGC, int nseg, xSegment * pSeg) DRIPolySegment(DrawablePtr dst, GCPtr pGC,
int nseg, xSegment *pSeg)
{ {
DRISavedDrawableState saved; DRISavedDrawableState saved;
@ -274,7 +287,8 @@ DRIPolySegment(DrawablePtr dst, GCPtr pGC, int nseg, xSegment * pSeg)
} }
static void static void
DRIPolyRectangle(DrawablePtr dst, GCPtr pGC, int nRects, xRectangle *pRects) DRIPolyRectangle(DrawablePtr dst, GCPtr pGC,
int nRects, xRectangle *pRects)
{ {
DRISavedDrawableState saved; DRISavedDrawableState saved;
@ -288,7 +302,6 @@ DRIPolyRectangle(DrawablePtr dst, GCPtr pGC, int nRects, xRectangle *pRects)
DRISurfaceRestoreDrawable(dst, &saved); DRISurfaceRestoreDrawable(dst, &saved);
} }
static void static void
DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs) DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
{ {
@ -307,7 +320,8 @@ DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc * parcs)
static void static void
DRIFillPolygon(DrawablePtr dst, GCPtr pGC, DRIFillPolygon(DrawablePtr dst, GCPtr pGC,
int shape, int mode, int count, DDXPointPtr pptInit) int shape, int mode, int count,
DDXPointPtr pptInit)
{ {
DRISavedDrawableState saved; DRISavedDrawableState saved;
@ -340,7 +354,8 @@ DRIPolyFillRect(DrawablePtr dst, GCPtr pGC,
} }
static void static void
DRIPolyFillArc(DrawablePtr dst, GCPtr pGC, int narcsInit, xArc * parcsInit) DRIPolyFillArc(DrawablePtr dst, GCPtr pGC,
int narcsInit, xArc *parcsInit)
{ {
DRISavedDrawableState saved; DRISavedDrawableState saved;
@ -356,7 +371,8 @@ DRIPolyFillArc(DrawablePtr dst, GCPtr pGC, int narcsInit, xArc * parcsInit)
} }
static int 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; int ret;
DRISavedDrawableState saved; DRISavedDrawableState saved;
@ -395,7 +411,8 @@ DRIPolyText16(DrawablePtr dst, GCPtr pGC,
} }
static void 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; DRISavedDrawableState saved;
@ -539,12 +556,12 @@ DRIWrapInit(ScreenPtr pScreen)
if (!dixRegisterPrivateKey(&driGCKeyRec, PRIVATE_GC, sizeof(DRIGCRec))) if (!dixRegisterPrivateKey(&driGCKeyRec, PRIVATE_GC, sizeof(DRIGCRec)))
return FALSE; return FALSE;
if (!dixRegisterPrivateKey if (!dixRegisterPrivateKey(&driWrapScreenKeyRec, PRIVATE_SCREEN,
(&driWrapScreenKeyRec, PRIVATE_SCREEN, sizeof(DRIWrapScreenRec))) sizeof(DRIWrapScreenRec)))
return FALSE; return FALSE;
pScreenPriv = pScreenPriv = dixGetPrivateAddr(&pScreen->devPrivates,
dixGetPrivateAddr(&pScreen->devPrivates, &driWrapScreenKeyRec); &driWrapScreenKeyRec);
pScreenPriv->CreateGC = pScreen->CreateGC; pScreenPriv->CreateGC = pScreen->CreateGC;
pScreen->CreateGC = DRICreateGC; pScreen->CreateGC = DRICreateGC;

View File

@ -1,31 +1,36 @@
/* /*
Copyright (c) 2009 Apple Computer, Inc. * Copyright (c) 2009-2012 Apple Inc. All rights reserved.
All Rights Reserved. *
* Permission is hereby granted, free of charge, to any person
Permission is hereby granted, free of charge, to any person obtaining a * obtaining a copy of this software and associated documentation files
copy of this software and associated documentation files (the * (the "Software"), to deal in the Software without restriction,
"Software"), to deal in the Software without restriction, including * including without limitation the rights to use, copy, modify, merge,
without limitation the rights to use, copy, modify, merge, publish, * publish, distribute, sublicense, and/or sell copies of the Software,
distribute, sub license, and/or sell copies of the Software, and to * and to permit persons to whom the Software is furnished to do so,
permit persons to whom the Software is furnished to do so, subject to * subject to the following conditions:
the following conditions: *
* The above copyright notice and this permission notice shall be
The above copyright notice and this permission notice (including the * included in all copies or substantial portions of the Software.
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
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * DEALINGS IN THE SOFTWARE.
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 #ifndef DRIWRAP_H
#include "scrnintstr.h" #include "scrnintstr.h"
Bool DRIWrapInit(ScreenPtr pScreen); Bool
DRIWrapInit(ScreenPtr pScreen);
#endif /*DRIWRAP_H*/ #endif /*DRIWRAP_H*/

View File

@ -1,7 +1,7 @@
/************************************************************************** /**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright (c) 2002 Apple Computer, Inc. Copyright (c) 2002-2012 Apple Computer, Inc.
All Rights Reserved. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* /*
* Authors: * Authors:
* Jens Owen <jens@precisioninsight.com> * Jens Owen <jens@precisioninsight.com>
* * Jeremy Huddleston <jeremyhu@apple.com>
*/ */
#ifndef DRI_STRUCT_H #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_MAX_DRAWABLES 256
#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \ #define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey)) dixLookupPrivate(&(pWin)-> \
devPrivates, \
DRIWindowPrivKey))
#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ #define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
dixLookupPrivate(&(pPix)->devPrivates, DRIPixmapPrivKey)) dixLookupPrivate(&(pPix)-> \
devPrivates, \
DRIPixmapPrivKey))
typedef struct _DRIDrawablePrivRec { typedef struct _DRIDrawablePrivRec {
xp_surface_id sid; xp_surface_id sid;
@ -57,10 +61,17 @@ typedef struct _DRIDrawablePrivRec {
} DRIDrawablePrivRec, *DRIDrawablePrivPtr; } DRIDrawablePrivRec, *DRIDrawablePrivPtr;
#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \ #define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey)) dixLookupPrivate(&(pScreen) \
-> \
devPrivates, \
DRIScreenPrivKey))
#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ #define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \ dixLookupPrivate(&screenInfo \
.screens[ \
screenIndex \
]-> \
devPrivates, \
DRIScreenPrivKey)) DRIScreenPrivKey))
typedef struct _DRIScreenPrivRec { typedef struct _DRIScreenPrivRec {

View File

@ -1,31 +1,32 @@
/* x-hash.c - basic hash tables /* x-hash.c - basic hash tables
*
Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifdef HAVE_DIX_CONFIG_H #ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
@ -56,8 +57,10 @@ struct x_hash_table_struct {
/* http://planetmath.org/?op=getobj&from=objects&name=GoodHashTablePrimes */ /* http://planetmath.org/?op=getobj&from=objects&name=GoodHashTablePrimes */
static const unsigned int bucket_sizes[] = { static const unsigned int bucket_sizes[] = {
29, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 29, 53, 97, 193, 389, 769, 1543,
98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 3079, 6151, 12289, 24593, 49157,
98317, 196613, 393241, 786433, 1572869, 3145739, 6291469,
12582917,
25165843, 50331653, 100663319, 201326611, 402653189, 805306457, 25165843, 50331653, 100663319, 201326611, 402653189, 805306457,
1610612741 1610612741
}; };
@ -139,7 +142,8 @@ hash_table_split(x_hash_table * h)
free(old); free(old);
} }
X_EXTERN x_hash_table *X_PFX(hash_table_new) (x_hash_fun * hash, X_EXTERN x_hash_table *
X_PFX(hash_table_new) (x_hash_fun * hash,
x_compare_fun * compare, x_compare_fun * compare,
x_destroy_fun * key_destroy, x_destroy_fun * key_destroy,
x_destroy_fun * value_destroy) { x_destroy_fun * value_destroy) {
@ -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 (hash_table_compare_keys(h, ITEM_KEY(item), k)) {
if (replace) { 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->next = k;
ITEM_VALUE(item) = v; ITEM_VALUE(item) = v;
} }
@ -270,8 +275,8 @@ X_EXTERN void
} }
} }
X_EXTERN void *X_PFX(hash_table_lookup) (x_hash_table * h, void *k, X_EXTERN void *
void **k_ret) { X_PFX(hash_table_lookup) (x_hash_table * h, void *k, void **k_ret) {
size_t hash_value; size_t hash_value;
x_list *node, *item; 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_EXTERN void
X_PFX(hash_table_foreach) (x_hash_table * h, X_PFX(hash_table_foreach) (x_hash_table * h,
x_hash_foreach_fun * fun, void *data) { x_hash_foreach_fun * fun, void *data) {
int i, n; int i, n;

View File

@ -1,31 +1,32 @@
/* x-hash.h -- basic hash table class /* x-hash.h -- basic hash table class
*
Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifndef X_HASH_H #ifndef X_HASH_H
#define X_HASH_H 1 #define X_HASH_H 1
@ -57,18 +58,20 @@ 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, X_EXTERN void *X_PFX(hash_table_lookup) (x_hash_table * h,
void *k, void **k_ret); void *k, void **k_ret);
X_EXTERN void X_PFX(hash_table_foreach) (x_hash_table * h, X_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 */ /* Conversion between unsigned int (e.g. xp_resource_id) and void pointer */
/* Forward declarations */ /* Forward declarations */
static __inline__ void *X_PFX(cvt_uint_to_vptr) (unsigned int val) static __inline__ void *
__attribute__ ((always_inline)); X_PFX(cvt_uint_to_vptr) (unsigned int val) __attribute__((always_inline));
static __inline__ unsigned int 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 */ /* Implementations */
static __inline__ void *X_PFX(cvt_uint_to_vptr) (unsigned int val) { static __inline__ void *
X_PFX(cvt_uint_to_vptr) (unsigned int val) {
return (void *)((unsigned long)(val)); return (void *)((unsigned long)(val));
} }

View File

@ -1,31 +1,32 @@
/* x-hook.c /* x-hook.c
*
Copyright (c) 2003 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifdef HAVE_DIX_CONFIG_H #ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
@ -41,13 +42,13 @@
#define CELL_FUN(c) ((x_hook_function *)((c)->next)) #define CELL_FUN(c) ((x_hook_function *)((c)->next))
#define CELL_DATA(c) ((c)->data) #define CELL_DATA(c) ((c)->data)
X_EXTERN x_list *X_PFX(hook_add) (x_list * lst, x_hook_function * fun, X_EXTERN x_list *
void *data) { X_PFX(hook_add) (x_list * lst, x_hook_function * fun, void *data) {
return X_PFX(list_prepend) (lst, CELL_NEW(fun, 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, X_EXTERN x_list *
void *data) { X_PFX(hook_remove) (x_list * lst, x_hook_function * fun, void *data) {
x_list *node, *cell; x_list *node, *cell;
x_list *to_delete = NULL; x_list *to_delete = NULL;

View File

@ -1,31 +1,32 @@
/* x-hook.h -- lists of function,data pairs to call. /* x-hook.h -- lists of function,data pairs to call.
*
Copyright (c) 2003 Apple Computer, Inc. All rights reserved. * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifndef X_HOOK_H #ifndef X_HOOK_H
#define X_HOOK_H 1 #define X_HOOK_H 1

View File

@ -1,31 +1,32 @@
/* x-list.c /* x-list.c
*
Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifdef HAVE_DIX_CONFIG_H #ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
@ -81,7 +82,8 @@ X_EXTERN void
pthread_mutex_unlock(&freelist_lock); 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; x_list *node;
pthread_mutex_lock(&freelist_lock); pthread_mutex_lock(&freelist_lock);
@ -111,7 +113,8 @@ X_EXTERN x_list *X_PFX(list_prepend) (x_list * lst, void *data) {
return node; 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; x_list *head = lst;
if (lst == NULL) if (lst == NULL)
@ -125,10 +128,12 @@ X_EXTERN x_list *X_PFX(list_append) (x_list * lst, void *data) {
return head; 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; x_list *head = NULL, *next;
while (lst != NULL) { while (lst != NULL)
{
next = lst->next; next = lst->next;
lst->next = head; lst->next = head;
head = lst; head = lst;
@ -138,7 +143,8 @@ X_EXTERN x_list *X_PFX(list_reverse) (x_list * lst) {
return head; 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) { for (; lst != NULL; lst = lst->next) {
if (lst->data == data) if (lst->data == data)
return lst; return lst;
@ -147,19 +153,20 @@ X_EXTERN x_list *X_PFX(list_find) (x_list * lst, void *data) {
return NULL; 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) while (n-- > 0 && lst != NULL)
lst = lst->next; lst = lst->next;
return lst; 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; void *data = NULL;
if (lst != NULL) { if (lst != NULL) {
x_list *tem = lst; x_list *tem = lst;
data = lst->data; data = lst->data;
lst = lst->next; lst = lst->next;
X_PFX(list_free_1) (tem); X_PFX(list_free_1) (tem);
@ -171,9 +178,9 @@ X_EXTERN x_list *X_PFX(list_pop) (x_list * lst, void **data_ret) {
return lst; return lst;
} }
X_EXTERN x_list *X_PFX(list_filter) (x_list * lst, X_EXTERN x_list *
int (*pred) (void *item, void *data), X_PFX(list_filter) (x_list * lst,
void *data) { int (*pred)(void *item, void *data), void *data) {
x_list *ret = NULL, *node; x_list *ret = NULL, *node;
for (node = lst; node != NULL; node = node->next) { for (node = lst; node != NULL; node = node->next) {
@ -184,9 +191,9 @@ X_EXTERN x_list *X_PFX(list_filter) (x_list * lst,
return X_PFX(list_reverse) (ret); return X_PFX(list_reverse) (ret);
} }
X_EXTERN x_list *X_PFX(list_map) (x_list * lst, X_EXTERN x_list *
void *(*fun) (void *item, void *data), X_PFX(list_map) (x_list * lst,
void *data) { void *(*fun)(void *item, void *data), void *data) {
x_list *ret = NULL, *node; x_list *ret = NULL, *node;
for (node = lst; node != NULL; node = node->next) { 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); 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; x_list *copy = NULL;
for (; lst != NULL; lst = lst->next) { 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); 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; x_list **ptr, *node;
for (ptr = &lst; *ptr != NULL;) { for (ptr = &lst; *ptr != NULL;) {
@ -235,7 +244,6 @@ X_EXTERN unsigned int
} }
X_EXTERN void X_EXTERN void
X_PFX(list_foreach) (x_list * lst, X_PFX(list_foreach) (x_list * lst,
void (*fun)(void *data, void *user_data), void (*fun)(void *data, void *user_data),
void *user_data) { void *user_data) {
@ -245,7 +253,8 @@ X_PFX(list_foreach) (x_list * lst,
} }
static x_list * 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 *mid, *ptr;
x_list *out_head, *out; x_list *out_head, *out;
@ -279,7 +288,8 @@ list_sort_1(x_list * lst, int length, int (*less) (const void *, const void *))
else else
out = out_head = lst, lst = lst->next; out = out_head = lst, lst = lst->next;
while (lst != NULL && mid != NULL) { while (lst != NULL && mid != NULL)
{
if ((*less)(mid->data, lst->data)) if ((*less)(mid->data, lst->data))
out = out->next = mid, mid = mid->next; out = out->next = mid, mid = mid->next;
else else
@ -294,8 +304,8 @@ list_sort_1(x_list * lst, int length, int (*less) (const void *, const void *))
return out_head; return out_head;
} }
X_EXTERN x_list *X_PFX(list_sort) (x_list * lst, X_EXTERN x_list *
int (*less) (const void *, const void *)) { X_PFX(list_sort) (x_list * lst, int (*less)(const void *, const void *)) {
int length; int length;
length = X_PFX(list_length) (lst); length = X_PFX(list_length) (lst);

View File

@ -1,31 +1,32 @@
/* x-list.h -- simple list type /* x-list.h -- simple list type
*
Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
*
Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, * (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, * including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, * publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, * and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: * subject to the following conditions:
*
The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name(s) of the above * Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to * copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without * promote the sale, use or other dealings in this Software without
prior written authorization. */ * prior written authorization.
*/
#ifndef X_LIST_H #ifndef X_LIST_H
#define X_LIST_H 1 #define X_LIST_H 1
@ -71,7 +72,7 @@ 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); void *user_data);
X_EXTERN x_list *X_PFX(list_sort) (x_list * lst, int (*less) (const void *, X_EXTERN x_list *X_PFX(list_sort) (x_list * lst,
const void *)); int (*less)(const void *, const void *));
#endif /* X_LIST_H */ #endif /* X_LIST_H */

View File

@ -2,6 +2,7 @@
* Xplugin rootless implementation * Xplugin rootless implementation
* *
* Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved. * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -38,19 +39,29 @@
#undef DEBUG_LOG #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
void xprAppleWMInit(void); AppleDRIExtensionInit(void);
Bool xprInit(ScreenPtr pScreen); void
Bool xprIsX11Window(int windowNumber); xprAppleWMInit(void);
WindowPtr xprGetXWindow(xp_window_id wid); 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); Bool
void QuartzSuspendXCursor(ScreenPtr pScreen); QuartzInitCursor(ScreenPtr pScreen);
void QuartzResumeXCursor(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 /* 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. * the menubar (24) but above native windows. Normal window level is 0.
@ -62,7 +73,6 @@ void QuartzResumeXCursor(ScreenPtr pScreen);
static const int normal_window_levels[AppleWMNumWindowLevels + 1] = { static const int normal_window_levels[AppleWMNumWindowLevels + 1] = {
0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29, 0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
}; };
static const int rooted_window_levels[AppleWMNumWindowLevels + 1] = { static const int rooted_window_levels[AppleWMNumWindowLevels + 1] = {
20, 21, 22, 23, 19, 18, 20, 21, 22, 23, 19, 18,
}; };

View File

@ -1,7 +1,7 @@
/* /*
* Xplugin rootless implementation functions for AppleWM extension * 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. * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -107,7 +107,8 @@ xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent)
RootlessStopDrawing(pWinChild, FALSE); 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; return BadValue;
} }
@ -121,7 +122,8 @@ xprFrameDraw(WindowPtr pWin,
xp_frame_attr attr, xp_frame_attr attr,
const BoxRec *outer, const BoxRec *outer,
const BoxRec *inner, const BoxRec *inner,
unsigned int title_len, const unsigned char *title_bytes) unsigned int title_len,
const unsigned char *title_bytes)
{ {
xp_window_id wid; xp_window_id wid;

View File

@ -57,11 +57,11 @@ typedef struct {
} QuartzCursorScreenRec, *QuartzCursorScreenPtr; } QuartzCursorScreenRec, *QuartzCursorScreenPtr;
static DevPrivateKeyRec darwinCursorScreenKeyRec; static DevPrivateKeyRec darwinCursorScreenKeyRec;
#define darwinCursorScreenKey (&darwinCursorScreenKeyRec) #define darwinCursorScreenKey (&darwinCursorScreenKeyRec)
#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \ #define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey)) dixLookupPrivate(&pScreen->devPrivates, \
darwinCursorScreenKey))
static Bool static Bool
load_cursor(CursorPtr src, int screen) load_cursor(CursorPtr src, int screen)
@ -93,7 +93,6 @@ load_cursor(CursorPtr src, int screen)
#else #else
const uint32_t *be_data = (uint32_t *)src->bits->argb; const uint32_t *be_data = (uint32_t *)src->bits->argb;
unsigned i; unsigned i;
rowbytes = src->bits->width * sizeof(CARD32); rowbytes = src->bits->width * sizeof(CARD32);
data = malloc(rowbytes * src->bits->height); data = malloc(rowbytes * src->bits->height);
free_data = TRUE; free_data = TRUE;
@ -134,13 +133,15 @@ load_cursor(CursorPtr src, int screen)
mrow = src->bits->mask; mrow = src->bits->mask;
drow = data; drow = data;
while (ycount-- > 0) { while (ycount-- > 0)
{
xcount = bits_to_bytes(src->bits->width); xcount = bits_to_bytes(src->bits->width);
sptr = srow; sptr = srow;
mptr = mrow; mptr = mrow;
dptr = drow; dptr = drow;
while (xcount-- > 0) { while (xcount-- > 0)
{
uint8_t s, m; uint8_t s, m;
int i; int i;
@ -219,7 +220,8 @@ QuartzUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
* Set the cursor sprite and position. * Set the cursor sprite and position.
*/ */
static void static void
QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
int x,
int y) int y)
{ {
QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen); QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
@ -249,8 +251,7 @@ QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
*/ */
static void static void
QuartzMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) QuartzMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{ {}
}
/* /*
=========================================================================== ===========================================================================
@ -383,8 +384,7 @@ QuartzInitCursor(ScreenPtr pScreen)
*/ */
void void
QuartzSuspendXCursor(ScreenPtr pScreen) QuartzSuspendXCursor(ScreenPtr pScreen)
{ {}
}
/* /*
* QuartzResumeXCursor * 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 * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
@ -61,7 +61,8 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent * e, DeviceIntPtr dev)
switch (e->subtype) { switch (e->subtype) {
case kXquartzWindowState: case kXquartzWindowState:
DEBUG_LOG("kXquartzWindowState\n"); DEBUG_LOG("kXquartzWindowState\n");
RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]), e->data[1]); RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]),
e->data[1]);
return TRUE; return TRUE;
case kXquartzWindowMoved: case kXquartzWindowMoved:
@ -73,6 +74,7 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent * e, DeviceIntPtr dev)
DEBUG_LOG("kXquartzBringAllToFront\n"); DEBUG_LOG("kXquartzBringAllToFront\n");
RootlessOrderAllWindows(e->data[0]); RootlessOrderAllWindows(e->data[0]);
return TRUE; return TRUE;
default: default:
return FALSE; 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 * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files * obtaining a copy of this software and associated documentation files
@ -29,6 +29,7 @@
#ifndef __XPR_EVENT_H__ #ifndef __XPR_EVENT_H__
#define __XPR_EVENT_H__ #define __XPR_EVENT_H__
Bool QuartzModeEventHandler(int screenNum, XQuartzEvent * e, DeviceIntPtr dev); Bool
QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev);
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
* Xplugin rootless implementation frame functions * 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. * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -74,15 +74,16 @@ static pthread_rwlock_t window_hash_rwlock;
/* Prototypes for static functions */ /* Prototypes for static functions */
static Bool static Bool
xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX,
int newX, int newY, RegionPtr pShape); int newY,
RegionPtr pShape);
static void static void
xprDestroyFrame(RootlessFrameID wid); xprDestroyFrame(RootlessFrameID wid);
static void static void
xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY); xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
static void static void
xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY,
int newX, int newY, unsigned int newW, unsigned int newH, unsigned int newW, unsigned int newH,
unsigned int gravity); unsigned int gravity);
static void static void
xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid); xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
@ -98,7 +99,8 @@ static void
xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage); xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage);
static void static void
xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
int shift_x, int shift_y); int shift_x,
int shift_y);
static void static void
xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin); xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
static Bool static Bool
@ -109,7 +111,8 @@ static void
xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen); xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen);
static void static void
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
int dx, int dy); int dx,
int dy);
static inline xp_error static inline xp_error
xprConfigureWindow(xp_window_id id, unsigned int mask, xprConfigureWindow(xp_window_id id, unsigned int mask,
@ -131,8 +134,9 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
data = native_id; data = native_id;
dixChangeWindowProperty(serverClient, pFrame->win, dixChangeWindowProperty(serverClient, pFrame->win,
xa_native_window_id(), XA_INTEGER, 32, xa_native_window_id(),
PropModeReplace, 1, &data, TRUE); XA_INTEGER, 32, PropModeReplace, 1, &data,
TRUE);
} }
} }
@ -140,8 +144,8 @@ static xp_error
xprColormapCallback(void *data, int first_color, int n_colors, xprColormapCallback(void *data, int first_color, int n_colors,
uint32_t *colors) uint32_t *colors)
{ {
return (RootlessResolveColormap(data, first_color, n_colors, colors) ? return (RootlessResolveColormap(data, first_color, n_colors,
XP_Success : XP_BadMatch); colors) ? XP_Success : XP_BadMatch);
} }
/* /*
@ -203,8 +207,8 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^ { 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 #else
pthread_rwlock_wrlock(&window_hash_rwlock); pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_insert(window_hash, pFrame->wid, pFrame); x_hash_table_insert(window_hash, pFrame->wid, pFrame);
@ -226,7 +230,8 @@ xprDestroyFrame(RootlessFrameID wid)
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^ { dispatch_async(window_hash_serial_q, ^ {
x_hash_table_remove(window_hash, wid);}); x_hash_table_remove(window_hash, wid);
});
#else #else
pthread_rwlock_wrlock(&window_hash_rwlock); pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_remove(window_hash, wid); x_hash_table_remove(window_hash, wid);
@ -236,7 +241,8 @@ xprDestroyFrame(RootlessFrameID wid)
err = xp_destroy_window(x_cvt_vptr_to_uint(wid)); err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
if (err != Success) if (err != Success)
FatalError("Could not destroy window %d (%d).", 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,7 +289,6 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
{ {
xp_window_changes wc; xp_window_changes wc;
unsigned int mask = XP_STACKING; unsigned int mask = XP_STACKING;
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
__block __block
#endif #endif
@ -303,8 +308,8 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
dispatch_sync(window_hash_serial_q, ^ { 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 #else
pthread_rwlock_rdlock(&window_hash_rwlock); pthread_rwlock_rdlock(&window_hash_rwlock);
winRec = x_hash_table_lookup(window_hash, wid, NULL); winRec = x_hash_table_lookup(window_hash, wid, NULL);
@ -371,12 +376,12 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
unsigned int rowbytes[2]; unsigned int rowbytes[2];
xp_error err; xp_error err;
err = err = xp_lock_window(x_cvt_vptr_to_uint(
xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, wid), NULL, NULL, data, rowbytes, NULL);
NULL);
if (err != Success) if (err != Success)
FatalError("Could not lock window %d for drawing (%d).", 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]; *pixelData = data[0];
*bytesPerRow = rowbytes[0]; *bytesPerRow = rowbytes[0];
@ -396,7 +401,8 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
*/ */
if (err != Success) if (err != Success)
ErrorF("Could not unlock window %d after drawing (%d).", 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);
} }
/* /*
@ -505,14 +511,13 @@ xprGetXWindow(xp_window_id wid)
{ {
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
RootlessWindowRec *winRec __block; RootlessWindowRec *winRec __block;
dispatch_sync(window_hash_serial_q, ^ { dispatch_sync(window_hash_serial_q, ^ {
winRec = winRec =
x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), x_hash_table_lookup(window_hash,
NULL);}); x_cvt_uint_to_vptr(wid), NULL);
});
#else #else
RootlessWindowRec *winRec; RootlessWindowRec *winRec;
pthread_rwlock_rdlock(&window_hash_rwlock); pthread_rwlock_rdlock(&window_hash_rwlock);
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);
pthread_rwlock_unlock(&window_hash_rwlock); pthread_rwlock_unlock(&window_hash_rwlock);
@ -553,7 +558,6 @@ xprHideWindows(Bool hide)
for (screen = 0; screen < screenInfo.numScreens; screen++) { for (screen = 0; screen < screenInfo.numScreens; screen++) {
RootlessFrameID prevWid = NULL; RootlessFrameID prevWid = NULL;
pRoot = screenInfo.screens[screen]->root; pRoot = screenInfo.screens[screen]->root;
for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) { for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
@ -603,7 +607,6 @@ xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen)
{ {
/* This is how we tell xp that the colormap may have changed. */ /* This is how we tell xp that the colormap may have changed. */
xp_window_changes wc; xp_window_changes wc;
wc.colormap = xprColormapCallback; wc.colormap = xprColormapCallback;
wc.colormap_data = pScreen; wc.colormap_data = pScreen;
@ -615,7 +618,6 @@ static
xprHideWindow(RootlessFrameID wid) xprHideWindow(RootlessFrameID wid)
{ {
xp_window_changes wc; xp_window_changes wc;
wc.stack_mode = XP_UNMAPPED; wc.stack_mode = XP_UNMAPPED;
wc.sibling = 0; wc.sibling = 0;
configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc); configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc);

View File

@ -1,7 +1,7 @@
/* /*
* Xplugin rootless implementation screen functions * 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. * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -55,7 +55,7 @@
#endif #endif
/* 10.4's deferred update makes X slower.. have to live with the tearing /* 10.4's deferred update makes X slower.. have to live with the tearing
for now.. */ * for now.. */
#define XP_NO_DEFERRED_UPDATES 8 #define XP_NO_DEFERRED_UPDATES 8
// Name of GLX bundle for native OpenGL // 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; const xp_window_state_event *ws_arg = arg;
DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n",
ws_arg->id, ws_arg->state); ws_arg->id,
DarwinSendDDXEvent(kXquartzWindowState, 2, ws_arg->id,
ws_arg->state); ws_arg->state);
DarwinSendDDXEvent(kXquartzWindowState, 2,
ws_arg->id, ws_arg->state);
} }
else { else {
DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n"); DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
@ -94,13 +95,13 @@ eventHandler(unsigned int type, const void *arg,
DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n"); DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
if (arg_size == sizeof(xp_window_id)) { 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); DarwinSendDDXEvent(kXquartzWindowMoved, 1, id);
} }
break; break;
case XP_EVENT_SURFACE_DESTROYED: case XP_EVENT_SURFACE_DESTROYED:
DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n"); DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
case XP_EVENT_SURFACE_CHANGED: case XP_EVENT_SURFACE_CHANGED:
DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n"); DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
if (arg_size == sizeof(xp_surface_id)) { if (arg_size == sizeof(xp_surface_id)) {
@ -114,15 +115,16 @@ eventHandler(unsigned int type, const void *arg,
DRISurfaceNotify(*(xp_surface_id *)arg, kind); DRISurfaceNotify(*(xp_surface_id *)arg, kind);
} }
break; break;
#ifdef XP_EVENT_SPACE_CHANGED #ifdef XP_EVENT_SPACE_CHANGED
case XP_EVENT_SPACE_CHANGED: case XP_EVENT_SPACE_CHANGED:
DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n"); DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n");
if (arg_size == sizeof(uint32_t)) { 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); DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id);
} }
break; break;
#endif #endif
default: default:
ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type); ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type);
@ -163,7 +165,8 @@ displayScreenBounds(CGDirectDisplayID id)
(int)frame.origin.x, (int)frame.origin.y); (int)frame.origin.x, (int)frame.origin.y);
/* Remove menubar to help standard X11 window managers. */ /* 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.origin.y += aquaMenuBarHeight;
frame.size.height -= aquaMenuBarHeight; frame.size.height -= aquaMenuBarHeight;
} }
@ -193,8 +196,8 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height,
DEBUG_LOG("displayCount: %d\n", (int)displayCount); DEBUG_LOG("displayCount: %d\n", (int)displayCount);
if (!displayCount) { if (!displayCount) {
ErrorF ErrorF(
("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n"); "CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n");
*x = *y = 0; *x = *y = 0;
*width = 800; *width = 800;
*height = 600; *height = 600;
@ -219,7 +222,6 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height,
/* Get the union of all screens */ /* Get the union of all screens */
for (i = 0; i < displayCount; i++) { for (i = 0; i < displayCount; i++) {
CGDirectDisplayID dpy = displayList[i]; CGDirectDisplayID dpy = displayList[i];
frame = displayScreenBounds(dpy); frame = displayScreenBounds(dpy);
unionRect = CGRectUnion(unionRect, frame); unionRect = CGRectUnion(unionRect, frame);
} }
@ -276,12 +278,14 @@ xprDisplayInit(void)
FatalError("Could not initialize the Xplugin library."); FatalError("Could not initialize the Xplugin library.");
xp_select_events(XP_EVENT_DISPLAY_CHANGED 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 #ifdef XP_EVENT_SPACE_CHANGED
| XP_EVENT_SPACE_CHANGED | XP_EVENT_SPACE_CHANGED
#endif #endif
| XP_EVENT_SURFACE_CHANGED | XP_EVENT_SURFACE_CHANGED
| XP_EVENT_SURFACE_DESTROYED, eventHandler, NULL); | XP_EVENT_SURFACE_DESTROYED,
eventHandler, NULL);
AppleDRIExtensionInit(); AppleDRIExtensionInit();
xprAppleWMInit(); xprAppleWMInit();
@ -305,8 +309,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
if (depth == -1) { if (depth == -1) {
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
depth = depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
CGDisplayBitsPerSample(kCGDirectMainDisplay); CGDisplayBitsPerSample(kCGDirectMainDisplay);
#else #else
CGDisplayModeRef modeRef; CGDisplayModeRef modeRef;
@ -321,19 +324,19 @@ xprAddScreen(int index, ScreenPtr pScreen)
if (!encStrRef) if (!encStrRef)
goto have_depth; goto have_depth;
if (CFStringCompare if (CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels),
(encStrRef, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) ==
kCFCompareCaseInsensitive) == kCFCompareEqualTo) { kCFCompareEqualTo) {
depth = 24; depth = 24;
} }
else if (CFStringCompare else if (CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels),
(encStrRef, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) ==
kCFCompareCaseInsensitive) == kCFCompareEqualTo) { kCFCompareEqualTo) {
depth = 15; depth = 15;
} }
else if (CFStringCompare else if (CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels),
(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) ==
kCFCompareCaseInsensitive) == kCFCompareEqualTo) { kCFCompareEqualTo) {
depth = 8; depth = 8;
} }
@ -355,6 +358,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
dfb->greenMask = 0; dfb->greenMask = 0;
dfb->blueMask = 0; dfb->blueMask = 0;
break; break;
case 15: case 15:
dfb->visuals = TrueColorMask; //LARGE_VISUALS; dfb->visuals = TrueColorMask; //LARGE_VISUALS;
dfb->preferredCVC = TrueColor; dfb->preferredCVC = TrueColor;
@ -365,11 +369,12 @@ xprAddScreen(int index, ScreenPtr pScreen)
dfb->greenMask = GM_ARGB(0, 5, 5, 5); dfb->greenMask = GM_ARGB(0, 5, 5, 5);
dfb->blueMask = BM_ARGB(0, 5, 5, 5); dfb->blueMask = BM_ARGB(0, 5, 5, 5);
break; break;
// case 24: // case 24:
default: default:
if (depth != 24) if (depth != 24)
ErrorF ErrorF(
("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", "Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n",
depth, darwinDesiredDepth); depth, darwinDesiredDepth);
dfb->visuals = TrueColorMask; //LARGE_VISUALS; dfb->visuals = TrueColorMask; //LARGE_VISUALS;
dfb->preferredCVC = TrueColor; dfb->preferredCVC = TrueColor;