# Advanced rubycocoa: full-screen applications? (Can I access

**URL:** <https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822>\
**Category:** Ruby\
**Created:** [December 9, 2005, 12:01am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822 "2005-12-09T00:01:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [December 9, 2005, 12:01am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/1 "2005-12-09T00:01:08Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [December 9, 2005, 1:31am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/2 "2005-12-09T01:31:01Z")

</div>

Hi folks,

On 12/9/05, Ben G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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](http://homepage3.nifty.com/kimuraw/proj/tmpresents.html) (Japanese  
page)
- [http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.2.tar.gz](http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.2.tar.gz)

thanks,

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [December 9, 2005, 4:37am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/3 "2005-12-09T04:37:45Z")

</div>

On Dec 8, 2005, at 19:30, FUJIMOTO Hisa wrote:

> 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](http://homepage3.nifty.com/kimuraw/proj/tmpresents.html)  
> (Japanese page)
> - [http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.2.tar.gz](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

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [December 9, 2005, 5:54am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/4 "2005-12-09T05:54:55Z")

</div>

On 12/9/05, Ben G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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,

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [December 12, 2005, 5:54pm UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/5 "2005-12-12T17:54:52Z")

</div>

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.tar.gz)  
[http://homepage.mac.com/kimuraw/archive/TMPresents-0.3.3-bin.dmg](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/](http://www.zobs.net/brian/software/)

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [December 9, 2005, 3:48pm UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/6 "2005-12-09T15:48:06Z")

</div>

On Dec 8, 2005, at 23:52, FUJIMOTO Hisa wrote:

> On 12/9/05, Ben G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > 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.

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

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [January 13, 2006, 12:14am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/7 "2006-01-13T00:14:45Z")

</div>

On Jan 10, 2006, at 7:52 PM, Ben G. wrote:

> that used Ruby classes. Once I did that, I was able to go full-  
> /Users/merc/Documents/Development/thingmagic/NRFApp/build/  
> Current time is: Tue Jan 10 03:31:42 2006
> 
> 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.

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [January 13, 2006, 10:54am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/8 "2006-01-13T10:54:18Z")

</div>

> Resources/ruby/osx/objc/oc\_wrapper.rb:17: [BUG] Bus Error  
> 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).

---

<div class="post-metadata">

**Author:** ![bg-rubytalk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/35a633/32.png) [@bg-rubytalk](https://www.ruby-forum.com/u/bg-rubytalk)\
**Post date:** [January 11, 2006, 1:54am UTC](https://www.ruby-forum.com/t/advanced-rubycocoa-full-screen-applications-can-i-access/49822/9 "2006-01-11T01:54:00Z")

</div>

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
