Colour picker issue.

Post your Gambas programming questions here.
Post Reply
User avatar
cogier
Site Admin
Posts: 1127
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Colour picker issue.

Post by cogier »

If, for example, you want to change the colour of a Form's background and select the 'Free' option and then use the picker to select a colour on the screen, it always used to show a magnified view of the screen in the area marked in red below. Since Gambas 3.19 this is not working for me. I also notice that if you create a program using the ColorChooser the same issue is repeated. Is this just me, or do others have this issue?

Image
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Colour picker issue.

Post by BruceSteers »

Benoit changed the color picker to use desktop portal

And changed the code.

Here is the code from FColorChooser in gb.form ...

Public Sub txtHexa_Click()

  Dim iColor As Integer
  
  Component.Load("gb.desktop")
  
  iColor = Desktop.PickColor()
  If iColor <> Color.Default Then 
    SetColor(iColor)
    RaiseActivate
  Endif
  
  ' hTimer.Stop
  ' $hZoom = Null
  ' panColor.Refresh

  ' panGrab.Mouse = Mouse.Cross
  ' 'panGrab.Cursor = New Cursor(txtHexa.Picture, 0, txtHexa.Picture.H - 1)
  ' panGrab.Show
  ' panGrab_MouseMove
  ' panGrab.Grab
  ' $hZoom = Null
  ' panColor.Refresh 'SetColor(hPict.Image[0, 0])
  ' panGrab.Hide

End


As you can see the desktop portal method is not as involved.
the commented out old code uses grab and stuff to monitor the mouse movement.

the Desktop.PickColor does not.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1127
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Colour picker issue.

Post by cogier »

Benoit changed the color picker to use desktop portal
I'm not sure I understand what the 'desktop portal' means. How do I pick the specific pixel I want and what is the point of an empty box?
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Colour picker issue.

Post by BruceSteers »

Desktop portal Is a DBus interface supposed to be the next xdg-utils thing.

And I agree, it not as good like that, Maybe ask Ben to put it back as it was.

I'm pretty sure portal ScreenShot does not work on all systems (Fedora iirc)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Colour picker issue.

Post by BruceSteers »

I've fixed it here...
https://gitlab.com/bsteers4/gambas/-/co ... 9688e6c354

I do not know if Benoit removed the feature for a reason (possibly it does not work on wayland)

I messaged the M/L pointing to that commit, maybe Ben will add it or do it his own way or not do it because of wayland?
Only time will tell.....
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1127
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Colour picker issue.

Post by cogier »

Thanks for that. We will see what happens...
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Colour picker issue.

Post by BruceSteers »

Looks like a no.
because of how crap wayland is.

Screenshot and PickColor from desktop portal do not work the same,
they have very few options and demand interaction.

like the screenshot method that with x11 can get any bit of the screen , with portal all it does is open a screenshot dialog.
then Ben has worked around it by copying part of the image after grabbing the whole screen.


Static Public Sub Screenshot(Optional X As Integer, Y As Integer, Width As Integer, Height As Integer) As Picture
  
  Dim hScreenshot As Image
  
  If Desktop.Platform <> "x11" Then
    hScreenshot = DesktopPortal.Screenshot()
    If Width <= 0 Then Width = Desktop.Width - X
    If Height <= 0 Then Height = Desktop.Height - Y
    Return hScreenshot.Copy(X, Y, Width, Height).Picture
  Endif
  
  Try Return Super.Screenshot(X, Y, Width, Height)
  
End



so basically the color being seen as you move the mouse in ColorChooser.class has been ruined by wayland because each call to Desktop.Screenshot to get the pixels will now open the screenshot dialog :(

It will still work on x11 but Benoit says any x11 specific code in gb.desktop will slowly disappear and use desktop portal instead!

God I hate wayland, it sucks so very badly that now it's even making gambas worse.
Damn that's sucky , really really sucky
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Colour picker issue.

Post by BruceSteers »

Right so i tried another merge request.
https://gitlab.com/gambas/gambas/-/merge_requests/337

This one uses the method to show the color in the color box only if using x11 as currently gb.desktop is set to use desktop.portal ONLY if on wayland.

The desktop portal PickColor method shows a nice little magnifying glass for the cursor that displays the color as you move.

So currently if using wayland you CAN see the color in the cursor but if using x there is nothing :(

So if Ben accepts this then it will work again for X11 systems.
Or if he changes x11 to use portal then we'll have the magnifying glass for a cursor showing color anyway.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Colour picker issue.

Post by BruceSteers »

Does not look like Ben wants to make this change.
He's not commented on the merge request. (i just gave him a nudge)

If you want your gambas to do it and you compile then you could replace this file in your branch's /comp/src/gb.form/.src/Color folder and recompile.
https://gitlab.com/gambas/gambas/-/blob ... oser.class
If at first you don't succeed , try doing something differently.
BruceS
Post Reply