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

View File

@ -1174,6 +1174,16 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
else
SizeType := SIZENORMAL or Size_SourceIsInterface;
{$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;
{$ENDIF}
Width := SmallInt(GtkWidth);