Recent

Author Topic: How to disable Alt + Tab on Linux  (Read 4871 times)

Stefano

  • New Member
  • *
  • Posts: 39
How to disable Alt + Tab on Linux
« on: March 24, 2013, 07:11:46 pm »
Hello,

I would like to disable in a program written with Lazarus the Alt+Tab Key, in order that the user can't move between the windows of my program with Alt+Tab, but only with the windows menu of my program.

This is due to a bug of the DBGrid, that force me to use still Lazarus 0.9.28.2 on Linux, that is quite old:
http://bugs.freepascal.org/view.php?id=22475

The bug is very serious, if the user moves with Alt+Tab from a windows to another, the grid is no more ok and isn't possibile to insert/modify data. So it isn't possibile to give a program with this bug to a user.

I'd like, in the time that the bug will be resolved, to find a way to bypass the problem. I've worked a lot on the events deactivate and activate, but without success.

At this point then only solution that I could try colud be to avoid that the user can use Alt+Tab (of course only in the program written with Lazarus).

Is there a way to disable Alt+Tab (or another combination of keys, on Linux the user can personalize what key to use to move from windows) on Linux?

I've tried using the KeyDown event:

Code: [Select]
  if (Key = 9{KeyTab}) and (ssAlt in Shift) then begin
    Key := 0;
    exit;
  end;

This code gives no errors, but doesn't work, while the OS deplace already the window before Lazarus reise the KeyDown event.

Besides, the user might be set another combinations of Keys at the places of Alt+Tab (that I should know).

Is there a similar way also for Windows? (in any case the most important thing is on Linux).

Thank you very much for any help.

Sorry for my bad English.

Best regards,

Stefano
Stefano Cortelli
Studio Rag. Cortelli
(Preferred languages: Italiano / Deutsch / Français)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to disable Alt + Tab on Linux
« Reply #1 on: March 24, 2013, 11:23:18 pm »
I would like to disable in a program written with Lazarus the Alt+Tab Key, in order that the user can't move between the windows of my program with Alt+Tab, but only with the windows menu of my program.
Certain key combinations are always intercepted by the OS or OS window manager even if your form's KeyPreview property is set to True.
The only way to get around this, so that the LCL gets a first look at such key presses is to program a low-level keyboard hook that interacts with the OS kernel or window manager. Obviously this sort of code is very platform-dependent, and open to breakage with newer OS updates or changes in the window manager. I don't think there's any simple and reliable cross-platform way to take full control of system key events. A fairly recent example was seen in the default settings for an Ubuntu UI update which gave Lazarus IDE users lots of grief until a usable workaround was implemented.

 

TinyPortal © 2005-2018