active_window_x 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,20 @@
1
1
  require "mkmf"
2
2
 
3
+ map = {
4
+ '1.8.' => 'RUBY_1_8',
5
+ '1.9.' => 'RUBY_1_9',
6
+ }
7
+ version, micro = map.find do |v, m|
8
+ RUBY_VERSION.start_with? v
9
+ end
10
+
11
+ if micro.nil?
12
+ then abort "Not supported ruby version: #{RUBY_VERSION}"
13
+ else $defs << "-D#{micro}"
14
+ end
15
+
3
16
  if have_library('X11')
4
17
  create_makefile "active_window_x/xlib"
5
18
  else
6
- raise "Cannot found X11"
19
+ abort "Cannot found X11"
7
20
  end
@@ -324,7 +324,6 @@ VALUE x_event_new(XEvent *xevent) {
324
324
  VALUE xlib_x_next_event(VALUE self, VALUE display_obj) {
325
325
  Display *display;
326
326
  XEvent *event_return;
327
- VALUE event_obj;
328
327
 
329
328
  GetDisplay(display_obj, display);
330
329
  event_return = ALLOC(XEvent);
@@ -345,13 +344,15 @@ VALUE xlib_x_set_wm_protocols(VALUE self, VALUE display_obj, VALUE w_obj,
345
344
  Display *display;
346
345
  Window w;
347
346
  Atom *atom_ary;
348
- int count, s, len, i;
347
+ int count, s, i;
349
348
 
350
349
  GetDisplay(display_obj, display);
350
+ count = RARRAY_LEN(atom_ary_obj);
351
+ atom_ary = ALLOC_N(Atom, count);
352
+ for (i=0; i<count; i++)
353
+ atom_ary[i] = RARRAY_PTR(atom_ary_obj)[i];
354
+
351
355
  w = (Window) NUM2ULONG(w_obj);
352
- count = RARRAY(atom_ary_obj)->len;
353
- atom_ary = ALLOC_N(Atom, len);
354
- for (i=0; i<count; i++) atom_ary[i] = RARRAY(atom_ary_obj)->ptr[i];
355
356
 
356
357
  s = XSetWMProtocols(display, w, atom_ary, count);
357
358
  raise_if_xerror_occurred();
@@ -1,4 +1,4 @@
1
- # -*- coding:undecided-unix; mode:ruby; -*-
1
+ # -*- coding:utf-8; mode:ruby; -*-
2
2
 
3
3
  require "active_window_x/version"
4
4
  require "active_window_x/xlib"
@@ -1,3 +1,3 @@
1
1
  module ActiveWindowX
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -6,8 +6,8 @@ include ActiveWindowX
6
6
 
7
7
  describe Atom do
8
8
  before do
9
- @raw_display = mock Xlib::Display
10
- @display = mock Display
9
+ @raw_display = double Xlib::Display
10
+ @display = double Display
11
11
  @display.stub(:raw){@raw_display}
12
12
  @display.stub(:kind_of?).with(Display).and_return(true)
13
13
  @id = 123
@@ -6,7 +6,7 @@ include ActiveWindowX
6
6
 
7
7
  describe Display do
8
8
  before do
9
- @display_raw = mock Xlib::Display
9
+ @display_raw = double Xlib::Display
10
10
  Xlib.stub(:x_open_display).and_return(@display_raw)
11
11
  @display = Display.new nil
12
12
  @root_id = 9999
@@ -26,7 +26,7 @@ describe Display do
26
26
  before do
27
27
  @root = @display.root_window
28
28
  @root.select_input Xlib::PropertyChangeMask
29
- @event = mock Xlib::XPropertyEvent
29
+ @event = double Xlib::XPropertyEvent
30
30
  @event.stub(:type){@type}
31
31
  @event.stub(:serial){1000}
32
32
  @event.stub(:send_event){0}
@@ -6,7 +6,7 @@ include ActiveWindowX
6
6
 
7
7
  describe RootWindow do
8
8
  before do
9
- @display_raw = mock Xlib::Display
9
+ @display_raw = double Xlib::Display
10
10
  @display_raw.stub(:kind_of?).with(Data).and_return(true)
11
11
  Xlib.stub(:x_open_display).and_return(@display_raw)
12
12
  @display = Display.new
@@ -6,8 +6,8 @@ include ActiveWindowX
6
6
 
7
7
  describe Window do
8
8
  before do
9
- @raw_display = mock Xlib::Display
10
- @display = mock Display
9
+ @raw_display = double Xlib::Display
10
+ @display = double Display
11
11
  @display.stub(:raw){@raw_display}
12
12
  @display.stub(:kind_of?).with(Display).and_return(true)
13
13
  @id = 123456
@@ -1,7 +1,6 @@
1
1
  # -*- coding:utf-8; mode:ruby; -*-
2
2
 
3
3
  require 'active_window_x'
4
- require 'dl'
5
4
 
6
5
  include ActiveWindowX
7
6
 
@@ -149,14 +148,13 @@ describe Xlib do
149
148
  it 'should return a Array such as [Xlib::None, ]' do
150
149
  r = Xlib::x_get_window_property(@display, @window, @atom, 0, @length, false, 10)
151
150
  p r
152
- r.shift.should == @window_atom
153
- r.shift.should == 32
154
- r.shift.should == 0
155
- r.shift.should # == DL::sizeof('l')
156
- r.length.should == 1
151
+ r[0].should == @window_atom
152
+ r[1].should == 32
153
+ r[2].should == 0
154
+ r.length.should == 5
157
155
  end
158
156
  end
159
- context 'with an validi type and a propery named as "_NET_ACTIVE_WINDOW"' do
157
+ context 'with an valid type and a propery named as "_NET_ACTIVE_WINDOW"' do
160
158
  before do
161
159
  @name = "_NET_ACTIVE_WINDOW"
162
160
  @atom = Xlib::x_intern_atom @display, @name, false
@@ -165,11 +163,10 @@ describe Xlib do
165
163
  it 'should return a Array such as [Xlib::None, ]' do
166
164
  r = Xlib::x_get_window_property(@display, @window, @atom, 0, @length, false, @window_atom)
167
165
  p r
168
- r.shift.should == @window_atom
169
- r.shift.should == 32
170
- l = r.shift
171
- r.shift.should
172
- r.shift.length == DL::sizeof('l') * l
166
+ r[0].should == @window_atom
167
+ r[1].should == 32
168
+ r[2].should == 1
169
+ r.length.should == 5
173
170
  end
174
171
  end
175
172
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_window_x
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Keiichiro Ui
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-06 00:00:00 Z
18
+ date: 2014-02-11 00:00:00 +09:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rake
@@ -95,6 +96,7 @@ files:
95
96
  - spec/root_window_spec.rb
96
97
  - spec/window_spec.rb
97
98
  - spec/xlib_spec.rb
99
+ has_rdoc: true
98
100
  homepage: https://github.com/kui/active_window_x
99
101
  licenses: []
100
102
 
@@ -124,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
126
  requirements: []
125
127
 
126
128
  rubyforge_project:
127
- rubygems_version: 1.8.15
129
+ rubygems_version: 1.6.2
128
130
  signing_key:
129
131
  specification_version: 3
130
132
  summary: observer an active window on Linux (X Window System).