View Issue Details

IDProjectCategoryView StatusLast Update
0036946LazarusWidgetsetpublic2020-08-28 07:44
ReporterAnton Kavalenka Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Summary0036946: gtk3: Make Screen.WorkArea work
DescriptionPatch for TGtk3WidgetSet.SystemParametersInfo
TagsNo tags attached.
Fixed in Revisionr63837
LazTarget-
WidgetsetGTK 3
Attached Files

Relationships

related to 0036963 closedZeljan Rikalo gtk3: GDK api for GDkMonitor 

Activities

Anton Kavalenka

2020-04-21 17:36

reporter  

gtk3winapi.diff (1,128 bytes)   
Index: lcl/interfaces/gtk3/gtk3winapi.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3winapi.inc	(revision 63043)
+++ lcl/interfaces/gtk3/gtk3winapi.inc	(working copy)
@@ -4006,10 +4006,18 @@
 function TGtk3WidgetSet.SystemParametersInfo(uiAction: DWord; uiParam: DWord;
   pvParam: Pointer; fWinIni: DWord): LongBool;
 begin
-  {$IFDEF GTK3DEBUGNOTIMPLEMENTED}
-  DebugLn('WARNING: TGtk3WidgetSet.SystemParametersInfo not implemented ...');
-  {$ENDIF}
-  Result:=inherited SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
+  Result:=True;
+  Case uiAction of
+    SPI_GETWHEELSCROLLLINES: PDword(pvParam)^ := 3;
+    SPI_GETWORKAREA: begin
+      TRect(pvParam^):=Bounds(GetSystemMetrics(SM_XVIRTUALSCREEN),
+                              GetSystemMetrics(SM_YVIRTUALSCREEN),
+                              GetSystemMetrics(SM_CXVIRTUALSCREEN),
+                              GetSystemMetrics(SM_CYVIRTUALSCREEN));
+    end;
+  else
+    Result:=False;
+  end;
 end;
 
 function TGtk3WidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: PChar; Count: Integer): Boolean;
gtk3winapi.diff (1,128 bytes)   

Zeljan Rikalo

2020-04-21 17:47

developer   ~0122323

@Anton, that patch is not good. Please look into gtk2 implementation, but I'll bet that Gtk3 have gtk_screen_workarea or similar

Anton Kavalenka

2020-04-21 18:16

reporter   ~0122324

gdk_monitor_get_workarea () is not in LazGdk3.pas, update needed

Zeljan Rikalo

2020-04-21 18:45

developer   ~0122325

hmmm.... gdk_monitor_get_workarea () is added in gtk3 3.22 but our bindings support 3.6 or 3.8 afair, maybe same approach as with gtk2 is needed

Zeljan Rikalo

2020-04-21 18:49

developer   ~0122326

maybe we should rethink gtk3 bindings and update it to 3.22 , according to https://en.wikipedia.org/wiki/GTK it is last stable version...well there's 3.24 but with minor adjustment for easy conversion between gtk3 and gtk4.

Anton Kavalenka

2020-08-19 18:53

reporter   ~0124995

looks like it works
gtk3workarea.diff (3,414 bytes)   
Index: lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas	(revision 63777)
+++ lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas	(working copy)
@@ -2891,6 +2891,10 @@
     function intern_static_string(atom_name: Pgchar): PGdkAtom; cdecl; inline; static;
   end;
 
+  { TGdkDisplay }
+
+  PGdkMonitor = ^TGdkMonitor;
+
   TGdkDisplay = object(TGObject)
     function get_default: PGdkDisplay; cdecl; inline; static;
     function open(display_name: Pgchar): PGdkDisplay; cdecl; inline; static;
@@ -2905,6 +2909,7 @@
     function get_default_screen: PGdkScreen; cdecl; inline;
     function get_device_manager: PGdkDeviceManager; cdecl; inline;
     function get_event: PGdkEvent; cdecl; inline;
+    function get_primary_monitor: PGdkMonitor; cdecl;inline;
     procedure get_maximal_cursor_size(width: Pguint; height: Pguint); cdecl; inline;
     function get_n_screens: gint; cdecl; inline;
     function get_name: Pgchar; cdecl; inline;
@@ -3901,7 +3906,6 @@
   );
 
   { TGdkMonitor available since 3.22 }
-  PGdkMonitor = ^TGdkMonitor;
   TGdkMonitor = object(TGObject)
   public
     function get_display ():PGdkDisplay;cdecl;inline;
@@ -3974,6 +3978,7 @@
 function gdk_display_get_n_screens(display: PGdkDisplay): gint; cdecl; external;
 function gdk_display_get_name(display: PGdkDisplay): Pgchar; cdecl; external;
 function gdk_display_get_screen(display: PGdkDisplay; screen_num: gint): PGdkScreen; cdecl; external;
+function gdk_display_get_primary_monitor(display: PGdkDisplay): PGdkMonitor; cdecl; external;
 function gdk_display_get_type: TGType; cdecl; external;
 function gdk_display_has_pending(display: PGdkDisplay): gboolean; cdecl; external;
 function gdk_display_is_closed(display: PGdkDisplay): gboolean; cdecl; external;
@@ -4552,6 +4557,11 @@
   Result := LazGdk3.gdk_display_get_event(@self);
 end;
 
+function TGdkDisplay.get_primary_monitor: PGdkMonitor; cdecl;
+begin
+  Result:=LazGdk3.gdk_display_get_primary_monitor(@Self);
+end;
+
 procedure TGdkDisplay.get_maximal_cursor_size(width: Pguint; height: Pguint); cdecl;
 begin
   LazGdk3.gdk_display_get_maximal_cursor_size(@self, width, height);
Index: lcl/interfaces/gtk3/gtk3winapi.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3winapi.inc	(revision 63777)
+++ lcl/interfaces/gtk3/gtk3winapi.inc	(working copy)
@@ -3955,11 +3955,28 @@
 
 function TGtk3WidgetSet.SystemParametersInfo(uiAction: DWord; uiParam: DWord;
   pvParam: Pointer; fWinIni: DWord): LongBool;
+var
+  wa:TGdkRectangle;
+  pdisp:PGdkDisplay;
+  pmon:PgdkMonitor;
+  pr:PRect;
 begin
-  {$IFDEF GTK3DEBUGNOTIMPLEMENTED}
-  DebugLn('WARNING: TGtk3WidgetSet.SystemParametersInfo not implemented ...');
-  {$ENDIF}
-  Result:=inherited SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
+  Result:=True;
+  Case uiAction of
+    SPI_GETWHEELSCROLLLINES: PDword(pvParam)^ := 3;
+    SPI_GETWORKAREA: begin
+      pdisp:=TGdkDisplay.get_default;
+      pmon:=pdisp^.get_primary_monitor();
+      pmon^.get_workarea(@wa);
+      pr:=PRect(pvParam);
+      pr^.Left:=wa.x;
+      pr^.Top:=wa.y;
+      pr^.Width:=wa.width;
+      pr^.Height:=wa.height;
+    end;
+  else
+    Result:=False;
+  end;
 end;
 
 function TGtk3WidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: PChar; Count: Integer): Boolean;
gtk3workarea.diff (3,414 bytes)   

CudaText man

2020-08-19 20:24

reporter   ~0124996

Thanks
Offtop.
@Anton,
if you have time, can you see why CudaText gtk3 build crashes on start? (Cudatext has 'build mode' gtk3 so just activate it in IDE).

Anton Kavalenka

2020-08-20 20:55

reporter   ~0125034

@CudaText man
CudaText fails to compile when packages installed via OPM.
Lots of absent or wrong publics.
/projects/laztest/CudaText/app/formmain_py_api.inc(275,67) Error: Call by var for arg no. 4 has to match exactly: Got "UnicodeString" expected "AnsiString"

Anton Kavalenka

2020-08-26 13:49

reporter   ~0125131

ping @Zeljan Rikalo

please apply the newer patch

Juha Manninen

2020-08-26 21:34

developer   ~0125142

Applied, thanks.

Issue History

Date Modified Username Field Change
2020-04-21 17:36 Anton Kavalenka New Issue
2020-04-21 17:36 Anton Kavalenka File Added: gtk3winapi.diff
2020-04-21 17:47 Zeljan Rikalo Assigned To => Zeljan Rikalo
2020-04-21 17:47 Zeljan Rikalo Status new => feedback
2020-04-21 17:47 Zeljan Rikalo LazTarget => -
2020-04-21 17:47 Zeljan Rikalo Note Added: 0122323
2020-04-21 18:16 Anton Kavalenka Note Added: 0122324
2020-04-21 18:16 Anton Kavalenka Status feedback => assigned
2020-04-21 18:45 Zeljan Rikalo Note Added: 0122325
2020-04-21 18:49 Zeljan Rikalo Note Added: 0122326
2020-04-24 17:24 Zeljan Rikalo Relationship added related to 0036963
2020-08-19 18:53 Anton Kavalenka Note Added: 0124995
2020-08-19 18:53 Anton Kavalenka File Added: gtk3workarea.diff
2020-08-19 20:24 CudaText man Note Added: 0124996
2020-08-20 20:55 Anton Kavalenka Note Added: 0125034
2020-08-26 13:49 Anton Kavalenka Note Added: 0125131
2020-08-26 21:28 Juha Manninen Assigned To Zeljan Rikalo => Juha Manninen
2020-08-26 21:34 Juha Manninen Status assigned => resolved
2020-08-26 21:34 Juha Manninen Resolution open => fixed
2020-08-26 21:34 Juha Manninen Fixed in Revision => r63837
2020-08-26 21:34 Juha Manninen Widgetset GTK 3 => GTK 3
2020-08-26 21:34 Juha Manninen Note Added: 0125142
2020-08-28 07:44 Anton Kavalenka Status resolved => closed