[Solved] Linux Workspace 2-4

Post your Gambas programming questions here.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Linux Workspace 2-4

Post by BruceSteers »

fixed following on gnome/cinnamon/kde with this..
Public Sub ShiftWorkSpace((Direction) As Integer, Optional Follow As Boolean)

  Dim xw As DesktopWindow = New DesktopWindow(Me.Handle)

  Select Direction
    Case Move_Right
      If Desktop.Type = "MATE" Then xw.Move(Screen.Width + Me.X, Me.Top) Else xw.Desktop += 1
    Case Move_Left
      If Desktop.Type = "MATE" Then xw.Move(0 - Screen.Width + Me.X, Me.Top) Else xw.Desktop = Max(xw.Desktop - 1, 0)
  End Select

  If Follow Then
    If Desktop.Type = "MATE" Then
      Me.Activate
    Else
      X11.CurrentDesktop = If(Direction = Move_Right, X11.CurrentDesktop + 1, Max(X11.CurrentDesktop - 1, 0))
    Endif
  Endif

End

seems MATE works differently to everything else :-\
If at first you don't succeed , try doing something differently.
BruceS
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: Linux Workspace 2-4

Post by grayghost4 »

That work fine on my Kubuntu
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Linux Workspace 2-4

Post by BruceSteers »

Right then i have done this work...
BruceS on gambas M/L wrote: 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. (https://specifications.freedesktop.org/ ... 01s02.html / 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 https://specifications.freedesktop.org/ ... 01s03.html

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.


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.


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)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Linux Workspace 2-4

Post by BruceSteers »

Update for what it's worth..

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
If at first you don't succeed , try doing something differently.
BruceS
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Linux Workspace 2-4

Post by AndyGable »

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.
Last edited by AndyGable on Sunday 30th October 2022 10:43pm, edited 1 time in total.
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Linux Workspace 2-4

Post by AndyGable »

BruceSteers wrote: Friday 21st October 2022 9:40pm I found a way that works...

this way moves the current active window to workspace to the right of the current one.
  X11.MoveWindow(X11.ActiveWindow, Screen.W + 100, Me.Top)
Or this for a specific window...

Public Sub btn2_Click()

  Form2.Show
  Dim iActiv As Integer = X11.ActiveWindow ' for some reason if you do not use this line the next line crashes gambas

  X11.MoveWindow(Form2.Id, Screen.W + Form2.X, form2.Top)

End



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)
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Linux Workspace 2-4

Post by BruceSteers »

AndyGable wrote: Sunday 30th October 2022 10:31pm
BruceSteers wrote: Friday 21st October 2022 9:40pm I found a way that works...

this way moves the current active window to workspace to the right of the current one.
  X11.MoveWindow(X11.ActiveWindow, Screen.W + 100, Me.Top)
Or this for a specific window...

Public Sub btn2_Click()

  Form2.Show
  Dim iActiv As Integer = X11.ActiveWindow ' for some reason if you do not use this line the next line crashes gambas

  X11.MoveWindow(Form2.Id, Screen.W + Form2.X, form2.Top)

End



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.
If at first you don't succeed , try doing something differently.
BruceS
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Linux Workspace 2-4

Post by AndyGable »

BruceSteers wrote: Wednesday 19th October 2022 8:36pm 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...
MyForm.Move(Screen.Width + 100, 100)
MyForm.Show
Sorry my bad it should have been this one
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Linux Workspace 2-4

Post by BruceSteers »

AndyGable wrote: Sunday 30th October 2022 10:29pm 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
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Linux Workspace 2-4

Post by BruceSteers »

For physical screens i found the following...

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..
$ xprop -root -notype _GTK_WORKAREAS_D0
in gambas
Dim aDims as Integer[] = X11.GetWindowProperty(X11.RootWindow, "_GTK_WORKAREAS_D0")
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)
If at first you don't succeed , try doing something differently.
BruceS
Post Reply