Recent

Author Topic: (Solved) that possible to make QWindow appear on all Virtual Desktop with Xlib?  (Read 1512 times)

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
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
  • Do not set the ShowInTheTaskbar! Leave it stDefault >:D (previously I set the property to stNever, that's why it won't work! I ended up in the corner of my room because of frustration /justkidding)
  • I don't know why, I need to use both _NET_WM_WINDOW_TYPE_DOCK (this one must be using XMapRaised, or the window is gone somewhere I don't know. It's on all Desktops and it shown in the Plasma Panel's Virtual Desktop Manager, but you can't see anywhere in the screen) and _NET_WM_DESKTOP!

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.
« Last Edit: June 26, 2022, 10:25:35 pm by AFFRIZA 亜風実 »
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #1 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #2 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.

With 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
« Last Edit: June 19, 2022, 01:15:50 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #3 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
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #4 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

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.

With 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.
« Last Edit: June 19, 2022, 01:47:38 pm by Dio Affriza »
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #5 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #6 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.
« Last Edit: June 19, 2022, 02:37:35 pm by Dio Affriza »
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #7 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #8 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
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #9 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.
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #10 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
« Last Edit: June 20, 2022, 05:29:20 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 144
Re: Is that possible to make QWindow appear on all Workspace with Xlib?
« Reply #11 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
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

 

TinyPortal © 2005-2018