Advanced rubycocoa: full-screen applications? (Can I access CoreGraphics calls?)

B

Ben Giddings

Hi guys,

I'm really pushing the RubyCocoa boundaries for a demo I'm trying to
build.

I want to display a QuartzComposer application full-screen (i.e. no
menu bar, no dock, etc.) and then control it by Ruby.

So far, I can get a windowed QuartzComposer application working, but
I don't know how to make it go full-screen.

I found instructions on how to make full-screen OSX applications, but
I can't figure out how to call the required methods / use the right
variables from within Ruby.

Here's the article on how to make a full-screen app from Cocoa:

http://www.cocoadevcentral.com/articles/000028.php

But when I do the bit that tries to call CGDisplayCapture:

if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the main display!" );
// Note: you'll probably want to display a proper error
dialog here
}

I can't figure out how to call those methods or use the
kCGDirectMainDisplay method from within Ruby.

I've loaded the ApplicationServices framework, which should give me
access to the CoreGraphics calls, but... I don't know how to get to
them.

Any ideas?

Ben
 
F

FUJIMOTO Hisa

Hi folks,

I want to display a QuartzComposer application full-screen (i.e. no
menu bar, no dock, etc.) and then control it by Ruby.

So far, I can get a windowed QuartzComposer application working, but
I don't know how to make it go full-screen. (snip)
Any ideas?

I'm not bright about QuartsComposer and CoreGraphics, but source code
of TMPresents.app may be helpful for you. This is a Takahashi-method
fullscreen presentation application written with RubyCocoa.

* http://homepage3.nifty.com/kimuraw/proj/tmpresents.html (Japanese page)
* http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.2.tar.gz

thanks,
 
B

Ben Giddings

I'm not bright about QuartsComposer and CoreGraphics, but source code
of TMPresents.app may be helpful for you. This is a Takahashi-method
fullscreen presentation application written with RubyCocoa.

* http://homepage3.nifty.com/kimuraw/proj/tmpresents.html
(Japanese page)
* http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.2.tar.gz

Thanks Hisa,

That's a lot of helpful code. Unfortunately, I don't know what kinds
of documents it opens so I can't try it out, but the source code
looks like has a lot of very useful methods, and since they're named
in English, I think I'll be able to figure it out.

Thanks a lot!

Ben
 
F

FUJIMOTO Hisa

That's a lot of helpful code. Unfortunately, I don't know what kinds
of documents it opens so I can't try it out, but the source code

Document format of the app is simply plain text. Each page
is separated by a null line. e.g.

--- cut here ---
Page 1

Page 2 - Line 1
Page 2 - Line 3

Page 3
--- cut here ---

cheers,
 
B

Ben Giddings

Document format of the app is simply plain text. Each page
is separated by a null line. e.g.

Hmm, I tried saving that text to a .txt file, but TMPresents wouldn't
give me the option to open that file. Everything except directories
is "greyed out" and I can't select them.

Is there a specific filename or mime type or something that the
dialog is looking for? It can't just be presentation.txt can it?

Ben
 
K

kimura wataru

Hi,

I fixed this problem and published new version.

http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.3.tar.gz
http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.3-bin.dmg

I implemented fullscreen with NSWindow, the application can be deactive.

I think ruby can handle CoreGraphics API via DL::Symbol (extension
library "dl"), not RubyCocoa. An other way is to use Cocoa wrapper for
CoreGraphics, like DisplayKit.

require 'osx/cocoa'
bundle = OSX::NSBundle.bundleWithPath('/Library/Frameworks/DisplayKit.framework')
bundle.load
OSX.ns_import :DKDisplay # => class OSX::DKDisplay is available

DisplayKit: http://www.zobs.net/brian/software/
 
B

Ben Giddings

Hi Fujimoto-san and Kimura-san,

Thanks to your help, I was able to get my application to go full-
screen with no menubar or dock visible.

I think the problem I was having was that I was trying to write a
Ruby program that used Cocoa libraries. I was using all the right
calls, but I couldn't get rid of the menubar or dock. I used
TMPresents as an example, and changed how I was doing things.
Instead of a Ruby application, I made it an objective C application
that used Ruby classes. Once I did that, I was able to go full-screen.

However, I'm having another problem. My application is crashing, and
the error is somewhere in the Ruby libraries, not directly in my
code. Here's the program output:

2006-01-10 03:31:04.506 NRFApp[918] NRFView(0x60dba0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:04.531 NRFApp[918] QCView(0x60e870) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Bus Error
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]


NRFApp has exited due to signal 6 (SIGABRT).

Another run went like this:

[Session started at 2006-01-10 03:31:42 -0500.]
Current time is: Tue Jan 10 03:31:42 2006

2006-01-10 03:31:42.993 NRFApp[932] NRFView(0x60daf0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:43.063 NRFApp[932] QCView(0x60e7c0) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Segmentation fault
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]


I've tried to debug the program using the XCode debugger (GDB
underneath) but I only get assembly output. I guess the problem is
that something, either Ruby or the RubyCocoa libs were built without
debugging symbols, or stripped. Unfortunately, I can't seem to
rebuild these properly to get debugging symbols, so I'm unable to
debug what's happening.

Can anybody help me understand how to debug and fix this problem? If
I can't get it working with RubyCocoa soon, I might have to give up
and write it in Objective-C (and I don't know Objective C!

Thanks,

Ben
 
L

Logan Capaldo

Hi Fujimoto-san and Kimura-san,

Thanks to your help, I was able to get my application to go full-
screen with no menubar or dock visible.

I think the problem I was having was that I was trying to write a
Ruby program that used Cocoa libraries. I was using all the right
calls, but I couldn't get rid of the menubar or dock. I used
TMPresents as an example, and changed how I was doing things.
Instead of a Ruby application, I made it an objective C application
that used Ruby classes. Once I did that, I was able to go full-
screen.

However, I'm having another problem. My application is crashing,
and the error is somewhere in the Ruby libraries, not directly in
my code. Here's the program output:

2006-01-10 03:31:04.506 NRFApp[918] NRFView(0x60dba0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:04.531 NRFApp[918] QCView(0x60e870) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/
Development/NRFApp.app/Contents/Frameworks/RubyCocoa.framework/
Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Bus Error
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]


NRFApp has exited due to signal 6 (SIGABRT).

Another run went like this:

[Session started at 2006-01-10 03:31:42 -0500.]
Current time is: Tue Jan 10 03:31:42 2006

2006-01-10 03:31:42.993 NRFApp[932] NRFView(0x60daf0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:43.063 NRFApp[932] QCView(0x60e7c0) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/
Development/NRFApp.app/Contents/Frameworks/RubyCocoa.framework/
Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG]
Segmentation fault
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]


I've tried to debug the program using the XCode debugger (GDB
underneath) but I only get assembly output. I guess the problem is
that something, either Ruby or the RubyCocoa libs were built
without debugging symbols, or stripped. Unfortunately, I can't
seem to rebuild these properly to get debugging symbols, so I'm
unable to debug what's happening.

Can anybody help me understand how to debug and fix this problem?
If I can't get it working with RubyCocoa soon, I might have to give
up and write it in Objective-C (and I don't know Objective C!

Thanks,

Ben

I've had a very similar sounding problem in a pure Objective-C app.
Basically what happened was I didn't #retain something I should have
#retain'ed. I'll note that at first I thought it was in the
libraries too, and had similar issues to what you had attempting to
debug it. I don't know how you'd go about doing that from RubyCocoa--
theoretically you shouldn't have that problem in the first place.
 
D

Dave Howell

However, I'm having another problem. My application is crashing, and
the error is somewhere in the Ruby libraries, not directly in my code.
Here's the program output:

2006-01-10 03:31:04.506 NRFApp[918] NRFView(0x60dba0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:04.531 NRFApp[918] QCView(0x60e870) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Bus Error
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]


NRFApp has exited due to signal 6 (SIGABRT).

Another run went like this:

[Session started at 2006-01-10 03:31:42 -0500.]
Current time is: Tue Jan 10 03:31:42 2006

2006-01-10 03:31:42.993 NRFApp[932] NRFView(0x60daf0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:43.063 NRFApp[932] QCView(0x60e7c0) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Segmentation fault
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]

Aha! Hopefully you will soon have a more complete answer, but I guess
you missed my recent query which featured exactly the same "NSView"
error message.

Or to be more precise, the warning. "Did you forget to call super?" is
a red herring, a spurious message that you should ignore. My views, as
it turned out, were being created exactly as they should have been.

The incredibly exasperating Segmentation Fault is another matter, of
course. I had to put one Ruby XCode project aside entirely because I
couldn't get that to go away. However, at first, many of those were to
some degree my fault. I had some bugs in my code where I was calling
something without initializing it properly, or, well, I don't remember
what, but it was actually a mistake that I had made, which
Ruby/RubyCocoa/Cocoa was handling with extremely poor grace.

Until/unless somebody more knowledgeable than me chimes in, I suggest
you see if you can find some particular part of your code that seems to
trigger the segmentation fault, and make sure it's doing what it's
supposed to. If that doesn't help, consider upgrading your Ruby (and
especially your RubyCocoa if you're not running the latest version).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

RubyCocoa question 2
[ANN] RubyCocoa 0.11.1 0
[ANN] RubyCocoa 0.13.2 0
RubyCocoa LoadError 0
[ANN] RubyCocoa 0.11.0 3
[ANN] RubyCocoa 0.13.0 0
[ANN] RubyCocoa 0.10.1 Developer Preview 0
[ANN] RubyCocoa 0.12.0 2

Members online

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top