gtk2 intf: implemented difference between Minimize and Desktop switch from Andrew, bug #1996

git-svn-id: trunk@10147 -
This commit is contained in:
mattias 2006-10-31 18:19:02 +00:00
parent fa382552fa
commit c3cc436b89
2 changed files with 44 additions and 7 deletions

View File

@ -1030,6 +1030,13 @@ var
SizeMsg: TLMSize; SizeMsg: TLMSize;
GtkWidth: LongInt; GtkWidth: LongInt;
GtkHeight: LongInt; GtkHeight: LongInt;
{$IFDEF HasX}
NetAtom: TGdkAtom;
AtomType: TGdkAtom;
AIndex, ADesktop: pguint;
AFormat: gint;
ALength: gint;
{$ENDIF}
begin begin
Result := CallBackDefaultReturn; Result := CallBackDefaultReturn;
@ -1046,14 +1053,34 @@ begin
GtkHeight:=Widget^.Allocation.Height; GtkHeight:=Widget^.Allocation.Height;
if GtkHeight<0 then GtkHeight:=0; if GtkHeight<0 then GtkHeight:=0;
debugln('GTKWindowStateEventCB ',DbgSName(TObject(Data)),' ',dbgs(state^.new_window_state),' ',WidgetFlagsToString(Widget)); debugln('GTKWindowStateEventCB ',DbgSName(TObject(Data)),' ',dbgs(state^.new_window_state),' ',WidgetFlagsToString(Widget));
if (GDK_WINDOW_STATE_ICONIFIED and state^.new_window_state)>0 then if ((GDK_WINDOW_STATE_ICONIFIED and state^.new_window_state)>0) then begin
// the window is iconified, or the user switched to another desktop {$IFDEF HasX}
// TODO: find out which one happened. NetAtom := gdk_atom_intern('_NET_WM_DESKTOP', True);
// The LCL interprets SIZEICONIC as minimizing by the user if NetAtom > 0 then begin
// and thus minimizes the whole application. if gdk_property_get(Widget^.window, NetAtom, XA_CARDINAL,0, 4, 0, @AtomType, @AFormat, @ALength, @AIndex)
SizeMsg.SizeType:=SIZENORMAL //SIZEICONIC then begin
NetAtom := gdk_atom_intern('_NET_CURRENT_DESKTOP', True);
if gdk_property_get(gdk_get_default_root_window, NetAtom, XA_CARDINAL,0, 4, 0, @AtomType, @AFormat, @ALength, @ADesktop)
then if ADesktop^ <> AIndex^ then begin
g_free(ADesktop);
g_free(AIndex);
exit;
end
else begin
g_free(ADesktop);
g_free(AIndex);
end;
end;
end;
{$ENDIF}
SizeMsg.SizeType:=SIZEICONIC;
end
else if (GDK_WINDOW_STATE_MAXIMIZED and state^.new_window_state)>0 then else if (GDK_WINDOW_STATE_MAXIMIZED and state^.new_window_state)>0 then
SizeMsg.SizeType:=SIZEFULLSCREEN begin
if (state^.changed_mask and GDK_WINDOW_STATE_MAXIMIZED)=0 then Exit;
SizeMsg.SizeType:=SIZEFULLSCREEN;
end
else else
SizeMsg.SizeType:=SIZENORMAL; SizeMsg.SizeType:=SIZENORMAL;
with SizeMsg do with SizeMsg do

View File

@ -1174,6 +1174,16 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
else else
SizeType := SIZENORMAL or Size_SourceIsInterface; SizeType := SIZENORMAL or Size_SourceIsInterface;
{$ELSE} {$ELSE}
if LCLControl is TCustomForm then begin
// if the LCL gets an event without a State it resets it to SIZENORMAL
// so we send it the state it already is
case TCustomForm(LCLControl).WindowState of
wsNormal: SizeType := SIZENORMAL or Size_SourceIsInterface;
wsMinimized: SizeType := SIZEICONIC or Size_SourceIsInterface;
wsMaximized: SizeType := SIZEFULLSCREEN or Size_SourceIsInterface;
end;
end
else
SizeType := Size_SourceIsInterface; SizeType := Size_SourceIsInterface;
{$ENDIF} {$ENDIF}
Width := SmallInt(GtkWidth); Width := SmallInt(GtkWidth);