[Solved] Linux Workspace 2-4
Posted
#1
(In Topic #915)
Enthusiast

Is it possible to have a application start on Workspace 1 but move it to another workspace ?
For example my main workspace (workspace 1 on Debian) is where I work on my code but when the app starts i would like it to show in Workspace 2 (the 4 little boxes at the bottom of the screen in Debian linux)
The Idea is I want to load some background apps but have thier windows display on other workspace and keep the main workspace clear
can I do this with Gambas or do I have to load each program I want in each workspace?
Posted
Guru

The workspaces are calculated as one big desktop.
So to open the form at x ,y position 100, 100 on a workspace to the right of the main screen do this…
Code (gambas)
- MyForm.Show
Posted
Guru

BruceSteers said
I believe you can use Form.Move()
The workspaces are calculated as one big desktop.
So to open the form at x ,y position 100, 100 on a workspace to the right of the main screen do this…Code (gambas)
MyForm.Show
Darn my apologies, that does not seem to work
I read this reply from Benoit on stack overflow gambas - GAMBAS3 - show form on second screen - Stack Overflow
Although he is talking about screens there not virtual desktops.
Posted
Guru

this way moves the current active window to workspace to the right of the current one.
Code (gambas)
Or this for a specific window…
Requires the gb.desktop.x11 component
Posted
Guru

and note. this will most definitely NOT work on wayland, it's x11 only.
Posted
Guru

I made a class file..
It's in my project .src called Form.class
EDITED:
Code (gambas)
This saved as Form.class adds workspace switching to all and any of my Forms
So my app can now do this with menu items to shift the window left or right…
PS. the Follow boolean option toggles between moving a window to a workspace and staying on the current workspace or switching workspace with it.
Posted
Guru

this was because i found setting the X11.DesktopWindow.Desktop property did not make the window switch workspace ,, on MATE , but turns out it does on gnome and cinnamon.
So i have modified the above code to make moving left or right work on the other desktops.
making up and down work involves a bit more code and getting info about the layout that i have not got working yet.
Posted
Enthusiast

I have not tried the new code…. yet.
new code makes it work
but it does not follow .
Posted
Enthusiast

And it will follow if there is an open program on the new desktop.
Posted
Guru

I could not get Gambas to do what was wanted, so I took a different tack. I have no idea if it will work in your distro, but here are my efforts.
<VIDEO content="https://www.cogier.com/video/MoveWorkspaces.webm">[video]
<IMG src="https://www.cogier.com/gambas/MoveWorkspaces.png">
</IMG>Run the following code in a Graphical Application
Code (gambas)
- ' Gambas class file
- $iCurrentWS = iGet[1]
- BuildForm
- SetCurrentButton
- SetCurrentButton
- .Height = 400
- .Width = 200
- .Padding = 5
- .Arrangement = Arrange.Vertical
- .Title = "Move me!"
- .Center
- .height = 300
- .Width = 100
- .Text = "Don't follow me."
- .ToolTip = "If checked the program will move by you wont!"
- .Height = 7
- .Height = 28
- .Width = 100
- .Tag = iLoop
- AllButtons.Add(hButton)
Posted
Guru

Code (gambas)
seems MATE works differently to everything else :-\
Posted
Enthusiast

Posted
Guru

BruceS on gambas M/L said
From what I've seen there are 2 ways of implementing virtual desktops with the window managers, one involves multiple viewports and one is one large screen. ( Non-ICCCM features | Extended Window Manager Hints / Implementation note)
It seems gb.desktop.x11 is coded to handle the multiple desktops method but not the single big screen virtual type
I'm almost there with implementing this (see attached project)
the project contains a folder called X11LargeDesktop containing files that add the following to gb.desktop.x11 according to infomation i got from here Root Window Properties (and Related Messages) | Extended Window Manager Hints
X11.DesktopCount and X11.CurrentDesktop now works for large desktops.
DesktopWindow.Desktop now also works for large desktops.
X11.IsLargeDesktop True if large desktop false if multiple viewports.
X11.ViewPorts returns a list of the viewport positions if using large desktop taking Orientation into account. Still todo: handle start corners, currently assumes TopLeft.
X11.Supported As String[], returns a list of the supported wm commands (from hint _NET_SUPPORTED)
X11.GetDesktopNames(DefaultName as String="Workspace") , get's the desktop names or makes them up if not found.
attached is a test app using the above features that has one window that will move to a desktop or change the amount of desktops and another window that will move itself to other desktops.
Adding the X11LargeDesktop folder to your own projects .src folder will automatically enable desktop switching on systems the current gb.desktop.x11 does not support.
<COLOR color="#33CC33">This is better than any of the previous code i have shown that uses
If Desktop.Type = "MATE"
as this uses the proper x11 hint to tell if the window manager is large desktop or multiple viewports. , it is possible to use alternative window managers on MATE so the attached project is much better.
</COLOR>
I've forwarded this code to the gambas M/L and Ben says he'll take a look so hopefully gambas will get the update (re-coded to perfection by Benoit of course) , it's probably just something he didn't know about but as i have paved the way and done some of the groundwork I'll bet he'll accept that handling the "other" desktop method gb.desktop.x11 does not yet support will be a good thing
(see below for code)
Posted
Guru

updates include..
handling for multiple row/column in VirtualRoot desktops taking into account the Orientation, Rows, Columns and the annoying StartCorner properties
Notes: the only desktop i have that uses a VritualRoot is MATE on Mint using compiz and setting multiple rows works in the test app (compiz "desktop cube" has to be disabled and "desktop wall" enabled)
Changing rows/columns works for virtualroot desktops not for multiple viewports
A much better check to see if desktop type is multiple vieports or a virtualroot is done.
I changed the format a bit by making a DesktopRoot.class for VirtualRoot screen handling and 2 functions to get the desktop index from the viewport position (GetIndex([X,Y])) and vice versa get the viewport at ( [X, Y] = DesktopRoot[Index]).
Working out the indexes from the viewport positions and vice versa when start corner is not TopLeft was quite a brain ache.
My head hurts
EDIT:
I uploaded a new version 0.0.12
I forgot to check using Vertical mode with the desktop workspace switcher and hadn't handled it yet (fixed now)
I made the test app hide the Row/Column changer if not showing a virtual root as changing it does not work.
Download is now here
Posted
Enthusiast

Thank you for all the recommendations I'm planning to use this to have all my add on modules on one workspace (workspace 2) and my main application on workspace 1
I am using xfce on Debian 11 now I'm feeling a bit more human I will see about implementing some of the options you all have come up with.
Thanks once again and I am so sorry for not being around on this one for a while.
Posted
Enthusiast

BruceSteers said
I found a way that works…
this way moves the current active window to workspace to the right of the current one.Code (gambas)
Or this for a specific window…
Requires the gb.desktop.x11 component
I assume this would be the code I need though to move my customer display application to the second monitor on my Debian machine (extended desktop to it)
Posted
Guru

AndyGable said
BruceSteers said
I found a way that works…
this way moves the current active window to workspace to the right of the current one.Code (gambas)
Or this for a specific window…
Requires the gb.desktop.x11 component
I assume this would be the code I need though to move my customer display application to the second monitor on my Debian machine (extended desktop to it)
Then you assume incorrectly I'm afraid. another screen is not the same as a workspace.
All the later code I provided was for dealing with workspace changing.
2 monitors should show as a single large area.
You will have to look and move the window accordingly.
Form1.Move() will probably do. No x11 needed.
Posted
Enthusiast

BruceSteers said
I believe you can use Form.Move()
The workspaces are calculated as one big desktop.
So to open the form at x ,y position 100, 100 on a workspace to the right of the main screen do this…Code (gambas)
MyForm.Show
Sorry my bad it should have been this one
Posted
Guru

AndyGable said
Hi everyone sorry for being so silent on this I've been super unwell.
Thank you for all the recommendations I'm planning to use this to have all my add on modules on one workspace (workspace 2) and my main application on workspace 1
I am using xfce on Debian 11 now I'm feeling a bit more human I will see about implementing some of the options you all have come up with.
Thanks once again and I am so sorry for not being around on this one for a while.
All okay fella, glad you're getting better.
I found it all quite enlightening.
i had tried to use the x11 desktop commands to switch workspaces before but it never did anything for me so i thought i was mistaken about something.
with this puzzle i found out it was because i use compiz.
but then i found the workaround
if you do not use compiz then you should be able to use X11.DesktopCount / X11.CurrentDesktop without any of the classes i provided, they only fix the desktop.x11 methods on compiz
Posted
Guru

If the main primary display is to the right of the other display then Screen.X will not show as 0 it will show as the left hand screen width.
That could be useful but if the main display is to the left then Screen.class just shows X as 0 and width as the current display width not the overall size.
you may be able to read _GTK_WORKAREAS_D0
in terminal..
<HIGHLIGHT highlight="shell">
$ xprop -root -notype _GTK_WORKAREAS_D0
</HIGHLIGHT>
in gambas
That will give you info about both displays and their positions, the primary display is the 1st 4 numbers, then next 4 will be the secondary display if there.
you should be able to control positioning from there.
(workareas do not show the total screen size just the "usable" area like Screen.AvailableX, Screen.AvailableWidth, etc)
Posted
Enthusiast

thank you for the information
would there be a reason why when I have FMain.hide or FMain.visible = false the form is still shown
is the first form hide status ignored in Gambas?
Posted
Guru

that will jump to the selected display center screen.
and you can use Me.Window.Screen to detect the display you are currently on but it does not work until the application has loaded (not in Form_Open or Form_Show)
Screens[0] is primary Screens[1] secondary
Posted
Guru

AndyGable said
Cool
thank you for the information
would there be a reason why when I have FMain.hide or FMain.visible = false the form is still shown
is the first form hide status ignored in Gambas?
Without seeing the code it's impossible to guess, but to answer the question, no, the main form is not restricted from hiding.
If i do that my window hides then pops back 3 seconds later even without Persistent set true.
So it's your code somewhere either preventing the window closing or opening it again.
Is there a check to stop the form closing in Form_Close? (setting Persistent should fix that)
a LostFocus() event could be triggered, do you have one regaining focus?.
a .SetFocus() or .Activate() or .EnsureVisible call could cause form to re-show.
Posted
Guru

like before the workspace switching functions but they have been fixed to work with multiple displays.
if more than one monitor my size calculations were incorrect.
Added a class called it BigScreen
BigScreen.Width
BigScreen.Height
Will show the total screen size including both monitors if there are 2, this fixes my previous code.
also now the test app has a screen switching option as well as workspace switching.
It may require some debugging on systems i've not tested it on.
Best wishes
Posted
Guru

It has some updates/fixes to the classes in the above mentioned project.
It's set to work on a System tray icon but the code could probably be easily made to pop open the window via a button in your own project to visually switch workspaces.
I've tried to make it show windows on other workspaces in the selection window while the preview for the current desktop is a screenshot.
Enjoy
1 guest and 0 members have just viewed this.



