Hi All,
I want to create a borderless non modal form (native Windows and Linux-Qt) which not catch the focus on mouse click. Tried with modified ControlStyle and CanFocus override but without success. Any other idea?
Gabor

Mailing lists / lazarus / 2015-10
19 messages · 3 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi All,
I want to create a borderless non modal form (native Windows and Linux-Qt) which not catch the focus on mouse click. Tried with modified ControlStyle and CanFocus override but without success. Any other idea?
Gabor
IIRC you can use THintWindow as ancestor. See particularly THintWindow.WMNCHitTest that does the job.
Ondrej
I want to create a borderless non modal form (native Windows and Linux-Qt) which not…
IIRC you can use THintWindow as ancestor. See particularly THintWindow.WMNCHitTest that does the job.
Ondrej
I want to create a borderless non modal form (native Windows and Linux-Qt) which not…
csNoFocus does not work for Qt ? Can you provide example ? For Qt: before example try to include qt4 and qtwidgets into your unit and then
in CreateWnd of your custom form (or after form handle is created)
TQtMainWindow(YourForm.Handle).SetFocusPolicy(QtNoFocus);
TQtMainWindow(YourForm.Handle).WindowArea.SetFocusPolicy(QtNoFocus);zeljko
Of course , you can try with THintWindow as Ondrej mentioned, but if form is bsNone than it should not take focus. Don't know what happens with framed forms on linux....if you click on frame then X11 rules are unpredictible.
Also, you can set QWidget attribute QtWA_ShowWithoutActivating, but that should be setted up before form is shown (eg in FormCreate call HandleNeeded and set focusPolicy and attributes). See QtWSControls/qtint, there's dnd imagelist operation and we are using ShowWithoutActivating etc ...
zeljko
IIRC you can use THintWindow as ancestor. See particularly THintWindow.WMNCHitTest that…
2015.10.27. 16:11 keltez?ssel, Ondrej Pokorny ?rta:
IIRC you can use THintWindow as ancestor. See particularly THintWindow.WMNCHitTest that does the job.
WMNCHitTest works on Windows but not fired with Linux-Qt.
Gabor
csNoFocus does not work for Qt ? Can you provide example ? For Qt: before example try to…
2015.10.27. 16:16 keltez?ssel, Zeljko ?rta:
WindowArea not exist, found ScrollAera which is TQtWindowArea type. But not have any effect for me. Example attached (without Qt and WMNCHitTest trick).
Gabor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Form_Focus.tar.gz
Type: application/gzip
Size: 1728 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151027/52c56fd2/attachment-0001.bin>
Yes, sorry, I've mistyped ... written from memory.
But not have any effect for me. Example attached (without Qt and WMNCHitTest trick).
WMNCHitTest is windows only thing afair, but I'll check your example with Qt under linux.
zeljko
2015.10.27. 16:16 keltez?ssel, Zeljko ?rta: WindowArea not exist, found ScrollAera which…
Please test with attached patch and give feedback. Note that this patch is tested under Qt X11 only.
zeljko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_activation_fix.diff
Type: text/x-patch
Size: 1245 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151028/4da5f2f8/attachment.bin>
2015.10.28. 10:59 keltez?ssel, Zeljko ?rta:
With the original example works but...
Modified the example...
procedure TForm1.Button1Click(Sender: TObject);
var
MyForm:TMyForm;
begin
MyForm:=TMyForm.CreateNew(Nil);
with TButton.Create(MyForm) do Parent:=MyForm;
MyForm.Show;
end;The button appear on the form only if modify ControlStyle in the example from
ControlStyle:=ControlStyle+[csNoFocus,csNoStdEvents]-[csCaptureMouse,csClickEvents];
to
ControlStyle:=ControlStyle+[csNoFocus]-[csCaptureMouse,csClickEvents];(csNoStdEvents removed) but after form grab focus if click on it or click on the button.
Gabor
I'll check that. csNoStdEvent is passed to form inside Qt widgetset
(csNoStdEvents removed) but after form grab focus if click on it or click on the button.
Ok, then go to QtWSForms, TQtWSCustomForms.UpdateWindowFlags and comment if csNoStdEvents ..... leave only
Flags := Flags or QtX11BypassWindowManagerHint;
in this case form will not take focus in any case, but must see what happens with parenting (button is not visible because of this param I guess).
zeljko
2015.10.28. 11:51 keltez?ssel, Zeljko ?rta:
Commented out "if csNoStdEvents..." line. Button not visible on form with out without csNoStdEvents in ControlStyle.
Gabor
2015.10.28. 13:06 keltez?ssel, Gabor Boros ?rta:
with out without
with or without
2015.10.28. 11:51 keltez?ssel, Zeljko ?rta: Commented out "if csNoStdEvents..." line.…
Yes, QtX11BypassWindowManagerHint does strange things and that's not documented in Qt :(
Really don't know how to achive that goal under X11. Tried pure Qt application and have same problem. Shown form does not activate and that's fine, but when I click on it then it activates :(
zeljko
2015.10.28. 11:51 keltez?ssel, Zeljko ?rta: Commented out "if csNoStdEvents..." line.…
seem that we are not lucky with Qt4.
I've readed a bit Qt5 docs and it seem that it's fixed there with new attributes like:Qt::WA_X11DoNotAcceptFocus and windowFlags like Qt::WindowDoesNotAcceptFocus.
zeljko
2015.10.28. 11:51 keltez?ssel, Zeljko ?rta: Commented out "if csNoStdEvents..." line.…
Please check with attached patch (same name as previous one). Seem that our C bindings does not have all attributes translated since they did not exist in Qt-4.5, but sometime later. I've added strict X11 attribute and now it does not steal activation or focus, even if clicked with mouse (tested with your example with button).
zeljko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_activation_fix.diff
Type: text/x-patch
Size: 987 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151028/8e65fdd9/attachment.bin>
2015.10.28. 14:12 keltez?ssel, Zeljko ?rta:
Tested with fixes_1_4 and trunk. Works like a charm! :D Thank you very much!
Report as a bug in the tracker?
A previous fix... Please add commit 50139 to merge requests for fixes_1_4.
Gabor
Yes please, attach there example and my latest patch :)
A previous fix... Please add commit 50139 to merge requests for fixes_1_4.
Done.
zeljko
2015.10.28. 15:25 keltez?ssel, Zeljko ?rta:
> > Report as a bug in the tracker? Yes please, attach there example and my latest patch :)
Done.
http://bugs.freepascal.org/view.php?id=28922
> A previous fix... Please add commit 50139 to merge requests for > fixes_1_4. Done.
I see it. Thank you!
Gabor