LCL-GTK3: Implement widgetset MonitorFromPoint and GetDpiForMonitor. Issue #37190, patch from Anton Kavalenka.

git-svn-id: trunk@63334 -
This commit is contained in:
juha 2020-06-10 09:35:34 +00:00
parent e75ffe32b0
commit 671e011f5f
3 changed files with 42 additions and 1 deletions

View File

@ -1508,7 +1508,7 @@ begin
FCanRelease := False;
FOwnsCairo := True;
FCurrentTextColor := clBlack;
AWindow^.get_geometry(@x, @y, @w, @h);
//AWindow^.get_geometry(@x, @y, @w, @h);
// ParentPixmap := gdk_pixbuf_get_from_window(AWindow, x, y, w, h);
Widget := gdk_cairo_create(AWindow);
// gdk_cairo_set_source_pixbuf(Widget, ParentPixmap, 0, 0);

View File

@ -2038,6 +2038,34 @@ begin
Usage);
end;
function TGtk3WidgetSet.GetDpiForMonitor(hmonitor: HMONITOR;
dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT;
var
w,w_mm,h,h_mm:gint;
rr:double;
pscr:PGdkScreen;
begin
(* MONITOR_DPI_TYPE = (
MDT_EFFECTIVE_DPI = 0,
MDT_ANGULAR_DPI = 1,
MDT_RAW_DPI = 2,
MDT_DEFAULT = MDT_EFFECTIVE_DPI);
TMonitorDpiType = MONITOR_DPI_TYPE;
*)
pscr:=TGdkScreen.get_default;
w:=pscr^.get_width;
w_mm:=pscr^.get_width_mm;
h:=pscr^.get_height;
h_mm:=pscr^.get_height_mm;
dpiX:=round(25.4*w/w_mm);
dpiY:=round(25.4*h/h_mm);
rr:=TGdkScreen.get_default^.get_resolution();
Result:=0;
//Result:=inherited GetDpiForMonitor(hmonitor, dpiType, dpiX, dpiY);
end;
function TGtk3WidgetSet.GetFocus: HWND;
var
i: Integer;
@ -3046,6 +3074,17 @@ begin
Result:= ADialogResult;
end;
function TGtk3WidgetSet.MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord
): HMONITOR;
var
pscr:PGdkScreen;
nmon:gint;
begin
pscr:=TGdkScreen.get_default;
nmon:=pscr^.get_monitor_at_point(ptScreenCoords.X,ptScreenCoords.Y);
Result:=HMONITOR(nmon+1);
end;
function TGtk3WidgetSet.MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint
): Boolean;
begin

View File

@ -121,6 +121,7 @@ function GetDesignerDC(WindowHandle: HWND): HDC; override;
function GetDeviceCaps(DC: HDC; Index: Integer): Integer; override;
function GetDeviceSize(DC: HDC; var p: TPoint): boolean; override;
function GetDIBits(DC: HDC; Bitmap: HBitmap; StartScan, NumScans: UINT; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT): Integer; override;
function GetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT;override;
function GetFocus: HWND; override;
function GetFontLanguageInfo(DC: HDC): DWord; override;
function GetForegroundWindow: HWND; override;
@ -165,6 +166,7 @@ function LineTo(DC: HDC; X, Y: Integer): Boolean; override;
function LPtoDP(DC: HDC; var Points; Count: Integer): BOOL; override;
function MessageBox({%H-}hWnd: HWND; lpText, lpCaption: PChar; uType: Cardinal): integer; override;
function MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord): HMONITOR;override;
function MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean; override;
function OffsetRgn(RGN: HRGN; nXOffset, nYOffset: Integer): Integer; override;