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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
46ec10622045f5671a1067865566f13c?d=identicon&s=25 bg-rubytalk (Guest)
on 2005-12-09 00:01
(Received via mailing list)
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
7e7f3de0f38d9973971e5759d5e4f5d8?d=identicon&s=25 hisa (Guest)
on 2005-12-09 01:31
(Received via mailing list)
Hi folks,

On 12/9/05, Ben Giddings <bg-rubytalk@infofiend.com> 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 (Japanese
page)
  * http://homepage.mac.com/kimuraw/archive/TMPresents...

thanks,
46ec10622045f5671a1067865566f13c?d=identicon&s=25 bg-rubytalk (Guest)
on 2005-12-09 04:37
(Received via mailing list)
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
> (Japanese page)
>   * http://homepage.mac.com/kimuraw/archive/TMPresents...

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
7e7f3de0f38d9973971e5759d5e4f5d8?d=identicon&s=25 hisa (Guest)
on 2005-12-09 05:54
(Received via mailing list)
On 12/9/05, Ben Giddings <bg-rubytalk@infofiend.com> 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,
46ec10622045f5671a1067865566f13c?d=identicon&s=25 bg-rubytalk (Guest)
on 2005-12-09 15:48
(Received via mailing list)
On Dec 8, 2005, at 23:52, FUJIMOTO Hisa wrote:
> On 12/9/05, Ben Giddings <bg-rubytalk@infofiend.com> 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
E298234a6e5a2c159287476abd76504a?d=identicon&s=25 kimura wataru (Guest)
on 2005-12-12 17:54
(Received via mailing list)
Hi,

I fixed this problem and published new version.

http://homepage.mac.com/kimuraw/archive/TMPresents...
http://homepage.mac.com/kimuraw/archive/TMPresents...

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/
46ec10622045f5671a1067865566f13c?d=identicon&s=25 Ben Giddings (Guest)
on 2006-01-11 01:54
(Received via mailing list)
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
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-01-13 00:14
(Received via mailing list)
On Jan 10, 2006, at 7:52 PM, Ben Giddings 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.
12271b6df73fe29930d65586be5a4a70?d=identicon&s=25 Dave Howell (Guest)
on 2006-01-13 10:54
(Received via mailing list)
> 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).
This topic is locked and can not be replied to.