Help with title bar

Hey everyone,

I need help to title bar. I am creating an application with my own title bar and I need to know how to get the window to move. This is the same function that done Mozilla, because uses it’s own title bar.

Which is the command or scripts that allow that when I click in the title bar this window to move? And for change the size?

What language or GUI framework are you using…?

I am using C# and GDScript in Godot Engine

This sounds like a question better asked to the Godot people, not KDE :slight_smile: We support everything that’s needed for applications to request system move/resize.

I’m sorry if I didn’t explain myself well.

I need to know the same command/script to move/resize the window from title bar, therefore, this information is belonging to KDE.

I want to use the framework that KDE uses. If it is a Java script or another one that is better (the one you recommend me). I can open the console in Godot and run any script :grinning:

I can be more specific, but only for one platform: Wayland :slight_smile: (that’s because I have no idea how it works on X11…)

The protocol Godot needs to support is xdg-shell, more specifically creating a xdg_toplevel for your window deco: XDG shell protocol | Wayland Explorer. This then allows you to start an interactive drag that KDE, GNOME and other DEs can use.

This is something that has to be done natively though, it can’t be done solely through Godot scripting.

I am using Godot 3.5.3 and this version does not support the function of move, for this reason I have resorted to asking for help here.

Godot supports X11 and my KDE version is 5.27.8. This version of KDE does not support Wayland and it works with X11. Therefore, I need a person who knows X11. Could you contact someone who works with X11?

The goal that I would like to achieve is implementing the move functionality that you can see in the attached image.

This move functionality is implemented in the bar of application called Konsole, I attach a picture and it represents my goal.

On the other hand, What framework could I use to make scripts for KDE? Is there a tool that allows executing KDE scripts through of the konsole?

Can anybody help me?

Probably not. What you’re trying to do isn’t a good idea on X11, and isn’t even possible at all on Wayland. Better to go back to the drawing board IMO.

I don’t think KDE developers don’t know how to get it, because they use it in their applications.

I think this should be possible the same way Firefox, Thunderbird or Code Composer Studio got it, for example.

If someone who is a “Developer” says that it is not possible when they have created applications that use this function is confusing IMO.

If your goal is to get the window to remember its size and/or position on startup and shutdown, that’s done using something different; check out KWindowConfig::SaveWindowSize and KWindowConfig::SaveWindowPosition.

If that doesn’t work for you because you really truly are trying to make your window move itself around on the screen, I’d reconsider what you’re doing. Having windows move themselves around is an anti-pattern and users won’t enjoy using your app.

At no time have I said that I want remember size and/or position on startup and shutdown. I haven’t said that either that I wanted that window move itself around the screen.

I want that window of my app move around the screen but when I click and drag the mouse. It is the same way which occurs when you clicked in the title bar and drag/move the mouse on any KDE application, but I want that this will be in my own title bar.

I am pretty clear about what I want and it is not an anti-pattern :grinning:

From what I could understand, you are trying to implement your custom CSD (Client-Side Decoration).

Firefox does it by using, on Linux, GTK components under the hood. Those components are the ones who provide the low-level infrastructure, so their title bar allows for user dragging the window around a DE.

Some other UI frameworks, like SDL, for example, doesn’t provide such infrastructure, as you can look into GNOME gitlab’s issue tracker about their compositor implementing the XDG decoration protocol.

One of the workarounds provided was a library called libdecor, which provides emulated window decoration, meant to be as CSD.

You could:

  • look into Firefox’s codebase, to see how they integrate GTK’s components to allow their titlebar to behave as you describe
  • look into libdecor’s codebase, to see how they issue low-level calls that allow their emulated window decorations to behave as native window decorations
  • Find a way to use libdecor in your project, from my understanding, it allows you to customize the window decoration look-and-feel
  • Take @redstrate suggestion, and look into implementing XDG protocol’s calls. I am not aware if Godot exposes the needed low-level calls to interact with a DE to their scripting engine
  • Ask Godot to provide such features to allow you to implement CSD on your own

Mind that none of these examples involves knowledge of KDE specific features.

KWin (KDE’s compositor) interacts with these UI Toolkit’s through standardized protocols, so there is not much it can provide for your specific request.

I guess there is a misconception on how the needed layers, for what you want to achieve, operate.

What you describe is not KDE specific, and I agree with @redstrate that it is a question better suited towards Godot’s forums or support.

I will consider all options.

I think that your answer will be useful to me.

Thanks for all information.

1 Like