Lazarus

Programming => Widgetset => QT => Topic started by: AFFRIZA 亜風実 on June 19, 2022, 12:44:18 pm

Title: (Solved) that possible to make QWindow appear on all Virtual Desktop with Xlib?
Post by: AFFRIZA 亜風実 on June 19, 2022, 12:44:18 pm
Something like:
Code: Pascal  [Select][+][-]
  1. uses
  2.   ..., Qt, QtWidgets;
  3. ...
  4. procedure TfrDock.FormShow(Sender: TObject);
  5. var
  6.   SelfWindow: TWindow;
  7.   Atom: TAtom;
  8.   prop: culong;
  9. begin
  10.   Atom := XInternAtom(Display, '_NET_WM_DESKTOP', LongBool(1));
  11.   SelfWindow := QWidget_winId(TQtMainWindow(Self.Handle).Widget);
  12.   XChangeProperty(Display, SelfWindow, Atom, XA_CARDINAL,
  13.     32, PropModeReplace, @prop, 1);
  14.  
  15.   XMapWindow(Display, SelfWindow);
  16. end;
  17.  
  18.  

EDIT:
I finally found the solution

And finally, here's the code:
Code: Pascal  [Select][+][-]
  1. procedure TXWindowList.SetDockedMode(Window: TWindow);
  2. var
  3.   wmtype, wmdesktop, wmdock: TAtom;
  4.   prop: culong;
  5. begin
  6.   wmtype := XInternAtom(display, '_NET_WM_WINDOW_TYPE', False);
  7.   wmdock := XInternAtom(display, '_NET_WM_WINDOW_TYPE_DOCK', False);
  8.   wmdesktop := XInternAtom(display, '_NET_WM_DESKTOP', False);
  9.   prop := $FFFFFFFF;
  10.   XChangeProperty(fDisplay, Window, wmtype, XA_ATOM,
  11.     32, PropModeAppend, @wmdock, 1);
  12.   XMapRaised(fDisplay, Window);
  13.  
  14.   XChangeProperty(fDisplay, Window, wmdesktop, XA_CARDINAL,
  15.     32, PropModeReplace, @prop, 1);
  16.   XMapWindow(fDisplay, Window);
  17. end;  
  18.  
  19. // should activate window after this, not from TForm but from Xlib.
  20.  
  21.  

Conclusion: I don't want to be dictated "you should use wmctrl" (seriously, 2 replies mentioned this even I already replied I don't want to use that) or "you should use (insert other library dependency)", those things doesn't answer the asked message. If it Xlib then answer Xlib, if it Wayland then answer Wayland, if you don't know then don't type anything. Also, there's no question about Raspberry or any barebone display library thing. I asked about possibility on Xlib, and that's mean it should be done on X! Especially when the person mentioned "I want to keep Plasma", so that supposed to work on KWin. Don't ruin the topic with bloated meaningless out of context replies. If someday any people who need to find this topic again, they won't getting lost on bunch of non-helping replies. Like typing, "you may be want to use inotify to monitor the disk change but it won't work on Windows, you should use Library(TM) to use this as a crossplatform solution" when the asking people not intended their app to run on Windows, that's not an answer.
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: MarkMLl on June 19, 2022, 01:00:07 pm
What is a workspace in this context? I'm not sure but I suspect that this is a Window Manager concept, and that it's handled by minimise/restore operations (compared with Windows's support for WindowStations as a layer of abstraction).

MarkMLl
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: Fred vS on June 19, 2022, 01:01:45 pm
Hello.

Sorry to disturb you with Qt but...

If you want something that will not need any dependencies and will have full control on what Xlib/X11 can do, maybe you may think to use MSEgui (https://github.com/mse-org/mseide-msegui).

With MSEgui (https://github.com/mse-org/mseide-msegui), all what you asked in your last posts, (custom toolbar with transparent background, use of BGRABitmap, etc) can be done, easy and without any dependencies.
You may even create what you want for a "pure" X11 system, where no one widget set is installed (even without GTK2).
Of course it will work also on systems with GTK2, QT, KDE, ... installed.

[EDIT] And it will be compatible with Wayland/XWayland.

And the same code can be used for Windows, with direct access to windows-gdi low level.

Fre;D
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: dbannon on June 19, 2022, 01:05:44 pm
While you might get that to work on some desktops, I think it would be unlikely to do so on a wayland controlled one.

A better approach might be to use wmctrl to switch the window of interest to the current workspace.

Davo
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: AFFRIZA 亜風実 on June 19, 2022, 01:45:45 pm
What is a workspace in this context? I'm not sure but I suspect that this is a Window Manager concept, and that it's handled by minimise/restore operations (compared with Windows's support for WindowStations as a layer of abstraction).

MarkMLl
Yeah, kind of like Window Manager concept but I don't want to make a full scale WM, just the task manager. I think the correct word is Virtual Desktop, I'm not sure which one (I guess?).
Currently it works really well but the problem is if switch to desktop 2, the taskbar just gone. Or, should I make multiple form?

The project repository is here: https://github.com/kirana-a2district/samarinda-dock (https://github.com/kirana-a2district/samarinda-dock)

Hello.

Sorry to disturb you with Qt but...

If you want something that will not need any dependencies and will have full control on what Xlib/X11 can do, maybe you may think to use MSEgui (https://github.com/mse-org/mseide-msegui).

With MSEgui (https://github.com/mse-org/mseide-msegui), all what you asked in your last posts, (custom toolbar with transparent background, use of BGRABitmap, etc) can be done, easy and without any dependencies.
You may even create what you want for a "pure" X11 system, where no one widget set is installed (even without GTK2).
Of course it will work also on systems with GTK2, QT, KDE, ... installed.

[EDIT] And it will be compatible with Wayland/XWayland.

And the same code can be used for Windows, with direct access to windows-gdi low level.

Fre;D
Wow, interesting, I'll check that. But for now, I think I'm quite happy with Qt.

While you might get that to work on some desktops, I think it would be unlikely to do so on a wayland controlled one.

A better approach might be to use wmctrl to switch the window of interest to the current workspace.

Davo
Actually, I only want my app only in X11 for now. I'll try to use wmctrl but I it possible I want the dependency is minimum.
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: MarkMLl on June 19, 2022, 02:16:15 pm
Yeah, kind of like Window Manager concept but I don't want to make a full scale WM, just the task manager. I think the correct word is Virtual Desktop, I'm not sure which one (I guess?).
Currently it works really well but the problem is if switch to desktop 2, the taskbar just gone. Or, should I make multiple form?

An X11/unix Window Manager is not a concept, it's a specific term for the subsystem which provides the "furniture" around Windows including scrollbars and the buttons on the title bar.

Traditionally, you could stop the current Window Manager and replace it with a different one... something that might be more difficult now that it typically includes the desktop environment's taskbar etc. And while some WMs supported multiple Virtual Desktops hence also a "pin" button, others didn't. See https://en.wikipedia.org/wiki/Fvwm

MarkMLl
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: AFFRIZA 亜風実 on June 19, 2022, 02:35:13 pm
An X11/unix Window Manager is not a concept, it's a specific term for the subsystem which provides the "furniture" around Windows including scrollbars and the buttons on the title bar.

Traditionally, you could stop the current Window Manager and replace it with a different one... something that might be more difficult now that it typically includes the desktop environment's taskbar etc. And while some WMs supported multiple Virtual Desktops hence also a "pin" button, others didn't. See https://en.wikipedia.org/wiki/Fvwm

MarkMLl
Yeah, but I don't want to make a Window Manager, just the taskbar. I want to keep a minimal plasma panel on the top while my app handle the minimize and maximize event, just let the KWin doing it's job. But, I think that's not my question.

There's also something called Conky system monitor that can make them displayed on all virtual desktop, I just thinking to doing like that since this is more for Free Pascal showcase in my place to make many Free Pascal app examples as possible. In this show case I want to make a taskbar for KDE, something like a LatteDock, and I have a problem to display the window in all virtual desktops.
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: MarkMLl on June 19, 2022, 02:55:48 pm
Yeah, but I don't want to make a Window Manager, just the taskbar.

I didn't say you did. I said that "Window Manager" was a specific X11 subsystem, implied that there was functionality you might not be able to usurp, and pointed you at something that confirmed that "Virtual Desktop" might actually be the correct phrase.

I believe that there is a Window Manager control library but it might not be installed by default, a quick grep doesn't yield the name. I don't know the extent to which this is distinct from sending control messages, and in any event the current Window Manager- and I remind you of peculiarities like the Raspberry Pi where they provide their own- might or might not implement the facility you're asking for.

MarkMLl
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: Fred vS on June 19, 2022, 04:09:24 pm
Something like:
Code: Pascal  [Select][+][-]
  1. uses
  2.   ..., Qt, QtWidgets;
  3. ...
  4. procedure TfrDock.FormShow(Sender: TObject);
  5. var
  6.   SelfWindow: TWindow;
  7.   Atom: TAtom;
  8.   prop: culong;
  9. begin
  10.   Atom := XInternAtom(Display, '_NET_WM_DESKTOP', LongBool(1));
  11.   SelfWindow := QWidget_winId(TQtMainWindow(Self.Handle).Widget);
  12.   XChangeProperty(Display, SelfWindow, Atom, XA_CARDINAL,
  13.     32, PropModeReplace, @prop, 1);
  14.  
  15.   XMapWindow(Display, SelfWindow);
  16. end;
  17.  
  18.  

Hello.

Did you try with this?:

Code: Pascal  [Select][+][-]
  1. ...
  2.  prop:= $FFFFFFFF;
  3.  XChangeProperty(Display, SelfWindow, Atom, XA_CARDINAL,
  4.     32, PropModeReplace, @prop, 1);
  5. ...

You may try also setting prop := 0, prop := 1, prop := 2, ... to set each virtual desktop.

See here:
https://stackoverflow.com/questions/43376991/stick-c-app-to-all-desktops
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: AFFRIZA 亜風実 on June 19, 2022, 06:42:35 pm
Hello.

Did you try with this?:

Code: Pascal  [Select][+][-]
  1. ...
  2.  prop:= $FFFFFFFF;
  3.  XChangeProperty(Display, SelfWindow, Atom, XA_CARDINAL,
  4.     32, PropModeReplace, @prop, 1);
  5. ...

You may try also setting prop := 0, prop := 1, prop := 2, ... to set each virtual desktop.

See here:
https://stackoverflow.com/questions/43376991/stick-c-app-to-all-desktops
I have read that. Anyway, after wondering around and reading the KWin source I finally found the solution. I'll update the code of the post.
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: Fred vS on June 20, 2022, 01:13:51 am
I'll update the code of the post.

Hello Dio Affriza.

I have tested your code for MSEgui and it works here for all kind of windows  using only this (not _NET_WM_WINDOW_TYPE_DOCK) :

[EDIT] You are right, with NET_WM_WINDOW_TYPE_DOCK the window is shown in other desktops.
Otherwise the form is minimized in other desktops.

Many thanks for your exploration, I did learn very interesting things (that I added to MSEgui  ;)).

[EDIT] For Windows GDI, in CreateWindowex(...) , set parameter dwExStyle to WS_EX_TOOLWINDOW.

Fre;D
Title: Re: Is that possible to make QWindow appear on all Workspace with Xlib?
Post by: AFFRIZA 亜風実 on June 20, 2022, 06:11:00 am
Hello Dio Affriza.

I have tested your code for MSEgui and it works here for all kind of windows  using only this (not _NET_WM_WINDOW_TYPE_DOCK) :

[EDIT] You are right, with NET_WM_WINDOW_TYPE_DOCK the window is shown in other desktops.
Otherwise the form is minimized in other desktops.

Many thanks for your exploration, I did learn very interesting things (that I added to MSEgui  ;)).

[EDIT] For Windows GDI, in CreateWindowex(...) , set parameter dwExStyle to WS_EX_TOOLWINDOW.

Fre;D
I'm glad if that's also helps  ;) With experiment like this it will expand the code samples and tutorials, I hope many people will know Pascal can do anything and make it great again.  8)
This is the video demo anyway: https://youtu.be/UDU7pO8G0nM (https://youtu.be/UDU7pO8G0nM)
TinyPortal © 2005-2018