hornetseye-xorg 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/ext/init.cc +1 -1
- data/ext/x11window.cc +27 -28
- data/ext/x11window.hh +5 -5
- data/lib/hornetseye-xorg/x11display.rb +4 -3
- data/lib/hornetseye-xorg/x11window.rb +36 -0
- data/lib/hornetseye_xorg_ext.rb +1 -0
- metadata +5 -25
data/README.md
CHANGED
@@ -15,7 +15,7 @@ Installation
|
|
15
15
|
|
16
16
|
*hornetseye-xorg* requires the X.Org and Mesa development headers. If you are running Debian or (K)ubuntu, you can install them like this:
|
17
17
|
|
18
|
-
$ sudo aptitude install xserver-xorg-dev libgl1-mesa-dev libglu1-mesa-dev
|
18
|
+
$ sudo aptitude install xserver-xorg-dev libxv-dev libxpm-dev libgl1-mesa-dev libglu1-mesa-dev
|
19
19
|
|
20
20
|
To install this Ruby extension, use the following command:
|
21
21
|
|
data/Rakefile
CHANGED
data/ext/init.cc
CHANGED
@@ -36,7 +36,7 @@ extern "C" {
|
|
36
36
|
void Init_hornetseye_xorg(void)
|
37
37
|
{
|
38
38
|
// XInitThreads();
|
39
|
-
|
39
|
+
rb_eval_string( "require 'hornetseye_frame'" );
|
40
40
|
VALUE rbHornetseye = rb_define_module( "Hornetseye" );
|
41
41
|
X11Output::registerRubyClass( rbHornetseye );
|
42
42
|
XImagePainter::registerRubyClass( rbHornetseye, X11Output::cRubyClass );
|
data/ext/x11window.cc
CHANGED
@@ -199,33 +199,24 @@ static const char *hornetseye_xpm[] = {
|
|
199
199
|
"e.^ % V.V.Q y j.V.V.U t V.V.[ M "
|
200
200
|
};
|
201
201
|
|
202
|
+
typedef struct {
|
203
|
+
unsigned long flags;
|
204
|
+
unsigned long functions;
|
205
|
+
unsigned long decorations;
|
206
|
+
long inputMode;
|
207
|
+
unsigned long status;
|
208
|
+
} Hints;
|
209
|
+
|
202
210
|
VALUE X11Window::cRubyClass = Qnil;
|
203
211
|
|
204
|
-
X11Window::X11Window(
|
205
|
-
|
212
|
+
X11Window::X11Window(X11DisplayPtr display, X11PainterPtr painter,
|
213
|
+
int width, int height, Window parent, bool border):
|
206
214
|
m_display(display), m_painter(painter), m_width(width), m_height(height)
|
207
215
|
{
|
208
|
-
// state = true;
|
209
216
|
ERRORMACRO( width > 0 && height > 0, Error, ,
|
210
217
|
width << 'x' << height << " is an illegal window size." );
|
211
218
|
|
212
219
|
m_visualInfo = painter->visualInfo( display );
|
213
|
-
/* // Request true-colour X11 visual.
|
214
|
-
if ( !XMatchVisualInfo( display->get(),
|
215
|
-
DefaultScreen( display->get() ),
|
216
|
-
24, TrueColor, &m_visualInfo) ) {
|
217
|
-
if ( !XMatchVisualInfo( display->get(),
|
218
|
-
DefaultScreen( display->get() ),
|
219
|
-
16, TrueColor, &m_visualInfo ) ) {
|
220
|
-
if ( !XMatchVisualInfo( display->get(),
|
221
|
-
DefaultScreen( display->get() ),
|
222
|
-
15, TrueColor, &m_visualInfo ) ) {
|
223
|
-
ERRORMACRO( false, Error, ,
|
224
|
-
"Could not get X11 visual for true-colour display." );
|
225
|
-
};
|
226
|
-
};
|
227
|
-
}; */
|
228
|
-
|
229
220
|
// Create a color map.
|
230
221
|
m_colourMap = XCreateColormap( m_display->get(),
|
231
222
|
DefaultRootWindow( display->get() ),
|
@@ -257,9 +248,17 @@ X11Window::X11Window( X11DisplayPtr display, X11PainterPtr painter,
|
|
257
248
|
&attributes );
|
258
249
|
ERRORMACRO( m_window != 0, Error, , "Error creating X11 window." );
|
259
250
|
|
260
|
-
|
261
|
-
|
262
|
-
|
251
|
+
Atom wmProperty = XInternAtom(display->get(), "_MOTIF_WM_HINTS", True);
|
252
|
+
Hints hints;
|
253
|
+
hints.flags = 2;
|
254
|
+
hints.decorations = border ? 1 : 0;
|
255
|
+
XChangeProperty(display->get(), m_window, wmProperty, wmProperty, 32,
|
256
|
+
PropModeReplace,(unsigned char *)&hints, 5);
|
257
|
+
|
258
|
+
m_wmProtocols = XInternAtom( display->get(), "WM_PROTOCOLS", False );
|
259
|
+
m_wmDeleteWindow = XInternAtom( display->get(), "WM_DELETE_WINDOW", False );
|
260
|
+
XSetWMProtocols( display->get(), m_window, &m_wmDeleteWindow, 1 );
|
261
|
+
|
263
262
|
XWMHints wmHints;
|
264
263
|
XpmCreatePixmapFromData( display->get(), m_window,
|
265
264
|
(char **)hornetseye_xpm,
|
@@ -377,8 +376,8 @@ void X11Window::handleEvent( XEvent &event ) throw (Error)
|
|
377
376
|
paintEvent( true );
|
378
377
|
break;
|
379
378
|
case ClientMessage:
|
380
|
-
if ( ( event.xclient.message_type ==
|
381
|
-
( (Atom)event.xclient.data.l[0] ==
|
379
|
+
if ( ( event.xclient.message_type == m_wmProtocols ) &&
|
380
|
+
( (Atom)event.xclient.data.l[0] == m_wmDeleteWindow ) ) {
|
382
381
|
#ifndef NDEBUG
|
383
382
|
cerr << "Delete message" << endl;
|
384
383
|
#endif
|
@@ -430,8 +429,8 @@ void X11Window::keyEvent( XKeyEvent &xkey ) throw (Error)
|
|
430
429
|
VALUE X11Window::registerRubyClass( VALUE module )
|
431
430
|
{
|
432
431
|
cRubyClass = rb_define_class_under( module, "X11Window", rb_cObject );
|
433
|
-
rb_define_singleton_method(
|
434
|
-
|
432
|
+
rb_define_singleton_method(cRubyClass, "new",
|
433
|
+
RUBY_METHOD_FUNC( wrapNew ), 5);
|
435
434
|
rb_define_method( cRubyClass, "title=",
|
436
435
|
RUBY_METHOD_FUNC( wrapSetTitle ), 1 );
|
437
436
|
rb_define_method( cRubyClass, "width",
|
@@ -453,7 +452,7 @@ void X11Window::deleteRubyObject( void *ptr )
|
|
453
452
|
}
|
454
453
|
|
455
454
|
VALUE X11Window::wrapNew( VALUE rbClass, VALUE rbDisplay, VALUE rbX11Output,
|
456
|
-
VALUE rbWidth, VALUE rbHeight )
|
455
|
+
VALUE rbWidth, VALUE rbHeight, VALUE rbBorder )
|
457
456
|
{
|
458
457
|
VALUE retVal = Qnil;
|
459
458
|
try {
|
@@ -467,7 +466,7 @@ VALUE X11Window::wrapNew( VALUE rbClass, VALUE rbDisplay, VALUE rbX11Output,
|
|
467
466
|
x11Output );
|
468
467
|
X11WindowPtr ptr
|
469
468
|
( new X11Window( *display, (*x11Output)->painter(),
|
470
|
-
NUM2INT( rbWidth ), NUM2INT( rbHeight ) ) );
|
469
|
+
NUM2INT( rbWidth ), NUM2INT( rbHeight ), 0, rbBorder == Qtrue ) );
|
471
470
|
retVal = Data_Wrap_Struct( rbClass, 0, X11Window::deleteRubyObject,
|
472
471
|
new X11WindowPtr( ptr ) );
|
473
472
|
} catch ( std::exception &e ) {
|
data/ext/x11window.hh
CHANGED
@@ -31,8 +31,8 @@ class X11Window
|
|
31
31
|
{
|
32
32
|
friend class X11Display;
|
33
33
|
public:
|
34
|
-
X11Window(
|
35
|
-
|
34
|
+
X11Window(X11DisplayPtr display, X11PainterPtr painter,
|
35
|
+
int width, int height, Window parent = 0, bool border = true);
|
36
36
|
virtual ~X11Window(void);
|
37
37
|
int width(void) const { return m_width; }
|
38
38
|
int height(void) const { return m_height; }
|
@@ -52,7 +52,7 @@ public:
|
|
52
52
|
static VALUE registerRubyClass( VALUE module );
|
53
53
|
static void deleteRubyObject( void *ptr );
|
54
54
|
static VALUE wrapNew( VALUE rbClass, VALUE rbDisplay, VALUE rbX11Output,
|
55
|
-
VALUE rbWidth, VALUE rbHeight );
|
55
|
+
VALUE rbWidth, VALUE rbHeight, VALUE rbBorder );
|
56
56
|
static VALUE wrapSetTitle( VALUE rbSelf, VALUE rbTitle );
|
57
57
|
static VALUE wrapWidth( VALUE rbSelf );
|
58
58
|
static VALUE wrapHeight( VALUE rbSelf );
|
@@ -69,8 +69,8 @@ protected:
|
|
69
69
|
X11PainterPtr m_painter;
|
70
70
|
int m_width;
|
71
71
|
int m_height;
|
72
|
-
Atom
|
73
|
-
Atom
|
72
|
+
Atom m_wmProtocols;
|
73
|
+
Atom m_wmDeleteWindow;
|
74
74
|
};
|
75
75
|
|
76
76
|
typedef boost::shared_ptr< X11Window > X11WindowPtr;
|
@@ -32,7 +32,8 @@ module Hornetseye
|
|
32
32
|
|
33
33
|
def show( *args, &action )
|
34
34
|
options = args.last.is_a?( Hash ) ? args.pop : {}
|
35
|
-
options = { :title => 'Hornetseye', :
|
35
|
+
options = { :title => 'Hornetseye', :border => true,
|
36
|
+
:output => XImageOutput }.merge options
|
36
37
|
unless action
|
37
38
|
frame, width, height = *args
|
38
39
|
width ||= frame.width
|
@@ -40,7 +41,7 @@ module Hornetseye
|
|
40
41
|
display = options[ :display ] || new
|
41
42
|
output = options[ :output ].new
|
42
43
|
output.write frame
|
43
|
-
window = X11Window.new display, output, width, height
|
44
|
+
window = X11Window.new display, output, width, height, options
|
44
45
|
window.title = options[ :title ]
|
45
46
|
begin
|
46
47
|
window.show
|
@@ -56,7 +57,7 @@ module Hornetseye
|
|
56
57
|
width ||= result.shape[0]
|
57
58
|
height ||= ( width.to_f * result.shape[1] / result.shape[0] ).round
|
58
59
|
output = options[ :output ].new
|
59
|
-
window = X11Window.new display, output, width, height
|
60
|
+
window = X11Window.new display, output, width, height, options
|
60
61
|
window.title = options[ :title ]
|
61
62
|
begin
|
62
63
|
window.show
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# hornetseye-xorg - Graphical output under X.Org
|
2
|
+
# Copyright (C) 2011 Jan Wedekind
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Namespace of Hornetseye computer vision library
|
18
|
+
module Hornetseye
|
19
|
+
|
20
|
+
class X11Window
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
alias_method :orig_new, :new
|
25
|
+
|
26
|
+
def new(display, output, width, height, options = {})
|
27
|
+
options = { :border => true }.merge options
|
28
|
+
orig_new display, output, width, height, options[:border]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
data/lib/hornetseye_xorg_ext.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
|
17
17
|
require 'hornetseye-xorg/x11display'
|
18
|
+
require 'hornetseye-xorg/x11window'
|
18
19
|
require 'hornetseye-xorg/x11output'
|
19
20
|
require 'hornetseye-xorg/ximageoutput'
|
20
21
|
require 'hornetseye-xorg/opengloutput'
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hornetseye-xorg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 6
|
8
|
-
- 0
|
9
|
-
version: 0.6.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.7.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Jan Wedekind
|
@@ -14,8 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
13
|
+
date: 2011-08-09 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: malloc
|
@@ -25,9 +20,6 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - ~>
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 1
|
31
23
|
version: "1.1"
|
32
24
|
type: :runtime
|
33
25
|
version_requirements: *id001
|
@@ -39,9 +31,6 @@ dependencies:
|
|
39
31
|
requirements:
|
40
32
|
- - ~>
|
41
33
|
- !ruby/object:Gem::Version
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
- 23
|
45
34
|
version: "0.23"
|
46
35
|
type: :runtime
|
47
36
|
version_requirements: *id002
|
@@ -53,9 +42,6 @@ dependencies:
|
|
53
42
|
requirements:
|
54
43
|
- - ~>
|
55
44
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
- 11
|
59
45
|
version: "0.11"
|
60
46
|
type: :runtime
|
61
47
|
version_requirements: *id003
|
@@ -67,8 +53,6 @@ dependencies:
|
|
67
53
|
requirements:
|
68
54
|
- - ">="
|
69
55
|
- !ruby/object:Gem::Version
|
70
|
-
segments:
|
71
|
-
- 0
|
72
56
|
version: "0"
|
73
57
|
type: :development
|
74
58
|
version_requirements: *id004
|
@@ -90,6 +74,7 @@ files:
|
|
90
74
|
- lib/hornetseye-xorg/x11output.rb
|
91
75
|
- lib/hornetseye-xorg/opengloutput.rb
|
92
76
|
- lib/hornetseye-xorg/x11display.rb
|
77
|
+
- lib/hornetseye-xorg/x11window.rb
|
93
78
|
- lib/hornetseye-xorg/frame.rb
|
94
79
|
- lib/hornetseye_xorg_ext.rb
|
95
80
|
- ext/x11output.cc
|
@@ -114,7 +99,6 @@ files:
|
|
114
99
|
- ext/x11window.hh
|
115
100
|
- ext/x11display.hh
|
116
101
|
- ext/rubytools.tcc
|
117
|
-
has_rdoc: yard
|
118
102
|
homepage: http://wedesoft.github.com/hornetseye-xorg/
|
119
103
|
licenses: []
|
120
104
|
|
@@ -129,21 +113,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
113
|
requirements:
|
130
114
|
- - ">="
|
131
115
|
- !ruby/object:Gem::Version
|
132
|
-
segments:
|
133
|
-
- 0
|
134
116
|
version: "0"
|
135
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
118
|
none: false
|
137
119
|
requirements:
|
138
120
|
- - ">="
|
139
121
|
- !ruby/object:Gem::Version
|
140
|
-
segments:
|
141
|
-
- 0
|
142
122
|
version: "0"
|
143
123
|
requirements: []
|
144
124
|
|
145
125
|
rubyforge_project: hornetseye
|
146
|
-
rubygems_version: 1.
|
126
|
+
rubygems_version: 1.8.5
|
147
127
|
signing_key:
|
148
128
|
specification_version: 3
|
149
129
|
summary: Graphical output under X.Org
|