virtual desktop - spaces

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

virtual desktop - spaces

Post by RobertC » Sat Feb 23, 2019 3:56 pm

Hello,

I have an application that I always want to be visible, whatever space (aka virtual desktop) I'm working on.
The message desktopChanged is sent when the screen's definition(*) or aspect ratio changes, but apparently not when I go to a different space on the same screen.
The screenRects is not changed either.

This is probably very macOS specific, though Windows also has virtual desktops.
(don't ask me why I want to do it; I just want the small window of this standalone application to sit in the same corner of the physical screen, irrespective of which space I have active).

Anyone any idea?

Robert.

(*) alas wrongly known as "resolution")
The Old Rant Robert.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9354
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: virtual desktop - spaces

Post by richmond62 » Sat Feb 23, 2019 5:16 pm

This is probably very macOS specific, though Windows also has virtual desktops.
No it isn't: Many types of Linux also have virtual desktops.

But whether this can be implemented in a truly cross-platform fashion is another
question.

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: virtual desktop - spaces

Post by RobertC » Sat Feb 23, 2019 5:53 pm

Sorry, yes, Linuxes also have them. And if Apple continues the way it goes, I'll have to switch to one of them soon.

Agreed also that it is not easy to implement. So I guess the answer must be that for the time being it is not available, i.e. I can't find out, at least not from LiveCode. I thought desktopChanged might give a hint, but it does not.
If there were a command-line incantation to list the available virtual desktops and find out which one I'm on, then I could do it in a non-cross-platform way and it would be good enough. But so far I've not found anything either.
The Old Rant Robert.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9354
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: virtual desktop - spaces

Post by richmond62 » Sat Feb 23, 2019 7:11 pm

I have just been "farting around" with LiveCode on a Linux box
I have here and noticed something that may or may not be significant.

LiveCode 9.0.3 RC-1, Xubuntu 19.04 Beta, 64-bit.

If, having opened LiveCode on one virtual desktop (let's be original and call that desktop #1),
then opening a stack, then dragging that stack to another virtual desktop (#2) via the "Workspace
Switcher
" on one of my panels (think Dock/Start Menu), the stack and the revTools stack appear
on desktop #2, but the revMenuBar stack remains on #1.

If I then click revMenuBar/Window/nameOfMyStack the stack "magically" reappears on desktop #1.

Now, maybe, "all one has to do" (think of those quotation marks as extreme sarcasm) is work
out how to send the revMenuBar/Window/nameOfMyStack every time the end-user changes their virtual
desktop . . .

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9354
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: virtual desktop - spaces

Post by richmond62 » Sat Feb 23, 2019 7:26 pm

I cannot work out how to call the

window activation process.

That might be a load of old "bollo" come to think of things.

Possibly:

PseudoCode
:

on virtualDesktopChange
topLevel stack "MyStack"
end virtualDesktopChange


On Linux, at least, if one calls up the Message Box on a virtual desktop where the
stack is not visible and does this:

topLevel stack "virtually useless"

the stack "virtually useless" 'moves' from the virtual desktop where it was previously
visible to the new one.

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: virtual desktop - spaces

Post by RobertC » Sat Feb 23, 2019 8:27 pm

I'll mess around with that a little too.
This code works:

Code: Select all

global gRun

on OpenStack
   put true into gRun
   show me
   RunIt
end OpenStack

command RunIt
   hide me
   set the topleft of me to 200,300
   wait 20 ticks
   show me
   if gRun then send "RunIt" to me in 1 seconds
end RunIt
but obviously it's not really efficient.
I could tweak it perhaps, but not quite sure how.
The program is a little clock that my wife uses all the time. It just shows the date and time in a large enough textsize that she can easily read it. She puts it in some corner. There was a freeware to do it, but with Mojave it has gone. So I made this:

Code: Select all

global gRun, gShadow

constant cWeekday = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday"
constant cYear = 1, cMonth = 2, cDay = 3, cHour = 4, cMinute = 5, cSecond = 6, cWeekDayNr = 7

on OpenStack
   lock screen
   set the decorations of me to "system"
   put false into gShadow
   set the shadow of me to gShadow
   set the loc of me to (item 3 of the screenrect)div 2,(item 4 of the screenrect)div 2
   put true into gRun
   unlock screen
   RunCLock
end OpenStack

on RunClock
   put the long time into lTime
   convert lTime to dateitems
   -- The dateitems conversion returns an American weekday number.
   -- Convert this to standard weekday number:
   -- Day:               M  T  W  T  F  S  S    Day of the week
   -- nr:                2  3  4  5  6  7  1    American number
   -- real:              1  2  3  4  5  6  7    Standard number
   -- real -1:           0  1  2  3  4  5  6    this looks like the result of a mod 7 operation
   -- nr+5:              7  8  9 10 11 12  6    and this gives real-1 after a mod 7
   -- (nr+5) mod 7 +1:   1  2  3  4  5  6  7    done!
   put ((item cWeekDayNr of lTime)+5) mod 7 +1 into lDay
   set the numberformat to "00"
   put \
         (1*(item cHour of lTime))&":"&(1*(item cMinute of lTime))&":"&(1*(item cSecond of lTime)) \
         &cr& \
         item lDay of cWeekday \
         &cr& \
         (1*(item cYear of lTime))&"-"&(1*(item cMonth of lTime))&"-"&(1*(item cDay of lTime)) \
         into field "DateTime"
   set the textsize of line 1 of field "DateTime" to 30
   set the textsize of line 2 of field "DateTime" to 20
   set the textsize of line 3 of field "DateTime" to 20
   if there is an image 1 then delete image 1
   import snapshot from field "DateTime" with effects
   set the windowshape of this stack to the id of image 1
   if gRun then send "RunClock" to me in 1 second
end RunClock

on MouseDown
   put false into gRun
   if the shiftkey is up then
      -- move the clock
      put the mouseH into lX; put the mouseV into lY
      repeat until the mouse is up
         set the topleft of me to (item 1 of the screenmouseloc -lX, item 2 of the screenmouseloc -lY)
      end repeat
   else
      -- toggle shadow
      set the decorations of me to "system"
      if gShadow then
         set the shadow of me to false
         put false into gShadow
      else
         set the shadow of me to true
         put true into gShadow
      end if
   end if
   put true into gRun
   RunClock
end MouseDown
That's the stack script and there is nothing else. You have to make a field with "opaque" set to false, on a card which preferably has the same background colour as the colour of the text. It works very well and does not take up too much CPU time. But it disappeared when changing spaces.

Robert.
The Old Rant Robert.

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 262
Joined: Mon May 18, 2009 4:12 am

Re: virtual desktop - spaces

Post by wsamples » Sun Feb 24, 2019 4:02 pm

On Linux one would write a simple window rule to do this. It would just tell the window manager to show the app on all desktops. Can't you do that with "Spaces" in MacOS? For a single window app under Linux, at least in KDE Plasma, you can do this with a contextual menu by clicking on an icon in the window's title bar.
Last edited by wsamples on Sun Feb 24, 2019 5:37 pm, edited 1 time in total.

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: virtual desktop - spaces

Post by RobertC » Sun Feb 24, 2019 4:39 pm

Hi wsamples:

From what I understand there is a kernel, which in the case of Linux and macOS should be very similar if not identical, but then above that there are things that vary widely (or should I say "wildly"). The window manager is probably among them, since on macOS it is called WindowServer.
Then from some searching it seems "Spaces" is rather opaque to everyone who is not a deep-systems developer (for which you need to pay Apple).
I would bet that WindowServer will be quite different from the handling of windows in KDE Plasma.
So, yes, I'm sure you are right in that it must be a simple system call: at least these applications on my current machine do keep their windows on the physical screen when switching spaces: Keyboard Maestro clipboard, Dragthing, Finder desktop.
However, it does not seem there is a command-line incantation to do it.
I even searched to see if an Applescript application has a means to do it, because if so, then in LiveCode I could just execute a string "as applescript" but I have so far found nothing.
The Old Rant Robert.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: virtual desktop - spaces

Post by bogs » Sun Feb 24, 2019 5:01 pm

I think from what you are describing you must be talking about a command line option to do this -
Expose / Mission control

This Wikipedia article lists some of the less documented features.

Some others I found -
http://osxdaily.com/2007/06/13/expose-k ... shortcuts/
https://superuser.com/questions/634412/ ... n-mac-os-x
And lastly I found this, which appears to show some of the domains commonly used by apple.
http://www.mactricksandtips.com/2008/02 ... mands.html
Image

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 262
Joined: Mon May 18, 2009 4:12 am

Re: virtual desktop - spaces

Post by wsamples » Sun Feb 24, 2019 5:33 pm

It appears that when you right+click an application's dock icon in MacOS you will see a contextual menu that allows you to assign the app to a specific desktop. You can also assign it to ALL desktops. This should do what you want, no?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9354
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: virtual desktop - spaces

Post by richmond62 » Sun Feb 24, 2019 7:03 pm

It appears that
IFF you have already set up extra desktops: otherwise the contextual menu on a dock icon shows nothing:

https://appleinsider.com/articles/18/10 ... ty-feature

Apple have been b*ggering around with their much-vaunted SPACES, and have not really
done much to make them easy to use like the multiple desktop thingies on Linux distros,
or this thing for MacOS 10.3-10.5 PPC that really rocked:
-
WorkspaceManager.png
WorkspaceManager.png (20.72 KiB) Viewed 9956 times
-
or this thing:
-
Deskswitch.png
-
Personally the thing (SPACES that is) is such a pig-in-a-poke I just jacked 2 oldy-mouldy
second-hand monitors into two of the thunderbolt sockets via some fancy converters
to 'embrace' my main monitor plugged into the HDMI socket.
-
TriplePlay.jpg
-
And, before you ask: https://youtu.be/NnqGVX8cfQo. 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9354
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: virtual desktop - spaces

Post by richmond62 » Sun Feb 24, 2019 7:30 pm

when you right+click an application's dock icon in MacOS you will see a contextual menu that allows you to assign the app to a specific desktop. You can also assign it to ALL desktops. This should do what you want, no?
Yes, this, undoubtedly is what s/he wants.

But they do not want to depend on the end-user to do that via the macOS dock,
they want the standalone to "tickle" the system to do it automatically.

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 262
Joined: Mon May 18, 2009 4:12 am

Re: virtual desktop - spaces

Post by wsamples » Sun Feb 24, 2019 7:41 pm

Can you find where Spaces stores its configuration file that tells it where to put things? This would be a per user config. If you can find it and read and write to it, you could be able to duplicate the configuration for some other app that displays on all desktops with your own app. You could have the app open a dialog asking the user for permission to do that on first launch.
Last edited by wsamples on Sun Feb 24, 2019 7:44 pm, edited 1 time in total.

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 262
Joined: Mon May 18, 2009 4:12 am

Re: virtual desktop - spaces

Post by wsamples » Sun Feb 24, 2019 7:44 pm

richmond62 wrote:
Sun Feb 24, 2019 7:03 pm
Apple have been b*ggering around with their much-vaunted SPACES, and have not really
done much to make them easy to use like the multiple desktop thingies on Linux distros,
or this thing for MacOS 10.3-10.5 PPC that really rocked:

WorkspaceManager.png
I used and loved CodeTek's VirtualDesktop Pro until Apple killed it with changes to the OS. That was a great piece of software. Spaces was never, for me, an adequate substitute.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9354
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: virtual desktop - spaces

Post by richmond62 » Sun Feb 24, 2019 9:12 pm

a simple window rule
Why, every time I see or hear the word "simple" do I feel a bit funny?

The problem is that, as far as I can tell, LiveCode stacks/standalones are very good at
"talking to themselves", but not much good at talking to other applications or part of
an operating system.

Now while it may be "simple" to set up a rule inwith a Linux OS itself,
I'm not sure how a LiveCode stack could "talk" to any of the multitude
of windowing managers that float around on Linux installations.

To give a very basic example of this:

I "normally" run Xubuntu on PCs I deploy for various things
[that's the variant of Ubuntu that sports the XFCE desktop].

In a fit of something a bit daft I recently installed Ubuntu MATE on a laptop
[the variant of Ubuntu with the MATE desktop] and got a bit "frazzled"
when I found the virtual desktop "thing" did not behave in the way the
XFCE one does [prefer the XFCE one].

Now Linux distros are a minefield of distros, desktops, windowing managers,
file browsers and so on: in fact I am quite sure that it would be possible to
have as many combinations of variables as there are Linux users. How one
can make anything "simple" to take all those variables into account escapes me.

Post Reply

Return to “Mac OS”