ctrl-q keybinding to quit the application?

Discussion of features in Mozilla Firefox
Post Reply
aarem
Posts: 119
Joined: November 13th, 2002, 9:23 pm

ctrl-q keybinding to quit the application?

Post by aarem »

Does anyone know how to patch the ctrl-q keybinding to quit the application in linux?

Thanks!
User avatar
daihard
Folder@Home
Posts: 16633
Joined: November 17th, 2002, 6:27 pm
Location: Lynnwood, WA
Contact:

Re: ctrl-q keybinding to quit the application?

Post by daihard »

aarem wrote:Does anyone know how to patch the ctrl-q keybinding to quit the application in linux?

Thanks!

I got it to work (at least with Phoenix). Here's what I've done:

1. Locate the file called "browser.jar" in the chrome subdirectory.
2. Unzip it. There's a file called "browser.xul".
3. Open "browser.xul". Locate the line that says:

<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>

4. Change this to look like this:

<key id="key_closeWindow" key="q" command="cmd_closeWindow" modifiers="control"/>

5. Save "browser.xul" and zip the entire directory back to "browser.jar".
6. Make a backup of the original "browser.jar".
7. Copy the new "browser.jar" back in your chrome subdirectory.
8. Restart Phoenix.

This is an amateur hack. I at least tested to make sure that 'ctrl + W' and 'alt + F4' still worked, but nothing beyond that.
aarem
Posts: 119
Joined: November 13th, 2002, 9:23 pm

Re: ctrl-q keybinding to quit the application?

Post by aarem »

daihard wrote:
aarem wrote:Does anyone know how to patch the ctrl-q keybinding to quit the application in linux?

Thanks!

I got it to work (at least with Phoenix). Here's what I've done:

1. Locate the file called "browser.jar" in the chrome subdirectory.
2. Unzip it. There's a file called "browser.xul".
3. Open "browser.xul". Locate the line that says:

<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>

4. Change this to look like this:

<key id="key_closeWindow" key="q" command="cmd_closeWindow" modifiers="control"/>

5. Save "browser.xul" and zip the entire directory back to "browser.jar".
6. Make a backup of the original "browser.jar".
7. Copy the new "browser.jar" back in your chrome subdirectory.
8. Restart Phoenix.

This is an amateur hack. I at least tested to make sure that 'ctrl + W' and 'alt + F4' still worked, but nothing beyond that.


Thank you!! This does work!!! Looks like I can get rid of that File toolbar altogether....:-)

I spoke too soon...yes, as a future poster writes, this does not quit the application, quits the window.....

Best wishes!
Last edited by aarem on November 21st, 2002, 1:26 pm, edited 1 time in total.
nkurz
Posts: 62
Joined: November 12th, 2002, 10:09 pm

Re: ctrl-q keybinding to quit the application?

Post by nkurz »

daihard wrote:4. Change this to look like this:

<key id="key_closeWindow" key="q" command="cmd_closeWindow" modifiers="control"/>



I haven't tried your solution, but it sure looks like it would simply close the window rather than quit the application. But it is hard, because the "cmd_quit" that you want is not defined. So you have to add it, and have it call goQuitApplication().

Here's the guts of my solution, which also includes a confirm. I did mine as an extension overlay, so I'm not sure exactly where the pieces go in browser.xul, but you can probably figure it out. It's still a work in progress, and I'll try to give more information on the overlay once I understand it enough to get it cleaned up.
<pre>
<script type="application/x-javascript">
function goQuitIfConfirmed() {
if (confirm("Close all windows and exit?")) goQuitApplication();
else return true;
}
</script>

<keyset id="mainKeyset">
<key key="q" modifiers="accel" command="cmd_quit" />
</keyset>

<commandset id="mainCommandSet">
<command id="cmd_quit" oncommand="goQuitIfConfirmed();" />
</commandset>
</pre>
User avatar
daihard
Folder@Home
Posts: 16633
Joined: November 17th, 2002, 6:27 pm
Location: Lynnwood, WA
Contact:

Re: ctrl-q keybinding to quit the application?

Post by daihard »

aarem wrote: I spoke too soon...yes, as a future poster writes, this does not quit the application, quits the window.....
Best wishes!

Maybe you or someone else can explain this to me. Once I hit "ctrl + Q" to close Phoenix, I don't see any process running as "phoenix" anymore. What, then, differentiates this and "quit application"?

Thanks,
Dai
User avatar
laszlo
Posts: 5225
Joined: November 4th, 2002, 6:13 pm
Location: .de
Contact:

Re: ctrl-q keybinding to quit the application?

Post by laszlo »

daihard wrote:
aarem wrote: I spoke too soon...yes, as a future poster writes, this does not quit the application, quits the window.....
Best wishes!

Maybe you or someone else can explain this to me. Once I hit "ctrl + Q" to close Phoenix, I don't see any process running as "phoenix" anymore. What, then, differentiates this and "quit application"?

Thanks,
Dai

Try both with more than one window open :wink: The difference is that one closes all windows and exits Phoenix, while the other just closes the active window (and if it happens to be the only one open it also exits).
User avatar
daihard
Folder@Home
Posts: 16633
Joined: November 17th, 2002, 6:27 pm
Location: Lynnwood, WA
Contact:

Re: ctrl-q keybinding to quit the application?

Post by daihard »

laszlo wrote:Try both with more than one window open :wink: The difference is that one closes all windows and exits Phoenix, while the other just closes the active window (and if it happens to be the only one open it also exits).

My new 'ctrl + Q' quits Phoenix whether or not it has more than one tab open; i.e. it behaves exactly like 'alt + F4'. My 'ctrl + W', on the other hand, closes the active tab (and exits if that's the only tab). I guess you're not using the tabbed browsing feature, are you? But again, 'alt + F4' only closes the active window, too, when there are multiple windows open...
aarem
Posts: 119
Joined: November 13th, 2002, 9:23 pm

Re: ctrl-q keybinding to quit the application?

Post by aarem »

daihard wrote:
laszlo wrote:Try both with more than one window open :wink: The difference is that one closes all windows and exits Phoenix, while the other just closes the active window (and if it happens to be the only one open it also exits).

My new 'ctrl + Q' quits Phoenix whether or not it has more than one tab open; i.e. it behaves exactly like 'alt + F4'. My 'ctrl + W', on the other hand, closes the active tab (and exits if that's the only tab). I guess you're not using the tabbed browsing feature, are you? But again, 'alt + F4' only closes the active window, too, when there are multiple windows open...


Yes, you are right -- the question is how one makes the ctrl+q work to exit the application completely (getting out of multiple windows, etc) as used to happen previously.

Thanks!
User avatar
laszlo
Posts: 5225
Joined: November 4th, 2002, 6:13 pm
Location: .de
Contact:

Post by laszlo »

I wasn't talking about multiple tabs, I was talking about multiple windows. A little research in http://lxr.mozilla.org/mozilla brought up three commands and according JS functions, all dealing with closing and all having a representation as a command attribute or an oncommand handler in the "File" menu:
  1. cmd_close, assigned to BrowserCloseTabOrWindow(), which calls BrowserCloseWindow() if only one tab is opened,
  2. cmd_closeWindow, assigned to BrowserCloseWindow(), which at the end does a window.close, thereby exiting the process if only one window is opened,
  3. cmd_quit, defined here, here and here for three different platforms, assigned to goQuitApplication(), which closes all open windows and exits.

Choose one :wink:
nkurz
Posts: 62
Joined: November 12th, 2002, 10:09 pm

Post by nkurz »

laszlo wrote:cmd_quit, defined here, here and here for three different platforms, assigned to goQuitApplication(), which closes all open windows and exits.
Choose one :wink:


Yes, but as best I can tell, "cmd_quit" is not accessible from within "browser.xul". It is defined for Communicator according to the templates you found, but these templates are not used by Phoenix. I think. At least that is what I concluded when keys assigned to "cmd_quit" didn't work. So if you want to assign a key to "cmd_quit", you are going to have to define "cmd_quit" yourself, hence adding to keyset id="mainKeyset":
<pre>
<keyset id="mainKeyset">
<key key="q" modifiers="accel" command="cmd_quit" />
</keyset>
</pre>

I'm sorry I'm explaining this badly. And I should note that hand editing browser.xul is really not the right way to go about making these changes, but I don't understand Phoenix well enough to describe the alternatives. Maybe someone who understands it better could chime in with an explanation of where the appropriate overlay could be placed?
User avatar
laszlo
Posts: 5225
Joined: November 4th, 2002, 6:13 pm
Location: .de
Contact:

Post by laszlo »

nkurz wrote:Yes, but as best I can tell, "cmd_quit" is not accessible from within "browser.xul". It is defined for Communicator according to the templates you found, but these templates are not used by Phoenix. I think. At least that is what I concluded when keys assigned to "cmd_quit" didn't work. So if you want to assign a key to "cmd_quit", you are going to have to define "cmd_quit" yourself, hence adding to keyset id="mainKeyset":

[...]

I think it's not essential to define a command "cmd_quit". The following works for me, using goQuitApplication() with an oncommand handler:

<key key="q" modifiers="accel" oncommand="goQuitApplication();"/>
User avatar
daihard
Folder@Home
Posts: 16633
Joined: November 17th, 2002, 6:27 pm
Location: Lynnwood, WA
Contact:

Post by daihard »

laszlo wrote:I think it's not essential to define a command "cmd_quit". The following works for me, using goQuitApplication() with an oncommand handler:

<key key="q" modifiers="accel" oncommand="goQuitApplication();"/>

This is _the_ solution, isn't it? I added this to my browser.xul. Worked like a charm. Thanks for sharing this great piece of information!

Dai
aarem
Posts: 119
Joined: November 13th, 2002, 9:23 pm

Post by aarem »

daihard wrote:
laszlo wrote:I think it's not essential to define a command "cmd_quit". The following works for me, using goQuitApplication() with an oncommand handler:

<key key="q" modifiers="accel" oncommand="goQuitApplication();"/>

This is _the_ solution, isn't it? I added this to my browser.xul. Worked like a charm. Thanks for sharing this great piece of information!

Dai


Yep!! Does work!! Thanks, so much, everybuddy!!!
:)
nkurz
Posts: 62
Joined: November 12th, 2002, 10:09 pm

Using "oncommand" vs "command" in <ke

Post by nkurz »

laszlo wrote:I think it's not essential to define a command "cmd_quit". The following works for me, using goQuitApplication() with an oncommand handler:

<key key="q" modifiers="accel" oncommand="goQuitApplication();"/>



Yes, that would be fine as well. For some reason I was presuming one needed the intermediary of "cmd_quit". But now that I think about it more (still not understanding the internals well) I agree it is not needed. Going straight to "oncommand' seems fine.

But then why do most (but not all) of the <key> tags in browser.xul use the "command" attribute as a layer of indirection instead of "oncommand"? I guess this allows it to go through a central command handler, but why? Perhaps because the backend of the command is in C++ and it avoids a Javascript call? Any roving experts who can explain this?
Post Reply