send window to bottom of stack

Post

Posted
Rating:
#1 (In Topic #513)
Guru
BruceSteers is in the usergroup ‘Guru’
Anyone know how to send a window to the bottom or top of the stack?

I'm using the Window object and win.Raise() and win.Lower() do nothing.

setting win.Stacking = Window.Top or Window.Bottom sends to top or bottom but keeps it there and if i set stacking back to normal the window returns to it's position. ?

I'm stumped.
tia

Bruce
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

Anyone know how to send a window to the bottom or top of the stack?…

I notice no one has come back to you on this so I thought I'd ask for clarification.

I've only used Window Raise/Lower in the Ncurses component which is simpler, but worked fine. I had no reason to know where a window was within the 'stack', only how to bring it towards the foreground.

Which component are you using: gtk, qt4, qt5?

So maybe you can post some simple test code?
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
Hi Steve , Cheers :)

Looks like Lower() works okay on QT it's just GTK it does nothing. (didn't think to check QT)

I just tried adding ncurses to the project (and another blank project) and all i got was failure to run saying "Screen is incorrectly overridden in class Screen" ?

I've been making a terminal..
(attachment removed)

unlike the std gambas terminal it supports XTerm window manipulation codes like window resize/minimise/send to back of stack etc.
unlike mate-terminal it also supports "\033[10;2t" (toggle full screen)
Unlike ANY terminal it also supports using ctrl-C and ctrl-V copy/paste text.  (if any text is selected it copies text with ctrl-c press, if no selected text it sends ctrl-c break to term)

but to support the echo -en "\033[6t" to send to back all i could do was use window.stacking as win.Lower() did nothing.
Seems it's a gtk (or gambas) problem though.
Cheers
Bruce

Here's how i've updated the gambas gb.form.terminal object to support CSI t commands..
I sent a merge request but not got any response from Ben.
https://gitlab.com/bsteers4/gambas/-/commits/VT100-WinManipulation-1cmt
[GB.FORM.TERMINAL]

* NEW: various XTerm window manipulation escape sequences added to VT100
* NEW: Added Boolean Property WinManipulation to enable manipulations.

Useful if your terminalview is standalone in a form/window.
Set property TerminalView1.WinManipulations to True and it
enables the following XTerm escape sequences on the top window…
Eg. Type 'echo -en "\033[10;2t"' to toggle fullscreen.\
Handles the following modes…
1, minimize false
2, minimize true
3, move window (x,y)
4, Resize (h,w) in pixels
5, stack front (this sets or unsets Stacking=Window.Above)
6, stack back (this sets or unsets Stacking=Window.Below)
7, Refresh
8, Resize (lines, cols) text characters
9;0 maximize false
9;1 maximize true (also works as true/false toggle)
10;0 full screen off
10;1 full screen on
10;2 full screen toggle\
5 and 6 should ideally just send window to front or back and not set stacking but i do not know how.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
I have done a little research on this. I found that the 'Raise' method works well in both QT & GTK, though GTK is noticeably slower! The 'Lower' method is not as good. So using 'Raise' only I came up with this. Am I getting close to what you want?

<IMG src="https://www.cogier.com/gambas/RaiseWindow.png"> </IMG>

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’

cogier said

I have done a little research on this. I found that the 'Raise' method works well in both QT & GTK, though GTK is noticeably slower! The 'Lower' method is not as good. So using 'Raise' only I came up with this. Am I getting close to what you want?

<IMG src="https://www.cogier.com/gambas/RaiseWindow.png"> </IMG>

That's bizzarre

Seems to work okay on your app.
Does not work on my terminal window with GTK  :(
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

…Looks like Lower() works okay on QT it's just GTK it does nothing. (didn't think to check QT)…

There is a loooong history of Gambas problems with gtk components.

I think this is because Gambas development has always been done in qt
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

…Looks like Lower() works okay on QT it's just GTK it does nothing. (didn't think to check QT)…

There is a loooong history of Gambas problems with gtk components.

I think this is because Gambas development has always been done in qt

I see , i guess it's going to change though as Benoít has set gambas IDE to use GTK by default now so forcing most to use GTK will find all the bugs. (eventually)


BruceSteers said

Hi Steve , Cheers :)
I just tried adding ncurses to the project (and another blank project) and all i got was failure to run saying "Screen is incorrectly overridden in class Screen" ?

Turns out ncurses can only be used in a non-GUI app so I couldn't use it.

My guess (after trying Charlies working example) is it's something to do with TerminalView.
Who knows?  I guess Ben does , I've sent a bug report.

cheers folks :)
Bruce
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

…if any text is selected it copies text with ctrl-c press, if no selected text it sends ctrl-c break to term…

That sounds a bit scary.
Historically, <ctrl><c> was used in editors, and now is more widespread. But its so well known as the way you stop a program running in a terminal, that I'd use the universal terminal method <shift><ctrl><c> for copy and  <shift><ctrl><v> for paste.
Online now: No Back to the top

Post

Posted
Rating:
#9
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

…if any text is selected it copies text with ctrl-c press, if no selected text it sends ctrl-c break to term…

That sounds a bit scary.
Historically, <ctrl><c> was used in editors, and now is more widespread. But its so well known as the way you stop a program running in a terminal, that I'd use the universal terminal method <shift><ctrl><c> for copy and  <shift><ctrl><v> for paste.

I dunno , it seems to work okay.
It checks if you have selected any text. stopping a program with ctrl-c still works fine if no text is selected.

I didn't know about shift + Ctrl-C lol.  Talk about "We learn something new every day" :)
 :D
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

…Turns out ncurses can only be used in a non-GUI app so I couldn't use it…

Yes sorry, Ncurses is for terminal use.

I did a horrible hack on an old ncurses test program earler to check 'Lower'

Code (gambas)

  1. ' Gambas module file
  2.  
  3. Public hTimerScreen As Timer        'screen update timer
  4. Public hUserInterface As Window     'our user interface window
  5. Public hUserInt2 As Window
  6. Public lngCount As Long       'just a trivial counter
  7. Public blnToggleFlag As Boolean
  8. '
  9. Public Sub Main()
  10.  
  11.   'this timer re-writes the screen at 2s intervals
  12.   hTimerScreen = New Timer As "tmrScreenUpdate"
  13.   hUserInterface = New Window(True, 0, 0, 400, 15) As "qWindow"
  14.   hUserInt2 = New Window(True, 5, 10, 200, 15) As "qWindow2"
  15.   hTimerScreen.Delay = 2000
  16.   hTimerScreen.start
  17.  
  18. Public Sub tmrScreenUpdate_Timer()
  19.  
  20.   Inc lngCount
  21.   Screen.Echo = False 'don't display key press
  22.   Screen.Cursor = Cursor.VeryVisible
  23.   With hUserInterface
  24.     .Border = Border.ACS
  25.     .Background = Color.Green
  26.     .Caption = "clock window\r"
  27.     .Print("Counter: " & lngCount, 2, 2, Attr.Blink, Pair[Color.Blue, Color.Green])
  28.     .PrintCenter(Format(Now, "hh:mm:ss"), Attr.Bold, Pair[Color.Black, Color.Green])
  29.     .Print("its a clock", 20, 13, Attr.Underline, Pair[Color.Blue, Color.Green])
  30.     .Raise()
  31.     .SetFocus()
  32.   With hUserInt2
  33.     .Border = Border.ACS
  34.     .Background = Color.Cyan
  35.     .Caption = "whats this window?\r"
  36.     .Print("Counter: " & lngCount, 2, 2, Attr.Blink, Pair[Color.Red, Color.Magenta])
  37.     .PrintCenter(Format(Now, "hh:mm:ss"), Attr.Bold, Pair[Color.Black, Color.Green])
  38.     .Print("...what can I say?", 20, 13, Attr.Underline, Pair[Color.Blue, Color.Green])
  39.     .Raise()
  40.     .SetFocus()
  41.   Toggle
  42.  
  43.  
  44. Public Function Toggle()
  45.  
  46.   If blnToggleFlag Then
  47.     hUserInt2.Lower()
  48.   Else
  49.     hUserInterface.Lower()
  50.   blnToggleFlag = Not blnToggleFlag
  51.  
Online now: No Back to the top

Post

Posted
Rating:
#11
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

…Turns out ncurses can only be used in a non-GUI app so I couldn't use it…

Yes sorry, Ncurses is for terminal use.

I did a horrible hack on an old ncurses test program earler to check 'Lower'

Sadly i can't use it though.
My app is not a terminal program it's a terminal :(
so it's got gb.gui and a TerminalView component rendering ncurses unusable :(

I have an easy hack to get .Raise() working.
win.TopOnly = True
win.TopOnly = False

Raises the window and does not alter Stacking property and leaves window on top.

that works fine but .Lower() does not want to play ball.
Like i said i tried setting the Stacking property to Window.Below but is sends the window to back and when resetting the Stacking back to Window.Normal the window comes to front again :(
Shame there's not a BottomOnly property to set/unset.
Online now: No Back to the top

Post

Posted
Rating:
#12
Guru
BruceSteers is in the usergroup ‘Guru’
Turns out it was a bug.
Ben has fixed it in latest commit <EMOJI seq="1f60e" tseq="1f60e">😎</EMOJI>
Online now: No Back to the top
1 guest and 0 members have just viewed this.