Troubles in Commodity-land

A forum for general AmigaOS 4.x support questions that are not platform-specific
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

Re: Troubles in Commodity-land

Post by chris »

xenic wrote:
trixie wrote:
broadblues wrote: A "commodity" that is just a normal app with a popup key is arguably not a true commodity.
Exactly. This is why I added, many months ago, the following note at the beginning of the Commodities Library wiki page:
In the past, some developers turned their programs into commodities only to provide them with a handy keyboard shortcut to bring up/close their GUI. Please note that such practice is actually a misuse of the commodities framework.
I'm not sure I entirely agree with this. The point of commodities is to allow global input handlers and programs that run in the background to be stopped/started even though they have no GUI etc.

A global keyboard shortcut to popup a running - but hidden - application is exactly the sort of thing commodites.library is designed for.

I'd be interested to know how you define a "true commodity", and why a popup shortcut key is a misuse of the framework.

Whether applications even need such a key is another discussion, but I would argue that in most cases, an AppIcon, application docky or entry into the WB tools menu is the correct thing to do, rather than adding a shortcut to everything that the user is not going to be able to remember and probably won't use. I'd suggest that the note on the commodities.library page should read something like:
In the past, some developers turned their programs into commodities only to provide them with a handy keyboard shortcut to bring up/close their GUI. Please note that adding a global shortcut to a regular application is not recommended, and instead it is encouraged to utilise visible user interface elements to hide and re-open a program's GUI.
Maybe something needs to be added to the Style Guide too.
It seems like it's way to late for such a restriction. If you check in your Exchange commodity, you will see many major applications like Odyssey, YAM, MUIBase, Directory Opus etc. Considering the already extensive use of Commodity hotkeys, I'd like a way to find out what hotkeys are already in use and being eaten. I had to do trial-and-error testing to find a working hotkey for my commodity.
This is because MUI registers everything as a commodity irrespective of what it actually is AFAIK. I'd certainly regard this as an abuse of the commodities framework, certainly on OS4 MUI apps should register with application.library instead, unless they actually need commodities.library functionality. I will try and raise a bug report. Whether it'll be fixed is another matter.
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Troubles in Commodity-land

Post by OldFart »

@xenic & trixie (in no particular order)

Please enjoy your bickering outside; I can't stand noses bleeding all over my thread... ;-)

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

Re: Troubles in Commodity-land

Post by chris »

@trixie

Official MUI line: http://muidev.de/ticket/277

It appears that any MUI applications which shouldn't be commodities will need to be taken up with the authors concerned, as apparently that can be disabled. I'm not sure why it's switched on by default (nor why having a global hotkey to iconify an application is useful) but I can't really be bothered to argue about it and the bugtracker won't let me add to or re-open the bug anyway.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Troubles in Commodity-land

Post by xenic »

@all
I've converted the PopShell.c example to OS4 and removed the deprecated argument parsing functions. I wanted to replace all of the amigalib functions but cannot find replacements for the following functions:

HotKey()
InvertString()
FreeIEvents()

Does anyone know of replacements functions or workarounds for the above functions?
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Troubles in Commodity-land

Post by broadblues »

xenic wrote:@all
I've converted the PopShell.c example to OS4 and removed the deprecated argument parsing functions. I wanted to replace all of the amigalib functions but cannot find replacements for the following functions:

HotKey()
InvertString()
FreeIEvents()

Does anyone know of replacements functions or workarounds for the above functions?
Yeah, go look in the clib2 src for the implmentations of them.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Troubles in Commodity-land

Post by broadblues »

For example:

Code: Select all

CxObj *
HotKey(CONST_STRPTR descr,struct MsgPort * port,LONG ID)
{
	CxObj * result = NULL;
	CxObj * filter = NULL;

	assert( descr != NULL && port != NULL );

	if(CxBase == NULL)
		goto out;

	filter = CxFilter(descr);
	if(filter == NULL)
		goto out;

	AttachCxObj(filter,CxSender(port,ID));
	AttachCxObj(filter,CxTranslate(NULL));

	if(CxObjError(filter))
		goto out;

	result = filter;

 out:

	if(result == NULL && filter != NULL)
		DeleteCxObjAll(filter);

	return(result);
}
I'll leave the others as an excercise for the reader....
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: Troubles in Commodity-land

Post by trixie »

@OldFart

Yeah, sorry about that. Let's focus on the meat :-)


@chris
MUI registers everything as a commodity irrespective of what it actually is AFAIK. I'd certainly regard this as an abuse of the commodities framework
Me too (if it's really the case). Could abuse be any more blatant than this? :-)
I'd be interested to know how you define a "true commodity"
But you have defined a "true commodity" yourself in what you're writing. It's a service program that 1) installs a handler in the input stream to catch input events, and 2) can be activated, deactivated and shut down on demand. As such, a commodity is generally supposed to be designed to react to CXM_COMMAND messages appropriately.

One of my other gripes is that "true applications" that install as commodities only to get a popup key shortcut don't bother to handle CXCMD_DISABLE and CXCMD_ENABLE because, quite logically, normal apps like a browser are not supposed to get activated or deactivated. So a commodities control program (and the user) will see the program as a running commodity but the control will look broken (the app is not responding to activation/deactivation commands). This I think can be confusing.

What I've suggested in a post above is a system that "serves" CX events to applications that have "subscribed" to them. This way an application could receive a global hotkey event without actually registering as a commodity. It would make sense to implement such functionality on the application.library level. For example:
  • an app would do something like REGAPP_PopUpKey, "ctrl a" at registration time;
  • the library's subscription server (a commodity created and managed by the library) would register this event ("rawkey ctrl a") for this particular application;
  • when the given hotkey is pressed, the server commodity will send an APPLIBMT_POPUPKEY message via SendApplicationMsg() to the subscribing application.
As I also said, I've already got something like this working on the BOOPSI level but it'd be much better to go with the application.library. If there's interest in such functionality at all.

And of course I see what you mean when you say that the question is whether "normal applications" should be able to toggle their GUIs in response to a global hotkey.
Last edited by trixie on Sat Dec 05, 2015 5:24 pm, edited 1 time in total.
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Troubles in Commodity-land

Post by xenic »

broadblues wrote:Yeah, go look in the clib2 src for the implmentations of them.
Thanks. I forgot that amigalib sources were in clib2.
AmigaOne X1000 with 2GB memory - OS4.1 FE
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Troubles in Commodity-land

Post by xenic »

trixie wrote:As I also said, I've already got something like this working on the BOOPSI level but it'd be much better to go with the application.library. If there's interest in such functionality at all.
Personally, I'd rather see it implemented in Intuition and available in traditional widows (for older ported programs) and window class with the simple addition of a Tag item or arg. However, any improvement would be appreciated.
And of course I see what you mean when you say that the question is whether "normal applications" should be able to toggle their GUIs in reaction to a global hotkey.
Agreed. The proliferation of global hotkeys can make it difficult for a programmer or user to find an unused global hotkey combination that's not already in use. For example, I wanted to use "ctrl alt u" for a commodity I wrote but it doesn't work. I searched through all the commodities on my system partition and was unable to find a commodity that is already using that hotkey. I really think we need a utility that can scan the Commodities filters to display those that are already in use and which application is using them (if that's even possible).

I think your definition of what constitutes a "REAL" commodity is spot on.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: Troubles in Commodity-land

Post by trixie »

@xenix
Personally, I'd rather see it implemented in Intuition and available in traditional widows (for older ported programs) and window class with the simple addition of a Tag item or arg.
That's certainly something we can discuss. I intentionally didn't suggest windows or the window.class because the concept of "application" in AmigaOS is no longer tied to the "window" concept (as it used to be the case before OS4). So I consider it more logical to implement application-level functionality in the application.library. As for "older ported programs": I guess if somebody bothers to go as far as porting or updating them, such programs can surely be adapted to use the library, it's not a lot of work.
I really think we need a utility that can scan the Commodities filters to display those that are already in use and which application is using them (if that's even possible).
It would be possible if the commodities.library provided a public function for retrieving the CX events registered in the individual filters connected to a commodity. Then programs like Exchange could display the registered events together with the respective commodities.
I think your definition of what constitutes a "REAL" commodity is spot on.
Thank you. :-)
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Post Reply