Commit Graph

44 Commits

Author SHA1 Message Date
Jeremy Huddleston Sequoia
8010d3a48b XQuartz: pbproxy: Fix build with -DDEBUG
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2013-09-16 07:06:57 -07:00
Jeremy Huddleston Sequoia
b4c2358e0a pbproxy: Fix a warning about a bad method prototype
x-selection.m:1502:1: warning: method has no return type specified; defaults to 'id'
      [-Wmissing-method-return-type,Semantic Issue]
- init
^
  (id)
1 warning generated.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2012-08-01 18:45:43 -07:00
Jeremy Huddleston
5324557c7b 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>
2012-03-24 01:07:06 -07:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Jeremy Huddleston
48b4b778f6 XQuartz: xpbproxy: Correct NSUInteger format strings
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-01 21:57:52 -07:00
Jeremy Huddleston
6f29dbf5e3 XQuartz: Use ErrorF rather than fprintf to log errors
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-04-25 22:00:41 -07:00
Emanuele Giaquinta
72ed7551f4 XQuartz: pbproxy: LP64: Fix itteration through XGetWindowProperty where sizeof(long) != 4
http://xquartz.macosforge.org/trac/ticket/476

Signed-off-by: Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-04-25 18:57:04 -07:00
Jeremy Huddleston
d0caa0e4cd XQuartz: Silence warnings about deprecated functionality where it is an intended fallback
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-04-25 18:57:03 -07:00
Jeremy Huddleston
422cd7a674 XQuartz: pbproxy: Remove debugging XBell()
(cherry picked from commit 1fd7c1fd47)
2009-09-14 14:29:50 -07:00
Jeremy Huddleston
7ece2cb220 XQuartz: pbproxy: 64bit fixes: Properly process an array of Atoms
(cherry picked from commit 1b659cda1a)
2009-09-06 14:06:06 -07:00
Jeremy Huddleston
b55cad4569 XQuartz: Don't hardcode values of org.x.X11 for the preferences domain
(cherry picked from commit 3a500d9247)
2008-11-25 00:54:37 -08:00
Jeremy Huddleston
c4ec71b405 XQuartz: pbproxy: nuke RCS Id, update header license/copyright
(cherry picked from commit 477c6968a8)
2008-11-19 10:58:15 -08:00
Jeremy Huddleston
e8112784e8 XQuartz: Integrated xpbproxy into the server.
Added a configure option called --enable-standalone-xpbproxy which is useful for deveoping xpbproxy.
The 'active' switch in preferences just disables the in-server xpbproxy (not this standalone).
(cherry picked from commit 4294493632)
2008-11-15 19:52:34 -08:00
George Peter Staplin
273df54685 XQuartz: pbproxy: Fix a bug that prevented nedit CLIPBOARD from being proxied.
It seems that we were calling copy_completed: too soon.  Now we return instead
of falling through to the free_propdata, and copy_completed:.
(cherry picked from commit 5797d5b662)
2008-10-28 22:01:34 -07:00
George Peter Staplin
313d87341a XQuartz: pbproxy: Work around bugs in some apps that aren't ICCCM compliant.
Eterm ends up setting the type of the property to TARGETS, instead of ATOM.
That's why it wasn't working.
(cherry picked from commit 9be5998ede)
2008-10-28 22:01:29 -07:00
George Peter Staplin
9007d3beea XQuartz: pbproxy: Add code to handle PICT conversion to PNG and JPEG.
This may work, unfortunately I don't have test apps that fail.

The way it works is by using an NSImage class initWithPasteboard:
method, which we then get the TIFFRepresentation of, and convert
to PNG or JPEG.

The TIFFRepresentation uses NSTIFFCompressionNone; which should be
lossless.
(cherry picked from commit 8d048cfa95)
2008-10-28 22:01:22 -07:00
Jeremy Huddleston
b742da0b71 XQuartz: pbproxy: fixed blocking
(cherry picked from commit bb330a1b1c)
2008-10-28 22:00:52 -07:00
Jeremy Huddleston
c885110aed Xquartz: pbproxy: Some debugging about unhandled mime types... this will spam up quick, but will be useful for a while...
(cherry picked from commit 3647215310)
2008-10-28 22:00:42 -07:00
Jeremy Huddleston
28d4f71193 XQuartz: pbproxy: Fix compilation on case-sensitive file systems...
(cherry picked from commit 6622efca21)
2008-10-23 16:30:53 -07:00
Jeremy Huddleston
2d764e21f2 XQuartz: pbproxy: SIGHUP reloads preferences.
(cherry picked from commit cbc0935ef7)
2008-10-23 14:16:57 -07:00
George Peter Staplin
f935c11398 XQuartz: pbproxy: Fix 2 bugs with the preferences.
Add dump_prefs() for instrospection.

Make prefs_get_bool a little more clear.

In get_property don't assume that the Mac realloc(NULL, 0); returns
non-NULL.  We shouldn't depend on implementation-defined behavior too
much.

Add more commentary in various spots.

Add TARGETS in the TARGETS response.  I don't know why some X11 apps
do this, but it could be something that some weird toolkit/app tests
for.

In reload_preferences add preferences synchronization, so that xpbproxy
reloads the preferences, and picks up any changes.

Fix a typo/misspelling of the sync_clipboard_to_pasteboard preference.
(cherry picked from commit 165cbbb90c)
2008-10-21 09:32:03 -07:00
Jeremy Huddleston
84ef8ed6fb XQuartz: implemented primary-on-grab and fixed clipboard-to-pasteboard
(cherry picked from commit bcb83eea72)
2008-10-15 17:31:54 -07:00
Jeremy Huddleston
ed3134918d XQuartz: pbcopy: Re-enabled some code I commented out for testing
(cherry picked from commit 9b5d114092)
2008-10-04 21:17:09 -07:00
Jeremy Huddleston
b3a971d8b5 XQuartz: xpbproxy: Support some of the preference toggles from X11.app, cleaned up CLIPBOARD_MANAGER atom management.
(cherry picked from commit f7673bb4de)
2008-10-04 21:17:02 -07:00
George Peter Staplin
7bb73a9513 XQuartz: pbproxy: Possibly fix a memory leak by using an [NSApp run] loop,
instead of calling CFRunLoopRun() directly.  The leak wasn't reproducible on
this machine, but someone was able to produce a leak trace with Instruments
that indicates it was leaking in the CFRunLoopRun() path.

x-input.m: dequeue and ignore events when pbproxy_active is false.

x-selection.h: add an is_active method that is used by x-input.m to ignore
events.

x-selection.m: Handle nearly every preference, except for primary_on_grab,
which I don't really understand yet.
(cherry picked from commit 4d51ad851e)
2008-10-03 11:14:49 -07:00
George Peter Staplin
b1d0b19661 XQuartz: pbproxy: Make the signal handler safer by using _exit, and only exit.
Remove some unnecesssary headers.

Remove some dead code that was never called or used in pbproxy.

Make use of an NSAutoreleasePool in x_init.  It could potentially cause a leak
on a startup without this.

Start adding reload_preferences to the x_selection class, as well as event
handling for that.
(cherry picked from commit 602e8ba8f7)
2008-10-03 11:14:30 -07:00
George Peter Staplin
eb8be3e90a XQuartz: pbproxy: Fix another STRING bug.
Fix the usage of the NSString cStringUsingEncoding: - it doesn't NUL
terminate the string, which lead to a bus error.  So, we use
lengthOfBytesUsingEncoding: to get the length in bytes instead of
strlen().
(cherry picked from commit 6333d619e7)
2008-09-26 12:31:33 -07:00
George Peter Staplin
edfa3f8233 XQuartz: pbproxy: Fix a bug that rxvt brought out in STRING copying. Now I can copy and paste to/from rxvt correctly.
(cherry picked from commit 82a4dc5f0f)
2008-09-26 12:31:29 -07:00
George Peter Staplin
591cc57627 XQuartz: pbproxy: Fix 3 paths that could leak memory.
2 of the paths leaked, when INCR transfers were done.  Now we
are leak free according to the leaks program for all transfers
I have tried so far.
(cherry picked from commit aa98db576b)
2008-09-26 12:31:12 -07:00
George Peter Staplin
586fbc91df XQuartz: pbproxy: Fix NSObject memory leaks by properly using the
NSAutoreleasePool.   Now the usage is consistent.  In x_input_run()
we create a pool, and release it after processing the XEvents.

Add some getpid() output to main for debugging.  It needs a bit more
testing before the next release.

Don't retain the NSPasteboard as the old code did.  That may have
contributed to the leak, and it made it so that we needed the
NSAutoreleasePool created in main().

Remove the _known_types, and _pasteboard instance variables from
the x_selection class.  They aren't needed anymore.

The leaks program now indicates 0 leaks after some usage.  I want
to test further, but this seems much better, and my memory usage
graph indicates it's not growing.
(cherry picked from commit b245d84a72)
2008-09-26 12:31:06 -07:00
George Peter Staplin
238999cfc9 XQuartz: pbproxy: Add a comment to pbproxy.h about how the DB()
macro causes a leak (according to the leaks program).

Attempt to fix several other leaks with release method calls.
For some reason the process still grows more than it should...

I will need to use some better methods than leaks, and malloc_history
I suspect.  Whatever is leaking, it's hard to find.  I need to isolate
the cases more.

Add a missing image/jpeg branch.

Remove read_prop_32 - it's not used.
(cherry picked from commit 63a680354d)
2008-09-26 12:31:01 -07:00
George Peter Staplin
852a0b0dde XQuartz: pbproxy: Add an X error handler that returns 0.
Move the struct atom_list into the x-selection class, so that it's
no longer a global variable named atoms.  This may ease pthread
integration and reduce the chances of symbols conflicting.
(cherry picked from commit c1403c713c)
2008-09-21 17:40:42 -07:00
George Peter Staplin
7fa6fc5ad0 XQuartz: pbproxy: Fix a bug that occured when a PICT format was available.
We may need another branch to convert a PICT to a PNG or JPEG.  For now
TIFF works well in all of the test image copying apps when converted to
PNG or JPEG with an NSBitmapImageRep class.
(cherry picked from commit adf339d8f9)
2008-09-21 17:40:41 -07:00
George Peter Staplin
f67490ceb5 XQuartz: pbproxy: Make the proxy handle copy request races, and PRIMARY
INCR transfers mixed with a CLIPBOARD change.

Fix a bug with some UTF-8 transfers.  I can only guess that my UTF-8
tests before were inadequate.  I can now copy/paste any characters between
uxterm and Textedit.app.
(cherry picked from commit 7ca1532e8e)
2008-09-21 17:40:41 -07:00
George Peter Staplin
a928cae57b XQuartz: pbproxy: Add a missing include of Xutil.h. Another header
seems to have done this before, but correctness matters.
(cherry picked from commit 1b4987e779)
2008-09-21 17:40:16 -07:00
George Peter Staplin
749bdf19b2 XQuartz: pbproxy: Add COMPOUND_TEXT handling. Do misc. cleanups with testing
to verify that the behavior didn't change.

main.m: XInternAtom compound_text, and atom_pair.

pbproxy.h: Add compound_text and atom_pair to the struct atom_list.

x-selection.m: Add an #include of Xutil.h.  Refactor the reply struct
initialization to be done in a common place.  Add send_reply: to simplify
the code a bit more.  Add send_compound_text: which handles the
COMPOUND_TEXT type.  Add the beginnings of a send_multiple:.  Change
handle_image:extension: to handle_image:.  The extension: message isn't
needed anymore.
(cherry picked from commit 1e9460abdf)
2008-09-21 17:40:16 -07:00
George Peter Staplin
00bfbee59f XQuartz: pbproxy: pbproxy now responds to selection request events.
We can now copy and paste images to and from X11.  Text copying and
pasting works as well.

The NSPasteboard can contain TIFF or PICT images, and pbproxy will
translate to an image/png or image/jpeg request, and list those in the
TARGETS.

I added a description of the basic design at the top of x-selection.m.

I removed the request_data x_selection class struct.  It's not needed.
(cherry picked from commit 4a8daf8846)
2008-09-21 17:40:16 -07:00
George Peter Staplin
811e9f5e9e XQuartz: pbproxy: Use an NSBitmapImageRep to convert an "image/png" selection
to a TIFFRepresentation for use with NSPasteboard.

This has been tested with the Gimp and works with some minor quartz-wm changes.
The Finder clipboard shows the image updates after an Edit -> Copy.
(cherry picked from commit 12912adaee)
2008-09-21 17:40:16 -07:00
George Peter Staplin
23ec8261b6 XQuartz: pbproxy: The greedy CLIPBOARD handling now works for text.
This change adds some [self own_clipboard] calls in the necessary places to get the proper greedy behavior.

UTF8_STRING and STRING properties seem to work well now with the test cases (PRIMARY, and CLIPBOARD).  I can copy from several different X apps, and have the behavior be correct when pasting.  I also verified that quartz-wm isn't doing the copying, by disabling the quartz-wm paths.
(cherry picked from commit 934669f732)
2008-09-21 17:40:15 -07:00
George Peter Staplin
7c2eb3d41a XQuartz: pbproxy: return the TARGETS list as a 32-bit list to fix a bug that was in the original.
Add TRACE() calls where appropriate to try to figure out why we are losing CLIPBOARD at times, after transferring PRIMARY to the NSPasteboard.

Use the new pbproxy_clipboard_to_pasteboard where appropriate.
(cherry picked from commit 40190675a6)
2008-09-21 17:40:15 -07:00
George Peter Staplin
81c836902d Rename reclaim_clipboard to claim_clipboard.
Convert the puts usage to use DB().

Add the initial handle_image method.

Check for nil in the NSString instantiation in various places.

Add some commentary to enhance the clarity of why I did some things.
(cherry picked from commit 37361567b6)
2008-09-21 17:40:15 -07:00
Jeremy Huddleston
cbd32645f7 XQuartz: pbproxy: Added global variables to customize how pbproxy behaves
(cherry picked from commit 21a2d0b8d0)
2008-09-21 17:40:14 -07:00
Jeremy Huddleston
5b397642cd XQuartz: pbproxy: First round of updates to pbproxy from George.
(cherry picked from commit 5c8b956f8f)
2008-09-21 17:40:14 -07:00
Jeremy Huddleston
1669308be6 XQuartz: Added pasteboard proxy code stripped out of quartz-wm.
(cherry picked from commit 1f842c71c3)
(cherry picked from commit 144746223d)
2008-09-03 09:33:58 -07:00