1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-02-17 07:40:11 -05:00

MML/Core: Clean up os_linux.

This commit is contained in:
Merlijn Wajer 2011-07-30 11:32:58 +02:00
parent da0de6e4b9
commit 880072d723

View File

@ -23,6 +23,12 @@
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
unit os_linux; unit os_linux;
{
TODO's:
- Allow selecting a different X display
- Fix keyboard layout / SendString
}
interface interface
uses uses
@ -126,7 +132,7 @@ implementation
{ {
This is extremely hacky, but also very useful. This is extremely hacky, but also very useful.
We have to install a X error handler, because otherwise X We have to install a X error handler, because otherwise X
will terminate out entire app on error. will terminate our entire app on error.
Since we want the right thread to recieve the right error, we have to Since we want the right thread to recieve the right error, we have to
fiddle a bit with threadvars, mutexes / semaphores. fiddle a bit with threadvars, mutexes / semaphores.
@ -413,40 +419,41 @@ implementation
result := xmask and ButtonP > 0; result := xmask and ButtonP > 0;
end; end;
procedure TWindow.SendString(str: string); { TODO: Check if this supports multiple keyboard layouts, probably not }
var procedure TWindow.SendString(str: string);
I, L: Integer; var
K: Byte; I, L: Integer;
HoldShift: Boolean; K: Byte;
begin HoldShift: Boolean;
HoldShift := False;
L := Length(str);
for I := 1 to L do
begin begin
if (((str[I] >= 'A') and (str[I] <= 'Z')) or HoldShift := False;
((str[I] >= '!') and (str[I] <= '&')) or L := Length(str);
((str[I] >= '(') and (str[I] <= '+')) or for I := 1 to L do
(str[I] = ':') or
((str[I] >= '<') and (str[I] <= '@')) or
((str[I] >= '^') and (str[I] <= '_')) or
((str[I] >= '{') and (str[I] <= '~'))) then
begin begin
HoldKey(VK_SHIFT); if (((str[I] >= 'A') and (str[I] <= 'Z')) or
HoldShift := True; ((str[I] >= '!') and (str[I] <= '&')) or
end; ((str[I] >= '(') and (str[I] <= '+')) or
(str[I] = ':') or
((str[I] >= '<') and (str[I] <= '@')) or
((str[I] >= '^') and (str[I] <= '_')) or
((str[I] >= '{') and (str[I] <= '~'))) then
begin
HoldKey(VK_SHIFT);
HoldShift := True;
end;
K := GetKeyCode(str[I]); K := GetKeyCode(str[I]);
HoldKey(K); HoldKey(K);
Sleep(20); Sleep(20);
ReleaseKey(K); ReleaseKey(K);
if (HoldShift) then if (HoldShift) then
begin begin
HoldShift := False; HoldShift := False;
ReleaseKey(VK_SHIFT); ReleaseKey(VK_SHIFT);
end;
end; end;
end; end;
end;
procedure TWindow.HoldKey(key: integer); procedure TWindow.HoldKey(key: integer);
begin begin