mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 10:39:09 +02:00
Merge branch 'gtk1-fix-startup-warnings' into 'main'
LCL-GTK1: Fix various startup warnings and Gtk1 assertions See merge request freepascal.org/lazarus/lazarus!255
This commit is contained in:
commit
686e828103
@ -37,9 +37,12 @@ begin
|
|||||||
Exit; // the GTKAPIWidget is self drawn, so no use to change the widget style.
|
Exit; // the GTKAPIWidget is self drawn, so no use to change the widget style.
|
||||||
|
|
||||||
if (GTK_WIDGET_REALIZED(AWidget)) then
|
if (GTK_WIDGET_REALIZED(AWidget)) then
|
||||||
WindowStyle := gtk_style_copy(gtk_widget_get_style(AWidget))
|
WindowStyle := gtk_widget_get_style(AWidget)
|
||||||
else
|
else
|
||||||
WindowStyle := gtk_style_copy(gtk_rc_get_style(AWidget));
|
WindowStyle := gtk_rc_get_style(AWidget);
|
||||||
|
|
||||||
|
if WindowStyle <> nil then
|
||||||
|
WindowStyle := gtk_style_copy(WindowStyle);
|
||||||
|
|
||||||
if (Windowstyle = nil) then
|
if (Windowstyle = nil) then
|
||||||
Windowstyle := gtk_style_new;
|
Windowstyle := gtk_style_new;
|
||||||
|
@ -33,8 +33,22 @@
|
|||||||
|
|
||||||
{off $Define Disable_GC_SysColors}
|
{off $Define Disable_GC_SysColors}
|
||||||
|
|
||||||
|
{$define HideKeyTableWarnings}
|
||||||
|
|
||||||
{$define RawimageConsistencyChecks}
|
{$define RawimageConsistencyChecks}
|
||||||
|
|
||||||
|
(*
|
||||||
|
Gtk1 uses a GTK_MODULES environment variable that causes it to load modules
|
||||||
|
at startup, however this variable is also used by Gtk2 and Gtk3, meaning
|
||||||
|
that if a referenced module is not part of the available Gtk1 modules the
|
||||||
|
program will display a warning at startup time. Since as of 2023 pretty much
|
||||||
|
no distribution comes with Gtk1 this is always a bogus warning and to avoid
|
||||||
|
this, the GTK_MODULES environment variable will be cleaned during startup and
|
||||||
|
reset after the toolkit has been initialized to allow for Gtk2 and later child
|
||||||
|
processes.
|
||||||
|
*)
|
||||||
|
{$define ClearGtkModulesEnvVar}
|
||||||
|
|
||||||
(*
|
(*
|
||||||
keep track of keystates instead of using OS
|
keep track of keystates instead of using OS
|
||||||
This is the old mode and might be removed
|
This is the old mode and might be removed
|
||||||
|
@ -3193,7 +3193,7 @@ var
|
|||||||
XKeyEvent: TXKeyEvent;
|
XKeyEvent: TXKeyEvent;
|
||||||
KeySymStart, KeySymNext: PKeySym;
|
KeySymStart, KeySymNext: PKeySym;
|
||||||
UpKeySym, LoKeySym: TKeySym;
|
UpKeySym, LoKeySym: TKeySym;
|
||||||
KeySyms: array of TKeySym;
|
KeySyms: array of TKeySym = nil;
|
||||||
{$else}
|
{$else}
|
||||||
KeySyms: array of guint;
|
KeySyms: array of guint;
|
||||||
KeyVals: Pguint;
|
KeyVals: Pguint;
|
||||||
@ -3214,7 +3214,7 @@ var
|
|||||||
|
|
||||||
KeyCode: Byte;
|
KeyCode: Byte;
|
||||||
m: Integer;
|
m: Integer;
|
||||||
LoKey, HiKey: Integer;
|
LoKey, HiKey, I: Integer;
|
||||||
|
|
||||||
VKey, FreeVK: Byte;
|
VKey, FreeVK: Byte;
|
||||||
HasMultiVK, DummyBool, Extended, SecondKey, HasKey, ComputeVK: Boolean;
|
HasMultiVK, DummyBool, Extended, SecondKey, HasKey, ComputeVK: Boolean;
|
||||||
@ -3258,8 +3258,14 @@ begin
|
|||||||
then XFree(KeySymStart);
|
then XFree(KeySymStart);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
if KeySymCount > Length(MVKeyInfo[0].KeySym)
|
// The code in Accelerate below assumes at least 2 items in the KeySym array
|
||||||
then DebugLn('[WARNING] keysymcount=%u larger than expected=%u', [KeySymCount, Length(MVKeyInfo[0].KeySym)]);
|
if KeySymCount > 2 then begin
|
||||||
|
for I:=Low(MVKeyInfo) to High(MVKeyInfo) do
|
||||||
|
SetLength(MVKeyInfo[I].KeySym, KeySymCount);
|
||||||
|
end else begin
|
||||||
|
for I:=Low(MVKeyInfo) to High(MVKeyInfo) do
|
||||||
|
SetLength(MVKeyInfo[I].KeySym, 2);
|
||||||
|
end;
|
||||||
SetLength(KeySyms, KeySymCount);
|
SetLength(KeySyms, KeySymCount);
|
||||||
{$else gtk1}
|
{$else gtk1}
|
||||||
LoKey := 0;
|
LoKey := 0;
|
||||||
|
@ -417,7 +417,7 @@ type
|
|||||||
TVKeyUTF8Char = array[0..7] of Char;
|
TVKeyUTF8Char = array[0..7] of Char;
|
||||||
TVKeyInfo = record
|
TVKeyInfo = record
|
||||||
KeyCode: array[Boolean] of Byte; // false is primary keycode, true the keycode of the other key when 2 keys exist (like CTRL or extended key)
|
KeyCode: array[Boolean] of Byte; // false is primary keycode, true the keycode of the other key when 2 keys exist (like CTRL or extended key)
|
||||||
KeySym: array[0..7] of Integer;
|
KeySym: array of Integer;
|
||||||
KeyChar: array[0..3] of TVKeyUTF8Char;
|
KeyChar: array[0..3] of TVKeyUTF8Char;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -148,6 +148,10 @@ begin
|
|||||||
fpsigaction(SIGCHLD, @child_action, nil);
|
fpsigaction(SIGCHLD, @child_action, nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef ClearGtkModulesEnvVar}
|
||||||
|
function setenv(envname, envvar: PAnsiChar; overwrite: cint): cint; cdecl; external 'c' name 'setenv';
|
||||||
|
{$endif}
|
||||||
|
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -164,6 +168,10 @@ var
|
|||||||
TM: TThreadManager;
|
TM: TThreadManager;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{$ifdef ClearGtkModulesEnvVar}
|
||||||
|
var
|
||||||
|
OldGtkModulesValue: AnsiString;
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
if ClassType = TGtkWidgetSet
|
if ClassType = TGtkWidgetSet
|
||||||
then raise EInvalidOperation.Create('Cannot create the base gtkwidgetset, use gtk1 or gtk2 instead');
|
then raise EInvalidOperation.Create('Cannot create the base gtkwidgetset, use gtk1 or gtk2 instead');
|
||||||
@ -226,9 +234,20 @@ begin
|
|||||||
// initialize app level gtk engine
|
// initialize app level gtk engine
|
||||||
gtk_set_locale ();
|
gtk_set_locale ();
|
||||||
|
|
||||||
|
// clear the GTK_MODULES environment variable if needed
|
||||||
|
{$ifdef ClearGtkModulesEnvVar}
|
||||||
|
OldGtkModulesValue:=GetEnvironmentVariable('GTK_MODULES');
|
||||||
|
setenv('GTK_MODULES', '', 1);
|
||||||
|
{$endif}
|
||||||
|
|
||||||
// call init and pass cmd line args
|
// call init and pass cmd line args
|
||||||
PassCmdLineOptions;
|
PassCmdLineOptions;
|
||||||
|
|
||||||
|
// restore the GTK_MODULES environment variable
|
||||||
|
{$ifdef ClearGtkModulesEnvVar}
|
||||||
|
setenv('GTK_MODULES', PAnsiChar(OldGtkModulesValue), 1);
|
||||||
|
{$endif}
|
||||||
|
|
||||||
// set glib log handler
|
// set glib log handler
|
||||||
FLogHandlerID := g_log_set_handler(nil, -1, @GLogFunc, Self);
|
FLogHandlerID := g_log_set_handler(nil, -1, @GLogFunc, Self);
|
||||||
|
|
||||||
@ -1054,9 +1073,11 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
if (GTK_WIDGET_REALIZED(AWidget)) then
|
if (GTK_WIDGET_REALIZED(AWidget)) then
|
||||||
WindowStyle := gtk_style_copy(gtk_widget_get_style(AWidget))
|
WindowStyle := gtk_widget_get_style(AWidget)
|
||||||
else
|
else
|
||||||
WindowStyle := gtk_style_copy(gtk_rc_get_style(AWidget));
|
WindowStyle := gtk_rc_get_style(AWidget);
|
||||||
|
|
||||||
|
if WindowStyle <> nil then WindowStyle := gtk_style_copy(WindowStyle);
|
||||||
|
|
||||||
if (Windowstyle = nil) then
|
if (Windowstyle = nil) then
|
||||||
Windowstyle := gtk_style_new;
|
Windowstyle := gtk_style_new;
|
||||||
@ -3791,6 +3812,11 @@ begin
|
|||||||
LM_DROPFILES:
|
LM_DROPFILES:
|
||||||
ConnectSenderSignal(gCore, 'drag_data_received', @GtkDragDataReceived);
|
ConnectSenderSignal(gCore, 'drag_data_received', @GtkDragDataReceived);
|
||||||
|
|
||||||
|
LM_CONTEXTMENU:
|
||||||
|
begin
|
||||||
|
// Gtk1 does not have an explicit context menu signal, LM_CONTEXTMENU
|
||||||
|
// support is emulated in gtkMouseBtnPress
|
||||||
|
end;
|
||||||
(*
|
(*
|
||||||
LM_WINDOWPOSCHANGED:
|
LM_WINDOWPOSCHANGED:
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user