Skip to content

Commit 6b8681f

Browse files
committed
Synchro with last commit of main branch (custom shape of forms).
1 parent 96a0c97 commit 6b8681f

File tree

4 files changed

+85
-21
lines changed

4 files changed

+85
-21
lines changed

lib/common/kernel/linux/mseguiintf.pas

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ interface
5353
{$define mse_debug}
5454
{$endif}
5555

56-
uses
57-
mxlib, mxrandr, msetypes, mseapplication, msesys,
58-
msegraphutils, mseevent, msepointer, mseguiglob, msesystypes,{msestockobjects,}
59-
msethread{$ifdef FPC},dynlibs{$endif},
60-
mselibc, msectypes, msesysintf, msegraphics,
61-
msestrings, mxft, mshape, mseclasses;
56+
{$ifdef FPC}mxlib{$else}Xlib{$endif},msetypes,mseapplication,msesys,
57+
msegraphutils,mseevent,msepointer,mseguiglob,msesystypes,{msestockobjects,}
58+
msethread{$ifdef FPC},mx,mxutil,dynlibs{$endif},
59+
mselibc,msectypes,msesysintf,msegraphics,
60+
msestrings,mxft,mxrender,mxrandr,mshape, mseclasses, msebitmap;
6261

6362
{$ifdef FPC}
6463
{$define xbooleanresult}
@@ -473,6 +472,8 @@ MwmHints = record
473472
TXICCEncodingStyle = (XStringStyle,XCompoundTextStyle,XTextStyle,
474473
XStdICCTextStyle,XUTF8StringStyle);
475474
}
475+
function CustomErrorHandler(dpy: PDisplay; err: PXErrorEvent): cint; cdecl;
476+
476477
function XSetWMHints(Display: PDisplay; W: xid; WMHints: PXWMHints): cint; cdecl;
477478
external sXLib name 'XSetWMHints';
478479
function XSetForeground(Display: PDisplay; GC: TGC;
@@ -539,6 +540,9 @@ function Xutf8TextPropertyToTextList(para1:PDisplay; para2:PXTextProperty;
539540
para3:PPPchar; para4: pinteger): integer; cdecl;
540541
external sXlib name 'Xutf8TextPropertyToTextList';
541542

543+
var
544+
mse_shapebmp: tmaskedbitmap;
545+
542546
implementation
543547
uses
544548
msebits,msekeyboard,sysutils,msesysutils,msefileutils,msedatalist,msedragglob
@@ -908,6 +912,14 @@ clipboardinfoty = record
908912
// lastshiftstate: shiftstatesty;
909913
clipboardbuffers: array[clipboardbufferty] of clipboardinfoty;
910914
fidnum: integer;
915+
DefaultErrorHandler: TXErrorHandler;
916+
917+
function CustomErrorHandler(dpy: PDisplay; err: PXErrorEvent): cint; cdecl;
918+
begin
919+
if (err^.error_code = 3) and (err^.request_code = 15) then
920+
Exit(0); // Ignore silently
921+
Result := DefaultErrorHandler(dpy, err); // Handle others normally
922+
end;
911923

912924
procedure deleteitemat(var dest: atomarty; index: integer); overload;
913925
begin
@@ -4091,7 +4103,7 @@ function gui_createwindow(const rect: rectty;
40914103
colormap1: tcolormap;
40924104
opt1: windowtypeoptionty;
40934105
// valall: ptruint;
4094-
4106+
// shapebmp: tmaskedbitmap;
40954107
// shape from Xext
40964108
xgcv :TXGCValues;
40974109
pmap : pixmapty;
@@ -4172,8 +4184,11 @@ function gui_createwindow(const rect: rectty;
41724184
//////////////////////////////////////////////
41734185

41744186
if (mse_hasxext = true) and ((wo_rounded in options.options) or (wo_ellipse in options.options)
4175-
or (wo_transparentbackground in options.options) or (wo_transparentbackgroundround in options.options)
4176-
or (wo_transparentbackgroundellipse in options.options)) then
4187+
or (wo_customshape in options.options)
4188+
or (wo_transparentbackground in options.options)
4189+
or (wo_transparentbackgroundround in options.options)
4190+
//or (wo_transparentbackgroundellipse in options.options)
4191+
) then
41774192
begin
41784193
// shape
41794194
//* create a graphics context for drawing on the window */
@@ -4220,6 +4235,12 @@ function gui_createwindow(const rect: rectty;
42204235
end;
42214236
end;
42224237
end else
4238+
if (wo_customshape in options.options) then
4239+
begin
4240+
DefaultErrorHandler := XSetErrorHandler(@CustomErrorHandler);
4241+
XCopyArea(appdisp, mse_shapebmp.mask.handle, pmap, shape_gc, 0, 0, width, height, 0, 0);
4242+
end else
4243+
{
42234244
if (wo_transparentbackgroundellipse in options.options) then
42244245
begin
42254246
if length(mse_formchild) = 0 then
@@ -4237,6 +4258,7 @@ function gui_createwindow(const rect: rectty;
42374258
end;
42384259
end;
42394260
end else
4261+
}
42404262
if (wo_transparentbackgroundround in options.options) then
42414263
begin
42424264
if length(mse_formchild) = 0 then
@@ -4422,7 +4444,6 @@ function gui_createwindow(const rect: rectty;
44224444
xdeleteproperty(appdisp,id,xdndatoms[xdnd_aware]);
44234445
end;
44244446
end;
4425-
44264447
gdi_unlock;
44274448
end;
44284449

lib/common/kernel/mseguiglob.pas

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ keyeventinfoty = record
136136
wo_ellipse,
137137
wo_rounded,
138138
wo_transparentbackground,
139-
wo_transparentbackgroundellipse,
139+
//wo_transparentbackgroundellipse, // removed because fpc published set are limitged to 31 elements
140140
wo_transparentbackgroundround,
141-
wo_onalldesktops
141+
wo_onalldesktops,
142+
wo_customshape
142143
);
143144
windowoptionsty = set of windowoptionty;
144145
windowtypeoptionty = wo_popup..wo_dnd;
@@ -328,17 +329,15 @@ egui = class(eerror)
328329
toplevelraise: boolean;
329330
nostaticgravity: boolean;
330331
mse_radiuscorner : integer = 8;
331-
// exabug: boolean;
332-
// nocreatestaticgravity: boolean;
333-
332+
334333
procedure guierror(error: guierrorty; text: string = ''); overload;
335334
procedure guierror(error: guierrorty; sender: tobject;
336335
text: string = ''); overload;
337336

338337
implementation
339338

340339
uses
341-
mseclasses,msestreaming{,mseapplication,msegui,mseguiintf};
340+
mseclasses,msestreaming {,mseapplication,msegui,mseguiintf};
342341

343342
const
344343
errortexts: array[guierrorty] of string =

lib/common/kernel/windows/mseguiintf.pas

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface
1515
uses
1616
windows,messages,mseapplication,msetypes,msegraphutils,msesys,
1717
mseevent,msepointer,mseguiglob,msegraphics,
18-
msethread,mseformatstr,{msesysintf,}msestrings,msesystypes,msewinglob;
18+
msethread,mseformatstr,{msesysintf,}msestrings,msesystypes,msewinglob, msebitmap;
1919

2020
type
2121
syseventty = record
@@ -60,11 +60,14 @@ function nestedwindowproc(): boolean; //window frame clicked
6060
gccount: integer;
6161
{$endif}
6262

63+
var
64+
mse_shapebmp: tmaskedbitmap;
65+
6366
implementation
6467
//todo: 19.10.03 rasterops for textout
6568
uses
6669
sysutils,mselist,msekeyboard,msebits,msearrayutils,msesysutils,msegui,
67-
msesystimer,msegdi32gdi,msesysintf1,msedynload,msewindnd,msebitmap
70+
msesystimer,msegdi32gdi,msesysintf1,msedynload,msewindnd
6871
{$ifdef mse_debugzorder},typinfo{$endif} ;
6972

7073
type
@@ -2944,6 +2947,10 @@ function gui_createwindow(const rect: rectty;
29442947
ownerwindow: winidty;
29452948
region, region2 : THandle;
29462949
x, deco_x, deco_y : integer;
2950+
// shapebmp: tmaskedbitmap;
2951+
//rgn, rectrgn: HRGN;
2952+
y, startx: integer;
2953+
29472954
begin
29482955
fillchar(awindow,sizeof(awindow),0);
29492956
with awindow,win32windowty(awindow.platformdata).d,options do begin
@@ -3029,8 +3036,7 @@ function gui_createwindow(const rect: rectty;
30293036
groupleaderwindow:= id;
30303037
end;
30313038
end;
3032-
3033-
3039+
30343040

30353041
if id = 0 then begin
30363042
result:= gue_createwindow;
@@ -3082,6 +3088,8 @@ function gui_createwindow(const rect: rectty;
30823088
DeleteObject(region2);
30833089
DeleteObject(region);
30843090
end else
3091+
3092+
{
30853093
if wo_transparentbackgroundellipse in options then
30863094
begin
30873095
if length(mse_formchild) = 0 then
@@ -3111,6 +3119,42 @@ function gui_createwindow(const rect: rectty;
31113119
DeleteObject(region2);
31123120
DeleteObject(region);
31133121
end else
3122+
}
3123+
if (wo_customshape in options)
3124+
then
3125+
begin
3126+
region := CreateRectRgn(0, 0, 0, 0);
3127+
3128+
mse_shapebmp.options := [bmo_graymask];
3129+
mse_shapebmp.mask.size := mse_shapebmp.size;
3130+
3131+
for y := 0 to mse_shapebmp.size.cy - 1 do
3132+
begin
3133+
x := 0;
3134+
while x < mse_shapebmp.size.cx do
3135+
begin
3136+
if (mse_shapebmp.pixels[x, y] and $FFFFFF) > $7F7F7F then
3137+
begin
3138+
Inc(x);
3139+
Continue;
3140+
end;
3141+
3142+
startx := x;
3143+
// Collect everything that is "dark"
3144+
while (x < mse_shapebmp.size.cx) and ((mse_shapebmp.pixels[x, y] and $FFFFFF) <= $7F7F7F) do
3145+
Inc(x);
3146+
3147+
region2 := CreateRectRgn(startx, y, x, y + 1);
3148+
CombineRgn(region, region, region2, RGN_OR);
3149+
DeleteObject(region2);
3150+
end;
3151+
end;
3152+
3153+
// Apply the custom region to the window handle
3154+
SetWindowRgn(id, region, True);
3155+
3156+
end else
3157+
31143158
if wo_transparentbackgroundround in options then
31153159
begin
31163160
if length(mse_formchild) = 0 then

lib/common/widgets/mseforms.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ procedure tcustommseform.dooncreate;
11681168
try
11691169
foncreate(self);
11701170
if (wo_transparentbackground in foptionswindow) or
1171-
(wo_transparentbackgroundellipse in foptionswindow) or
1171+
// (wo_transparentbackgroundellipse in foptionswindow) or
11721172
(wo_transparentbackgroundround in foptionswindow) then SetChildBounds(self);
11731173
finally
11741174
endsuspendgloballoading;

0 commit comments

Comments
 (0)