Skip to content

Commit

Permalink
Added window options: wo_transparentbackgroundround ,wo_inalldesktops.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredvs committed Jun 20, 2022
1 parent da757b7 commit 0943f1a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 10 deletions.
73 changes: 66 additions & 7 deletions lib/common/kernel/linux/mseguiintf.pas
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ procedure setmsestringproperty(id: winidty; prop: atom; const value: msestring);
end;

procedure setwinidproperty(id: winidty; prop: atom; value: winidty);
begin
begin
{$ifdef mse_debuggdisync}
checkgdilock;
{$endif}
Expand Down Expand Up @@ -1652,8 +1652,8 @@ function gui_getwindowdesktop(const id: winidty): integer;
begin
result:= 0;
if getnetcardinal(id,net_wm_desktop,lwo1) then begin
result:= lwo1;
end;
result:= lwo1;
end;
end;

function changenetwmstate(id: winidty; const operation: netwmstateoperationty;
Expand Down Expand Up @@ -4062,6 +4062,8 @@ function gui_createwindow(const rect: rectty;
icmask: longword;
colormap1: tcolormap;
opt1: windowtypeoptionty;
valall: ptruint;

// shape from Xext
xgcv :TXGCValues;
pmap : pixmapty;
Expand Down Expand Up @@ -4129,7 +4131,7 @@ function gui_createwindow(const rect: rectty;
setnetatomarrayitem(id,net_wm_state,net_wm_alwaystofront);

if (mse_hasxext = true) and ((wo_rounded in options.options) or (wo_ellipse in options.options)
or (wo_transparentbackground in options.options)) then
or (wo_transparentbackground in options.options) or (wo_transparentbackgroundround in options.options)) then
begin
// shape
//* create a graphics context for drawing on the window */
Expand Down Expand Up @@ -4176,6 +4178,56 @@ function gui_createwindow(const rect: rectty;
end;
end;
end else
if (wo_transparentbackgroundround in options.options) then
begin
if length(mse_formchild) = 0 then
begin
XDrawRectangle(appdisp, pmap, shape_gc, 0, 0, Width, Height);
XFillRectangle(appdisp, pmap, shape_gc, 0, 0, Width, Height);
end else
begin
for x := 0 to length(mse_formchild) - 1 do
begin
XDrawarc(appdisp, pmap, shape_gc, mse_formchild[x].left, mse_formchild[x].top,
mse_radiuscorner , mse_radiuscorner, mse_formchild[x].top, 360*64);
XFillarc(appdisp, pmap, shape_gc, mse_formchild[x].left, mse_formchild[x].top,
mse_radiuscorner , mse_radiuscorner, mse_formchild[x].top, 360*64);

XDrawarc(appdisp, pmap, shape_gc, mse_formchild[x].left + mse_formchild[x].Width - mse_radiuscorner, mse_formchild[x].top,
mse_radiuscorner , mse_radiuscorner, mse_formchild[x].top, 360*64);
XFillarc(appdisp, pmap, shape_gc, mse_formchild[x].left + mse_formchild[x].Width - mse_radiuscorner, mse_formchild[x].top,
mse_radiuscorner , mse_radiuscorner, mse_formchild[x].top, 360*64);

XDrawarc(appdisp, pmap, shape_gc, mse_formchild[x].left,
mse_formchild[X].Height + mse_formchild[x].top - mse_radiuscorner -1,
mse_radiuscorner-1 , mse_radiuscorner, mse_formchild[x].left, 360*64);
XFillarc(appdisp, pmap, shape_gc, mse_formchild[x].left,
mse_formchild[X].Height + mse_formchild[x].top - mse_radiuscorner -1,
mse_radiuscorner-1 , mse_radiuscorner, mse_formchild[x].left, 360*64);

XDrawarc(appdisp, pmap, shape_gc, mse_formchild[x].left + mse_formchild[x].Width - mse_radiuscorner,
mse_formchild[X].Height + mse_formchild[x].top - mse_radiuscorner -1,
mse_radiuscorner , mse_radiuscorner, mse_formchild[x].left, 360*64);

XFillarc(appdisp, pmap, shape_gc, mse_formchild[x].left + mse_formchild[x].Width - mse_radiuscorner,
mse_formchild[X].Height + mse_formchild[x].top - mse_radiuscorner -1,
mse_radiuscorner , mse_radiuscorner, mse_formchild[x].left, 360*64);

XDrawRectangle(appdisp, pmap, shape_gc,mse_formchild[x].left + (mse_radiuscorner div 2),
mse_formchild[x].top, mse_formchild[x].Width - (mse_radiuscorner) , mse_formchild[X].Height);

XFillRectangle(appdisp, pmap, shape_gc,mse_formchild[x].left + (mse_radiuscorner div 2),
mse_formchild[x].top, mse_formchild[x].Width - (mse_radiuscorner) , mse_formchild[X].Height);


XDrawRectangle(appdisp, pmap, shape_gc, mse_formchild[x].left, mse_formchild[x].top + (mse_radiuscorner div 2),
mse_formchild[x].Width, mse_formchild[X].Height - (mse_radiuscorner));

XFillRectangle(appdisp, pmap, shape_gc, mse_formchild[x].left, mse_formchild[x].top + (mse_radiuscorner div 2),
mse_formchild[x].Width, mse_formchild[X].Height - (mse_radiuscorner));
end;
end;
end else
if (wo_rounded in options.options) then
begin
XDrawarc(appdisp, pmap, shape_gc, 0, 0, mse_radiuscorner , mse_radiuscorner, 0, 360*64);
Expand All @@ -4200,7 +4252,7 @@ function gui_createwindow(const rect: rectty;
XShapeCombineMask(appdisp, id, ShapeBounding, 0, 0, pmap, ShapeSet);

XFreePixmap(appdisp, pmap);

//* register events: ExposureMask for re-drawing, ButtonPressMask
// to capture mouse button press events */

Expand All @@ -4211,7 +4263,14 @@ function gui_createwindow(const rect: rectty;

// fin shape
end;


if (wo_inalldesktops in options.options) then
begin
options.options := options.options + [wo_dock];
valall := $FFFFFFFF;
xchangeproperty(appdisp,id,netatoms[NET_WM_DESKTOP],cardinalatom,32,propmodereplace,@valall,1);
end;

if colormap <> 0 then begin
xfreecolormap(appdisp,colormap);
colormap:= 0;
Expand Down Expand Up @@ -4312,7 +4371,7 @@ function gui_createwindow(const rect: rectty;
end;
end;

gdi_unlock;
gdi_unlock;
end;


Expand Down
6 changes: 4 additions & 2 deletions lib/common/kernel/mseguiglob.pas
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ keyeventinfoty = record
wo_alwaysontop,
wo_ellipse,
wo_rounded,
wo_transparentbackground
wo_transparentbackground,
wo_transparentbackgroundround,
wo_inalldesktops
);
windowoptionsty = set of windowoptionty;
windowtypeoptionty = wo_popup..wo_dnd;
Expand Down Expand Up @@ -323,7 +325,7 @@ egui = class(eerror)
noreconfigurewmwindow: boolean;
toplevelraise: boolean;
nostaticgravity: boolean;
mse_radiuscorner : integer = 22;
mse_radiuscorner : integer = 8;
// exabug: boolean;
// nocreatestaticgravity: boolean;

Expand Down
34 changes: 33 additions & 1 deletion lib/common/kernel/windows/mseguiintf.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2954,6 +2954,10 @@ function gui_createwindow(const rect: rectty;
windowstyleex:= windowstyleex or ws_ex_noactivate;
end;

if wo_inalldesktops in options then begin
windowstyleex:= windowstyleex or WS_EX_TOOLWINDOW ;
end;

// Thanks to Alexander.
if wo_alwaysontop in options then begin
windowstyleex:= windowstyleex or WS_EX_TOPMOST;
Expand Down Expand Up @@ -3077,8 +3081,36 @@ function gui_createwindow(const rect: rectty;
SetWindowRgn(id, region, True);
DeleteObject(region2);
DeleteObject(region);
end else
if wo_transparentbackgroundround in options then
begin
if length(mse_formchild) = 0 then
begin
region := CreateRoundRectRgn(0,0, rect1.cx, rect1.cy - 1, mse_radiuscorner, mse_radiuscorner);
end else
begin
region := CreateRoundRectRgn(0, 0, 0, 0, 0, 0);

deco_y := GetSystemMetrics(SM_CYFRAME)+
GetSystemMetrics(SM_CYCAPTION);

deco_x := GetSystemMetrics(SM_CXFRAME);

application.processmessages;

for x := 0 to length(mse_formchild) - 1 do
begin
region2 := CreateRoundRectRgn(mse_formchild[x].left + deco_x,mse_formchild[x].top + deco_y,
mse_formchild[x].left + mse_formchild[x].Width + deco_x,
mse_formchild[x].top + mse_formchild[x].height + deco_y,
mse_radiuscorner, mse_radiuscorner);
CombineRgn(region, region, region2, RGN_OR);
end;
end;
SetWindowRgn(id, region, True);
DeleteObject(region2);
DeleteObject(region);
end;


if not (pos = wp_default) and (parent = 0) then begin
result:= gui_reposwindow(id,rect);
Expand Down

0 comments on commit 0943f1a

Please sign in to comment.