accessibility_core 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.markdown +6 -0
- data/README.markdown +6 -3
- data/Rakefile +0 -14
- data/ext/accessibility/bridge/bridge.c +393 -425
- data/ext/accessibility/bridge/bridge.h +126 -128
- data/ext/accessibility/bridge/extconf.rb +7 -12
- data/ext/accessibility/core/core.c +76 -109
- data/ext/accessibility/core/extconf.rb +7 -12
- data/ext/accessibility/extras/extconf.rb +7 -13
- data/ext/accessibility/extras/extras.c +18 -41
- data/ext/accessibility/highlighter/extconf.rb +7 -13
- data/ext/accessibility/highlighter/highlighter.c +11 -20
- data/lib/accessibility/bridge.rb +1 -31
- data/lib/accessibility/core.rb +1 -6
- data/lib/accessibility/core/version.rb +1 -1
- data/lib/accessibility/extras.rb +0 -2
- data/lib/accessibility/highlighter.rb +1 -6
- data/test/helper.rb +0 -10
- metadata +4 -9
- data/lib/accessibility/bridge/macruby.rb +0 -202
- data/lib/accessibility/core/macruby.rb +0 -855
- data/lib/accessibility/highlighter/macruby.rb +0 -85
- data/test/test_core.rb +0 -100
@@ -4,19 +4,14 @@ $CFLAGS << ' -std=c99 -Wall -Werror -pedantic -ObjC'
|
|
4
4
|
$LIBS << ' -framework CoreFoundation -framework ApplicationServices -framework Cocoa'
|
5
5
|
$LIBS << ' -framework CoreGraphics' unless `sw_vers -productVersion`.to_f == 10.7
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
RbConfig::MAKEFILE_CONFIG["CC"] = clang
|
16
|
-
RbConfig::MAKEFILE_CONFIG["CXX"] = clang
|
17
|
-
end
|
7
|
+
unless RbConfig::CONFIG["CC"].match(/clang/)
|
8
|
+
clang = `which clang`.chomp
|
9
|
+
if clang.empty?
|
10
|
+
raise "Clang not installed. Cannot build C extension"
|
11
|
+
else
|
12
|
+
RbConfig::MAKEFILE_CONFIG["CC"] = clang
|
13
|
+
RbConfig::MAKEFILE_CONFIG["CXX"] = clang
|
18
14
|
end
|
19
|
-
$CFLAGS << ' -DNOT_MACRUBY'
|
20
15
|
end
|
21
16
|
|
22
17
|
create_makefile 'accessibility/core/core'
|
@@ -3,20 +3,14 @@ require 'mkmf'
|
|
3
3
|
$CFLAGS << ' -std=c99 -Wall -Werror -pedantic -ObjC'
|
4
4
|
$LIBS << ' -framework CoreFoundation -framework Cocoa -framework IOKit'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
raise "Clang not installed. Cannot build C extension"
|
14
|
-
else
|
15
|
-
RbConfig::MAKEFILE_CONFIG["CC"] = clang
|
16
|
-
RbConfig::MAKEFILE_CONFIG["CXX"] = clang
|
17
|
-
end
|
6
|
+
unless RbConfig::CONFIG["CC"].match(/clang/)
|
7
|
+
clang = `which clang`.chomp
|
8
|
+
if clang.empty?
|
9
|
+
raise "Clang not installed. Cannot build C extension"
|
10
|
+
else
|
11
|
+
RbConfig::MAKEFILE_CONFIG["CC"] = clang
|
12
|
+
RbConfig::MAKEFILE_CONFIG["CXX"] = clang
|
18
13
|
end
|
19
|
-
$CFLAGS << ' -DNOT_MACRUBY'
|
20
14
|
end
|
21
15
|
|
22
16
|
create_makefile 'accessibility/extras/extras'
|
@@ -7,11 +7,9 @@
|
|
7
7
|
#import <IOKit/ps/IOPSKeys.h>
|
8
8
|
#import <IOKit/pwr_mgt/IOPMLib.h>
|
9
9
|
#import <IOKit/hidsystem/IOHIDShared.h>
|
10
|
+
#import <Cocoa/Cocoa.h>
|
10
11
|
|
11
12
|
static VALUE rb_mBattery;
|
12
|
-
#ifndef NOT_MACRUBY
|
13
|
-
static VALUE rb_cScreen;
|
14
|
-
#endif
|
15
13
|
|
16
14
|
static VALUE battery_not_installed;
|
17
15
|
static VALUE battery_charged;
|
@@ -20,11 +18,6 @@ static VALUE battery_discharging;
|
|
20
18
|
|
21
19
|
static io_connect_t screen_connection = MACH_PORT_NULL;
|
22
20
|
|
23
|
-
|
24
|
-
#ifdef NOT_MACRUBY
|
25
|
-
|
26
|
-
#import <Cocoa/Cocoa.h>
|
27
|
-
|
28
21
|
static VALUE rb_cRunningApp;
|
29
22
|
static VALUE rb_cWorkspace;
|
30
23
|
static VALUE rb_cProcInfo;
|
@@ -38,9 +31,9 @@ static VALUE key_opts;
|
|
38
31
|
|
39
32
|
static
|
40
33
|
VALUE
|
41
|
-
wrap_app(NSRunningApplication* app)
|
34
|
+
wrap_app(NSRunningApplication* const app)
|
42
35
|
{
|
43
|
-
|
36
|
+
return Data_Wrap_Struct(rb_cRunningApp, NULL, objc_finalizer, (void*)app);
|
44
37
|
}
|
45
38
|
|
46
39
|
static
|
@@ -52,22 +45,23 @@ unwrap_app(VALUE app)
|
|
52
45
|
return running_app;
|
53
46
|
}
|
54
47
|
|
55
|
-
static VALUE wrap_array_apps(NSArray* ary)
|
48
|
+
static VALUE wrap_array_apps(NSArray* const ary)
|
56
49
|
{
|
57
|
-
CFArrayRef array = (CFArrayRef)ary;
|
50
|
+
CFArrayRef const array = (CFArrayRef const)ary;
|
58
51
|
WRAP_ARRAY(wrap_app);
|
59
52
|
}
|
60
53
|
|
61
54
|
|
62
55
|
static
|
63
56
|
VALUE
|
64
|
-
rb_running_app_with_pid(VALUE self, VALUE
|
57
|
+
rb_running_app_with_pid(VALUE self, VALUE num_pid)
|
65
58
|
{
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
59
|
+
const pid_t pid = NUM2PIDT(num_pid);
|
60
|
+
NSRunningApplication* const app =
|
61
|
+
[NSRunningApplication runningApplicationWithProcessIdentifier:pid];
|
62
|
+
|
63
|
+
if (app) return wrap_app(app);
|
64
|
+
return Qnil; // ruby behaviour would be to raise, but we want "drop-in" compat
|
71
65
|
}
|
72
66
|
|
73
67
|
static
|
@@ -82,10 +76,9 @@ static
|
|
82
76
|
VALUE
|
83
77
|
rb_running_app_current_app(VALUE self)
|
84
78
|
{
|
85
|
-
|
86
|
-
|
87
|
-
return
|
88
|
-
return Qnil;
|
79
|
+
NSRunningApplication* const app = [NSRunningApplication currentApplication];
|
80
|
+
if (app) return wrap_app(app);
|
81
|
+
return Qnil;
|
89
82
|
}
|
90
83
|
|
91
84
|
static
|
@@ -482,26 +475,19 @@ static
|
|
482
475
|
VALUE
|
483
476
|
rb_screen_screens(VALUE self)
|
484
477
|
{
|
485
|
-
|
478
|
+
return wrap_array_screens((CFArrayRef)[NSScreen screens]);
|
486
479
|
}
|
487
480
|
|
488
481
|
static
|
489
482
|
VALUE
|
490
483
|
rb_screen_frame(VALUE self)
|
491
484
|
{
|
492
|
-
|
485
|
+
return wrap_rect(NSRectToCGRect([unwrap_screen(self) frame]));
|
493
486
|
}
|
494
487
|
|
495
|
-
#endif
|
496
|
-
|
497
|
-
|
498
488
|
static
|
499
489
|
VALUE
|
500
|
-
#ifdef NOT_MACRUBY
|
501
490
|
rb_screen_wake(VALUE self)
|
502
|
-
#else
|
503
|
-
rb_screen_wake(VALUE self, SEL sel)
|
504
|
-
#endif
|
505
491
|
{
|
506
492
|
// don't bother if we are awake
|
507
493
|
if (!CGDisplayIsAsleep(CGMainDisplayID()))
|
@@ -518,7 +504,7 @@ rb_screen_wake(VALUE self, SEL sel)
|
|
518
504
|
}
|
519
505
|
}
|
520
506
|
|
521
|
-
CGPoint mouse = [NSEvent mouseLocation];
|
507
|
+
CGPoint mouse = NSPointToCGPoint([NSEvent mouseLocation]);
|
522
508
|
IOGPoint point = { mouse.x, mouse.y };
|
523
509
|
unsigned int flags = (unsigned int)[NSEvent modifierFlags];
|
524
510
|
NXEventData data;
|
@@ -720,8 +706,6 @@ Init_extras()
|
|
720
706
|
// force Ruby to be registered as an app with the system
|
721
707
|
[NSApplication sharedApplication];
|
722
708
|
|
723
|
-
#ifdef NOT_MACRUBY
|
724
|
-
|
725
709
|
/*
|
726
710
|
* Document-class: NSRunningApplication
|
727
711
|
*
|
@@ -861,9 +845,7 @@ Init_extras()
|
|
861
845
|
rb_define_method(rb_cBundle, "infoDictionary", rb_bundle_info_dict, 0);
|
862
846
|
rb_define_method(rb_cBundle, "objectForInfoDictionaryKey", rb_bundle_object_for_info_dict_key, 1);
|
863
847
|
|
864
|
-
|
865
848
|
rb_define_method(rb_cObject, "load_plist", rb_load_plist, 1);
|
866
|
-
#endif
|
867
849
|
|
868
850
|
|
869
851
|
/*
|
@@ -877,15 +859,10 @@ Init_extras()
|
|
877
859
|
*/
|
878
860
|
rb_cScreen = rb_define_class("NSScreen", rb_cObject);
|
879
861
|
|
880
|
-
#ifdef NOT_MACRUBY
|
881
862
|
rb_define_singleton_method(rb_cScreen, "mainScreen", rb_screen_main, 0);
|
882
863
|
rb_define_singleton_method(rb_cScreen, "screens", rb_screen_screens, 0);
|
883
864
|
rb_define_singleton_method(rb_cScreen, "wakeup", rb_screen_wake, 0); // our custom method
|
884
865
|
rb_define_method( rb_cScreen, "frame", rb_screen_frame, 0);
|
885
|
-
#else
|
886
|
-
rb_objc_define_method(*(VALUE*)rb_cScreen, "wakeup", rb_screen_wake, 0);
|
887
|
-
#endif
|
888
|
-
|
889
866
|
|
890
867
|
/*
|
891
868
|
* Document-module: Battery
|
@@ -4,20 +4,14 @@ $CFLAGS << ' -std=c99 -Wall -Werror -pedantic -ObjC'
|
|
4
4
|
$LIBS << ' -framework CoreFoundation -framework ApplicationServices -framework Cocoa'
|
5
5
|
$LIBS << ' -framework CoreGraphics' unless `sw_vers -productVersion`.to_f == 10.7
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
raise "Clang not installed. Cannot build C extension"
|
15
|
-
else
|
16
|
-
RbConfig::MAKEFILE_CONFIG["CC"] = clang
|
17
|
-
RbConfig::MAKEFILE_CONFIG["CXX"] = clang
|
18
|
-
end
|
7
|
+
unless RbConfig::CONFIG["CC"].match(/clang/)
|
8
|
+
clang = `which clang`.chomp
|
9
|
+
if clang.empty?
|
10
|
+
raise "Clang not installed. Cannot build C extension"
|
11
|
+
else
|
12
|
+
RbConfig::MAKEFILE_CONFIG["CC"] = clang
|
13
|
+
RbConfig::MAKEFILE_CONFIG["CXX"] = clang
|
19
14
|
end
|
20
|
-
$CFLAGS << ' -DNOT_MACRUBY'
|
21
15
|
end
|
22
16
|
|
23
17
|
create_makefile 'accessibility/highlighter/highlighter'
|
@@ -4,8 +4,6 @@
|
|
4
4
|
#include "../extras/extras.h"
|
5
5
|
|
6
6
|
|
7
|
-
#ifdef NOT_MACRUBY
|
8
|
-
|
9
7
|
static VALUE rb_cHighlighter;
|
10
8
|
static VALUE rb_cColor;
|
11
9
|
|
@@ -53,9 +51,9 @@ static
|
|
53
51
|
CGRect
|
54
52
|
flip(CGRect rect)
|
55
53
|
{
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
const double screen_height = NSMaxY([[NSScreen mainScreen] frame]);
|
55
|
+
rect.origin.y = screen_height - NSMaxY(NSRectFromCGRect(rect));
|
56
|
+
return rect;
|
59
57
|
}
|
60
58
|
|
61
59
|
static
|
@@ -65,14 +63,12 @@ rb_highlighter_new(int argc, VALUE* argv, VALUE self)
|
|
65
63
|
if (!argc)
|
66
64
|
rb_raise(rb_eArgError, "wrong number of arguments (0 for 1+)");
|
67
65
|
|
68
|
-
CGRect bounds = unwrap_rect(coerce_to_rect(argv[0]));
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
backing:NSBackingStoreBuffered
|
75
|
-
defer:true];
|
66
|
+
const CGRect bounds = flip(unwrap_rect(coerce_to_rect(argv[0])));
|
67
|
+
NSWindow* const window =
|
68
|
+
[[NSWindow alloc] initWithContentRect:NSRectFromCGRect(bounds)
|
69
|
+
styleMask:NSBorderlessWindowMask
|
70
|
+
backing:NSBackingStoreBuffered
|
71
|
+
defer:true];
|
76
72
|
|
77
73
|
NSColor* color = [NSColor magentaColor];
|
78
74
|
|
@@ -89,7 +85,7 @@ rb_highlighter_new(int argc, VALUE* argv, VALUE self)
|
|
89
85
|
[window setLevel:NSStatusWindowLevel];
|
90
86
|
[window setBackgroundColor:color];
|
91
87
|
[window setIgnoresMouseEvents:true];
|
92
|
-
[window setFrame:bounds display:false];
|
88
|
+
[window setFrame:NSRectFromCGRect(bounds) display:false];
|
93
89
|
[window makeKeyAndOrderFront:NSApp];
|
94
90
|
[window setReleasedWhenClosed:false];
|
95
91
|
|
@@ -132,7 +128,7 @@ static
|
|
132
128
|
VALUE
|
133
129
|
rb_highlighter_frame(VALUE self)
|
134
130
|
{
|
135
|
-
|
131
|
+
return wrap_rect(NSRectToCGRect([unwrap_window(self) frame]));
|
136
132
|
}
|
137
133
|
|
138
134
|
static
|
@@ -225,7 +221,6 @@ rb_color_equality(VALUE self, VALUE other)
|
|
225
221
|
return Qfalse;
|
226
222
|
}
|
227
223
|
|
228
|
-
#endif
|
229
224
|
|
230
225
|
|
231
226
|
void
|
@@ -234,8 +229,6 @@ Init_highlighter()
|
|
234
229
|
Init_bridge();
|
235
230
|
Init_extras();
|
236
231
|
|
237
|
-
#ifdef NOT_MACRUBY
|
238
|
-
|
239
232
|
// force initialization or NSWindow won't work
|
240
233
|
[NSApplication sharedApplication];
|
241
234
|
|
@@ -292,6 +285,4 @@ Init_highlighter()
|
|
292
285
|
//rb_define_singleton_method(rb_cColor, "colorWithSRGBRed", rb_color_rgb, 2);
|
293
286
|
|
294
287
|
rb_define_method(rb_cColor, "==", rb_color_equality, 1);
|
295
|
-
|
296
|
-
#endif
|
297
288
|
}
|
data/lib/accessibility/bridge.rb
CHANGED
@@ -1,33 +1,3 @@
|
|
1
1
|
require 'accessibility/core/version'
|
2
|
+
require 'accessibility/bridge/mri'
|
2
3
|
|
3
|
-
|
4
|
-
if defined? MACRUBY_REVISION
|
5
|
-
|
6
|
-
##
|
7
|
-
# Whether or not we are running on MacRuby
|
8
|
-
def on_macruby?
|
9
|
-
true
|
10
|
-
end
|
11
|
-
|
12
|
-
framework 'Cocoa'
|
13
|
-
|
14
|
-
# A workaround that guarantees that `CGPoint` is defined
|
15
|
-
unless defined? MOUNTAIN_LION_APPKIT_VERSION
|
16
|
-
MOUNTAIN_LION_APPKIT_VERSION = 1187
|
17
|
-
end
|
18
|
-
|
19
|
-
if NSAppKitVersionNumber >= MOUNTAIN_LION_APPKIT_VERSION
|
20
|
-
framework '/System/Library/Frameworks/CoreGraphics.framework'
|
21
|
-
end
|
22
|
-
|
23
|
-
require 'accessibility/bridge/macruby'
|
24
|
-
|
25
|
-
else
|
26
|
-
|
27
|
-
def on_macruby?
|
28
|
-
false
|
29
|
-
end
|
30
|
-
|
31
|
-
require 'accessibility/bridge/mri'
|
32
|
-
|
33
|
-
end
|
data/lib/accessibility/core.rb
CHANGED
data/lib/accessibility/extras.rb
CHANGED
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accessibility_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
accessibility_core is a wrapper around the OS X Accessibility framework.
|
@@ -28,15 +28,12 @@ extensions:
|
|
28
28
|
extra_rdoc_files: []
|
29
29
|
files:
|
30
30
|
- lib/accessibility/bridge/common.rb
|
31
|
-
- lib/accessibility/bridge/macruby.rb
|
32
31
|
- lib/accessibility/bridge/mri.rb
|
33
32
|
- lib/accessibility/bridge.rb
|
34
|
-
- lib/accessibility/core/macruby.rb
|
35
33
|
- lib/accessibility/core/version.rb
|
36
34
|
- lib/accessibility/core.rb
|
37
35
|
- lib/accessibility/extras/common.rb
|
38
36
|
- lib/accessibility/extras.rb
|
39
|
-
- lib/accessibility/highlighter/macruby.rb
|
40
37
|
- lib/accessibility/highlighter.rb
|
41
38
|
- ext/accessibility/bridge/bridge.c
|
42
39
|
- ext/accessibility/core/core.c
|
@@ -52,9 +49,8 @@ files:
|
|
52
49
|
- README.markdown
|
53
50
|
- History.markdown
|
54
51
|
- .yardopts
|
55
|
-
- test/test_core.rb
|
56
52
|
- test/helper.rb
|
57
|
-
homepage:
|
53
|
+
homepage: https://github.com/AXElements/accessibility_core
|
58
54
|
licenses:
|
59
55
|
- BSD 3-clause
|
60
56
|
metadata: {}
|
@@ -74,10 +70,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
70
|
version: '0'
|
75
71
|
requirements: []
|
76
72
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.0.
|
73
|
+
rubygems_version: 2.0.14
|
78
74
|
signing_key:
|
79
75
|
specification_version: 4
|
80
76
|
summary: A library for building automation tools on OS X
|
81
77
|
test_files:
|
82
|
-
- test/test_core.rb
|
83
78
|
- test/helper.rb
|