Moving a borderless window with wayland

Post

Posted
Rating:
#1 (In Topic #1579)
Guru
BruceSteers is in the usergroup ‘Guru’
Initially Wayland presented a problem with moving borderless windows by code.

Previous code made to move a window would no longer work.
For example lets say i have a panel pnlMove on my form that when left mouse is pressed and dragged the window moves with the mouse.

The code to move the window might be like this..

Code (gambas)

  1. Public Sub plnMove_MouseMove()
  2.  
  3.   If Mouse.Left Then Me.Move(Me.ScreenX + (Mouse.X - Mouse.StartX), Me.ScreenY + (Mouse.Y - Mouse.StartY))
  4.  
  5.  
The above code will only work on X systems not with wayland.

But now there is a new way (Since gambas 3.21) with Window.StartMove method. /comp/gb.qt4/window/startmove - Gambas Documentation
It works like when you right click a Taskbar item and select move.

The following code will move the window while you hold the mouse on pnlMove then stop the move when mouse is released…

Code (gambas)

  1. Public Sub plnMove_MouseDown()
  2.  
  3.   Me.StartMove
  4.  
  5.  

This allows a borderless window with no title bar to be moved around the screen with the mouse, even on wayland.

Still no way to manually set the position by code on program startup but at least there's now a way to move borderless widows with a mouse.
Online now: No Back to the top
1 guest and 0 members have just viewed this.