82
82
class procedure SetFormBorderStyle(const AForm: TCustomForm;
83
83
const AFormBorderStyle: TFormBorderStyle); override;
84
84
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle,
85
AOldFormStyle: TFormStyle); override;
86
{ class function GetDefaultClientRect(const AWinControl: TWinControl;
87
const aLeft, aTop, aWidth, aHeight: integer; var aClientRect: TRect
89
class procedure SetBorderIcons(const AForm: TCustomForm;
90
const ABorderIcons: TBorderIcons); override;}
85
{%H-}AOldFormStyle: TFormStyle); override;
91
86
class procedure SetAllowDropFiles(const AForm: TCustomForm; AValue: Boolean); override;
92
87
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
93
88
class procedure ShowHide(const AWinControl: TWinControl); override;
94
class procedure ShowModal(const AForm: TCustomForm); override;
89
class procedure ShowModal(const {%H-}AForm: TCustomForm); override;
95
90
class procedure SetBorderIcons(const AForm: TCustomForm;
96
91
const ABorderIcons: TBorderIcons); override;
97
92
class procedure SetColor(const AWinControl: TWinControl); override;
136
132
AEvent: TGdkEventWindowState;
139
AEvent := GetWidgetInfo(PGtkWidget(AnForm.Handle))^.FormWindowState;
140
GTKWindowStateEventCB(PGtkWidget(AnForm.Handle), @AEvent, Data);
135
AEvent := GetWidgetInfo({%H-}PGtkWidget(AnForm.Handle))^.FormWindowState;
136
GTKWindowStateEventCB({%H-}PGtkWidget(AnForm.Handle), @AEvent, Data);
141
137
// remove idle handler, because in fast switching hide/show there could
142
138
// be dozen of added idle handlers, only one should be here.
143
139
// also reset our internal flag on send_event.
144
GetWidgetInfo(PGtkWidget(AnForm.Handle))^.FormWindowState.send_event := 0;
140
GetWidgetInfo({%H-}PGtkWidget(AnForm.Handle))^.FormWindowState.send_event := 0;
145
141
g_idle_remove_by_data(Data);
149
function compositeManagerRunning: Boolean;
155
// who's running such old composition manager ?
156
if (gtk_major_version = 2) and (gtk_minor_version < 10) then
158
XDisplay := gdk_display;
159
WMAtom := XInternAtom(XDisplay,'_NET_WM_CM_S0', False);
161
Result := XGetSelectionOwner(XDisplay, WMAtom) <> 0;
165
144
function Gtk2FormEvent(widget: PGtkWidget; event: PGdkEvent; data: GPointer): gboolean; cdecl;
167
146
ACtl: TWinControl;
182
161
{fixes multiple resize events. See comments on
183
162
http://bugs.freepascal.org/view.php?id=17015}
184
163
ACtl := TWinControl(Data);
185
GetWidgetRelativePosition(PGtkWidget(ACtl.Handle), X, Y);
164
GetWidgetRelativePosition({%H-}PGtkWidget(ACtl.Handle), X, Y);
186
165
Result := (event^.configure.send_event = 1) and
187
166
not ((X <> ACtl.Left) or (Y <> ACtl.Top));
190
169
// fix for buggy compiz.
191
170
// see http://bugs.freepascal.org/view.php?id=17523
192
if compositeManagerRunning then
171
if Gtk2WidgetSet.compositeManagerRunning then
194
173
if (X <> ACtl.Left) or (Y <> ACtl.Top) then
195
174
Result := gtkconfigureevent(widget, PGdkEventConfigure(event),
438
424
if not AWinControl.HandleAllocated then exit;
439
WidgetInfo := GetWidgetInfo(PGtkWidget(AWinControl.Handle));
425
WidgetInfo := GetWidgetInfo({%H-}PGtkWidget(AWinControl.Handle));
440
426
Layout := PGtkLayout(WidgetInfo^.ClientWidget);
441
427
Adjustment := gtk_layout_get_hadjustment(Layout);
442
428
if Adjustment <> nil then
444
430
h := gtk_adjustment_get_value(Adjustment);
445
431
NewPos := Adjustment^.upper - Adjustment^.page_size;
446
if h + DeltaX <= NewPos then
447
NewPos := h + DeltaX;
432
if h - DeltaX <= NewPos then
433
NewPos := h - DeltaX;
448
434
if gtk_adjustment_get_value(Adjustment) <> NewPos then
450
436
gtk_adjustment_set_value(Adjustment, NewPos);
550
536
if (csDesigning in AForm.ComponentState) then
552
if GTK_IS_WINDOW(PGtkWindow(AForm.Handle)) then
553
gtk_window_set_keep_above(PGtkWindow(AForm.Handle),
538
if GTK_IS_WINDOW({%H-}PGtkWindow(AForm.Handle)) then
539
gtk_window_set_keep_above({%H-}PGtkWindow(AForm.Handle),
554
540
GBoolean(AFormStyle in fsAllStayOnTop));
557
{class function TGtk2WSCustomForm.GetDefaultClientRect(
558
const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
559
var aClientRect: TRect): boolean;
562
if AWinControl.HandleAllocated then begin
565
FrameBorders:=GetStyleFormFrameBorders(TCustomForm(AWinControl).Menu<>nil);
566
aClientRect:=Rect(0,0,
567
Max(0,aWidth-FrameBorders.Left-FrameBorders.Right),
568
Max(0,aHeight-FrameBorders.Top-FrameBorders.Bottom));
573
class procedure TGtk2WSCustomForm.SetBorderIcons(const AForm: TCustomForm;
574
const ABorderIcons: TBorderIcons);
576
gtk_window_get_modal();
579
543
class procedure TGtk2WSCustomForm.SetAllowDropFiles(const AForm: TCustomForm;
580
544
AValue: Boolean);
583
gtk_drag_dest_set(PGtkWidget(AForm.Handle), GTK_DEST_DEFAULT_ALL,
547
gtk_drag_dest_set({%H-}PGtkWidget(AForm.Handle), GTK_DEST_DEFAULT_ALL,
584
548
@FileDragTarget, 1, GDK_ACTION_COPY or GDK_ACTION_MOVE)
586
gtk_drag_dest_unset(PGtkWidget(AForm.Handle));
550
gtk_drag_dest_unset({%H-}PGtkWidget(AForm.Handle));
589
553
class procedure TGtk2WSCustomForm.SetShowInTaskbar(const AForm: TCustomForm;
600
564
AForm: TCustomForm;
601
565
GtkWindow: PGtkWindow;
566
Geometry: TGdkGeometry;
568
function ShowNonModalOverModal: Boolean;
574
AForm := TCustomForm(AWinControl);
575
if AWinControl.HandleObjectShouldBeVisible and
576
not (csDesigning in AForm.ComponentState) and
577
not (fsModal in AForm.FormState) and
578
(AForm.Parent = nil) and
579
(AForm.FormStyle <> fsMDIChild) and
580
(ModalWindows <> nil) and (ModalWindows.Count > 0) and
581
not (AForm.FormStyle in fsAllStayOnTop) and
582
(AForm.BorderStyle in [bsDialog, bsSingle, bsSizeable]) and
583
(AForm.PopupParent = nil) and (AForm.PopupMode = pmNone) then
585
AWindow := {%H-}PGtkWindow(AForm.Handle);
586
gtk_window_set_modal(AWindow, True);
587
// lcl_nonmodal_over_modal is needed to track nonmodal form
588
// created and shown when we have active modal forms
589
g_object_set_data(PGObject(AWindow),'lcl_nonmodal_over_modal', AForm);
603
594
AForm := TCustomForm(AWinControl);
604
595
if not (csDesigning in AForm.ComponentState) then
606
597
if AForm.HandleObjectShouldBeVisible and
607
GTK_IS_WINDOW(PGtkWindow(AForm.Handle)) then
608
gtk_window_set_keep_above(PGtkWindow(AForm.Handle),
598
GTK_IS_WINDOW({%H-}PGtkWindow(AForm.Handle)) then
599
gtk_window_set_keep_above({%H-}PGtkWindow(AForm.Handle),
609
600
GBoolean(AForm.FormStyle in fsAllStayOnTop))
611
602
if (AForm.FormStyle in fsAllStayOnTop) and
612
603
not (csDestroying in AWinControl.ComponentState) then
613
gtk_window_set_keep_above(PGtkWindow(AForm.Handle), GBoolean(False));
604
gtk_window_set_keep_above({%H-}PGtkWindow(AForm.Handle), GBoolean(False));
607
GtkWindow := {%H-}PGtkWindow(AForm.Handle);
615
608
if (fsModal in AForm.FormState) and AForm.HandleObjectShouldBeVisible then
617
GtkWindow := PGtkWindow(AForm.Handle);
618
610
gtk_window_set_default_size(GtkWindow, Max(1,AForm.Width), Max(1,AForm.Height));
619
611
gtk_widget_set_uposition(PGtkWidget(GtkWindow), AForm.Left, AForm.Top);
620
612
GtkWindowShowModal(AForm, GtkWindow);
615
if ShowNonModalOverModal then
618
if (AForm.FormStyle <> fsMDIChild) and AForm.HandleObjectShouldBeVisible and
619
(ModalWindows <> nil) and (ModalWindows.Count > 0) and
620
(AForm.PopupParent = nil) and (AForm.BorderStyle = bsNone) then
622
gtk_window_set_transient_for(GtkWindow, nil);
623
gtk_window_set_modal(GtkWindow, True);
623
625
Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible);
628
if not (csDesigning in AForm.ComponentState) and
629
AForm.HandleObjectShouldBeVisible and
630
(AForm.BorderStyle in [bsDialog, bsSingle]) then
632
// we must set fixed size, gtk_window_set_resizable does not work
633
// as expected for some reason.issue #20741
636
min_width := AForm.Width;
637
max_width := AForm.Width;
638
min_height := AForm.Height;
639
max_height := AForm.Height;
641
base_width := AForm.Width;
642
base_height := AForm.Height;
647
win_gravity := gtk_window_get_gravity(GtkWindow);
649
//debugln('TGtk2WSWinControl.ConstraintsChange A ',GetWidgetDebugReport(Widget),' max=',dbgs(Geometry.max_width),'x',dbgs(Geometry.max_height));
650
gtk_window_set_geometry_hints(GtkWindow, nil, @Geometry,
651
GDK_HINT_POS or GDK_HINT_MIN_SIZE or GDK_HINT_MAX_SIZE);
654
if not (csDesigning in AForm.ComponentState) and
655
AForm.HandleObjectShouldBeVisible and (AForm.WindowState = wsFullScreen) then
656
gtk_window_fullscreen(GtkWindow);
624
659
InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect);
726
760
SetFixedWidget(Scrolled, Layout);
727
761
SetMainWidget(Scrolled, Layout);
730
Result := TLCLIntfHandle(PtrUInt(Scrolled));
763
Result := TLCLIntfHandle({%H-}PtrUInt(Scrolled));
732
765
Set_RC_Name(AWinControl, PGtkWidget(Scrolled));
733
766
SetCallBacks(PGtkWidget(Scrolled), WidgetInfo);
734
767
if (gtk_major_version >= 2) and (gtk_minor_version > 8) then
736
769
g_signal_connect(Scrolled^.hscrollbar, 'change-value',
737
TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
770
TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
738
771
g_signal_connect(Scrolled^.vscrollbar, 'change-value',
739
TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
772
TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
773
g_signal_connect(Scrolled^.hscrollbar, 'button-press-event',
774
TGCallback(@Gtk2RangeScrollPressCB), WidgetInfo);
775
g_signal_connect(Scrolled^.hscrollbar, 'button-release-event',
776
TGCallback(@Gtk2RangeScrollReleaseCB), WidgetInfo);
777
g_signal_connect(Scrolled^.vscrollbar, 'button-press-event',
778
TGCallback(@Gtk2RangeScrollPressCB), WidgetInfo);
779
g_signal_connect(Scrolled^.vscrollbar, 'button-release-event',
780
TGCallback(@Gtk2RangeScrollReleaseCB), WidgetInfo);
781
if (AWinControl is TScrollBox) then
782
g_signal_connect(Scrolled, 'scroll-event',
783
TGCallback(@Gtk2ScrolledWindowScrollCB), WidgetInfo);
849
893
{$IFDEF DebugLCLComponents}
850
894
DebugGtkWidgets.MarkCreated(P,dbgsName(AWinControl));
852
Result := TLCLIntfHandle(PtrUInt(P));
896
Result := TLCLIntfHandle({%H-}PtrUInt(P));
853
897
Set_RC_Name(AWinControl, P);
854
898
SetCallbacks(P, WidgetInfo);
901
class procedure TGtk2WSHintWindow.ShowHide(const AWinControl: TWinControl);
903
if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
905
Gtk2WidgetSet.SetVisible(AWinControl, AWinControl.HandleObjectShouldBeVisible);
906
InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect);