Move window with no titlebar
Move window with no titlebar
Is there any way to move a borderless window in Linux (without using the ALT key and the mouse button) like it can be done in Windows with WM_NCHITTEST & HTCAPTION?
Re: Move window with no titlebar
I would also like to know
Re: Move window with no titlebar
This is what I have been able to do:Instead of a callback can the button press event trigger a window move event like the Windows way:GTK has a builtin function gtk-window-move to do this but I don't know how to call it.
Any Linux devs can help?
Code: Select all
Procedure Callback(*udata)
Debug "move window routine?"
EndProcedure
hWnd = OpenWindow(0, 0, 0, 300, 300, "Linux Callback", #PB_Window_ScreenCentered)
g_signal_connect_(hWnd, "button-press-event", @Callback(), #Null)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Select all
SendMessage_(WindowID(#win), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
Code: Select all
g_signal_connect_(hWnd, "button-press-event", gtk-window-move, #Null) ;does not work!
Re: Move window with no titlebar
That's how I work a click event
Code: Select all
ImportC "-gtk"
g_signal_connect(instance,signal.p-ascii,*Callback,*user_data,destroy=0,flags=0) As "g_signal_connect_data"
EndImport
ProcedureC Callback(*widget.GtkWidget,*event.GdkEventButton,user_data)
Select *event\button
Case 1
Debug "left "
Case 3
Debug "right"
EndSelect
EndProcedure
hWnd = OpenWindow(0, 0, 0, 300, 300, "Linux Callback", #PB_Window_ScreenCentered)
g_signal_connect(hWnd, "button-press-event", @Callback(), #Null)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Move window with no titlebar
like that kind of work
Code: Select all
EnableExplicit
;ImportC "-gtk"
ImportC ""
g_signal_connect(instance,signal.p-ascii,*fn,*vdata,destroy=0,flags=0) As "g_signal_connect_data"
g_signal_connect_data(*instance, signal.p-utf8, *handler, *data, *destroy_data, *connect_flags)
EndImport
ProcedureC Callback(*Widget.GtkWindow, *Event.GdkEventAny, Window)
Static press
Static DeltaX, DeltaY
If *Event\type = #GDK_BUTTON_PRESS
press = 1
DeltaX = WindowMouseX(Window)
DeltaY = WindowMouseY(Window)
ElseIf *Event\type = #GDK_BUTTON_RELEASE
press = 0
EndIf
If press
ResizeWindow(Window,DesktopMouseX()-DeltaX,DesktopMouseY()-DeltaY,#PB_Ignore,#PB_Ignore)
EndIf
ProcedureReturn 1
EndProcedure
Define hwnd = OpenWindow(0, 0, 0, 300, 300, "Linux Callback", #PB_Window_ScreenCentered|#PB_Window_BorderLess)
gtk_widget_add_events_(WindowID (0), #GDK_MOUSE)
g_signal_connect(hwnd, "event", @Callback(), 0)
;g_signal_connect_(hwnd, "button-press-event", @"gtk-window-move", #Null) ;does not work!
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Last edited by mestnyi on Mon Jan 16, 2023 8:25 pm, edited 2 times in total.
Re: Move window with no titlebar
Very good mestnyi!! Ingenious workaround! Thank you.mestnyi wrote:like that kind of workCode: Select all
EnableExplicit ImportC "-gtk" g_signal_connect(instance,signal.p-ascii,*fn,*vdata,destroy=0,flags=0) As "g_signal_connect_data" EndImport ProcedureC Callback(*Widget.GtkWindow, *Event.GdkEventAny, Window) Static press Static DeltaX, DeltaY If *Event\type = #GDK_BUTTON_PRESS press = 1 DeltaX = WindowMouseX(Window) DeltaY = WindowMouseY(Window) ElseIf *Event\type = #GDK_BUTTON_RELEASE press = 0 EndIf If press ResizeWindow(Window,DesktopMouseX()-DeltaX,DesktopMouseY()-DeltaY,#PB_Ignore,#PB_Ignore) EndIf ProcedureReturn 1 EndProcedure Define hwnd = OpenWindow(0, 0, 0, 300, 300, "Linux Callback", #PB_Window_ScreenCentered|#PB_Window_BorderLess) gtk_widget_add_events_(WindowID (0), #GDK_MOUSE) g_signal_connect(hwnd, "event", @Callback(), 0) ;g_signal_connect_(hwnd, "button-press-event", @"gtk-window-move", #Null) ;does not work! Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow