OSX Xboard 4.7.2 .app

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

It doesn't open up a terminal that way.

But clicking on the executable inside the app directly does.
So I opened xboard first that way, then tried to load a png file by clicking on it.
This created the second xboard window with it loaded, but then the first window hung.

The terminal read what you would expect

Code: Select all

Joshuas-MacBook-Pro:~ herecomethej$ /Applications/Xboard/Xboard.app/Contents/MacOS/Xboard ; exit;
Xboard
/Applications/Xboard/Xboard.app/Contents/MacOS
Open new XBoard
New XBoard, path = '/Applications/Xboard/herecomethej-Sjeng_11.2.pgn'
xboard
/Applications/Xboard/Xboard.app/Contents/MacOS
Dec 19 16&#58;57&#58;28 Joshuas-MacBook-Pro.local xboard-bin&#91;35102&#93; <Error>&#58; The function `CGContextErase' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.
Dec 19 16&#58;57&#58;59 Joshuas-MacBook-Pro.local Xboard-bin&#91;35091&#93; <Error>&#58; The function `CGContextErase' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.
logout
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

Well, that is sort of what we want, except that the first instance should not hang. Perhaps the two instances are not independent, as far as OS X is concerned. After reading the link you posted, I think perhaps we should use this "open -n -a" prefix. Perhaps the snprintf in StartNewXBoard() should be changed to:

Code: Select all

snprintf&#40;buf, MSG_SIZ, "open -n -a \"xboard %s\"", path&#41;;
(Looks a bit messy, because you cannot have " inside a string without prefixing it with \ to indicate it is not the terminating quote.)
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

But both instances read from the same xboard conf file. Couldn't that be messy?
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

Yes, it can. But that also holds for Windows and Linux. When you save settings on exit, the last exit overwrites all previous saves. But I never saw anything wrong with that. The only alternative I see is that they would always have the same settings. Which is exactly what you don't want; you might want to do completely different things with them. If I switch the TC in one to 40 min, I don't want my blitz game running in the other switch to 40 min as well. If I switch one to Xiangqi board and pieces, I don't want the Chess game in the other instance to switch to that. etc. But Apple thinks it is a great thing if it would, and calls it a problem if it doesn't...
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

aw dang, with the open command, it doesn't know where xboard is

Code: Select all

Xboard
/Applications/Xboard/Xboard.app/Contents/MacOS
Open new XBoard
New XBoard, path = '/Applications/Xboard/Josh-Crafty-23.5.pgn'
Unable to find application named 'xboard /Applications/Xboard/Josh-Crafty-23.5.pgn'
We will have to use that find bundle code you said earlier.
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

Well, my bed time is approaching. I still have no idea how it would be possible that OS X starts two XBoard instances when no XBoard was running and you click a PGN file. Perhaps it starts XBoard as just "xboard" without any arguments, and then sends it the file to open as an OpenFile signal. The current code would then not suppress the OpenFile signal. You could make it do that by setting suppress in main() as:

Code: Select all

suppress = &#40;argc == 1 || argc > 1 && argv&#91;1&#93;&#91;00&#93; != '-');
This could never distinguish the case where you really would have started xboard by hand without arguments in order to run Fairy-Max, and much later clicked a PGN file that caused an OpenFile signal. That would then be falsely ignored. But perhaps that is not a disaster; nothing would happen, and you could click it again, and then a new instance would start.

I am not usre about the syntax of this "open -n" thing when the application would need arguments. I assumed thew would be within the quotes. But perhaps they have to be separate arguments to "open". In that case the format string in snprintf would have to be

Code: Select all

"open -n -a \"xboard\" %s"
Another worry is what would happen if you first started "xboard -fcp crafty" from a terminal, and then start "xboard -fcp fruit -fUCI" from another terminal. If OS X would now try to become clever, and refuse to start a second instance, but in stead send an OpenFile signal to the XBoard instance running Crafty, I really wonder what it would send as "path". Would we just get "-fcp" and forget about the rest of the command line? Would it realize that "-fcp" isn't a filename, and send nothing at all? Would it send all the remaining arguments as one string? Would it send an OpenFile signal for each argument?
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

JoshPettus wrote:aw dang, with the open command, it doesn't know where xboard is

Code: Select all

Xboard
/Applications/Xboard/Xboard.app/Contents/MacOS
Open new XBoard
New XBoard, path = '/Applications/Xboard/Josh-Crafty-23.5.pgn'
Unable to find application named 'xboard /Applications/Xboard/Josh-Crafty-23.5.pgn'
We will have to use that find bundle code you said earlier.
No, I think the problem might be that it considers the PGN filename as part of the application name (one name with a space in it). Try to move the %s in the format string outside the (escaped) double quotes in the string, as I suggested in the previous post.
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: OSX Xboard 4.7.2 .app

Post by hgm »

I Googled for the manual page of OS X' "open" command, and I can definitely confirm that the %s must NOT be in the quotes around XBoard.

An idea: since you seem to be using a launch script, would the whole problem not disappear if in that script you would launch xboard-bin with the aid of the "open -n" command? Then perhaps none of this signal business would have been needed at all, because clicking the icon would invoke the script, and automatically bump into the "open -n" before it started xboard-bin.

[Edit] OK, this was my last post for today. Good night!
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

It's a good thought, but I seem to be having an issue. It opens another instance but doesn't load the pgn file. I fear you may not be able to use open to pass arguments. Unless there is another syntax you'd like to try. I looked at the documentation but they didn't say anything about arguments.

I just opened the terminal and tried
'open -a xboard -ncp' yields a syntax error for improper use of the command. It thinks the argument is for open :\

and 'open -a 'xboard -ncp'' of-course yields unknown application as we established earlier
-------

I just had a thought of my own, don't know why I didn't think of it before. I actually include a bunch of bash scripts labeled .command with xboard.app, mostly for loading xboard in with an ICS. If someone were to click on that it it would open Xboard in a Terminal window. You can actually click on it as many times as you like and it would just open another terminal window and another instance of xboard. (Terminal.app window not another instance of Terminal.app) I should just make a PGN viewer one. Unfortunately it's difficult to automate this in xboard itself as you can't pass Terminal.app arguments... Apparently they never imagined someone would want to do that... Well you could with apple script but I don't think we want to go there.

I would still like to be able to open xboard by clicking on a pgn file and have it open it. Just as a small convenience. You can't point a file to, or drag and drop on one of these bash scripts: only apps. If they want more functionality, they can always open the PGN viewer.command file. Even the load game menu is greyed out when the board is busy so it's at least understandable to the user. I say we just blame it all on apple because, hey, it's their fault. :)

Ideally for a mac app (and to save on clutter with a bunch of bash scripts) , if you Arun ever feel up to a heck of a lot of work and a passion for Mac users ;), xboard would need to change modes without restarting. Then we can just open extra windows, switch from engine mode to pgn viewing, switch to ICS mode with it's own configuration menu, the whole nine yards. But you said that would take some fundamental restructuring of xboard, so no worries. We already have some workarounds.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: OSX Xboard 4.7.2 .app

Post by JoshPettus »

shame... exec command will let arguments through, but you can't have more then one instance with it.