Skip to content

Commit

Permalink
Merge remote-tracking branch 'yshui/next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
FT-Labs committed Feb 16, 2024
2 parents 39534b9 + b99c7db commit 3b9e2c5
Show file tree
Hide file tree
Showing 50 changed files with 902 additions and 899 deletions.
3 changes: 2 additions & 1 deletion .builds/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ packages:
- uthash
- libconfig
- libglvnd
- libepoxy
- dbus
- pcre
sources:
- https://github.com/yshui/picom
tasks:
- setup: |
cd picom
CPPFLAGS="-I/usr/local/include" meson -Dunittest=true build
CPPFLAGS="-I/usr/local/include" meson setup -Dunittest=true --werror build
- build: |
cd picom
ninja -C build
Expand Down
23 changes: 23 additions & 0 deletions .builds/openbsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
image: openbsd/latest
packages:
- libev
- xcb
- meson
- pkgconf
- cmake
- uthash
- libconfig
- dbus
- pcre2
sources:
- https://github.com/yshui/picom
tasks:
- setup: |
cd picom
CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" meson setup -Dunittest=true --werror build
- build: |
cd picom
ninja -C build
- unittest: |
cd picom
ninja -C build test
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ commands:
- ".git"
- run:
name: config
command: CC=<< parameters.cc >> meson << parameters.build-config >> -Dunittest=true --werror . build
command: CC=<< parameters.cc >> meson setup << parameters.build-config >> -Dunittest=true --werror . build
- run:
name: build
command: ninja -vC build
Expand Down
4 changes: 4 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ CheckOptions:
value: 255.0;1.0;
- key: readability-function-cognitive-complexity.IgnoreMacros
value: true
- key: readability-function-cognitive-complexity.Threshold
value: 50
- key: readability-function-cognitive-complexity.DescribeBasicIncrements
value: true
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
value: int8_t
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ root = true
indent_style = tab
indent_size = 8
max_line_length = 90
[*.nix]
indent_style = space
indent_size = 2
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

Expand All @@ -32,7 +32,7 @@ jobs:

# Autobuild
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
4 changes: 2 additions & 2 deletions .github/workflows/coding-style-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
- uses: yshui/git-clang-format-lint@v1.14
- uses: yshui/git-clang-format-lint@v1.15
with:
base: ${{ github.event.pull_request.base.sha }}
4 changes: 2 additions & 2 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: yshui/git-clang-format-lint@v1.14
- uses: yshui/git-clang-format-lint@v1.15
with:
base: ${{ github.event.ref }}~1
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@

* Allow `corner-radius-rules` to override `corner-radius = 0`. Previously setting corner radius to 0 globally disables rounded corners. (#1170)

## Notable changes

* Marginally improve performance when resizing/opening/closing windows. (#1190)

# v11.2 (2024-Feb-13)

## Build changes

* `picom` now depends on `libepoxy` for OpenGL symbol management.

## Bug fixes

* Workaround a NVIDIA problem that causes high CPU usage after suspend/resume (#1172, #1168)
* Fix building on OpenBSD (#1189, #1188)
* Fix occasional freezes (#1040, #1145, #1166)
* Fix `corner-radius-rules` not applying sometimes (#1177)
* Fix window shader not having an effect when frame opacity is enabled (#1174)
* Fix binding root pixmap in case of depth mismatch (#984)

# v11.1 (2024-Jan-28)

Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ hasufell <julian.ospald at googlemail.com>
i-c-u-p
Ignacio Taranto <ignacio.taranto at eclypsium.com>
Istvan Petres
Ivan Malison <ivanmalison at gmail.com>
Jake <jakeroggenbuck2 at gmail.com>
James Cloos <cloos at jhcloos.com>
Jamey Sharp <jamey at minilop.net>
Expand All @@ -43,6 +44,7 @@ Javeed Shaikh <syscrash2k at gmail.com>
Jerónimo Navarro <jnavarro at ancasrl.com.ar>
jialeens <jialeadmin at 163.com>
Johnny Pribyl <pribylsnbits at gmail.com>
Jose Maldonado aka Yukiteru <josemald89 at gmail.com>
Keith Packard <keithp at keithp.com>
Kevin Kelley <kelleyk at kelleyk.net>
ktprograms <ktprograms at gmail.com>
Expand All @@ -68,6 +70,7 @@ Peter Mattern <matternp at arcor.de>
Phil Blundell <pb at reciva.com>
Que Quotion <quequotion at bugmenot.com>
Rafael Kitover <rkitover at gmail.com>
Reith
Richard Grenville <pyxlcy at gmail.com>
Rytis Karpuska <rytis.karpuska at gmail.com>
Samuel Hand <samuel.d.hand at gmail.com>
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ Assuming you already have all the usual building tools installed (e.g. gcc, pyth
* pixman
* libdbus (optional, disable with the `-Ddbus=false` meson configure flag)
* libconfig (optional, disable with the `-Dconfig_file=false` meson configure flag)
* libGL, libEGL (optional, disable with the `-Dopengl=false` meson configure flag)
* libGL, libEGL, libepoxy (optional, disable with the `-Dopengl=false` meson configure flag)
* libpcre2 (optional, disable with the `-Dregex=false` meson configure flag)
* libev
* uthash

On Debian based distributions (e.g. Ubuntu), the needed packages are

```
libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libepoxy-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
```

On Fedora, the needed packages are

```
dbus-devel gcc git libconfig-devel libdrm-devel libev-devel libX11-devel libX11-xcb libXext-devel libxcb-devel libGL-devel libEGL-devel meson pcre2-devel pixman-devel uthash-devel xcb-util-image-devel xcb-util-renderutil-devel xorg-x11-proto-devel xcb-util-devel
dbus-devel gcc git libconfig-devel libdrm-devel libev-devel libX11-devel libX11-xcb libXext-devel libxcb-devel libGL-devel libEGL-devel libepoxy-devel meson pcre2-devel pixman-devel uthash-devel xcb-util-image-devel xcb-util-renderutil-devel xorg-x11-proto-devel xcb-util-devel
```

To build the documents, you need `asciidoc`
Expand Down
80 changes: 51 additions & 29 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,55 @@
};
};
outputs = {
self, flake-utils, nixpkgs, git-ignore-nix, ...
}: flake-utils.lib.eachDefaultSystem (system: let
overlay = self: super: {
picom = super.picom.overrideAttrs (oldAttrs: rec {
pname = "picom";
buildInputs = [
self.pcre2 self.xorg.xcbutil
] ++ self.lib.remove self.xorg.libXinerama (
self.lib.remove self.pcre oldAttrs.buildInputs
);
src = git-ignore-nix.lib.gitignoreSource ./.;
});
};
pkgs = import nixpkgs { inherit system overlays; config.allowBroken = true; };
overlays = [ overlay ];
in rec {
inherit overlay overlays;
defaultPackage = pkgs.picom.overrideAttrs {
version = "11";
src = ./.;
};
devShell = defaultPackage.overrideAttrs {
buildInputs = defaultPackage.buildInputs ++ [
pkgs.clang-tools_17
pkgs.llvmPackages_17.clang-unwrapped.python
];
hardeningDisable = [ "fortify" ];
};
});
self,
flake-utils,
nixpkgs,
git-ignore-nix,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
overlay = self: super: {
picom = super.picom.overrideAttrs (oldAttrs: rec {
version = "11";
pname = "picom";
buildInputs =
[
self.pcre2
self.xorg.xcbutil
self.libepoxy
]
++ self.lib.remove self.xorg.libXinerama (
self.lib.remove self.pcre oldAttrs.buildInputs
);
src = git-ignore-nix.lib.gitignoreSource ./.;
});
};

pkgs = import nixpkgs {
inherit system overlays;
config.allowBroken = true;
};

overlays = [overlay];
in rec {
inherit
overlay
overlays
;
defaultPackage = pkgs.picom;
devShell = defaultPackage.overrideAttrs {
buildInputs =
defaultPackage.buildInputs
++ (with pkgs; [
clang-tools_17
llvmPackages_17.clang-unwrapped.python
]);
hardeningDisable = ["fortify"];
shellHook = ''
# Workaround a NixOS limitation on sanitizers:
# See: https://github.com/NixOS/nixpkgs/issues/287763
export LD_LIBRARY_PATH+=":/run/opengl-driver/lib"
'';
};
});
}
50 changes: 43 additions & 7 deletions src/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
#include <xcb/xcb.h>

#include "atom.h"
#include "cache.h"
#include "common.h"
#include "utils.h"
#include "compiler.h"
#include "log.h"
#include "utils.h"

static inline void *atom_getter(void *ud, const char *atom_name, int *err) {
xcb_connection_t *c = ud;
struct atom_entry {
struct cache_handle entry;
xcb_atom_t atom;
};

static inline int atom_getter(struct cache *cache attr_unused, const char *atom_name,
struct cache_handle **value, void *user_data) {
xcb_connection_t *c = user_data;
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
c, xcb_intern_atom(c, 0, to_u16_checked(strlen(atom_name)), atom_name), NULL);

Expand All @@ -18,20 +26,48 @@ static inline void *atom_getter(void *ud, const char *atom_name, int *err) {
free(reply);
} else {
log_error("Failed to intern atoms");
*err = 1;
return -1;
}
return (void *)(intptr_t)atom;

struct atom_entry *entry = ccalloc(1, struct atom_entry);
entry->atom = atom;
*value = &entry->entry;
return 0;
}

static inline void
atom_entry_free(struct cache *cache attr_unused, struct cache_handle *handle) {
struct atom_entry *entry = cache_entry(handle, struct atom_entry, entry);
free(entry);
}

xcb_atom_t get_atom(struct atom *a, const char *key, xcb_connection_t *c) {
struct cache_handle *entry = NULL;
if (cache_get_or_fetch(&a->c, key, &entry, c, atom_getter) < 0) {
log_error("Failed to get atom %s", key);
return XCB_NONE;
}
return cache_entry(entry, struct atom_entry, entry)->atom;
}

xcb_atom_t get_atom_cached(struct atom *a, const char *key) {
return cache_entry(cache_get(&a->c, key), struct atom_entry, entry)->atom;
}

/**
* Create a new atom structure and fetch all predefined atoms
*/
struct atom *init_atoms(xcb_connection_t *c) {
auto atoms = ccalloc(1, struct atom);
atoms->c = new_cache((void *)c, atom_getter, NULL);
#define ATOM_GET(x) atoms->a##x = (xcb_atom_t)(intptr_t)cache_get(atoms->c, #x, NULL)
atoms->c = CACHE_INIT;
#define ATOM_GET(x) atoms->a##x = get_atom(atoms, #x, c)
LIST_APPLY(ATOM_GET, SEP_COLON, ATOM_LIST1);
LIST_APPLY(ATOM_GET, SEP_COLON, ATOM_LIST2);
#undef ATOM_GET
return atoms;
}

void destroy_atoms(struct atom *a) {
cache_invalidate_all(&a->c, atom_entry_free);
free(a);
}
20 changes: 9 additions & 11 deletions src/atom.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once
#include <stdlib.h>

#include <xcb/xcb.h>

#include "cache.h"
Expand All @@ -23,6 +21,7 @@
WM_CLIENT_MACHINE, \
_NET_ACTIVE_WINDOW, \
_COMPTON_SHADOW, \
COMPTON_VERSION, \
_NET_WM_WINDOW_TYPE, \
_XROOTPMAP_ID, \
ESETROOT_PMAP_ID, \
Expand Down Expand Up @@ -52,19 +51,18 @@

#define ATOM_DEF(x) xcb_atom_t a##x

struct atom_entry;
struct atom {
struct cache *c;
struct cache c;
LIST_APPLY(ATOM_DEF, SEP_COLON, ATOM_LIST1);
LIST_APPLY(ATOM_DEF, SEP_COLON, ATOM_LIST2);
};

struct atom *init_atoms(xcb_connection_t *);
/// Create a new atom object with a xcb connection. `struct atom` does not hold
/// a reference to the connection.
struct atom *init_atoms(xcb_connection_t *c);

static inline xcb_atom_t get_atom(struct atom *a, const char *key) {
return (xcb_atom_t)(intptr_t)cache_get(a->c, key, NULL);
}
xcb_atom_t get_atom(struct atom *a, const char *key, xcb_connection_t *c);
xcb_atom_t get_atom_cached(struct atom *a, const char *key);

static inline void destroy_atoms(struct atom *a) {
cache_free(a->c);
free(a);
}
void destroy_atoms(struct atom *a);
Loading

0 comments on commit 3b9e2c5

Please sign in to comment.