# Inset titlebar like in Electron

**URL:** <https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329>\
**Category:** support\
**Created:** [March 22, 2023, 4:43pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329 "2023-03-22T16:43:16Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![anantnrg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/anantnrg/32/736_2.png) [@anantnrg](https://discourse.glfw.org/u/anantnrg)\
**Post date:** [March 22, 2023, 4:43pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/1 "2023-03-22T16:43:16Z")

</div>

Hey guys, I trying to build a cross-platform desktop app using GLFW, OpenGL and C++. Previously I used Electron. In Electron, there is an option to remove the titlebar but keep the native window buttons (the close, minimize, restore buttons). I want to do the same thing in GLFW but I couldn’t find any resources. I’m not that experienced in C++ so any help would be greatly appreciated. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [March 22, 2023, 5:12pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/2 "2023-03-22T17:12:52Z")

</div>

Hi @anantrng,

This option doesn’t exist in GLFW, so you’d have to user the [GLFW native access API](https://www.glfw.org/docs/3.3/group__native.html) and modify the Window styling yourself on those systems which support this.

I don’t know how to achieve this myself, but if you search through the electron code you can probably work out how they do it for the `hidden` `titleBarstyle`:

> **[Search · titleBarStyle · electron/electron](https://github.com/electron/electron/search?q=titleBarStyle)**
>
> :electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS - Search · titleBarStyle · electron/electron

Cheers,

Doug.

---

<div class="post-metadata">

**Author:** ![anantnrg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/anantnrg/32/736_2.png) [@anantnrg](https://discourse.glfw.org/u/anantnrg)\
**Post date:** [March 23, 2023, 2:02am UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/3 "2023-03-23T02:02:29Z")

</div>

Thx man! I’ll definitely check it out although I may take some time because I’m relatively new to C++. 🙂

---

<div class="post-metadata">

**Author:** ![anantnrg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/anantnrg/32/736_2.png) [@anantnrg](https://discourse.glfw.org/u/anantnrg)\
**Post date:** [March 23, 2023, 2:29am UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/4 "2023-03-23T02:29:36Z")

</div>

Hey, I checked out what you said but I couldn’t find anything useful in the Electron repo. There probably is something, but I can’t seem to find it. May have to disable the titlebar and create my own. Thx anyway 🙂

---

<div class="post-metadata">

**Author:** ![bmitc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/bmitc/32/664_2.png) [@bmitc](https://discourse.glfw.org/u/bmitc)\
**Post date:** [March 23, 2023, 7:40am UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/5 "2023-03-23T07:40:48Z")

</div>

I am not entirely sure, but my assumption for Flutter and Electron is that they simply have a non-title bar window and fully recreate the title bar look with UI widgets/components, which allows them to have things displayed in the title bar or the title bar removed completely with only the minimize, maximize, and close buttons visible. But I don’t know for sure and could be totally wrong on this.

However, this is an approach that could work for GLFW.

---

<div class="post-metadata">

**Author:** ![bmitc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/bmitc/32/664_2.png) [@bmitc](https://discourse.glfw.org/u/bmitc)\
**Post date:** [March 23, 2023, 7:45am UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/6 "2023-03-23T07:45:37Z")

</div>

Well, maybe not with built-in GLFW window hints. I was thinking you could remove the title bar by setting `GLFW_DECORATED` to false, but that would make the window non-resizable it seems.

---

<div class="post-metadata">

**Author:** ![anantnrg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/anantnrg/32/736_2.png) [@anantnrg](https://discourse.glfw.org/u/anantnrg)\
**Post date:** [March 23, 2023, 9:07am UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/7 "2023-03-23T09:07:12Z")

</div>

You’re probably right. As for the non-resizable problem, you can create a drag area and the get the mouse drag amount and add it to the window size. I think I’m going to have to create my own titlebar. I’ll let you know how it goes.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [March 23, 2023, 11:09am UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/8 "2023-03-23T11:09:31Z")

</div>

If you’re looking into creating your own resize and drag handles you should take a look at the [Dear ImGui Docking Branch](https://github.com/ocornut/imgui/tree/docking) whose child windows use this approach: [https://github.com/ocornut/imgui/issues/2109](https://github.com/ocornut/imgui/issues/2109)

---

<div class="post-metadata">

**Author:** ![ws909](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ws909/32/714_2.png) [@ws909](https://discourse.glfw.org/u/ws909)\
**Post date:** [March 23, 2023, 2:38pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/9 "2023-03-23T14:38:31Z")

</div>

I think this is functionality provided directly by Cocoa, so at least one of the platforms should have a good basis for building this functionality into GLFW.

@dougbinks I’m going to look into that branch, but I just wondered, beforehand, if this functionality is available on MacOS. I made a PR to GLFW a while ago, that allowed configuration of window tabbing on MacOS, but ImGUI seems to be drawing a custom title bar in that image you provided (and the preview on GH), and the PR for user-invoked window dragging for GLFW has no MacOS implementation, as this was not trivial to implement. So, unless ImGUI resorts to native window tabs on MacOS, I assume this functionality is unavailable there?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [March 23, 2023, 3:32pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/10 "2023-03-23T15:32:41Z")

</div>

@ws909 Dear ImGui uses it’s own UI for the docking branch child window controls, not native window controls.

---

<div class="post-metadata">

**Author:** ![anantnrg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/anantnrg/32/736_2.png) [@anantnrg](https://discourse.glfw.org/u/anantnrg)\
**Post date:** [March 23, 2023, 3:38pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/11 "2023-03-23T15:38:57Z")

</div>

I’ll definitely try that. Thx 🙂

---

<div class="post-metadata">

**Author:** ![ws909](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ws909/32/714_2.png) [@ws909](https://discourse.glfw.org/u/ws909)\
**Post date:** [March 23, 2023, 3:52pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/12 "2023-03-23T15:52:22Z")

</div>

@dougbinks Yes, that’s what I noticed, but as you’re using that branch for your projects, I was wondering if it works on MacOS. If you’re unknown with its state on MacOS, that’s fine. I’ll dig into the code nonetheless, and it’s not directly relevant to this thread.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [March 23, 2023, 5:02pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/13 "2023-03-23T17:02:59Z")

</div>

@ws909 Ah, I misunderstood and thought you were asking if it was using MacOS specific functionality. It’s all using it’s own UI and this works cross platform including MacOS via a number of different backends including GLFW, SDL, and custom ones.

---

<div class="post-metadata">

**Author:** ![ws909](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ws909/32/714_2.png) [@ws909](https://discourse.glfw.org/u/ws909)\
**Post date:** [March 23, 2023, 11:42pm UTC](https://discourse.glfw.org/t/inset-titlebar-like-in-electron/2329/14 "2023-03-23T23:42:19Z")

</div>

Thanks for the information. 🙂 That means there might be a solution for `glfwDragWindow` on MacOS somewhere in there.
