mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 07:36:06 +02:00
added some checks to avoid crashes
git-svn-id: trunk@6964 -
This commit is contained in:
parent
84a5d07140
commit
e630464bae
@ -181,14 +181,20 @@ end;
|
|||||||
{$IFDEF GTK1}
|
{$IFDEF GTK1}
|
||||||
function InternalGtkShowWindow(AForm: TCustomForm): gint; cdecl;
|
function InternalGtkShowWindow(AForm: TCustomForm): gint; cdecl;
|
||||||
var
|
var
|
||||||
XDisplay: PDisplay;
|
XDisplay: xlib.PDisplay;
|
||||||
XWindow: TWindow;
|
XWindow: X.TWindow;
|
||||||
|
FormWidget: PGtkWidget;
|
||||||
|
FormWindow: PGdkWindowPrivate;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
XWindow := GDK_WINDOW_XWINDOW (PGdkWindowPrivate(PGtkWidget(AForm.Handle)^.window));
|
if not AForm.HandleAllocated then exit;
|
||||||
XDisplay := GDK_WINDOW_XDISPLAY (PGdkWindowPrivate(PGtkWidget(AForm.Handle)^.window));
|
FormWidget:=PGtkWidget(AForm.Handle);
|
||||||
|
FormWindow:=PGdkWindowPrivate(FormWidget^.window);
|
||||||
|
if FormWindow<>nil then exit;
|
||||||
|
XWindow := GDK_WINDOW_XWINDOW (FormWindow);
|
||||||
|
XDisplay := GDK_WINDOW_XDISPLAY (FormWindow);
|
||||||
if (XDisplay<>nil) and (XWindow>0) then
|
if (XDisplay<>nil) and (XWindow>0) then
|
||||||
XSetInputFocus(XDisplay, XWindow, RevertToNone, CurrentTime);
|
XSetInputFocus(XDisplay, XWindow, X.RevertToNone, X.CurrentTime);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -205,8 +211,10 @@ var
|
|||||||
GdkWindow: PGdkWindow;
|
GdkWindow: PGdkWindow;
|
||||||
AForm: TCustomForm;
|
AForm: TCustomForm;
|
||||||
{$IFDEF GTK1}
|
{$IFDEF GTK1}
|
||||||
XDisplay: PDisplay;
|
XDisplay: xlib.PDisplay;
|
||||||
XWindow: TWindow;
|
XWindow: x.TWindow;
|
||||||
|
FormWidget: PGtkWidget;
|
||||||
|
FormWindow: PGdkWindowPrivate;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
@ -233,11 +241,15 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// how to set the keyboard focus to the raised window?
|
// how to set the keyboard focus to the raised window?
|
||||||
{$IFDEF GTK1}
|
{$IFDEF GTK1}
|
||||||
XWindow := GDK_WINDOW_XWINDOW (PGdkWindowPrivate(PGtkWidget(AForm.Handle)^.window));
|
FormWidget:=PGtkWidget(AForm.Handle);
|
||||||
XDisplay := GDK_WINDOW_XDISPLAY (PGdkWindowPrivate(PGtkWidget(AForm.Handle)^.window));
|
FormWindow:=PGdkWindowPrivate(FormWidget^.window);
|
||||||
XMapWindow(XDisplay, XWindow);
|
if FormWindow<>nil then begin
|
||||||
// a horrible horrible hack to give "something" time to unminimize the window
|
XWindow := GDK_WINDOW_XWINDOW (FormWindow);
|
||||||
gtk_timeout_add(50, TGtkFunction(@InternalGtkShowWindow), AForm);
|
XDisplay := GDK_WINDOW_XDISPLAY (FormWindow);
|
||||||
|
XMapWindow(XDisplay, XWindow);
|
||||||
|
// a horrible horrible hack to give "something" time to unminimize the window
|
||||||
|
gtk_timeout_add(50, TGtkFunction(@InternalGtkShowWindow), AForm);
|
||||||
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ifdef gtk2}
|
{$ifdef gtk2}
|
||||||
gtk_window_present(PGtkWindow(hWnd));
|
gtk_window_present(PGtkWindow(hWnd));
|
||||||
@ -8990,6 +9002,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.410 2005/03/16 12:30:15 mattias
|
||||||
|
added some checks to avoid crashes
|
||||||
|
|
||||||
Revision 1.409 2005/03/16 11:36:21 mattias
|
Revision 1.409 2005/03/16 11:36:21 mattias
|
||||||
improved gtk1 intf switching focus to another form from Andrew Haines
|
improved gtk1 intf switching focus to another form from Andrew Haines
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user