Skip to content

Instantly share code, notes, and snippets.

View andrew-harter's full-sized avatar

Andrew Harter andrew-harter

View GitHub Profile
@andrew-harter
andrew-harter / README.md
Last active July 3, 2024 10:15
Barebones X11 Smooth Resizing

Barebones X11 Smooth Resizing

This example illustrates how you can use the X11 XSync extension (not to be confused with XSync()) to achieve smooth interactive resizing on the majority of X environments, assuming your program can redraw fast enough.

DISCLAIMER: This example shows only the basic usage of XSync using a single counter, which is the bare minimum required to support smooth resizing.

Basic Rundown:

  1. Indicate that your client is willing to receive sync requests:
  • Add _NET_WM_SYNC_REQUEST to your window's WM_PROTOCOLS.
@andrew-harter
andrew-harter / README.md
Last active July 17, 2024 18:16
X11 Custom Window Decorations

X11 Custom Window Decorations

To create an X window with custom decorations, you must remove the default decorations and emulate their behavior with your own UI. The example below shows a basic implementation of this.

Steps

  1. Create a window without decorations:
    The most common approach is to create a frameless window using the _MOTIF_WM_HINTS property.
  2. Emulate button behaviors:
    Most floating window managers have 3 buttons in each titlebar: "Close", "Maximize", and "Minimize".
    • "Close" can just be handled by breaking the main loop or sending a close event to your application.
  • "Maximize" is handled by sending a ClientMessage event to the root window. See ToggleMaximize().