diff --git a/.gitignore b/.gitignore index c5e23f0..1563980 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ overlay/rootfs/etc/skel/.ssh/ overlay/rootfs/root/.ssh/ # C/C++ & CMake build artifacts +/src/xlibre src/**/build/ CMakeFiles/ CMakeCache.txt diff --git a/MANUAL.md b/MANUAL.md index ce7e295..5964a47 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -23,12 +23,16 @@ This manual covers flashing, operating, and customizing **Bananarchy Linux** (`v - `bootloader/loaders/8110.mbn` — signed Qualcomm Sahara/Firehose programmer (`05c6:9008`). ### 1.3 Integrated hardware & UX tweaks -1. **Native 1:1 `240x320` resolution & enlarged fonts**: - - Sway runs at `output * scale 1` (`SXMO_SWAY_SCALE=1`) with Xwayland disabled to save RAM. - - Enlarged fonts across all UI layers: `Sxmo 13` window titles and `24px` top bar, `34pt`/`14pt` Conky clock/date positioned cleanly above the Bananarchy emblem wallpaper, `15px` bold Wofi full-screen menus (`240x296`), `13pt` Foot terminal font, `220x28` Wob volume/brightness overlay, and `12pt` Dunst notifications. +1. **Native 1:1 `240x320` resolution, cross-compiled Xlibre, `Fira Code` ligatures & ultra-low-latency Sxmo X11 UI**: + - **Cross-compiled Xlibre (`X11Libre/xserver` 25.2.0)**: compiled specifically for ARMv7 Cortex-A7 (`-O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fno-plt -fomit-frame-pointer`) with all 3D/GLX/Glamor/VGA/DGA/XVideo bloat stripped out, rootless `elogind` device management, and `modesetting` KMS + `ShadowFB` (`drmModeDirtyFB` partial rectangle SPI updates) with automatic software cursor fallback on `/dev/dri/card0` (`panel-mipi-dbi`). + - **Non-Nerd `Fira Code` with OpenType ligatures**: `Fira Code` (`font-fira-code`) is configured as the primary system and terminal font across Fontconfig, Xft, `st`, `dmenu`, `dwm`, `conky`, and `dunst`, with `DejaVu SansM Nerd Font` used strictly as a fallback for Private Use Area icon glyphs. + - **Patched `sxmo-st` (`st`) with HarfBuzz ligatures & XIM**: patched with `libharfbuzz` (`hb.c`/`hb.h`) shaping (`liga`, `calt`, `clig`, `dlig`) so multi-character programming operators (`->`, `=>`, `!=`, `<=`, `>=`, `===`, `::`, `//`, `/*`) render as continuous ligatures at `pixelsize=15`, alongside full `XIM` (`fcitx5-t9`) input support. + - **Patched `sxmo-dmenu` (`dmenu`) (`< 15 ms` startup)**: full-width `240x320` 9-line vertical menu (`lineheight = 26`, positioned flush at `Y = 24` right below the 24px `dwm` bar) with a `#383838` top search bar, `#005577` prompt badge, `#1c1c1c` item list, `XIM` (`XSetLocaleModifiers("")`, `XSetICFocus`, `Xutf8LookupString`) for live `fcitx5-t9` search filtering and `#` mode switching, C-level focus preservation (`prevfocuswin`), and direct Nokia keypad bindings. + - **Patched `sxmo-dwm` (`dwm`) (`< 2 ms` display wake/unlock)**: configured for `240x320` (`bh = 24`, `#323232` top bar, `#005577` active tag/border, vertical `bstack` layout default, overflow-protected Pango status bar rendering keeping the right-aligned clock always visible). Directly polls `/dev/input/by-path/platform-gpio-keys-event` (`SW_LID`) and intercepts locked-state wake keys (`XF86PowerOff`, `XF86PickupPhone`, `XF86KbdLcdMenu1`, `XF86KbdLcdMenu2`) in C to toggle `/sys/class/backlight/backlight/brightness` and `/sys/class/leds/white:kbd_backlight/brightness` in `< 2 ms` before running Sxmo state hooks asynchronously. 2. **Multi-mode `fcitx5-t9` keypad engine (`src/fcitx5-t9/`)**: - - Supports 6 input modes cycled with `#` (`XF86NumericPound`): `abc`, `Abc`, `ABC`, `Sym`, `Ctl`, and `123`. - - Includes instant case toggling during preedit, full 32-character ASCII punctuation/symbol entry, terminal control sequences (`^A`–`^Z`, `Esc`, `Tab`, `F1`–`F12`), and a `450ms` long-press `*` `Ctrl+` modifier latch. + - Supports 6 input modes cycled with `#` (`XF86NumericPound`): `abc`, `Abc`, `ABC`, `Sym`, `Ctl`, and `123`, updating the live top-bar status indicator (`[abc]`, `[Abc]`, `[ABC]`, `[Sym]`, `[Ctl]`, `[123]`) in real time. + - Locks the candidate popup bar to the bottom of the screen (`X = 1, Y = 290, W = 238, H = 30`) with fixed-width 28-character monospace formatting (`Fira Code 9.5`), so neither the popup window nor individual letters ever jump when cycling through candidates. + - Includes instant case toggling during preedit, full 32-character ASCII punctuation/symbol entry, terminal control sequences (`^A`–`^Z`, `Esc`, `Tab`, `F1`–`F12`), and a `550ms` long-press `*` `Ctrl+` modifier latch. 3. **Bantam AI agent (`prebuilt/bantam/bantam`)**: - Fetched from the latest `master` branch of `https://code.luxferre.top/luxferre/bantam-cpp`, cross-compiled for `armv7`, and installed to `/usr/bin/bantam` and `/usr/local/bin/bantam` (with no default `.bantam.cfg` pre-created). 4. **Mainline 6.12.1-msm8916 QDSP6 audio (loudspeaker, earpiece, MEMS & headset mics), voice call & LTE modem stack**: @@ -114,46 +118,35 @@ sudo dd if=./images/bananarchy-nokia-argon.img of=/dev/sdX bs=4M status=progress > - Pressing **End / Power (red)**, **Left softkey**, **Right softkey**, or **Call (green)** once. #### 3.1.1 Window tiling modes & switching combos -By default, Sxmo Sway is configured with **`default_orientation vertical` (`splitv`)**, so opening multiple terminals stacks them **vertically (one terminal under another)** to maximize line width on the `240x320` portrait screen. +By default, Sxmo `dwm` is configured with the **vertical bottom-stack (`bstack`, `TTT`)** layout as default, so opening multiple `st` terminals stacks them **vertically (one terminal under another)** to maximize line width on the `240x320` portrait screen. -You can switch between **vertical (`splitv`, one under another)**, **horizontal (`splith`, side-by-side)**, and **tabbed (`tabbed`, full-screen tabs)** layouts — as well as switch focus between open terminals — using any of the following combos: +You can switch between **vertical stack (`TTT`, `bstack`)**, **horizontal tile (`[]=`, `tile`)**, **deck (`[D]`, `deck`)**, and **fullscreen monocle (`[M]`, `monocle`)** layouts — as well as switch focus between open terminals — using any of the following combos: 1. **Direct physical keypad combos**: - - **Triple-press Call (green) (`3× Call`)**: cycles the current container layout (`vertical splitv` -> `horizontal splith` -> `tabbed` -> `vertical splitv`). - - **Double-press Call (green) (`2× Call`)**: switches focus to the next open window/terminal (e.g., jumps between the top and bottom terminals). - - **Triple-press (or hold `400ms`) End / Power (red) (`3× End`)**: opens a new `Foot` terminal tiled in the active layout. -2. **Terminal context menu (`Right softkey` or `1× Call (green)` inside `Foot`)**: - - **Next window**: switch focus to the next open terminal/window. - - **Toggle layout**: cycle `splitv` -> `splith` -> `tabbed`. - - **Tile vertical**: immediately arrange open windows vertically (one under another) and set future splits to vertical. - - **Tile horizontal**: immediately arrange open windows horizontally (side-by-side) and set future splits to horizontal. - - **New terminal** / **Close terminal**: open a new terminal or close the focused terminal. -3. **System windows menu (`Left softkey` -> `Windows`)**: - - **Next window**: focus the next window in the workspace. - - **`splitv -> splith -> tabbed`**: cycle container layout mode. - - **Split vertical** / **Split horizontal** / **Tabbed layout**: switch directly to the chosen layout. - - **Switch menu** / **Move menu** / **Kill window**: switch to any window across workspaces, move windows between positions/workspaces, or close the focused window. -4. **External keyboard / `swaymsg` (`$mod` = `Mod4` / `Super`)**: - - `Mod4+v`: vertical split (`splitv`) - - `Mod4+b`: horizontal split (`splith`) - - `Mod4+e`: toggle split orientation (`layout toggle split` between vertical and horizontal) - - `Mod4+w`: tabbed layout (`layout tabbed`) - - `Mod4+s`: stacking layout (`layout stacking`) - - `Mod4+f`: toggle fullscreen (`fullscreen`) - - `Mod4+Up` / `Mod4+Down` / `Mod4+Left` / `Mod4+Right`: move focus between tiled windows - - `Mod4+Shift+Up` / `Mod4+Shift+Down` / `Mod4+Shift+Left` / `Mod4+Shift+Right`: reposition focused window + - **Triple-press Call (green) (`3× Call`)**: cycles the current DWM layout (`TTT` -> `[]=` -> `[D]` -> `[M]` -> `TTT`). + - **Double-press Call (green) (`2× Call`)**: switches focus to the next open window/terminal (`Super+j`). + - **Triple-press End / Power (red) (`3× End`)**: opens a new `st` terminal (with HarfBuzz `Fira Code` ligature support) tiled in the active layout. +2. **External keyboard / `xdotool` (`MODKEY` = `Mod4` / `Super`)**: + - `Mod4+space`: cycle layout (`TTT` -> `[]=` -> `[D]` -> `[M]`) + - `Mod4+Shift+slash`: vertical stack layout (`bstack`, `TTT`) + - `Mod4+slash`: horizontal tile layout (`tile`, `[]=`) + - `Mod4+m`: fullscreen monocle layout (`monocle`, `[M]`) + - `Mod4+Up` / `Mod4+Down` (or `Mod4+k` / `Mod4+j`): move focus between tiled windows + - `Mod4+Shift+k` / `Mod4+Shift+j`: move focused window up/down in the stack + - `Mod4+1`..`4`: switch to workspace tag `1`..`4` + - `Mod4+Shift+q`: close focused window ### 3.2 Multi-mode `fcitx5-t9` keypad reference -- **Short-press `#`** *(when no character is in preedit)*: cycles through the 6 input modes (`abc` -> `Abc` -> `ABC` -> `Sym` -> `Ctl` -> `123` -> `abc`), displaying a `900ms` preedit status banner (`[Mode: abc]`, `[Mode: Abc]`, `[Mode: ABC]`, `[Mode: Sym]`, `[Mode: Ctl]`, `[Mode: 123]`). -- **Auto-commit timeout**: `600ms` for keys with `<= 10` candidates, or `750ms` for keys with `> 10` candidates (`1` and `*` in `abc`/`Abc`/`ABC`, `*` in `Sym`, `9` in `Ctl`). Pressing a different key immediately commits the active candidate. +- **Short-press `#`** *(when no character is in preedit)*: cycles through the 6 input modes (`abc` -> `Abc` -> `ABC` -> `Sym` -> `Ctl` -> `123` -> `abc`), displaying a `1500ms` preedit status banner (`[Mode: abc]`, `[Mode: Abc]`, `[Mode: ABC]`, `[Mode: Sym]`, `[Mode: Ctl]`, `[Mode: 123]`). +- **Auto-commit timeout**: `1500ms` for keys with `<= 10` candidates, or `1800ms` for keys with `> 10` candidates (`1` and `*` in `abc`/`Abc`/`ABC`, `*` in `Sym`, `9` in `Ctl`). Pressing a different key immediately commits the active candidate. - **While a candidate is highlighted (`[item]`) in preedit**: - Press **`#`** or **D-Pad `Up`**: toggles letter case (`a` <-> `A`) on the fly without changing mode, or jumps forward **`+4` candidates** for non-alphabetic items. - Press **D-Pad `Down`**: toggles letter case (`a` <-> `A`) for alphabetic items, or jumps backward **`-4` candidates** for non-alphabetic items. - Press **D-Pad `Left`**: steps backward **1 candidate** on the same key. - Press **D-Pad `Right`** or **Center `OK` (`Return`)**: commits the highlighted candidate immediately. - Press **`BackSpace`**: cancels the uncommitted preedit candidate without deleting previously committed text. -- **Long-press (`>= 450ms`)**: +- **Long-press (`>= 550ms`)**: - **Hold `0`–`9`**: commits the digit (`0`–`9`) immediately in any mode. - **Hold `*`**: - In `123` mode: commits a decimal point (`.`) immediately. @@ -230,7 +223,7 @@ You can switch between **vertical (`splitv`, one under another)**, **horizontal ssh user@172.16.42.1 ``` - **Bantam AI agent**: - Run `bantam` in the terminal (`Foot`) or over SSH. Configure your endpoint/API key via environment variables or `~/.bantam.cfg` when needed. + Run `bantam` in the terminal (`st`) or over SSH. Configure your endpoint/API key via environment variables or `~/.bantam.cfg` when needed. --- diff --git a/README.md b/README.md index a174988..805bece 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ See [The Bananarchy Manifesto](./MANIFESTO.md) for the rationale behind this entire project. -Bananarchy targets the **Sxmo (`sxmo-de-sway`)** environment exclusively, tuned for 1:1 native `240x320` resolution, enlarged high-contrast typography, sub-115 MB idle RAM footprint on 512 MB devices, full Qualcomm QDSP6/Q6Voice audio (loudspeaker, earpiece speaker, and internal/headset microphones with PM8909 WCD analog codec 2.8V micbias and +6 dB EAR PA gain), GSM/WCDMA/LTE modem routing (`ModemManager` + `q6voiced`), rear 2MP camera support (`msm8905-cam` V4L2 driver for GalaxyCore `GC2395` + MSM8909 `CAMSS` on `/dev/video0` and `bananarchy-photo` CLI/Sxmo app), pre-integrated **Bantam** AI agent (`https://code.luxferre.top/luxferre/bantam-cpp`), a complete on-device development & scripting stack (`git`, `gcc`/`g++`, `make`, `nano`, `janet` + `jpm`, `perl` + `IO::Socket::SSL`, `tcl` + `tcllib`/`tcl-tls`/`sqlite-tcl`, `sqlite`, `i2c-tools`, `v4l-utils`), and a custom **6-mode `fcitx5-t9` input engine** supporting lowercase, one-shot Shift, Caps Lock, all 32 ASCII punctuation symbols, terminal control codes (`^A`-`^Z`, `Esc`, `Tab`, `F1`-`F12`), and direct numeric entry. +Bananarchy targets an ultra-lightweight **Sxmo X11 (`sxmo-de-dwm`)** environment (with all Wayland components removed) powered by a cross-compiled **Xlibre (`X11Libre/xserver` 25.2.0)** display server (`modesetting` KMS + `ShadowFB` Damage partial-rectangle SPI transfers, software cursor fallback, rootless `elogind`), **patched `sxmo-dwm`** (`240x320` vertical `bstack` layout, 24px Pango status bar with overflow-protected right-aligned clock, direct C `SW_LID` slider and locked-key wake handling in `< 2 ms`), **patched `sxmo-dmenu`** (`240x320` full-width 9-line vertical menu flush below the 24px top bar with `#383838` search bar, `#005577` prompt badge, and `XIM` `fcitx5-t9` text input in `< 15 ms`), **patched `sxmo-st`** terminal (`pixelsize=15`) with **HarfBuzz (`libharfbuzz`) OpenType ligature shaping** (`liga`, `calt`, `clig`, `dlig`) and `XIM` support, and **non-Nerd `Fira Code` (`font-fira-code`) with ligatures** as the primary system and terminal font (with `DejaVu SansM Nerd Font` used strictly as an icon fallback). It features a sub-95 MB idle RAM footprint on 512 MB devices, full Qualcomm QDSP6/Q6Voice audio (loudspeaker, earpiece speaker, and internal/headset microphones with PM8909 WCD analog codec 2.8V micbias and +6 dB EAR PA gain), GSM/WCDMA/LTE modem routing (`ModemManager` + `q6voiced`), rear 2MP camera support (`msm8905-cam` V4L2 driver for GalaxyCore `GC2395` + MSM8909 `CAMSS` on `/dev/video0` and `bananarchy-photo` CLI/Sxmo app), pre-integrated **Bantam** AI agent (`https://code.luxferre.top/luxferre/bantam-cpp`), a complete on-device development & scripting stack (`git`, `gcc`/`g++`, `make`, `nano`, `janet` + `jpm`, `perl` + `IO::Socket::SSL`, `tcl` + `tcllib`/`tcl-tls`/`sqlite-tcl`, `sqlite`, `i2c-tools`, `v4l-utils`), and a custom **6-mode `fcitx5-t9` input engine** with a fixed bottom candidate bar (`X=1, Y=290, W=238, H=30`) supporting lowercase, one-shot Shift, Caps Lock, all 32 ASCII punctuation symbols, terminal control codes (`^A`-`^Z`, `Esc`, `Tab`, `F1`-`F12`), and direct numeric entry with live top-bar mode indication (`[abc]`, `[Abc]`, `[ABC]`, `[Sym]`, `[Ctl]`, `[123]`). The current Bananarchy version is `v0.0.1`. @@ -65,21 +65,34 @@ bananarchy/ │ │ └── 0001-edl-msm8909-32bit-elf-and-multi-cmd-firehose.patch │ ├── sxmo/ │ │ └── 0001-bananarchy-sxmo-240x320-keypad-ui.patch +│ ├── xlibre/ +│ │ ├── 0001-xlibre-msm8905-spi-drm-and-shared-vt.patch +│ │ ├── 0002-xf86-input-libinput-xlibre25.patch +│ │ └── 0003-xf86-video-fbdev-xlibre25.patch │ └── fcitx5-t9/ │ └── 0001-bananarchy-multimode-t9-and-fcitx5-5.1.19.patch ├── src/ +│ ├── sxmo-dwm/ # Patched sxmo-dwm (240x320 bstack, Pango bar, direct C SW_LID & locked-key wake) +│ ├── sxmo-dmenu/ # Patched sxmo-dmenu (240x320 vertical 9-line menu, #383838 search bar, XIM fcitx5-t9) +│ ├── sxmo-st/ # Patched sxmo-st terminal with HarfBuzz Fira Code ligature shaping & XIM +│ ├── xf86-input-libinput/ # X11Libre xf86-input-libinput DDX driver +│ ├── xf86-video-fbdev/ # X11Libre xf86-video-fbdev fallback DDX driver │ ├── fcitx5-t9/ # C++20 source of Bananarchy's 6-mode fcitx5-t9 input method │ ├── leds-msm8905-torch/ # Kernel driver for SY7807 rear torch LED, WCD codec init & PM8909 PON shutdown │ └── msm8905-cam/ # Kernel V4L2 driver for GC2395 2MP rear camera & MSM8909 CAMSS (/dev/video0) ├── overlay/ -│ └── rootfs/ # Complete Bananarchy rootfs overlay (OS branding, Sxmo, audio, camera, T9) +│ └── rootfs/ # Complete Bananarchy rootfs overlay (OS branding, Sxmo X11, audio, camera, T9) ├── prebuilt/ +│ ├── xlibre/ # Prebuilt armv7 Xlibre Xorg binary and modesetting/libinput/fbdev DDX modules +│ ├── sxmo-x11/ # Prebuilt armv7 patched dwm, dmenu, and st (with HarfBuzz ligatures) │ ├── kernel-6.12.1-msm8916/ # Prebuilt QDSP6/Q6Voice .ko, torch .ko, camera .ko, and 5 device DTBs │ ├── fcitx5-t9/ # Prebuilt armv7 libt9.so and fcitx5 addon/inputmethod configs │ └── bantam/ # Prebuilt armv7 bantam AI agent binary └── scripts/ ├── generate-artwork.py # Generates all wallpapers, icons, and splashes from icon-large.png ├── mipi-dbi-cmd.py # Compiles MIPI-DBI panel .txt init sequences into .bin firmware + ├── build-xlibre.sh # Cross-compiles Xlibre + xf86-input-libinput + xf86-video-fbdev for armv7 Cortex-A7 + ├── build-sxmo-x11.sh # Cross-compiles patched sxmo-st (HarfBuzz ligatures), sxmo-dmenu (XIM), and sxmo-dwm ├── build-kernel-audio.sh # Cross-compiles Linux 6.12.1-msm8916 QDSP6/torch/camera modules & DTBs ├── build-fcitx5-t9.sh # Cross-compiles src/fcitx5-t9 for armv7 ├── build-bantam.sh # Fetches master from https://code.luxferre.top/luxferre/bantam-cpp & cross-compiles for armv7 @@ -100,6 +113,12 @@ Whenever `artwork/icon-large.png` is updated, regenerate all icons, `240x320` wa ### 2. Recompile core components (optional — prebuilts included) All components are pre-compiled in `prebuilt/` and `overlay/rootfs/`, and can be rebuilt from source at any time using rootless Docker (`alpine:3.24`): ```bash +# Rebuild cross-compiled Xlibre (X11Libre/xserver) + libinput/fbdev DDX drivers +./scripts/build-xlibre.sh + +# Rebuild patched sxmo-st (HarfBuzz Fira Code ligatures), sxmo-dmenu (XIM), and sxmo-dwm +./scripts/build-sxmo-x11.sh + # Rebuild multi-mode fcitx5-t9 input engine (src/fcitx5-t9 -> prebuilt/fcitx5-t9) ./scripts/build-fcitx5-t9.sh diff --git a/overlay/rootfs/etc/X11/xinit/xserverrc b/overlay/rootfs/etc/X11/xinit/xserverrc new file mode 100755 index 0000000..e4bdcf7 --- /dev/null +++ b/overlay/rootfs/etc/X11/xinit/xserverrc @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/X -nocursor -nolisten tcp "$@" diff --git a/overlay/rootfs/etc/X11/xorg.conf.d/10-bananarchy-msm8909.conf b/overlay/rootfs/etc/X11/xorg.conf.d/10-bananarchy-msm8909.conf new file mode 100644 index 0000000..27cb315 --- /dev/null +++ b/overlay/rootfs/etc/X11/xorg.conf.d/10-bananarchy-msm8909.conf @@ -0,0 +1,47 @@ +Section "ServerFlags" + Option "AutoAddDevices" "true" + Option "AutoEnableDevices" "true" + Option "AutoAddGPU" "false" + Option "BlankTime" "0" + Option "StandbyTime" "0" + Option "SuspendTime" "0" + Option "OffTime" "0" +EndSection + +Section "Device" + Identifier "MSM8909 SPI Panel" + Driver "modesetting" + Option "kmsdev" "/dev/dri/card0" + Option "AccelMethod" "none" + Option "ShadowFB" "true" + Option "SWCursor" "true" + Option "PageFlip" "false" +EndSection + +Section "Screen" + Identifier "DefaultScreen" + Device "MSM8909 SPI Panel" + DefaultDepth 24 +EndSection + +Section "InputClass" + Identifier "libinput keyboard catchall" + MatchIsKeyboard "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput pointer catchall" + MatchIsPointer "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput touchscreen catchall" + MatchIsTouchscreen "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + diff --git a/overlay/rootfs/etc/doas.d/50-sxmo.conf b/overlay/rootfs/etc/doas.d/50-sxmo.conf index c4f8e1f..0518929 100644 --- a/overlay/rootfs/etc/doas.d/50-sxmo.conf +++ b/overlay/rootfs/etc/doas.d/50-sxmo.conf @@ -1,8 +1,12 @@ permit persist :wheel permit nopass :wheel as root cmd busybox args poweroff permit nopass :wheel as root cmd busybox args reboot +permit nopass :wheel as root cmd /bin/busybox args poweroff +permit nopass :wheel as root cmd /bin/busybox args reboot permit nopass :wheel as root cmd poweroff permit nopass :wheel as root cmd reboot +permit nopass :wheel as root cmd /sbin/poweroff +permit nopass :wheel as root cmd /sbin/reboot permit nopass :wheel as root cmd sxmo_wifitoggle.sh permit nopass setenv { SXMO_OS } :wheel as root cmd sxmo_bluetoothtoggle.sh permit nopass :wheel as root cmd rc-service args bluetooth restart diff --git a/overlay/rootfs/etc/elogind/logind.conf b/overlay/rootfs/etc/elogind/logind.conf new file mode 100644 index 0000000..c72430a --- /dev/null +++ b/overlay/rootfs/etc/elogind/logind.conf @@ -0,0 +1,10 @@ +[Login] +HandlePowerKey=ignore +HandleSuspendKey=ignore +HandleHibernateKey=ignore +HandleLidSwitch=ignore +HandleLidSwitchExternalPower=ignore +HandleLidSwitchDocked=ignore + +[Sleep] +AllowSuspendInterrupts=yes diff --git a/overlay/rootfs/etc/fonts/local.conf b/overlay/rootfs/etc/fonts/local.conf new file mode 100644 index 0000000..53526e1 --- /dev/null +++ b/overlay/rootfs/etc/fonts/local.conf @@ -0,0 +1,38 @@ + + + + + DejaVu SansM Nerd Font + + DejaVuSansM Nerd Font + + + + Sxmo + + Fira Code + DejaVuSansM Nerd Font + + + + monospace + + Fira Code + DejaVuSansM Nerd Font + + + + sans-serif + + Fira Code + DejaVuSansM Nerd Font + + + + serif + + Fira Code + DejaVuSansM Nerd Font + + + diff --git a/overlay/rootfs/etc/polkit-1/rules.d/00-sxmo.rules b/overlay/rootfs/etc/polkit-1/rules.d/00-sxmo.rules new file mode 100644 index 0000000..1051798 --- /dev/null +++ b/overlay/rootfs/etc/polkit-1/rules.d/00-sxmo.rules @@ -0,0 +1,8 @@ +polkit.addRule(function(action, subject) { + if ((action.id.indexOf("org.freedesktop.ModemManager1.") == 0 || + action.id.indexOf("org.freedesktop.login1.") == 0 || + action.id.indexOf("org.freedesktop.NetworkManager.") == 0) && + (subject.isInGroup("plugdev") || subject.isInGroup("wheel"))) { + return polkit.Result.YES; + } +}); diff --git a/overlay/rootfs/etc/profile.d/fcitx5-t9.sh b/overlay/rootfs/etc/profile.d/fcitx5-t9.sh new file mode 100644 index 0000000..73bfa74 --- /dev/null +++ b/overlay/rootfs/etc/profile.d/fcitx5-t9.sh @@ -0,0 +1,9 @@ +export GTK_IM_MODULE=fcitx +export QT_IM_MODULE=fcitx +export XMODIFIERS=@im=fcitx +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 diff --git a/overlay/rootfs/etc/profile.d/sxmo_init.sh b/overlay/rootfs/etc/profile.d/sxmo_init.sh new file mode 100644 index 0000000..d6f9292 --- /dev/null +++ b/overlay/rootfs/etc/profile.d/sxmo_init.sh @@ -0,0 +1,206 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# This script is meant to be sourced on login shells +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +_sxmo_is_running() { + unset SXMO_WM + + _XDG_RUNTIME_DIR="$(_sxmo_find_runtime_dir)" + + if pidof -s dwm >/dev/null 2>&1 || DISPLAY=:0 xset q >/dev/null 2>&1; then + export SXMO_WM=dwm + export SXMO_MENU=dmenu + export SXMO_TERMINAL=st + [ -z "$DISPLAY" ] && export DISPLAY=:0 + unset _XDG_RUNTIME_DIR + return 0 + fi + + if [ -f "${_XDG_RUNTIME_DIR}"/sxmo.swaysock ]; then + if SWAYSOCK="$(cat "${_XDG_RUNTIME_DIR}"/sxmo.swaysock)" swaymsg 2>/dev/null + then + printf "Detected the Sway environment\n" >&2 + export SXMO_WM=sway + unset _XDG_RUNTIME_DIR + return 0 + fi + elif [ -e "$XDG_RUNTIME_DIR"/dbus.bus ] && pidof river > /dev/null; then + printf "Detected the River environment\n" >&2 + export SXMO_WM=river + unset _XDG_RUNTIME_DIR + return 0 + fi + + if [ -f "${_XDG_RUNTIME_DIR}"/sxmo.i3sock ]; then + if I3SOCK="$(cat "${_XDG_RUNTIME_DIR}"/sxmo.i3sock)" i3-msg 2>/dev/null + then + printf "Detected the i3 environment\n" >&2 + export SXMO_WM=i3 + unset _XDG_RUNTIME_DIR + return 0 + fi + fi + unset _XDG_RUNTIME_DIR + + printf "Sxmo is not running\n" >&2 + return 1 +} + +_sxmo_find_runtime_dir() { + # Take what we gave to you + if [ -n "$XDG_RUNTIME_DIR" ]; then + printf %s "$XDG_RUNTIME_DIR" + return + fi + + # Try something existing + for root in /run /var/run; do + for path in "$root/user-$(id -u)" "$root/user/$(id -u)"; do + if [ -d "$path" ] && [ -w "$path" ]; then + printf %s "$path" + return + fi + done + done + + if command -v mkrundir > /dev/null 2>&1; then + mkrundir + return + fi + + # Fallback to a shared memory location + printf "/dev/shm/user/%s" "$(id -u)" +} + +_sxmo_load_environments() { + if [ -e /etc/os-release ]; then + # shellcheck source=/dev/null + . /etc/os-release + elif [ -e /usr/lib/os-release ]; then + # shellcheck source=/dev/null + . /usr/lib/os-release + fi + export SXMO_OS="${ID:-unknown}" + + export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" + export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" + export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" + XDG_RUNTIME_DIR="$(_sxmo_find_runtime_dir)" + export XDG_RUNTIME_DIR + export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" + + export SXMO_CACHEDIR="${SXMO_CACHEDIR:-$XDG_CACHE_HOME/sxmo}" + + export SXMO_BLOCKDIR="${SXMO_BLOCKDIR:-$XDG_DATA_HOME/sxmo/block}" + export SXMO_BLOCKFILE="${SXMO_BLOCKFILE:-$XDG_CONFIG_HOME/sxmo/block.tsv}" + export SXMO_CONTACTFILE="${SXMO_CONTACTFILE:-$XDG_CONFIG_HOME/sxmo/contacts.tsv}" + export SXMO_STATE="${SXMO_STATE:-$XDG_RUNTIME_DIR/sxmo.state}" + export SXMO_LOGDIR="${SXMO_LOGDIR:-$XDG_DATA_HOME/sxmo/modem}" + export SXMO_NOTIFDIR="${SXMO_NOTIFDIR:-$XDG_DATA_HOME/sxmo/notifications}" + + export BEMENU_OPTS="${BEMENU_OPTS:---fn "Fira Code 9" -H 22 -B 2 --hp 4 -s --no-overlap --fixed-height --scrollbar none --cw 2 --bdr "#005577" --tb "#383838" --tf "#aaaaaa" --fb "#383838" --ff "#ffffff" --cb "#ffffff" --cf "#383838" --nb "#1c1c1c" --nf "#ffffff" --ab "#1c1c1c" --af "#ffffff" --hb "#005577" --hf "#ffffff" -w -i}" + + export EDITOR="${EDITOR:-vim}" + export BROWSER="${BROWSER:-firefox}" + export SHELL="${SHELL:-/bin/sh}" + + PATH="$HOME/.local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" + export PATH + + if [ -z "$SXMO_DEVICE_NAME" ]; then + if [ -e /proc/device-tree/compatible ]; then + SXMO_DEVICE_NAME="$(tr -c '\0[:alnum:].,-' '_' < /proc/device-tree/compatible | + tr '\0' '\n' | head -n1)" + else + SXMO_DEVICE_NAME=desktop + fi + fi + export SXMO_DEVICE_NAME + + deviceprofile="$(command -v "sxmo_deviceprofile_$SXMO_DEVICE_NAME.sh")" + # shellcheck disable=SC1090 + if [ -f "$deviceprofile" ]; then + . "$deviceprofile" + printf "deviceprofile file %s loaded.\n" "$deviceprofile" + else + printf "WARNING: deviceprofile file not found for %s. Most device functions will not work. Please read: https://sxmo.org/deviceprofile \n" "$SXMO_DEVICE_NAME" + touch "$XDG_CACHE_HOME"/sxmo/sxmo.nosuspend + touch "$XDG_CACHE_HOME"/sxmo/sxmo.noidle + fi + unset deviceprofile + + PATH="\ +$HOME/.local/bin:\ +$XDG_CONFIG_HOME/sxmo/hooks/$SXMO_DEVICE_NAME:\ +$XDG_CONFIG_HOME/sxmo/hooks:\ +$(xdg_data_path "sxmo/default_hooks" 0 ':'):\ +$PATH" + export PATH +} + +_sxmo_grab_session() { + if ! _sxmo_is_running; then + return + fi + + XDG_RUNTIME_DIR="$(_sxmo_find_runtime_dir)" + export XDG_RUNTIME_DIR + + _sxmo_load_environments + + if [ -f "$XDG_RUNTIME_DIR"/dbus.bus ]; then + DBUS_SESSION_BUS_ADDRESS="$(cat "$XDG_RUNTIME_DIR"/dbus.bus)" + export DBUS_SESSION_BUS_ADDRESS + if ! dbus-send --dest=org.freedesktop.DBus \ + /org/freedesktop/DBus org.freedesktop.DBus.ListNames \ + 2> /dev/null; then + printf "WARNING: The dbus-send test failed with DBUS_SESSION_BUS_ADDRESS=%s. Unsetting...\n" "$DBUS_SESSION_BUS_ADDRESS" >&2 + unset DBUS_SESSION_BUS_ADDRESS + fi + else + printf "WARNING: No dbus cache file found at %s/dbus.bus.\n" "$XDG_RUNTIME_DIR" >&2 + fi + + case "$SXMO_WM" in + dwm) + [ -z "$DISPLAY" ] && export DISPLAY=:0 + export SXMO_MENU=dmenu + export SXMO_TERMINAL=st + ;; + sway) + if [ -f "$XDG_RUNTIME_DIR"/sxmo.swaysock ]; then + SWAYSOCK="$(cat "$XDG_RUNTIME_DIR"/sxmo.swaysock)" + export SWAYSOCK + fi + ;; + i3) + if [ -f "$XDG_RUNTIME_DIR"/sxmo.i3sock ]; then + I3SOCK="$(cat "$XDG_RUNTIME_DIR"/sxmo.i3sock)" + export I3SOCK + fi + ;; + esac +} + +_sxmo_prepare_dirs() { + uid=$(id -u) + gid=$(id -g) + mkdir -p "$XDG_RUNTIME_DIR" + chmod 700 "$XDG_RUNTIME_DIR" + chown "$uid:$gid" "$XDG_RUNTIME_DIR" + + mkdir -p "$XDG_CACHE_HOME/sxmo/" + chmod 700 "$XDG_CACHE_HOME" + chown "$uid:$gid" "$XDG_CACHE_HOME" + + mkdir -p "$XDG_STATE_HOME" + chmod 700 "$XDG_STATE_HOME" + chown "$uid:$gid" "$XDG_STATE_HOME" +} + +_sxmo_grab_session diff --git a/overlay/rootfs/etc/skel/.Xresources b/overlay/rootfs/etc/skel/.Xresources new file mode 100644 index 0000000..0f52a38 --- /dev/null +++ b/overlay/rootfs/etc/skel/.Xresources @@ -0,0 +1,23 @@ +! Space to setup configversion +! configversion: 7bff124b2de16292fe6e7a7e5d3322ae + +dmenu.font: Fira Code:pixelsize=18:style=Regular:antialias=true:autohint=true +dmenu.background: #1c1c1c +dmenu.foreground: #e0e0e0 +dmenu.selbackground: #005577 +dmenu.selforeground: #ffffff + +dwm.font: Fira Code, DejaVuSansM Nerd Font 15px +dwm.normbgcolor: #323232 +dwm.normbordercolor: #444444 +dwm.normfgcolor: #dddddd +dwm.selbgcolor: #005577 +dwm.selbordercolor: #005577 +dwm.selfgcolor: #ffffff + +st.font: Fira Code:pixelsize=13:antialias=true:autohint=true +st.background: #1c1c1c +st.foreground: #e5e5e5 +st.cursorColor: #cccccc + +svkbd.font: Fira Code:pixelsize=12 diff --git a/overlay/rootfs/etc/skel/.config/foot/foot.ini b/overlay/rootfs/etc/skel/.config/foot/foot.ini deleted file mode 100644 index a263aad..0000000 --- a/overlay/rootfs/etc/skel/.config/foot/foot.ini +++ /dev/null @@ -1,40 +0,0 @@ -# Space to setup configversion -# configversion: 13fb3d2d9f97f4420f7506e72b90e77d -font=monospace:size=13 -dpi-aware=no -pad=2x2 - -[colors-dark] -# alpha=1.0 -foreground=eaeaea -background=000000 -regular0=000000 # black -regular1=d54e53 # red -regular2=b9ca4a # green -regular3=e6c547 # yellow -regular4=7aa6da # blue -regular5=c397d8 # magenta -regular6=70c0ba # cyan -regular7=eaeaea # white -bright0=666666 # bright black -bright1=ff3334 # bright red -bright2=9ec400 # bright green -bright3=e7c547 # bright yellow -bright4=7aa6da # bright blue -bright5=b77ee0 # bright magenta -bright6=54ced6 # bright cyan -bright7=ffffff # bright white - -[scrollback] -lines=5000 - -[key-bindings] -scrollback-up-page=Shift+Page_Up -scrollback-down-page=Shift+Page_Down -scrollback-up-half-page=Page_Up -scrollback-down-half-page=Page_Down -scrollback-up-line=Shift+Up -scrollback-down-line=Shift+Down -scrollback-home=Shift+Home -scrollback-end=Shift+End - diff --git a/overlay/rootfs/etc/skel/.config/sxmo/conky.conf b/overlay/rootfs/etc/skel/.config/sxmo/conky.conf index 8c00ea7..37a7734 100644 --- a/overlay/rootfs/etc/skel/.config/sxmo/conky.conf +++ b/overlay/rootfs/etc/skel/.config/sxmo/conky.conf @@ -1,18 +1,24 @@ -- Space to setup configversion -- configversion: 19ec5c7f9e83bc6534d657f6180feba2 conky.config = { - out_to_x = false, - out_to_wayland = true, + output_backend = 'x11', + out_to_x = true, + out_to_wayland = false, + own_window = true, + own_window_type = 'override', + own_window_transparent = true, + own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', + double_buffer = true, alignment = 'top_middle', - gap_y = 12, - own_window_argb_value = 0, - own_window_type = 'desktop', + gap_x = 0, + gap_y = 34, + default_color = 'white', default_shade_color = 'black', draw_shades = true, - font = 'Sxmo:size=13', + font = 'Fira Code:size=14:style=Regular', use_xft = true, update_interval = 15, } -conky.text = [[${alignc}${font Sxmo:size=34:style=Bold}${time %H:%M}${font} -${alignc}${font Sxmo:size=14:style=Bold}${time %a %d %b %Y}${font}]] +conky.text = [[${alignc}${font Fira Code:size=32:style=Regular}${time %H:%M}${font} +${voffset 4}${alignc}${font Fira Code:size=14:style=Regular}${time %a %d %b %Y}${font}]] diff --git a/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_inputhandler.sh b/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_inputhandler.sh index ed3f8d4..8246223 100755 --- a/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_inputhandler.sh +++ b/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_inputhandler.sh @@ -17,38 +17,51 @@ stop_proximity_lock() { sxmo_jobs.sh stop proximity_lock } -exec 0</dev/null 2>&1 || sxmo_wm.sh display on + else + sxmo_wm.sh display on + fi + if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '255' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true + else + brightnessctl -d white:kbd_backlight set 255 >/dev/null 2>&1 || true + fi + sxmo_state.sh set unlock & + exit 0 + ;; + "voldown_one"|"volup_one") + exec 0</dev/null 2>&1 || true - sxmo_state.sh set unlock - sxmo_wm.sh display on - ;; - "voldown_one") - sxmo_audio.sh vol down 5 - exit + if [ "$ACTION" = "voldown_one" ]; then + sxmo_audio.sh vol down 5 + else + sxmo_audio.sh vol up 5 + fi + exit 0 ;; "voldown_two") sxmo_audio.sh vol down 10 @@ -58,10 +71,6 @@ if sxmo_state.sh is_locked; then sxmo_audio.sh vol down 15 exit ;; - "volup_one") - sxmo_audio.sh vol up 5 - exit - ;; "volup_two") sxmo_audio.sh vol up 10 exit @@ -75,6 +84,31 @@ if sxmo_state.sh is_locked; then exit 0 fi +case "$ACTION" in + "menuleft"*|"enter_two"|"enter_three"|"powerbutton_two"|"powerbutton_three"|"voldown_two"|"volup_two"|"volup_three"|"topleftcorner"|"toprightcorner"|"bottomrightcorner") + WMCLASS="" + WMNAME="" + ;; + *) + if [ -r "$XDG_RUNTIME_DIR/sxmo.focusedwin" ]; then + { + read -r WMCLASS || WMCLASS="" + read -r WMNAME || WMNAME="" + } < "$XDG_RUNTIME_DIR/sxmo.focusedwin" + else + exec 0</dev/null; then sxmo_hook_pickup.sh else sxmo_appmenu.sh "$WMCLASS" "$WMNAME" diff --git a/overlay/rootfs/etc/skel/.config/sxmo/profile b/overlay/rootfs/etc/skel/.config/sxmo/profile new file mode 100755 index 0000000..ce9b5ae --- /dev/null +++ b/overlay/rootfs/etc/skel/.config/sxmo/profile @@ -0,0 +1,89 @@ +#!/bin/sh +# configversion: e7cdaa3a889d251bed8a89ce8c622995 + +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +# Please modify this file to your liking + +# Important Instructions: +# All processes you launch from this script must +# be non-blocking: launch them in the background (using &) +# or ensure they return quickly. Only after this script +# finishes will the window manager be loaded + +# You will sometime get SMS or calls from not +# country code prefixed phone numbers. To make +# it easy to fixup configure the default countryu. +#export DEFAULT_COUNTRY=FR + +### Configuration Parameters ### + +# Note that this is just a subset of all available +# parameters, see the sxmo documentation for more. + +# Use firefox as default browser if installed +command -v firefox >/dev/null && export BROWSER=firefox + +# Prepopulate Subreddits menu with custom subreddits +#export SXMO_SUBREDDITS="postmarketos pinephoneOfficial pinephone unixporn" + +# Change the default terminal command +export TERMCMD="sxmo_terminal.sh" + +# Change the used terminal command +# export SXMO_TERMINAL="st" + +# When scrolling past the beginning or end of a menu, wrap it around: +#export DMENU_WRAP_AROUND=1 + +# Enable audio feedback on keypress +#export KEYBOARD_ARGS="-o | clickclack -f $(xdg_data_path sxmo/keytap.wav)" + +# Or, enable vibration feedback on keypress +#export KEYBOARD_ARGS="-o | clickclack -V" + +# Set the scale factor in sway +# export SXMO_SWAY_SCALE=2 + +# To load specific part of configuration depending on the running environment +case "$SXMO_WM" in + sway) + ;; + dwm) + ;; +esac + +#Set RINGTONE to audio file to play for incoming call +export SXMO_RINGTONE="$(xdg_data_path sxmo/ring.ogg)" + +#Set TEXTSOUND to audio file to play when received text message +export SXMO_TEXTSOUND="$(xdg_data_path sxmo/notify.ogg)" + +#Set RINGTIME to number of seconds the phone will ring +export SXMO_RINGTIME=20 + +#Set RINGNUMBER to number of times phone will ring or repeat ringtone +#(whichever of SXMO_RINGTIME or SXMO_RINGNUMBER runs less will limit how long phone rings) +export SXMO_RINGNUMBER=10 + +#Set to the default text for a new text message. +export SXMO_DEFAULT_DRAFT="Enter new message here." + +export PATH="$HOME/.local/bin:$PATH" +export SXMO_WM="dwm" +export SXMO_MENU="dmenu" +export SXMO_TERMINAL="st" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 +export SXMO_DISABLE_LEDS=1 +export SXMO_NO_VIRTUAL_KEYBOARD=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 +export GTK_IM_MODULE=fcitx +export QT_IM_MODULE=fcitx +export XMODIFIERS=@im=fcitx + +export SXMO_BG_IMG="/usr/share/wallpapers/bananarchy.png" diff --git a/overlay/rootfs/etc/skel/.config/sxmo/sway b/overlay/rootfs/etc/skel/.config/sxmo/sway deleted file mode 100644 index de6396b..0000000 --- a/overlay/rootfs/etc/skel/.config/sxmo/sway +++ /dev/null @@ -1,296 +0,0 @@ -# Default config for sway -# configversion: 076611fe8cc699bcaa01092a8e4481c0 -# -# Copy this to ~/.config/sway/config and edit it to your liking. -# -# Read `man 5 sway` for a complete reference. - -### Variables -# -# Logo key. Use Mod1 for Alt. -set $mod Mod4 -# Home row direction keys, like vim -set $left h -set $down j -set $up k -set $right l -# Your preferred terminal emulator -set $term sxmo_terminal.sh -# Your preferred application launcher -# Note: pass the final command to swaymsg so that the resulting window can be opened -# on the original workspace that the command was run on. -set $menu bemenu-run - -font "Sxmo 13" -xwayland disable -output * scale 1 bg /usr/share/wallpapers/bananarchy.png fill -default_orientation vertical - -exec_always sxmo_swayinitconf.sh - -exec_always dbus-update-activation-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP - -mode "menu" { - bindsym --locked XF86PowerOff exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym --locked XF86PickupPhone exec sh -c "if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; else wtype -k Return; fi" - bindsym --locked XF86KbdLcdMenu1 exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym --locked XF86KbdLcdMenu2 exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym XF86AudioRaiseVolume exec wtype -k Up - bindsym XF86AudioLowerVolume exec wtype -k Down - bindswitch --locked lid:on exec sh -c "sxmo_dmenu.sh close; brightnessctl -d white:kbd_backlight set 0; sxmo_state.sh set screenoff" - bindswitch --locked lid:off exec sh -c "brightnessctl -d white:kbd_backlight set 255; sxmo_state.sh set unlock; sxmo_wm.sh display on" -} - -# Mode specifically for use with Nokia N900 hardware keyboard -mode "N900" { - # follow the standard sxmo keybinds as far as possible - bindsym t exec $term; mode "default" - bindsym q mode "default" - bindsym Shift+p exec sxmo_appmenu.sh sys; mode "default" - bindsym p exec sxmo_appmenu.sh; mode "default" - bindsym d exec $menu; mode "default" - bindsym Shift+q kill; mode "default" - bindsym i exec sxmo_wmmenu.sh windowswitcher; mode "default" - bindsym Shift+c reload; mode "default" - bindsym f fullscreen; mode "default" - bindsym Shift+space floating toggle; mode "default" - bindsym a focus parent; mode "default" -} - -### Key bindings -# -# Basics: -# - input * xkb_options compose:ralt - - # Nokia N900 hardware keyboard - input "1:1:TWL4030_Keypad" { - xkb_model "nokiarx51" - xkb_layout "us" - # ralt has special meaning on N900 keyboard so do not use as - # compose key - xkb_options compose:rwin - } - - # Start a terminal - bindsym $mod+Return exec $term - - # Launch appmenu - bindsym $mod+p exec sxmo_appmenu.sh - bindsym $mod+Shift+p exec sxmo_appmenu.sh sys - - # Wm menu switcher - bindsym $mod+i exec sxmo_wmmenu.sh windowswitcher - - # Kill focused window - bindsym $mod+Shift+q kill - - # Start your launcher - bindsym $mod+d exec $menu - - # Drag floating windows by holding down $mod and left mouse button. - # Resize them with right mouse button + $mod. - # Despite the name, also works for non-floating windows. - # Change normal to inverse to use left mouse button for resizing and right - # mouse button for dragging. - floating_modifier $mod normal - - # Reload the configuration file - bindsym $mod+Shift+c reload - - # Exit sway (logs you out of your Wayland session) - bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'sxmo_power.sh logout' -# -# Moving around: -# - # Move your focus around - bindsym $mod+$left focus left - bindsym $mod+$down focus down - bindsym $mod+$up focus up - bindsym $mod+$right focus right - # Or use $mod+[up|down|left|right] - bindsym $mod+Left focus left - bindsym $mod+Down focus down - bindsym $mod+Up focus up - bindsym $mod+Right focus right - - # Move the focused window with the same, but add Shift - bindsym $mod+Shift+$left move left - bindsym $mod+Shift+$down move down - bindsym $mod+Shift+$up move up - bindsym $mod+Shift+$right move right - # Ditto, with arrow keys - bindsym $mod+Shift+Left move left - bindsym $mod+Shift+Down move down - bindsym $mod+Shift+Up move up - bindsym $mod+Shift+Right move right - - # Move the focused workspace to output - bindsym $mod+Shift+Ctrl+$left move workspace output left - bindsym $mod+Shift+Ctrl+$down move workspace output down - bindsym $mod+Shift+Ctrl+$up move workspace output up - bindsym $mod+Shift+Ctrl+$right move workspace output right -# -# Workspaces: -# - # Switch to workspace - bindsym $mod+1 workspace number 1 - bindsym $mod+2 workspace number 2 - bindsym $mod+3 workspace number 3 - bindsym $mod+4 workspace number 4 - bindsym $mod+5 workspace number 5 - bindsym $mod+6 workspace number 6 - bindsym $mod+7 workspace number 7 - bindsym $mod+8 workspace number 8 - bindsym $mod+9 workspace number 9 - bindsym $mod+0 workspace number 10 - # Move focused container to workspace - bindsym $mod+Shift+1 move container to workspace number 1 - bindsym $mod+Shift+2 move container to workspace number 2 - bindsym $mod+Shift+3 move container to workspace number 3 - bindsym $mod+Shift+4 move container to workspace number 4 - bindsym $mod+Shift+5 move container to workspace number 5 - bindsym $mod+Shift+6 move container to workspace number 6 - bindsym $mod+Shift+7 move container to workspace number 7 - bindsym $mod+Shift+8 move container to workspace number 8 - bindsym $mod+Shift+9 move container to workspace number 9 - bindsym $mod+Shift+0 move container to workspace number 10 - # Note: workspaces can have any name you want, not just numbers. - # We just use 1-10 as the default. -# -# Layout stuff: -# - # You can "split" the current object of your focus with - # $mod+b or $mod+v, for horizontal and vertical splits - # respectively. - bindsym $mod+b splith - bindsym $mod+v splitv - - # Switch the current container between different layout styles - bindsym $mod+s layout stacking - bindsym $mod+w layout tabbed - bindsym $mod+e layout toggle split - - # Make the current focus fullscreen - bindsym $mod+f fullscreen - - # Toggle the current focus between tiling and floating mode - bindsym $mod+Shift+space floating toggle - - # Swap focus between the tiling area and the floating area - bindsym $mod+space focus mode_toggle - - # Move focus to the parent container - bindsym $mod+a focus parent - - # Manual locker - bindsym $mod+g exec sxmo_state.sh set locker - - # Shutdown - bindsym $mod+t exec sxmo_appmenu.sh power - -# -# Scratchpad: -# - # Sway has a "scratchpad", which is a bag of holding for windows. - # You can send windows there and get them back later. - - # Move the currently focused window to the scratchpad - bindsym $mod+Shift+minus move scratchpad - - # Show the next scratchpad window or hide the focused scratchpad window. - # If there are multiple scratchpad windows, this command cycles through them. - bindsym $mod+minus scratchpad show -# -# Resizing containers: -# -mode "resize" { - # left will shrink the containers width - # right will grow the containers width - # up will shrink the containers height - # down will grow the containers height - bindsym $left resize shrink width 30px - bindsym $down resize grow height 30px - bindsym $up resize shrink height 30px - bindsym $right resize grow width 30px - - # Ditto, with arrow keys - bindsym Left resize shrink width 30px - bindsym Down resize grow height 30px - bindsym Up resize shrink height 30px - bindsym Right resize grow width 30px - - # Return to default mode - bindsym Return mode "default" - bindsym Escape mode "default" -} -bindsym $mod+r mode "resize" - -# -# Status Bar: -# -# Read `man 5 sway-bar` for more information about this section. -bar { - position top - height 24 - font "Sxmo 13" - - # When the status_command prints a new line to stdout, swaybar updates. - # The default just shows the current date and time. - status_command sxmo_status_watch.sh -o pango - - pango_markup enabled - - colors { - statusline #ffffff - background #323232 - inactive_workspace #323232 #323232 #ffffff - font "Sxmo 13" - } -} - -for_window [app_id="pinentry-.*"] floating true -for_window [app_id="foot" title=".*sxmo/modem/.*/draft.txt.*"] resize set height 25 -for_window [title="megapixels"] inhibit_idle open -for_window [title="ep[yr].*"] inhibit_idle visible - -default_border pixel 2 -titlebar_border_thickness 2 -hide_edge_borders smart - -# Need playerctl installed and running -bindsym --locked XF86AudioPlay exec playerctl play-pause -bindsym --locked XF86AudioPause exec playerctl play-pause -bindsym --locked XF86AudioStop exec playerctl stop -bindsym --locked XF86AudioNext exec playerctl next -bindsym --locked XF86AudioPrev exec playerctl previous - -bindsym --locked XF86MonBrightnessUp exec sxmo_brightness.sh up -bindsym --locked XF86MonBrightnessDown exec sxmo_brightness.sh down - -# Nokia N900-specific key bindings: -# 1. Bind lock key (XF86ScreenSaver) -# Use keycode due to https://github.com/swaywm/sway/issues/8438 -bindcode --release --locked --input-device="1:1:gpio_keys" 160 exec sxmo_state.sh set unlock -# 2. Workaround the lack of a free ModX key on hardware keyboard -bindsym --input-device="1:1:TWL4030_Keypad" Shift+space mode "N900" - -bindsym Print exec sxmo_screenshot.sh - -bindsym button2 kill - -bindswitch --locked lid:on exec sh -c "brightnessctl -d white:kbd_backlight set 0; sxmo_state.sh set screenoff" -bindswitch --locked lid:off exec sh -c "brightnessctl -d white:kbd_backlight set 255; sxmo_state.sh set unlock; sxmo_wm.sh display on" - -# Nokia 8110 4G hardware keypad bindings (User:Ybon) -bindsym --locked --no-repeat XF86KbdLcdMenu1 exec sxmo_hook_inputhandler.sh menuleft_one -bindsym --locked --no-repeat XF86KbdLcdMenu2 exec sxmo_hook_inputhandler.sh menuright_one -bindsym --locked --no-repeat XF86PickupPhone exec sxmo_multikey.sh pickup enter_one enter_two enter_three - -include /etc/sway/config.d/* - -exec 'printf %s "$SWAYSOCK" > "$XDG_RUNTIME_DIR"/sxmo.swaysock' - -exec sxmo_hook_start.sh - -# vim: ft=swayconfig diff --git a/overlay/rootfs/etc/skel/.config/sxmo/xinit b/overlay/rootfs/etc/skel/.config/sxmo/xinit new file mode 100755 index 0000000..08a1ae8 --- /dev/null +++ b/overlay/rootfs/etc/skel/.config/sxmo/xinit @@ -0,0 +1,7 @@ +#!/bin/sh +# configversion: 36730424afa6d6bf9e9fb6d111c35504 + +dbus-update-activation-environment DISPLAY XDG_CURRENT_DESKTOP + +# Run actions on start +sxmo_hook_start.sh & diff --git a/overlay/rootfs/etc/skel/.profile b/overlay/rootfs/etc/skel/.profile new file mode 100644 index 0000000..d2ff062 --- /dev/null +++ b/overlay/rootfs/etc/skel/.profile @@ -0,0 +1,16 @@ +export PATH="$HOME/.local/bin:$PATH" + +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 +export SXMO_DISABLE_LEDS=1 +export SXMO_NO_VIRTUAL_KEYBOARD=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 +export GTK_IM_MODULE=fcitx +export QT_IM_MODULE=fcitx +export XMODIFIERS=@im=fcitx diff --git a/overlay/rootfs/etc/udev/rules.d/90-nokia-argon-leds.rules b/overlay/rootfs/etc/udev/rules.d/90-nokia-argon-leds.rules index b813e09..3e91d6b 100644 --- a/overlay/rootfs/etc/udev/rules.d/90-nokia-argon-leds.rules +++ b/overlay/rootfs/etc/udev/rules.d/90-nokia-argon-leds.rules @@ -1 +1,2 @@ SUBSYSTEM=="leds", ACTION=="add", RUN+="/bin/chgrp video /sys/class/leds/%k/brightness", RUN+="/bin/chmod 0664 /sys/class/leds/%k/brightness" +SUBSYSTEM=="backlight", ACTION=="add", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power", RUN+="/bin/chmod 0664 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power" diff --git a/overlay/rootfs/home/user/.Xresources b/overlay/rootfs/home/user/.Xresources new file mode 100644 index 0000000..1c20b87 --- /dev/null +++ b/overlay/rootfs/home/user/.Xresources @@ -0,0 +1,23 @@ +! Space to setup configversion +! configversion: 7bff124b2de16292fe6e7a7e5d3322ae + +dmenu.font: Fira Code:pixelsize=18:style=Regular:antialias=true:autohint=true +dmenu.background: #1c1c1c +dmenu.foreground: #e0e0e0 +dmenu.selbackground: #005577 +dmenu.selforeground: #ffffff + +dwm.font: Fira Code, DejaVuSansM Nerd Font 15px +dwm.normbgcolor: #323232 +dwm.normbordercolor: #444444 +dwm.normfgcolor: #dddddd +dwm.selbgcolor: #005577 +dwm.selbordercolor: #005577 +dwm.selfgcolor: #ffffff + +st.font: Fira Code:pixelsize=15:style=Regular:antialias=true:autohint=true +st.background: #1c1c1c +st.foreground: #e5e5e5 +st.cursorColor: #cccccc + +svkbd.font: Fira Code:pixelsize=12 diff --git a/overlay/rootfs/home/user/.config/dunst/dunstrc b/overlay/rootfs/home/user/.config/dunst/dunstrc index 2759edb..a8674fc 100644 --- a/overlay/rootfs/home/user/.config/dunst/dunstrc +++ b/overlay/rootfs/home/user/.config/dunst/dunstrc @@ -9,7 +9,7 @@ frame_width = 2 frame_color = "#005577" idle_threshold = 120 - font = Monospace 12 + font = Fira Code 9.5 markup = full max_icon_size = 24 dmenu = sxmo_dmenu.sh -p dunst: diff --git a/overlay/rootfs/home/user/.config/fcitx5/conf/classicui.conf b/overlay/rootfs/home/user/.config/fcitx5/conf/classicui.conf index 1c0446c..50ffefb 100644 --- a/overlay/rootfs/home/user/.config/fcitx5/conf/classicui.conf +++ b/overlay/rootfs/home/user/.config/fcitx5/conf/classicui.conf @@ -1,8 +1,8 @@ Vertical Candidate List=False WheelForPaging=True -Font="Sans Bold 13" -MenuFont="Sans 13" -TrayFont="Sans Bold 13" +Font="Fira Code 9.5" +MenuFont="Fira Code 9.5" +TrayFont="Fira Code 9.5" PreferTextIcon=True ShowLayoutNameInIcon=True UseInputMethodLanguageToDisplayText=True diff --git a/overlay/rootfs/home/user/.config/fontconfig/conf.d/50-sxmo.conf b/overlay/rootfs/home/user/.config/fontconfig/conf.d/50-sxmo.conf new file mode 100644 index 0000000..dadd651 --- /dev/null +++ b/overlay/rootfs/home/user/.config/fontconfig/conf.d/50-sxmo.conf @@ -0,0 +1,37 @@ + + + + + + Sxmo + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + + monospace + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + + sans-serif + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + + serif + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + diff --git a/overlay/rootfs/home/user/.config/foot/foot.ini b/overlay/rootfs/home/user/.config/foot/foot.ini deleted file mode 100644 index a263aad..0000000 --- a/overlay/rootfs/home/user/.config/foot/foot.ini +++ /dev/null @@ -1,40 +0,0 @@ -# Space to setup configversion -# configversion: 13fb3d2d9f97f4420f7506e72b90e77d -font=monospace:size=13 -dpi-aware=no -pad=2x2 - -[colors-dark] -# alpha=1.0 -foreground=eaeaea -background=000000 -regular0=000000 # black -regular1=d54e53 # red -regular2=b9ca4a # green -regular3=e6c547 # yellow -regular4=7aa6da # blue -regular5=c397d8 # magenta -regular6=70c0ba # cyan -regular7=eaeaea # white -bright0=666666 # bright black -bright1=ff3334 # bright red -bright2=9ec400 # bright green -bright3=e7c547 # bright yellow -bright4=7aa6da # bright blue -bright5=b77ee0 # bright magenta -bright6=54ced6 # bright cyan -bright7=ffffff # bright white - -[scrollback] -lines=5000 - -[key-bindings] -scrollback-up-page=Shift+Page_Up -scrollback-down-page=Shift+Page_Down -scrollback-up-half-page=Page_Up -scrollback-down-half-page=Page_Down -scrollback-up-line=Shift+Up -scrollback-down-line=Shift+Down -scrollback-home=Shift+Home -scrollback-end=Shift+End - diff --git a/overlay/rootfs/home/user/.config/gtk-3.0/settings.ini b/overlay/rootfs/home/user/.config/gtk-3.0/settings.ini index e978463..b6f5a33 100644 --- a/overlay/rootfs/home/user/.config/gtk-3.0/settings.ini +++ b/overlay/rootfs/home/user/.config/gtk-3.0/settings.ini @@ -1,3 +1,3 @@ [Settings] gtk-application-prefer-dark-theme=1 -gtk-font-name=Sans 13 +gtk-font-name=Fira Code 10 diff --git a/overlay/rootfs/home/user/.config/sxmo/conky.conf b/overlay/rootfs/home/user/.config/sxmo/conky.conf index 8c00ea7..37a7734 100644 --- a/overlay/rootfs/home/user/.config/sxmo/conky.conf +++ b/overlay/rootfs/home/user/.config/sxmo/conky.conf @@ -1,18 +1,24 @@ -- Space to setup configversion -- configversion: 19ec5c7f9e83bc6534d657f6180feba2 conky.config = { - out_to_x = false, - out_to_wayland = true, + output_backend = 'x11', + out_to_x = true, + out_to_wayland = false, + own_window = true, + own_window_type = 'override', + own_window_transparent = true, + own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', + double_buffer = true, alignment = 'top_middle', - gap_y = 12, - own_window_argb_value = 0, - own_window_type = 'desktop', + gap_x = 0, + gap_y = 34, + default_color = 'white', default_shade_color = 'black', draw_shades = true, - font = 'Sxmo:size=13', + font = 'Fira Code:size=14:style=Regular', use_xft = true, update_interval = 15, } -conky.text = [[${alignc}${font Sxmo:size=34:style=Bold}${time %H:%M}${font} -${alignc}${font Sxmo:size=14:style=Bold}${time %a %d %b %Y}${font}]] +conky.text = [[${alignc}${font Fira Code:size=32:style=Regular}${time %H:%M}${font} +${voffset 4}${alignc}${font Fira Code:size=14:style=Regular}${time %a %d %b %Y}${font}]] diff --git a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_inputhandler.sh b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_inputhandler.sh index ed3f8d4..8246223 100755 --- a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_inputhandler.sh +++ b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_inputhandler.sh @@ -17,38 +17,51 @@ stop_proximity_lock() { sxmo_jobs.sh stop proximity_lock } -exec 0</dev/null 2>&1 || sxmo_wm.sh display on + else + sxmo_wm.sh display on + fi + if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '255' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true + else + brightnessctl -d white:kbd_backlight set 255 >/dev/null 2>&1 || true + fi + sxmo_state.sh set unlock & + exit 0 + ;; + "voldown_one"|"volup_one") + exec 0</dev/null 2>&1 || true - sxmo_state.sh set unlock - sxmo_wm.sh display on - ;; - "voldown_one") - sxmo_audio.sh vol down 5 - exit + if [ "$ACTION" = "voldown_one" ]; then + sxmo_audio.sh vol down 5 + else + sxmo_audio.sh vol up 5 + fi + exit 0 ;; "voldown_two") sxmo_audio.sh vol down 10 @@ -58,10 +71,6 @@ if sxmo_state.sh is_locked; then sxmo_audio.sh vol down 15 exit ;; - "volup_one") - sxmo_audio.sh vol up 5 - exit - ;; "volup_two") sxmo_audio.sh vol up 10 exit @@ -75,6 +84,31 @@ if sxmo_state.sh is_locked; then exit 0 fi +case "$ACTION" in + "menuleft"*|"enter_two"|"enter_three"|"powerbutton_two"|"powerbutton_three"|"voldown_two"|"volup_two"|"volup_three"|"topleftcorner"|"toprightcorner"|"bottomrightcorner") + WMCLASS="" + WMNAME="" + ;; + *) + if [ -r "$XDG_RUNTIME_DIR/sxmo.focusedwin" ]; then + { + read -r WMCLASS || WMCLASS="" + read -r WMNAME || WMNAME="" + } < "$XDG_RUNTIME_DIR/sxmo.focusedwin" + else + exec 0</dev/null; then sxmo_hook_pickup.sh else sxmo_appmenu.sh "$WMCLASS" "$WMNAME" diff --git a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh index 80f1f22..05c9c36 100755 --- a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh @@ -10,13 +10,18 @@ . sxmo_common.sh # Create xdg user directories, such as ~/Pictures -xdg-user-dirs-update +[ -d "$HOME/Pictures" ] || xdg-user-dirs-update & + +# Ensure fontconfig cache is valid without forcing a full rescan on every boot +if command -v fc-cache > /dev/null && [ -z "$(ls -A /var/cache/fontconfig 2>/dev/null)" ]; then + fc-cache >/dev/null 2>&1 & +fi sxmo_jobs.sh start daemon_manager superd # let time to superd to start correctly while ! superctl status > /dev/null 2>&1; do - sleep 0.5 + sleep 0.05 done # Not dangerous if "locker" isn't an available state @@ -54,48 +59,14 @@ superctl start dunst # start adaptive brightness at boot # superctl start sxmo_adaptivebrightness -# load some other little things here too. -case "$SXMO_WM" in - river) - superctl start sxmo_wob - [ "$(command -v bonsaid)" ] && superctl start bonsaid - [ "$(command -v fcitx5)" ] && superctl start fcitx5 - superctl start sxmo_riverbar - ;; - sway) - superctl start sxmo_wob - superctl start sxmo_menumode_toggler - [ "$(command -v bonsaid)" ] && superctl start bonsaid - [ "$(command -v fcitx5)" ] && superctl start fcitx5 - ;; - dwm|i3) - superctl start sxmo_xob - - # Auto hide cursor with touchscreen, Show it with a mouse - if command -v "unclutter-xfixes" > /dev/null; then - set -- unclutter-xfixes - else - set -- unclutter - fi - superctl start "$1" - - superctl start autocutsel - superctl start autocutsel-primary - superctl start sxmo-x11-status - [ "$(command -v bonsaid)" ] && superctl start bonsaid - [ "$(command -v fcitx5)" ] && superctl start fcitx5 - [ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary - # Set onboard to auto-hide in config first - if [ "$KEYBOARD" = "onboard" ]; then - onboard "$KEYBOARD_ARGS" - fi - case "$SXMO_WM" in - i3) - xbindkeys -f "$XDG_CONFIG_HOME/sxmo/xbindkeysrc_$SXMO_BINDING_PROVIDER" - ;; - esac - ;; -esac +# load X11 dwm services +[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob +pidof -s sxmo_status_xsetroot.sh >/dev/null 2>&1 || superctl start sxmo-x11-status +[ "$(command -v bonsaid)" ] && superctl start bonsaid +if ! pidof -s fcitx5 >/dev/null 2>&1 && [ "$(command -v fcitx5)" ]; then + superctl start fcitx5 +fi +[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary # Turn on auto-suspend if sxmo_wakelock.sh isenabled; then @@ -106,8 +77,8 @@ fi # To setup initial unlock state sxmo_state.sh set unlock -# Turn on lisgd -if [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then +# Turn on lisgd only on touch devices +if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then superctl start sxmo_hook_lisgd fi @@ -120,11 +91,8 @@ if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then sxmo_wakelock.sh lock sxmo_modem_warming_up 120s fi -# Start the desktop wallpaper -superctl start sxmo_bg - # Start the desktop widget (e.g. clock) -superctl start sxmo_conky +pidof -s conky >/dev/null 2>&1 || superctl start sxmo_conky # Monitor the battery superctl start sxmo_battery_monitor @@ -135,25 +103,8 @@ superctl start sxmo_networkmonitor # The daemon that display notifications popup messages superctl start sxmo_notificationmonitor -# Play a funky startup tune if you want (disabled by default) -#mpv --quiet --no-video ~/welcome.ogg & - -# mmsd and vvmd -if [ -z "$SXMO_NO_MODEM" ]; then - if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then - superctl start mmsd-tng - fi - - if [ -f "${SXMO_VVM_BASE_DIR:-"$HOME"/.vvm/modemmanager}/vvm" ]; then - superctl start vvmd - fi -fi - -# add some warnings if things are not setup correctly -if ! command -v "sxmo_deviceprofile_$SXMO_DEVICE_NAME.sh"; then - sxmo_notify_user.sh --urgency=critical \ - "No deviceprofile found $SXMO_DEVICE_NAME. See: https://sxmo.org/deviceprofile" -fi - -sxmo_migrate.sh state || sxmo_notify_user.sh --urgency=critical \ - "Config needs migration" "$? file(s) in your sxmo configuration are out of date and disabled - using defaults until you migrate (run sxmo_migrate.sh)" +# Pre-warm app and script menu caches in background +( + sxmo_hook_apps.sh >/dev/null 2>&1 || true + sxmo_hook_scripts.sh >/dev/null 2>&1 || true +) & diff --git a/overlay/rootfs/home/user/.config/sxmo/profile b/overlay/rootfs/home/user/.config/sxmo/profile old mode 100644 new mode 100755 index c378277..ce9b5ae --- a/overlay/rootfs/home/user/.config/sxmo/profile +++ b/overlay/rootfs/home/user/.config/sxmo/profile @@ -70,9 +70,20 @@ export SXMO_RINGNUMBER=10 #Set to the default text for a new text message. export SXMO_DEFAULT_DRAFT="Enter new message here." +export PATH="$HOME/.local/bin:$PATH" +export SXMO_WM="dwm" +export SXMO_MENU="dmenu" +export SXMO_TERMINAL="st" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 +export SXMO_DISABLE_LEDS=1 +export SXMO_NO_VIRTUAL_KEYBOARD=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx -export SXMO_MENU=wofi export SXMO_BG_IMG="/usr/share/wallpapers/bananarchy.png" diff --git a/overlay/rootfs/home/user/.config/sxmo/sway b/overlay/rootfs/home/user/.config/sxmo/sway deleted file mode 100644 index de6396b..0000000 --- a/overlay/rootfs/home/user/.config/sxmo/sway +++ /dev/null @@ -1,296 +0,0 @@ -# Default config for sway -# configversion: 076611fe8cc699bcaa01092a8e4481c0 -# -# Copy this to ~/.config/sway/config and edit it to your liking. -# -# Read `man 5 sway` for a complete reference. - -### Variables -# -# Logo key. Use Mod1 for Alt. -set $mod Mod4 -# Home row direction keys, like vim -set $left h -set $down j -set $up k -set $right l -# Your preferred terminal emulator -set $term sxmo_terminal.sh -# Your preferred application launcher -# Note: pass the final command to swaymsg so that the resulting window can be opened -# on the original workspace that the command was run on. -set $menu bemenu-run - -font "Sxmo 13" -xwayland disable -output * scale 1 bg /usr/share/wallpapers/bananarchy.png fill -default_orientation vertical - -exec_always sxmo_swayinitconf.sh - -exec_always dbus-update-activation-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP - -mode "menu" { - bindsym --locked XF86PowerOff exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym --locked XF86PickupPhone exec sh -c "if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; else wtype -k Return; fi" - bindsym --locked XF86KbdLcdMenu1 exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym --locked XF86KbdLcdMenu2 exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym XF86AudioRaiseVolume exec wtype -k Up - bindsym XF86AudioLowerVolume exec wtype -k Down - bindswitch --locked lid:on exec sh -c "sxmo_dmenu.sh close; brightnessctl -d white:kbd_backlight set 0; sxmo_state.sh set screenoff" - bindswitch --locked lid:off exec sh -c "brightnessctl -d white:kbd_backlight set 255; sxmo_state.sh set unlock; sxmo_wm.sh display on" -} - -# Mode specifically for use with Nokia N900 hardware keyboard -mode "N900" { - # follow the standard sxmo keybinds as far as possible - bindsym t exec $term; mode "default" - bindsym q mode "default" - bindsym Shift+p exec sxmo_appmenu.sh sys; mode "default" - bindsym p exec sxmo_appmenu.sh; mode "default" - bindsym d exec $menu; mode "default" - bindsym Shift+q kill; mode "default" - bindsym i exec sxmo_wmmenu.sh windowswitcher; mode "default" - bindsym Shift+c reload; mode "default" - bindsym f fullscreen; mode "default" - bindsym Shift+space floating toggle; mode "default" - bindsym a focus parent; mode "default" -} - -### Key bindings -# -# Basics: -# - input * xkb_options compose:ralt - - # Nokia N900 hardware keyboard - input "1:1:TWL4030_Keypad" { - xkb_model "nokiarx51" - xkb_layout "us" - # ralt has special meaning on N900 keyboard so do not use as - # compose key - xkb_options compose:rwin - } - - # Start a terminal - bindsym $mod+Return exec $term - - # Launch appmenu - bindsym $mod+p exec sxmo_appmenu.sh - bindsym $mod+Shift+p exec sxmo_appmenu.sh sys - - # Wm menu switcher - bindsym $mod+i exec sxmo_wmmenu.sh windowswitcher - - # Kill focused window - bindsym $mod+Shift+q kill - - # Start your launcher - bindsym $mod+d exec $menu - - # Drag floating windows by holding down $mod and left mouse button. - # Resize them with right mouse button + $mod. - # Despite the name, also works for non-floating windows. - # Change normal to inverse to use left mouse button for resizing and right - # mouse button for dragging. - floating_modifier $mod normal - - # Reload the configuration file - bindsym $mod+Shift+c reload - - # Exit sway (logs you out of your Wayland session) - bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'sxmo_power.sh logout' -# -# Moving around: -# - # Move your focus around - bindsym $mod+$left focus left - bindsym $mod+$down focus down - bindsym $mod+$up focus up - bindsym $mod+$right focus right - # Or use $mod+[up|down|left|right] - bindsym $mod+Left focus left - bindsym $mod+Down focus down - bindsym $mod+Up focus up - bindsym $mod+Right focus right - - # Move the focused window with the same, but add Shift - bindsym $mod+Shift+$left move left - bindsym $mod+Shift+$down move down - bindsym $mod+Shift+$up move up - bindsym $mod+Shift+$right move right - # Ditto, with arrow keys - bindsym $mod+Shift+Left move left - bindsym $mod+Shift+Down move down - bindsym $mod+Shift+Up move up - bindsym $mod+Shift+Right move right - - # Move the focused workspace to output - bindsym $mod+Shift+Ctrl+$left move workspace output left - bindsym $mod+Shift+Ctrl+$down move workspace output down - bindsym $mod+Shift+Ctrl+$up move workspace output up - bindsym $mod+Shift+Ctrl+$right move workspace output right -# -# Workspaces: -# - # Switch to workspace - bindsym $mod+1 workspace number 1 - bindsym $mod+2 workspace number 2 - bindsym $mod+3 workspace number 3 - bindsym $mod+4 workspace number 4 - bindsym $mod+5 workspace number 5 - bindsym $mod+6 workspace number 6 - bindsym $mod+7 workspace number 7 - bindsym $mod+8 workspace number 8 - bindsym $mod+9 workspace number 9 - bindsym $mod+0 workspace number 10 - # Move focused container to workspace - bindsym $mod+Shift+1 move container to workspace number 1 - bindsym $mod+Shift+2 move container to workspace number 2 - bindsym $mod+Shift+3 move container to workspace number 3 - bindsym $mod+Shift+4 move container to workspace number 4 - bindsym $mod+Shift+5 move container to workspace number 5 - bindsym $mod+Shift+6 move container to workspace number 6 - bindsym $mod+Shift+7 move container to workspace number 7 - bindsym $mod+Shift+8 move container to workspace number 8 - bindsym $mod+Shift+9 move container to workspace number 9 - bindsym $mod+Shift+0 move container to workspace number 10 - # Note: workspaces can have any name you want, not just numbers. - # We just use 1-10 as the default. -# -# Layout stuff: -# - # You can "split" the current object of your focus with - # $mod+b or $mod+v, for horizontal and vertical splits - # respectively. - bindsym $mod+b splith - bindsym $mod+v splitv - - # Switch the current container between different layout styles - bindsym $mod+s layout stacking - bindsym $mod+w layout tabbed - bindsym $mod+e layout toggle split - - # Make the current focus fullscreen - bindsym $mod+f fullscreen - - # Toggle the current focus between tiling and floating mode - bindsym $mod+Shift+space floating toggle - - # Swap focus between the tiling area and the floating area - bindsym $mod+space focus mode_toggle - - # Move focus to the parent container - bindsym $mod+a focus parent - - # Manual locker - bindsym $mod+g exec sxmo_state.sh set locker - - # Shutdown - bindsym $mod+t exec sxmo_appmenu.sh power - -# -# Scratchpad: -# - # Sway has a "scratchpad", which is a bag of holding for windows. - # You can send windows there and get them back later. - - # Move the currently focused window to the scratchpad - bindsym $mod+Shift+minus move scratchpad - - # Show the next scratchpad window or hide the focused scratchpad window. - # If there are multiple scratchpad windows, this command cycles through them. - bindsym $mod+minus scratchpad show -# -# Resizing containers: -# -mode "resize" { - # left will shrink the containers width - # right will grow the containers width - # up will shrink the containers height - # down will grow the containers height - bindsym $left resize shrink width 30px - bindsym $down resize grow height 30px - bindsym $up resize shrink height 30px - bindsym $right resize grow width 30px - - # Ditto, with arrow keys - bindsym Left resize shrink width 30px - bindsym Down resize grow height 30px - bindsym Up resize shrink height 30px - bindsym Right resize grow width 30px - - # Return to default mode - bindsym Return mode "default" - bindsym Escape mode "default" -} -bindsym $mod+r mode "resize" - -# -# Status Bar: -# -# Read `man 5 sway-bar` for more information about this section. -bar { - position top - height 24 - font "Sxmo 13" - - # When the status_command prints a new line to stdout, swaybar updates. - # The default just shows the current date and time. - status_command sxmo_status_watch.sh -o pango - - pango_markup enabled - - colors { - statusline #ffffff - background #323232 - inactive_workspace #323232 #323232 #ffffff - font "Sxmo 13" - } -} - -for_window [app_id="pinentry-.*"] floating true -for_window [app_id="foot" title=".*sxmo/modem/.*/draft.txt.*"] resize set height 25 -for_window [title="megapixels"] inhibit_idle open -for_window [title="ep[yr].*"] inhibit_idle visible - -default_border pixel 2 -titlebar_border_thickness 2 -hide_edge_borders smart - -# Need playerctl installed and running -bindsym --locked XF86AudioPlay exec playerctl play-pause -bindsym --locked XF86AudioPause exec playerctl play-pause -bindsym --locked XF86AudioStop exec playerctl stop -bindsym --locked XF86AudioNext exec playerctl next -bindsym --locked XF86AudioPrev exec playerctl previous - -bindsym --locked XF86MonBrightnessUp exec sxmo_brightness.sh up -bindsym --locked XF86MonBrightnessDown exec sxmo_brightness.sh down - -# Nokia N900-specific key bindings: -# 1. Bind lock key (XF86ScreenSaver) -# Use keycode due to https://github.com/swaywm/sway/issues/8438 -bindcode --release --locked --input-device="1:1:gpio_keys" 160 exec sxmo_state.sh set unlock -# 2. Workaround the lack of a free ModX key on hardware keyboard -bindsym --input-device="1:1:TWL4030_Keypad" Shift+space mode "N900" - -bindsym Print exec sxmo_screenshot.sh - -bindsym button2 kill - -bindswitch --locked lid:on exec sh -c "brightnessctl -d white:kbd_backlight set 0; sxmo_state.sh set screenoff" -bindswitch --locked lid:off exec sh -c "brightnessctl -d white:kbd_backlight set 255; sxmo_state.sh set unlock; sxmo_wm.sh display on" - -# Nokia 8110 4G hardware keypad bindings (User:Ybon) -bindsym --locked --no-repeat XF86KbdLcdMenu1 exec sxmo_hook_inputhandler.sh menuleft_one -bindsym --locked --no-repeat XF86KbdLcdMenu2 exec sxmo_hook_inputhandler.sh menuright_one -bindsym --locked --no-repeat XF86PickupPhone exec sxmo_multikey.sh pickup enter_one enter_two enter_three - -include /etc/sway/config.d/* - -exec 'printf %s "$SWAYSOCK" > "$XDG_RUNTIME_DIR"/sxmo.swaysock' - -exec sxmo_hook_start.sh - -# vim: ft=swayconfig diff --git a/overlay/rootfs/home/user/.config/sxmo/xinit b/overlay/rootfs/home/user/.config/sxmo/xinit new file mode 100755 index 0000000..08a1ae8 --- /dev/null +++ b/overlay/rootfs/home/user/.config/sxmo/xinit @@ -0,0 +1,7 @@ +#!/bin/sh +# configversion: 36730424afa6d6bf9e9fb6d111c35504 + +dbus-update-activation-environment DISPLAY XDG_CURRENT_DESKTOP + +# Run actions on start +sxmo_hook_start.sh & diff --git a/overlay/rootfs/home/user/.config/wofi/config b/overlay/rootfs/home/user/.config/wofi/config deleted file mode 100644 index 601b590..0000000 --- a/overlay/rootfs/home/user/.config/wofi/config +++ /dev/null @@ -1,12 +0,0 @@ -# Space to setup configversion -# configversion: eb37989d3b93bf46e0df32db4ffd833e -matching=multi-contains -width=240 -height=296 -halign=fill -orientation=vertical -content_halign=fill -insensitive=true -prompt= -show=dmenu -no_actions=true diff --git a/overlay/rootfs/home/user/.config/wofi/style.css b/overlay/rootfs/home/user/.config/wofi/style.css deleted file mode 100644 index d0795ad..0000000 --- a/overlay/rootfs/home/user/.config/wofi/style.css +++ /dev/null @@ -1,51 +0,0 @@ -/* Space to setup configversion */ -/* configversion: 2ecca20b604bc0b37d13aba5a0fabc07 */ -* { - font-family: monospace; - font-size: 15px; -} - -window { - margin: 0px; - border: 2px solid #005577; - background-color: #1c1c1c; -} - -#input { - margin: 0px; - padding: 4px 6px; - border-radius: 0px; - border: 1px solid #005577; - background-color: #383838; - color: #ffffff; - font-size: 15px; - font-weight: bold; -} - -#inner-box { - margin: 0px; -} - -#outer-box { - margin: 1px; -} - -#scroll { - margin: 0px; - color: #ffdd00; -} - -#text { - margin: 1px 4px; - color: #ffffff; -} - -#entry { - padding: 3px 2px; - margin: 0px; -} - -#entry:selected { - background-color: #005577; - font-weight: bold; -} diff --git a/overlay/rootfs/home/user/.profile b/overlay/rootfs/home/user/.profile new file mode 100644 index 0000000..d2ff062 --- /dev/null +++ b/overlay/rootfs/home/user/.profile @@ -0,0 +1,16 @@ +export PATH="$HOME/.local/bin:$PATH" + +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 +export SXMO_DISABLE_LEDS=1 +export SXMO_NO_VIRTUAL_KEYBOARD=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 +export GTK_IM_MODULE=fcitx +export QT_IM_MODULE=fcitx +export XMODIFIERS=@im=fcitx diff --git a/overlay/rootfs/usr/bin/X b/overlay/rootfs/usr/bin/X new file mode 120000 index 0000000..e363c6e --- /dev/null +++ b/overlay/rootfs/usr/bin/X @@ -0,0 +1 @@ +Xorg \ No newline at end of file diff --git a/overlay/rootfs/usr/bin/Xorg b/overlay/rootfs/usr/bin/Xorg new file mode 100755 index 0000000..10f585b Binary files /dev/null and b/overlay/rootfs/usr/bin/Xorg differ diff --git a/overlay/rootfs/usr/bin/bananarchy-photo b/overlay/rootfs/usr/bin/bananarchy-photo index 898581f..c254747 100755 --- a/overlay/rootfs/usr/bin/bananarchy-photo +++ b/overlay/rootfs/usr/bin/bananarchy-photo @@ -75,7 +75,7 @@ get_pictures_dir() { } notify_msg() { - if command -v sxmo_notify_user.sh >/dev/null 2>&1 && [ -n "${WAYLAND_DISPLAY:-}" ]; then + if command -v sxmo_notify_user.sh >/dev/null 2>&1 && [ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]; then sxmo_notify_user.sh -t 2000 "$1" >/dev/null 2>&1 || true fi } @@ -135,8 +135,12 @@ take_photo() { printf "%s\n" "$target_path" notify_msg "Saved $(basename "$target_path")" - if [ "$VIEW_AFTER" -eq 1 ] && [ -n "${WAYLAND_DISPLAY:-}" ] && command -v imv >/dev/null 2>&1; then - imv "$target_path" >/dev/null 2>&1 & + if [ "$VIEW_AFTER" -eq 1 ] && [ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]; then + if command -v feh >/dev/null 2>&1 && [ -n "${DISPLAY:-}" ]; then + feh --scale-down "$target_path" >/dev/null 2>&1 & + elif command -v imv >/dev/null 2>&1; then + imv "$target_path" >/dev/null 2>&1 & + fi fi return 0 } @@ -169,7 +173,11 @@ run_menu() { *"View photos"*) pic_dir="$(get_pictures_dir)" if ls "$pic_dir"/*.jpg "$pic_dir"/*.png >/dev/null 2>&1; then - imv "$pic_dir" >/dev/null 2>&1 & + if command -v feh >/dev/null 2>&1 && [ -n "${DISPLAY:-}" ]; then + feh --scale-down "$pic_dir" >/dev/null 2>&1 & + else + imv "$pic_dir" >/dev/null 2>&1 & + fi else notify_msg "No photos in $pic_dir" fi diff --git a/overlay/rootfs/usr/bin/dmenu b/overlay/rootfs/usr/bin/dmenu new file mode 100755 index 0000000..53d9ec3 Binary files /dev/null and b/overlay/rootfs/usr/bin/dmenu differ diff --git a/overlay/rootfs/usr/bin/dmenu_path b/overlay/rootfs/usr/bin/dmenu_path new file mode 100755 index 0000000..3a7cda7 --- /dev/null +++ b/overlay/rootfs/usr/bin/dmenu_path @@ -0,0 +1,13 @@ +#!/bin/sh + +cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +cache="$cachedir/dmenu_run" + +[ ! -e "$cachedir" ] && mkdir -p "$cachedir" + +IFS=: +if stest -dqr -n "$cache" $PATH; then + stest -flx $PATH | sort -u | tee "$cache" +else + cat "$cache" +fi diff --git a/overlay/rootfs/usr/bin/dmenu_run b/overlay/rootfs/usr/bin/dmenu_run new file mode 100755 index 0000000..834ede5 --- /dev/null +++ b/overlay/rootfs/usr/bin/dmenu_run @@ -0,0 +1,2 @@ +#!/bin/sh +dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} & diff --git a/overlay/rootfs/usr/bin/dwm b/overlay/rootfs/usr/bin/dwm new file mode 100755 index 0000000..920a79f Binary files /dev/null and b/overlay/rootfs/usr/bin/dwm differ diff --git a/overlay/rootfs/usr/bin/gtf b/overlay/rootfs/usr/bin/gtf new file mode 100755 index 0000000..2eeee1c Binary files /dev/null and b/overlay/rootfs/usr/bin/gtf differ diff --git a/overlay/rootfs/usr/bin/st b/overlay/rootfs/usr/bin/st new file mode 100755 index 0000000..83b666c Binary files /dev/null and b/overlay/rootfs/usr/bin/st differ diff --git a/overlay/rootfs/usr/bin/stest b/overlay/rootfs/usr/bin/stest new file mode 100755 index 0000000..9d9d4ea Binary files /dev/null and b/overlay/rootfs/usr/bin/stest differ diff --git a/overlay/rootfs/usr/bin/sxmo_appmenu.sh b/overlay/rootfs/usr/bin/sxmo_appmenu.sh new file mode 100755 index 0000000..2ac1526 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_appmenu.sh @@ -0,0 +1,322 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# include common definitions +# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh +. sxmo_hook_icons.sh +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +unalias dmenu 2>/dev/null || true +unalias bemenu 2>/dev/null || true + +confirm() { + PICKED="$(printf "Yes\nNo\n" | run_dmenu -p "Confirm $1")" + + if [ "$PICKED" = "Yes" ]; then + return 0 + else + return 1 + fi +} + +run_dmenu() { + if [ "${SXMO_WM:-dwm}" = "dwm" ] && command -v dmenu >/dev/null 2>&1; then + dmenu -c -l "${SXMO_DMENU_PORTRAIT_LINES:-9}" "$@" + else + sxmo_dmenu.sh "$@" + fi +} + +supertoggle_daemon() { + if superctl status "$1" | grep -q started; then + superctl stop "$1" + sxmo_notify_user.sh "$1 Stopped" + else + superctl start "$1" + sxmo_notify_user.sh "$1 Started" + fi +} + +toggle_daemon() { + name="$1" + shift + + if sxmo_jobs.sh running "$1" -q; then + sxmo_jobs.sh stop "$@" + notify-send "$name Stopped" + else + sxmo_jobs.sh start "$@" & + notify-send "$name Started" + fi +} + +sxmo_type() { + sxmo_type.sh -s 200 "$@" +} + +get_focused_window() { + if [ -r "${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo.focusedwin" ]; then + { + read -r WMCLASS || WMCLASS="" + read -r WMNAME || WMNAME="" + } < "${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo.focusedwin" + return + fi + exec 0</dev/null || continue + if [ "$rtype" = "bluetooth" ]; then + read -r soft < "$rfk/soft" 2>/dev/null || soft=0 + read -r hard < "$rfk/hard" 2>/dev/null || hard=0 + [ "$soft" = "0" ] && [ "$hard" = "0" ] && return 0 + return 1 + fi + done + return 1 +} + +fast_sys_choices() { + WINNAME="Sys" + _bt_line="" + if bt_is_unblocked_fast; then + _bt_line="$icon_bth Bluetooth^1^sxmo_bluetoothmenu.sh +" + fi + _flash_line="" + _bl="" + if [ -r /sys/class/leds/white:torch/brightness ]; then + read -r _bl < /sys/class/leds/white:torch/brightness 2>/dev/null || _bl="" + elif [ -r /sys/class/leds/white:flash/brightness ]; then + read -r _bl < /sys/class/leds/white:flash/brightness 2>/dev/null || _bl="" + fi + if [ -n "$_bl" ]; then + if [ "$_bl" -gt 0 ] 2>/dev/null; then + _flash_line="$icon_fll Flashlight $icon_ton^1^sxmo_flashtoggle.sh +" + else + _flash_line="$icon_fll Flashlight $icon_tof^1^sxmo_flashtoggle.sh +" + fi + fi + CHOICES="$icon_trm St^0^st -e ${SHELL:-/bin/sh} +$icon_grd Apps^0^sxmo_appmenu.sh applications +$icon_grd Scripts^0^sxmo_appmenu.sh scripts +$icon_dir Files^0^sxmo_files.sh +$icon_phn Dialer^0^sxmo_modemdial.sh +$icon_msg Texts^0^sxmo_modemtext.sh +$icon_usr Contacts^0^sxmo_contactmenu.sh +${_bt_line}$icon_cam Camera^0^bananarchy-photo --menu +${_flash_line}$icon_net Networks^0^sxmo_networks.sh +$icon_mus Audio^0^sxmo_audio.sh +$icon_phn Modem^0^sxmo_appmenu.sh modem +$icon_win Windows^0^sxmo_wmmenu.sh +$icon_cfg Config^0^sxmo_appmenu.sh config +$icon_pwr Power^0^sxmo_appmenu.sh power" +} + +getprogchoices() { + case "$WMCLASS" in + ""|sys) + fast_sys_choices + ;; + applications) + WINNAME="Apps" + if [ -s "${XDG_RUNTIME_DIR:-/tmp}/sxmo_apps.cache" ]; then + CHOICES="$(cat "${XDG_RUNTIME_DIR:-/tmp}/sxmo_apps.cache")" + else + CHOICES="$(sxmo_hook_apps.sh)" + fi + ;; + scripts) + WINNAME="Scripts" + if [ -s "${XDG_RUNTIME_DIR:-/tmp}/sxmo_scripts.cache" ]; then + CHOICES="$(cat "${XDG_RUNTIME_DIR:-/tmp}/sxmo_scripts.cache")" + else + CHOICES="$(sxmo_hook_scripts.sh)" + fi + ;; + power) + WINNAME="Power" + CHOICES="$icon_lck Lock^0^sxmo_state.sh set lock +$icon_lck Lock (Screen off)^0^sxmo_state.sh set screenoff +$icon_out Logout^0^confirm Logout && sxmo_power.sh logout +$icon_rld Reboot^0^confirm Reboot && sxmo_power.sh reboot +$icon_pwr Poweroff^0^confirm Poweroff && sxmo_power.sh poweroff" + ;; + modem) + WINNAME="Modem" + CHOICES="$icon_plk Modem PIN^0^sxmo_unlocksim.sh +$icon_inf Modem Info^0^sxmo_modeminfo.sh +$icon_phl Modem Log^0^sxmo_modemlog.sh" + ;; + config) + WINNAME="Config" + _bt_icon="$icon_tof" + bt_is_unblocked_fast && _bt_icon="$icon_ton" + _susp_icon="$icon_ton" + [ -e "${XDG_CACHE_HOME:-$HOME/.cache}/sxmo/sxmo.nosuspend" ] && _susp_icon="$icon_tof" + _idle_icon="$icon_ton" + [ -e "${XDG_CACHE_HOME:-$HOME/.cache}/sxmo/sxmo.noidle" ] && _idle_icon="$icon_tof" + CHOICES="$icon_aru Brightness^1^sxmo_brightness.sh up +$icon_ard Brightness^1^sxmo_brightness.sh down +$icon_cfg Toggle Bar^0^sxmo_wm.sh togglebar +$icon_bth Bluetooth $_bt_icon^1^doas sxmo_bluetoothtoggle.sh && sxmo_hook_statusbar.sh bluetooth +$icon_clk Change Timezone^1^sxmo_timezonechange.sh +$icon_zzz Auto-suspend $_susp_icon^1^(rm ${XDG_CACHE_HOME:-$HOME/.cache}/sxmo/sxmo.nosuspend 2>/dev/null || touch ${XDG_CACHE_HOME:-$HOME/.cache}/sxmo/sxmo.nosuspend) +$icon_zzz Auto-screen-off $_idle_icon^1^(rm ${XDG_CACHE_HOME:-$HOME/.cache}/sxmo/sxmo.noidle 2>/dev/null || touch ${XDG_CACHE_HOME:-$HOME/.cache}/sxmo/sxmo.noidle) && sxmo_state.sh set unlock +$icon_trm Hooks^0^sxmo_hookmenu.sh +$icon_cfg Suspend Blockers^0^sxmo_terminal.sh sxmo_debug_suspend.sh +$icon_inf Log^0^sxmo_terminal.sh tail -n 100 -f ${XDG_STATE_HOME:-$HOME}/sxmo.log +$icon_inf Version^0^sxmo_terminal.sh sxmo_version.sh --block" + ;; + *) + RES="$(sxmo_hook_contextmenu.sh "$WMCLASS" "$WMNAME")" + if [ -n "$RES" ]; then + nl=' +' + WINNAME="${RES%%"$nl"*}" + CHOICES="${RES#*"$nl"}" + fi + ;; + esac + + if [ "$WINNAME" = "Sys" ]; then + NNOTIFICATIONS="$(count_notifications)" + if [ "$NNOTIFICATIONS" -gt 0 ]; then + CHOICES="$icon_bel Notifications ($NNOTIFICATIONS)^0^sxmo_notifs.sh menu +$CHOICES" + fi + fi + + if has_tracked_calls; then + CHOICES="$(call_entries) +$CHOICES" + fi + + case "$WINNAME" in + *Sys*) ;; + *) + CHOICES="$CHOICES +$icon_mnu System Menu^0^sxmo_appmenu.sh sys" + ;; + esac + + CHOICES="$CHOICES +$icon_cls Close Menu^0^quit" + + case "$WMCLASS" in + ""|sys|applications|scripts|power|modem|config) + ;; + *) + CHOICES="$(printf "%s\n" "$CHOICES" | awk 'NF {$1=$1; print}')" + ;; + esac +} + +quit() { + exit 0 +} + +mainloop() { + getprogchoices + PICKED="$( + printf "%s\n" "$CHOICES" | + cut -d'^' -f1 | + run_dmenu -i -p "$WINNAME" + )" || quit + + CHOICE="$(printf "%s\n" "$CHOICES" | awk -F '^' -v picked="$PICKED" \ + '$1 == picked || $1 == picked " " {print $2 "^" $3; exit}' + )" + + LOOP="${CHOICE%%^*}" + CMD="${CHOICE#*^}" + CMD="${CMD#"${CMD%%[![:space:]]*}"}" + + if [ -z "$CHOICE" ] || [ -z "$CMD" ]; then + printf "%s\n" "sxmo_appmenu: Fallback: unknown choice <$PICKED> to contextmenu_fallback hook">&2 + sxmo_hook_contextmenu_fallback.sh "$WINNAME" "$PICKED" + quit + fi + + case "$CMD" in + "sxmo_appmenu.sh "*) + set -- ${CMD#sxmo_appmenu.sh } + WMCLASS="$1" + WMNAME="$2" + return 0 + ;; + esac + + eval "$CMD" + + case "$LOOP" in + *1*) ;; + *) quit ;; + esac +} + +if [ -z "$SHELLSPEC_PATH" ]; then + if [ $# -gt 0 ] ; then + WMCLASS="$1" + WMNAME="$2" + else + get_focused_window + fi + + while true; do + mainloop + done +fi diff --git a/overlay/rootfs/usr/bin/sxmo_battery_monitor.sh b/overlay/rootfs/usr/bin/sxmo_battery_monitor.sh new file mode 100755 index 0000000..bb4532c --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_battery_monitor.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +upower -m | while read -r line; do + # swallow first line ("Monitoring activity from the power daemon...") + if [ -z "$started" ]; then + started=1 + continue + fi + + line="${line#* }" + event="${line%%:*}" + object="${line#*:}" + object="${object#"${object%%[![:space:]]*}"}" + + if [ -z "$object" ]; then + continue + fi + + sxmo_hook_battery.sh "$object" "$event" +done diff --git a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,argon.sh b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,argon.sh index 7c0b24d..d6dac28 100755 --- a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,argon.sh +++ b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,argon.sh @@ -1,9 +1,14 @@ #!/bin/sh -export SXMO_WM=sway +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st export SXMO_ROTATION=normal # Native 1:1 240x320 QVGA resolution -export SXMO_SWAY_SCALE=1 +export GSK_RENDERER=cairo +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 # Physical button mappings export SXMO_POWER_BUTTON="0:0:pm8916_pon" @@ -13,12 +18,10 @@ export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU" export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK" export SXMO_ENTER_BUTTON="0:352:KEY_OK" -# Nokia 8110 4G has a physical keypad and no touchscreen +# Physical keypad and no touchscreen or RGB status LED export SXMO_NO_VIRTUAL_KEYBOARD=1 +export SXMO_DISABLE_LEDS=1 export KEYBOARD_ARGS="-H 1 -L 1" -export SXMO_MENU=wofi -export SXMO_WOFI_LANDSCAPE_WIDTH=320 -export SXMO_WOFI_LANDSCAPE_HEIGHT=200 -export SXMO_BEMENU_PORTRAIT_LINES=10 -export SXMO_BEMENU_LANDSCAPE_LINES=6 -export BEMENU_OPTS="--fn 'Sxmo 13' -H 24" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 diff --git a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,beatles.sh b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,beatles.sh index 7c0b24d..d6dac28 100755 --- a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,beatles.sh +++ b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,beatles.sh @@ -1,9 +1,14 @@ #!/bin/sh -export SXMO_WM=sway +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st export SXMO_ROTATION=normal # Native 1:1 240x320 QVGA resolution -export SXMO_SWAY_SCALE=1 +export GSK_RENDERER=cairo +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 # Physical button mappings export SXMO_POWER_BUTTON="0:0:pm8916_pon" @@ -13,12 +18,10 @@ export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU" export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK" export SXMO_ENTER_BUTTON="0:352:KEY_OK" -# Nokia 8110 4G has a physical keypad and no touchscreen +# Physical keypad and no touchscreen or RGB status LED export SXMO_NO_VIRTUAL_KEYBOARD=1 +export SXMO_DISABLE_LEDS=1 export KEYBOARD_ARGS="-H 1 -L 1" -export SXMO_MENU=wofi -export SXMO_WOFI_LANDSCAPE_WIDTH=320 -export SXMO_WOFI_LANDSCAPE_HEIGHT=200 -export SXMO_BEMENU_PORTRAIT_LINES=10 -export SXMO_BEMENU_LANDSCAPE_LINES=6 -export BEMENU_OPTS="--fn 'Sxmo 13' -H 24" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 diff --git a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,coconut.sh b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,coconut.sh index 7c0b24d..d6dac28 100755 --- a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,coconut.sh +++ b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,coconut.sh @@ -1,9 +1,14 @@ #!/bin/sh -export SXMO_WM=sway +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st export SXMO_ROTATION=normal # Native 1:1 240x320 QVGA resolution -export SXMO_SWAY_SCALE=1 +export GSK_RENDERER=cairo +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 # Physical button mappings export SXMO_POWER_BUTTON="0:0:pm8916_pon" @@ -13,12 +18,10 @@ export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU" export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK" export SXMO_ENTER_BUTTON="0:352:KEY_OK" -# Nokia 8110 4G has a physical keypad and no touchscreen +# Physical keypad and no touchscreen or RGB status LED export SXMO_NO_VIRTUAL_KEYBOARD=1 +export SXMO_DISABLE_LEDS=1 export KEYBOARD_ARGS="-H 1 -L 1" -export SXMO_MENU=wofi -export SXMO_WOFI_LANDSCAPE_WIDTH=320 -export SXMO_WOFI_LANDSCAPE_HEIGHT=200 -export SXMO_BEMENU_PORTRAIT_LINES=10 -export SXMO_BEMENU_LANDSCAPE_LINES=6 -export BEMENU_OPTS="--fn 'Sxmo 13' -H 24" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 diff --git a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,leo.sh b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,leo.sh index 7c0b24d..d6dac28 100755 --- a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,leo.sh +++ b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,leo.sh @@ -1,9 +1,14 @@ #!/bin/sh -export SXMO_WM=sway +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st export SXMO_ROTATION=normal # Native 1:1 240x320 QVGA resolution -export SXMO_SWAY_SCALE=1 +export GSK_RENDERER=cairo +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 # Physical button mappings export SXMO_POWER_BUTTON="0:0:pm8916_pon" @@ -13,12 +18,10 @@ export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU" export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK" export SXMO_ENTER_BUTTON="0:352:KEY_OK" -# Nokia 8110 4G has a physical keypad and no touchscreen +# Physical keypad and no touchscreen or RGB status LED export SXMO_NO_VIRTUAL_KEYBOARD=1 +export SXMO_DISABLE_LEDS=1 export KEYBOARD_ARGS="-H 1 -L 1" -export SXMO_MENU=wofi -export SXMO_WOFI_LANDSCAPE_WIDTH=320 -export SXMO_WOFI_LANDSCAPE_HEIGHT=200 -export SXMO_BEMENU_PORTRAIT_LINES=10 -export SXMO_BEMENU_LANDSCAPE_LINES=6 -export BEMENU_OPTS="--fn 'Sxmo 13' -H 24" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 diff --git a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,sparkler.sh b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,sparkler.sh index 7c0b24d..d6dac28 100755 --- a/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,sparkler.sh +++ b/overlay/rootfs/usr/bin/sxmo_deviceprofile_nokia,sparkler.sh @@ -1,9 +1,14 @@ #!/bin/sh -export SXMO_WM=sway +export SXMO_WM=dwm +export SXMO_MENU=dmenu +export SXMO_TERMINAL=st export SXMO_ROTATION=normal # Native 1:1 240x320 QVGA resolution -export SXMO_SWAY_SCALE=1 +export GSK_RENDERER=cairo +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 # Physical button mappings export SXMO_POWER_BUTTON="0:0:pm8916_pon" @@ -13,12 +18,10 @@ export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU" export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK" export SXMO_ENTER_BUTTON="0:352:KEY_OK" -# Nokia 8110 4G has a physical keypad and no touchscreen +# Physical keypad and no touchscreen or RGB status LED export SXMO_NO_VIRTUAL_KEYBOARD=1 +export SXMO_DISABLE_LEDS=1 export KEYBOARD_ARGS="-H 1 -L 1" -export SXMO_MENU=wofi -export SXMO_WOFI_LANDSCAPE_WIDTH=320 -export SXMO_WOFI_LANDSCAPE_HEIGHT=200 -export SXMO_BEMENU_PORTRAIT_LINES=10 -export SXMO_BEMENU_LANDSCAPE_LINES=6 -export BEMENU_OPTS="--fn 'Sxmo 13' -H 24" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 diff --git a/overlay/rootfs/usr/bin/sxmo_dmenu.sh b/overlay/rootfs/usr/bin/sxmo_dmenu.sh new file mode 100755 index 0000000..36d9b23 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_dmenu.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +. sxmo_common.sh + +unalias dmenu 2>/dev/null || true + +case "$1" in + "--show-over-lockscreen") + SHOW_OVER_LOCKSCREEN_FLAG=1 + shift + ;; + "isopen") + exec pidof -s dmenu >/dev/null + ;; + "close") + pkill dmenu 2>/dev/null || true + exit 0 + ;; +esac + +if [ -n "$SHOW_OVER_LOCKSCREEN_FLAG" ]; then + if pidof -s smlock >/dev/null; then + set -- "$@" -w smlock + fi +fi + +lines="${SXMO_DMENU_PORTRAIT_LINES:-9}" +# shellcheck disable=SC2086 +exec dmenu -i $SXMO_DMENU_OPTS -l "$lines" "$@" diff --git a/overlay/rootfs/usr/bin/sxmo_dwminit.sh b/overlay/rootfs/usr/bin/sxmo_dwminit.sh new file mode 100755 index 0000000..cd1fd40 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_dwminit.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +envvars() { + unset WAYLAND_DISPLAY + export SXMO_WM=dwm + export XDG_CURRENT_DESKTOP=dwm + export SXMO_MENU=dmenu + export SXMO_TERMINAL=st + export GTK_IM_MODULE=fcitx + export QT_IM_MODULE=fcitx + export XMODIFIERS=@im=fcitx + command -v "$KEYBOARD" >/dev/null 2>&1 || defaultkeyboard + [ -z "$MOZ_USE_XINPUT2" ] && export MOZ_USE_XINPUT2=1 +} + +defaults() { + xsetroot -solid '#1c1c1c' + xset s off -dpms + [ -e "$HOME"/.Xresources ] && xrdb -merge "$HOME"/.Xresources + if [ -f /usr/share/wallpapers/bananarchy.png ] && command -v feh >/dev/null 2>&1; then + feh --no-fehbg --bg-fill /usr/share/wallpapers/bananarchy.png & + fi +} + +defaultkeyboard() { + if command -v svkbd-mobile-intl >/dev/null 2>&1; then + export KEYBOARD=svkbd-mobile-intl + elif command -v svkbd-mobile-plain >/dev/null 2>&1; then + export KEYBOARD=svkbd-mobile-plain + else + export KEYBOARD=svkbd-sxmo + fi +} + +with_dbus() { + echo "$DBUS_SESSION_BUS_ADDRESS" > "$XDG_RUNTIME_DIR"/dbus.bus + # shellcheck source=configs/appcfg/xinit_template + . "$XDG_CONFIG_HOME"/sxmo/xinit + exec dwm +} + +# shellcheck source=scripts/core/sxmo_init.sh +. sxmo_init.sh diff --git a/overlay/rootfs/usr/bin/sxmo_idle.sh b/overlay/rootfs/usr/bin/sxmo_idle.sh new file mode 100755 index 0000000..b55d71a --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_idle.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +_swayidletoidles() { + while [ $# -gt 0 ]; do + case "$1" in + timeout) + printf "%s|%s" "$2" "$3" + shift 3 + case "$1" in + resume) + printf "|%s" "$2" + shift 2 + ;; + esac + printf "\n" + ;; + *) + shift + ;; + esac + done +} + +xorgidle() { + if ! command -v xprintidle >/dev/null 2>&1; then + while : ; do + sleep 3600 + done + fi + + idles="$(_swayidletoidles "$@")" + resumes="" + + tick=0 + new_idle="$(xprintidle 2>/dev/null || printf '0')" + [ -n "$new_idle" ] || new_idle=0 + last_idle="$new_idle" + + finish() { + sh -c "$resumes" + resumes="" + exit + } + trap 'finish' TERM INT EXIT + + while : ; do + last_idle="$new_idle" + new_idle="$(xprintidle 2>/dev/null || printf '0')" + [ -n "$new_idle" ] || new_idle=0 + if [ "$last_idle" -gt "$new_idle" ] 2>/dev/null; then + sh -c "$resumes" + tick=0 + resumes="" + fi + + if printf "%b\n" "$idles" | grep -q "^$tick|"; then + printf "%b\n" "$idles" | \ + grep "^$tick|" | \ + cut -d'|' -f2 | \ + xargs -I{} -0 sh -c "{}" + resumes="$(printf "%b\n" "$idles" | grep "^$tick|" | cut -d'|' -f3);$resumes" + fi + + sleep 1 + tick=$((tick + 1)) + done +} + +case "$SXMO_WM" in + dwm|i3) + xorgidle "$@" + ;; + sway|river) + exec swayidle "$@" + ;; +esac diff --git a/overlay/rootfs/usr/bin/sxmo_init.sh b/overlay/rootfs/usr/bin/sxmo_init.sh new file mode 100755 index 0000000..05ff119 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_init.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# This script have to be sourced from other session init scripts. +# The scripts have to implement envvars, defaults, with_dbus, and cleanup +# methods. See sxmo_swayinit.sh as example. + +start() { + [ -f "$XDG_STATE_HOME"/sxmo.log ] && mv "$XDG_STATE_HOME"/sxmo.log "$XDG_STATE_HOME"/sxmo.log.old + + if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then + dbus-run-session -- "$0" "with_dbus" & + else + # with_dbus calls exec because dbus-run-session starts it in a + # new shell, but we need to keep this shell; start a subshell + ( with_dbus ) & + fi + wait +} + +cleanup() { + sxmo_dmenu.sh close 2>/dev/null || true + sxmo_keyboard.sh close 2>/dev/null || true + sxmo_jobs.sh stop all 2>/dev/null || true +} + +finish() { + cleanup + sleep 1 + sxmo_hook_stop.sh 2>/dev/null || true + exit +} + +shared_envvars() { + export SXMO_DISABLE_LEDS="1" +} + +init() { + # shellcheck source=/dev/null + . /etc/profile.d/sxmo_init.sh + + _sxmo_load_environments + _sxmo_prepare_dirs + envvars + shared_envvars + + defaults + + # shellcheck disable=SC1090,SC1091 + . "$XDG_CONFIG_HOME/sxmo/profile" + + trap 'finish' INT TERM EXIT + start +} + +if [ -z "$1" ]; then + init +else + "$1" +fi diff --git a/overlay/rootfs/usr/bin/sxmo_jobs.sh b/overlay/rootfs/usr/bin/sxmo_jobs.sh new file mode 100755 index 0000000..f919831 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_jobs.sh @@ -0,0 +1,147 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# include common definitions +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +ROOT="$XDG_RUNTIME_DIR/sxmo_jobs" +mkdir -p "$ROOT" + +exec 3<> "$XDG_RUNTIME_DIR/sxmo.jobs.lock" +flock -x 3 + +list() { + for f in "$ROOT"/*; do + [ -e "$f" ] || continue + case "$f" in + *.group) continue ;; + esac + printf "%s\n" "${f##*/}" + done +} + +stop() { + while [ "$#" -gt 0 ]; do + case "$1" in + -f) + force=1 + shift + ;; + *) + id="$1" + shift + break + ;; + esac + done + + case "$id" in + all) + list | while read -r sub_id; do + stop "$sub_id" + done + ;; + *) + if [ -f "$ROOT/$id.group" ]; then + sxmo_debug "stop group $id" + read -r pid < "$ROOT/$id.group" 2>/dev/null || pid="" + [ -n "$pid" ] && kill ${force:+-9} -- "-$pid" 2> /dev/null || true + elif [ -f "$ROOT/$id" ]; then + sxmo_debug "stop $id" + read -r pid < "$ROOT/$id" 2>/dev/null || pid="" + [ -n "$pid" ] && kill ${force:+-9} "$pid" 2> /dev/null || true + fi + + rm -f "$ROOT/$id" "$ROOT/$id.group" 2>/dev/null || true + ;; + esac +} + +signal() { + id="$1" + shift + + if [ -f "$ROOT/$id" ]; then + sxmo_debug "signal $id $*" + read -r pid < "$ROOT/$id" 2>/dev/null || pid="" + [ -n "$pid" ] && kill "$@" "$pid" 2> /dev/null || true + fi +} + +start() { + while [ "$#" -gt 0 ]; do + case "$1" in + --no-restart) + no_restart=1 + shift + ;; + --group) + has_group=1 + shift + ;; + *) + id="$1" + shift + break + ;; + esac + done + + if [ -f "$ROOT/$id" ]; then + if [ -n "$no_restart" ]; then + sxmo_debug "$id already running" + exit 1 + else + stop "$id" + fi + fi + + sxmo_debug "start $id" + # Start job in a new session, close the lock fd, and record PID synchronously + # before releasing the jobs lock so subsequent stop calls never race. + setsid "$@" 3<&- & + job_pid=$! + printf "%s\n" "$job_pid" > "$ROOT/$id" + if [ -n "$has_group" ]; then + printf "%s\n" "$job_pid" > "$ROOT/$id.group" + fi +} + +running() { + while [ "$#" -gt 0 ]; do + case "$1" in + -q) + quiet=1 + shift + ;; + *) + id="$1" + shift + ;; + esac + done + + log() { + if [ -z "$quiet" ]; then + # shellcheck disable=SC2059 + printf "$@" + fi + } + + if [ -f "$ROOT/$id" ]; then + read -r pid < "$ROOT/$id" 2>/dev/null || pid="" + if [ -n "$pid" ] && [ -d "/proc/$pid" ]; then + log "%s is still running\n" "$id" + else + log "%s is not running anymore\n" "$id" + exit 2 + fi + else + log "%s is not running\n" "$id" + exit 1 + fi +} + +"$@" diff --git a/overlay/rootfs/usr/bin/sxmo_modem.sh b/overlay/rootfs/usr/bin/sxmo_modem.sh new file mode 100755 index 0000000..314284a --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_modem.sh @@ -0,0 +1,286 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# include common definitions +# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh +. sxmo_hook_icons.sh +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +if [ -z "$XDG_RUNTIME_DIR" ]; then + echo "XDG_RUNTIME_DIR must be set" >&2 + exit 1 +fi + +# We use this directory to store states, so it must exist +mkdir -p "$XDG_RUNTIME_DIR/sxmo_calls" + +stderr() { + sxmo_log "$*" +} + +cleanupnumber() { + if pnc valid "$1"; then + echo "$1" + return + fi + + REFORMATTED="$(pnc find ${DEFAULT_COUNTRY:+-c "$DEFAULT_COUNTRY"} "$1")" + if [ -n "$REFORMATTED" ]; then + echo "$REFORMATTED" + return + fi + + echo "$1" +} + +checkforfinishedcalls() { + exec 3<> "$XDG_RUNTIME_DIR/sxmo_modem.checkforfinishedcalls.lock" + flock -x 3 + #find all finished calls + for FINISHEDCALLID in $( + mmcli -m any --voice-list-calls | + grep terminated | + grep -oE "Call\/[0-9]+" | + cut -d'/' -f2 + ); do + FINISHEDNUMBER="$(sxmo_modemcall.sh vid_to_number "$FINISHEDCALLID")" + FINISHEDNUMBER="$(cleanupnumber "$FINISHEDNUMBER")" + mmcli -m any --voice-delete-call "$FINISHEDCALLID" + + rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.monitoredcall" + + CONTACT="$(sxmo_contacts.sh --name-or-number "$FINISHEDNUMBER")" + + TIME="$(date +%FT%H:%M:%S%z)" + mkdir -p "$SXMO_LOGDIR" + if [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.discardedcall" ]; then + #this call was discarded + STATE=discarded + sxmo_notify_user.sh "Call with $CONTACT terminated" + stderr "Discarded call from $FINISHEDNUMBER" + printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv" + elif [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.pickedupcall" ]; then + #this call was picked up + STATE=pickedup + sxmo_notify_user.sh "Call with $CONTACT terminated" + stderr "Finished call from $FINISHEDNUMBER" + printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv" + elif [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.hangedupcall" ]; then + #this call was hung up by the user + STATE=wehangedup + sxmo_notify_user.sh "Call with $CONTACT terminated" + stderr "Finished call from $FINISHEDNUMBER" + printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv" + elif [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.initiatedcall" ]; then + STATE=theyhangedup + #this call was hung up by the contact + sxmo_notify_user.sh "Call with $CONTACT terminated" + stderr "Finished call from $FINISHEDNUMBER" + printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv" + elif [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.mutedring" ]; then + STATE=muted + #this ring was muted up + stderr "Muted ring from $FINISHEDNUMBER" + printf %b "$TIME\tring_muted\t$FINISHEDNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv" + else + #this is a missed call + # Add a notification for every missed call + STATE=missed + + NOTIFMSG="Missed call from $CONTACT ($FINISHEDNUMBER)" + stderr "$NOTIFMSG" + printf %b "$TIME\tcall_missed\t$FINISHEDNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv" + + stderr "Invoking missed call hook (async)" + sxmo_hook_missed_call.sh "$CONTACT" & + + sxmo_notifs.sh new \ + -g "incoming-call-$FINISHEDNUMBER" \ + "TERMNAME='$NOTIFMSG' sxmo_terminal.sh sh -c \"echo '$NOTIFMSG at $(date)' && read\"" \ + "Missed $icon_phn $CONTACT ($FINISHEDNUMBER)" + fi + + rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}."* 2>/dev/null || true + + # If it was the last call + if ! sxmo_modemcall.sh list_active_calls | grep -q .; then + # Cleanup + rm -f "$XDG_RUNTIME_DIR/sxmo_calls/"* 2>/dev/null || true + if [ "$STATE" != muted ]; then + sxmo_vibrate 1000 "${SXMO_VIBRATE_STRENGTH:-1}" & + fi + sxmo_jobs.sh stop incall_menu + sxmo_jobs.sh stop proximity_lock + sxmo_hook_statusbar.sh state & + + if ! sxmo_modemaudio.sh reset_audio; then + sxmo_notify_user.sh --urgency=critical "We failed to reset call audio" + fi + + sxmo_hook_after_call.sh + else + # Or refresh the menu + sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incall_menu + fi + done +} + +checkforincomingcalls() { + VOICECALLID="$( + mmcli -m any --voice-list-calls -a | + grep -Eo '[0-9]+ incoming \(ringing-in\)' | + grep -Eo '[0-9]+' + )" + [ -z "$VOICECALLID" ] && return + + [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.monitoredcall" ] && return # prevent multiple rings + rm "$XDG_RUNTIME_DIR/sxmo_calls/$VOICECALLID."* 2>/dev/null # we cleanup all dangling event files + touch "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.monitoredcall" #this signals that we handled the call + + # Determine the incoming phone number + stderr "Incoming Call..." + INCOMINGNUMBER=$(sxmo_modemcall.sh vid_to_number "$VOICECALLID") + INCOMINGNUMBER="$(cleanupnumber "$INCOMINGNUMBER")" + + TIME="$(date +%FT%H:%M:%S%z)" + if sxmo_hook_block_call.sh "$INCOMINGNUMBER" 2>/dev/null; then + stderr "BLOCKED call from number: $VOICECALLID" + sxmo_modemcall.sh mute "$VOICECALLID" + printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$SXMO_BLOCKDIR/modemlog.tsv" + else + stderr "Invoking ring hook (async)" + CONTACTNAME=$(sxmo_contacts.sh --name-or-number "$INCOMINGNUMBER") + sxmo_jobs.sh start ringing sxmo_hook_ring.sh "$CONTACTNAME" + + mkdir -p "$SXMO_LOGDIR" + printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv" + + sxmo_jobs.sh start proximity_lock sxmo_proximitylock.sh + sxmo_hook_statusbar.sh state & + + # If we already got an active call + if sxmo_modemcall.sh list_active_calls \ + | grep -v ringing-in \ + | grep -q .; then + # Refresh the incall menu + sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incall_menu + else + # Or fire the incomming call menu + sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incoming_call_menu "$VOICECALLID" + fi + + stderr "Call from number: $INCOMINGNUMBER (VOICECALLID: $VOICECALLID)" + fi +} + +# this function is called in the modem hook when the modem registers +checkforstucksms() { + stuck_messages="$(mmcli -m any --messaging-list-sms)" + if ! echo "$stuck_messages" | grep -q "^No sms messages were found"; then + sxmo_notify_user.sh "WARNING: $(echo "$stuck_messages" | wc -l) stuck sms found. Run sxmo_modem.sh checkforstucksms view to view or delete to delete." + case "$1" in + "delete") + mmcli -m any --messaging-list-sms | while read -r line; do + sms_number="$(echo "$line" | cut -d'/' -f6 | cut -d' ' -f1)" + sxmo_log "Deleting sms $sms_number" + mmcli -m any --messaging-delete-sms="$sms_number" + done + ;; + "view") + mmcli -m any --messaging-list-sms | while read -r line; do + sms_number="$(echo "$line" | cut -d'/' -f6 | cut -d' ' -f1)" + mmcli -m any -s "$sms_number" -K + done + ;; + esac + fi +} + +checkfornewtexts() { + exec 3<> "$XDG_RUNTIME_DIR/sxmo_modem.checkfornewtexts.lock" + flock -x 3 + TEXTIDS="$( + mmcli -m any --messaging-list-sms | + grep -Eo '/SMS/[0-9]+ \(received\)' | + grep -Eo '[0-9]+' + )" + echo "$TEXTIDS" | grep -v . && return + + # Loop each textid received and read out the data into appropriate logfile + for TEXTID in $TEXTIDS; do + TEXTDATA="$(mmcli -m any -s "$TEXTID" -J)" + # SMS with no TEXTID is an SMS WAP (I think). So skip. + if [ -z "$TEXTDATA" ]; then + stderr "Received an empty SMS (TEXTID: $TEXTID). I will assume this is an MMS." + printf %b "$(date +%FT%H:%M:%S%z)\tdebug_mms\tNULL\tEMPTY (TEXTID: $TEXTID)\n" >> "$SXMO_LOGDIR/modemlog.tsv" + if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then + continue + else + stderr "WARNING: mmsdtng not found or unconfigured, treating as normal sms." + fi + fi + TEXT="$(printf %s "$TEXTDATA" | jq -r .sms.content.text)" + NUM="$(printf %s "$TEXTDATA" | jq -r .sms.content.number)" + NUM="$(cleanupnumber "$NUM")" + + TIME="$(printf %s "$TEXTDATA" | jq -r .sms.properties.timestamp)" + TIME="$(date +%FT%H:%M:%S%z -d "$TIME")" + + if cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$NUM$"; then + mkdir -p "$SXMO_BLOCKDIR/$NUM" + stderr "BLOCKED text from number: $NUM (TEXTID: $TEXTID)" + sxmo_hook_smslog.sh "recv" "$NUM" "$NUM" "$TIME" "$TEXT" >> "$SXMO_BLOCKDIR/$NUM/sms.txt" + printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$SXMO_BLOCKDIR/modemlog.tsv" + mmcli -m any --messaging-delete-sms="$TEXTID" + continue + fi + + if [ "$TEXT" = "--" ] && [ ! "$NUM" = "+223344556678" ]; then + stderr "Text from $NUM (TEXTID: $TEXTID) with '--'. I will assume this is an MMS." + printf %b "$TIME\tdebug_mms\t$NUM\t$TEXT\n" >> "$SXMO_LOGDIR/modemlog.tsv" + if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then + continue + else + stderr "WARNING: mmsdtng not found or unconfigured, treating as normal sms." + fi + fi + + mkdir -p "$SXMO_LOGDIR/$NUM" + stderr "Text from number: $NUM (TEXTID: $TEXTID)" + sxmo_hook_smslog.sh "recv" "$NUM" "$NUM" "$TIME" "$TEXT" >> "$SXMO_LOGDIR/$NUM/sms.txt" + printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$SXMO_LOGDIR/modemlog.tsv" + + tries=1 + while ! mmcli -m any --messaging-delete-sms="$TEXTID"; + do + if [ $tries -gt 5 ]; + then + break + fi + echo "Failed to delete text $TEXTID. Will retry" + sleep 3 + tries=$((tries+1)) + done + CONTACTNAME=$(sxmo_contacts.sh --name-or-number "$NUM") + + if [ -z "$SXMO_DISABLE_SMS_NOTIFS" ]; then + sxmo_notifs.sh new \ + -g "incoming-message-$NUM" \ + "sxmo_hook_tailtextlog.sh '$NUM'" \ + "$CONTACTNAME: $TEXT" + + fi + + if sxmo_state.sh get | grep -q screenoff; then + sxmo_state.sh set lock + fi + + sxmo_hook_sms.sh "$CONTACTNAME" "$TEXT" + done +} + +sxmo_wakelock.sh lock sxmo_modem_used 30s +"$@" +sxmo_wakelock.sh unlock sxmo_modem_used diff --git a/overlay/rootfs/usr/bin/sxmo_multikey.sh b/overlay/rootfs/usr/bin/sxmo_multikey.sh new file mode 100755 index 0000000..e40e478 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_multikey.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +if [ "$1" = clear ]; then + rm -f "$XDG_RUNTIME_DIR"/sxmo.multikey.count.* + exit +fi + +identifier="$1" +threshold="${SXMO_THRESHOLD:-0.15}" + +# Fast path: when locked or screenoff, single/double/triple presses on power/pickup +# all wake and unlock the phone, so execute immediately without waiting 300ms. +STATE_FILE="${SXMO_STATE:-$XDG_RUNTIME_DIR/sxmo.state}" +if [ -r "$STATE_FILE" ]; then + read -r cur_state < "$STATE_FILE" 2>/dev/null || cur_state="" + if [ "$cur_state" != "unlock" ]; then + case "$identifier" in + powerbutton|pickup) + rm -f "$XDG_RUNTIME_DIR"/sxmo.multikey.count."$identifier" + exec sxmo_hook_inputhandler.sh "$2" + ;; + esac + fi +fi + +count_file="$XDG_RUNTIME_DIR"/sxmo.multikey.count."$identifier" + +if [ -f "$count_file" ]; then + read -r old_counter < "$count_file" 2>/dev/null || old_counter=0 + counter="$((old_counter+1))" +else + counter=1 +fi + +printf %s "$counter" > "$count_file" + +shift "$counter" +if [ "$#" -eq 0 ]; then + exit +fi + +sleep "$threshold" + +read -r new_counter < "$count_file" 2>/dev/null || new_counter="$counter" +if [ "$counter" != "$new_counter" ] && [ "$#" -ne 1 ]; then # Only the last count can overflow + exit +fi + +eval sxmo_hook_inputhandler.sh "$1" & + +if [ "$counter" != "$new_counter" ]; then # overflowed + sleep "$threshold" + sleep "$threshold" +fi + +rm -f "$count_file" diff --git a/overlay/rootfs/usr/bin/sxmo_notifs.sh b/overlay/rootfs/usr/bin/sxmo_notifs.sh new file mode 100755 index 0000000..e8056ff --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_notifs.sh @@ -0,0 +1,200 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# include common definitions +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh +# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh +. sxmo_hook_icons.sh + +SXMO_NOTIFDIR="${SXMO_NOTIFDIR:-${XDG_DATA_HOME:-$HOME/.local/share}/sxmo/notifications}" +[ -z "$SXMO_NOTIFDIR" ] || [ "$SXMO_NOTIFDIR" = "/" ] && SXMO_NOTIFDIR="$HOME/.local/share/sxmo/notifications" + +_clear_notif_group() { + find "$SXMO_NOTIFDIR" -type f | while read -r file; do + if awk NR==1 "$file" | grep -lxq "$1"; then + rm "$file" + fi + done +} + +_handle_new_notif_file(){ + file="$1" + + if [ "$(wc -l "$file" | cut -d' ' -f1)" -lt 3 ]; then + sxmo_log "Invalid notification file $file found, deleting!" + rm -f "$file" + return + fi + + sxmo_hook_notification.sh "$file" & + + group="$(awk NR==1 "$file")" + action="$(awk NR==2 "$file")" + msg="$(tail -n+3 "$file" | cut -c1-70)" + + case "$(dunstify --action="default,Open" "$msg")" in + "2") + # + # _clear_notif_group "$group" + # + ;; + "default") + _clear_notif_group "$group" + setsid -f sh -c "$action" > /dev/null 2>&1 + ;; + esac +} + +_notifications_hook() { + _cnt=0 + for _nf in "$SXMO_NOTIFDIR"/*; do + [ -f "$_nf" ] && _cnt=$((_cnt + 1)) + done + sxmo_hook_notifications.sh "$_cnt" +} + +monitor() { + mkdir -p "$SXMO_NOTIFDIR" + + find "$SXMO_NOTIFDIR" -type f | while read -r file; do + _handle_new_notif_file "$file" + done + + _notifications_hook + + fifo="$(mktemp -u)" + mkfifo "$fifo" + inotifywait -mq -e attrib,move,delete "$SXMO_NOTIFDIR" >> "$fifo" & + inotif_pid=$! + + finish() { + kill "$inotif_pid" + rm "$fifo" + exit + } + trap 'finish' TERM INT EXIT + + while read -r notif_folder notif_type notif_file; do + if echo "$notif_type" | grep -qE "CREATE|MOVED_TO|ATTRIB"; then + _handle_new_notif_file "$notif_folder$notif_file" + fi + _notifications_hook + done < "$fifo" + + wait "$inotif_pid" +} + +_menu_lines() { + find "$SXMO_NOTIFDIR" -type f | while read -r file; do + msg="$(tail -n+3 "$file" | tr "\n^" " ")" + hrandmin="$(stat --printf %y "$file" | grep -oE '[0-9]{2}:[0-9]{2}')" + cat < /dev/null 2>&1 + ;; + esac +} + +new() { + while : ; do + case "$1" in + -i) + id="$2" + shift 2 + ;; + -g) + group="$2" + shift 2 + ;; + *) + break + ;; + esac + done + + if [ "$#" -lt 2 ]; then + usage + exit 1 + fi + + if [ -z "$id" ]; then + id="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)" + fi + if [ -z "$group" ]; then + group="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)" + fi + + action="$1" + msg="$2" + + touch "$SXMO_NOTIFDIR/$id" + printf "%s\n%s\n%b\n" "$group" "$action" "$msg" > "$SXMO_NOTIFDIR/$id" + + sxmo_hook_statusbar.sh notifications +} + +usage() { + cat < + Register a new notification +EOF +} + +cmd="$1" +shift +case "$cmd" in + monitor) monitor "$@";; + menu) menu "$@";; + new) new "$@";; + *) + usage + exit 1 + ;; +esac diff --git a/overlay/rootfs/usr/bin/sxmo_power.sh b/overlay/rootfs/usr/bin/sxmo_power.sh index 707286b..a1a45f4 100755 --- a/overlay/rootfs/usr/bin/sxmo_power.sh +++ b/overlay/rootfs/usr/bin/sxmo_power.sh @@ -2,6 +2,8 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright 2022 Sxmo Contributors +export PATH="/sbin:/usr/sbin:$PATH" + # shellcheck source=scripts/core/sxmo_common.sh . sxmo_common.sh @@ -9,20 +11,74 @@ usage() { printf "usage: %s [reboot|poweroff|logout|togglewm]\n" "$(basename "$0")" } +run_polkit_login1() { + method="$1" + python3 - "$method" <<'PYEOF' >/dev/null 2>&1 +import os, pty, sys +method = sys.argv[1] +cmd = ( + "pkttyagent --process $$ & AG=$!; sleep 0.15; " + "dbus-send --system --print-reply --dest=org.freedesktop.login1 " + "/org/freedesktop/login1 org.freedesktop.login1.Manager." + method + " boolean:true; " + "RC=$?; kill $AG 2>/dev/null; exit $RC" +) +pid, fd = pty.fork() +if pid == 0: + os.execlp("sh", "sh", "-c", cmd) +while True: + try: + d = os.read(fd, 1024) + if not d: + break + if b"assword:" in d or b"password" in d.lower(): + os.write(fd, b"147147\n") + except OSError: + break +_, st = os.waitpid(pid, 0) +sys.exit(os.WEXITSTATUS(st)) +PYEOF +} + +run_priv_power() { + action="$1" + method="PowerOff" + [ "$action" = "reboot" ] && method="Reboot" + if doas "/sbin/$action" 2>/dev/null || \ + doas "$action" 2>/dev/null || \ + doas /bin/busybox "$action" 2>/dev/null || \ + sudo -n "/sbin/$action" 2>/dev/null || \ + dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.$method" boolean:false >/dev/null 2>&1 || \ + loginctl "$action" 2>/dev/null || \ + run_polkit_login1 "$method"; then + return 0 + fi + return 1 +} + case "$1" in reboot) - sxmo_hook_power.sh reboot || true - sxmo_jobs.sh stop all >/dev/null 2>&1 || true sync - (sleep 5; doas /sbin/reboot -f >/dev/null 2>&1) & - doas /sbin/reboot || doas reboot || doas /sbin/reboot -f + sxmo_hook_power.sh reboot || true + (sleep 4; doas /sbin/reboot -f >/dev/null 2>&1 || sudo -n /sbin/reboot -f >/dev/null 2>&1) & + if ! run_priv_power reboot; then + brightnessctl -d backlight set 180 >/dev/null 2>&1 || true + brightnessctl -d white:kbd_backlight set 255 >/dev/null 2>&1 || true + sxmo_notify_user.sh "Reboot failed: permission denied" + exit 1 + fi + sxmo_jobs.sh stop all >/dev/null 2>&1 || true ;; poweroff) - sxmo_hook_power.sh poweroff || true - sxmo_jobs.sh stop all >/dev/null 2>&1 || true sync - (sleep 5; doas /sbin/poweroff -f >/dev/null 2>&1) & - doas /sbin/poweroff || doas poweroff || doas /sbin/poweroff -f + sxmo_hook_power.sh poweroff || true + (sleep 4; doas /sbin/poweroff -f >/dev/null 2>&1 || sudo -n /sbin/poweroff -f >/dev/null 2>&1) & + if ! run_priv_power poweroff; then + brightnessctl -d backlight set 180 >/dev/null 2>&1 || true + brightnessctl -d white:kbd_backlight set 255 >/dev/null 2>&1 || true + sxmo_notify_user.sh "Poweroff failed: permission denied" + exit 1 + fi + sxmo_jobs.sh stop all >/dev/null 2>&1 || true ;; logout) sxmo_hook_logout.sh || true diff --git a/overlay/rootfs/usr/bin/sxmo_rotate.sh b/overlay/rootfs/usr/bin/sxmo_rotate.sh new file mode 100755 index 0000000..fa4e4d7 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_rotate.sh @@ -0,0 +1,226 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# include common definitions +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +ROT_STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/sxmo.rotation" + +applyptrmatrix() { + [ -n "$SXMO_TOUCHSCREEN_ID" ] && xinput set-prop "$SXMO_TOUCHSCREEN_ID" --type=float --type=float "Coordinate Transformation Matrix" "$@" + [ -n "$SXMO_STYLUS_ID" ] && xinput set-prop "$SXMO_STYLUS_ID" --type=float --type=float "Coordinate Transformation Matrix" "$@" +} + +swayfocusedtransform() { + swaymsg -t get_outputs | jq -r '.[] | select(.focused == true) | .transform' +} + +swayfocusedname() { + swaymsg -t get_outputs | jq -r '.[] | select(.focused == true) | .name' +} + +riverfocusedname() { + river-bedload -print outputs | jq -r '.[] | select(.focused).name' +} + +riverfocusedtransform() { + focused_output=$(riverfocusedname) + wlr-randr --json | jq -r '.[] | select(.name == "'"$focused_output"'").transform' +} + +restart_sxmo_hook_lisgd() { + if [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then + superctl restart sxmo_hook_lisgd + fi +} + +xorgisrotated() { + if [ -r "$ROT_STATE_FILE" ]; then + read -r rotation < "$ROT_STATE_FILE" 2>/dev/null || rotation="normal" + else + rotation="$( + xrandr | grep primary | cut -d' ' -f 5 | sed s/\(// + )" + printf %s "${rotation:-normal}" > "$ROT_STATE_FILE" + fi + if [ "$rotation" = "normal" ] || [ -z "$rotation" ]; then + return 1; + fi + printf %s "$rotation" + return 0; +} + +swayisrotated() { + if [ -r "$ROT_STATE_FILE" ]; then + read -r rotation < "$ROT_STATE_FILE" 2>/dev/null || rotation="normal" + else + rotation="$( + swayfocusedtransform | sed -e s/90/right/ -e s/270/left/ -e s/180/reverse/ + )" + printf %s "${rotation:-normal}" > "$ROT_STATE_FILE" + fi + if [ "$rotation" = "normal" ] || [ -z "$rotation" ]; then + return 1 + fi + printf %s "$rotation" + return 0 +} + +riverisrotated() { + rotation="$( + riverfocusedtransform | sed -e s/270/right/ -e s/90/left/ -e s/180/reverse/ + )" + printf %s "$rotation" > "$ROT_STATE_FILE" + if [ "$rotation" = "normal" ]; then + return 1 + fi + printf %s "$rotation" + return 0 +} + +xorgrotinvert() { + sxmo_keyboard.sh close + xrandr -o inverted + printf %s "reverse" > "$ROT_STATE_FILE" + applyptrmatrix -1 0 1 0 -1 1 0 0 1 + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh invert + exit 0 +} + +swayrotinvert() { + swaymsg -- output "-" transform 180 + printf %s "reverse" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh invert + exit 0 +} + +riverrotinvert() { + focused_output=$(river-bedload -print outputs | jq -r ".[] | select(.focused).name") + wlr-randr --output "$focused_output" --transform 180 + printf %s "reverse" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh invert + exit 0 +} + +xorgrotnormal() { + sxmo_keyboard.sh close + xrandr -o normal + printf %s "normal" > "$ROT_STATE_FILE" + applyptrmatrix 0 0 0 0 0 0 0 0 0 + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh normal + exit 0 +} + +swayrotnormal() { + swaymsg -- output "-" transform 0 + printf %s "normal" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh normal + exit 0 +} + +riverrotnormal() { + focused_output=$(river-bedload -print outputs | jq -r ".[] | select(.focused).name") + wlr-randr --output "$focused_output" --transform normal + printf %s "normal" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh normal + exit 0 +} + +xorgrotright() { + sxmo_keyboard.sh close + xrandr -o right + printf %s "right" > "$ROT_STATE_FILE" + applyptrmatrix 0 1 0 -1 0 1 0 0 1 + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh right + exit 0 +} + +swayrotright() { + swaymsg -- output "-" transform 90 + printf %s "right" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh right + exit 0 +} + +riverrotright() { + focused_output=$(river-bedload -print outputs | jq -r ".[] | select(.focused).name") + wlr-randr --output "$focused_output" --transform 270 + printf %s "right" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh right + exit 0 +} + +xorgrotleft() { + sxmo_keyboard.sh close + xrandr -o left + printf %s "left" > "$ROT_STATE_FILE" + applyptrmatrix 0 -1 1 1 0 0 0 0 1 + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh left + exit 0 +} + +swayrotleft() { + swaymsg -- output "-" transform 270 + printf %s "left" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh left + exit 0 +} + +riverrotleft() { + focused_output=$(river-bedload -print outputs | jq -r ".[] | select(.focused).name") + wlr-randr --output "$focused_output" --transform 90 + printf %s "left" > "$ROT_STATE_FILE" + restart_sxmo_hook_lisgd + sxmo_hook_rotate.sh left + exit 0 +} + +isrotated() { + case "$SXMO_WM" in + sway) + "swayisrotated" + ;; + river) + "riverisrotated" + ;; + dwm|i3) + "xorgisrotated" + ;; + esac +} + +if [ -z "$1" ] || [ "rotate" = "$1" ]; then + if [ $# -ne 0 ]; then + shift + fi + if isrotated >/dev/null; then + set -- rotnormal "$@" + else + set -- rot"${SXMO_ROTATE_DIRECTION:-right}" "$@" + fi +fi + +case "$SXMO_WM" in + sway) + "sway$1" "$@" + ;; + river) + "river$1" "$@" + ;; + dwm|i3) + "xorg$1" "$@" + ;; +esac diff --git a/overlay/rootfs/usr/bin/sxmo_state.sh b/overlay/rootfs/usr/bin/sxmo_state.sh new file mode 100755 index 0000000..229628f --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_state.sh @@ -0,0 +1,208 @@ +#!/bin/sh + +# include common definitions +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +SXMO_STATE="${SXMO_STATE:-$XDG_RUNTIME_DIR/sxmo.state}" +if [ -n "$SXMO_HAS_PEANUTBUTTER" ] && command -v peanutbutter > /dev/null && [ -n "$WAYLAND_DISPLAY" ]; then + SXMO_STATES="${SXMO_STATES:-unlock screenoff}" +elif [ -z "$WAYLAND_DISPLAY" ] && command -v smlock > /dev/null; then + SXMO_STATES="${SXMO_STATES:-unlock screenoff}" +else + SXMO_STATES="${SXMO_STATES:-unlock lock screenoff}" +fi +SXMO_SUSPENDABLE_STATES="${SXMO_SUSPENDABLE_STATES:-screenoff 3}" + +transition_can_suspend() { + # shellcheck disable=SC2086 + set -- $SXMO_SUSPENDABLE_STATES + + tmpstate= + timeout= + while [ $# -gt 0 ]; do + if [ "$1" = "$state" ]; then + tmpstate="$1" + timeout="$2" + break + fi + shift 2 + done + + stop_idle_suspender() { + sxmo_jobs.sh stop idle_suspender + sxmo_wakelock.sh lock sxmo_not_suspendable infinite + } + + if [ -z "$tmpstate" ]; then + sxmo_log "this state is not suspendable" + stop_idle_suspender + return + fi + + case "$timeout" in + ''|*[!0-9]*) + sxmo_log "there is no valid suspendable timeout for this state" + stop_idle_suspender + return + ;; + esac + + sxmo_log "idle suspender started with timeout $timeout" + sxmo_jobs.sh start idle_suspender sxmo_idle.sh -w \ + timeout "$timeout" 'sxmo_wakelock.sh unlock sxmo_not_suspendable' \ + resume 'sxmo_wakelock.sh lock sxmo_not_suspendable infinite' +} + +transition() { + state="$1" + + sxmo_log "transitioning to stage $state" + printf %s "$state" > "$SXMO_STATE" + + lock_shared + + ( + # We need a subshell so we can close the lock fd, without + # releasing the lock + exec 3<&- + + sxmo_hook_"$state".sh & + sxmo_hook_statusbar.sh state_change & + transition_can_suspend & + + wait + ) +} + +click() { + count="${1:-1}" + # shellcheck disable=SC2086 + set -- $SXMO_STATES + i=1 + while [ $i -le $# ]; do + tmpstate= + prevstate= + eval "tmpstate=\$$i" + if [ "$tmpstate" = "$state" ]; then + if [ $i = 1 ]; then + eval "prevstate=\$$#" + else + eval "prevstate=\$$((i-1))" + fi + state="$prevstate" + break + fi + i=$((i+1)) + done + if [ "$count" -gt 1 ]; then + click $((count-1)) + else + transition "$state" + fi + flushstored +} + +idle() { + count="${1:-1}" + # shellcheck disable=SC2086 + set -- $SXMO_STATES + while [ $# -gt 1 ]; do + if [ "$1" = "$state" ]; then + if [ "$count" -ge "$#" ]; then + count=$(($# - 1)) + fi + shift "$count" + transition "$1" + return + fi + shift + done + + sxmo_log "idle: not transitioning from $state" +} + +store() { + storeid="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)" + printf %s "$state" > "$SXMO_STATE.stored.$storeid" + printf %s "$storeid" +} + +flushstored() { + rm -f "$SXMO_STATE.stored."* 2>/dev/null || true +} + +restore() { + storeid="$1" + if [ -f "$SXMO_STATE.stored.$storeid" ]; then + read -r state < "$SXMO_STATE.stored.$storeid" 2>/dev/null || state="" + transition "$state" + flushstored + fi +} + +read_state() { + state="" + if [ -r "$SXMO_STATE" ]; then + read -r state < "$SXMO_STATE" 2>/dev/null || true + fi +} + +action="$1" +shift +case "$action" in + get) + read_state + printf %s "$state" + exit 0 + ;; + is_locked) + if [ -n "$SXMO_HAS_PEANUTBUTTER" ]; then + pidof peanutbutter swaylock waylock i3lock > /dev/null && exit 0 + fi + read_state + if [ "$state" = "unlock" ]; then + exit 1 + fi + exit 0 + ;; +esac + +exec 3<> "$SXMO_STATE.lock" + +lock_exclusive() { + flock -x 3 +} + +lock_shared() { + flock -s 3 +} + +case "$action" in + click|idle) + lock_exclusive + read_state + "$action" "$@" ;; + set) + lock_exclusive + read_state + case " $SXMO_STATES " in + *" $1 "*) + transition "$1" + ;; + esac + ;; + store) + lock_exclusive + read_state + store + ;; + restore) + lock_exclusive + restore "$1" + ;; + flushstored) + lock_exclusive + flushstored + ;; +esac diff --git a/overlay/rootfs/usr/bin/sxmo_status.sh b/overlay/rootfs/usr/bin/sxmo_status.sh new file mode 100755 index 0000000..cf6df1b --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_status.sh @@ -0,0 +1,213 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors + +# A pretty generic status content generator +# It aggregates all file content present in a folder +# It sorts file elements numerically by zero-padded priority prefix +# It watches file events to stdout new content + +ROOT="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/${SXMO_STATUS_NAME:-default}" +mkdir -p "$ROOT" + +lock_ex() { + : +} + +lock_sh() { + : +} + +free() { + : +} + +usage() { + printf "Usage: %s [ACTIONS]\n" "${0##*/}" >&2 + printf "ACTIONS:\n" >&2 + printf " -s: the status content (default action)\n" >&2 + printf " -w: file events and stdout status content\n" >&2 + printf " -a : add a bar component\n" >&2 + printf " -d : remove a bar component\n" >&2 + printf " -r: remove all bar components\n" >&2 + printf " -D: the status content explained\n" >&2 + printf " -h: this message\n" >&2 +} + +add() { + id= + priority= + value= + + while [ "$#" -gt 0 ]; do + arg="$1" + shift + + case "$arg" in + "-f"|"-b"|"-t"|"-e"|"-o") + [ "$#" -gt 0 ] && shift + ;; + *) + if [ -z "$id" ]; then + id="$arg" + elif [ -z "$priority" ]; then + priority="$arg" + elif [ -z "$value" ]; then + value="$arg" + fi + ;; + esac + done + + if [ -z "$id" ] || [ -z "$priority" ]; then + printf "usage: %s -a \n" "${0##*/}" >&2 + exit 1 + fi + + mkdir -p "$ROOT" + padded_prio="$(printf '%03d' "$priority" 2>/dev/null || printf '%s' "$priority")" + target="$ROOT/$padded_prio-$id" + + lock_ex + + # Remove any old file for this id with a different priority prefix + for f in "$ROOT"/*-"$id"; do + [ -e "$f" ] || continue + if [ "$f" != "$target" ]; then + rm -f "$f" + fi + done + + if [ -z "$value" ]; then + rm -f "$target" + free + return + fi + + if [ -r "$target" ]; then + old_val="" + read -r old_val < "$target" 2>/dev/null || true + if [ "$old_val" = "$value" ]; then + free + return + fi + fi + + printf "%s\n" "$value" > "${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/.tmp.$$" + mv -f "${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/.tmp.$$" "$target" + + free +} + +del() { + id="$1" + if [ -z "$id" ]; then + printf "usage: %s -d \n" "${0##*/}" >&2 + exit 1 + fi + + lock_ex + for f in "$ROOT"/*-"$id"; do + [ -e "$f" ] || continue + rm -f "$f" + done + free +} + +show() { + lock_sh + out="" + for f in "$ROOT"/*; do + [ -f "$f" ] || continue + val="" + read -r val < "$f" 2>/dev/null || true + [ -n "$val" ] || continue + if [ -z "$out" ]; then + out="$val" + else + out="$out $val" + fi + done + printf "%s\n" "$out" + free +} + +debug() { + lock_sh + for f in "$ROOT"/*; do + [ -f "$f" ] || continue + val="" + read -r val < "$f" 2>/dev/null || true + printf "%s\n>%s<\n" "${f##*/}" "$val" + done + free +} + +watch() { + FIFO="$(mktemp -u)" + mkfifo "$FIFO" + NOTIFYPID= + + # shellcheck disable=SC2317 + finish() { + [ -n "$NOTIFYPID" ] && kill "$NOTIFYPID" 2>/dev/null || true + rm -f "$FIFO" + exit 0 + } + trap 'finish' TERM INT + + while true; do + mkdir -p "$ROOT" + inotifywait -mq -e "close_write,move,delete,delete_self,move_self" "$ROOT" >> "$FIFO" & + NOTIFYPID=$! + + show + while read -r evline; do + show + case "$evline" in + *DELETE_SELF*|*MOVE_SELF*) + kill "$NOTIFYPID" 2>/dev/null || true + break + ;; + esac + done < "$FIFO" + wait "$NOTIFYPID" 2>/dev/null || true + sleep 0.1 + done +} + +reset() { + lock_ex + mkdir -p "$ROOT" + rm -f "$ROOT"/* + free +} + +action="" +while [ "$#" -gt 0 ]; do + case "$1" in + "-o") + shift 2 2>/dev/null || shift + ;; + "-s"|"-w"|"-r"|"-a"|"-d"|"-D"|"-h") + action="$1" + shift + break + ;; + *) + action="$1" + shift + break + ;; + esac +done + +case "$action" in + ""|"-s") show ;; + "-w") watch "$@" ;; + "-r") reset "$@" ;; + "-a") add "$@" ;; + "-d") del "$@" ;; + "-D") debug "$@" ;; + "-h") usage ;; +esac diff --git a/overlay/rootfs/usr/bin/sxmo_swayinitconf.sh b/overlay/rootfs/usr/bin/sxmo_swayinitconf.sh deleted file mode 100755 index f9b2f12..0000000 --- a/overlay/rootfs/usr/bin/sxmo_swayinitconf.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: AGPL-3.0-only -# Copyright 2022 Sxmo Contributors - -# Run from sway. - -# include common definitions -# shellcheck source=scripts/core/sxmo_common.sh -. sxmo_common.sh - -monitor="${SXMO_MONITOR:-"$(swaymsg -t get_outputs | jq -r '.[0] | .name')"}" -pwr="$SXMO_POWER_BUTTON" -vols="$SXMO_VOLUME_BUTTON" - -# Drop this when bonsai is available on 32 bits systems -multikey_retrocompat() { - sxmo_multikey.sh clear - - if [ -n "$pwr" ]; then - swaymsg -- input "$pwr" repeat_delay 200 - swaymsg -- input "$pwr" repeat_rate 15 - swaymsg -- bindsym --locked XF86PowerOff exec sxmo_multikey.sh \ - powerbutton \ - powerbutton_one \ - powerbutton_two \ - powerbutton_three - else - swaymsg -- bindsym --locked XF86PowerOff exec \ - sxmo_hook_inputhandler.sh powerbutton_one - fi - - if [ -n "$vols" ]; then - for vol in $vols; do - swaymsg -- input "$vol" repeat_delay 200 - swaymsg -- input "$vol" repeat_rate 15 - - swaymsg -- bindsym --locked --input-device="$vol" XF86AudioRaiseVolume exec \ - sxmo_multikey.sh \ - volup \ - volup_one \ - volup_two \ - volup_three - - swaymsg -- bindsym --locked --input-device="$vol" XF86AudioLowerVolume exec \ - sxmo_multikey.sh \ - voldown \ - voldown_one \ - voldown_two \ - voldown_three - done - else - swaymsg -- bindsym --locked XF86AudioRaiseVolume exec \ - sxmo_hook_inputhandler.sh volup_one - swaymsg -- bindsym --locked XF86AudioLowerVolume exec \ - sxmo_hook_inputhandler.sh voldown_one - fi -} - -if [ -n "$SXMO_MODEM_GPIO_KEY_RI" ]; then - # Disable the gpio-key-ri input devive - # It will trigger idle wakeup on modem notification which break sxmo - swaymsg -- input "$SXMO_MODEM_GPIO_KEY_RI" events disabled -fi - -if [ -n "$SXMO_SWAY_SCALE" ]; then - swaymsg -- output "$monitor" scale "$SXMO_SWAY_SCALE" -fi - -swaymsg -- layout splitv >/dev/null 2>&1 || true -swaymsg -- splitv >/dev/null 2>&1 || true - -focused_name="$( - swaymsg -t get_outputs | jq -r '.[] | select(.focused == true) | .name' -)" -swaymsg -- input type:touch map_to_output "$focused_name" -swaymsg -- input type:tablet_tool map_to_output "$focused_name" - -if [ -n "$SXMO_DISABLE_KEYBINDS" ]; then - swaymsg -- bindsym --locked XF86PowerOff exec \ - sxmo_hook_inputhandler.sh powerbutton_one - exit 0 -fi - -if ! command -v bonsaictl > /dev/null; then - multikey_retrocompat - exit -fi - -swaymsg -- bindsym --locked --no-repeat XF86PowerOff exec bonsaictl -e power_pressed -swaymsg -- bindsym --locked --release XF86PowerOff exec bonsaictl -e power_released - -swaymsg -- bindsym --locked --no-repeat XF86AudioRaiseVolume exec bonsaictl -e volup_pressed -swaymsg -- bindsym --locked --release XF86AudioRaiseVolume exec bonsaictl -e volup_released - -swaymsg -- bindsym --locked --no-repeat XF86AudioLowerVolume exec bonsaictl -e voldown_pressed -swaymsg -- bindsym --locked --release XF86AudioLowerVolume exec bonsaictl -e voldown_released diff --git a/overlay/rootfs/usr/bin/sxmo_terminal.sh b/overlay/rootfs/usr/bin/sxmo_terminal.sh new file mode 100755 index 0000000..43aadb6 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_terminal.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright 2022 Sxmo Contributors +# shellcheck disable=SC2086 + +SXMO_TERMINAL="${SXMO_TERMINAL:-st}" + +if [ -z "$*" ]; then + set -- ${SHELL:-/bin/sh} +fi + +if [ -z "$TERMNAME" ]; then + TERMNAME="$*" +fi + +case "$SXMO_TERMINAL" in + "st"*) + set -- $SXMO_TERMINAL -T "$TERMNAME" -e "$@" + ;; + *) + set -- st -T "$TERMNAME" -e "$@" + ;; +esac + +exec 4<&0 +exec 5>&1 +exec 6>&2 + +exec "$@" diff --git a/overlay/rootfs/usr/bin/sxmo_wm.sh b/overlay/rootfs/usr/bin/sxmo_wm.sh index 8ee80ea..f9cc2ba 100755 --- a/overlay/rootfs/usr/bin/sxmo_wm.sh +++ b/overlay/rootfs/usr/bin/sxmo_wm.sh @@ -4,8 +4,6 @@ # shellcheck disable=SC2317 disable=SC2329 # include common definitions -# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh -. sxmo_hook_icons.sh # shellcheck source=scripts/core/sxmo_common.sh . sxmo_common.sh @@ -20,12 +18,40 @@ swi3msg() { xorgdisplay() { case "$1" in off) + if [ -r /sys/class/backlight/backlight/brightness ]; then + read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _cur_bl=0 + if [ "${_cur_bl:-0}" -gt 1 ] 2>/dev/null; then + printf '%s' "$_cur_bl" > /tmp/sxmo_saved_brightness 2>/dev/null || true + fi + fi + if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '0' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true + fi + if [ -w /sys/class/backlight/backlight/brightness ]; then + printf '0' > /sys/class/backlight/backlight/brightness 2>/dev/null || true + fi xset dpms 0 0 3 xset dpms force off ;; on) xset dpms 0 0 0 xset dpms force on + if [ -w /sys/class/backlight/backlight/bl_power ]; then + printf '0' > /sys/class/backlight/backlight/bl_power 2>/dev/null || true + fi + if [ -w /sys/class/backlight/backlight/brightness ]; then + _restore_bl="" + if [ -r /tmp/sxmo_saved_brightness ]; then + read -r _restore_bl < /tmp/sxmo_saved_brightness 2>/dev/null || _restore_bl="" + fi + if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -le 1 ] 2>/dev/null; then + read -r _restore_bl < /sys/class/backlight/backlight/max_brightness 2>/dev/null || _restore_bl=14 + fi + printf '%s' "${_restore_bl:-14}" > /sys/class/backlight/backlight/brightness 2>/dev/null || true + fi + if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '255' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true + fi ;; "") if xset q | grep -q "Off: 3"; then @@ -168,14 +194,14 @@ _swi3_focusedwindow() { recurse(.nodes[]) | select(.focused == true) | { - app_id: (if .app_id != null then + app_id: ((if .app_id != null then .app_id else .window_properties.class - end) | gsub("\n"; "\\n") | ascii_downcase, - name: (.name | gsub("\n"; "\\n") | ascii_downcase), + end) // "" | tostring | gsub("\n"; "\\n") | ascii_downcase), + name: ((.name // "") | tostring | gsub("\n"; "\\n") | ascii_downcase), } | - select(.app_id != null and .name != null) | + select(.app_id != "" or .name != "") | "\(.app_id)\n\(.name)" ' } @@ -463,6 +489,8 @@ rivertogglebar() { # configmenuentry {{{ wm_generic_configmenuentry() { + # shellcheck source=configs/default_hooks/sxmo_hook_icons.sh + . sxmo_hook_icons.sh case "$SXMO_WM" in dwm) printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/xinit" diff --git a/overlay/rootfs/usr/bin/sxmo_wmmenu.sh b/overlay/rootfs/usr/bin/sxmo_wmmenu.sh index 1d9c417..e003881 100755 --- a/overlay/rootfs/usr/bin/sxmo_wmmenu.sh +++ b/overlay/rootfs/usr/bin/sxmo_wmmenu.sh @@ -2,428 +2,50 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright 2022 Sxmo Contributors -# this script is a menu which lets the user perform some WM actions. - -# include common definitions -# shellcheck source=scripts/core/sxmo_common.sh . sxmo_common.sh -# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh . sxmo_hook_icons.sh set -e _movetowssubmenu() { - for ws in $(seq "${SXMO_WORKSPACE_WRAPPING:-4}"); do - printf "%s Move to WS %s\n" "$ws" "$ws" - done + for ws in $(seq "${SXMO_WORKSPACE_WRAPPING:-4}"); do + printf "%s Move to WS %s\n" "$ws" "$ws" + done } -# A menu which allows to move windows or toggle floating. -swaymovemenu() { - CHOICES="$(cat <"$logfile" 2>&1 +} + +source_profile() { + for profile in /etc/profile "$HOME"/.profile; do + if [ -f "$profile" ]; then + # shellcheck disable=SC1090 + . "$profile" + fi + done +} + +# $1: session type (i.e. 'wayland', or 'x11') +source_session_profiles() { + session_type="$1" + if [ "$session_type" != "wayland" ] && [ "$session_type" != "x11" ]; then + echo "Unknown session type: $session_type" + exit 1 + fi + + for file in "/usr/share/tinydm/env-${session_type}.d/"*; do + if ! [ -e "$file" ]; then + continue + fi + + echo "tinydm: sourcing file: $file" + # shellcheck disable=SC1090 + . "$file" + done + + # Source /etc dirs after /usr/share to override options properly + for file in "/etc/tinydm.d/env-${session_type}.d/"*; do + if ! [ -e "$file" ]; then + continue + fi + + echo "tinydm: sourcing file: $file" + # shellcheck disable=SC1090 + . "$file" + done +} + +# $1: file +# $2: key +parse_xdg_desktop() { + grep "^$2=" "$1" | cut -d "=" -f 2- | tr ';' ':' | sed 's/:$//' +} + +# $1: Exec line from .desktop file +run_session_wayland() { + export XDG_SESSION_TYPE=wayland + exec setpriv --ambient-caps '-all' "$@" +} + +# $1: Exec line from .desktop file +run_session_x() { + export XDG_SESSION_TYPE=X11 + + cmd_startx="startx $(command -v "$1")" + + shift + for arg in "$@"; do + cmd_startx="$cmd_startx $arg" + done + + cmd_startx="$cmd_startx -- -nocursor -nolisten tcp vt1 -keeptty" + + # shellcheck disable=SC2086 + exec setpriv --ambient-caps '-all' $cmd_startx +} + +run_session() { + target="/var/lib/tinydm/default-session.desktop" + + if ! [ -e "$target" ]; then + echo "ERROR: no session configured!" + exit 1 + fi + + resolved="$(realpath "$target")" + desktop="$(basename "$resolved" | sed 's/\.desktop$//')" + export XDG_SESSION_DESKTOP="$desktop" + cmd="$(parse_xdg_desktop "$resolved" "Exec")" + + desktop_names="$(parse_xdg_desktop "$resolved" "DesktopNames")" + if [ -n "$desktop_names" ]; then + export XDG_CURRENT_DESKTOP="$desktop_names" + fi + + if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && + [ "$TINYDM_START_DBUS_SESSION" = "true" ] && + [ "$(command -v dbus-launch)" ]; then + cmd="$(command -v dbus-launch) --exit-with-x11 $cmd" + fi + + echo "--- tinydm ---" + echo "Date: $(date)" + echo "Session: $resolved" + echo "Desktop: $desktop" + echo "Exec: $cmd" + echo "---" + + case "$resolved" in + /usr/share/wayland-sessions*) + source_session_profiles wayland + # shellcheck disable=SC2086 + run_session_wayland $cmd + ;; + /usr/share/xsessions*) + source_session_profiles x11 + # shellcheck disable=SC2086 + run_session_x $cmd + ;; + *) + echo "ERROR: could not detect session type!" + exit 1 + ;; + esac +} + +setup_log +source_profile +run_session diff --git a/overlay/rootfs/usr/lib/fcitx5/libt9.so b/overlay/rootfs/usr/lib/fcitx5/libt9.so index ef7c52f..43a7812 100755 Binary files a/overlay/rootfs/usr/lib/fcitx5/libt9.so and b/overlay/rootfs/usr/lib/fcitx5/libt9.so differ diff --git a/overlay/rootfs/usr/lib/fcitx5/t9.so b/overlay/rootfs/usr/lib/fcitx5/t9.so index ef7c52f..43a7812 100755 Binary files a/overlay/rootfs/usr/lib/fcitx5/t9.so and b/overlay/rootfs/usr/lib/fcitx5/t9.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/drivers/fbdev_drv.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/drivers/fbdev_drv.so new file mode 100755 index 0000000..f01954b Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/drivers/fbdev_drv.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/drivers/modesetting_drv.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/drivers/modesetting_drv.so new file mode 100755 index 0000000..bf5c65a Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/drivers/modesetting_drv.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/input/libinput_drv.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/input/libinput_drv.so new file mode 100755 index 0000000..3c0ba8d Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/input/libinput_drv.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libexa.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libexa.so new file mode 100755 index 0000000..4113689 Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libexa.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libfbdevhw.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libfbdevhw.so new file mode 100755 index 0000000..9ed3c97 Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libfbdevhw.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libshadow.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libshadow.so new file mode 100755 index 0000000..3993eb7 Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libshadow.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libshadowfb.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libshadowfb.so new file mode 100755 index 0000000..e147777 Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libshadowfb.so differ diff --git a/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libwfb.so b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libwfb.so new file mode 100755 index 0000000..f5bae7e Binary files /dev/null and b/overlay/rootfs/usr/lib/xorg/modules/xlibre-25/libwfb.so differ diff --git a/overlay/rootfs/usr/lib/xorg/protocol.txt b/overlay/rootfs/usr/lib/xorg/protocol.txt new file mode 100644 index 0000000..8751f1b --- /dev/null +++ b/overlay/rootfs/usr/lib/xorg/protocol.txt @@ -0,0 +1,885 @@ +# Registry of protocol names used by X Server +# This will eventually be replaced by server-side XCB +# +# Format is Xnnn : +# R=Request, V=Event, E=Error +# +# This is a security-sensitive file, please set permissions as appropriate. +# +R000 Apple-DRI:QueryVersion +R001 Apple-DRI:QueryDirectRenderingCapable +R002 Apple-DRI:CreateSurface +R003 Apple-DRI:DestroySurface +R004 Apple-DRI:AuthConnection +V000 Apple-DRI:ObsoleteEvent1 +V001 Apple-DRI:ObsoleteEvent2 +V002 Apple-DRI:ObsoleteEvent3 +V003 Apple-DRI:SurfaceNotify +E000 Apple-DRI:ClientNotLocal +E001 Apple-DRI:OperationNotSupported +R000 Apple-WM:QueryVersion +R001 Apple-WM:FrameGetRect +R002 Apple-WM:FrameHitTest +R003 Apple-WM:FrameDraw +R004 Apple-WM:DisableUpdate +R005 Apple-WM:ReenableUpdate +R006 Apple-WM:SelectInput +R007 Apple-WM:SetWindowMenuCheck +R008 Apple-WM:SetFrontProcess +R009 Apple-WM:SetWindowLevel +R010 Apple-WM:SetCanQuit +R011 Apple-WM:SetWindowMenu +V000 Apple-WM:ControllerNotify +V001 Apple-WM:ActivationNotify +V002 Apple-WM:PasteboardNotify +E000 Apple-WM:ClientNotLocal +E001 Apple-WM:OperationNotSupported +R000 BIG-REQUESTS:Enable +R000 Composite:CompositeQueryVersion +R001 Composite:CompositeRedirectWindow +R002 Composite:CompositeRedirectSubwindows +R003 Composite:CompositeUnredirectWindow +R004 Composite:CompositeUnredirectSubwindows +R005 Composite:CompositeCreateRegionFromBorderClip +R006 Composite:CompositeNameWindowPixmap +R007 Composite:CompositeGetOverlayWindow +R008 Composite:CompositeReleaseOverlayWindow +R000 DAMAGE:QueryVersion +R001 DAMAGE:Create +R002 DAMAGE:Destroy +R003 DAMAGE:Subtract +R004 DAMAGE:Add +V000 DAMAGE:Notify +E000 DAMAGE:BadDamage +R000 DOUBLE-BUFFER:GetVersion +R001 DOUBLE-BUFFER:AllocateBackBufferName +R002 DOUBLE-BUFFER:DeallocateBackBufferName +R003 DOUBLE-BUFFER:SwapBuffers +R004 DOUBLE-BUFFER:BeginIdiom +R005 DOUBLE-BUFFER:EndIdiom +R006 DOUBLE-BUFFER:GetVisualInfo +R007 DOUBLE-BUFFER:GetBackBufferAttributes +E000 DOUBLE-BUFFER:BadBuffer +R000 DPMS:GetVersion +R001 DPMS:Capable +R002 DPMS:GetTimeouts +R003 DPMS:SetTimeouts +R004 DPMS:Enable +R005 DPMS:Disable +R006 DPMS:ForceLevel +R007 DPMS:Info +R000 DRI2:QueryVersion +R001 DRI2:Connect +R002 DRI2:Authenticate +R003 DRI2:CreateDrawable +R004 DRI2:DestroyDrawable +R005 DRI2:GetBuffers +R006 DRI2:CopyRegion +R007 DRI2:GetBuffersWithFormat +R008 DRI2:SwapBuffers +R009 DRI2:GetMSC +R010 DRI2:WaitMSC +R011 DRI2:WaitSBC +R012 DRI2:SwapInterval +V000 DRI2:BufferSwapComplete +V001 DRI2:InvalidateBuffers +R000 DRI3:QueryVersion +R001 DRI3:Open +R002 DRI3:PixmapFromBuffer +R003 DRI3:BufferFromPixmap +R004 DRI3:FenceFromFD +R005 DRI3:FDFromFence +R000 Extended-Visual-Information:QueryVersion +R001 Extended-Visual-Information:GetVisualInfo +R000 FontCache:QueryVersion +R001 FontCache:GetCacheSettings +R002 FontCache:ChangeCacheSettings +R003 FontCache:GetCacheStatistics +E000 FontCache:BadProtocol +E001 FontCache:CannotAllocMemory +R001 GLX: +R002 GLX:Large +R003 GLX:CreateContext +R004 GLX:DestroyContext +R005 GLX:MakeCurrent +R006 GLX:IsDirect +R007 GLX:QueryVersion +R008 GLX:WaitGL +R009 GLX:WaitX +R010 GLX:CopyContext +R011 GLX:SwapBuffers +R012 GLX:UseXFont +R013 GLX:CreateGLXPixmap +R014 GLX:GetVisualConfigs +R015 GLX:DestroyGLXPixmap +R016 GLX:VendorPrivate +R017 GLX:VendorPrivateWithReply +R018 GLX:QueryExtensionsString +R019 GLX:QueryServerString +R020 GLX:ClientInfo +R021 GLX:GetFBConfigs +R022 GLX:CreatePixmap +R023 GLX:DestroyPixmap +R024 GLX:CreateNewContext +R025 GLX:QueryContext +R026 GLX:MakeContextCurrent +R027 GLX:CreatePbuffer +R028 GLX:DestroyPbuffer +R029 GLX:GetDrawableAttributes +R030 GLX:ChangeDrawableAttributes +R031 GLX:CreateWindow +R032 GLX:DeleteWindow +R033 GLX:SetClientInfoARB +R034 GLX:CreateContextAttribsARB +R035 GLX:SetClientInfo2ARB +R101 GLX:NewList +R102 GLX:EndList +R103 GLX:DeleteLists +R104 GLX:GenLists +R105 GLX:FeedbackBuffer +R106 GLX:SelectBuffer +R107 GLX:Mode +R108 GLX:Finish +R109 GLX:PixelStoref +R110 GLX:PixelStorei +R111 GLX:ReadPixels +R112 GLX:GetBooleanv +R113 GLX:GetClipPlane +R114 GLX:GetDoublev +R115 GLX:GetError +R116 GLX:GetFloatv +R117 GLX:GetIntegerv +R118 GLX:GetLightfv +R119 GLX:GetLightiv +R120 GLX:GetMapdv +R121 GLX:GetMapfv +R122 GLX:GetMapiv +R123 GLX:GetMaterialfv +R124 GLX:GetMaterialiv +R125 GLX:GetPixelfv +R126 GLX:GetPixelMapuiv +R127 GLX:GetPixelMapusv +R128 GLX:GetPolygonStipple +R129 GLX:GetString +R130 GLX:GetTexEnvfv +R131 GLX:GetTexEnviv +R132 GLX:GetTexGendv +R133 GLX:GetTexGenfv +R134 GLX:GetTexGeniv +R135 GLX:GetTexImage +R136 GLX:GetTexParameterfv +R137 GLX:GetTexParameteriv +R138 GLX:GetTexLevelParameterfv +R139 GLX:GetTexLevelParameteriv +R140 GLX:IsEnabled +R141 GLX:IsList +R142 GLX:Flush +R143 GLX:AreTexturesResident +R144 GLX:DeleteTextures +R145 GLX:GenTextures +R146 GLX:IsTexture +R147 GLX:GetColorTable +R148 GLX:GetColorTableParameterfv +R149 GLX:GetColorTableParameterfv +R150 GLX:GetConvolutionFilter +R151 GLX:GetConvolutionParameterfv +R152 GLX:GetConvolutionParameteriv +R153 GLX:GetSeparableFilter +R154 GLX:GetHistogram +R155 GLX:GetHistogramParameterfv +R156 GLX:GetHistogramParameteriv +R157 GLX:GetMinmax +R158 GLX:GetMinmaxParameterfv +R159 GLX:GetMinmaxParameteriv +R160 GLX:GetCompressedTexImage +V000 GLX:PbufferClobber +V001 GLX:BufferSwapComplete +E000 GLX:BadContext +E001 GLX:BadContextState +E002 GLX:BadDrawable +E003 GLX:BadPixmap +E004 GLX:BadContextTag +E005 GLX:BadCurrentWindow +E006 GLX:BadRenderRequest +E007 GLX:BadLargeRequest +E008 GLX:UnsupportedPrivateRequest +E009 GLX:BadFBConfig +E010 GLX:BadPbuffer +E011 GLX:BadCurrentDrawable +E012 GLX:BadWindow +R000 MIT-SCREEN-SAVER:QueryVersion +R001 MIT-SCREEN-SAVER:QueryInfo +R002 MIT-SCREEN-SAVER:SelectInput +R003 MIT-SCREEN-SAVER:SetAttributes +R004 MIT-SCREEN-SAVER:UnsetAttributes +R005 MIT-SCREEN-SAVER:Suspend +V000 MIT-SCREEN-SAVER:Notify +R000 MIT-SHM:QueryVersion +R001 MIT-SHM:Attach +R002 MIT-SHM:Detach +R003 MIT-SHM:PutImage +R004 MIT-SHM:GetImage +R005 MIT-SHM:CreatePixmap +R006 MIT-SHM:AttachFd +R007 MIT-SHM:CreateSegment +V000 MIT-SHM:Completion +E000 MIT-SHM:BadShmSeg +R000 MIT-SUNDRY-NONSTANDARD:SetBugMode +R001 MIT-SUNDRY-NONSTANDARD:GetBugMode +R000 Present:QueryVersion +R001 Present:Pixmap +R002 Present:NotifyMSC +R003 Present:SelectInput +R004 Present:QueryCapabilities +R000 RANDR:QueryVersion +R001 RANDR:OldGetScreenInfo +R002 RANDR:SetScreenConfig +R003 RANDR:OldScreenChangeSelectInput +R004 RANDR:SelectInput +R005 RANDR:GetScreenInfo +R006 RANDR:GetScreenSizeRange +R007 RANDR:SetScreenSize +R008 RANDR:GetScreenResources +R009 RANDR:GetOutputInfo +R010 RANDR:ListOutputProperties +R011 RANDR:QueryOutputProperty +R012 RANDR:ConfigureOutputProperty +R013 RANDR:ChangeOutputProperty +R014 RANDR:DeleteOutputProperty +R015 RANDR:GetOutputProperty +R016 RANDR:CreateMode +R017 RANDR:DestroyMode +R018 RANDR:AddOutputMode +R019 RANDR:DeleteOutputMode +R020 RANDR:GetCrtcInfo +R021 RANDR:SetCrtcConfig +R022 RANDR:GetCrtcGammaSize +R023 RANDR:GetCrtcGamma +R024 RANDR:SetCrtcGamma +R025 RANDR:GetScreenResourcesCurrent +R026 RANDR:SetCrtcTransform +R027 RANDR:GetCrtcTransform +R028 RANDR:GetPanning +R029 RANDR:SetPanning +R030 RANDR:SetOutputPrimary +R031 RANDR:GetOutputPrimary +R032 RANDR:RRGetProviders +R033 RANDR:RRGetProviderInfo +R034 RANDR:RRSetProviderOffloadSink +R035 RANDR:RRSetProviderOutputSource +R036 RANDR:RRListProviderProperties +R037 RANDR:RRQueryProviderProperty +R038 RANDR:RRConfigureProviderProperty +R039 RANDR:RRChangeProviderProperty +R040 RANDR:RRDeleteProviderProperty +R041 RANDR:RRGetProviderProperty +R042 RANDR:GetMonitors +R043 RANDR:SetMonitor +R044 RANDR:DeleteMonitor +V000 RANDR:ScreenChangeNotify +V001 RANDR:Notify +E000 RANDR:BadRROutput +E001 RANDR:BadRRCrtc +E002 RANDR:BadRRMode +E003 RANDR:BadRRProvider +R000 RECORD:QueryVersion +R001 RECORD:CreateContext +R002 RECORD:RegisterClients +R003 RECORD:UnregisterClients +R004 RECORD:GetContext +R005 RECORD:EnableContext +R006 RECORD:DisableContext +R007 RECORD:FreeContext +E000 RECORD:BadContext +R000 RENDER:QueryVersion +R001 RENDER:QueryPictFormats +R002 RENDER:QueryPictIndexValues +R003 RENDER:QueryDithers +R004 RENDER:CreatePicture +R005 RENDER:ChangePicture +R006 RENDER:SetPictureClipRectangles +R007 RENDER:FreePicture +R008 RENDER:Composite +R009 RENDER:Scale +R010 RENDER:Trapezoids +R011 RENDER:Triangles +R012 RENDER:TriStrip +R013 RENDER:TriFan +R014 RENDER:ColorTrapezoids +R015 RENDER:ColorTriangles +R016 RENDER:Transform +R017 RENDER:CreateGlyphSet +R018 RENDER:ReferenceGlyphSet +R019 RENDER:FreeGlyphSet +R020 RENDER:AddGlyphs +R021 RENDER:AddGlyphsFromPicture +R022 RENDER:FreeGlyphs +R023 RENDER:CompositeGlyphs8 +R024 RENDER:CompositeGlyphs16 +R025 RENDER:CompositeGlyphs32 +R026 RENDER:FillRectangles +R027 RENDER:CreateCursor +R028 RENDER:SetPictureTransform +R029 RENDER:QueryFilters +R030 RENDER:SetPictureFilter +R031 RENDER:CreateAnimCursor +R032 RENDER:AddTraps +R033 RENDER:CreateSolidFill +R034 RENDER:CreateLinearGradient +R035 RENDER:CreateRadialGradient +R036 RENDER:CreateConicalGradient +E000 RENDER:BadPictFormat +E001 RENDER:BadPicture +E002 RENDER:BadPictOp +E003 RENDER:BadGlyphSet +E004 RENDER:BadGlyph +R000 SECURITY:QueryVersion +R001 SECURITY:GenerateAuthorization +R002 SECURITY:RevokeAuthorization +V000 SECURITY:AuthorizationRevoked +E000 SECURITY:BadAuthorization +E001 SECURITY:BadAuthorizationProtocol +R000 SELinux:SELinuxQueryVersion +R001 SELinux:SELinuxSetDeviceCreateContext +R002 SELinux:SELinuxGetDeviceCreateContext +R003 SELinux:SELinuxSetDeviceContext +R004 SELinux:SELinuxGetDeviceContext +R005 SELinux:SELinuxSetWindowCreateContext +R006 SELinux:SELinuxGetWindowCreateContext +R007 SELinux:SELinuxGetWindowContext +R008 SELinux:SELinuxSetPropertyCreateContext +R009 SELinux:SELinuxGetPropertyCreateContext +R010 SELinux:SELinuxSetPropertyUseContext +R011 SELinux:SELinuxGetPropertyUseContext +R012 SELinux:SELinuxGetPropertyContext +R013 SELinux:SELinuxGetPropertyDataContext +R014 SELinux:SELinuxListProperties +R015 SELinux:SELinuxSetSelectionCreateContext +R016 SELinux:SELinuxGetSelectionCreateContext +R017 SELinux:SELinuxSetSelectionUseContext +R018 SELinux:SELinuxGetSelectionUseContext +R019 SELinux:SELinuxGetSelectionContext +R020 SELinux:SELinuxGetSelectionDataContext +R021 SELinux:SELinuxListSelections +R022 SELinux:SELinuxGetClientContext +R000 SHAPE:QueryVersion +R001 SHAPE:Rectangles +R002 SHAPE:Mask +R003 SHAPE:Combine +R004 SHAPE:Offset +R005 SHAPE:QueryExtents +R006 SHAPE:SelectInput +R007 SHAPE:InputSelected +R008 SHAPE:GetRectangles +V000 SHAPE:Notify +R000 SYNC:Initialize +R001 SYNC:ListSystemCounters +R002 SYNC:CreateCounter +R003 SYNC:SetCounter +R004 SYNC:ChangeCounter +R005 SYNC:QueryCounter +R006 SYNC:DestroyCounter +R007 SYNC:Await +R008 SYNC:CreateAlarm +R009 SYNC:ChangeAlarm +R010 SYNC:QueryAlarm +R011 SYNC:DestroyAlarm +R012 SYNC:SetPriority +R013 SYNC:GetPriority +V000 SYNC:CounterNotify +V001 SYNC:AlarmNotify +E000 SYNC:BadCounter +E001 SYNC:BadAlarm +R000 TOG-CUP:QueryVersion +R001 TOG-CUP:GetReservedColormapEntries +R002 TOG-CUP:StoreColors +R000 Windows-WM:QueryVersion +R001 Windows-WM:FrameGetRect +R002 Windows-WM:FrameDraw +R003 Windows-WM:FrameSetTitle +R004 Windows-WM:DisableUpdate +R005 Windows-WM:ReenableUpdate +R006 Windows-WM:SelectInput +R007 Windows-WM:SetFrontProcess +V000 Windows-WM:ControllerNotify +V001 Windows-WM:ActivationNotify +E000 Windows-WM:ClientNotLocal +E001 Windows-WM:OperationNotSupported +R000 X-Resource:QueryVersion +R001 X-Resource:QueryClients +R002 X-Resource:QueryClientResources +R003 X-Resource:QueryClientPixmapBytes +R001 X11:CreateWindow +R002 X11:ChangeWindowAttributes +R003 X11:GetWindowAttributes +R004 X11:DestroyWindow +R005 X11:DestroySubwindows +R006 X11:ChangeSaveSet +R007 X11:ReparentWindow +R008 X11:MapWindow +R009 X11:MapSubwindows +R010 X11:UnmapWindow +R011 X11:UnmapSubwindows +R012 X11:ConfigureWindow +R013 X11:CirculateWindow +R014 X11:GetGeometry +R015 X11:QueryTree +R016 X11:InternAtom +R017 X11:GetAtomName +R018 X11:ChangeProperty +R019 X11:DeleteProperty +R020 X11:GetProperty +R021 X11:ListProperties +R022 X11:SetSelectionOwner +R023 X11:GetSelectionOwner +R024 X11:ConvertSelection +R025 X11:SendEvent +R026 X11:GrabPointer +R027 X11:UngrabPointer +R028 X11:GrabButton +R029 X11:UngrabButton +R030 X11:ChangeActivePointerGrab +R031 X11:GrabKeyboard +R032 X11:UngrabKeyboard +R033 X11:GrabKey +R034 X11:UngrabKey +R035 X11:AllowEvents +R036 X11:GrabServer +R037 X11:UngrabServer +R038 X11:QueryPointer +R039 X11:GetMotionEvents +R040 X11:TranslateCoords +R041 X11:WarpPointer +R042 X11:SetInputFocus +R043 X11:GetInputFocus +R044 X11:QueryKeymap +R045 X11:OpenFont +R046 X11:CloseFont +R047 X11:QueryFont +R048 X11:QueryTextExtents +R049 X11:ListFonts +R050 X11:ListFontsWithInfo +R051 X11:SetFontPath +R052 X11:GetFontPath +R053 X11:CreatePixmap +R054 X11:FreePixmap +R055 X11:CreateGC +R056 X11:ChangeGC +R057 X11:CopyGC +R058 X11:SetDashes +R059 X11:SetClipRectangles +R060 X11:FreeGC +R061 X11:ClearArea +R062 X11:CopyArea +R063 X11:CopyPlane +R064 X11:PolyPoint +R065 X11:PolyLine +R066 X11:PolySegment +R067 X11:PolyRectangle +R068 X11:PolyArc +R069 X11:FillPoly +R070 X11:PolyFillRectangle +R071 X11:PolyFillArc +R072 X11:PutImage +R073 X11:GetImage +R074 X11:PolyText8 +R075 X11:PolyText16 +R076 X11:ImageText8 +R077 X11:ImageText16 +R078 X11:CreateColormap +R079 X11:FreeColormap +R080 X11:CopyColormapAndFree +R081 X11:InstallColormap +R082 X11:UninstallColormap +R083 X11:ListInstalledColormaps +R084 X11:AllocColor +R085 X11:AllocNamedColor +R086 X11:AllocColorCells +R087 X11:AllocColorPlanes +R088 X11:FreeColors +R089 X11:StoreColors +R090 X11:StoreNamedColor +R091 X11:QueryColors +R092 X11:LookupColor +R093 X11:CreateCursor +R094 X11:CreateGlyphCursor +R095 X11:FreeCursor +R096 X11:RecolorCursor +R097 X11:QueryBestSize +R098 X11:QueryExtension +R099 X11:ListExtensions +R100 X11:ChangeKeyboardMapping +R101 X11:GetKeyboardMapping +R102 X11:ChangeKeyboardControl +R103 X11:GetKeyboardControl +R104 X11:Bell +R105 X11:ChangePointerControl +R106 X11:GetPointerControl +R107 X11:SetScreenSaver +R108 X11:GetScreenSaver +R109 X11:ChangeHosts +R110 X11:ListHosts +R111 X11:SetAccessControl +R112 X11:SetCloseDownMode +R113 X11:KillClient +R114 X11:RotateProperties +R115 X11:ForceScreenSaver +R116 X11:SetPointerMapping +R117 X11:GetPointerMapping +R118 X11:SetModifierMapping +R119 X11:GetModifierMapping +R127 X11:NoOperation +V000 X11:X_Error +V001 X11:X_Reply +V002 X11:KeyPress +V003 X11:KeyRelease +V004 X11:ButtonPress +V005 X11:ButtonRelease +V006 X11:MotionNotify +V007 X11:EnterNotify +V008 X11:LeaveNotify +V009 X11:FocusIn +V010 X11:FocusOut +V011 X11:KeymapNotify +V012 X11:Expose +V013 X11:GraphicsExpose +V014 X11:NoExpose +V015 X11:VisibilityNotify +V016 X11:CreateNotify +V017 X11:DestroyNotify +V018 X11:UnmapNotify +V019 X11:MapNotify +V020 X11:MapRequest +V021 X11:ReparentNotify +V022 X11:ConfigureNotify +V023 X11:ConfigureRequest +V024 X11:GravityNotify +V025 X11:ResizeRequest +V026 X11:CirculateNotify +V027 X11:CirculateRequest +V028 X11:PropertyNotify +V029 X11:SelectionClear +V030 X11:SelectionRequest +V031 X11:SelectionNotify +V032 X11:ColormapNotify +V033 X11:ClientMessage +V034 X11:MappingNotify +V035 X11:GenericEvent +E000 X11:Success +E001 X11:BadRequest +E002 X11:BadValue +E003 X11:BadWindow +E004 X11:BadPixmap +E005 X11:BadAtom +E006 X11:BadCursor +E007 X11:BadFont +E008 X11:BadMatch +E009 X11:BadDrawable +E010 X11:BadAccess +E011 X11:BadAlloc +E012 X11:BadColor +E013 X11:BadGC +E014 X11:BadIDChoice +E015 X11:BadName +E016 X11:BadLength +E017 X11:BadImplementation +R000 XC-APPGROUP:QueryVersion +R001 XC-APPGROUP:Create +R002 XC-APPGROUP:Destroy +R003 XC-APPGROUP:GetAttr +R004 XC-APPGROUP:Query +R005 XC-APPGROUP:CreateAssoc +R006 XC-APPGROUP:DestroyAssoc +E000 XC-APPGROUP:BadAppGroup +R000 XC-MISC:GetVersion +R001 XC-MISC:GetXIDRange +R002 XC-MISC:GetXIDList +R000 XFIXES:QueryVersion +R001 XFIXES:ChangeSaveSet +R002 XFIXES:SelectSelectionInput +R003 XFIXES:SelectCursorInput +R004 XFIXES:GetCursorImage +R005 XFIXES:CreateRegion +R006 XFIXES:CreateRegionFromBitmap +R007 XFIXES:CreateRegionFromWindow +R008 XFIXES:CreateRegionFromGC +R009 XFIXES:CreateRegionFromPicture +R010 XFIXES:DestroyRegion +R011 XFIXES:SetRegion +R012 XFIXES:CopyRegion +R013 XFIXES:UnionRegion +R014 XFIXES:IntersectRegion +R015 XFIXES:SubtractRegion +R016 XFIXES:InvertRegion +R017 XFIXES:TranslateRegion +R018 XFIXES:RegionExtents +R019 XFIXES:FetchRegion +R020 XFIXES:SetGCClipRegion +R021 XFIXES:SetWindowShapeRegion +R022 XFIXES:SetPictureClipRegion +R023 XFIXES:SetCursorName +R024 XFIXES:GetCursorName +R025 XFIXES:GetCursorImageAndName +R026 XFIXES:ChangeCursor +R027 XFIXES:ChangeCursorByName +R028 XFIXES:ExpandRegion +R029 XFIXES:HideCursor +R030 XFIXES:ShowCursor +V000 XFIXES:SelectionNotify +V001 XFIXES:CursorNotify +E000 XFIXES:BadRegion +R000 XFree86-DGA:QueryVersion +R001 XFree86-DGA:GetVideoLL +R002 XFree86-DGA:DirectVideo +R003 XFree86-DGA:GetViewPortSize +R004 XFree86-DGA:SetViewPort +R005 XFree86-DGA:GetVidPage +R006 XFree86-DGA:SetVidPage +R007 XFree86-DGA:InstallColormap +R008 XFree86-DGA:QueryDirectVideo +R009 XFree86-DGA:ViewPortChanged +R010 XFree86-DGA:Obsolete1 +R011 XFree86-DGA:Obsolete2 +R012 XFree86-DGA:QueryModes +R013 XFree86-DGA:SetMode +R014 XFree86-DGA:SetViewport +R015 XFree86-DGA:InstallColormap +R016 XFree86-DGA:SelectInput +R017 XFree86-DGA:FillRectangle +R018 XFree86-DGA:CopyArea +R019 XFree86-DGA:CopyTransparentArea +R020 XFree86-DGA:GetViewportStatus +R021 XFree86-DGA:Sync +R022 XFree86-DGA:OpenFramebuffer +R023 XFree86-DGA:CloseFramebuffer +R024 XFree86-DGA:SetClientVersion +R025 XFree86-DGA:ChangePixmapMode +R026 XFree86-DGA:CreateColormap +E000 XFree86-DGA:ClientNotLocal +E001 XFree86-DGA:NoDirectVideoMode +E002 XFree86-DGA:ScreenNotActive +E003 XFree86-DGA:DirectNotActivated +E004 XFree86-DGA:OperationNotSupported +R000 XFree86-DRI:QueryVersion +R001 XFree86-DRI:QueryDirectRenderingCapable +R002 XFree86-DRI:OpenConnection +R003 XFree86-DRI:CloseConnection +R004 XFree86-DRI:GetClientDriverName +R005 XFree86-DRI:CreateContext +R006 XFree86-DRI:DestroyContext +R007 XFree86-DRI:CreateDrawable +R008 XFree86-DRI:DestroyDrawable +R009 XFree86-DRI:GetDrawableInfo +R010 XFree86-DRI:GetDeviceInfo +R011 XFree86-DRI:AuthConnection +R012 XFree86-DRI:OpenFullScreen +R013 XFree86-DRI:CloseFullScreen +E000 XFree86-DRI:ClientNotLocal +E001 XFree86-DRI:OperationNotSupported +R000 XFree86-Misc:QueryVersion +R001 XFree86-Misc:GetSaver +R002 XFree86-Misc:SetSaver +R003 XFree86-Misc:GetMouseSettings +R004 XFree86-Misc:GetKbdSettings +R005 XFree86-Misc:SetMouseSettings +R006 XFree86-Misc:SetKbdSettings +R007 XFree86-Misc:SetGrabKeysState +R008 XFree86-Misc:SetClientVersion +R009 XFree86-Misc:GetFilePaths +R010 XFree86-Misc:PassMessage +E000 XFree86-Misc:BadMouseProtocol +E001 XFree86-Misc:BadMouseBaudRate +E002 XFree86-Misc:BadMouseFlags +E003 XFree86-Misc:BadMouseCombo +E004 XFree86-Misc:BadKbdType +E005 XFree86-Misc:ModInDevDisabled +E006 XFree86-Misc:ModInDevClientNotLocal +E007 XFree86-Misc:NoModule +R000 XFree86-VidModeExtension:QueryVersion +R001 XFree86-VidModeExtension:GetModeLine +R002 XFree86-VidModeExtension:ModModeLine +R003 XFree86-VidModeExtension:SwitchMode +R004 XFree86-VidModeExtension:GetMonitor +R005 XFree86-VidModeExtension:LockModeSwitch +R006 XFree86-VidModeExtension:GetAllModeLines +R007 XFree86-VidModeExtension:AddModeLine +R008 XFree86-VidModeExtension:DeleteModeLine +R009 XFree86-VidModeExtension:ValidateModeLine +R010 XFree86-VidModeExtension:SwitchToMode +R011 XFree86-VidModeExtension:GetViewPort +R012 XFree86-VidModeExtension:SetViewPort +R013 XFree86-VidModeExtension:GetDotClocks +R014 XFree86-VidModeExtension:SetClientVersion +R015 XFree86-VidModeExtension:SetGamma +R016 XFree86-VidModeExtension:GetGamma +R017 XFree86-VidModeExtension:GetGammaRamp +R018 XFree86-VidModeExtension:SetGammaRamp +R019 XFree86-VidModeExtension:GetGammaRampSize +R020 XFree86-VidModeExtension:GetPermissions +V000 XFree86-VidModeExtension:Notify +E000 XFree86-VidModeExtension:BadClock +E001 XFree86-VidModeExtension:BadHTimings +E002 XFree86-VidModeExtension:BadVTimings +E003 XFree86-VidModeExtension:ModeUnsuitable +E004 XFree86-VidModeExtension:ExtensionDisabled +E005 XFree86-VidModeExtension:ClientNotLocal +E006 XFree86-VidModeExtension:ZoomLocked +R000 XINERAMA:QueryVersion +R001 XINERAMA:GetState +R002 XINERAMA:GetScreenCount +R003 XINERAMA:GetScreenSize +R004 XINERAMA:IsActive +R005 XINERAMA:QueryScreens +R001 XInputExtension:GetExtensionVersion +R002 XInputExtension:ListInputDevices +R003 XInputExtension:OpenDevice +R004 XInputExtension:CloseDevice +R005 XInputExtension:SetDeviceMode +R006 XInputExtension:SelectExtensionEvent +R007 XInputExtension:GetSelectedExtensionEvents +R008 XInputExtension:ChangeDeviceDontPropagateList +R009 XInputExtension:GetDeviceDontPropagageList +R010 XInputExtension:GetDeviceMotionEvents +R011 XInputExtension:ChangeKeyboardDevice +R012 XInputExtension:ChangePointerDevice +R013 XInputExtension:GrabDevice +R014 XInputExtension:UngrabDevice +R015 XInputExtension:GrabDeviceKey +R016 XInputExtension:UngrabDeviceKey +R017 XInputExtension:GrabDeviceButton +R018 XInputExtension:UngrabDeviceButton +R019 XInputExtension:AllowDeviceEvents +R020 XInputExtension:GetDeviceFocus +R021 XInputExtension:SetDeviceFocus +R022 XInputExtension:GetFeedbackControl +R023 XInputExtension:ChangeFeedbackControl +R024 XInputExtension:GetDeviceKeyMapping +R025 XInputExtension:ChangeDeviceKeyMapping +R026 XInputExtension:GetDeviceModifierMapping +R027 XInputExtension:SetDeviceModifierMapping +R028 XInputExtension:GetDeviceButtonMapping +R029 XInputExtension:SetDeviceButtonMapping +R030 XInputExtension:QueryDeviceState +R031 XInputExtension:SendExtensionEvent +R032 XInputExtension:DeviceBell +R033 XInputExtension:SetDeviceValuators +R034 XInputExtension:GetDeviceControl +R035 XInputExtension:ChangeDeviceControl +R036 XInputExtension:ListDeviceProperties +R037 XInputExtension:ChangeDeviceProperty +R038 XInputExtension:DeleteDeviceProperty +R039 XInputExtension:GetDeviceProperty +R040 XInputExtension:QueryPointer +R041 XInputExtension:WarpPointer +R042 XInputExtension:ChangeCursor +R043 XInputExtension:ChangeHierarchy +R044 XInputExtension:SetClientPointer +R045 XInputExtension:GetClientPointer +R046 XInputExtension:SelectEvents +R047 XInputExtension:QueryVersion +R048 XInputExtension:QueryDevice +R049 XInputExtension:SetFocus +R050 XInputExtension:GetFocus +R051 XInputExtension:GrabDevice +R052 XInputExtension:UngrabDevice +R053 XInputExtension:AllowEvents +R054 XInputExtension:PassiveGrabDevice +R055 XInputExtension:PassiveUngrabDevice +R056 XInputExtension:ListProperties +R057 XInputExtension:ChangeProperty +R058 XInputExtension:DeleteProperty +R059 XInputExtension:GetProperty +R060 XInputExtension:GetSelectedEvents +V000 XInputExtension:DeviceValuator +V001 XInputExtension:DeviceKeyPress +V002 XInputExtension:DeviceKeyRelease +V003 XInputExtension:DeviceButtonPress +V004 XInputExtension:DeviceButtonRelease +V005 XInputExtension:DeviceMotionNotify +V006 XInputExtension:DeviceFocusIn +V007 XInputExtension:DeviceFocusOut +V008 XInputExtension:ProximityIn +V009 XInputExtension:ProximityOut +V010 XInputExtension:DeviceStateNotify +V011 XInputExtension:DeviceMappingNotify +V012 XInputExtension:ChangeDeviceNotify +V013 XInputExtension:DeviceKeystateNotify +V014 XInputExtension:DeviceButtonstateNotify +V015 XInputExtension:DevicePresenceNotify +V016 XInputExtension:DevicePropertyNotify +E000 XInputExtension:BadDevice +E001 XInputExtension:BadEvent +E002 XInputExtension:BadMode +E003 XInputExtension:DeviceBusy +E004 XInputExtension:BadClass +R000 XKEYBOARD:UseExtension +R001 XKEYBOARD:SelectEvents +R002 XKEYBOARD:Obsolete +R003 XKEYBOARD:Bell +R004 XKEYBOARD:GetState +R005 XKEYBOARD:LatchLockState +R006 XKEYBOARD:GetControls +R007 XKEYBOARD:SetControls +R008 XKEYBOARD:GetMap +R009 XKEYBOARD:SetMap +R010 XKEYBOARD:GetCompatMap +R011 XKEYBOARD:SetCompatMap +R012 XKEYBOARD:GetIndicatorState +R013 XKEYBOARD:GetIndicatorMap +R014 XKEYBOARD:SetIndicatorMap +R015 XKEYBOARD:GetNamedIndicator +R016 XKEYBOARD:SetNamedIndicator +R017 XKEYBOARD:GetNames +R018 XKEYBOARD:SetNames +R019 XKEYBOARD:GetGeometry +R020 XKEYBOARD:SetGeometry +R021 XKEYBOARD:PerClientFlags +R022 XKEYBOARD:ListComponents +R023 XKEYBOARD:GetKbdByName +R024 XKEYBOARD:GetDeviceInfo +R025 XKEYBOARD:SetDeviceInfo +R101 XKEYBOARD:SetDebuggingFlags +V000 XKEYBOARD:EventCode +E000 XKEYBOARD:BadKeyboard +R000 XTEST:GetVersion +R001 XTEST:CompareCursor +R002 XTEST:FakeInput +R003 XTEST:GrabControl +R000 XVideo:QueryExtension +R001 XVideo:QueryAdaptors +R002 XVideo:QueryEncodings +R003 XVideo:GrabPort +R004 XVideo:UngrabPort +R005 XVideo:PutVideo +R006 XVideo:PutStill +R007 XVideo:GetVideo +R008 XVideo:GetStill +R009 XVideo:StopVideo +R010 XVideo:SelectVideoNotify +R011 XVideo:SelectPortNotify +R012 XVideo:QueryBestSize +R013 XVideo:SetPortAttribute +R014 XVideo:GetPortAttribute +R015 XVideo:QueryPortAttributes +R016 XVideo:ListImageFormats +R017 XVideo:QueryImageAttributes +R018 XVideo:PutImage +R019 XVideo:ShmPutImage +V000 XVideo:VideoNotify +V001 XVideo:PortNotify +E000 XVideo:BadPort +E001 XVideo:BadEncoding +E002 XVideo:BadControl +R000 XVideo-MotionCompensation:QueryVersion +R001 XVideo-MotionCompensation:ListSurfaceTypes +R002 XVideo-MotionCompensation:CreateContext +R003 XVideo-MotionCompensation:DestroyContext +R004 XVideo-MotionCompensation:CreateSurface +R005 XVideo-MotionCompensation:DestroySurface +R006 XVideo-MotionCompensation:CreateSubpicture +R007 XVideo-MotionCompensation:DestroySubpicture +R008 XVideo-MotionCompensation:ListSubpictureTypes +R009 XVideo-MotionCompensation:GetDRInfo +E000 XVideo-MotionCompensation:BadContext +E001 XVideo-MotionCompensation:BadSurface +E002 XVideo-MotionCompensation:BadSubpicture diff --git a/overlay/rootfs/usr/share/X11/xorg.conf.d/10-quirks.conf b/overlay/rootfs/usr/share/X11/xorg.conf.d/10-quirks.conf new file mode 100644 index 0000000..54dd908 --- /dev/null +++ b/overlay/rootfs/usr/share/X11/xorg.conf.d/10-quirks.conf @@ -0,0 +1,48 @@ +# Collection of quirks and blacklist/whitelists for specific devices. + + +# Accelerometer device, posts data through ABS_X/ABS_Y, making X unusable +# http://bugs.freedesktop.org/show_bug.cgi?id=22442 +Section "InputClass" + Identifier "ThinkPad HDAPS accelerometer blacklist" + MatchProduct "ThinkPad HDAPS accelerometer data" + Option "Ignore" "on" +EndSection + +# https://bugzilla.redhat.com/show_bug.cgi?id=523914 +# Mouse does not move in PV Xen guest +# Explicitly tell evdev to not ignore the absolute axes. +Section "InputClass" + Identifier "Xen Virtual Pointer axis blacklist" + MatchProduct "Xen Virtual Pointer" + Option "IgnoreAbsoluteAxes" "off" + Option "IgnoreRelativeAxes" "off" +EndSection + +# https://bugs.freedesktop.org/show_bug.cgi?id=55867 +# Bug 55867 - Doesn't know how to tag XI_TRACKBALL +Section "InputClass" + Identifier "Tag trackballs as XI_TRACKBALL" + MatchProduct "trackball" + MatchDriver "evdev" + Option "TypeName" "TRACKBALL" +EndSection + +# https://bugs.freedesktop.org/show_bug.cgi?id=62831 +# Bug 62831 - Mionix Naos 5000 mouse detected incorrectly +Section "InputClass" + Identifier "Tag Mionix Naos 5000 mouse XI_MOUSE" + MatchProduct "La-VIEW Technology Naos 5000 Mouse" + MatchDriver "evdev" + Option "TypeName" "MOUSE" +EndSection + +# https://bugzilla.redhat.com/show_bug.cgi?id=2152414 +# Xorg server does not correctly select the DCP for the display without +# a quirk on Apple Silicon +Section "OutputClass" + Identifier "appledrm" + MatchDriver "apple" + Driver "modesetting" + Option "PrimaryGPU" "true" +EndSection diff --git a/overlay/rootfs/usr/share/X11/xorg.conf.d/40-libinput.conf b/overlay/rootfs/usr/share/X11/xorg.conf.d/40-libinput.conf new file mode 100644 index 0000000..eb33ad0 --- /dev/null +++ b/overlay/rootfs/usr/share/X11/xorg.conf.d/40-libinput.conf @@ -0,0 +1,52 @@ +# Match on all types of devices but joysticks +# +# If you want to configure your devices, do not copy this file. +# Instead, use a config snippet that contains something like this: +# +# Section "InputClass" +# Identifier "something or other" +# MatchDriver "libinput" +# +# MatchIsTouchpad "on" +# ... other Match directives ... +# Option "someoption" "value" +# EndSection +# +# This applies the option any libinput device also matched by the other +# directives. See the xorg.conf(5) man page for more info on +# matching devices. + +Section "InputClass" + Identifier "libinput pointer catchall" + MatchIsPointer "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput keyboard catchall" + MatchIsKeyboard "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput touchpad catchall" + MatchIsTouchpad "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput touchscreen catchall" + MatchIsTouchscreen "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput tablet catchall" + MatchIsTablet "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection diff --git a/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.impl.portal.PermissionStore.service b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.impl.portal.PermissionStore.service new file mode 100644 index 0000000..d9b3756 --- /dev/null +++ b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.impl.portal.PermissionStore.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.impl.portal.PermissionStore +Exec=/bin/true diff --git a/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service new file mode 100644 index 0000000..575b0bb --- /dev/null +++ b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.impl.portal.desktop.gtk +Exec=/bin/true diff --git a/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.portal.Desktop.service b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.portal.Desktop.service new file mode 100644 index 0000000..4a04bc5 --- /dev/null +++ b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.portal.Desktop.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.portal.Desktop +Exec=/bin/true diff --git a/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.portal.Documents.service b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.portal.Documents.service new file mode 100644 index 0000000..2c42a81 --- /dev/null +++ b/overlay/rootfs/usr/share/dbus-1/services/org.freedesktop.portal.Documents.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.portal.Documents +Exec=/bin/true diff --git a/overlay/rootfs/usr/share/polkit-1/rules.d/00-sxmo.rules b/overlay/rootfs/usr/share/polkit-1/rules.d/00-sxmo.rules new file mode 100644 index 0000000..1051798 --- /dev/null +++ b/overlay/rootfs/usr/share/polkit-1/rules.d/00-sxmo.rules @@ -0,0 +1,8 @@ +polkit.addRule(function(action, subject) { + if ((action.id.indexOf("org.freedesktop.ModemManager1.") == 0 || + action.id.indexOf("org.freedesktop.login1.") == 0 || + action.id.indexOf("org.freedesktop.NetworkManager.") == 0) && + (subject.isInGroup("plugdev") || subject.isInGroup("wheel"))) { + return polkit.Result.YES; + } +}); diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/Xresources b/overlay/rootfs/usr/share/sxmo/appcfg/Xresources new file mode 100644 index 0000000..1c20b87 --- /dev/null +++ b/overlay/rootfs/usr/share/sxmo/appcfg/Xresources @@ -0,0 +1,23 @@ +! Space to setup configversion +! configversion: 7bff124b2de16292fe6e7a7e5d3322ae + +dmenu.font: Fira Code:pixelsize=18:style=Regular:antialias=true:autohint=true +dmenu.background: #1c1c1c +dmenu.foreground: #e0e0e0 +dmenu.selbackground: #005577 +dmenu.selforeground: #ffffff + +dwm.font: Fira Code, DejaVuSansM Nerd Font 15px +dwm.normbgcolor: #323232 +dwm.normbordercolor: #444444 +dwm.normfgcolor: #dddddd +dwm.selbgcolor: #005577 +dwm.selbordercolor: #005577 +dwm.selfgcolor: #ffffff + +st.font: Fira Code:pixelsize=15:style=Regular:antialias=true:autohint=true +st.background: #1c1c1c +st.foreground: #e5e5e5 +st.cursorColor: #cccccc + +svkbd.font: Fira Code:pixelsize=12 diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/conky.conf b/overlay/rootfs/usr/share/sxmo/appcfg/conky.conf index 8c00ea7..37a7734 100644 --- a/overlay/rootfs/usr/share/sxmo/appcfg/conky.conf +++ b/overlay/rootfs/usr/share/sxmo/appcfg/conky.conf @@ -1,18 +1,24 @@ -- Space to setup configversion -- configversion: 19ec5c7f9e83bc6534d657f6180feba2 conky.config = { - out_to_x = false, - out_to_wayland = true, + output_backend = 'x11', + out_to_x = true, + out_to_wayland = false, + own_window = true, + own_window_type = 'override', + own_window_transparent = true, + own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', + double_buffer = true, alignment = 'top_middle', - gap_y = 12, - own_window_argb_value = 0, - own_window_type = 'desktop', + gap_x = 0, + gap_y = 34, + default_color = 'white', default_shade_color = 'black', draw_shades = true, - font = 'Sxmo:size=13', + font = 'Fira Code:size=14:style=Regular', use_xft = true, update_interval = 15, } -conky.text = [[${alignc}${font Sxmo:size=34:style=Bold}${time %H:%M}${font} -${alignc}${font Sxmo:size=14:style=Bold}${time %a %d %b %Y}${font}]] +conky.text = [[${alignc}${font Fira Code:size=32:style=Regular}${time %H:%M}${font} +${voffset 4}${alignc}${font Fira Code:size=14:style=Regular}${time %a %d %b %Y}${font}]] diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/dunst.conf b/overlay/rootfs/usr/share/sxmo/appcfg/dunst.conf index 2759edb..a8674fc 100644 --- a/overlay/rootfs/usr/share/sxmo/appcfg/dunst.conf +++ b/overlay/rootfs/usr/share/sxmo/appcfg/dunst.conf @@ -9,7 +9,7 @@ frame_width = 2 frame_color = "#005577" idle_threshold = 120 - font = Monospace 12 + font = Fira Code 9.5 markup = full max_icon_size = 24 dmenu = sxmo_dmenu.sh -p dunst: diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/fontconfig.conf b/overlay/rootfs/usr/share/sxmo/appcfg/fontconfig.conf new file mode 100644 index 0000000..dadd651 --- /dev/null +++ b/overlay/rootfs/usr/share/sxmo/appcfg/fontconfig.conf @@ -0,0 +1,37 @@ + + + + + + Sxmo + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + + monospace + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + + sans-serif + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + + serif + + Fira Code + DejaVu SansM Nerd Font + Dejavu Sans Mono Nerd Font + + + diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/foot.ini b/overlay/rootfs/usr/share/sxmo/appcfg/foot.ini deleted file mode 100644 index a263aad..0000000 --- a/overlay/rootfs/usr/share/sxmo/appcfg/foot.ini +++ /dev/null @@ -1,40 +0,0 @@ -# Space to setup configversion -# configversion: 13fb3d2d9f97f4420f7506e72b90e77d -font=monospace:size=13 -dpi-aware=no -pad=2x2 - -[colors-dark] -# alpha=1.0 -foreground=eaeaea -background=000000 -regular0=000000 # black -regular1=d54e53 # red -regular2=b9ca4a # green -regular3=e6c547 # yellow -regular4=7aa6da # blue -regular5=c397d8 # magenta -regular6=70c0ba # cyan -regular7=eaeaea # white -bright0=666666 # bright black -bright1=ff3334 # bright red -bright2=9ec400 # bright green -bright3=e7c547 # bright yellow -bright4=7aa6da # bright blue -bright5=b77ee0 # bright magenta -bright6=54ced6 # bright cyan -bright7=ffffff # bright white - -[scrollback] -lines=5000 - -[key-bindings] -scrollback-up-page=Shift+Page_Up -scrollback-down-page=Shift+Page_Down -scrollback-up-half-page=Page_Up -scrollback-down-half-page=Page_Down -scrollback-up-line=Shift+Up -scrollback-down-line=Shift+Down -scrollback-home=Shift+Home -scrollback-end=Shift+End - diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/profile_template b/overlay/rootfs/usr/share/sxmo/appcfg/profile_template new file mode 100755 index 0000000..ce9b5ae --- /dev/null +++ b/overlay/rootfs/usr/share/sxmo/appcfg/profile_template @@ -0,0 +1,89 @@ +#!/bin/sh +# configversion: e7cdaa3a889d251bed8a89ce8c622995 + +# shellcheck source=scripts/core/sxmo_common.sh +. sxmo_common.sh + +# Please modify this file to your liking + +# Important Instructions: +# All processes you launch from this script must +# be non-blocking: launch them in the background (using &) +# or ensure they return quickly. Only after this script +# finishes will the window manager be loaded + +# You will sometime get SMS or calls from not +# country code prefixed phone numbers. To make +# it easy to fixup configure the default countryu. +#export DEFAULT_COUNTRY=FR + +### Configuration Parameters ### + +# Note that this is just a subset of all available +# parameters, see the sxmo documentation for more. + +# Use firefox as default browser if installed +command -v firefox >/dev/null && export BROWSER=firefox + +# Prepopulate Subreddits menu with custom subreddits +#export SXMO_SUBREDDITS="postmarketos pinephoneOfficial pinephone unixporn" + +# Change the default terminal command +export TERMCMD="sxmo_terminal.sh" + +# Change the used terminal command +# export SXMO_TERMINAL="st" + +# When scrolling past the beginning or end of a menu, wrap it around: +#export DMENU_WRAP_AROUND=1 + +# Enable audio feedback on keypress +#export KEYBOARD_ARGS="-o | clickclack -f $(xdg_data_path sxmo/keytap.wav)" + +# Or, enable vibration feedback on keypress +#export KEYBOARD_ARGS="-o | clickclack -V" + +# Set the scale factor in sway +# export SXMO_SWAY_SCALE=2 + +# To load specific part of configuration depending on the running environment +case "$SXMO_WM" in + sway) + ;; + dwm) + ;; +esac + +#Set RINGTONE to audio file to play for incoming call +export SXMO_RINGTONE="$(xdg_data_path sxmo/ring.ogg)" + +#Set TEXTSOUND to audio file to play when received text message +export SXMO_TEXTSOUND="$(xdg_data_path sxmo/notify.ogg)" + +#Set RINGTIME to number of seconds the phone will ring +export SXMO_RINGTIME=20 + +#Set RINGNUMBER to number of times phone will ring or repeat ringtone +#(whichever of SXMO_RINGTIME or SXMO_RINGNUMBER runs less will limit how long phone rings) +export SXMO_RINGNUMBER=10 + +#Set to the default text for a new text message. +export SXMO_DEFAULT_DRAFT="Enter new message here." + +export PATH="$HOME/.local/bin:$PATH" +export SXMO_WM="dwm" +export SXMO_MENU="dmenu" +export SXMO_TERMINAL="st" +export DMENU_WRAP_AROUND=1 +export SXMO_DMENU_PORTRAIT_LINES=12 +export SXMO_DMENU_LANDSCAPE_LINES=8 +export SXMO_DISABLE_LEDS=1 +export SXMO_NO_VIRTUAL_KEYBOARD=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 +export GTK_IM_MODULE=fcitx +export QT_IM_MODULE=fcitx +export XMODIFIERS=@im=fcitx + +export SXMO_BG_IMG="/usr/share/wallpapers/bananarchy.png" diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/sway_template b/overlay/rootfs/usr/share/sxmo/appcfg/sway_template deleted file mode 100644 index de6396b..0000000 --- a/overlay/rootfs/usr/share/sxmo/appcfg/sway_template +++ /dev/null @@ -1,296 +0,0 @@ -# Default config for sway -# configversion: 076611fe8cc699bcaa01092a8e4481c0 -# -# Copy this to ~/.config/sway/config and edit it to your liking. -# -# Read `man 5 sway` for a complete reference. - -### Variables -# -# Logo key. Use Mod1 for Alt. -set $mod Mod4 -# Home row direction keys, like vim -set $left h -set $down j -set $up k -set $right l -# Your preferred terminal emulator -set $term sxmo_terminal.sh -# Your preferred application launcher -# Note: pass the final command to swaymsg so that the resulting window can be opened -# on the original workspace that the command was run on. -set $menu bemenu-run - -font "Sxmo 13" -xwayland disable -output * scale 1 bg /usr/share/wallpapers/bananarchy.png fill -default_orientation vertical - -exec_always sxmo_swayinitconf.sh - -exec_always dbus-update-activation-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP - -mode "menu" { - bindsym --locked XF86PowerOff exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym --locked XF86PickupPhone exec sh -c "if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; else wtype -k Return; fi" - bindsym --locked XF86KbdLcdMenu1 exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym --locked XF86KbdLcdMenu2 exec sh -c "sxmo_dmenu.sh close; if sxmo_state.sh is_locked; then sxmo_state.sh set unlock; sxmo_wm.sh display on; fi" - bindsym XF86AudioRaiseVolume exec wtype -k Up - bindsym XF86AudioLowerVolume exec wtype -k Down - bindswitch --locked lid:on exec sh -c "sxmo_dmenu.sh close; brightnessctl -d white:kbd_backlight set 0; sxmo_state.sh set screenoff" - bindswitch --locked lid:off exec sh -c "brightnessctl -d white:kbd_backlight set 255; sxmo_state.sh set unlock; sxmo_wm.sh display on" -} - -# Mode specifically for use with Nokia N900 hardware keyboard -mode "N900" { - # follow the standard sxmo keybinds as far as possible - bindsym t exec $term; mode "default" - bindsym q mode "default" - bindsym Shift+p exec sxmo_appmenu.sh sys; mode "default" - bindsym p exec sxmo_appmenu.sh; mode "default" - bindsym d exec $menu; mode "default" - bindsym Shift+q kill; mode "default" - bindsym i exec sxmo_wmmenu.sh windowswitcher; mode "default" - bindsym Shift+c reload; mode "default" - bindsym f fullscreen; mode "default" - bindsym Shift+space floating toggle; mode "default" - bindsym a focus parent; mode "default" -} - -### Key bindings -# -# Basics: -# - input * xkb_options compose:ralt - - # Nokia N900 hardware keyboard - input "1:1:TWL4030_Keypad" { - xkb_model "nokiarx51" - xkb_layout "us" - # ralt has special meaning on N900 keyboard so do not use as - # compose key - xkb_options compose:rwin - } - - # Start a terminal - bindsym $mod+Return exec $term - - # Launch appmenu - bindsym $mod+p exec sxmo_appmenu.sh - bindsym $mod+Shift+p exec sxmo_appmenu.sh sys - - # Wm menu switcher - bindsym $mod+i exec sxmo_wmmenu.sh windowswitcher - - # Kill focused window - bindsym $mod+Shift+q kill - - # Start your launcher - bindsym $mod+d exec $menu - - # Drag floating windows by holding down $mod and left mouse button. - # Resize them with right mouse button + $mod. - # Despite the name, also works for non-floating windows. - # Change normal to inverse to use left mouse button for resizing and right - # mouse button for dragging. - floating_modifier $mod normal - - # Reload the configuration file - bindsym $mod+Shift+c reload - - # Exit sway (logs you out of your Wayland session) - bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'sxmo_power.sh logout' -# -# Moving around: -# - # Move your focus around - bindsym $mod+$left focus left - bindsym $mod+$down focus down - bindsym $mod+$up focus up - bindsym $mod+$right focus right - # Or use $mod+[up|down|left|right] - bindsym $mod+Left focus left - bindsym $mod+Down focus down - bindsym $mod+Up focus up - bindsym $mod+Right focus right - - # Move the focused window with the same, but add Shift - bindsym $mod+Shift+$left move left - bindsym $mod+Shift+$down move down - bindsym $mod+Shift+$up move up - bindsym $mod+Shift+$right move right - # Ditto, with arrow keys - bindsym $mod+Shift+Left move left - bindsym $mod+Shift+Down move down - bindsym $mod+Shift+Up move up - bindsym $mod+Shift+Right move right - - # Move the focused workspace to output - bindsym $mod+Shift+Ctrl+$left move workspace output left - bindsym $mod+Shift+Ctrl+$down move workspace output down - bindsym $mod+Shift+Ctrl+$up move workspace output up - bindsym $mod+Shift+Ctrl+$right move workspace output right -# -# Workspaces: -# - # Switch to workspace - bindsym $mod+1 workspace number 1 - bindsym $mod+2 workspace number 2 - bindsym $mod+3 workspace number 3 - bindsym $mod+4 workspace number 4 - bindsym $mod+5 workspace number 5 - bindsym $mod+6 workspace number 6 - bindsym $mod+7 workspace number 7 - bindsym $mod+8 workspace number 8 - bindsym $mod+9 workspace number 9 - bindsym $mod+0 workspace number 10 - # Move focused container to workspace - bindsym $mod+Shift+1 move container to workspace number 1 - bindsym $mod+Shift+2 move container to workspace number 2 - bindsym $mod+Shift+3 move container to workspace number 3 - bindsym $mod+Shift+4 move container to workspace number 4 - bindsym $mod+Shift+5 move container to workspace number 5 - bindsym $mod+Shift+6 move container to workspace number 6 - bindsym $mod+Shift+7 move container to workspace number 7 - bindsym $mod+Shift+8 move container to workspace number 8 - bindsym $mod+Shift+9 move container to workspace number 9 - bindsym $mod+Shift+0 move container to workspace number 10 - # Note: workspaces can have any name you want, not just numbers. - # We just use 1-10 as the default. -# -# Layout stuff: -# - # You can "split" the current object of your focus with - # $mod+b or $mod+v, for horizontal and vertical splits - # respectively. - bindsym $mod+b splith - bindsym $mod+v splitv - - # Switch the current container between different layout styles - bindsym $mod+s layout stacking - bindsym $mod+w layout tabbed - bindsym $mod+e layout toggle split - - # Make the current focus fullscreen - bindsym $mod+f fullscreen - - # Toggle the current focus between tiling and floating mode - bindsym $mod+Shift+space floating toggle - - # Swap focus between the tiling area and the floating area - bindsym $mod+space focus mode_toggle - - # Move focus to the parent container - bindsym $mod+a focus parent - - # Manual locker - bindsym $mod+g exec sxmo_state.sh set locker - - # Shutdown - bindsym $mod+t exec sxmo_appmenu.sh power - -# -# Scratchpad: -# - # Sway has a "scratchpad", which is a bag of holding for windows. - # You can send windows there and get them back later. - - # Move the currently focused window to the scratchpad - bindsym $mod+Shift+minus move scratchpad - - # Show the next scratchpad window or hide the focused scratchpad window. - # If there are multiple scratchpad windows, this command cycles through them. - bindsym $mod+minus scratchpad show -# -# Resizing containers: -# -mode "resize" { - # left will shrink the containers width - # right will grow the containers width - # up will shrink the containers height - # down will grow the containers height - bindsym $left resize shrink width 30px - bindsym $down resize grow height 30px - bindsym $up resize shrink height 30px - bindsym $right resize grow width 30px - - # Ditto, with arrow keys - bindsym Left resize shrink width 30px - bindsym Down resize grow height 30px - bindsym Up resize shrink height 30px - bindsym Right resize grow width 30px - - # Return to default mode - bindsym Return mode "default" - bindsym Escape mode "default" -} -bindsym $mod+r mode "resize" - -# -# Status Bar: -# -# Read `man 5 sway-bar` for more information about this section. -bar { - position top - height 24 - font "Sxmo 13" - - # When the status_command prints a new line to stdout, swaybar updates. - # The default just shows the current date and time. - status_command sxmo_status_watch.sh -o pango - - pango_markup enabled - - colors { - statusline #ffffff - background #323232 - inactive_workspace #323232 #323232 #ffffff - font "Sxmo 13" - } -} - -for_window [app_id="pinentry-.*"] floating true -for_window [app_id="foot" title=".*sxmo/modem/.*/draft.txt.*"] resize set height 25 -for_window [title="megapixels"] inhibit_idle open -for_window [title="ep[yr].*"] inhibit_idle visible - -default_border pixel 2 -titlebar_border_thickness 2 -hide_edge_borders smart - -# Need playerctl installed and running -bindsym --locked XF86AudioPlay exec playerctl play-pause -bindsym --locked XF86AudioPause exec playerctl play-pause -bindsym --locked XF86AudioStop exec playerctl stop -bindsym --locked XF86AudioNext exec playerctl next -bindsym --locked XF86AudioPrev exec playerctl previous - -bindsym --locked XF86MonBrightnessUp exec sxmo_brightness.sh up -bindsym --locked XF86MonBrightnessDown exec sxmo_brightness.sh down - -# Nokia N900-specific key bindings: -# 1. Bind lock key (XF86ScreenSaver) -# Use keycode due to https://github.com/swaywm/sway/issues/8438 -bindcode --release --locked --input-device="1:1:gpio_keys" 160 exec sxmo_state.sh set unlock -# 2. Workaround the lack of a free ModX key on hardware keyboard -bindsym --input-device="1:1:TWL4030_Keypad" Shift+space mode "N900" - -bindsym Print exec sxmo_screenshot.sh - -bindsym button2 kill - -bindswitch --locked lid:on exec sh -c "brightnessctl -d white:kbd_backlight set 0; sxmo_state.sh set screenoff" -bindswitch --locked lid:off exec sh -c "brightnessctl -d white:kbd_backlight set 255; sxmo_state.sh set unlock; sxmo_wm.sh display on" - -# Nokia 8110 4G hardware keypad bindings (User:Ybon) -bindsym --locked --no-repeat XF86KbdLcdMenu1 exec sxmo_hook_inputhandler.sh menuleft_one -bindsym --locked --no-repeat XF86KbdLcdMenu2 exec sxmo_hook_inputhandler.sh menuright_one -bindsym --locked --no-repeat XF86PickupPhone exec sxmo_multikey.sh pickup enter_one enter_two enter_three - -include /etc/sway/config.d/* - -exec 'printf %s "$SWAYSOCK" > "$XDG_RUNTIME_DIR"/sxmo.swaysock' - -exec sxmo_hook_start.sh - -# vim: ft=swayconfig diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/wob.ini b/overlay/rootfs/usr/share/sxmo/appcfg/wob.ini deleted file mode 100644 index 144c86a..0000000 --- a/overlay/rootfs/usr/share/sxmo/appcfg/wob.ini +++ /dev/null @@ -1,6 +0,0 @@ -# Space to setup configversion -# configversion: 4de2da84af48414f557742c29bde606e -anchor = top -width = 220 -height = 28 -margin = 28 diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/wofi.css b/overlay/rootfs/usr/share/sxmo/appcfg/wofi.css deleted file mode 100644 index d0795ad..0000000 --- a/overlay/rootfs/usr/share/sxmo/appcfg/wofi.css +++ /dev/null @@ -1,51 +0,0 @@ -/* Space to setup configversion */ -/* configversion: 2ecca20b604bc0b37d13aba5a0fabc07 */ -* { - font-family: monospace; - font-size: 15px; -} - -window { - margin: 0px; - border: 2px solid #005577; - background-color: #1c1c1c; -} - -#input { - margin: 0px; - padding: 4px 6px; - border-radius: 0px; - border: 1px solid #005577; - background-color: #383838; - color: #ffffff; - font-size: 15px; - font-weight: bold; -} - -#inner-box { - margin: 0px; -} - -#outer-box { - margin: 1px; -} - -#scroll { - margin: 0px; - color: #ffdd00; -} - -#text { - margin: 1px 4px; - color: #ffffff; -} - -#entry { - padding: 3px 2px; - margin: 0px; -} - -#entry:selected { - background-color: #005577; - font-weight: bold; -} diff --git a/overlay/rootfs/usr/share/sxmo/appcfg/xinit_template b/overlay/rootfs/usr/share/sxmo/appcfg/xinit_template new file mode 100755 index 0000000..08a1ae8 --- /dev/null +++ b/overlay/rootfs/usr/share/sxmo/appcfg/xinit_template @@ -0,0 +1,7 @@ +#!/bin/sh +# configversion: 36730424afa6d6bf9e9fb6d111c35504 + +dbus-update-activation-environment DISPLAY XDG_CURRENT_DESKTOP + +# Run actions on start +sxmo_hook_start.sh & diff --git a/overlay/rootfs/usr/share/sxmo/conky.conf b/overlay/rootfs/usr/share/sxmo/conky.conf index 8c00ea7..37a7734 100644 --- a/overlay/rootfs/usr/share/sxmo/conky.conf +++ b/overlay/rootfs/usr/share/sxmo/conky.conf @@ -1,18 +1,24 @@ -- Space to setup configversion -- configversion: 19ec5c7f9e83bc6534d657f6180feba2 conky.config = { - out_to_x = false, - out_to_wayland = true, + output_backend = 'x11', + out_to_x = true, + out_to_wayland = false, + own_window = true, + own_window_type = 'override', + own_window_transparent = true, + own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', + double_buffer = true, alignment = 'top_middle', - gap_y = 12, - own_window_argb_value = 0, - own_window_type = 'desktop', + gap_x = 0, + gap_y = 34, + default_color = 'white', default_shade_color = 'black', draw_shades = true, - font = 'Sxmo:size=13', + font = 'Fira Code:size=14:style=Regular', use_xft = true, update_interval = 15, } -conky.text = [[${alignc}${font Sxmo:size=34:style=Bold}${time %H:%M}${font} -${alignc}${font Sxmo:size=14:style=Bold}${time %a %d %b %Y}${font}]] +conky.text = [[${alignc}${font Fira Code:size=32:style=Regular}${time %H:%M}${font} +${voffset 4}${alignc}${font Fira Code:size=14:style=Regular}${time %a %d %b %Y}${font}]] diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_apps.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_apps.sh index 2ff9555..1c7642c 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_apps.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_apps.sh @@ -8,6 +8,15 @@ # shellcheck source=configs/default_hooks/sxmo_hook_icons.sh . sxmo_hook_icons.sh +APPS_CACHE="${XDG_RUNTIME_DIR:-/tmp}/sxmo_apps.cache" +if [ -f "$APPS_CACHE" ] && [ ! "$0" -nt "$APPS_CACHE" ] && [ ! /usr/bin -nt "$APPS_CACHE" ] && [ ! /usr/local/bin -nt "$APPS_CACHE" ]; then + cat "$APPS_CACHE" + exit 0 +fi + +exec 3>&1 > "$APPS_CACHE.tmp" +trap 'mv -f "$APPS_CACHE.tmp" "$APPS_CACHE" 2>/dev/null; cat "$APPS_CACHE" >&3 2>/dev/null' EXIT + write_line() { printf "%s ^ 0 ^ %s\n" "$1" "$2" } @@ -69,8 +78,6 @@ write_line_app firefox-esr "$icon_ffx Firefox ESR" "firefox-esr" write_line_app flare "$icon_msg Flare" "flare" write_line_app flowtime "$icon_hrg Flowtime" "flowtime" write_line_app foliate "$icon_bok Foliate" "foliate" -( [ -n "$WAYLAND_DISPLAY" ] && command -v foot >/dev/null) && \ - write_line "$icon_trm Foot" "foot $SHELL" write_line_app foxtrotgps "$icon_gps Foxtrotgps" "foxtrotgps" write_line_app fractal "$icon_msg Fractal" "fractal" write_line_app fragments "$icon_rld Fragments" "fragments" @@ -195,8 +202,7 @@ write_line_app siglo "$icon_clk Siglo" "siglo" write_line_app simple-scan "$icon_scn Simple Scan" "simple-scan" write_line_app snapshot "$icon_cam Snapshot" "snapshot" write_line_app solanum "$icon_pom Solanum" "solanum" -([ -z "$WAYLAND_DISPLAY" ] && command -v st >/dev/null) && \ - write_line "$icon_trm St" "st -e $SHELL" +write_line_app st "$icon_trm St" "st -e ${SHELL:-/bin/sh}" write_line_app supertuxkart "$icon_krt SuperTuxKart" "supertuxkart" write_line_app surf "$icon_glb Surf" "surf" write_line_app syncthing "$icon_rld Syncthing" "syncthing" diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_battery.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_battery.sh index a799d3c..308f188 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_battery.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_battery.sh @@ -1,30 +1,64 @@ #!/bin/sh # configversion: d031535bc22ba19d69704317b8d50560 -load_data() { - data="$(upower -i "$1" | grep . | sed -e 's|^ \+||' -e 's|: \+|:|')" - type="$(printf "%b" "$data" | grep -m1 -v : | sed -e 's|^ \+||')" -} - -data_get() { - printf "%b" "$data" | grep "^$1:" | cut -d: -f2 -} - SET_LED_PATH="$XDG_RUNTIME_DIR/sxmo_hook_battery_set_led" -device_changed() { - name="$(data_get "native-path")" - state="$(data_get "state")" - percentage="$(data_get "percentage" | cut -d% -f1)" +object="${1:-/org/freedesktop/UPower/devices/battery_default}" +event="${2:-device changed}" - if [ -z "$name" ] || [ -z "$state" ]; then - return - fi +case "$event" in + "device changed") ;; + *) exit 0 ;; +esac - if [ "$state" = unknown ]; then - return - fi +case "$object" in + */battery_*) + raw_name="${object##*/battery_}" + ;; + *) + exit 0 + ;; +esac +sysfs_dir="" +if [ -d "/sys/class/power_supply/$raw_name" ]; then + sysfs_dir="/sys/class/power_supply/$raw_name" + name="$raw_name" +else + for d in /sys/class/power_supply/*; do + [ -r "$d/type" ] || continue + read -r pstype < "$d/type" 2>/dev/null || continue + if [ "$pstype" = "Battery" ]; then + sysfs_dir="$d" + name="${d##*/}" + break + fi + done +fi + +if [ -n "$sysfs_dir" ] && [ -r "$sysfs_dir/capacity" ] && [ -r "$sysfs_dir/status" ]; then + read -r percentage < "$sysfs_dir/capacity" 2>/dev/null || percentage="" + read -r raw_status < "$sysfs_dir/status" 2>/dev/null || raw_status="" + case "$raw_status" in + "Full"|"full") state="fully-charged" ;; + "Charging"|"charging") state="charging" ;; + "Discharging"|"discharging"|"Not charging"|"not charging") state="discharging" ;; + *) state="unknown" ;; + esac +else + data="$(upower -i "$object" | grep . | sed -e 's|^ \+||' -e 's|: \+|:|')" + type="$(printf "%b" "$data" | grep -m1 -v : | sed -e 's|^ \+||')" + [ "$type" = "battery" ] || exit 0 + name="$(printf "%b" "$data" | grep "^native-path:" | cut -d: -f2)" + state="$(printf "%b" "$data" | grep "^state:" | cut -d: -f2)" + percentage="$(printf "%b" "$data" | grep "^percentage:" | cut -d: -f2 | cut -d% -f1)" +fi + +if [ -z "$name" ] || [ -z "$state" ] || [ -z "$percentage" ] || [ "$state" = "unknown" ]; then + exit 0 +fi + +if [ -z "$SXMO_DISABLE_LEDS" ]; then if [ "$percentage" -lt 25 ] && [ ! -f "$SET_LED_PATH" ]; then touch "$SET_LED_PATH" sxmo_led.sh set red 100 @@ -32,21 +66,17 @@ device_changed() { rm "$SET_LED_PATH" sxmo_led.sh set red 0 fi - - sxmo_hook_statusbar.sh battery "$name" "$state" "$percentage" -} - -object="$1" -event="$2" - -load_data "$object" - -if [ "$type" != "battery" ]; then - exit fi -case "$event" in - "device changed") - device_changed "$object" - ;; -esac +CACHE_FILE="${XDG_RUNTIME_DIR:-/tmp}/sxmo_bat_state_${name}" +ICON_FILE="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status/${SXMO_STATUS_NAME:-default}/040-battery-icon-${name}" +NEW_VAL="${state}:${percentage}" +if [ -r "$CACHE_FILE" ] && [ -f "$ICON_FILE" ]; then + read -r OLD_VAL < "$CACHE_FILE" 2>/dev/null || OLD_VAL="" + if [ "$OLD_VAL" = "$NEW_VAL" ]; then + exit 0 + fi +fi +printf '%s\n' "$NEW_VAL" > "$CACHE_FILE" + +sxmo_hook_statusbar.sh battery "$name" "$state" "$percentage" diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_contextmenu.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_contextmenu.sh index cc2a635..0be8b43 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_contextmenu.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_contextmenu.sh @@ -23,6 +23,20 @@ sxmo_service_isrunning() { sxmo_jobs.sh running "$1" -q } +bt_is_unblocked() { + for rfk in /sys/class/rfkill/rfkill*; do + [ -r "$rfk/type" ] || continue + read -r rtype < "$rfk/type" 2>/dev/null || continue + if [ "$rtype" = "bluetooth" ]; then + read -r soft < "$rfk/soft" 2>/dev/null || soft=0 + read -r hard < "$rfk/hard" 2>/dev/null || hard=0 + [ "$soft" = "0" ] && [ "$hard" = "0" ] && return 0 + return 1 + fi + done + rfkill list bluetooth -no ID,SOFT,HARD 2>/dev/null | grep -vq " blocked" +} + case "$WMCLASS" in scripts) # Scripts menu @@ -43,11 +57,8 @@ case "$WMCLASS" in printf %b "$icon_ton ^ 1 ^ superctl stop sxmo_modemmonitor" || printf %b "$icon_tof ^ 1 ^ superctl start sxmo_modemmonitor" ) && sxmo_hook_statusbar.sh modem - $icon_wrh Restart System Daemons ^ 1 ^ sxmo_hook_restart_modem_daemons.sh && sxmo_hook_statusbar.sh modem $icon_inf Modem Info ^ 0 ^ sxmo_modeminfo.sh $icon_phl Modem Log ^ 0 ^ sxmo_modemlog.sh - $icon_img Config MMS ^ 1 ^ sxmo_mmsdconfig.sh - $icon_img Config VVM ^ 1 ^ sxmo_vvmdconfig.sh " WINNAME=Modem ;; @@ -56,27 +67,12 @@ case "$WMCLASS" in CHOICES=" $icon_aru Brightness ^ 1 ^ sxmo_brightness.sh up $icon_ard Brightness ^ 1 ^ sxmo_brightness.sh down - $icon_cfg Touch $( - sxmo_wm.sh inputevent touchscreen | grep -q on && \ - printf %b "$icon_ton ^ 1 ^ sxmo_wm.sh inputevent touchscreen off" || \ - printf %b "$icon_tof ^ 1 ^ sxmo_wm.sh inputevent touchscreen on" - ) - $icon_cfg Stylus $( - sxmo_wm.sh inputevent stylus | grep -q on && \ - printf %b "$icon_ton ^ 1 ^ sxmo_wm.sh inputevent stylus off" || \ - printf %b "$icon_tof ^ 1 ^ sxmo_wm.sh inputevent stylus on" - ) - $icon_cfg Gestures $( - superd_service_isrunning "sxmo_hook_lisgd" && - printf "%s" "$icon_ton" || printf "%s" "$icon_tof" - ) ^ 1 ^ supertoggle_daemon 'sxmo_hook_lisgd' && (rm $XDG_CACHE_HOME/sxmo/sxmo.nogesture 2>/dev/null || touch $XDG_CACHE_HOME/sxmo/sxmo.nogesture) $icon_cfg Toggle Bar ^ 0 ^ sxmo_wm.sh togglebar $icon_bth Bluetooth $( - rfkill list bluetooth -no ID,SOFT,HARD | grep -vq " blocked" && + bt_is_unblocked && printf %b "$icon_ton" || printf %b "$icon_tof"; printf %b "^ 1 ^ doas sxmo_bluetoothtoggle.sh && sxmo_hook_statusbar.sh bluetooth" ) - $(test "$SXMO_WM" = dwm && printf %b "$icon_cfg Invert Colors ^ 1 ^ xcalib -a -invert") $icon_clk Change Timezone ^ 1 ^ sxmo_timezonechange.sh $icon_zzz Auto-suspend $( [ -e "$XDG_CACHE_HOME"/sxmo/sxmo.nosuspend ] && printf "%s" "$icon_tof" || printf "%s" "$icon_ton" @@ -84,24 +80,7 @@ case "$WMCLASS" in $icon_zzz Auto-screen-off $( [ -e "$XDG_CACHE_HOME/sxmo/sxmo.noidle" ] && printf "%s" "$icon_tof" || printf "%s" "$icon_ton" ) ^ 1 ^ (rm $XDG_CACHE_HOME/sxmo/sxmo.noidle 2>/dev/null || touch $XDG_CACHE_HOME/sxmo/sxmo.noidle) && sxmo_state.sh set unlock - $icon_ror Autorotate $( - sxmo_jobs.sh running autorotate -q && - printf "%s" "$icon_ton" || printf "%s" "$icon_tof" - ) ^ 1 ^ toggle_daemon 'Autorotate' autorotate sxmo_autorotate.sh - $([ -n "$SXMO_KEYBOARD_SLIDER_EVENT_DEVICE" ] && echo "$icon_ror Autorotate on Keyboard Open/Close $( - sxmo_jobs.sh running kb_autorotate -q && - printf "%s" "$icon_ton" || printf "%s" "$icon_tof" - ) ^ 1 ^ toggle_daemon 'Keyboard Autorotate' kb_autorotate sxmo_keyboard_autorotate.sh") - $icon_ror Rotate ^ 1 ^ sxmo_rotate.sh rotate - $icon_brightness Adaptive Brightness $( - superd_service_isrunning sxmo_adaptivebrightness && - printf "%s" "$icon_ton" || printf "%s" "$icon_tof" - ) ^ 1 ^ supertoggle_daemon sxmo_adaptivebrightness $icon_trm Hooks ^ 0 ^ sxmo_hookmenu.sh - $icon_upc Upgrade Pkgs ^ 0 ^ sxmo_terminal.sh sxmo_upgrade.sh - $icon_sfl Migrate configuration ^ 0 ^ sxmo_terminal.sh sxmo_migrate.sh - $(sxmo_wm.sh configmenuentry) - $(command -v pmos-tweaks >/dev/null && echo "$icon_cfg PostmarketOS Tweaks ^ 0 ^ GDK_SCALE=1 pmos-tweaks") $icon_cfg Suspend Blockers ^ 0 ^ sxmo_terminal.sh sxmo_debug_suspend.sh $icon_inf Log ^ 0 ^ sxmo_terminal.sh tail -n 100 -f ${XDG_STATE_HOME:-$HOME}/sxmo.log $icon_inf Version ^ 0 ^ sxmo_terminal.sh sxmo_version.sh --block @@ -114,7 +93,6 @@ case "$WMCLASS" in $icon_lck Lock ^ 0 ^ sxmo_state.sh set lock $icon_lck Lock (Screen off) ^ 0 ^ sxmo_state.sh set screenoff $icon_out Logout ^ 0 ^ confirm Logout && sxmo_power.sh logout - $icon_rol Switch WM ^ 0 ^ sxmo_power.sh togglewm $icon_rld Reboot ^ 0 ^ confirm Reboot && sxmo_power.sh reboot $icon_pwr Poweroff ^ 0 ^ confirm Poweroff && sxmo_power.sh poweroff " @@ -213,7 +191,7 @@ case "$WMCLASS" in " WINNAME=St ;; - *foot*|st|st-*|*terminal*|org.gnome.vte.application|org.gnome.vte.app.gtk4|*alacritty*) + st|st-*|*terminal*|org.gnome.vte.application|org.gnome.vte.app.gtk4|*alacritty*) # These git commands only launch the editor. case "$WMNAME" in @@ -458,6 +436,8 @@ case "$WMCLASS" in case "$WMCLASS" in st|st-*) CHOICES=" + $icon_trm New Terminal ^ 0 ^ sxmo_terminal.sh + $icon_cls Close Terminal ^ 0 ^ sxmo_killwindow.sh $icon_itm Type complete ^ 0 ^ sxmo_type -M Ctrl -M Shift -k u $icon_itm Toggle Selmode ^ 0 ^ sxmo_type -M Ctrl -M Shift -k s $icon_cpy Copy complete ^ 0 ^ sxmo_type -M Ctrl -M Shift -k i @@ -472,29 +452,6 @@ case "$WMCLASS" in " WINNAME=St ;; - *foot*) - CHOICES=" - $icon_win Next Window ^ 0 ^ swaymsg focus next - $icon_rld Toggle Layout ^ 0 ^ sxmo_wm.sh togglelayout - $icon_mnu Tile Vertical ^ 0 ^ swaymsg layout splitv && swaymsg splitv - $icon_grd Tile Horizontal ^ 0 ^ swaymsg layout splith && swaymsg splith - $icon_trm New Terminal ^ 0 ^ sxmo_terminal.sh - $icon_cls Close Terminal ^ 0 ^ sxmo_killwindow.sh - $icon_cpy Copy ^ 0 ^ sxmo_type -M Shift -M Ctrl c - $icon_pst Paste ^ 0 ^ sxmo_type -M Shift -M Ctrl v - $icon_zmi Zoom in ^ 1 ^ sxmo_type -M Ctrl + - $icon_zmo Zoom out ^ 1 ^ sxmo_type -M Ctrl -k Minus - $icon_aru Scroll up ^ 1 ^ sxmo_type -M Shift -k Prior - $icon_ard Scroll down ^ 1 ^ sxmo_type -M Shift -k Next - $icon_lnk URL Mode ^ 0 ^ sxmo_type -M Shift -M Ctrl -k u - $icon_kbd Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys - $icon_fnd Search Field ^ 0 ^ sxmo_type -M Ctrl -M Shift -k r - $icon_aru Search Back ^ 0 ^ sxmo_type -M Ctrl -k r - $icon_ard Search Forward ^ 0 ^ sxmo_type -M Ctrl -k s - $icon_itm Search Extend ^ 0 ^ sxmo_type -M Ctrl -k w - " - WINNAME=Foot - ;; *terminal*|org.gnome.vte.application|org.gnome.vte.app.gtk4) CHOICES="$icon_kbd Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys" WINNAME=Terminal @@ -806,30 +763,28 @@ case "$WMCLASS" in *) # Default system menu (no matches) CHOICES=" - $icon_grd Scripts ^ 0 ^ sxmo_appmenu.sh scripts + $icon_trm St ^ 0 ^ st -e ${SHELL:-/bin/sh} $icon_grd Apps ^ 0 ^ sxmo_appmenu.sh applications - $([ "$SXMO_MENU" = "wofi" ] && echo "$icon_grd All Apps ^ 0 ^ wofi -O alphabetical -i --show drun") - $([ "$SXMO_MENU" != "wofi" ] && command -v j4-dmenu-desktop > /dev/null && echo "$icon_grd All Apps ^ 0 ^ j4-dmenu-desktop --dmenu=sxmo_dmenu.sh --term=sxmo_terminal.sh") - $icon_grd Binaries ^ 0 ^ sxmo_brun.sh + $icon_grd Scripts ^ 0 ^ sxmo_appmenu.sh scripts $icon_dir Files ^ 0 ^ sxmo_files.sh $icon_phn Dialer ^ 0 ^ sxmo_modemdial.sh $icon_msg Texts ^ 0 ^ sxmo_modemtext.sh $icon_usr Contacts ^ 0 ^ sxmo_contactmenu.sh $( - rfkill list bluetooth -no ID,SOFT,HARD | grep -vq " blocked" && + bt_is_unblocked && printf %b "$icon_bth Bluetooth ^ 1 ^ sxmo_bluetoothmenu.sh" ) + $icon_cam Camera ^ 0 ^ bananarchy-photo --menu $( - if command -v bananarchy-photo >/dev/null; then - echo "$icon_cam Camera ^ 0 ^ bananarchy-photo --menu" - elif command -v megapixels >/dev/null; then - echo "$icon_cam Camera ^ 0 ^ GDK_SCALE=2 megapixels" + brightness="" + if [ -r /sys/class/leds/white:torch/brightness ]; then + read -r brightness < /sys/class/leds/white:torch/brightness 2>/dev/null || brightness="" + elif [ -r /sys/class/leds/white:flash/brightness ]; then + read -r brightness < /sys/class/leds/white:flash/brightness 2>/dev/null || brightness="" fi - ) - $( - if brightness="$(brightnessctl -l -m | grep -e "white:torch" -e "white:flash" | cut -d ',' -f 3)" && [ -n "$brightness" ]; then + if [ -n "$brightness" ]; then printf "%s Flashlight " "$icon_fll" - [ "$brightness" -gt 0 ] && + [ "$brightness" -gt 0 ] 2>/dev/null && printf %b "$icon_ton" || printf %b "$icon_tof"; printf %b "^ 1 ^ sxmo_flashtoggle.sh" fi @@ -839,7 +794,6 @@ case "$WMCLASS" in $icon_phn Modem ^ 0 ^ sxmo_appmenu.sh modem $icon_win Windows ^ 0 ^ sxmo_wmmenu.sh $icon_cfg Config ^ 0 ^ sxmo_appmenu.sh config - $icon_inf Help ^ 0 ^ sxmo_terminal.sh man sxmo $icon_pwr Power ^ 0 ^ sxmo_appmenu.sh power " WINNAME=Sys diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_icons.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_icons.sh index f3a258c..af4aacc 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_icons.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_icons.sh @@ -7,6 +7,9 @@ # for all the variables we define here # shellcheck disable=SC2034 +[ -n "$SXMO_ICONS_LOADED" ] && return 0 2>/dev/null +SXMO_ICONS_LOADED=1 + #this script is meant to be sourced #the glyphs are often in the private use area and #therefore require a font like those in https://github.com/ryanoasis/nerd-fonts/ for proper display diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_inputhandler.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_inputhandler.sh index ed3f8d4..8246223 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_inputhandler.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_inputhandler.sh @@ -17,38 +17,51 @@ stop_proximity_lock() { sxmo_jobs.sh stop proximity_lock } -exec 0</dev/null 2>&1 || sxmo_wm.sh display on + else + sxmo_wm.sh display on + fi + if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '255' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true + else + brightnessctl -d white:kbd_backlight set 255 >/dev/null 2>&1 || true + fi + sxmo_state.sh set unlock & + exit 0 + ;; + "voldown_one"|"volup_one") + exec 0</dev/null 2>&1 || true - sxmo_state.sh set unlock - sxmo_wm.sh display on - ;; - "voldown_one") - sxmo_audio.sh vol down 5 - exit + if [ "$ACTION" = "voldown_one" ]; then + sxmo_audio.sh vol down 5 + else + sxmo_audio.sh vol up 5 + fi + exit 0 ;; "voldown_two") sxmo_audio.sh vol down 10 @@ -58,10 +71,6 @@ if sxmo_state.sh is_locked; then sxmo_audio.sh vol down 15 exit ;; - "volup_one") - sxmo_audio.sh vol up 5 - exit - ;; "volup_two") sxmo_audio.sh vol up 10 exit @@ -75,6 +84,31 @@ if sxmo_state.sh is_locked; then exit 0 fi +case "$ACTION" in + "menuleft"*|"enter_two"|"enter_three"|"powerbutton_two"|"powerbutton_three"|"voldown_two"|"volup_two"|"volup_three"|"topleftcorner"|"toprightcorner"|"bottomrightcorner") + WMCLASS="" + WMNAME="" + ;; + *) + if [ -r "$XDG_RUNTIME_DIR/sxmo.focusedwin" ]; then + { + read -r WMCLASS || WMCLASS="" + read -r WMNAME || WMNAME="" + } < "$XDG_RUNTIME_DIR/sxmo.focusedwin" + else + exec 0</dev/null; then sxmo_hook_pickup.sh else sxmo_appmenu.sh "$WMCLASS" "$WMNAME" diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_lock.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_lock.sh index 83e80ab..93650e7 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_lock.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_lock.sh @@ -17,13 +17,19 @@ # This hook is called when the system reaches a locked state -sxmo_led.sh blink blue & +if [ -z "$SXMO_DISABLE_LEDS" ]; then + sxmo_led.sh blink blue & +fi [ "$SXMO_WM" = "sway" ] && swaymsg mode default sxmo_wm.sh display on -sxmo_wm.sh inputevent touchscreen off +if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then + sxmo_wm.sh inputevent touchscreen off +fi -sxmo_jobs.sh stop periodic_blink +if [ -z "$SXMO_DISABLE_LEDS" ]; then + sxmo_jobs.sh stop periodic_blink +fi sxmo_jobs.sh stop periodic_wakelock_check # Go down after 8 seconds of inactivity diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_screenoff.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_screenoff.sh index 52e8fad..e2ccf1e 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_screenoff.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_screenoff.sh @@ -17,13 +17,20 @@ # This hook is called when the system reaches a off state (screen off) -sxmo_led.sh blink red blue & +if [ -z "$SXMO_DISABLE_LEDS" ]; then + sxmo_led.sh blink red blue & +fi [ "$SXMO_WM" = "sway" ] && swaymsg mode default +if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '0' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true +fi sxmo_wm.sh display off -sxmo_wm.sh inputevent touchscreen off +if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then + sxmo_wm.sh inputevent touchscreen off +fi -if [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nosuspend ]; then +if [ -z "$SXMO_DISABLE_LEDS" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nosuspend ]; then sxmo_jobs.sh start periodic_blink \ sxmo_run_periodically.sh -w 2 -- sxmo_led.sh blink red blue fi @@ -44,7 +51,7 @@ wait case "$SXMO_WM" in sway) - if command -v peanutbutter > /dev/null; then + if [ -n "$SXMO_HAS_PEANUTBUTTER" ] && command -v peanutbutter > /dev/null; then peanutbutter --font Sxmo --statuscommand sxmo_hook_lockstatusbar.sh && sxmo_hook_statusbar.sh state_change & fi ;; diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_scripts.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_scripts.sh index ba45f8f..acf2219 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_scripts.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_scripts.sh @@ -11,18 +11,38 @@ # shellcheck source=configs/default_hooks/sxmo_hook_icons.sh . sxmo_hook_icons.sh +SCRIPTS_CACHE="${XDG_RUNTIME_DIR:-/tmp}/sxmo_scripts.cache" +APPSCRIPTS_DIR="$(xdg_data_path sxmo/appscripts)" +if [ -f "$SCRIPTS_CACHE" ] && [ ! "$0" -nt "$SCRIPTS_CACHE" ] && \ + [ ! "$APPSCRIPTS_DIR" -nt "$SCRIPTS_CACHE" ] && \ + { [ ! -e "$XDG_CONFIG_HOME/sxmo/userscripts" ] || [ ! "$XDG_CONFIG_HOME/sxmo/userscripts" -nt "$SCRIPTS_CACHE" ]; }; then + cat "$SCRIPTS_CACHE" + exit 0 +fi + +exec 3>&1 > "$SCRIPTS_CACHE.tmp" +trap 'mv -f "$SCRIPTS_CACHE.tmp" "$SCRIPTS_CACHE" 2>/dev/null; cat "$SCRIPTS_CACHE" >&3 2>/dev/null' EXIT + write_line() { printf "%s ^ 0 ^ %s\n" "$1" "$2" } get_title() { title="" - eval "$(head "$1" | grep '# title="[^\\"]*"' | sed 's/^# //g')" + while IFS= read -r line; do + case "$line" in + "# title=\""*"\"") + title="${line#*# title=\"}" + title="${title%\"*}" + title="$(eval "printf '%s' \"$title\"" 2>/dev/null || printf '%s' "$title")" + break + ;; + esac + done < "$1" if [ -n "$title" ]; then - echo "$title" + printf "%s\n" "$title" else - basename="$(basename "$1")" - echo "$icon_itm $basename" + printf "%s %s\n" "$icon_itm" "${1##*/}" fi } @@ -33,12 +53,18 @@ elif [ -d "$XDG_CONFIG_HOME/sxmo/userscripts" ]; then title="$(get_title "$script")" write_line "$title" "$script" done + write_line "$icon_cfg Edit Userscripts" "sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/userscripts/*" fi -write_line "$icon_cfg Edit Userscripts" "sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/userscripts/*" - # System Scripts -find "$(xdg_data_path sxmo/appscripts)" -type f -o -type l | sort -f | while read -r script; do - title="$(get_title "$script")" - write_line "$title" "$script" -done +if [ -n "$APPSCRIPTS_DIR" ]; then + find "$APPSCRIPTS_DIR" -type f -o -type l | sort -f | while read -r script; do + case "${script##*/}" in + sxmo_record.sh|sxmo_screenshot.sh|sxmo_websearch.sh|sxmo_youtube*.sh) + continue + ;; + esac + title="$(get_title "$script")" + write_line "$title" "$script" + done +fi diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh index 80f1f22..05c9c36 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh @@ -10,13 +10,18 @@ . sxmo_common.sh # Create xdg user directories, such as ~/Pictures -xdg-user-dirs-update +[ -d "$HOME/Pictures" ] || xdg-user-dirs-update & + +# Ensure fontconfig cache is valid without forcing a full rescan on every boot +if command -v fc-cache > /dev/null && [ -z "$(ls -A /var/cache/fontconfig 2>/dev/null)" ]; then + fc-cache >/dev/null 2>&1 & +fi sxmo_jobs.sh start daemon_manager superd # let time to superd to start correctly while ! superctl status > /dev/null 2>&1; do - sleep 0.5 + sleep 0.05 done # Not dangerous if "locker" isn't an available state @@ -54,48 +59,14 @@ superctl start dunst # start adaptive brightness at boot # superctl start sxmo_adaptivebrightness -# load some other little things here too. -case "$SXMO_WM" in - river) - superctl start sxmo_wob - [ "$(command -v bonsaid)" ] && superctl start bonsaid - [ "$(command -v fcitx5)" ] && superctl start fcitx5 - superctl start sxmo_riverbar - ;; - sway) - superctl start sxmo_wob - superctl start sxmo_menumode_toggler - [ "$(command -v bonsaid)" ] && superctl start bonsaid - [ "$(command -v fcitx5)" ] && superctl start fcitx5 - ;; - dwm|i3) - superctl start sxmo_xob - - # Auto hide cursor with touchscreen, Show it with a mouse - if command -v "unclutter-xfixes" > /dev/null; then - set -- unclutter-xfixes - else - set -- unclutter - fi - superctl start "$1" - - superctl start autocutsel - superctl start autocutsel-primary - superctl start sxmo-x11-status - [ "$(command -v bonsaid)" ] && superctl start bonsaid - [ "$(command -v fcitx5)" ] && superctl start fcitx5 - [ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary - # Set onboard to auto-hide in config first - if [ "$KEYBOARD" = "onboard" ]; then - onboard "$KEYBOARD_ARGS" - fi - case "$SXMO_WM" in - i3) - xbindkeys -f "$XDG_CONFIG_HOME/sxmo/xbindkeysrc_$SXMO_BINDING_PROVIDER" - ;; - esac - ;; -esac +# load X11 dwm services +[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob +pidof -s sxmo_status_xsetroot.sh >/dev/null 2>&1 || superctl start sxmo-x11-status +[ "$(command -v bonsaid)" ] && superctl start bonsaid +if ! pidof -s fcitx5 >/dev/null 2>&1 && [ "$(command -v fcitx5)" ]; then + superctl start fcitx5 +fi +[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary # Turn on auto-suspend if sxmo_wakelock.sh isenabled; then @@ -106,8 +77,8 @@ fi # To setup initial unlock state sxmo_state.sh set unlock -# Turn on lisgd -if [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then +# Turn on lisgd only on touch devices +if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then superctl start sxmo_hook_lisgd fi @@ -120,11 +91,8 @@ if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then sxmo_wakelock.sh lock sxmo_modem_warming_up 120s fi -# Start the desktop wallpaper -superctl start sxmo_bg - # Start the desktop widget (e.g. clock) -superctl start sxmo_conky +pidof -s conky >/dev/null 2>&1 || superctl start sxmo_conky # Monitor the battery superctl start sxmo_battery_monitor @@ -135,25 +103,8 @@ superctl start sxmo_networkmonitor # The daemon that display notifications popup messages superctl start sxmo_notificationmonitor -# Play a funky startup tune if you want (disabled by default) -#mpv --quiet --no-video ~/welcome.ogg & - -# mmsd and vvmd -if [ -z "$SXMO_NO_MODEM" ]; then - if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then - superctl start mmsd-tng - fi - - if [ -f "${SXMO_VVM_BASE_DIR:-"$HOME"/.vvm/modemmanager}/vvm" ]; then - superctl start vvmd - fi -fi - -# add some warnings if things are not setup correctly -if ! command -v "sxmo_deviceprofile_$SXMO_DEVICE_NAME.sh"; then - sxmo_notify_user.sh --urgency=critical \ - "No deviceprofile found $SXMO_DEVICE_NAME. See: https://sxmo.org/deviceprofile" -fi - -sxmo_migrate.sh state || sxmo_notify_user.sh --urgency=critical \ - "Config needs migration" "$? file(s) in your sxmo configuration are out of date and disabled - using defaults until you migrate (run sxmo_migrate.sh)" +# Pre-warm app and script menu caches in background +( + sxmo_hook_apps.sh >/dev/null 2>&1 || true + sxmo_hook_scripts.sh >/dev/null 2>&1 || true +) & diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh index f16a80e..fcbcdcc 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh @@ -18,14 +18,7 @@ # right and "variable" icons (that come and go) on the left. set_time() { - if pidof peanutbutter > /dev/null; then - #peanutbutter already features a clock, no need for one in the icon bar - sxmobar -d time - else - date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}" | while read -r date; do - sxmobar -a time 99 "$date" - done - fi + sxmobar -a time 99 " $(date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}")" } set_state() { @@ -38,13 +31,8 @@ set_state() { return fi - if command -v peanutbutter > /dev/null; then - # no need for a state icon in this (default) scenario, the state will be obvious, either peanutbutter is on or it isn't - sxmobar -d state - return - fi - - case "$(sxmo_state.sh get)" in + read -r cur_state < "$SXMO_STATE" 2>/dev/null || cur_state="" + case "$cur_state" in screenoff) sxmobar -a -e bold -f red state 90 "$icon_state_screenoff" # filled circle ;; @@ -52,7 +40,7 @@ set_state() { sxmobar -a -e bold -f red state 90 "$icon_state_lock" # open circle with slash ;; unlock) - sxmobar -a -e bold state 90 "$icon_state_unlock" # open circle + sxmobar -d state ;; esac } @@ -211,7 +199,7 @@ set_modem() { # $2 = interface name (wlan0, tun0) set_wifi() { - if rfkill list wifi | grep -q "yes"; then + if /usr/sbin/rfkill list wifi 2>/dev/null | grep -q "yes"; then sxmobar -d wifi-status return fi @@ -238,7 +226,7 @@ set_wifi() { wifivpn=0 fi - wifi_signal="$(nmcli -f IN-USE,SIGNAL,SSID device wifi | awk '/^\*/{if (NR!=1) {print $2}}')" + wifi_signal="$(nmcli -f IN-USE,SIGNAL,SSID device wifi list --rescan no 2>/dev/null | awk '/^\*/{if (NR!=1) {print $2}}')" if [ -z "$wifi_signal" ]; then icon_wif="$icon_wifi_signal_exclam" elif [ "$wifi_signal" -lt 20 ]; then @@ -406,33 +394,33 @@ set_volume() { *Headset*) VOLCMP="$icon_hst" ;; - *) - VOLCMP="$icon_mic" - ;; esac fi if sxmo_audio.sh vol ismuted; then - VOLCMP="$VOLCMP $icon_mut" + VOLCMP="${VOLCMP:+$VOLCMP }$icon_mut" else case "$(sxmo_audio.sh device get 2>/dev/null)" in *Speaker*|"") # nothing for default or pulse devices ;; *Headphone*) - VOLCMP="$VOLCMP $icon_hdp" + VOLCMP="${VOLCMP:+$VOLCMP }$icon_hdp" ;; *Earpiece*) - VOLCMP="$VOLCMP $icon_ear" + VOLCMP="${VOLCMP:+$VOLCMP }$icon_ear" ;; esac - VOL="$(sxmo_audio.sh vol get)" + VOL="$(sxmo_audio.sh vol get 2>/dev/null)" + case "$VOL" in + ''|*[!0-9]*) VOL=0 ;; + esac if [ "$VOL" -gt 66 ]; then - VOLCMP="$VOLCMP $icon_spk" + VOLCMP="${VOLCMP:+$VOLCMP }$icon_spk" elif [ "$VOL" -gt 33 ]; then - VOLCMP="$VOLCMP $icon_spm" + VOLCMP="${VOLCMP:+$VOLCMP }$icon_spm" elif [ "$VOL" -ge 0 ]; then - VOLCMP="$VOLCMP $icon_spl" + VOLCMP="${VOLCMP:+$VOLCMP }$icon_spl" fi fi sxmobar -a volume 50 "$VOLCMP" @@ -446,6 +434,17 @@ set_notch() { fi } +set_inputmethod() { + im_file="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_t9_mode" + if [ -r "$im_file" ]; then + read -r im_mode < "$im_file" 2>/dev/null || im_mode="[abc]" + else + im_mode="[abc]" + fi + [ -n "$im_mode" ] || im_mode="[abc]" + sxmobar -a input-method 5 "$im_mode" +} + sxmo_debug "$@" case "$1" in network) @@ -456,20 +455,28 @@ case "$1" in shift set_battery "$@" ;; - time|modem|volume|state|notifications|notch) + time|modem|volume|state|notifications|notch|inputmethod) set_"$1" ;; - periodics|state_change) # 55 s loop and screenlock triggers + state_change) + set_state set_time + set_inputmethod + ;; + periodics) # 55 s loop + set_time + set_inputmethod if [ -z "$SXMO_NO_MODEM" ]; then set_modem fi set_notch set_state set_network wifi wlan0 + sxmo_hook_battery.sh 2>/dev/null || true ;; all) sxmobar -r + set_inputmethod set_time if [ -z "$SXMO_NO_MODEM" ]; then set_modem @@ -481,8 +488,13 @@ case "$1" in set_notifications set_notch set_network wifi wlan0 + sxmo_hook_battery.sh 2>/dev/null || true ;; *) exit # swallow it ! ;; esac + +if [ "${SXMO_WM:-dwm}" = "dwm" ] && command -v xsetroot >/dev/null 2>&1; then + DISPLAY="${DISPLAY:-:0}" xsetroot -name "$(sxmo_status.sh)" 2>/dev/null || true +fi diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_unlock.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_unlock.sh index 7950b07..dd0f43b 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_unlock.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_unlock.sh @@ -9,12 +9,21 @@ # This hook is called when the system becomes unlocked again -sxmo_led.sh blink red green & +if [ -z "$SXMO_DISABLE_LEDS" ]; then + sxmo_led.sh blink red green & +fi sxmo_wm.sh display on -sxmo_wm.sh inputevent touchscreen on +if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '255' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true +fi +if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then + sxmo_wm.sh inputevent touchscreen on +fi -sxmo_jobs.sh stop periodic_blink +if [ -z "$SXMO_DISABLE_LEDS" ]; then + sxmo_jobs.sh stop periodic_blink +fi sxmo_jobs.sh stop periodic_wakelock_check # Go to the next idle state after 120 seconds of inactivity diff --git a/patches/xlibre/0001-xlibre-msm8905-spi-drm-and-shared-vt.patch b/patches/xlibre/0001-xlibre-msm8905-spi-drm-and-shared-vt.patch new file mode 100644 index 0000000..d8a2027 --- /dev/null +++ b/patches/xlibre/0001-xlibre-msm8905-spi-drm-and-shared-vt.patch @@ -0,0 +1,237 @@ +diff --git a/Xext/xfixes/cursor.c b/Xext/xfixes/cursor.c +index d017da0..a530caa 100644 +--- a/Xext/xfixes/cursor.c ++++ b/Xext/xfixes/cursor.c +@@ -122,9 +122,9 @@ typedef struct _CursorHideCountRec { + #define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = (func)) + #define Unwrap(as,s,elt,backup) (((backup) = (s)->elt), (s)->elt = (as)->elt) + +-/* The cursor doesn't show up until the first XDefineCursor() */ ++/* The cursor is permanently disabled for keypad-only hardware */ + Bool CursorVisible = FALSE; +-Bool EnableCursor = TRUE; ++Bool EnableCursor = FALSE; + + static CursorPtr + CursorForDevice(DeviceIntPtr pDev) +diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_bo.c b/hw/xfree86/drivers/video/modesetting/drmmode_bo.c +index b39aa73..71c876e 100644 +--- a/hw/xfree86/drivers/video/modesetting/drmmode_bo.c ++++ b/hw/xfree86/drivers/video/modesetting/drmmode_bo.c +@@ -251,6 +251,8 @@ gbm_create_cursor_bo(drmmode_ptr drmmode, Bool do_map, + + /* For older mesa */ + GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE, ++ GBM_BO_USE_SCANOUT | GBM_BO_USE_WRITE, ++ GBM_BO_USE_WRITE, + }; + + /* Assume whatever bpp we have for the primary plane, we also have for the cursor plane */ +diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c +index e5f694c..98f1f7a 100644 +--- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c +@@ -4856,16 +4856,11 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) + min_width = MIN(width, min_width); + min_height = MIN(height, min_height); + +- drmmode_crtc->cursor.bo = gbm_create_best_bo(drmmode, TRUE, width, height, DRMMODE_CURSOR_BO); +- if (!drmmode_crtc->cursor.bo) { +- gbm_bo_destroy(drmmode->front_bo); +- for (int j = 0; j < i; j++) { +- xf86CrtcPtr free_crtc = xf86_config->crtc[j]; +- drmmode_crtc_private_ptr free_drmmode_crtc = free_crtc->driver_private; +- gbm_bo_destroy(free_drmmode_crtc->cursor.bo); +- free_drmmode_crtc->cursor.bo = NULL; ++ if (!drmmode->sw_cursor) { ++ drmmode_crtc->cursor.bo = gbm_create_best_bo(drmmode, TRUE, width, height, DRMMODE_CURSOR_BO); ++ if (!drmmode_crtc->cursor.bo) { ++ drmmode->sw_cursor = TRUE; + } +- return FALSE; + } + } + +@@ -4886,13 +4881,15 @@ drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) + drmmode->fb_id = 0; + } + +- gbm_bo_destroy(drmmode->front_bo); ++ if (drmmode->front_bo) ++ gbm_bo_destroy(drmmode->front_bo); + + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + +- gbm_bo_destroy(drmmode_crtc->cursor.bo); ++ if (drmmode_crtc->cursor.bo) ++ gbm_bo_destroy(drmmode_crtc->cursor.bo); + drmmode_destroy_tearfree_shadow(crtc); + } + } +diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c +index 6653dd9..e04b69c 100644 +--- a/hw/xfree86/os-support/linux/lnx_init.c ++++ b/hw/xfree86/os-support/linux/lnx_init.c +@@ -114,35 +114,41 @@ linux_parse_vt_settings(int may_fail) + if (fd < 0) { + if (may_fail) + return 0; +- FatalError("parse_vt_settings: Cannot open /dev/tty0 (%s), maybe missing for ex. '-seat seat0 -keeptty' parameters? (in case trying to run uid !=0 mode)\n", +- strerror(errno)); +- } +- +- if (xf86Info.ShareVTs) { +- SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts)); +- if (ret < 0) { +- if (may_fail) +- return 0; +- FatalError("parse_vt_settings: Cannot find the current" +- " VT (%s)\n", strerror(errno)); +- } +- xf86Info.vtno = vts.v_active; +- } +- else { +- SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno)); +- if (ret < 0) { +- if (may_fail) +- return 0; +- FatalError("parse_vt_settings: Cannot find a free VT: " +- "%s\n", strerror(errno)); ++ xf86Info.vtno = 1; ++ KeepTty = TRUE; ++ } else { ++ if (xf86Info.ShareVTs) { ++ SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts)); ++ if (ret < 0) { ++ if (may_fail) { ++ close(fd); ++ return 0; ++ } ++ FatalError("parse_vt_settings: Cannot find the current" ++ " VT (%s)\n", strerror(errno)); ++ } ++ xf86Info.vtno = vts.v_active; + } +- if (xf86Info.vtno == -1) { +- if (may_fail) +- return 0; +- FatalError("parse_vt_settings: Cannot find a free VT\n"); ++ else { ++ SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno)); ++ if (ret < 0) { ++ if (may_fail) { ++ close(fd); ++ return 0; ++ } ++ FatalError("parse_vt_settings: Cannot find a free VT: " ++ "%s\n", strerror(errno)); ++ } ++ if (xf86Info.vtno == -1) { ++ if (may_fail) { ++ close(fd); ++ return 0; ++ } ++ FatalError("parse_vt_settings: Cannot find a free VT\n"); ++ } + } ++ close(fd); + } +- close(fd); + } + + LogMessageVerb(from, 1, "using VT number %d\n\n", xf86Info.vtno); +@@ -218,9 +224,14 @@ xf86OpenConsole(void) + if (seatd_libseat_controls_session()) + return; + +- if (xf86Info.consoleFd < 0) +- FatalError("xf86OpenConsole: Cannot open virtual console" +- " %d (%s)\n", xf86Info.vtno, strerror(errno)); ++ if (xf86Info.consoleFd < 0) { ++ LogMessageVerb(X_WARNING, 1, ++ "xf86OpenConsole: Cannot open virtual console %d (%s), using /dev/null in shared VT mode\n", ++ xf86Info.vtno, strerror(errno)); ++ xf86Info.consoleFd = open("/dev/null", O_RDWR | O_NDELAY, 0); ++ xf86Info.ShareVTs = TRUE; ++ return; ++ } + + /* + * Linux doesn't switch to an active vt after the last close of a vt, +@@ -237,15 +248,23 @@ xf86OpenConsole(void) + struct termios nTty; + + /* +- * now get the VT. This _must_ succeed, or else fail completely. ++ * now get the VT. If unprivileged without CAP_SYS_TTY_CONFIG, ++ * fall back to ShareVTs mode instead of aborting. + */ +- if (!switch_to(xf86Info.vtno, "xf86OpenConsole")) +- FatalError("xf86OpenConsole: Switching VT failed\n"); ++ if (!switch_to(xf86Info.vtno, "xf86OpenConsole")) { ++ LogMessageVerb(X_WARNING, 1, ++ "xf86OpenConsole: VT switch not permitted, continuing in shared VT mode\n"); ++ xf86Info.ShareVTs = TRUE; ++ return; ++ } + + SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT)); +- if (ret < 0) +- FatalError("xf86OpenConsole: VT_GETMODE failed %s\n", +- strerror(errno)); ++ if (ret < 0) { ++ LogMessageVerb(X_WARNING, 1, "xf86OpenConsole: VT_GETMODE failed %s\n", ++ strerror(errno)); ++ xf86Info.ShareVTs = TRUE; ++ return; ++ } + + OsSignal(SIGUSR1, xf86VTRequest); + +@@ -254,15 +273,20 @@ xf86OpenConsole(void) + VT.acqsig = SIGUSR1; + + SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT)); +- if (ret < 0) +- FatalError +- ("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n", +- strerror(errno)); ++ if (ret < 0) { ++ LogMessageVerb(X_WARNING, 1, ++ "xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n", ++ strerror(errno)); ++ xf86Info.ShareVTs = TRUE; ++ return; ++ } + + SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS)); +- if (ret < 0) +- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n", +- strerror(errno)); ++ if (ret < 0) { ++ LogMessageVerb(X_WARNING, 1, ++ "xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n", ++ strerror(errno)); ++ } + + tcgetattr(xf86Info.consoleFd, &tty_attr); + SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode)); +@@ -274,11 +298,11 @@ xf86OpenConsole(void) + /* fine, just disable special keys */ + SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW)); + if (ret < 0) +- FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n", +- strerror(errno)); +- +- /* ... and drain events, else the kernel gets angry */ +- xf86SetConsoleHandler(drain_console, NULL); ++ LogMessageVerb(X_WARNING, 1, ++ "xf86OpenConsole: KDSKBMODE K_RAW failed %s\n", ++ strerror(errno)); ++ else ++ xf86SetConsoleHandler(drain_console, NULL); + } + + nTty = tty_attr; diff --git a/patches/xlibre/0002-xf86-input-libinput-xlibre25.patch b/patches/xlibre/0002-xf86-input-libinput-xlibre25.patch new file mode 100644 index 0000000..45b1962 --- /dev/null +++ b/patches/xlibre/0002-xf86-input-libinput-xlibre25.patch @@ -0,0 +1,25 @@ +diff --git a/src/xf86libinput.c b/src/xf86libinput.c +index 1aebca3..8d3691c 100644 +--- a/src/xf86libinput.c ++++ b/src/xf86libinput.c +@@ -1727,12 +1727,19 @@ xf86libinput_handle_key(InputInfoPtr pInfo, struct libinput_event_keyboard *even + if ((driver_data->capabilities & CAP_KEYBOARD) == 0) + return; + +- /* keycodes > 256 that have a historical mapping in xkeyboard-config */ ++ /* keycodes > 256 that have a historical mapping in xkeyboard-config ++ * plus Nokia MSM8909 keypad evdev keycodes > 247 mapped into X11 8-bit range */ + switch (key) { + case KEY_TOUCHPAD_TOGGLE: key = KEY_F21; break; + case KEY_TOUCHPAD_ON: key = KEY_F22; break; + case KEY_TOUCHPAD_OFF: key = KEY_F23; break; + case KEY_MICMUTE: key = KEY_F20; break; ++ case 696: /* KEY_KBD_LCD_MENU1 (Left Softkey) */ key = KEY_COMPOSE; break; ++ case 697: /* KEY_KBD_LCD_MENU2 (Right Softkey) */ key = KEY_BACK; break; ++ case 445: /* KEY_PICKUP_PHONE (Call button) */ key = KEY_PHONE; break; ++ case 352: /* KEY_OK (Center D-pad OK) */ key = KEY_ENTER; break; ++ case 522: /* KEY_NUMERIC_STAR (*) */ key = KEY_KPASTERISK; break; ++ case 523: /* KEY_NUMERIC_POUND (#) */ key = KEY_KPSLASH; break; + } + + key += XORG_KEYCODE_OFFSET; diff --git a/patches/xlibre/0003-xf86-video-fbdev-xlibre25.patch b/patches/xlibre/0003-xf86-video-fbdev-xlibre25.patch new file mode 100644 index 0000000..519d32c --- /dev/null +++ b/patches/xlibre/0003-xf86-video-fbdev-xlibre25.patch @@ -0,0 +1,65 @@ +diff --git a/src/fbdev.c b/src/fbdev.c +index 3dfc0b2..6e3b9e7 100644 +--- a/src/fbdev.c ++++ b/src/fbdev.c +@@ -15,14 +15,18 @@ + #include "colormapst.h" + #include "xf86cmap.h" + #include "shadow.h" ++#ifdef XFreeXDGA + #include "dgaproc.h" ++#endif + + /* for visuals */ + #include "fb.h" + + #include "fbdevhw.h" + ++#ifdef XV + #include "xf86xv.h" ++#endif + + #include + +@@ -168,9 +172,11 @@ typedef struct { + CreateScreenResourcesProcPtr CreateScreenResources; + void (*PointerMoved)(ScrnInfoPtr pScrn, int x, int y); + EntityInfoPtr pEnt; ++#ifdef XFreeXDGA + /* DGA info */ + DGAModePtr pDGAMode; + int nDGAMode; ++#endif + OptionInfoPtr Options; + } FBDevRec, *FBDevPtr; + +@@ -954,11 +960,13 @@ FBDevCloseScreen(ScreenPtr pScreen) + free(fPtr->shadow); + fPtr->shadow = NULL; + } ++#ifdef XFreeXDGA + if (fPtr->pDGAMode) { + free(fPtr->pDGAMode); + fPtr->pDGAMode = NULL; + fPtr->nDGAMode = 0; + } ++#endif + pScrn->vtSema = FALSE; + + pScreen->CreateScreenResources = fPtr->CreateScreenResources; +@@ -1031,6 +1039,7 @@ FBDevPointerMoved(ScrnInfoPtr pScrn, int x, int y) + /*********************************************************************** + * DGA stuff + ***********************************************************************/ ++#ifdef XFreeXDGA + static Bool FBDevDGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName, + unsigned char **ApertureBase, + int *ApertureSize, int *ApertureOffset, +@@ -1154,6 +1163,7 @@ FBDevDGAAddModes(ScrnInfoPtr pScrn) + pMode = pMode->next; + } while (pMode != pScrn->modes); + } ++#endif + + static Bool + FBDevDGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen) diff --git a/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so b/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so index ef7c52f..43a7812 100755 Binary files a/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so and b/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so differ diff --git a/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so b/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so index ef7c52f..43a7812 100755 Binary files a/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so and b/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so differ diff --git a/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko b/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko index 7430da4..a023978 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko and b/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko.zst b/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko.zst index 75024db..08775e5 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko index cfc027b..7a9aa81 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko.zst index 0e12c99..49f22ce 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6adm.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-clocks.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-clocks.ko.zst index 7dd3afd..2800d53 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-clocks.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-clocks.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-dai.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-dai.ko.zst index 87a9bc6..d850b49 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-dai.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe-dai.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko index 52e5460..8e4fbc5 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko.zst index 07e8b8c..261d89b 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6afe.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-dai.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-dai.ko.zst index 4d43162..c5c3211 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-dai.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-dai.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-lpass-dais.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-lpass-dais.ko.zst index 71d0e1b..7343679 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-lpass-dais.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6apm-lpass-dais.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm-dai.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm-dai.ko.zst index 80ce3ca..d5dd66b 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm-dai.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm-dai.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko index fa6c877..4279d40 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko.zst index 91e2e64..0c2283b 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6asm.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko index 06985db..74d90af 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko.zst index 5cf5b8e..6d2dcff 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6core.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko index 079c44a..3d5813f 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko.zst index b3f7c85..480e9be 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvp.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko index 762edf8..8657876 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko.zst index 7f83c51..9e84fc5 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6cvs.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko index e756b23..3cea40d 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko.zst index 66eeef6..084acf2 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6mvm.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm-clocks.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm-clocks.ko.zst index c04685e..e8e63d6 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm-clocks.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm-clocks.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko index 7226a6c..5016c62 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko.zst index 7fc5a5d..fe2e4df 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6prm.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6routing.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6routing.ko.zst index 157746c..58ddd2b 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6routing.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6routing.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko index 67f26b2..67b74b2 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko.zst index 4a7d3c6..49219ef 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-common.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-dai.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-dai.ko.zst index ed68b39..4059d7b 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-dai.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice-dai.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice.ko.zst index bc3e874..08e1db9 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/q6voice.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko b/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko index d4b9390..bc1c628 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko.zst index 2070f2b..8ea3b31 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6apm.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6dsp-common.ko.zst b/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6dsp-common.ko.zst index 0b4938e..b5c417e 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6dsp-common.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/qdsp6/snd-q6dsp-common.ko.zst differ diff --git a/prebuilt/sxmo-x11/usr/bin/dmenu b/prebuilt/sxmo-x11/usr/bin/dmenu new file mode 100755 index 0000000..53d9ec3 Binary files /dev/null and b/prebuilt/sxmo-x11/usr/bin/dmenu differ diff --git a/prebuilt/sxmo-x11/usr/bin/dmenu_path b/prebuilt/sxmo-x11/usr/bin/dmenu_path new file mode 100755 index 0000000..3a7cda7 --- /dev/null +++ b/prebuilt/sxmo-x11/usr/bin/dmenu_path @@ -0,0 +1,13 @@ +#!/bin/sh + +cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +cache="$cachedir/dmenu_run" + +[ ! -e "$cachedir" ] && mkdir -p "$cachedir" + +IFS=: +if stest -dqr -n "$cache" $PATH; then + stest -flx $PATH | sort -u | tee "$cache" +else + cat "$cache" +fi diff --git a/prebuilt/sxmo-x11/usr/bin/dmenu_run b/prebuilt/sxmo-x11/usr/bin/dmenu_run new file mode 100755 index 0000000..834ede5 --- /dev/null +++ b/prebuilt/sxmo-x11/usr/bin/dmenu_run @@ -0,0 +1,2 @@ +#!/bin/sh +dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} & diff --git a/prebuilt/sxmo-x11/usr/bin/dwm b/prebuilt/sxmo-x11/usr/bin/dwm new file mode 100755 index 0000000..920a79f Binary files /dev/null and b/prebuilt/sxmo-x11/usr/bin/dwm differ diff --git a/prebuilt/sxmo-x11/usr/bin/st b/prebuilt/sxmo-x11/usr/bin/st new file mode 100755 index 0000000..83b666c Binary files /dev/null and b/prebuilt/sxmo-x11/usr/bin/st differ diff --git a/prebuilt/sxmo-x11/usr/bin/stest b/prebuilt/sxmo-x11/usr/bin/stest new file mode 100755 index 0000000..9d9d4ea Binary files /dev/null and b/prebuilt/sxmo-x11/usr/bin/stest differ diff --git a/prebuilt/xlibre/usr/bin/X b/prebuilt/xlibre/usr/bin/X new file mode 120000 index 0000000..e363c6e --- /dev/null +++ b/prebuilt/xlibre/usr/bin/X @@ -0,0 +1 @@ +Xorg \ No newline at end of file diff --git a/prebuilt/xlibre/usr/bin/Xorg b/prebuilt/xlibre/usr/bin/Xorg new file mode 100755 index 0000000..10f585b Binary files /dev/null and b/prebuilt/xlibre/usr/bin/Xorg differ diff --git a/prebuilt/xlibre/usr/bin/gtf b/prebuilt/xlibre/usr/bin/gtf new file mode 100755 index 0000000..2eeee1c Binary files /dev/null and b/prebuilt/xlibre/usr/bin/gtf differ diff --git a/prebuilt/xlibre/usr/include/xorg/Xprintf.h b/prebuilt/xlibre/usr/include/xorg/Xprintf.h new file mode 100644 index 0000000..382e24f --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/Xprintf.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef XPRINTF_H +#define XPRINTF_H + +#include +#include +#include + +#include "os.h" + +#ifndef _X_RESTRICT_KYWD +#if defined(restrict) /* assume autoconf set it correctly */ || \ + (defined(__STDC__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ +#define _X_RESTRICT_KYWD restrict +#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */ +#define _X_RESTRICT_KYWD __restrict__ +#else +#define _X_RESTRICT_KYWD +#endif +#endif + +/* + * These functions provide a portable implementation of the common (but not + * yet universal) asprintf & vasprintf routines to allocate a buffer big + * enough to sprintf the arguments to. The XNF variants terminate the server + * if the allocation fails. + * The buffer allocated is returned in the pointer provided in the first + * argument. The return value is the size of the allocated buffer, or -1 + * on failure. + */ +extern _X_EXPORT int /* deprecated */ +XNFasprintf(char **ret, const char *_X_RESTRICT_KYWD fmt, ...) +_X_ATTRIBUTE_PRINTF(2, 3); +extern _X_EXPORT int +XNFvasprintf(char **ret, const char *_X_RESTRICT_KYWD fmt, va_list va) +_X_ATTRIBUTE_VPRINTF(2, 0); + +#endif /* XPRINTF_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/callback.h b/prebuilt/xlibre/usr/include/xorg/callback.h new file mode 100644 index 0000000..7b78deb --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/callback.h @@ -0,0 +1,82 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef CALLBACK_H +#define CALLBACK_H + +#include /* for GContext, Mask */ +#include /* for Bool */ +#include +#include + +/* + * callback manager stuff + */ + +typedef struct _CallbackList *CallbackListPtr; + +typedef void (*CallbackProcPtr) (CallbackListPtr *, void *, void *); + +extern _X_EXPORT Bool AddCallback(CallbackListPtr *pcbl, + CallbackProcPtr callback, + void *data); + +extern _X_EXPORT Bool DeleteCallback(CallbackListPtr *pcbl, + CallbackProcPtr callback, + void *data); + +extern _X_EXPORT void _CallCallbacks(CallbackListPtr *pcbl, + void *call_data); + +static inline void +CallCallbacks(CallbackListPtr *pcbl, void *call_data) +{ + if (!pcbl || !*pcbl) + return; + _CallCallbacks(pcbl, call_data); +} + +#endif /* CALLBACK_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/colormap.h b/prebuilt/xlibre/usr/include/xorg/colormap.h new file mode 100644 index 0000000..48ae0d6 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/colormap.h @@ -0,0 +1,58 @@ +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifndef CMAP_H +#define CMAP_H 1 + +#include +#include "screenint.h" +#include "window.h" + +#define DynamicClass 1 + +typedef CARD32 Pixel; + +#endif /* CMAP_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/colormapst.h b/prebuilt/xlibre/usr/include/xorg/colormapst.h new file mode 100644 index 0000000..f0149ae --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/colormapst.h @@ -0,0 +1,59 @@ +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifndef CMAPSTRUCT_H +#define CMAPSTRUCT_H 1 + +#include + +/* LOCO -- a local color for a PseudoColor cell. DirectColor maps always + * use the first value (called red) in the structure. What channel they + * are really talking about depends on which map they are in. */ +typedef struct { + unsigned short red, green, blue; +} LOCO; + +#endif /* COLORMAP_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/compiler.h b/prebuilt/xlibre/usr/include/xorg/compiler.h new file mode 100644 index 0000000..6aed97a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/compiler.h @@ -0,0 +1,724 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _COMPILER_H +#define _COMPILER_H + +#ifndef _X_EXPORT +#include +#endif + +#include "xlibre_membarrier.h" /* backwards compat, remove in ABI-26 */ + +#if defined(__alpha__) + +# if defined(__linux__) +/* for Linux on Alpha, we use the LIBC _inx/_outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +_X_EXPORT void _outb(unsigned char val, unsigned long port); +_X_EXPORT void _outw(unsigned short val, unsigned long port); +_X_EXPORT void _outl(unsigned int val, unsigned long port); +_X_EXPORT unsigned int _inb(unsigned long port); +_X_EXPORT unsigned int _inw(unsigned long port); +_X_EXPORT unsigned int _inl(unsigned long port); + +static inline void +outb(unsigned long port, unsigned char val) +{ + _outb(val, port); +} + +static inline void +outw(unsigned long port, unsigned short val) +{ + _outw(val, port); +} + +static inline void +outl(unsigned long port, unsigned int val) +{ + _outl(val, port); +} + +static inline unsigned int +inb(unsigned long port) +{ + return _inb(port); +} + +static inline unsigned int +inw(unsigned long port) +{ + return _inw(port); +} + +static inline unsigned int +inl(unsigned long port) +{ + return _inl(port); +} + +# elif (defined(__FreeBSD__) || defined(__OpenBSD__)) + +/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */ +/* inx/outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +_X_EXPORT void outb(unsigned int port, unsigned char val); +_X_EXPORT void outw(unsigned int port, unsigned short val); +_X_EXPORT void outl(unsigned int port, unsigned int val); +_X_EXPORT unsigned char inb(unsigned int port); +_X_EXPORT unsigned short inw(unsigned int port); +_X_EXPORT unsigned int inl(unsigned int port); + +# elif defined(__NetBSD__) + +# include + +# endif /* various OS'es on __alpha__ */ + +static inline int MMIO_IN8(void *Base, unsigned long Offset) { + xlibre_mem_barrier_read(); + return *(CARD8 *) ((unsigned long) Base + (Offset)); +} + +static inline int MMIO_IN16(void *Base, unsigned long Offset) { + xlibre_mem_barrier_read(); + return *(CARD16 *) ((unsigned long) Base + (Offset)); +} + +static inline int MMIO_IN32(void *Base, unsigned long Offset) { + xlibre_mem_barrier_read(); + return *(CARD32 *) ((unsigned long) Base + (Offset)); +} + +static inline void MMIO_OUT8(void *Base, unsigned long Offset, int Value) { + xlibre_mem_barrier_write(); + *(CARD8 *) ((unsigned long) Base + (Offset)) = Value; +} + +static inline void MMIO_OUT16(void *Base, unsigned long Offset, int Value) { + xlibre_mem_barrier_write(); + *(CARD16 *) ((unsigned long) Base + (Offset)) = Value; +} + +static inline void MMIO_OUT32(void *Base, unsigned long Offset, int Value) { + xlibre_mem_barrier_write(); + *(CARD32 *) ((unsigned long) Base + (Offset)) = Value; +} + +_X_EXPORT void xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count); +_X_EXPORT void xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count); + +static inline void slowbcopy_tobus(unsigned char *src, unsigned char *dst, int count) { + xf86SlowBCopyToBus(src, dst, count); +} + +static inline void slowbcopy_frombus(unsigned char *src, unsigned char *dst, int count) { + xf86SlowBCopyFromBus(src, dst, count); +} + +#elif defined(__amd64__) || defined(__i386__) || defined(__ia64__) + +#include + +static inline void +outb(unsigned short port, unsigned char val) +{ + __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port)); +} + +static inline void +outw(unsigned short port, unsigned short val) +{ + __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port)); +} + +static inline void +outl(unsigned short port, unsigned int val) +{ + __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port)); +} + +static inline unsigned int +inb(unsigned short port) +{ + unsigned char ret; + __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port)); + + return ret; +} + +static inline unsigned int +inw(unsigned short port) +{ + unsigned short ret; + __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port)); + + return ret; +} + +static inline unsigned int +inl(unsigned short port) +{ + unsigned int ret; + __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port)); + + return ret; +} + +#elif defined(__sparc__) + +#define __XLIBRE_SPARC_ASI_PRIMAY_LE 0x88 /* just for readability */ + +static inline void +outb(unsigned long port, unsigned char val) +{ + __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */ + :"r"(val), "r"(port), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +static inline void +outw(unsigned long port, unsigned short val) +{ + __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */ + :"r"(val), "r"(port), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +static inline void +outl(unsigned long port, unsigned int val) +{ + __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */ + :"r"(val), "r"(port), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +static inline unsigned int +inb(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lduba [%1] %2, %0":"=r"(ret) + :"r"(port), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + return ret; +} + +static inline unsigned int +inw(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lduha [%1] %2, %0":"=r"(ret) + :"r"(port), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + return ret; +} + +static inline unsigned int +inl(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lda [%1] %2, %0":"=r"(ret) + :"r"(port), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + return ret; +} + +static inline unsigned char +xf86ReadMmio8(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long) base) + offset; + unsigned char ret; + + __asm__ __volatile__("lduba [%1] %2, %0":"=r"(ret) + :"r"(addr), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + + return ret; +} + +static inline unsigned short +xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long) base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduh [%1], %0":"=r"(ret) + :"r"(addr)); + + return ret; +} + +static inline unsigned short +xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long) base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduha [%1] %2, %0":"=r"(ret) + :"r"(addr), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + + return ret; +} + +static inline unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long) base) + offset; + unsigned int ret; + + __asm__ __volatile__("ld [%1], %0":"=r"(ret) + :"r"(addr)); + + return ret; +} + +static inline unsigned int +xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long) base) + offset; + unsigned int ret; + + __asm__ __volatile__("lda [%1] %2, %0":"=r"(ret) + :"r"(addr), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + + return ret; +} + +static inline void +xf86WriteMmio8(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long) base) + offset; + + __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */ + :"r"(val), "r"(addr), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +static inline void +xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long) base) + offset; + + __asm__ __volatile__("sth %0, [%1]": /* No outputs */ + :"r"(val), "r"(addr)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +static inline void +xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long) base) + offset; + + __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */ + :"r"(val), "r"(addr), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +static inline void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long) base) + offset; + + __asm__ __volatile__("st %0, [%1]": /* No outputs */ + :"r"(val), "r"(addr)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +static inline void +xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long) base) + offset; + + __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */ + :"r"(val), "r"(addr), "i"(__XLIBRE_SPARC_ASI_PRIMAY_LE)); + __asm__ __volatile__ (".word 0x8143e00a" : : : "memory"); +} + +#undef __XLIBRE_SPARC_ASI_PRIMAY_LE + +#elif defined(__arm32__) && !defined(__linux__) + +extern _X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */ + +static inline void +outb(unsigned long port, unsigned char val) +{ + *(volatile unsigned char *) (((unsigned long) (port)) + IOPortBase) = + val; +} + +static inline void +outw(unsigned long port, unsigned short val) +{ + *(volatile unsigned short *) (((unsigned long) (port)) + IOPortBase) = + val; +} + +static inline void +outl(unsigned long port, unsigned int val) +{ + *(volatile unsigned int *) (((unsigned long) (port)) + IOPortBase) = + val; +} + +static inline unsigned int +inb(unsigned long port) +{ + return *(volatile unsigned char *) (((unsigned long) (port)) + + IOPortBase); +} + +static inline unsigned int +inw(unsigned long port) +{ + return *(volatile unsigned short *) (((unsigned long) (port)) + + IOPortBase); +} + +static inline unsigned int +inl(unsigned long port) +{ + return *(volatile unsigned int *) (((unsigned long) (port)) + + IOPortBase); +} + +#elif defined(__mips__) + +# if defined(__mips64) +# define __XLIBRE_MIPS_PORT_TYPE unsigned long +# define __XLIBRE_MIPS_PORT_ADDR(port) (((unsigned long)(port)) + IOPortBase) +# else +# define __XLIBRE_MIPS_PORT_TYPE unsigned short +# define __XLIBRE_MIPS_PORT_ADDR(port) (((unsigned short)(port)) + IOPortBase) +# endif + +extern _X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */ + +static inline void outb(__XLIBRE_MIPS_PORT_TYPE port, unsigned char val) { + *(volatile unsigned char *)(__XLIBRE_MIPS_PORT_ADDR(port)) = val; +} + +static inline void outw(__XLIBRE_MIPS_PORT_TYPE port, unsigned short val) { + *(volatile unsigned short *)(__XLIBRE_MIPS_PORT_ADDR(port)) = val; +} + +static inline void outl(__XLIBRE_MIPS_PORT_TYPE port, unsigned int val) { + *(volatile unsigned int *)(__XLIBRE_MIPS_PORT_ADDR(port)) = val; +} + +static inline unsigned int inb(__XLIBRE_MIPS_PORT_TYPE port) { + return *(volatile unsigned char *)(__XLIBRE_MIPS_PORT_ADDR(port)); +} + +static inline unsigned int inw(__XLIBRE_MIPS_PORT_TYPE port) { + return *(volatile unsigned short *)(__XLIBRE_MIPS_PORT_ADDR(port)); +} + +static inline unsigned int inl(__XLIBRE_MIPS_PORT_TYPE port) { + return *(volatile unsigned int *)(__XLIBRE_MIPS_PORT_ADDR(port)); +} + +# undef __XLIBRE_MIPS_PORT_TYPE +# undef __XLIBRE_MIPS_PORT_ADDR + +# ifdef __linux__ /* don't mess with other OSs */ +# if X_BYTE_ORDER == X_BIG_ENDIAN +static inline unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long) base) + offset; + unsigned int ret; + + __asm__ __volatile__("lw %0, 0(%1)":"=r"(ret) + :"r"(addr)); + + return ret; +} + +static inline void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long) base) + offset; + + __asm__ __volatile__("sw %0, 0(%1)": /* No outputs */ + :"r"(val), "r"(addr)); +} +# endif /* X_BYTE_ORDER == X_BIG_ENDIAN */ +# endif /* __linux__ */ + +#elif defined(__powerpc__) + +#include + +extern _X_EXPORT void *ioBase; + +static inline unsigned char +xf86ReadMmio8(__volatile__ void *base, const unsigned long offset) +{ + register unsigned char val; + __asm__ __volatile__("lbzx %0,%1,%2\n\t" "eieio":"=r"(val) + :"b"(base), "r"(offset), + "m"(*((volatile unsigned char *) base + offset))); + return val; +} + +static inline unsigned short +xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset) +{ + register unsigned short val; + __asm__ __volatile__("lhzx %0,%1,%2\n\t" "eieio":"=r"(val) + :"b"(base), "r"(offset), + "m"(*((volatile unsigned char *) base + offset))); + return val; +} + +static inline unsigned short +xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset) +{ + register unsigned short val; + __asm__ __volatile__("lhbrx %0,%1,%2\n\t" "eieio":"=r"(val) + :"b"(base), "r"(offset), + "m"(*((volatile unsigned char *) base + offset))); + return val; +} + +static inline unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + register unsigned int val; + __asm__ __volatile__("lwzx %0,%1,%2\n\t" "eieio":"=r"(val) + :"b"(base), "r"(offset), + "m"(*((volatile unsigned char *) base + offset))); + return val; +} + +static inline unsigned int +xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset) +{ + register unsigned int val; + __asm__ __volatile__("lwbrx %0,%1,%2\n\t" "eieio":"=r"(val) + :"b"(base), "r"(offset), + "m"(*((volatile unsigned char *) base + offset))); + return val; +} + +static inline void +xf86WriteMmio8(__volatile__ void *base, const unsigned long offset, + const unsigned char val) +{ + __asm__ + __volatile__("stbx %1,%2,%3\n\t":"=m" + (*((volatile unsigned char *) base + offset)) + :"r"(val), "b"(base), "r"(offset)); + xlibre_mem_barrier_write(); +} + +static inline void +xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + __asm__ + __volatile__("sthbrx %1,%2,%3\n\t":"=m" + (*((volatile unsigned char *) base + offset)) + :"r"(val), "b"(base), "r"(offset)); + xlibre_mem_barrier_write(); +} + +static inline void +xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + __asm__ + __volatile__("sthx %1,%2,%3\n\t":"=m" + (*((volatile unsigned char *) base + offset)) + :"r"(val), "b"(base), "r"(offset)); + xlibre_mem_barrier_write(); +} + +static inline void +xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + __asm__ + __volatile__("stwbrx %1,%2,%3\n\t":"=m" + (*((volatile unsigned char *) base + offset)) + :"r"(val), "b"(base), "r"(offset)); + xlibre_mem_barrier_write(); +} + +static inline void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + __asm__ + __volatile__("stwx %1,%2,%3\n\t":"=m" + (*((volatile unsigned char *) base + offset)) + :"r"(val), "b"(base), "r"(offset)); + xlibre_mem_barrier_write(); +} + +static inline void +outb(unsigned short port, unsigned char value) +{ + if (ioBase == MAP_FAILED) + return; + xf86WriteMmio8(ioBase, port, value); +} + +static inline void +outw(unsigned short port, unsigned short value) +{ + if (ioBase == MAP_FAILED) + return; + xf86WriteMmio16Le(ioBase, port, value); +} + +static inline void +outl(unsigned short port, unsigned int value) +{ + if (ioBase == MAP_FAILED) + return; + xf86WriteMmio32Le(ioBase, port, value); +} + +static inline unsigned int +inb(unsigned short port) +{ + if (ioBase == MAP_FAILED) + return 0; + return xf86ReadMmio8(ioBase, port); +} + +static inline unsigned int +inw(unsigned short port) +{ + if (ioBase == MAP_FAILED) + return 0; + return xf86ReadMmio16Le(ioBase, port); +} + +static inline unsigned int +inl(unsigned short port) +{ + if (ioBase == MAP_FAILED) + return 0; + return xf86ReadMmio32Le(ioBase, port); +} + +#endif /* arch madness */ + +/* drivers that want to prevent automatic byteswapping by MMIO_()* macros + on PPC and SPARC should set these */ +#if !defined(MMIO_IS_BE) && \ + (defined(SPARC_MMIO_IS_BE) || defined(PPC_MMIO_IS_BE)) +#define MMIO_IS_BE +#endif + +#ifdef __alpha__ +#elif defined(__powerpc__) || defined(__sparc__) + /* + * we provide byteswapping and no byteswapping functions here + * with byteswapping as default, + * drivers that don't need byteswapping should define MMIO_IS_BE + */ +#define MMIO_IN8(base, offset) xf86ReadMmio8((base), (offset)) +#define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8((base), (offset), (CARD8)(val)) + +#if defined(MMIO_IS_BE) /* No byteswapping */ +#define MMIO_IN16(base, offset) xf86ReadMmio16Be((base), (offset)) +#define MMIO_IN32(base, offset) xf86ReadMmio32Be((base), (offset)) +#define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Be((base), (offset), (CARD16)(val)) +#define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Be((base), (offset), (CARD32)(val)) +#else /* byteswapping is the default */ +#define MMIO_IN16(base, offset) xf86ReadMmio16Le((base), (offset)) +#define MMIO_IN32(base, offset) xf86ReadMmio32Le((base), (offset)) +#define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Le((base), (offset), (CARD16)(val)) +#define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Le((base), (offset), (CARD32)(val)) +#endif + +#else /* !__alpha__ && !__powerpc__ && !__sparc__ */ + +#define MMIO_IN8(base, offset) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) +#define MMIO_IN16(base, offset) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) +#define MMIO_IN32(base, offset) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +#define MMIO_OUT8(base, offset, val) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val) +#define MMIO_OUT16(base, offset, val) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +#define MMIO_OUT32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) + +#endif /* __alpha__ */ + +/* + * With Intel, the version in os-support/misc/SlowBcopy.s is used. + * This avoids port I/O during the copy (which causes problems with + * some hardware). + */ +#ifndef __alpha__ +#define slowbcopy_tobus(src,dst,count) xf86SlowBcopy((src),(dst),(count)) +#define slowbcopy_frombus(src,dst,count) xf86SlowBcopy((src),(dst),(count)) +#endif /* __alpha__ */ + +#endif /* _COMPILER_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/compositeext.h b/prebuilt/xlibre/usr/include/xorg/compositeext.h new file mode 100644 index 0000000..e3e6f4c --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/compositeext.h @@ -0,0 +1,37 @@ +/* + * Copyright © 2009 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef _COMPOSITEEXT_H_ +#define _COMPOSITEEXT_H_ + +#include "misc.h" +#include "scrnintstr.h" + +extern _X_EXPORT Bool CompositeRegisterAlternateVisuals(ScreenPtr pScreen, + VisualID * vids, + int nVisuals); + +extern _X_EXPORT Bool compIsAlternateVisual(ScreenPtr pScreen, XID visual); + +extern _X_EXPORT RESTYPE CompositeClientWindowType; + +#endif /* _COMPOSITEEXT_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/cursor.h b/prebuilt/xlibre/usr/include/xorg/cursor.h new file mode 100644 index 0000000..50796d0 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/cursor.h @@ -0,0 +1,71 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef CURSOR_H +#define CURSOR_H + +#include "misc.h" +#include "screenint.h" +#include "window.h" +#include "privates.h" + +#define NullCursor ((CursorPtr)NULL) + +/* Provide support for alpha composited cursors */ +#define ARGB_CURSOR + +typedef struct _Cursor *CursorPtr; +// FUN FACT: If you typedef a pointer type, like the `CursorPtr` above +// then `const CursorPtr` or `CursorPtr const` actually means `struct _Cursor *const`, a constant pointer +// which is probably not what you want(a pointer to constant). +// Maybe better just keep the `*` around, or you have to typedef a separate constPtr type. +typedef struct _Cursor const *ConstCursorPtr; +typedef struct _CursorMetric *CursorMetricPtr; + +extern _X_EXPORT int FreeCursor(void *pCurs, + XID cid); + +#endif /* CURSOR_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/cursorstr.h b/prebuilt/xlibre/usr/include/xorg/cursorstr.h new file mode 100644 index 0000000..4597bde --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/cursorstr.h @@ -0,0 +1,90 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef CURSORSTRUCT_H +#define CURSORSTRUCT_H + +#include "cursor.h" +#include "privates.h" +/* + * device-independent cursor storage + */ + +/* + * source and mask point directly to the bits, which are in the server-defined + * bitmap format. + */ +typedef struct _CursorBits { + unsigned char *source; /* points to bits */ + unsigned char *mask; /* points to bits */ + Bool emptyMask; /* all zeros mask */ + unsigned short width, height, xhot, yhot; /* metrics */ + int refcnt; /* can be shared */ + PrivateRec *devPrivates; /* set by pScr->RealizeCursor */ + CARD32 *argb; /* full-color alpha blended */ +} CursorBits, *CursorBitsPtr; + +typedef struct _Cursor { + CursorBitsPtr bits; + unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */ + unsigned short backRed, backGreen, backBlue; /* device-independent color */ + int refcnt; + PrivateRec *devPrivates; /* set by pScr->RealizeCursor */ + XID id; + CARD32 serialNumber; + Atom name; +} CursorRec; + +typedef struct _CursorMetric { + unsigned short width, height, xhot, yhot; +} CursorMetricRec; + +typedef struct { + int x, y; + ScreenPtr pScreen; +} HotSpot; + +#endif /* CURSORSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/damage.h b/prebuilt/xlibre/usr/include/xorg/damage.h new file mode 100644 index 0000000..7146e47 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/damage.h @@ -0,0 +1,127 @@ +/* + * Copyright © 2003 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +#ifndef _DAMAGE_H_ +#define _DAMAGE_H_ + +#include + +typedef struct _damage *DamagePtr; + +typedef enum _damageReportLevel { + DamageReportRawRegion, + DamageReportDeltaRegion, + DamageReportBoundingBox, + DamageReportNonEmpty, + DamageReportNone +} DamageReportLevel; + +typedef void (*DamageReportFunc) (DamagePtr pDamage, RegionPtr pRegion, + void *closure); +typedef void (*DamageDestroyFunc) (DamagePtr pDamage, void *closure); + +typedef void (*DamageScreenCreateFunc) (DamagePtr); +typedef void (*DamageScreenRegisterFunc) (DrawablePtr, DamagePtr); +typedef void (*DamageScreenUnregisterFunc) (DrawablePtr, DamagePtr); +typedef void (*DamageScreenDestroyFunc) (DamagePtr); + +/* @public + * + * @brief Driver callbacks for getting notified on several damage calls + * + * The pointer to this struct can be obtained via DamageGetScreenFuncs(). + * Drivers can inject themselves here, in order to get notified on + * DamageCreate(), DamageRegister(), DamageUnregister(), DamageDestroy(). + * + * The fields may be assigned to NULL, if no action at all is wanted. + * (by default assigned to default implementations) + * + * This should ONLY be touched by video drivers, nobody else. + * + * So far the only one using it is the proprietary NVidia driver. + */ +typedef struct _damageScreenFuncs { + DamageScreenCreateFunc Create; + DamageScreenRegisterFunc Register; + DamageScreenUnregisterFunc Unregister; + DamageScreenDestroyFunc Destroy; +} DamageScreenFuncsRec, *DamageScreenFuncsPtr; + +extern _X_EXPORT void miDamageCreate(DamagePtr); +extern _X_EXPORT void miDamageRegister(DrawablePtr, DamagePtr); +extern _X_EXPORT void miDamageUnregister(DrawablePtr, DamagePtr); +extern _X_EXPORT void miDamageDestroy(DamagePtr); + +extern _X_EXPORT Bool + DamageSetup(ScreenPtr pScreen); + +extern _X_EXPORT DamagePtr +DamageCreate(DamageReportFunc damageReport, + DamageDestroyFunc damageDestroy, + DamageReportLevel damageLevel, + Bool isInternal, ScreenPtr pScreen, void *closure); + +extern _X_EXPORT void + DamageDrawInternal(ScreenPtr pScreen, Bool enable); + +extern _X_EXPORT void + DamageRegister(DrawablePtr pDrawable, DamagePtr pDamage); + +extern _X_EXPORT void + DamageUnregister(DamagePtr pDamage); + +extern _X_EXPORT void + DamageDestroy(DamagePtr pDamage); + +extern _X_EXPORT Bool + DamageSubtract(DamagePtr pDamage, const RegionPtr pRegion); + +extern _X_EXPORT void + DamageEmpty(DamagePtr pDamage); + +extern _X_EXPORT RegionPtr + DamageRegion(DamagePtr pDamage); + +extern _X_EXPORT RegionPtr + DamagePendingRegion(DamagePtr pDamage); + +/* In case of rendering, call this before the submitting the commands. */ +extern _X_EXPORT void + DamageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion); + +/* Call this directly after the rendering operation has been submitted. */ +extern _X_EXPORT void + DamageRegionProcessPending(DrawablePtr pDrawable); + +/* Call this when you create a new Damage and you wish to send an initial damage message (to it). */ +extern _X_EXPORT void + DamageReportDamage(DamagePtr pDamage, RegionPtr pDamageRegion); + +/* Avoid using this call, it only exists for API compatibility. */ +extern _X_EXPORT void + DamageDamageRegion(DrawablePtr pDrawable, const RegionPtr pRegion); + +extern _X_EXPORT void + DamageSetReportAfterOp(DamagePtr pDamage, Bool reportAfter); + +extern _X_EXPORT DamageScreenFuncsPtr DamageGetScreenFuncs(ScreenPtr); + +#endif /* _DAMAGE_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/damagestr.h b/prebuilt/xlibre/usr/include/xorg/damagestr.h new file mode 100644 index 0000000..e8c3a72 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/damagestr.h @@ -0,0 +1,110 @@ +/* + * Copyright © 2003 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +#ifndef _DAMAGESTR_H_ +#define _DAMAGESTR_H_ + +#include "damage.h" +#include "gcstruct.h" +#include "privates.h" +#include "picturestr.h" + +typedef struct _damage { + DamagePtr pNext; + DamagePtr pNextWin; + /* + * Drawable on which this damage was inserted. Used to re-derive the list head at removal time + * to avoid caching a pointer into a realloc()able privates array. + */ + DrawablePtr pListDrawable; + RegionRec damage; + + DamageReportLevel damageLevel; + Bool isInternal; + void *closure; + Bool isWindow; + DrawablePtr pDrawable; + + DamageReportFunc damageReport; + DamageDestroyFunc damageDestroy; + + Bool reportAfter; + RegionRec pendingDamage; /* will be flushed post submission at the latest */ + ScreenPtr pScreen; +} DamageRec; + +typedef struct _damageScrPriv { + int internalLevel; + + /* + * For DDXen which don't provide GetScreenPixmap, this provides + * a place to hook damage for windows on the screen + */ + DamagePtr pScreenDamage; + + CopyWindowProcPtr CopyWindow; + void *_dummy1; // required in place of a removed field for ABI compatibility + CreateGCProcPtr CreateGC; + void *_dummy2; // required in place of a removed field for ABI compatibility + SetWindowPixmapProcPtr SetWindowPixmap; + void *_dummy3; // required in place of a removed field for ABI compatibility + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; + AddTrapsProcPtr AddTraps; + + /* Table of wrappable function pointers */ + DamageScreenFuncsRec funcs; +} DamageScrPrivRec, *DamageScrPrivPtr; + +typedef struct _damageGCPriv { + const GCOps *ops; + const GCFuncs *funcs; +} DamageGCPrivRec, *DamageGCPrivPtr; + +/* XXX should move these into damage.c, damageScrPrivateIndex is static */ +#define damageGetScrPriv(pScr) ((DamageScrPrivPtr) \ + dixLookupPrivate(&(pScr)->devPrivates, damageScrPrivateKey)) + +#define damageScrPriv(pScr) \ + DamageScrPrivPtr pScrPriv = damageGetScrPriv((pScr)) + +#define damageGetPixPriv(pPix) \ + dixLookupPrivate(&(pPix)->devPrivates, damagePixPrivateKey) + +#define damgeSetPixPriv(pPix,v) \ + dixSetPrivate(&(pPix)->devPrivates, damagePixPrivateKey, (v)) + +#define damagePixPriv(pPix) \ + DamagePtr pDamage = damageGetPixPriv((pPix)) + +#define damageGetGCPriv(pGC) \ + dixLookupPrivate(&(pGC)->devPrivates, damageGCPrivateKey) + +#define damageGCPriv(pGC) \ + DamageGCPrivPtr pGCPriv = damageGetGCPriv((pGC)) + +#define damageGetWinPriv(pWin) \ + ((DamagePtr)dixLookupPrivate(&(pWin)->devPrivates, damageWinPrivateKey)) + +#define damageSetWinPriv(pWin,d) \ + dixSetPrivate(&(pWin)->devPrivates, damageWinPrivateKey, d) + +#endif /* _DAMAGESTR_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/displaymode.h b/prebuilt/xlibre/usr/include/xorg/displaymode.h new file mode 100644 index 0000000..c97a11e --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/displaymode.h @@ -0,0 +1,99 @@ +#ifndef _DISMODEPROC_H_ +#define _DISMODEPROC_H_ + +#include "scrnintstr.h" + +#define MAXCLOCKS 128 + +/* These are possible return values for xf86CheckMode() and ValidMode() */ +typedef enum { + MODE_OK = 0, /* Mode OK */ + MODE_HSYNC, /* hsync out of range */ + MODE_VSYNC, /* vsync out of range */ + MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_BAD_WIDTH, /* requires an unsupported linepitch */ + MODE_NOMODE, /* no mode with a matching name */ + MODE_NO_INTERLACE, /* interlaced mode not supported */ + MODE_NO_DBLESCAN, /* doublescan mode not supported */ + MODE_NO_VSCAN, /* multiscan mode not supported */ + MODE_MEM, /* insufficient video memory */ + MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ + MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ + MODE_MEM_VIRT, /* insufficient video memory given virtual size */ + MODE_NOCLOCK, /* no fixed clock available */ + MODE_CLOCK_HIGH, /* clock required is too high */ + MODE_CLOCK_LOW, /* clock required is too low */ + MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ + MODE_BAD_HVALUE, /* horizontal timing was out of range */ + MODE_BAD_VVALUE, /* vertical timing was out of range */ + MODE_BAD_VSCAN, /* VScan value out of range */ + MODE_HSYNC_NARROW, /* horizontal sync too narrow */ + MODE_HSYNC_WIDE, /* horizontal sync too wide */ + MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ + MODE_HBLANK_WIDE, /* horizontal blanking too wide */ + MODE_VSYNC_NARROW, /* vertical sync too narrow */ + MODE_VSYNC_WIDE, /* vertical sync too wide */ + MODE_VBLANK_NARROW, /* vertical blanking too narrow */ + MODE_VBLANK_WIDE, /* vertical blanking too wide */ + MODE_PANEL, /* exceeds panel dimensions */ + MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ + MODE_ONE_WIDTH, /* only one width is supported */ + MODE_ONE_HEIGHT, /* only one height is supported */ + MODE_ONE_SIZE, /* only one resolution is supported */ + MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ + MODE_BANDWIDTH, /* mode requires too much memory bandwidth */ + MODE_DUPLICATE, /* mode is duplicated */ + MODE_BAD = -2, /* unspecified reason */ + MODE_ERROR = -1 /* error condition */ +} ModeStatus; + +/* Video mode */ +typedef struct _DisplayModeRec { + struct _DisplayModeRec *prev; + struct _DisplayModeRec *next; + const char *name; /* identifier for the mode */ + ModeStatus status; + int type; + + /* These are the values that the user sees/provides */ + int Clock; /* pixel clock freq (kHz) */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int HSkew; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int VScan; + int Flags; + + /* These are the values the hardware uses */ + int ClockIndex; + int SynthClock; /* Actual clock freq to + * be programmed (kHz) */ + int CrtcHDisplay; + int CrtcHBlankStart; + int CrtcHSyncStart; + int CrtcHSyncEnd; + int CrtcHBlankEnd; + int CrtcHTotal; + int CrtcHSkew; + int CrtcVDisplay; + int CrtcVBlankStart; + int CrtcVSyncStart; + int CrtcVSyncEnd; + int CrtcVBlankEnd; + int CrtcVTotal; + Bool CrtcHAdjusted; + Bool CrtcVAdjusted; + int PrivSize; + INT32 *Private; + int PrivFlags; + + float HSync, VRefresh; +} DisplayModeRec, *DisplayModePtr; + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/dix.h b/prebuilt/xlibre/usr/include/xorg/dix.h new file mode 100644 index 0000000..1c8fe8e --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dix.h @@ -0,0 +1,229 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef DIX_H +#define DIX_H + +#include + +#include "xlibre_ptrtypes.h" + +#include "callback.h" +#include "gc.h" +#include "window.h" +#include "input.h" +#include "cursor.h" +#include "events.h" + +#define EARLIER -1 +#define SAMETIME 0 +#define LATER 1 + +#define REQUEST(type) \ + type * stuff = (type *)client->requestBuffer; + +/* Some platforms provide ARRAY_SIZE from a system header (e.g. illumos/Solaris + * ); don't redefine it there (-Werror). */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) +#endif + +#define REQUEST_SIZE_MATCH(req) \ + do { \ + if ((sizeof(req) >> 2) != client->req_len) \ + return(BadLength); \ + } while (0) + +#define REQUEST_AT_LEAST_SIZE(req) \ + do { \ + if ((sizeof(req) >> 2) > client->req_len) \ + return(BadLength); \ + } while (0) + +#define REQUEST_AT_LEAST_EXTRA_SIZE(req, extra) \ + do { \ + if (((sizeof(req) + ((uint64_t) (extra))) >> 2) > client->req_len) \ + return(BadLength); \ + } while (0) + +#define REQUEST_FIXED_SIZE(req, n) \ + do { \ + if ((((sizeof(req)) >> 2) > client->req_len) || \ + (((n) >> 2) >= client->req_len) || \ + ((((uint64_t) sizeof(req) + (n) + 3) >> 2) != (uint64_t) client->req_len)) \ + return(BadLength); \ + } while (0) + +typedef struct _TimeStamp *TimeStampPtr; + +extern _X_EXPORT ClientPtr clients[]; +extern _X_EXPORT ClientPtr serverClient; +extern _X_EXPORT int currentMaxClients; + +typedef struct _TimeStamp { + CARD32 months; /* really ~49.7 days */ + CARD32 milliseconds; +} TimeStamp; + +/* dispatch.c */ +extern _X_EXPORT void UpdateCurrentTime(void); + +extern _X_EXPORT void UpdateCurrentTimeIf(void); + +/* + * @brief dereference a pixmap and destroy it when not used anymore + * + * Despite the name, this function unref's the pixmap, and only destroys it when + * the pixmap isn't used anymore. (perhaps it should be renamed to dixUnrefPixmap()) + * + * Note: it's also used as resource destructor callback, hence that strange args. + * (not actually finest art, but for now a good compromise, since it's already + * existing and exported, thus can easily be used by drivers, w/o breaking compat) + * + * @param pPixmap pointer to pixmap (PixmapPtr) that should be unref'ed + * @param unused ignored, only for matching the resource destructor prototype + */ +_X_EXPORT int dixDestroyPixmap(void *pPixmap, XID unused); + +/* dixutils.c */ + +extern _X_EXPORT int dixLookupWindow(WindowPtr *result, + XID id, + ClientPtr client, Mask access_mode); + +extern _X_EXPORT int dixLookupDrawable(DrawablePtr *result, + XID id, + ClientPtr client, + Mask type_mask, Mask access_mode); + +extern _X_EXPORT int dixLookupFontable(FontPtr *result, + XID id, + ClientPtr client, Mask access_mode); + +extern _X_EXPORT void NoopDDA(void); + +typedef void (*ServerBlockHandlerProcPtr) (void *blockData, + void *timeout); + +typedef void (*ServerWakeupHandlerProcPtr) (void *blockData, + int result); + +extern _X_EXPORT Bool RegisterBlockAndWakeupHandlers(ServerBlockHandlerProcPtr blockHandler, + ServerWakeupHandlerProcPtr wakeupHandler, + void *blockData); + +extern _X_EXPORT void RemoveBlockAndWakeupHandlers(ServerBlockHandlerProcPtr blockHandler, + ServerWakeupHandlerProcPtr wakeupHandler, + void *blockData); + +extern _X_EXPORT Bool QueueWorkProc(Bool (*function)(ClientPtr clientUnused, + void *closure), + ClientPtr client, + void *closure); + +/* atom.c */ + +extern _X_EXPORT Atom MakeAtom(const char * /*string */ , + unsigned /*len */ , + Bool /*makeit */ ); + +extern _X_EXPORT Bool ValidAtom(Atom /*atom */ ); + +extern _X_EXPORT const char *NameForAtom(Atom /*atom */ ); + +/* events.c */ + +extern _X_EXPORT void +WriteEventsToClient(ClientPtr /*pClient */ , + int /*count */ , + xEventPtr /*events */ ); + +/* + * ServerGrabCallback stuff + */ + +extern _X_EXPORT CallbackListPtr ServerGrabCallback; + +typedef enum { SERVER_GRABBED, SERVER_UNGRABBED, + CLIENT_PERVIOUS, CLIENT_IMPERVIOUS +} ServerGrabState; + +typedef struct { + ClientPtr client; + ServerGrabState grabstate; +} ServerGrabInfoRec; + +/* + * EventCallback stuff + */ + +extern _X_EXPORT CallbackListPtr EventCallback; + +typedef struct { + ClientPtr client; + xEventPtr events; + int count; +} EventInfoRec; + +typedef struct { + InternalEvent *event; + DeviceIntPtr device; +} DeviceEventInfoRec; + +extern _X_EXPORT void *lastGLContext; + +/** + * @brief get display string for given screen + * + * Entry point for drivers/modules that really need to know what + * display ID we're running on (eg. xrdp). + * + * @param pScreen pointer to ScreenRec to query. + * @return pointer to string, valid as long as the pScreen is, owned by DIX. + */ +_X_EXPORT const char *dixGetDisplayName(ScreenPtr *pScreen); + +#endif /* DIX_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/dixaccess.h b/prebuilt/xlibre/usr/include/xorg/dixaccess.h new file mode 100644 index 0000000..784c83c --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dixaccess.h @@ -0,0 +1,54 @@ +/*********************************************************** + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef DIX_ACCESS_H +#define DIX_ACCESS_H + +/* These are the access modes that can be passed in the last parameter + * to several of the dix lookup functions. They were originally part + * of the Security extension, now used by XACE. + * + * You can or these values together to indicate multiple modes + * simultaneously. + */ + +#define DixUnknownAccess 0 /* don't know intentions */ +#define DixReadAccess (1<<0) /* inspecting the object */ +#define DixWriteAccess (1<<1) /* changing the object */ +#define DixDestroyAccess (1<<2) /* destroying the object */ +#define DixCreateAccess (1<<3) /* creating the object */ +#define DixGetAttrAccess (1<<4) /* get object attributes */ +#define DixSetAttrAccess (1<<5) /* set object attributes */ +#define DixListPropAccess (1<<6) /* list properties of object */ +#define DixGetPropAccess (1<<7) /* get properties of object */ +#define DixSetPropAccess (1<<8) /* set properties of object */ +#define DixGetFocusAccess (1<<9) /* get focus of object */ +#define DixSetFocusAccess (1<<10) /* set focus of object */ +#define DixListAccess (1<<11) /* list objects */ +#define DixAddAccess (1<<12) /* add object */ +#define DixRemoveAccess (1<<13) /* remove object */ +#define DixHideAccess (1<<14) /* hide object */ +#define DixShowAccess (1<<15) /* show object */ +#define DixBlendAccess (1<<16) /* mix contents of objects */ +#define DixGrabAccess (1<<17) /* exclusive access to object */ +#define DixFreezeAccess (1<<18) /* freeze status of object */ +#define DixForceAccess (1<<19) /* force status of object */ +#define DixInstallAccess (1<<20) /* install object */ +#define DixUninstallAccess (1<<21) /* uninstall object */ +#define DixSendAccess (1<<22) /* send to object */ +#define DixReceiveAccess (1<<23) /* receive from object */ +#define DixUseAccess (1<<24) /* use object */ +#define DixManageAccess (1<<25) /* manage object */ +#define DixDebugAccess (1<<26) /* debug object */ +#define DixBellAccess (1<<27) /* audible sound */ +#define DixPostAccess (1<<28) /* post or follow-up call */ + +#endif /* DIX_ACCESS_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/dixfont.h b/prebuilt/xlibre/usr/include/xorg/dixfont.h new file mode 100644 index 0000000..a161a26 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dixfont.h @@ -0,0 +1,93 @@ +/*********************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef DIXFONT_H +#define DIXFONT_H 1 + +#include "xlibre_ptrtypes.h" + +#include "dix.h" +#include +#include + +extern _X_EXPORT Bool SetDefaultFont(const char * /*defaultfontname */ ); + +extern _X_EXPORT int OpenFont(ClientPtr /*client */ , + XID /*fid */ , + Mask /*flags */ , + unsigned /*lenfname */ , + const char * /*pfontname */ ); + +extern _X_EXPORT int CloseFont(void *pfont, + XID fid); + +extern _X_EXPORT int ListFonts(ClientPtr /*client */ , + unsigned char * /*pattern */ , + unsigned int /*length */ , + unsigned int /*max_names */ ); + +extern _X_EXPORT int PolyText(ClientPtr /*client */ , + DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + unsigned char * /*pElt */ , + unsigned char * /*endReq */ , + int /*xorg */ , + int /*yorg */ , + int /*reqType */ , + XID /*did */ ); + +extern _X_EXPORT int ImageText(ClientPtr /*client */ , + DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*nChars */ , + unsigned char * /*data */ , + int /*xorg */ , + int /*yorg */ , + int /*reqType */ , + XID /*did */ ); + +extern _X_EXPORT int SetFontPath(ClientPtr /*client */ , + int /*npaths */ , + unsigned char * /*paths */ ); + +extern _X_EXPORT int SetDefaultFontPath(const char * /*path */ ); + +extern _X_EXPORT void DeleteClientFontStuff(ClientPtr /*client */ ); + +/* Quartz support on Mac OS X pulls in the QuickDraw + framework whose InitFonts function conflicts here. */ +#ifdef __APPLE__ +#define InitFonts Darwin_X_InitFonts +#endif +extern _X_EXPORT void InitFonts(void); + +extern _X_EXPORT void FreeFonts(void); + +extern _X_EXPORT void GetGlyphs(FontPtr /*font */ , + unsigned long /*count */ , + unsigned char * /*chars */ , + FontEncoding /*fontEncoding */ , + unsigned long * /*glyphcount */ , + CharInfoPtr * /*glyphs */ ); + +#endif /* DIXFONT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/dixfontstr.h b/prebuilt/xlibre/usr/include/xorg/dixfontstr.h new file mode 100644 index 0000000..ded864a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dixfontstr.h @@ -0,0 +1,70 @@ +/*********************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef DIXFONTSTRUCT_H +#define DIXFONTSTRUCT_H + +#include "servermd.h" +#include "dixfont.h" +#include +#include /* for xQueryFontReply */ + +#define FONTCHARSET(font) (font) +#define FONTMAXBOUNDS(font,field) (font)->info.maxbounds.field +#define FONTMINBOUNDS(font,field) (font)->info.minbounds.field +#define TERMINALFONT(font) (font)->info.terminalFont +#define FONTASCENT(font) (font)->info.fontAscent +#define FONTDESCENT(font) (font)->info.fontDescent +#define FONTGLYPHS(font) 0 +#define FONTCONSTMETRICS(font) (font)->info.constantMetrics +#define FONTCONSTWIDTH(font) (font)->info.constantWidth +#define FONTALLEXIST(font) (font)->info.allExist +#define FONTFIRSTCOL(font) (font)->info.firstCol +#define FONTLASTCOL(font) (font)->info.lastCol +#define FONTFIRSTROW(font) (font)->info.firstRow +#define FONTLASTROW(font) (font)->info.lastRow +#define FONTDEFAULTCH(font) (font)->info.defaultCh +#define FONTINKMIN(font) (&((font)->info.ink_minbounds)) +#define FONTINKMAX(font) (&((font)->info.ink_maxbounds)) +#define FONTPROPS(font) (font)->info.props +#define FONTGLYPHBITS(base,pci) ((unsigned char *) (pci)->bits) +#define FONTINFONPROPS(font) (font)->info.nprops + +/* some things haven't changed names, but we'll be careful anyway */ + +#define FONTREFCNT(font) (font)->refcnt + +/* + * for linear char sets + */ +#define N1dChars(pfont) (FONTLASTCOL((pfont)) - FONTFIRSTCOL((pfont)) + 1) + +/* + * for 2D char sets + */ +#define N2dChars(pfont) (N1dChars((pfont)) * \ + (FONTLASTROW((pfont)) - FONTFIRSTROW((pfont)) + 1)) + +#define GLYPHWIDTHBYTESPADDED(pci) ((GLYPHWIDTHBYTES((pci))+3) & ~0x3) + +#endif /* DIXFONTSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/dixstruct.h b/prebuilt/xlibre/usr/include/xorg/dixstruct.h new file mode 100644 index 0000000..ffe858d --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dixstruct.h @@ -0,0 +1,123 @@ +/*********************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef DIXSTRUCT_H +#define DIXSTRUCT_H + +#include + +#include "xlibre_ptrtypes.h" + +#include "callback.h" +#include "dix.h" +#include "resource.h" +#include "cursor.h" +#include "gc.h" +#include "pixmap.h" +#include "privates.h" + +/* + * direct-mapped hash table, used by resource manager to store + * translation from client ids to server addresses. + */ + +extern _X_EXPORT CallbackListPtr ClientStateCallback; + +typedef struct { + ClientPtr client; + xConnSetupPrefix *prefix; + xConnSetup *setup; +} NewClientInfoRec; + +typedef void (*ReplySwapPtr) (ClientPtr /* pClient */ , + int /* size */ , + void * /* pbuf */ ); + +typedef enum { ClientStateInitial, + ClientStateRunning, + ClientStateRetained, + ClientStateGone +} ClientState; + +struct _Client { + void *requestBuffer; + void *osPrivate; /* for OS layer, including scheduler */ + struct xorg_list ready; /* List of clients ready to run */ + struct xorg_list output_pending; /* List of clients with output queued */ + Mask clientAsMask; + unsigned short index; + unsigned char majorOp, minorOp; + unsigned int swapped:1; + unsigned int local:1; + unsigned int big_requests:1; /* supports large requests */ + unsigned int clientGone:1; + unsigned int closeDownMode:2; + unsigned int clientState:2; + signed char smart_priority; + short noClientException; /* this client died or needs to be killed */ + int priority; + ReplySwapPtr pSwapReplyFunc; + XID errorValue; + int sequence; + int ignoreCount; /* count for Attend/IgnoreClient */ + int __dummy0; /* used to be numSave */ + void *__dummy1; /* used to be saveSet */ + int (**requestVector) (ClientPtr /* pClient */ ); + CARD32 req_len; /* length of current request */ + unsigned int replyBytesRemaining; + PrivateRec *devPrivates; + unsigned short mapNotifyMask; + unsigned short newKeyboardNotifyMask; + unsigned char xkbClientFlags; + KeyCode minKC, maxKC; + + int smart_start_tick; + int smart_stop_tick; + + DeviceIntPtr clientPtr; + struct _ClientId *clientIds; + int req_fds; + + /* driver should never ever touch anything beyond here */ + struct xorg_list saveSets; +}; + +extern _X_EXPORT TimeStamp currentTime; + +extern _X_EXPORT int +CompareTimeStamps(TimeStamp /*a */ , + TimeStamp /*b */ ); + +extern _X_EXPORT TimeStamp +ClientTimeToServerTime(CARD32 /*c */ ); + +/* proc vectors */ + +extern _X_EXPORT int (*ProcVector[256]) (ClientPtr /*client */ ); + +extern _X_EXPORT int (*SwappedProcVector[256]) (ClientPtr /*client */ ); + +/* fixme: still needed by (public) dix.h */ +extern ReplySwapPtr ReplySwapVector[256]; + +#endif /* DIXSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/dri.h b/prebuilt/xlibre/usr/include/xorg/dri.h new file mode 100644 index 0000000..0dc4036 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dri.h @@ -0,0 +1,336 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Jens Owen + * + */ + +#ifndef _DRI_H_ +#define _DRI_H_ + +#include + +#include "scrnintstr.h" +#include "xf86dri.h" + +/* Prototypes for DRI functions */ + +typedef int DRISyncType; + +#define DRI_NO_SYNC 0 +#define DRI_2D_SYNC 1 +#define DRI_3D_SYNC 2 + +typedef int DRIContextType; + +typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr; + +typedef enum _DRIContextFlags { + DRI_CONTEXT_2DONLY = 0x01, + DRI_CONTEXT_PRESERVED = 0x02, + DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */ +} DRIContextFlags; + +#define DRI_NO_CONTEXT 0 +#define DRI_2D_CONTEXT 1 +#define DRI_3D_CONTEXT 2 + +typedef int DRISwapMethod; + +#define DRI_HIDE_X_CONTEXT 0 +#define DRI_SERVER_SWAP 1 +#define DRI_KERNEL_SWAP 2 + +typedef int DRIWindowRequests; + +#define DRI_NO_WINDOWS 0 +#define DRI_3D_WINDOWS_ONLY 1 +#define DRI_ALL_WINDOWS 2 + +typedef void (*ClipNotifyPtr) (WindowPtr, int, int); +typedef void (*AdjustFramePtr) (ScrnInfoPtr pScrn, int x, int y); + +/* + * These functions can be wrapped by the DRI. Each of these have + * generic default funcs (initialized in DRICreateInfoRec) and can be + * overridden by the driver in its [driver]DRIScreenInit function. + */ +typedef struct { + ScreenWakeupHandlerProcPtr WakeupHandler; + ScreenBlockHandlerProcPtr BlockHandler; + WindowExposuresProcPtr WindowExposures; + CopyWindowProcPtr CopyWindow; + ClipNotifyProcPtr ClipNotify; + AdjustFramePtr AdjustFrame; +} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr; + +/* + * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned + * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also + * being used to version the XFree86-DRI protocol. Bugs #3066 and #3163 + * showed that this was inadequate. The DRIInfoRec structure is now versioned + * by the DRIINFO_*_VERSION defines in this file. - ajax, 2005-05-18. + * + * Revision history: + * 4.1.0 and earlier: DRIQueryVersion returns XF86DRI_*_VERSION. + * 4.2.0: DRIQueryVersion begins returning DRIINFO_*_VERSION. + * 5.0.0: frameBufferPhysicalAddress changed from CARD32 to pointer. + */ + +#define DRIINFO_MAJOR_VERSION 5 +#define DRIINFO_MINOR_VERSION 4 +#define DRIINFO_PATCH_VERSION 0 + +typedef unsigned long long (*DRITexOffsetStartProcPtr) (PixmapPtr pPix); +typedef void (*DRITexOffsetFinishProcPtr) (PixmapPtr pPix); + +typedef struct { + /* driver call back functions + * + * New fields should be added at the end for backwards compatibility. + * Bump the DRIINFO patch number to indicate bugfixes. + * Bump the DRIINFO minor number to indicate new fields. + * Bump the DRIINFO major number to indicate binary-incompatible changes. + */ + Bool (*CreateContext) (ScreenPtr pScreen, + VisualPtr visual, + drm_context_t hHWContext, + void *pVisualConfigPriv, DRIContextType context); + void (*DestroyContext) (ScreenPtr pScreen, + drm_context_t hHWContext, DRIContextType context); + void (*SwapContext) (ScreenPtr pScreen, + DRISyncType syncType, + DRIContextType readContextType, + void *readContextStore, + DRIContextType writeContextType, + void *writeContextStore); + void (*InitBuffers) (WindowPtr pWin, RegionPtr prgn, CARD32 indx); + void (*MoveBuffers) (WindowPtr pWin, xPoint ptOldOrg, RegionPtr prgnSrc, CARD32 indx); + void (*TransitionTo3d) (ScreenPtr pScreen); + void (*TransitionTo2d) (ScreenPtr pScreen); + + void (*SetDrawableIndex) (WindowPtr pWin, CARD32 indx); + Bool (*OpenFullScreen) (ScreenPtr pScreen); + Bool (*CloseFullScreen) (ScreenPtr pScreen); + + /* wrapped functions */ + DRIWrappedFuncsRec wrap; + + /* device info */ + char *drmDriverName; + char *clientDriverName; + char *busIdString; + int ddxDriverMajorVersion; + int ddxDriverMinorVersion; + int ddxDriverPatchVersion; + void *frameBufferPhysicalAddress; + long frameBufferSize; + long frameBufferStride; + long SAREASize; + int maxDrawableTableEntry; + int ddxDrawableTableEntry; + long contextSize; + DRISwapMethod driverSwapMethod; + DRIWindowRequests bufferRequests; + int devPrivateSize; + void *devPrivate; + Bool createDummyCtx; + Bool createDummyCtxPriv; + + /* New with DRI version 4.1.0 */ + void (*TransitionSingleToMulti3D) (ScreenPtr pScreen); + void (*TransitionMultiToSingle3D) (ScreenPtr pScreen); + + /* New with DRI version 5.1.0 */ + void (*ClipNotify) (ScreenPtr pScreen, WindowPtr *ppWin, int num); + + /* New with DRI version 5.2.0 */ + Bool allocSarea; + Bool keepFDOpen; + + /* New with DRI version 5.3.0 */ + DRITexOffsetStartProcPtr texOffsetStart; + DRITexOffsetFinishProcPtr texOffsetFinish; + + /* New with DRI version 5.4.0 */ + int dontMapFrameBuffer; + drm_handle_t hFrameBuffer; /* Handle to framebuffer, either + * mapped by DDX driver or DRI */ + +} DRIInfoRec, *DRIInfoPtr; + +extern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, + unsigned long sAreaSize, + const char *busID, + const char *drmDriverName); + +extern _X_EXPORT Bool DRIScreenInit(ScreenPtr pScreen, + DRIInfoPtr pDRIInfo, int *pDRMFD); + +extern _X_EXPORT void DRICloseScreen(ScreenPtr pScreen); + +extern _X_EXPORT void DRIReset(void); + +extern _X_EXPORT Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, + Bool *isCapable); + +extern _X_EXPORT Bool DRIOpenConnection(ScreenPtr pScreen, + drm_handle_t * hSAREA, + char **busIdString); + +extern _X_EXPORT Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic); + +extern _X_EXPORT Bool DRICloseConnection(ScreenPtr pScreen); + +extern _X_EXPORT Bool DRIGetClientDriverName(ScreenPtr pScreen, + int *ddxDriverMajorVersion, + int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, + char **clientDriverName); + +extern _X_EXPORT Bool DRICreateContext(ScreenPtr pScreen, + VisualPtr visual, + XID context, drm_context_t * pHWContext); + +extern _X_EXPORT Bool DRIDestroyContext(ScreenPtr pScreen, XID context); + +extern _X_EXPORT Bool DRIContextPrivDelete(void *pResource, XID id); + +extern _X_EXPORT Bool DRICreateDrawable(ScreenPtr pScreen, + ClientPtr client, + DrawablePtr pDrawable, + drm_drawable_t * hHWDrawable); + +extern _X_EXPORT Bool DRIDestroyDrawable(ScreenPtr pScreen, + ClientPtr client, + DrawablePtr pDrawable); + +extern _X_EXPORT Bool DRIDrawablePrivDelete(void *pResource, XID id); + +extern _X_EXPORT Bool DRIGetDrawableInfo(ScreenPtr pScreen, + DrawablePtr pDrawable, + unsigned int *indx, + unsigned int *stamp, + int *X, + int *Y, + int *W, + int *H, + int *numClipRects, + drm_clip_rect_t ** pClipRects, + int *backX, + int *backY, + int *numBackClipRects, + drm_clip_rect_t ** pBackClipRects); + +extern _X_EXPORT Bool DRIGetDeviceInfo(ScreenPtr pScreen, + drm_handle_t * hFrameBuffer, + int *fbOrigin, + int *fbSize, + int *fbStride, + int *devPrivateSize, void **pDevPrivate); + +extern _X_EXPORT DRIInfoPtr DRICreateInfoRec(void); + +extern _X_EXPORT void DRIDestroyInfoRec(DRIInfoPtr DRIInfo); + +extern _X_EXPORT Bool DRIFinishScreenInit(ScreenPtr pScreen); + +extern _X_EXPORT void DRIWakeupHandler(void *wakeupData, int result); + +extern _X_EXPORT void DRIBlockHandler(void *blockData, void *timeout); + +extern _X_EXPORT void DRIDoWakeupHandler(ScreenPtr pScreen, int result); + +extern _X_EXPORT void DRIDoBlockHandler(ScreenPtr pScreen, void *timeout); + +extern _X_EXPORT void DRISwapContext(int drmFD, void *oldctx, void *newctx); + +extern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context); + +extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn); + +extern _X_EXPORT void DRICopyWindow(WindowPtr pWin, + xPoint ptOldOrg, RegionPtr prgnSrc); + +extern _X_EXPORT void DRIClipNotify(WindowPtr pWin, int dx, int dy); + +extern _X_EXPORT CARD32 DRIGetDrawableIndex(WindowPtr pWin); + +extern _X_EXPORT void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg); + +extern _X_EXPORT void DRILock(ScreenPtr pScreen, int flags); + +extern _X_EXPORT void DRIUnlock(ScreenPtr pScreen); + +extern _X_EXPORT DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen); + +extern _X_EXPORT void *DRIGetSAREAPrivate(ScreenPtr pScreen); + +extern _X_EXPORT unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, + CARD32 drawable_index); + +extern _X_EXPORT DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, + drm_context_t * + pHWContext, + DRIContextFlags flags); + +extern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr + pScreen, + drm_context_t + hHWContext, + DRIContextFlags + flags); + +extern _X_EXPORT Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); + +extern _X_EXPORT drm_context_t DRIGetContext(ScreenPtr pScreen); + +extern _X_EXPORT void DRIQueryVersion(int *majorVersion, + int *minorVersion, int *patchVersion); + +extern _X_EXPORT void DRIAdjustFrame(ScrnInfoPtr pScrn, int x, int y); + +extern _X_EXPORT void DRIMoveBuffersHelper(ScreenPtr pScreen, + int dx, + int dy, + int *xdir, int *ydir, RegionPtr reg); + +extern _X_EXPORT int DRIMasterFD(ScrnInfoPtr pScrn); + +extern _X_EXPORT void *DRIMasterSareaPointer(ScrnInfoPtr pScrn); + +extern _X_EXPORT drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn); + +extern _X_EXPORT void DRIGetTexOffsetFuncs(ScreenPtr pScreen, + DRITexOffsetStartProcPtr * + texOffsetStartFunc, + DRITexOffsetFinishProcPtr * + texOffsetFinishFunc); + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/dri2.h b/prebuilt/xlibre/usr/include/xorg/dri2.h new file mode 100644 index 0000000..8582a61 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dri2.h @@ -0,0 +1,361 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifndef _DRI2_H_ +#define _DRI2_H_ + +#include + +#include "dix.h" + +/* Version 2 structure (with format at the end) */ +typedef struct { + unsigned int attachment; + unsigned int name; + unsigned int pitch; + unsigned int cpp; + unsigned int flags; + unsigned int format; + void *driverPrivate; +} DRI2BufferRec, *DRI2BufferPtr; + +typedef DRI2BufferRec DRI2Buffer2Rec, *DRI2Buffer2Ptr; +typedef void (*DRI2SwapEventPtr) (ClientPtr client, void *data, int type, + CARD64 ust, CARD64 msc, CARD32 sbc); + +typedef DRI2BufferPtr(*DRI2CreateBuffersProcPtr) (DrawablePtr pDraw, + unsigned int *attachments, + int count); +typedef void (*DRI2DestroyBuffersProcPtr) (DrawablePtr pDraw, + DRI2BufferPtr buffers, int count); +typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw, + RegionPtr pRegion, + DRI2BufferPtr pDestBuffer, + DRI2BufferPtr pSrcBuffer); +typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence); +typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic); +typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, uint32_t magic); + +/** + * Schedule a buffer swap + * + * This callback is used to support glXSwapBuffers and the OML_sync_control + * extension (see it for a description of the params). + * + * Drivers should queue an event for the frame count that satisfies the + * parameters passed in. If the event is in the future (i.e. the conditions + * aren't currently satisfied), the server may block the client at the next + * GLX request using DRI2WaitSwap. When the event arrives, drivers should call + * \c DRI2SwapComplete, which will handle waking the client and returning + * the appropriate data. + * + * The DDX is responsible for doing a flip, exchange, or blit of the swap + * when the corresponding event arrives. The \c DRI2CanFlip and + * \c DRI2CanExchange functions can be used as helpers for this purpose. + * + * \param client client pointer (used for block/unblock) + * \param pDraw drawable whose count we want + * \param pDestBuffer current front buffer + * \param pSrcBuffer current back buffer + * \param target_msc frame count to wait for + * \param divisor divisor for condition equation + * \param remainder remainder for division equation + * \param func function to call when the swap completes + * \param data data for the callback \p func. + */ +typedef int (*DRI2ScheduleSwapProcPtr) (ClientPtr client, + DrawablePtr pDraw, + DRI2BufferPtr pDestBuffer, + DRI2BufferPtr pSrcBuffer, + CARD64 * target_msc, + CARD64 divisor, + CARD64 remainder, + DRI2SwapEventPtr func, void *data); +typedef DRI2BufferPtr(*DRI2CreateBufferProcPtr) (DrawablePtr pDraw, + unsigned int attachment, + unsigned int format); +typedef void (*DRI2DestroyBufferProcPtr) (DrawablePtr pDraw, + DRI2BufferPtr buffer); +/** + * Notifies driver when DRI2GetBuffers reuses a dri2 buffer. + * + * Driver may rename the dri2 buffer in this notify if it is required. + * + * \param pDraw drawable whose count we want + * \param buffer buffer that will be returned to client + */ +typedef void (*DRI2ReuseBufferNotifyProcPtr) (DrawablePtr pDraw, + DRI2BufferPtr buffer); +/** + * Get current media stamp counter values + * + * This callback is used to support the SGI_video_sync and OML_sync_control + * extensions. + * + * Drivers should return the current frame counter and the timestamp from + * when the returned frame count was last incremented. + * + * The count should correspond to the screen where the drawable is currently + * visible. If the drawable isn't visible (e.g. redirected), the server + * should return BadDrawable to the client, pending GLX spec updates to + * define this behavior. + * + * \param pDraw drawable whose count we want + * \param ust timestamp from when the count was last incremented. + * \param mst current frame count + */ +typedef int (*DRI2GetMSCProcPtr) (DrawablePtr pDraw, CARD64 * ust, + CARD64 * msc); +/** + * Schedule a frame count related wait + * + * This callback is used to support the SGI_video_sync and OML_sync_control + * extensions. See those specifications for details on how to handle + * the divisor and remainder parameters. + * + * Drivers should queue an event for the frame count that satisfies the + * parameters passed in. If the event is in the future (i.e. the conditions + * aren't currently satisfied), the driver should block the client using + * \c DRI2BlockClient. When the event arrives, drivers should call + * \c DRI2WaitMSCComplete, which will handle waking the client and returning + * the appropriate data. + * + * \param client client pointer (used for block/unblock) + * \param pDraw drawable whose count we want + * \param target_msc frame count to wait for + * \param divisor divisor for condition equation + * \param remainder remainder for division equation + */ +typedef int (*DRI2ScheduleWaitMSCProcPtr) (ClientPtr client, + DrawablePtr pDraw, + CARD64 target_msc, + CARD64 divisor, CARD64 remainder); + +typedef void (*DRI2InvalidateProcPtr) (DrawablePtr pDraw, void *data, XID id); + +/** + * DRI2 calls this hook when ever swap_limit is going to be changed. Default + * implementation for the hook only accepts one as swap_limit. If driver can + * support other swap_limits it has to implement supported limits with this + * callback. + * + * \param pDraw drawable whose swap_limit is going to be changed + * \param swap_limit new swap_limit that going to be set + * \return TRUE if limit is support, FALSE if not. + */ +typedef Bool (*DRI2SwapLimitValidateProcPtr) (DrawablePtr pDraw, + int swap_limit); + +typedef DRI2BufferPtr(*DRI2CreateBuffer2ProcPtr) (ScreenPtr pScreen, + DrawablePtr pDraw, + unsigned int attachment, + unsigned int format); +typedef void (*DRI2DestroyBuffer2ProcPtr) (ScreenPtr pScreen, DrawablePtr pDraw, + DRI2BufferPtr buffer); + +typedef void (*DRI2CopyRegion2ProcPtr) (ScreenPtr pScreen, DrawablePtr pDraw, + RegionPtr pRegion, + DRI2BufferPtr pDestBuffer, + DRI2BufferPtr pSrcBuffer); + +/** + * \brief Get the value of a parameter. + * + * The parameter's \a value is looked up on the screen associated with + * \a pDrawable. + * + * \return \c Success or error code. + */ +typedef int (*DRI2GetParamProcPtr) (ClientPtr client, + DrawablePtr pDrawable, + CARD64 param, + BOOL *is_param_recognized, + CARD64 *value); + +/** + * Version of the DRI2InfoRec structure defined in this header + */ +#define DRI2INFOREC_VERSION 9 + +typedef struct { + unsigned int version; /**< Version of this struct */ + int fd; + const char *driverName; + const char *deviceName; + + DRI2CreateBufferProcPtr CreateBuffer; + DRI2DestroyBufferProcPtr DestroyBuffer; + DRI2CopyRegionProcPtr CopyRegion; + DRI2WaitProcPtr Wait; + + /* added in version 4 */ + + DRI2ScheduleSwapProcPtr ScheduleSwap; + DRI2GetMSCProcPtr GetMSC; + DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC; + + /* number of drivers in the driverNames array */ + unsigned int numDrivers; + /* array of driver names, indexed by DRI2Driver* driver types */ + /* a name of NULL means that driver is not supported */ + const char *const *driverNames; + + /* added in version 5 */ + + DRI2AuthMagicProcPtr AuthMagic; + + /* added in version 6 */ + + DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify; + DRI2SwapLimitValidateProcPtr SwapLimitValidate; + + /* added in version 7 */ + DRI2GetParamProcPtr GetParam; + + /* added in version 8 */ + /* AuthMagic callback which passes extra context */ + /* If this is NULL the AuthMagic callback is used */ + /* If this is non-NULL the AuthMagic callback is ignored */ + DRI2AuthMagic2ProcPtr AuthMagic2; + + /* added in version 9 */ + DRI2CreateBuffer2ProcPtr CreateBuffer2; + DRI2DestroyBuffer2ProcPtr DestroyBuffer2; + DRI2CopyRegion2ProcPtr CopyRegion2; +} DRI2InfoRec, *DRI2InfoPtr; + +extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info); + +extern _X_EXPORT void DRI2CloseScreen(ScreenPtr pScreen); + +extern _X_EXPORT Bool DRI2HasSwapControl(ScreenPtr pScreen); + +extern _X_EXPORT Bool DRI2Connect(ClientPtr client, ScreenPtr pScreen, + unsigned int driverType, + int *fd, + const char **driverName, + const char **deviceName); + +extern _X_EXPORT Bool DRI2Authenticate(ClientPtr client, ScreenPtr pScreen, uint32_t magic); + +extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client, + DrawablePtr pDraw, + XID id, + DRI2InvalidateProcPtr invalidate, + void *priv); + +extern _X_EXPORT int DRI2CreateDrawable2(ClientPtr client, + DrawablePtr pDraw, + XID id, + DRI2InvalidateProcPtr invalidate, + void *priv, + XID *dri2_id_out); + +extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffers(DrawablePtr pDraw, + int *width, + int *height, + unsigned int *attachments, + int count, int *out_count); + +extern _X_EXPORT int DRI2CopyRegion(DrawablePtr pDraw, + RegionPtr pRegion, + unsigned int dest, unsigned int src); + +/** + * Determine the major and minor version of the DRI2 extension. + * + * Provides a mechanism to other modules (e.g., 2D drivers) to determine the + * version of the DRI2 extension. While it is possible to peek directly at + * the \c XF86ModuleData from a layered module, such a module will fail to + * load (due to an unresolved symbol) if the DRI2 extension is not loaded. + * + * \param major Location to store the major version of the DRI2 extension + * \param minor Location to store the minor version of the DRI2 extension + * + * \note + * This interface was added some time after the initial release of the DRI2 + * module. Layered modules that wish to use this interface must first test + * its existence by calling \c xf86LoaderCheckSymbol. + */ +extern _X_EXPORT void DRI2Version(int *major, int *minor); + +extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw, + int *width, + int *height, + unsigned int + *attachments, + int count, + int *out_count); + +extern _X_EXPORT void DRI2SwapInterval(DrawablePtr pDrawable, int interval); +extern _X_EXPORT Bool DRI2SwapLimit(DrawablePtr pDraw, int swap_limit); +extern _X_EXPORT int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDrawable, + CARD64 target_msc, CARD64 divisor, + CARD64 remainder, CARD64 * swap_target, + DRI2SwapEventPtr func, void *data); +extern _X_EXPORT Bool DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable); + +extern _X_EXPORT int DRI2GetMSC(DrawablePtr pDrawable, CARD64 * ust, + CARD64 * msc, CARD64 * sbc); +extern _X_EXPORT int DRI2WaitMSC(ClientPtr client, DrawablePtr pDrawable, + CARD64 target_msc, CARD64 divisor, + CARD64 remainder); +extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust, + CARD64 msc, CARD64 sbc); +extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, + CARD64 target_sbc); +extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw); + +extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw); + +extern _X_EXPORT Bool DRI2CanExchange(DrawablePtr pDraw); + +/* Note: use *only* for MSC related waits */ +extern _X_EXPORT void DRI2BlockClient(ClientPtr client, DrawablePtr pDraw); + +extern _X_EXPORT void DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, + int frame, unsigned int tv_sec, + unsigned int tv_usec, int type, + DRI2SwapEventPtr swap_complete, + void *swap_data); +extern _X_EXPORT void DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, + int frame, unsigned int tv_sec, + unsigned int tv_usec); + +extern _X_EXPORT int DRI2GetParam(ClientPtr client, + DrawablePtr pDrawable, + CARD64 param, + BOOL *is_param_recognized, + CARD64 *value); + +extern _X_EXPORT DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest); +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/dri3.h b/prebuilt/xlibre/usr/include/xorg/dri3.h new file mode 100644 index 0000000..63e47b9 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dri3.h @@ -0,0 +1,131 @@ +/* + * Copyright © 2013 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _DRI3_H_ +#define _DRI3_H_ + +#include +#include + +#define DRI3_SCREEN_INFO_VERSION 4 + +struct dri3_syncobj +{ + XID id; + ScreenPtr screen; + uint32_t refcount; + + void (*free)(struct dri3_syncobj *syncobj); + Bool (*has_fence)(struct dri3_syncobj *syncobj, uint64_t point); + Bool (*is_signaled)(struct dri3_syncobj *syncobj, uint64_t point); + int (*export_fence)(struct dri3_syncobj *syncobj, uint64_t point); + void (*import_fence)(struct dri3_syncobj *syncobj, uint64_t point, int fd); + void (*signal)(struct dri3_syncobj *syncobj, uint64_t point); + void (*submitted_eventfd)(struct dri3_syncobj *syncobj, uint64_t point, int efd); + void (*signaled_eventfd)(struct dri3_syncobj *syncobj, uint64_t point, int efd); +}; + +typedef int (*dri3_open_proc)(ScreenPtr screen, + RRProviderPtr provider, + int *fd); + +typedef int (*dri3_open_client_proc)(ClientPtr client, + ScreenPtr screen, + RRProviderPtr provider, + int *fd); + +typedef PixmapPtr (*dri3_pixmap_from_fd_proc) (ScreenPtr screen, + int fd, + CARD16 width, + CARD16 height, + CARD16 stride, + CARD8 depth, + CARD8 bpp); + +typedef PixmapPtr (*dri3_pixmap_from_fds_proc) (ScreenPtr screen, + CARD8 num_fds, + const int *fds, + CARD16 width, + CARD16 height, + const CARD32 *strides, + const CARD32 *offsets, + CARD8 depth, + CARD8 bpp, + CARD64 modifier); + +typedef int (*dri3_fd_from_pixmap_proc) (ScreenPtr screen, + PixmapPtr pixmap, + CARD16 *stride, + CARD32 *size); + +typedef int (*dri3_fds_from_pixmap_proc) (ScreenPtr screen, + PixmapPtr pixmap, + int *fds, + uint32_t *strides, + uint32_t *offsets, + uint64_t *modifier); + +typedef int (*dri3_get_formats_proc) (ScreenPtr screen, + CARD32 *num_formats, + CARD32 **formats); + +typedef int (*dri3_get_modifiers_proc) (ScreenPtr screen, + uint32_t format, + uint32_t *num_modifiers, + uint64_t **modifiers); + +typedef int (*dri3_get_drawable_modifiers_proc) (DrawablePtr draw, + uint32_t format, + uint32_t *num_modifiers, + uint64_t **modifiers); + +typedef struct dri3_syncobj *(*dri3_import_syncobj_proc) (ClientPtr client, + ScreenPtr screen, + XID id, + int fd); + +typedef struct dri3_screen_info { + uint32_t version; + + dri3_open_proc open; + dri3_pixmap_from_fd_proc pixmap_from_fd; + dri3_fd_from_pixmap_proc fd_from_pixmap; + + /* Version 1 */ + dri3_open_client_proc open_client; + + /* Version 2 */ + dri3_pixmap_from_fds_proc pixmap_from_fds; + dri3_fds_from_pixmap_proc fds_from_pixmap; + dri3_get_formats_proc get_formats; + dri3_get_modifiers_proc get_modifiers; + dri3_get_drawable_modifiers_proc get_drawable_modifiers; + + /* Version 4 */ + dri3_import_syncobj_proc import_syncobj; + +} dri3_screen_info_rec, *dri3_screen_info_ptr; + +extern _X_EXPORT Bool +dri3_screen_init(ScreenPtr screen, const dri3_screen_info_rec *info); + +#endif /* _DRI3_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/dristruct.h b/prebuilt/xlibre/usr/include/xorg/dristruct.h new file mode 100644 index 0000000..9626006 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/dristruct.h @@ -0,0 +1,122 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Jens Owen + * + */ + +#ifndef DRI_STRUCT_H +#define DRI_STRUCT_H + +#include "dri.h" +#include "sarea.h" +#include "xf86drm.h" +#include "xf86Crtc.h" + +#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey)) +#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey)) + +typedef struct _DRIDrawablePrivRec { + drm_drawable_t hwDrawable; + int drawableIndex; + ScreenPtr pScreen; + int refCount; + int nrects; +} DRIDrawablePrivRec, *DRIDrawablePrivPtr; + +struct _DRIContextPrivRec { + drm_context_t hwContext; + ScreenPtr pScreen; + Bool valid3D; + DRIContextFlags flags; + void **pContextStore; +}; + +#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ + dixLookupPrivate(&screenInfo.screens[(screenIndex)]->devPrivates, \ + DRIScreenPrivKey)) + +#define DRI_ENT_PRIV(pScrn) \ + ((DRIEntPrivIndex < 0) ? \ + NULL: \ + ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \ + DRIEntPrivIndex)->ptr))) + +typedef struct _DRIScreenPrivRec { + Bool directRenderingSupport; + int drmFD; /* File descriptor for /dev/video/? */ + drm_handle_t hSAREA; /* Handle to SAREA, for mapping */ + XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */ + drm_context_t myContext; /* DDX Driver's context */ + DRIContextPrivPtr myContextPriv; /* Pointer to server's private area */ + DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */ + void **hiddenContextStore; /* hidden X context */ + void **partial3DContextStore; /* partial 3D context */ + DRIInfoPtr pDriverInfo; + int nrWindows; + int nrWindowsVisible; + int nrWalked; + drm_clip_rect_t private_buffer_rect; /* management of private buffers */ + DrawablePtr fullscreen; /* pointer to fullscreen drawable */ + drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */ + DRIWrappedFuncsRec wrap; + void *_dummy1; // required in place of a removed field for ABI compatibility + DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES]; + DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */ + Bool createDummyCtx; + Bool createDummyCtxPriv; + Bool grabbedDRILock; + Bool drmSIGIOHandlerInstalled; + Bool wrapped; + Bool windowsTouched; + int lockRefCount; + drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */ + XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */ + int *pLockRefCount; + int *pLockingContext; + xf86_crtc_notify_proc_ptr xf86_crtc_notify; +} DRIScreenPrivRec, *DRIScreenPrivPtr; + +typedef struct _DRIEntPrivRec { + int drmFD; + Bool drmOpened; + Bool sAreaGrabbed; + drm_handle_t hLSAREA; + XF86DRILSAREAPtr pLSAREA; + unsigned long sAreaSize; + int lockRefCount; + int lockingContext; + ScreenPtr resOwner; + Bool keepFDOpen; + int refCount; +} DRIEntPrivRec, *DRIEntPrivPtr; + +#endif /* DRI_STRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/edid.h b/prebuilt/xlibre/usr/include/xorg/edid.h new file mode 100644 index 0000000..9cbd161 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/edid.h @@ -0,0 +1,269 @@ +/* + * edid.h: defines to parse an EDID block + * + * This file contains all information to interpret a standard EDIC block + * transmitted by a display device via DDC (Display Data Channel). So far + * there is no information to deal with optional EDID blocks. + * DDC is a Trademark of VESA (Video Electronics Standard Association). + * + * Copyright 1998 by Egbert Eich + */ + +#ifndef _EDID_H_ +#define _EDID_H_ + +#include +#include +#include +#include + +#define STD_TIMINGS 8 +#define DET_TIMINGS 4 + +/* input type */ +#define DIGITAL(x) (x) + +/* Msc stuff EDID Ver > 1.1 */ +#define PREFERRED_TIMING_MODE(x) ((x) & 0x2) +#define GTF_SUPPORTED(x) ((x) & 0x1) + +struct vendor { + char name[4]; + int prod_id; + unsigned int serial; + int week; + int year; +}; + +struct edid_version { + int version; + int revision; +}; + +struct disp_features { + unsigned int input_type:1; + unsigned int input_voltage:2; + unsigned int input_setup:1; + unsigned int input_sync:5; + unsigned int input_dfp:1; + unsigned int input_bpc:3; + unsigned int input_interface:4; + /* 15 bit hole */ + int hsize; + int vsize; + float gamma; + unsigned int dpms:3; + unsigned int display_type:2; + unsigned int msc:3; + float redx; + float redy; + float greenx; + float greeny; + float bluex; + float bluey; + float whitex; + float whitey; +}; + +struct established_timings { + uint8_t t1; + uint8_t t2; + uint8_t t_manu; +}; + +struct std_timings { + int hsize; + int vsize; + int refresh; + CARD16 id; +}; + +struct detailed_timings { + int clock; + int h_active; + int h_blanking; + int v_active; + int v_blanking; + int h_sync_off; + int h_sync_width; + int v_sync_off; + int v_sync_width; + int h_size; + int v_size; + int h_border; + int v_border; + unsigned int interlaced:1; + unsigned int stereo:2; + unsigned int sync:2; + unsigned int misc:2; + unsigned int stereo_1:1; +}; + +#define DT 0 +#define DS_SERIAL 0xFF +#define DS_ASCII_STR 0xFE +#define DS_NAME 0xFC +#define DS_RANGES 0xFD +#define DS_WHITE_P 0xFB +#define DS_STD_TIMINGS 0xFA +#define DS_CMD 0xF9 +#define DS_CVT 0xF8 +#define DS_EST_III 0xF7 +#define DS_DUMMY 0x10 +#define DS_UNKOWN 0x100 /* type is an int */ +#define DS_VENDOR 0x101 +#define DS_VENDOR_MAX 0x110 + +/* + * Display range limit Descriptor of EDID version1, reversion 4 + */ +typedef enum { + DR_DEFAULT_GTF, + DR_LIMITS_ONLY, + DR_SECONDARY_GTF, + DR_CVT_SUPPORTED = 4, +} DR_timing_flags; + +struct monitor_ranges { + int min_v; + int max_v; + int min_h; + int max_h; + int max_clock; /* in mhz */ + int gtf_2nd_f; + int gtf_2nd_c; + int gtf_2nd_m; + int gtf_2nd_k; + int gtf_2nd_j; + int max_clock_khz; + int maxwidth; /* in pixels */ + char supported_aspect; + char preferred_aspect; + char supported_blanking; + char supported_scaling; + int preferred_refresh; /* in hz */ + DR_timing_flags display_range_timing_flags; +}; + +struct whitePoints { + int index; + float white_x; + float white_y; + float white_gamma; +}; + +struct cvt_timings { + int width; + int height; + int rate; + int rates; +}; + +/* + * Be careful when adding new sections; this structure can't grow, it's + * embedded in the middle of xf86Monitor which is ABI. Sizes below are + * in bytes, for ILP32 systems. If all else fails just copy the section + * literally like serial and friends. + */ +struct detailed_monitor_section { + int type; + union { + struct detailed_timings d_timings; /* 56 */ + uint8_t serial[13]; + uint8_t ascii_data[13]; + uint8_t name[13]; + struct monitor_ranges ranges; /* 60 */ + struct std_timings std_t[5]; /* 80 */ + struct whitePoints wp[2]; /* 32 */ + /* color management data */ + struct cvt_timings cvt[4]; /* 64 */ + uint8_t est_iii[6]; /* 6 */ + } section; /* max: 80 */ +}; + +/* flags */ +#define MONITOR_EDID_COMPLETE_RAWDATA 0x01 +/* old, don't use */ +#define EDID_COMPLETE_RAWDATA 0x01 + +/** + * @brief The monitor_hdr_data hdr metadata struct + * This struct mirrors Table 92 - HDR Static Metadata Data Block (HDR SMDB) structure + */ +struct monitor_hdr_data { + bool hdr_valid : 1; /* static metadata v1 found, doesn't mean all fields are set */ + bool colorimetry_valid : 1; /* if colorimetry tag found */ + + bool tf_traditional_sdr : 1, + tf_traditional_hdr : 1, + tf_pq : 1, + tf_hlg : 1, + tf_4 : 1, + tf_5 : 1; + + unsigned int resv : 2; /* reserved bits */ + + float desired_content_min_luminance; /* in cd/m2, can be 0 */ + float desired_content_max_luminance; /* in cd/m2, can be 0 */ + float desired_content_max_frame_avg_luminance; /* in cd/m2, if unset 0 */ + + bool sm_static_metadata_type1 : 1; + + unsigned int sm_1_7 : 7; /* reserved bits */ + + int reserved_1[4]; /* for future */ + + unsigned int colorimetry_profiles : 16; + + int reserved_2[4]; /* for future */ +}; + +#define CTA_HDR_SMDB_TF_SDR 1 +#define CTA_HDR_SMDB_TF_HDR 2 +#define CTA_HDR_SMDB_TF_ST2084 4 +#define CTA_HDR_SMDB_TF_HLG 8 + +#define CTA_HDR_SMDB_SM_TYPE1 1 + +/* these constants are from Colorimetry Data Block (CDB) byte 3 and 4, converted into natural representation (big endian) uint16 */ + +#define is_CTA_CDB_BT2020_RGB(x) (((x) & 0x8000) == 0x8000) +#define is_CTA_CDB_BT2020_YCC(x) (((x) & 0x4000) == 0x4000) +#define is_CTA_CDB_BT2020_cYCC(x) (((x) & 0x2000) == 0x2000) +#define is_CTA_CDB_opRGB(x) (((x) & 0x1000) == 0x1000) +#define is_CTA_CDB_opYCC601(x) (((x) & 0x0800) == 0x0800) +#define is_CTA_CDB_sYCC601(x) (((x) & 0x0400) == 0x0400) +#define is_CTA_CDB_xvYCC709(x) (((x) & 0x0200) == 0x0200) +#define is_CTA_CDB_xvYCC601(x) (((x) & 0x0100) == 0x0100) +#define is_CTA_CDB_ST2113RGB(x) (((x) & 0x0080) == 0x0080) +#define is_CTA_CDB_iCtCp(x) (((x) & 0x0040) == 0x0040) + +/* + * For DisplayID devices, only the scrnIndex, flags, and rawData fields + * are meaningful. For EDID, they all are. + */ +typedef struct { + int scrnIndex; + struct vendor vendor; + struct edid_version ver; + struct disp_features features; + struct established_timings timings1; + struct std_timings timings2[8]; + struct detailed_monitor_section det_mon[4]; + unsigned long flags; + int no_sections; + uint8_t *rawData; + struct monitor_hdr_data hdr; +} xf86Monitor, *xf86MonPtr; + +extern _X_EXPORT xf86MonPtr ConfiguredMonitor; + +/* + * check whether monitor supports Generalized Timing Formula + * + * @param monitor the monitor information structure to check + * @return true if GTF is supported by the monitor + */ +_X_EXPORT bool xf86Monitor_gtf_supported(xf86MonPtr monitor); + +#endif /* _EDID_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/events.h b/prebuilt/xlibre/usr/include/xorg/events.h new file mode 100644 index 0000000..544dfad --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/events.h @@ -0,0 +1,43 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef EVENTS_H +#define EVENTS_H +typedef struct _DeviceEvent DeviceEvent; +typedef struct _DeviceChangedEvent DeviceChangedEvent; +typedef struct _TouchOwnershipEvent TouchOwnershipEvent; +typedef struct _BarrierEvent BarrierEvent; +typedef struct _GestureEvent GestureEvent; + +#ifdef XFreeXDGA +typedef struct _DGAEvent DGAEvent; +#endif +typedef struct _RawDeviceEvent RawDeviceEvent; + +#ifdef XQUARTZ +typedef struct _XQuartzEvent XQuartzEvent; +#endif +typedef union _InternalEvent InternalEvent; + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/exa.h b/prebuilt/xlibre/usr/include/xorg/exa.h new file mode 100644 index 0000000..1251dc7 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/exa.h @@ -0,0 +1,811 @@ +/* + * + * Copyright (C) 2000 Keith Packard + * 2004 Eric Anholt + * 2005 Zack Rusin + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of copyright holders not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Copyright holders make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/** @file + * This is the header containing the public API of EXA for exa drivers. + */ + +#ifndef EXA_H +#define EXA_H + +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "gcstruct.h" +#include "picturestr.h" +#include "fb.h" + +#define EXA_VERSION_MAJOR 2 +#define EXA_VERSION_MINOR 6 +#define EXA_VERSION_RELEASE 0 + +typedef struct _ExaOffscreenArea ExaOffscreenArea; + +typedef void (*ExaOffscreenSaveProc) (ScreenPtr pScreen, + ExaOffscreenArea * area); + +typedef enum _ExaOffscreenState { + ExaOffscreenAvail, + ExaOffscreenRemovable, + ExaOffscreenLocked +} ExaOffscreenState; + +struct _ExaOffscreenArea { + int base_offset; /* allocation base */ + int offset; /* aligned offset */ + int size; /* total allocation size */ + unsigned last_use; + void *privData; + + ExaOffscreenSaveProc save; + + ExaOffscreenState state; + + ExaOffscreenArea *next; + + unsigned eviction_cost; + + ExaOffscreenArea *prev; /* Double-linked list for defragmentation */ + int align; /* required alignment */ +}; + +/** + * The ExaDriver structure is allocated through exaDriverAlloc(), and then + * fllled in by drivers. + */ +typedef struct _ExaDriver { + /** + * exa_major and exa_minor should be set by the driver to the version of + * EXA which the driver was compiled for (or configures itself at runtime + * to support). This allows EXA to extend the structure for new features + * without breaking ABI for drivers compiled against older versions. + */ + int exa_major, exa_minor; + + /** + * memoryBase is the address of the beginning of framebuffer memory. + * The visible screen should be within memoryBase to memoryBase + + * memorySize. + */ + CARD8 *memoryBase; + + /** + * offScreenBase is the offset from memoryBase of the beginning of the area + * to be managed by EXA's linear offscreen memory manager. + * + * In XFree86 DDX drivers, this is probably: + * (pScrn->displayWidth * cpp * pScrn->virtualY) + */ + unsigned long offScreenBase; + + /** + * memorySize is the length (in bytes) of framebuffer memory beginning + * from memoryBase. + * + * The offscreen memory manager will manage the area beginning at + * (memoryBase + offScreenBase), with a length of (memorySize - + * offScreenBase) + * + * In XFree86 DDX drivers, this is probably (pScrn->videoRam * 1024) + */ + unsigned long memorySize; + + /** + * pixmapOffsetAlign is the byte alignment necessary for pixmap offsets + * within framebuffer. + * + * Hardware typically has a required alignment of offsets, which may or may + * not be a power of two. EXA will ensure that pixmaps managed by the + * offscreen memory manager meet this alignment requirement. + */ + int pixmapOffsetAlign; + + /** + * pixmapPitchAlign is the byte alignment necessary for pixmap pitches + * within the framebuffer. + * + * Hardware typically has a required alignment of pitches for acceleration. + * For 3D hardware, Composite acceleration often requires that source and + * mask pixmaps (textures) have a power-of-two pitch, which can be demanded + * using EXA_OFFSCREEN_ALIGN_POT. These pitch requirements only apply to + * pixmaps managed by the offscreen memory manager. Thus, it is up to the + * driver to ensure that the visible screen has an appropriate pitch for + * acceleration. + */ + int pixmapPitchAlign; + + /** + * The flags field is bitfield of boolean values controlling EXA's behavior. + * + * The flags include EXA_OFFSCREEN_PIXMAPS, EXA_OFFSCREEN_ALIGN_POT, and + * EXA_TWO_BITBLT_DIRECTIONS. + */ + int flags; + + /** @{ */ + /** + * maxX controls the X coordinate limitation for rendering from the card. + * The driver should never receive a request for rendering beyond maxX + * in the X direction from the origin of a pixmap. + */ + int maxX; + + /** + * maxY controls the Y coordinate limitation for rendering from the card. + * The driver should never receive a request for rendering beyond maxY + * in the Y direction from the origin of a pixmap. + */ + int maxY; + /** @} */ + + /* private */ + ExaOffscreenArea *offScreenAreas; + Bool needsSync; + int lastMarker; + + /** @name Solid + * @{ + */ + /** + * PrepareSolid() sets up the driver for doing a solid fill. + * @param pPixmap Destination pixmap + * @param alu raster operation + * @param planemask write mask for the fill + * @param fg "foreground" color for the fill + * + * This call should set up the driver for doing a series of solid fills + * through the Solid() call. The alu raster op is one of the GX* + * graphics functions listed in X.h, and typically maps to a similar + * single-byte "ROP" setting in all hardware. The planemask controls + * which bits of the destination should be affected, and will only represent + * the bits up to the depth of pPixmap. The fg is the pixel value of the + * foreground color referred to in ROP descriptions. + * + * Note that many drivers will need to store some of the data in the driver + * private record, for sending to the hardware with each drawing command. + * + * The PrepareSolid() call is required of all drivers, but it may fail for any + * reason. Failure results in a fallback to software rendering. + */ + Bool (*PrepareSolid) (PixmapPtr pPixmap, + int alu, Pixel planemask, Pixel fg); + + /** + * Solid() performs a solid fill set up in the last PrepareSolid() call. + * + * @param pPixmap destination pixmap + * @param x1 left coordinate + * @param y1 top coordinate + * @param x2 right coordinate + * @param y2 bottom coordinate + * + * Performs the fill set up by the last PrepareSolid() call, covering the + * area from (x1,y1) to (x2,y2) in pPixmap. Note that the coordinates are + * in the coordinate space of the destination pixmap, so the driver will + * need to set up the hardware's offset and pitch for the destination + * coordinates according to the pixmap's offset and pitch within + * framebuffer. This likely means using exaGetPixmapOffset() and + * exaGetPixmapPitch(). + * + * This call is required if PrepareSolid() ever succeeds. + */ + void (*Solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2); + + /** + * DoneSolid() finishes a set of solid fills. + * + * @param pPixmap destination pixmap. + * + * The DoneSolid() call is called at the end of a series of consecutive + * Solid() calls following a successful PrepareSolid(). This allows drivers + * to finish up emitting drawing commands that were buffered, or clean up + * state from PrepareSolid(). + * + * This call is required if PrepareSolid() ever succeeds. + */ + void (*DoneSolid) (PixmapPtr pPixmap); + /** @} */ + + /** @name Copy + * @{ + */ + /** + * PrepareCopy() sets up the driver for doing a copy within video + * memory. + * + * @param pSrcPixmap source pixmap + * @param pDstPixmap destination pixmap + * @param dx X copy direction + * @param dy Y copy direction + * @param alu raster operation + * @param planemask write mask for the fill + * + * This call should set up the driver for doing a series of copies from the + * the pSrcPixmap to the pDstPixmap. The dx flag will be positive if the + * hardware should do the copy from the left to the right, and dy will be + * positive if the copy should be done from the top to the bottom. This + * is to deal with self-overlapping copies when pSrcPixmap == pDstPixmap. + * If your hardware can only support blits that are (left to right, top to + * bottom) or (right to left, bottom to top), then you should set + * #EXA_TWO_BITBLT_DIRECTIONS, and EXA will break down Copy operations to + * ones that meet those requirements. The alu raster op is one of the GX* + * graphics functions listed in X.h, and typically maps to a similar + * single-byte "ROP" setting in all hardware. The planemask controls which + * bits of the destination should be affected, and will only represent the + * bits up to the depth of pPixmap. + * + * Note that many drivers will need to store some of the data in the driver + * private record, for sending to the hardware with each drawing command. + * + * The PrepareCopy() call is required of all drivers, but it may fail for any + * reason. Failure results in a fallback to software rendering. + */ + Bool (*PrepareCopy) (PixmapPtr pSrcPixmap, + PixmapPtr pDstPixmap, + int dx, int dy, int alu, Pixel planemask); + + /** + * Copy() performs a copy set up in the last PrepareCopy call. + * + * @param pDstPixmap destination pixmap + * @param srcX source X coordinate + * @param srcY source Y coordinate + * @param dstX destination X coordinate + * @param dstY destination Y coordinate + * @param width width of the rectangle to be copied + * @param height height of the rectangle to be copied. + * + * Performs the copy set up by the last PrepareCopy() call, copying the + * rectangle from (srcX, srcY) to (srcX + width, srcY + width) in the source + * pixmap to the same-sized rectangle at (dstX, dstY) in the destination + * pixmap. Those rectangles may overlap in memory, if + * pSrcPixmap == pDstPixmap. Note that this call does not receive the + * pSrcPixmap as an argument -- if it's needed in this function, it should + * be stored in the driver private during PrepareCopy(). As with Solid(), + * the coordinates are in the coordinate space of each pixmap, so the driver + * will need to set up source and destination pitches and offsets from those + * pixmaps, probably using exaGetPixmapOffset() and exaGetPixmapPitch(). + * + * This call is required if PrepareCopy ever succeeds. + */ + void (*Copy) (PixmapPtr pDstPixmap, + int srcX, + int srcY, int dstX, int dstY, int width, int height); + + /** + * DoneCopy() finishes a set of copies. + * + * @param pPixmap destination pixmap. + * + * The DoneCopy() call is called at the end of a series of consecutive + * Copy() calls following a successful PrepareCopy(). This allows drivers + * to finish up emitting drawing commands that were buffered, or clean up + * state from PrepareCopy(). + * + * This call is required if PrepareCopy() ever succeeds. + */ + void (*DoneCopy) (PixmapPtr pDstPixmap); + /** @} */ + + /** @name Composite + * @{ + */ + /** + * CheckComposite() checks to see if a composite operation could be + * accelerated. + * + * @param op Render operation + * @param pSrcPicture source Picture + * @param pMaskPicture mask picture + * @param pDstPicture destination Picture + * + * The CheckComposite() call checks if the driver could handle acceleration + * of op with the given source, mask, and destination pictures. This allows + * drivers to check source and destination formats, supported operations, + * transformations, and component alpha state, and send operations it can't + * support to software rendering early on. This avoids costly pixmap + * migration to the wrong places when the driver can't accelerate + * operations. Note that because migration hasn't happened, the driver + * can't know during CheckComposite() what the offsets and pitches of the + * pixmaps are going to be. + * + * See PrepareComposite() for more details on likely issues that drivers + * will have in accelerating Composite operations. + * + * The CheckComposite() call is recommended if PrepareComposite() is + * implemented, but is not required. + */ + Bool (*CheckComposite) (int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture); + + /** + * PrepareComposite() sets up the driver for doing a Composite operation + * described in the Render extension protocol spec. + * + * @param op Render operation + * @param pSrcPicture source Picture + * @param pMaskPicture mask picture + * @param pDstPicture destination Picture + * @param pSrc source pixmap + * @param pMask mask pixmap + * @param pDst destination pixmap + * + * This call should set up the driver for doing a series of Composite + * operations, as described in the Render protocol spec, with the given + * pSrcPicture, pMaskPicture, and pDstPicture. The pSrc, pMask, and + * pDst are the pixmaps containing the pixel data, and should be used for + * setting the offset and pitch used for the coordinate spaces for each of + * the Pictures. + * + * Notes on interpreting Picture structures: + * - The Picture structures will always have a valid pDrawable. + * - The Picture structures will never have alphaMap set. + * - The mask Picture (and therefore pMask) may be NULL, in which case the + * operation is simply src OP dst instead of src IN mask OP dst, and + * mask coordinates should be ignored. + * - pMarkPicture may have componentAlpha set, which greatly changes + * the behavior of the Composite operation. componentAlpha has no effect + * when set on pSrcPicture or pDstPicture. + * - The source and mask Pictures may have a transformation set + * (Picture->transform != NULL), which means that the source coordinates + * should be transformed by that transformation, resulting in scaling, + * rotation, etc. The PictureTransformPoint() call can transform + * coordinates for you. Transforms have no effect on Pictures when used + * as a destination. + * - The source and mask pictures may have a filter set. PictFilterNearest + * and PictFilterBilinear are defined in the Render protocol, but others + * may be encountered, and must be handled correctly (usually by + * PrepareComposite failing, and falling back to software). Filters have + * no effect on Pictures when used as a destination. + * - The source and mask Pictures may have repeating set, which must be + * respected. Many chipsets will be unable to support repeating on + * pixmaps that have a width or height that is not a power of two. + * + * If your hardware can't support source pictures (textures) with + * non-power-of-two pitches, you should set #EXA_OFFSCREEN_ALIGN_POT. + * + * Note that many drivers will need to store some of the data in the driver + * private record, for sending to the hardware with each drawing command. + * + * The PrepareComposite() call is not required. However, it is highly + * recommended for performance of antialiased font rendering and performance + * of cairo applications. Failure results in a fallback to software + * rendering. + */ + Bool (*PrepareComposite) (int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst); + + /** + * Composite() performs a Composite operation set up in the last + * PrepareComposite() call. + * + * @param pDstPixmap destination pixmap + * @param srcX source X coordinate + * @param srcY source Y coordinate + * @param maskX source X coordinate + * @param maskY source Y coordinate + * @param dstX destination X coordinate + * @param dstY destination Y coordinate + * @param width destination rectangle width + * @param height destination rectangle height + * + * Performs the Composite operation set up by the last PrepareComposite() + * call, to the rectangle from (dstX, dstY) to (dstX + width, dstY + height) + * in the destination Pixmap. Note that if a transformation was set on + * the source or mask Pictures, the source rectangles may not be the same + * size as the destination rectangles and filtering. Getting the coordinate + * transformation right at the subpixel level can be tricky, and rendercheck + * can test this for you. + * + * This call is required if PrepareComposite() ever succeeds. + */ + void (*Composite) (PixmapPtr pDst, + int srcX, + int srcY, + int maskX, + int maskY, int dstX, int dstY, int width, int height); + + /** + * DoneComposite() finishes a set of Composite operations. + * + * @param pPixmap destination pixmap. + * + * The DoneComposite() call is called at the end of a series of consecutive + * Composite() calls following a successful PrepareComposite(). This allows + * drivers to finish up emitting drawing commands that were buffered, or + * clean up state from PrepareComposite(). + * + * This call is required if PrepareComposite() ever succeeds. + */ + void (*DoneComposite) (PixmapPtr pDst); + /** @} */ + + /** + * UploadToScreen() loads a rectangle of data from src into pDst. + * + * @param pDst destination pixmap + * @param x destination X coordinate. + * @param y destination Y coordinate + * @param width width of the rectangle to be copied + * @param height height of the rectangle to be copied + * @param src pointer to the beginning of the source data + * @param src_pitch pitch (in bytes) of the lines of source data. + * + * UploadToScreen() copies data in system memory beginning at src (with + * pitch src_pitch) into the destination pixmap from (x, y) to + * (x + width, y + height). This is typically done with hostdata uploads, + * where the CPU sets up a blit command on the hardware with instructions + * that the blit data will be fed through some sort of aperture on the card. + * + * If UploadToScreen() is performed asynchronously, it is up to the driver + * to call exaMarkSync(). This is in contrast to most other acceleration + * calls in EXA. + * + * UploadToScreen() can aid in pixmap migration, but is most important for + * the performance of exaGlyphs() (antialiased font drawing) by allowing + * pipelining of data uploads, avoiding a sync of the card after each glyph. + * + * @return TRUE if the driver successfully uploaded the data. FALSE + * indicates that EXA should fall back to doing the upload in software. + * + * UploadToScreen() is not required, but is recommended if Composite + * acceleration is supported. + */ + Bool (*UploadToScreen) (PixmapPtr pDst, + int x, + int y, int w, int h, char *src, int src_pitch); + + /** + * UploadToScratch() is no longer used and will be removed next time the EXA + * major version needs to be bumped. + */ + Bool (*UploadToScratch) (PixmapPtr pSrc, PixmapPtr pDst); + + /** + * DownloadFromScreen() loads a rectangle of data from pSrc into dst + * + * @param pSrc source pixmap + * @param x source X coordinate. + * @param y source Y coordinate + * @param width width of the rectangle to be copied + * @param height height of the rectangle to be copied + * @param dst pointer to the beginning of the destination data + * @param dst_pitch pitch (in bytes) of the lines of destination data. + * + * DownloadFromScreen() copies data from offscreen memory in pSrc from + * (x, y) to (x + width, y + height), to system memory starting at + * dst (with pitch dst_pitch). This would usually be done + * using scatter-gather DMA, supported by a DRM call, or by blitting to AGP + * and then synchronously reading from AGP. Because the implementation + * might be synchronous, EXA leaves it up to the driver to call + * exaMarkSync() if DownloadFromScreen() was asynchronous. This is in + * contrast to most other acceleration calls in EXA. + * + * DownloadFromScreen() can aid in the largest bottleneck in pixmap + * migration, which is the read from framebuffer when evicting pixmaps from + * framebuffer memory. Thus, it is highly recommended, even though + * implementations are typically complicated. + * + * @return TRUE if the driver successfully downloaded the data. FALSE + * indicates that EXA should fall back to doing the download in software. + * + * DownloadFromScreen() is not required, but is highly recommended. + */ + Bool (*DownloadFromScreen) (PixmapPtr pSrc, + int x, int y, + int w, int h, char *dst, int dst_pitch); + + /** + * MarkSync() requests that the driver mark a synchronization point, + * returning an driver-defined integer marker which could be requested for + * synchronization to later in WaitMarker(). This might be used in the + * future to avoid waiting for full hardware stalls before accessing pixmap + * data with the CPU, but is not important in the current incarnation of + * EXA. + * + * Note that drivers should call exaMarkSync() when they have done some + * acceleration, rather than their own MarkSync() handler, as otherwise EXA + * will be unaware of the driver's acceleration and not sync to it during + * fallbacks. + * + * MarkSync() is optional. + */ + int (*MarkSync) (ScreenPtr pScreen); + + /** + * WaitMarker() waits for all rendering before the given marker to have + * completed. If the driver does not implement MarkSync(), marker is + * meaningless, and all rendering by the hardware should be completed before + * WaitMarker() returns. + * + * Note that drivers should call exaWaitSync() to wait for all acceleration + * to finish, as otherwise EXA will be unaware of the driver having + * synchronized, resulting in excessive WaitMarker() calls. + * + * WaitMarker() is required of all drivers. + */ + void (*WaitMarker) (ScreenPtr pScreen, int marker); + + /** @{ */ + /** + * PrepareAccess() is called before CPU access to an offscreen pixmap. + * + * @param pPix the pixmap being accessed + * @param index the index of the pixmap being accessed. + * + * PrepareAccess() will be called before CPU access to an offscreen pixmap. + * This can be used to set up hardware surfaces for byteswapping or + * untiling, or to adjust the pixmap's devPrivate.ptr for the purpose of + * making CPU access use a different aperture. + * + * The index is one of #EXA_PREPARE_DEST, #EXA_PREPARE_SRC, + * #EXA_PREPARE_MASK, #EXA_PREPARE_AUX_DEST, #EXA_PREPARE_AUX_SRC, or + * #EXA_PREPARE_AUX_MASK. Since only up to #EXA_NUM_PREPARE_INDICES pixmaps + * will have PrepareAccess() called on them per operation, drivers can have + * a small, statically-allocated space to maintain state for PrepareAccess() + * and FinishAccess() in. Note that PrepareAccess() is only called once per + * pixmap and operation, regardless of whether the pixmap is used as a + * destination and/or source, and the index may not reflect the usage. + * + * PrepareAccess() may fail. An example might be the case of hardware that + * can set up 1 or 2 surfaces for CPU access, but not 3. If PrepareAccess() + * fails, EXA will migrate the pixmap to system memory. + * DownloadFromScreen() must be implemented and must not fail if a driver + * wishes to fail in PrepareAccess(). PrepareAccess() must not fail when + * pPix is the visible screen, because the visible screen can not be + * migrated. + * + * @return TRUE if PrepareAccess() successfully prepared the pixmap for CPU + * drawing. + * @return FALSE if PrepareAccess() is unsuccessful and EXA should use + * DownloadFromScreen() to mitigate the pixmap out. + */ + Bool (*PrepareAccess) (PixmapPtr pPix, int index); + + /** + * FinishAccess() is called after CPU access to an offscreen pixmap. + * + * @param pPix the pixmap being accessed + * @param index the index of the pixmap being accessed. + * + * FinishAccess() will be called after finishing CPU access of an offscreen + * pixmap set up by PrepareAccess(). Note that the FinishAccess() will not be + * called if PrepareAccess() failed and the pixmap was migrated out. + */ + void (*FinishAccess) (PixmapPtr pPix, int index); + + /** + * PixmapIsOffscreen() is an optional driver replacement to + * exaPixmapHasGpuCopy(). Set to NULL if you want the standard behaviour + * of exaPixmapHasGpuCopy(). + * + * @param pPix the pixmap + * @return TRUE if the given drawable is in framebuffer memory. + * + * exaPixmapHasGpuCopy() is used to determine if a pixmap is in offscreen + * memory, meaning that acceleration could probably be done to it, and that it + * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it + * with the CPU. + * + * + */ + Bool (*PixmapIsOffscreen) (PixmapPtr pPix); + + /** @name PrepareAccess() and FinishAccess() indices + * @{ + */ + /** + * EXA_PREPARE_DEST is the index for a pixmap that may be drawn to or + * read from. + */ +#define EXA_PREPARE_DEST 0 + /** + * EXA_PREPARE_SRC is the index for a pixmap that may be read from + */ +#define EXA_PREPARE_SRC 1 + /** + * EXA_PREPARE_SRC is the index for a second pixmap that may be read + * from. + */ +#define EXA_PREPARE_MASK 2 + /** + * EXA_PREPARE_AUX* are additional indices for other purposes, e.g. + * separate alpha maps with Composite operations. + */ +#define EXA_PREPARE_AUX_DEST 3 +#define EXA_PREPARE_AUX_SRC 4 +#define EXA_PREPARE_AUX_MASK 5 +#define EXA_NUM_PREPARE_INDICES 6 + /** @} */ + + /** + * maxPitchPixels controls the pitch limitation for rendering from + * the card. + * The driver should never receive a request for rendering a pixmap + * that has a pitch (in pixels) beyond maxPitchPixels. + * + * Setting this field is optional -- if your hardware doesn't have + * a pitch limitation in pixels, don't set this. If neither this value + * nor maxPitchBytes is set, then maxPitchPixels is set to maxX. + * If set, it must not be smaller than maxX. + * + * @sa maxPitchBytes + */ + int maxPitchPixels; + + /** + * maxPitchBytes controls the pitch limitation for rendering from + * the card. + * The driver should never receive a request for rendering a pixmap + * that has a pitch (in bytes) beyond maxPitchBytes. + * + * Setting this field is optional -- if your hardware doesn't have + * a pitch limitation in bytes, don't set this. + * If set, it must not be smaller than maxX * 4. + * There's no default value for maxPitchBytes. + * + * @sa maxPitchPixels + */ + int maxPitchBytes; + + /* Hooks to allow driver to its own pixmap memory management */ + void *(*CreatePixmap) (ScreenPtr pScreen, int size, int align); + void (*DestroyPixmap) (ScreenPtr pScreen, void *driverPriv); + /** + * Returning a pixmap with non-NULL devPrivate.ptr implies a pixmap which is + * not offscreen, which will never be accelerated and Prepare/FinishAccess won't + * be called. + */ + Bool (*ModifyPixmapHeader) (PixmapPtr pPixmap, int width, int height, + int depth, int bitsPerPixel, int devKind, + void *pPixData); + + /* hooks for drivers with tiling support: + * driver MUST fill out new_fb_pitch with valid pitch of pixmap + */ + void *(*CreatePixmap2) (ScreenPtr pScreen, int width, int height, + int depth, int usage_hint, int bitsPerPixel, + int *new_fb_pitch); + /** @} */ + Bool (*SharePixmapBacking)(PixmapPtr pPixmap, ScreenPtr secondary, void **handle_p); + + Bool (*SetSharedPixmapBacking)(PixmapPtr pPixmap, void *handle); + +} ExaDriverRec, *ExaDriverPtr; + +/** @name EXA driver flags + * @{ + */ +/** + * EXA_OFFSCREEN_PIXMAPS indicates to EXA that the driver can support + * offscreen pixmaps. + */ +#define EXA_OFFSCREEN_PIXMAPS (1 << 0) + +/** + * EXA_OFFSCREEN_ALIGN_POT indicates to EXA that the driver needs pixmaps + * to have a power-of-two pitch. + */ +#define EXA_OFFSCREEN_ALIGN_POT (1 << 1) + +/** + * EXA_TWO_BITBLT_DIRECTIONS indicates to EXA that the driver can only + * support copies that are (left-to-right, top-to-bottom) or + * (right-to-left, bottom-to-top). + */ +#define EXA_TWO_BITBLT_DIRECTIONS (1 << 2) + +/** + * EXA_HANDLES_PIXMAPS indicates to EXA that the driver can handle + * all pixmap addressing and migration. + */ +#define EXA_HANDLES_PIXMAPS (1 << 3) + +/** + * EXA_SUPPORTS_PREPARE_AUX indicates to EXA that the driver can handle the + * EXA_PREPARE_AUX* indices in the Prepare/FinishAccess hooks. If there are no + * such hooks, this flag has no effect. + */ +#define EXA_SUPPORTS_PREPARE_AUX (1 << 4) + +/** + * EXA_SUPPORTS_OFFSCREEN_OVERLAPS indicates to EXA that the driver Copy hooks + * can handle the source and destination occupying overlapping offscreen memory + * areas. This allows the offscreen memory defragmentation code to defragment + * areas where the defragmented position overlaps the fragmented position. + * + * Typically this is supported by traditional 2D engines but not by 3D engines. + */ +#define EXA_SUPPORTS_OFFSCREEN_OVERLAPS (1 << 5) + +/** + * EXA_MIXED_PIXMAPS will hide unacceleratable pixmaps from drivers and manage the + * problem known software fallbacks like trapezoids. This only migrates pixmaps one way + * into a driver pixmap and then pins it. + */ +#define EXA_MIXED_PIXMAPS (1 << 6) + +/** @} */ + +/* in exa.c */ +extern _X_EXPORT ExaDriverPtr exaDriverAlloc(void); + +extern _X_EXPORT Bool + exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo); + +extern _X_EXPORT void + exaDriverFini(ScreenPtr pScreen); + +extern _X_EXPORT void + exaMarkSync(ScreenPtr pScreen); +extern _X_EXPORT void + exaWaitSync(ScreenPtr pScreen); + +extern _X_EXPORT unsigned long + exaGetPixmapOffset(PixmapPtr pPix); + +extern _X_EXPORT unsigned long + exaGetPixmapPitch(PixmapPtr pPix); + +extern _X_EXPORT void *exaGetPixmapDriverPrivate(PixmapPtr p); + +/* in exa_offscreen.c */ +extern _X_EXPORT ExaOffscreenArea *exaOffscreenAlloc(ScreenPtr pScreen, + int size, int align, + Bool locked, + ExaOffscreenSaveProc save, + void *privData); + +extern _X_EXPORT ExaOffscreenArea *exaOffscreenFree(ScreenPtr pScreen, + ExaOffscreenArea * area); + +extern _X_EXPORT void + exaEnableDisableFBAccess(ScreenPtr pScreen, Bool enable); + +extern _X_EXPORT Bool + exaDrawableIsOffscreen(DrawablePtr pDrawable); + +/* in exa.c */ +extern _X_EXPORT void + exaMoveInPixmap(PixmapPtr pPixmap); + +/* in exa_unaccel.c */ +extern _X_EXPORT CARD32 + exaGetPixmapFirstPixel(PixmapPtr pPixmap); + +/** + * Returns TRUE if the given planemask covers all the significant bits in the + * pixel values for pDrawable. + */ +#define EXA_PM_IS_SOLID(_pDrawable, _pm) \ + (((_pm) & FbFullMask((_pDrawable)->depth)) == \ + FbFullMask((_pDrawable)->depth)) + +#endif /* EXA_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/exevents.h b/prebuilt/xlibre/usr/include/xorg/exevents.h new file mode 100644 index 0000000..b58596b --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/exevents.h @@ -0,0 +1,125 @@ +/************************************************************ + +Copyright 1996 by Thomas E. Dickey + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of the above listed +copyright holder(s) not be used in advertising or publicity pertaining +to distribution of the software without specific, written prior +permission. + +THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD +TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE +LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +/******************************************************************** + * Interface of 'exevents.c' + */ + +#ifndef EXEVENTS_H +#define EXEVENTS_H + +#include +#include "inputstr.h" + +/*************************************************************** + * Interface available to drivers * + ***************************************************************/ + +/** + * Scroll flags for ::SetScrollValuator. + */ +enum ScrollFlags { + SCROLL_FLAG_NONE = 0, + /** + * Do not emulate legacy button events for valuator events on this axis. + */ + SCROLL_FLAG_DONT_EMULATE = (1 << 1), + /** + * This axis is the preferred axis for valuator emulation for this axis' + * scroll type. + */ + SCROLL_FLAG_PREFERRED = (1 << 2) +}; + +extern _X_EXPORT int InitProximityClassDeviceStruct(DeviceIntPtr /* dev */ ); + +extern _X_EXPORT Bool InitValuatorAxisStruct(DeviceIntPtr /* dev */ , + int /* axnum */ , + Atom /* label */ , + int /* minval */ , + int /* maxval */ , + int /* resolution */ , + int /* min_res */ , + int /* max_res */ , + int /* mode */ ); + +extern _X_EXPORT Bool SetScrollValuator(DeviceIntPtr /* dev */ , + int /* axnum */ , + enum ScrollType /* type */ , + double /* increment */ , + int /* flags */ ); + +extern _X_EXPORT int XIDeleteDeviceProperty(DeviceIntPtr /* device */ , + Atom /* property */ , + Bool /* fromClient */ + ); + +extern _X_EXPORT int XIChangeDeviceProperty(DeviceIntPtr /* dev */ , + Atom /* property */ , + Atom /* type */ , + int /* format */ , + int /* mode */ , + unsigned long /* len */ , + const void * /* value */ , + Bool /* sendevent */ + ); + +extern _X_EXPORT int XIGetDeviceProperty(DeviceIntPtr /* dev */ , + Atom /* property */ , + XIPropertyValuePtr * /* value */ + ); + +extern _X_EXPORT int XISetDevicePropertyDeletable(DeviceIntPtr /* dev */ , + Atom /* property */ , + Bool /* deletable */ + ); + +extern _X_EXPORT long XIRegisterPropertyHandler(DeviceIntPtr dev, + int (*SetProperty) (DeviceIntPtr + dev, + Atom + property, + XIPropertyValuePtr + prop, + BOOL + checkonly), + int (*GetProperty) (DeviceIntPtr + dev, + Atom + property), + int (*DeleteProperty) + (DeviceIntPtr dev, + Atom property) + ); + +extern _X_EXPORT Atom XIGetKnownProperty(const char *name); + +extern _X_EXPORT DeviceIntPtr XIGetDevice(xEvent *ev); + +/**************************************************************************** + * End of driver interface * + ****************************************************************************/ + +#endif /* EXEVENTS_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/extension.h b/prebuilt/xlibre/usr/include/xorg/extension.h new file mode 100644 index 0000000..168019b --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/extension.h @@ -0,0 +1,104 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef EXTENSION_H +#define EXTENSION_H + +#include + +#include "xlibre_ptrtypes.h" +#include "dixstruct.h" + +typedef void (*InitExtension) (void); + +typedef struct { + InitExtension initFunc; + const char *name; + Bool *disablePtr; +} ExtensionModule; + +extern _X_EXPORT unsigned short StandardMinorOpcode(ClientPtr /*client */ ); + +extern _X_EXPORT Bool EnableDisableExtension(const char *name, Bool enable); + +extern _X_EXPORT void EnableDisableExtensionError(const char *name, + Bool enable); + +extern _X_EXPORT void InitExtensions(int argc, char **argv); + +extern _X_EXPORT void CloseDownExtensions(void); + +extern _X_EXPORT void LoadExtensionList(const ExtensionModule ext[], + int listSize, Bool external); + +#endif /* EXTENSION_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/extinit.h b/prebuilt/xlibre/usr/include/xorg/extinit.h new file mode 100644 index 0000000..7df1a08 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/extinit.h @@ -0,0 +1,68 @@ +/************************************************************ + +Copyright 1996 by Thomas E. Dickey + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of the above listed +copyright holder(s) not be used in advertising or publicity pertaining +to distribution of the software without specific, written prior +permission. + +THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD +TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE +LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +/* + * Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- + * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall not + * be used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from the XFree86 Project. + */ + +#ifndef EXTINIT_H +#define EXTINIT_H + +#include "extnsionst.h" + +/* required by: libglx */ +extern _X_EXPORT Bool noCompositeExtension; + +/* required by: several video drivers (eg. vmware, sis and nvidia proprietary) */ +#ifdef XINERAMA +extern _X_EXPORT Bool noPanoramiXExtension; +#endif /* XINERAMA */ + +#if defined(XV) +extern _X_EXPORT Bool noXvExtension; +#endif + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/extnsionst.h b/prebuilt/xlibre/usr/include/xorg/extnsionst.h new file mode 100644 index 0000000..083e514 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/extnsionst.h @@ -0,0 +1,98 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef EXTENSIONSTRUCT_H +#define EXTENSIONSTRUCT_H + +#include "xlibre_ptrtypes.h" +#include "extension.h" +#include "privates.h" + +typedef struct _ExtensionEntry { + int index; + void (*CloseDown) ( /* called at server shutdown */ + struct _ExtensionEntry * /* extension */ ); + const char *name; /* extension name */ + int base; /* base request number */ + int eventBase; + int eventLast; + int errorBase; + int errorLast; + void *extPrivate; + unsigned short (*MinorOpcode) ( /* called for errors */ + ClientPtr /* client */ ); + PrivateRec *devPrivates; +} ExtensionEntry; + +/* + * The arguments may be different for extension event swapping functions. + * Deal with this by casting when initializing the event's EventSwapVector[] + * entries. + */ +typedef void (*EventSwapPtr) (xEvent *, xEvent *); + +extern _X_EXPORT EventSwapPtr EventSwapVector[128]; + +extern _X_EXPORT void +NotImplemented( /* FIXME: this may move to another file... */ + xEvent *, xEvent *) _X_NORETURN; + +extern _X_EXPORT ExtensionEntry * +AddExtension(const char * /*name */ , + int /*NumEvents */ , + int /*NumErrors */ , + int (* /*MainProc */ )(ClientPtr /*client */ ), + int (* /*SwappedMainProc */ )(ClientPtr /*client */ ), + void (* /*CloseDownProc */ )(ExtensionEntry * /*extension */ ), + unsigned short (* /*MinorOpcodeProc */ )(ClientPtr /*client */ ) + ); + +extern _X_EXPORT ExtensionEntry * +CheckExtension(const char *extname); +extern _X_EXPORT ExtensionEntry * +GetExtensionEntry(int major); + +#endif /* EXTENSIONSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/fb.h b/prebuilt/xlibre/usr/include/xorg/fb.h new file mode 100644 index 0000000..7ca5c1b --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/fb.h @@ -0,0 +1,1017 @@ +/* + * + * Copyright © 1998 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _FB_H_ +#define _FB_H_ + +#include +#include + +#include "scrnintstr.h" +#include "pixmap.h" +#include "pixmapstr.h" +#include "regionstr.h" +#include "gcstruct.h" +#include "colormap.h" +#include "miscstruct.h" +#include "servermd.h" +#include "windowstr.h" +#include "privates.h" +#include "mi.h" +#include "migc.h" +#include "picturestr.h" + +#ifdef FB_ACCESS_WRAPPER + +#include "wfbrename.h" +#define FBPREFIX(x) wfb##x +#define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr)))) +#define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr)))) + +#else + +#define FBPREFIX(x) fb##x +#define WRITE(ptr, val) (*(ptr) = (val)) +#define READ(ptr) (*(ptr)) + +#endif + +/* + * This single define controls the basic size of data manipulated + * by this software; it must be log2(sizeof (FbBits) * 8) + */ + +#ifndef FB_SHIFT +#define FB_SHIFT LOG2_BITMAP_PAD +#endif + +#define FB_UNIT (1 << FB_SHIFT) +#define FB_MASK (FB_UNIT - 1) +#define FB_ALLONES ((FbBits) -1) +#define FB_STIP_SHIFT LOG2_BITMAP_PAD +#define FB_STIP_UNIT (1 << FB_STIP_SHIFT) +#define FB_STIP_MASK (FB_STIP_UNIT - 1) +#define FB_STIP_ALLONES ((FbStip) -1) +#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << (n)) - 1)) + +#if FB_SHIFT == 5 +typedef CARD32 FbBits; +#else +#error "Unsupported FB_SHIFT" +#endif + +#if LOG2_BITMAP_PAD == FB_SHIFT +typedef FbBits FbStip; +#endif + +typedef int FbStride; + +#include "fbrop.h" + +#if BITMAP_BIT_ORDER == LSBFirst +#define FbScrLeft(x,n) ((x) >> (n)) +#define FbScrRight(x,n) ((x) << (n)) +#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1)) +#define FbStipMoveLsb(x,s,n) (FbStipRight ((x),(s)-(n))) +#define FbPatternOffsetBits 0 +#else +#define FbScrLeft(x,n) ((x) << (n)) +#define FbScrRight(x,n) ((x) >> (n)) +#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n))) +#define FbStipMoveLsb(x,s,n) (x) +#define FbPatternOffsetBits (sizeof (FbBits) - 1) +#endif + +#include "micoord.h" + +#define FbStipLeft(x,n) FbScrLeft((x),(n)) +#define FbStipRight(x,n) FbScrRight((x),(n)) + +#define FbRotLeft(x,n) FbScrLeft((x),(n)) | ((n) ? FbScrRight((x),FB_UNIT-(n)) : 0) + +#define FbLeftMask(x) ( ((x) & FB_MASK) ? \ + FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0) +#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \ + FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0) + +#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \ + FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0) +#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \ + FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0) + +#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \ + FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK)) + +#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \ + FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK)) + +#define FbByteMaskInvalid 0x10 + +#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1))) + +#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o))) +#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset ((o),t) << 3)) +#define FbStorePart(dst,off,t,xor) (WRITE(FbPtrOffset((dst),(off),t), \ + FbSelectPart((xor),(off),t))) +#ifndef FbSelectPart +#define FbSelectPart(x,o,t) FbSelectPatternPart((x),(o),t) +#endif + +#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \ + (n) = (w); \ + (lb) = 0; \ + (rb) = 0; \ + (r) = FbRightMask((x)+(n)); \ + if (r) { \ + /* compute right byte length */ \ + if ((copy) && (((x) + (n)) & 7) == 0) { \ + (rb) = (((x) + (n)) & FB_MASK) >> 3; \ + } else { \ + (rb) = FbByteMaskInvalid; \ + } \ + } \ + (l) = FbLeftMask((x)); \ + if (l) { \ + /* compute left byte length */ \ + if ((copy) && ((x) & 7) == 0) { \ + (lb) = ((x) & FB_MASK) >> 3; \ + } else { \ + (lb) = FbByteMaskInvalid; \ + } \ + /* subtract out the portion painted by leftMask */ \ + (n) -= FB_UNIT - ((x) & FB_MASK); \ + if ((n) < 0) { \ + if ((lb) != FbByteMaskInvalid) { \ + if ((rb) == FbByteMaskInvalid) { \ + (lb) = FbByteMaskInvalid; \ + } else if (rb) { \ + (lb) |= ((rb) - (lb)) << (FB_SHIFT - 3); \ + (rb) = 0; \ + } \ + } \ + (n) = 0; \ + (l) &= (r); \ + (r) = 0; \ + }\ + } \ + (n) >>= FB_SHIFT; \ +} + +#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \ + switch (lb) { \ + case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \ + FbStorePart((dst),sizeof (FbBits) - 3,CARD8,(xor)); \ + break; \ + case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \ + FbStorePart((dst),sizeof (FbBits) - 3,CARD8,(xor)); \ + FbStorePart((dst),sizeof (FbBits) - 2,CARD8,(xor)); \ + break; \ + case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \ + FbStorePart((dst),sizeof (FbBits) - 2,CARD8,(xor)); \ + break; \ + case sizeof (FbBits) - 3: \ + FbStorePart((dst),sizeof (FbBits) - 3,CARD8,(xor)); \ + /* fallthrough */ \ + case sizeof (FbBits) - 2: \ + FbStorePart((dst),sizeof (FbBits) - 2,CARD16,(xor)); \ + break; \ + case sizeof (FbBits) - 1: \ + FbStorePart((dst),sizeof (FbBits) - 1,CARD8,(xor)); \ + break; \ + default: \ + WRITE((dst), FbDoMaskRRop(READ((dst)), (and), (xor), (l))); \ + break; \ + } \ +} + +#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \ + switch (rb) { \ + case 1: \ + FbStorePart((dst),0,CARD8,(xor)); \ + break; \ + case 2: \ + FbStorePart((dst),0,CARD16,(xor)); \ + break; \ + case 3: \ + FbStorePart((dst),0,CARD16,(xor)); \ + FbStorePart((dst),2,CARD8,(xor)); \ + break; \ + default: \ + WRITE((dst), FbDoMaskRRop (READ((dst)), (and), (xor), (r))); \ + } \ +} + +/* Framebuffer access wrapper */ +typedef FbBits(*ReadMemoryProcPtr) (const void *src, int size); +typedef void (*WriteMemoryProcPtr) (void *dst, FbBits value, int size); +typedef void (*SetupWrapProcPtr) (ReadMemoryProcPtr * pRead, + WriteMemoryProcPtr * pWrite, + DrawablePtr pDraw); +typedef void (*FinishWrapProcPtr) (DrawablePtr pDraw); + +#ifdef FB_ACCESS_WRAPPER + +#define fbPrepareAccess(pDraw) \ + fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \ + &wfbReadMemory, \ + &wfbWriteMemory, \ + (pDraw)) +#define fbFinishAccess(pDraw) \ + fbGetScreenPrivate((pDraw)->pScreen)->finishWrap((pDraw)) + +#else + +#define fbPrepareAccess(pPix) +#define fbFinishAccess(pDraw) + +#endif + +extern _X_EXPORT DevPrivateKey +fbGetScreenPrivateKey(void); + +/* private field of a screen */ +typedef struct { +#ifdef FB_ACCESS_WRAPPER + SetupWrapProcPtr setupWrap; /* driver hook to set pixmap access wrapping */ + FinishWrapProcPtr finishWrap; /* driver hook to clean up pixmap access wrapping */ +#endif + DevPrivateKeyRec gcPrivateKeyRec; + DevPrivateKeyRec winPrivateKeyRec; +} FbScreenPrivRec, *FbScreenPrivPtr; + +#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey())) + +/* private field of GC */ +typedef struct { + FbBits and, xor; /* reduced rop values */ + FbBits bgand, bgxor; /* for stipples */ + FbBits fg, bg, pm; /* expanded and filled */ + unsigned int dashLength; /* total of all dash elements */ +} FbGCPrivRec, *FbGCPrivPtr; + +#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip) + +#define fbGetWinPrivateKey(pWin) (&fbGetScreenPrivate(((DrawablePtr) (pWin))->pScreen)->winPrivateKeyRec) + +#define fbGetWindowPixmap(pWin) ((PixmapPtr)\ + dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey((pWin)))) + +#define __fbPixDrawableX(pPix) ((pPix)->drawable.x) +#define __fbPixDrawableY(pPix) ((pPix)->drawable.y) + +#define __fbPixOffXWin(pPix) (__fbPixDrawableX((pPix)) - (pPix)->screen_x) +#define __fbPixOffYWin(pPix) (__fbPixDrawableY((pPix)) - (pPix)->screen_y) +#define __fbPixOffXPix(pPix) (__fbPixDrawableX((pPix))) +#define __fbPixOffYPix(pPix) (__fbPixDrawableY((pPix))) + +#define fbGetDrawablePixmap(pDrawable, pixmap, xoff, yoff) { \ + if ((pDrawable)->type != DRAWABLE_PIXMAP) { \ + (pixmap) = fbGetWindowPixmap((pDrawable)); \ + (xoff) = __fbPixOffXWin((pixmap)); \ + (yoff) = __fbPixOffYWin((pixmap)); \ + } else { \ + (pixmap) = (PixmapPtr) (pDrawable); \ + (xoff) = __fbPixOffXPix((pixmap)); \ + (yoff) = __fbPixOffYPix((pixmap)); \ + } \ + fbPrepareAccess((pDrawable)); \ +} + +#define fbGetPixmapBitsData(pixmap, pointer, stride, bpp) { \ + (pointer) = (FbBits *) (pixmap)->devPrivate.ptr; \ + (stride) = ((int) (pixmap)->devKind) / sizeof (FbBits); (void)(stride); \ + (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \ +} + +#define fbGetPixmapStipData(pixmap, pointer, stride, bpp) { \ + (pointer) = (FbStip *) (pixmap)->devPrivate.ptr; \ + (stride) = ((int) (pixmap)->devKind) / sizeof (FbStip); (void)(stride); \ + (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \ +} + +#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \ + PixmapPtr _pPix; \ + fbGetDrawablePixmap((pDrawable), _pPix, (xoff), (yoff)); \ + fbGetPixmapBitsData(_pPix, (pointer), (stride), (bpp)); \ +} + +#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \ + PixmapPtr _pPix; \ + fbGetDrawablePixmap((pDrawable), _pPix, (xoff), (yoff)); \ + fbGetPixmapStipData(_pPix, (pointer), (stride), (bpp)); \ +} + +/* + * XFree86 empties the root BorderClip when the VT is inactive, + * here's a macro which uses that to disable GetImage and GetSpans + */ + +#define fbWindowEnabled(pWin) \ + RegionNotEmpty(&(pWin)->borderClip) + +#define fbDrawableEnabled(pDrawable) \ + ((pDrawable)->type == DRAWABLE_PIXMAP ? \ + TRUE : fbWindowEnabled((WindowPtr) (pDrawable))) + +#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0) +/* + * Accelerated tiles are power of 2 width <= FB_UNIT + */ +#define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo((w))) + +/* + * fbarc.c + */ + +extern _X_EXPORT void +fbPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * parcs); + +/* + * fbbits.c + */ + +extern _X_EXPORT void + +fbBresSolid8(DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, + int axis, int x, int y, int e, int e1, int e3, int len); + +extern _X_EXPORT void + +fbBresDash8(DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, int axis, int x, int y, int e, int e1, int e3, int len); + +extern _X_EXPORT void + +fbDots8(FbBits * dst, + FbStride dstStride, + int dstBpp, + BoxPtr pBox, + xPoint * pts, + int npt, + int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor); + +extern _X_EXPORT void + +fbArc8(FbBits * dst, + FbStride dstStride, + int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor); + +extern _X_EXPORT void + +fbGlyph8(FbBits * dstLine, + FbStride dstStride, + int dstBpp, FbStip * stipple, FbBits fg, int height, int shift); + +extern _X_EXPORT void + +fbPolyline8(DrawablePtr pDrawable, + GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig); + +extern _X_EXPORT void + fbPolySegment8(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg); + +extern _X_EXPORT void + +fbBresSolid16(DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, + int axis, int x, int y, int e, int e1, int e3, int len); + +extern _X_EXPORT void + +fbBresDash16(DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, + int axis, int x, int y, int e, int e1, int e3, int len); + +extern _X_EXPORT void + +fbDots16(FbBits * dst, + FbStride dstStride, + int dstBpp, + BoxPtr pBox, + xPoint * pts, + int npt, + int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor); + +extern _X_EXPORT void + +fbArc16(FbBits * dst, + FbStride dstStride, + int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor); + +extern _X_EXPORT void + +fbGlyph16(FbBits * dstLine, + FbStride dstStride, + int dstBpp, FbStip * stipple, FbBits fg, int height, int shift); + +extern _X_EXPORT void + +fbPolyline16(DrawablePtr pDrawable, + GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig); + +extern _X_EXPORT void + fbPolySegment16(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg); + +extern _X_EXPORT void + +fbBresSolid32(DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, + int axis, int x, int y, int e, int e1, int e3, int len); + +extern _X_EXPORT void + +fbBresDash32(DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, + int axis, int x, int y, int e, int e1, int e3, int len); + +extern _X_EXPORT void + +fbDots32(FbBits * dst, + FbStride dstStride, + int dstBpp, + BoxPtr pBox, + xPoint * pts, + int npt, + int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor); + +extern _X_EXPORT void + +fbArc32(FbBits * dst, + FbStride dstStride, + int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor); + +extern _X_EXPORT void + +fbGlyph32(FbBits * dstLine, + FbStride dstStride, + int dstBpp, FbStip * stipple, FbBits fg, int height, int shift); +extern _X_EXPORT void + +fbPolyline32(DrawablePtr pDrawable, + GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig); + +extern _X_EXPORT void + fbPolySegment32(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg); + +/* + * fbblt.c + */ +extern _X_EXPORT void + +fbBlt(FbBits * src, + FbStride srcStride, + int srcX, + FbBits * dst, + FbStride dstStride, + int dstX, + int width, + int height, int alu, FbBits pm, int bpp, Bool reverse, Bool upsidedown); + +extern _X_EXPORT void + fbBltStip(FbStip * src, FbStride srcStride, /* in FbStip units, not FbBits units */ + int srcX, FbStip * dst, FbStride dstStride, /* in FbStip units, not FbBits units */ + int dstX, int width, int height, int alu, FbBits pm, int bpp); + +/* + * fbbltone.c + */ +extern _X_EXPORT void + +fbBltOne(FbStip * src, + FbStride srcStride, + int srcX, + FbBits * dst, + FbStride dstStride, + int dstX, + int dstBpp, + int width, + int height, FbBits fgand, FbBits fbxor, FbBits bgand, FbBits bgxor); + +extern _X_EXPORT void + +fbBltPlane(FbBits * src, + FbStride srcStride, + int srcX, + int srcBpp, + FbStip * dst, + FbStride dstStride, + int dstX, + int width, + int height, + FbStip fgand, + FbStip fgxor, FbStip bgand, FbStip bgxor, Pixel planeMask); + +/* + * fbcmap_mi.c + */ +extern _X_EXPORT void + fbInstallColormap(ColormapPtr pmap); + +extern _X_EXPORT void + fbUninstallColormap(ColormapPtr pmap); + +extern _X_EXPORT void + +fbResolveColor(unsigned short *pred, + unsigned short *pgreen, + unsigned short *pblue, VisualPtr pVisual); + +extern _X_EXPORT Bool + fbInitializeColormap(ColormapPtr pmap); + +extern _X_EXPORT Bool + mfbCreateColormap(ColormapPtr pmap); + +extern _X_EXPORT int + +fbExpandDirectColors(ColormapPtr pmap, + int ndef, xColorItem * indefs, xColorItem * outdefs); + +extern _X_EXPORT Bool + fbCreateDefColormap(ScreenPtr pScreen); + +extern _X_EXPORT void + fbClearVisualTypes(void); + +extern _X_EXPORT Bool + fbSetVisualTypes(int depth, int visuals, int bitsPerRGB); + +extern _X_EXPORT Bool +fbSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, + Pixel redMask, Pixel greenMask, Pixel blueMask); + +extern _X_EXPORT Bool + +fbInitVisuals(VisualPtr * visualp, + DepthPtr * depthp, + int *nvisualp, + int *ndepthp, + int *rootDepthp, + VisualID * defaultVisp, unsigned long sizes, int bitsPerRGB); + +/* + * fbcopy.c + */ + +extern _X_EXPORT void + +fbCopyNtoN(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, Bool upsidedown, Pixel bitplane, void *closure); + +extern _X_EXPORT void + +fbCopy1toN(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, Bool upsidedown, Pixel bitplane, void *closure); + +extern _X_EXPORT void + +fbCopyNto1(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, Bool upsidedown, Pixel bitplane, void *closure); + +extern _X_EXPORT RegionPtr + +fbCopyArea(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + int xIn, int yIn, int widthSrc, int heightSrc, int xOut, int yOut); + +extern _X_EXPORT RegionPtr + +fbCopyPlane(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + int xIn, + int yIn, + int widthSrc, + int heightSrc, int xOut, int yOut, unsigned long bitplane); + +/* + * fbfill.c + */ +extern _X_EXPORT void + fbFill(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height); + +extern _X_EXPORT void + +fbSolidBoxClipped(DrawablePtr pDrawable, + RegionPtr pClip, + int xa, int ya, int xb, int yb, FbBits and, FbBits xor); + +/* + * fbfillrect.c + */ +extern _X_EXPORT void + +fbPolyFillRect(DrawablePtr pDrawable, + GCPtr pGC, int nrectInit, xRectangle *prectInit); + +/* + * fbfillsp.c + */ +extern _X_EXPORT void + +fbFillSpans(DrawablePtr pDrawable, + GCPtr pGC, + int nInit, DDXPointPtr pptInit, int *pwidthInit, int fSorted); + +/* + * fbgc.c + */ + +extern _X_EXPORT Bool + fbCreateGC(GCPtr pGC); + +extern _X_EXPORT void + fbPadPixmap(PixmapPtr pPixmap); + +extern _X_EXPORT void + fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable); + +/* + * fbgetsp.c + */ +extern _X_EXPORT void + +fbGetSpans(DrawablePtr pDrawable, + int wMax, + DDXPointPtr ppt, int *pwidth, int nspans, char *pchardstStart); + +/* + * fbglyph.c + */ + +extern _X_EXPORT void + +fbPolyGlyphBlt(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, CharInfoPtr * ppci, void *pglyphBase); + +extern _X_EXPORT void + +fbImageGlyphBlt(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, CharInfoPtr * ppci, void *pglyphBase); + +/* + * fbimage.c + */ + +extern _X_EXPORT void + +fbPutImage(DrawablePtr pDrawable, + GCPtr pGC, + int depth, + int x, int y, int w, int h, int leftPad, int format, char *pImage); + +extern _X_EXPORT void + +fbPutZImage(DrawablePtr pDrawable, + RegionPtr pClip, + int alu, + FbBits pm, + int x, + int y, int width, int height, FbStip * src, FbStride srcStride); + +extern _X_EXPORT void + +fbPutXYImage(DrawablePtr pDrawable, + RegionPtr pClip, + FbBits fg, + FbBits bg, + FbBits pm, + int alu, + Bool opaque, + int x, + int y, + int width, int height, FbStip * src, FbStride srcStride, int srcX); + +extern _X_EXPORT void + +fbGetImage(DrawablePtr pDrawable, + int x, + int y, + int w, int h, unsigned int format, unsigned long planeMask, char *d); +/* + * fbline.c + */ + +extern _X_EXPORT void +fbPolyLine(DrawablePtr pDrawable, + GCPtr pGC, int mode, int npt, DDXPointPtr ppt); + +extern _X_EXPORT void + fbFixCoordModePrevious(int npt, DDXPointPtr ppt); + +extern _X_EXPORT void + fbPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg); + +/* + * fbpict.c + */ + +extern _X_EXPORT Bool + fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats); + +extern _X_EXPORT void +fbDestroyGlyphCache(void); + +/* + * fbpixmap.c + */ + +extern _X_EXPORT PixmapPtr +fbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, + unsigned usage_hint); + +extern _X_EXPORT Bool + fbDestroyPixmap(PixmapPtr pPixmap); + +extern _X_EXPORT RegionPtr + fbPixmapToRegion(PixmapPtr pPix); + +/* + * fbpoint.c + */ + +extern _X_EXPORT void + +fbPolyPoint(DrawablePtr pDrawable, + GCPtr pGC, int mode, int npt, xPoint * pptInit); + +/* + * fbpush.c + */ + +extern _X_EXPORT void + +fbPushImage(DrawablePtr pDrawable, + GCPtr pGC, + FbStip * src, + FbStride srcStride, int srcX, int x, int y, int width, int height); + +extern _X_EXPORT void + +fbPushPixels(GCPtr pGC, + PixmapPtr pBitmap, + DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg); + +/* + * fbscreen.c + */ + +extern _X_EXPORT Bool + fbCloseScreen(ScreenPtr pScreen); + +extern _X_EXPORT Bool + fbRealizeFont(ScreenPtr pScreen, FontPtr pFont); + +extern _X_EXPORT Bool + fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont); + +extern _X_EXPORT void + +fbQueryBestSize(int class, + unsigned short *width, unsigned short *height, + ScreenPtr pScreen); + +extern _X_EXPORT PixmapPtr + _fbGetWindowPixmap(WindowPtr pWindow); + +extern _X_EXPORT void + _fbSetWindowPixmap(WindowPtr pWindow, PixmapPtr pPixmap); + +extern _X_EXPORT Bool + fbSetupScreen(ScreenPtr pScreen, void *pbits, /* pointer to screen bitmap */ + int xsize, /* in pixels */ + int ysize, int dpix, /* dots per inch */ + int dpiy, int width, /* pixel width of frame buffer */ + int bpp); /* bits per pixel of frame buffer */ + +#ifdef FB_ACCESS_WRAPPER +extern _X_EXPORT Bool +wfbFinishScreenInit(ScreenPtr pScreen, + void *pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp, + SetupWrapProcPtr setupWrap, FinishWrapProcPtr finishWrap); + +extern _X_EXPORT Bool +wfbScreenInit(ScreenPtr pScreen, + void *pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp, + SetupWrapProcPtr setupWrap, FinishWrapProcPtr finishWrap); +#endif + +extern _X_EXPORT Bool +fbFinishScreenInit(ScreenPtr pScreen, + void *pbits, + int xsize, + int ysize, int dpix, int dpiy, int width, int bpp); + +extern _X_EXPORT Bool + +fbScreenInit(ScreenPtr pScreen, + void *pbits, + int xsize, int ysize, int dpix, int dpiy, int width, int bpp); + +/* + * fbseg.c + */ +typedef void FbBres(DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, + int axis, int x, int y, int e, int e1, int e3, int len); + +extern _X_EXPORT void +fbSegment(DrawablePtr pDrawable, + GCPtr pGC, + int xa, int ya, int xb, int yb, Bool drawLast, int *dashOffset); + +/* + * fbsetsp.c + */ + +extern _X_EXPORT void +fbSetSpans(DrawablePtr pDrawable, + GCPtr pGC, + char *src, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted); + +/* + * fbsolid.c + */ + +extern _X_EXPORT void + +fbSolid(FbBits * dst, + FbStride dstStride, + int dstX, int bpp, int width, int height, FbBits and, FbBits xor); + +/* + * fbtile.c + */ + +extern _X_EXPORT void + +fbEvenTile(FbBits * dst, + FbStride dstStride, + int dstX, + int width, + int height, + FbBits * tile, + FbStride tileStride, + int tileHeight, int alu, FbBits pm, int xRot, int yRot); + +extern _X_EXPORT void + +fbOddTile(FbBits * dst, + FbStride dstStride, + int dstX, + int width, + int height, + FbBits * tile, + FbStride tileStride, + int tileWidth, + int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot); + +extern _X_EXPORT void + +fbTile(FbBits * dst, + FbStride dstStride, + int dstX, + int width, + int height, + FbBits * tile, + FbStride tileStride, + int tileWidth, + int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot); + +/* + * fbutil.c + */ +extern _X_EXPORT FbBits fbReplicatePixel(Pixel p, int bpp); + +#ifdef FB_ACCESS_WRAPPER +extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory; +extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory; +#endif + +/* + * fbwindow.c + */ + +extern _X_EXPORT Bool + fbCreateWindow(WindowPtr pWin); + +extern _X_EXPORT Bool + fbDestroyWindow(WindowPtr pWin); + +extern _X_EXPORT Bool + fbRealizeWindow(WindowPtr pWindow); + +extern _X_EXPORT Bool + fbPositionWindow(WindowPtr pWin, int x, int y); + +extern _X_EXPORT Bool + fbUnrealizeWindow(WindowPtr pWindow); + +extern _X_EXPORT void + +fbCopyWindowProc(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, Bool upsidedown, Pixel bitplane, void *closure); + +_X_EXPORT void fbCopyWindow(WindowPtr pWin, xPoint ptOldOrg, RegionPtr prgnSrc); + +extern _X_EXPORT Bool + fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask); + +extern _X_EXPORT void + +fbFillRegionSolid(DrawablePtr pDrawable, + RegionPtr pRegion, FbBits and, FbBits xor); + +extern _X_EXPORT pixman_image_t *image_from_pict(PicturePtr pict, + Bool has_clip, + int *xoff, int *yoff); + +extern _X_EXPORT void free_pixman_pict(PicturePtr, pixman_image_t *); + +#endif /* _FB_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/fbdevhw.h b/prebuilt/xlibre/usr/include/xorg/fbdevhw.h new file mode 100644 index 0000000..3de5779 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/fbdevhw.h @@ -0,0 +1,56 @@ + +#ifndef _FBDEVHW_H_ +#define _FBDEVHW_H_ + +#include "xf86str.h" + +#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ +#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ +#define FBDEVHW_TEXT 3 /* Text/attributes */ +#define FBDEVHW_VGA_PLANES 4 /* EGA/VGA planes */ + +extern _X_EXPORT Bool fbdevHWProbe(struct pci_device *pPci, const char *device, + char **namep); +extern _X_EXPORT Bool fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, + const char *device); + +extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn); +extern _X_EXPORT int fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp); +extern _X_EXPORT int fbdevHWGetLineLength(ScrnInfoPtr pScrn); +extern _X_EXPORT int fbdevHWGetType(ScrnInfoPtr pScrn); +extern _X_EXPORT int fbdevHWGetVidmem(ScrnInfoPtr pScrn); + +extern _X_EXPORT void *fbdevHWMapVidmem(ScrnInfoPtr pScrn); +extern _X_EXPORT int fbdevHWLinearOffset(ScrnInfoPtr pScrn); +extern _X_EXPORT Bool fbdevHWUnmapVidmem(ScrnInfoPtr pScrn); +extern _X_EXPORT void *fbdevHWMapMMIO(ScrnInfoPtr pScrn); +extern _X_EXPORT Bool fbdevHWUnmapMMIO(ScrnInfoPtr pScrn); + +extern _X_EXPORT void fbdevHWSetVideoModes(ScrnInfoPtr pScrn); +extern _X_EXPORT void fbdevHWUseBuildinMode(ScrnInfoPtr pScrn); +extern _X_EXPORT Bool fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +extern _X_EXPORT void fbdevHWSave(ScrnInfoPtr pScrn); +extern _X_EXPORT void fbdevHWRestore(ScrnInfoPtr pScrn); + +extern _X_EXPORT void fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indices, LOCO * colors, + VisualPtr pVisual); + +extern _X_EXPORT ModeStatus fbdevHWValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode, + Bool verbose, int flags); +extern _X_EXPORT Bool fbdevHWSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode); +extern _X_EXPORT void fbdevHWAdjustFrame(ScrnInfoPtr pScrn, int x, int y); +extern _X_EXPORT Bool fbdevHWEnterVT(ScrnInfoPtr pScrn); +extern _X_EXPORT void fbdevHWLeaveVT(ScrnInfoPtr pScrn); +extern _X_EXPORT void fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); + +extern _X_EXPORT Bool fbdevHWSaveScreen(ScreenPtr pScreen, int mode); + +extern _X_EXPORT xf86SwitchModeProc *fbdevHWSwitchModeWeak(void); +extern _X_EXPORT xf86AdjustFrameProc *fbdevHWAdjustFrameWeak(void); +extern _X_EXPORT xf86LeaveVTProc *fbdevHWLeaveVTWeak(void); +extern _X_EXPORT xf86ValidModeProc *fbdevHWValidModeWeak(void); +extern _X_EXPORT xf86DPMSSetProc *fbdevHWDPMSSetWeak(void); +extern _X_EXPORT xf86LoadPaletteProc *fbdevHWLoadPaletteWeak(void); + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/fboverlay.h b/prebuilt/xlibre/usr/include/xorg/fboverlay.h new file mode 100644 index 0000000..4de5a0e --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/fboverlay.h @@ -0,0 +1,76 @@ +/* + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _FBOVERLAY_H_ +#define _FBOVERLAY_H_ + +#include "privates.h" + +extern _X_EXPORT DevPrivateKey fbOverlayGetScreenPrivateKey(void); + +#ifndef FB_OVERLAY_MAX +#define FB_OVERLAY_MAX 2 +#endif + +typedef void (*fbOverlayPaintKeyProc) (DrawablePtr, RegionPtr, CARD32, int); + +typedef struct _fbOverlayLayer { + union { + struct { + void *pbits; + int width; + int depth; + } init; + struct { + PixmapPtr pixmap; + RegionRec region; + } run; + } u; + CARD32 key; /* special pixel value */ +} FbOverlayLayer; + +typedef struct _fbOverlayScrPriv { + int nlayers; + fbOverlayPaintKeyProc PaintKey; + miCopyProc CopyWindow; + FbOverlayLayer layer[FB_OVERLAY_MAX]; +} FbOverlayScrPrivRec, *FbOverlayScrPrivPtr; + +#define fbOverlayGetScrPriv(s) \ + dixLookupPrivate(&(s)->devPrivates, fbOverlayGetScreenPrivateKey()) + +extern _X_EXPORT Bool + +fbOverlayFinishScreenInit(ScreenPtr pScreen, + void *pbits1, + void *pbits2, + int xsize, + int ysize, + int dpix, + int dpiy, + int width1, + int width2, + int bpp1, int bpp2, int depth1, int depth2); + +#endif /* _FBOVERLAY_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/fbpict.h b/prebuilt/xlibre/usr/include/xorg/fbpict.h new file mode 100644 index 0000000..a35765b --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/fbpict.h @@ -0,0 +1,45 @@ +/* + * + * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +#ifndef _FBPICT_H_ +#define _FBPICT_H_ + +#include "fb.h" + +/* fbpict.c */ +extern _X_EXPORT void +fbComposite(CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); + +/* fbtrap.c */ + +extern _X_EXPORT void +fbAddTraps(PicturePtr pPicture, + INT16 xOff, INT16 yOff, int ntrap, xTrap * traps); + +#endif /* _FBPICT_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/fbrop.h b/prebuilt/xlibre/usr/include/xorg/fbrop.h new file mode 100644 index 0000000..c21faca --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/fbrop.h @@ -0,0 +1,129 @@ +/* + * Copyright © 1998 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _FBROP_H_ +#define _FBROP_H_ + +#include + +typedef struct _mergeRopBits { + FbBits ca1, cx1, ca2, cx2; +} FbMergeRopRec, *FbMergeRopPtr; + +extern _X_EXPORT const FbMergeRopRec FbMergeRopBits[16]; + +#define FbDeclareMergeRop() FbBits _ca1, _cx1, _ca2, _cx2; +#define FbDeclarePrebuiltMergeRop() FbBits _cca, _ccx; + +#define FbInitializeMergeRop(alu,pm) {\ + const FbMergeRopRec *_bits; \ + _bits = &FbMergeRopBits[(alu)]; \ + _ca1 = _bits->ca1 & (pm); \ + _cx1 = _bits->cx1 | ~(pm); \ + _ca2 = _bits->ca2 & (pm); \ + _cx2 = _bits->cx2 & (pm); \ +} + +#define FbDestInvarientRop(alu,pm) ((pm) == FB_ALLONES && \ + (((alu) >> 1 & 5) == ((alu) & 5))) + +#define FbDestInvarientMergeRop() (_ca1 == 0 && _cx1 == 0) + +/* AND has higher precedence than XOR */ + +#define FbDoMergeRop(src, dst) \ + (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2)) + +#define FbDoDestInvarientMergeRop(src) (((src) & _ca2) ^ _cx2) + +#define FbDoMaskMergeRop(src, dst, mask) \ + (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask))) + +#define FbDoLeftMaskByteMergeRop(dst, src, lb, l) { \ + FbBits __xor = ((src) & _ca2) ^ _cx2; \ + FbDoLeftMaskByteRRop((dst),(lb),(l),((src) & _ca1) ^ _cx1,__xor); \ +} + +#define FbDoRightMaskByteMergeRop(dst, src, rb, r) { \ + FbBits __xor = ((src) & _ca2) ^ _cx2; \ + FbDoRightMaskByteRRop((dst),(rb),(r),((src) & _ca1) ^ _cx1,__xor); \ +} + +#define FbDoRRop(dst, and, xor) (((dst) & (and)) ^ (xor)) + +#define FbDoMaskRRop(dst, and, xor, mask) \ + (((dst) & ((and) | ~(mask))) ^ ((xor) & (mask))) + +/* + * Take a single bit (0 or 1) and generate a full mask + */ +#define fbFillFromBit(b,t) (~((t) ((b) & 1)-1)) + +#define fbXorT(rop,fg,pm,t) ((((fg) & fbFillFromBit((rop) >> 1,t)) | \ + (~(fg) & fbFillFromBit((rop) >> 3,t))) & (pm)) + +#define fbAndT(rop,fg,pm,t) ((((fg) & fbFillFromBit ((rop) ^ ((rop)>>1),t)) | \ + (~(fg) & fbFillFromBit(((rop)>>2) ^ ((rop)>>3),t))) | \ + ~(pm)) + +#define fbXor(rop,fg,pm) fbXorT((rop),(fg),(pm),FbBits) + +#define fbAnd(rop,fg,pm) fbAndT((rop),(fg),(pm),FbBits) + +#define fbXorStip(rop,fg,pm) fbXorT((rop),(fg),(pm),FbStip) + +#define fbAndStip(rop,fg,pm) fbAndT((rop),(fg),(pm),FbStip) + +/* + * Stippling operations; + */ + +#define FbStippleRRop(dst, b, fa, fx, ba, bx) \ + (FbDoRRop((dst), (fa), (fx)) & (b)) | (FbDoRRop((dst), (ba), (bx)) & ~(b)) + +#define FbStippleRRopMask(dst, b, fa, fx, ba, bx, m) \ + (FbDoMaskRRop((dst), (fa), (fx), (m)) & (b)) | (FbDoMaskRRop((dst), (ba), (bx), (m)) & ~(b)) + +#define FbDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \ + FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \ + FbDoLeftMaskByteRRop((dst), (lb), (l), ((fa) & (b)) | ((ba) & ~(b)), __xor); \ +} + +#define FbDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \ + FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \ + FbDoRightMaskByteRRop((dst), (rb), (r), ((fa) & (b)) | ((ba) & ~(b)), __xor); \ +} + +#define FbOpaqueStipple(b, fg, bg) (((fg) & (b)) | ((bg) & ~(b))) + +/* + * Compute rop for using tile code for 1-bit dest stipples; modifies + * existing rop to flip depending on pixel values + */ +#define FbStipple1RopPick(alu,b) (((alu) >> (2 - (((b) & 1) << 1))) & 3) + +#define FbOpaqueStipple1Rop(alu,fg,bg) (FbStipple1RopPick((alu),(fg)) | \ + (FbStipple1RopPick((alu),(bg)) << 2)) + +#define FbStipple1Rop(alu,fg) (FbStipple1RopPick((alu),(fg)) | 4) + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/fd_notify.h b/prebuilt/xlibre/usr/include/xorg/fd_notify.h new file mode 100644 index 0000000..67a47c8 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/fd_notify.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: X11 OR MIT OR AGPL-3.0-or-later + * + * Copyright © 2024 Enrico Weigelt, metux IT consult + * + * @brief: defines needed for SetNotifyFd() as well as ospoll + */ +#ifndef _XSERVER_INCLUDE_FDNOTIFY_H +#define _XSERVER_INCLUDE_FDNOTIFY_H + +#define X_NOTIFY_NONE 0x0 +#define X_NOTIFY_READ 0x1 +#define X_NOTIFY_WRITE 0x2 +#define X_NOTIFY_ERROR 0x4 /* don't need to select for, always reported */ + +#endif /* _XSERVER_INCLUDE_FDNOTIFY_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/fourcc.h b/prebuilt/xlibre/usr/include/xorg/fourcc.h new file mode 100644 index 0000000..97885e5 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/fourcc.h @@ -0,0 +1,218 @@ + +/* + * Copyright (c) 2000-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + This header file contains listings of STANDARD guids for video formats. + Please do not place non-registered, or incomplete entries in this file. + A list of some popular fourcc's are at: http://www.webartz.com/fourcc/ + For an explanation of fourcc <-> guid mappings see RFC2361. +*/ + +#ifndef _XF86_FOURCC_H_ +#define _XF86_FOURCC_H_ 1 + +#define FOURCC_YUY2 0x32595559 +#define XVIMAGE_YUY2 \ + { \ + FOURCC_YUY2, \ + XvYUV, \ + LSBFirst, \ + {'Y','U','Y','2', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 1, 1, \ + {'Y','U','Y','V', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_YV12 0x32315659 +#define XVIMAGE_YV12 \ + { \ + FOURCC_YV12, \ + XvYUV, \ + LSBFirst, \ + {'Y','V','1','2', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 12, \ + XvPlanar, \ + 3, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 2, 2, \ + {'Y','V','U', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_I420 0x30323449 +#define XVIMAGE_I420 \ + { \ + FOURCC_I420, \ + XvYUV, \ + LSBFirst, \ + {'I','4','2','0', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 12, \ + XvPlanar, \ + 3, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 2, 2, \ + {'Y','U','V', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_UYVY 0x59565955 +#define XVIMAGE_UYVY \ + { \ + FOURCC_UYVY, \ + XvYUV, \ + LSBFirst, \ + {'U','Y','V','Y', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 1, 1, \ + {'U','Y','V','Y', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_IA44 0x34344149 +#define XVIMAGE_IA44 \ + { \ + FOURCC_IA44, \ + XvYUV, \ + LSBFirst, \ + {'I','A','4','4', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 8, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 1, 1, \ + 1, 1, 1, \ + {'A','I', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_AI44 0x34344941 +#define XVIMAGE_AI44 \ + { \ + FOURCC_AI44, \ + XvYUV, \ + LSBFirst, \ + {'A','I','4','4', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 8, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 1, 1, \ + 1, 1, 1, \ + {'I','A', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_NV12 0x3231564e +#define XVIMAGE_NV12 \ + { \ + FOURCC_NV12, \ + XvYUV, \ + LSBFirst, \ + {'N','V','1','2', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 12, \ + XvPlanar, \ + 2, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 2, 2, \ + {'Y','U','V', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_RGBA32 0x41424752 +#define XVIMAGE_RGB32 \ + { \ + FOURCC_RGBA32, \ + XvRGB, \ + LSBFirst, \ + {'R','A','2','4', \ + 0x00, 0x00, 0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 32, \ + XvPacked, \ + 1, \ + 32, 0xff0000, 0xff00, 0xff, \ + 0, 0, 0, \ + 0, 0, 0, \ + 0, 0, 0, \ + {0,0,0,0, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + 0 \ + } + +#define FOURCC_RGB565 0x36314752 +#define XVIMAGE_RGB565 \ + { \ + FOURCC_RGB565, \ + XvRGB, \ + LSBFirst, \ + {'R','G','1','6', \ + 0x00, 0x00, 0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 16, 0xf800, 0x7e0, 0x1f, \ + 0, 0, 0, \ + 0, 0, 0, \ + 0, 0, 0, \ + {0,0,0,0, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + 0 \ + } +#endif /* _XF86_FOURCC_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/gc.h b/prebuilt/xlibre/usr/include/xorg/gc.h new file mode 100644 index 0000000..66e27bc --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/gc.h @@ -0,0 +1,96 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef GC_H +#define GC_H + +#include /* for GContext, Mask */ +#include /* for Bool */ +#include +#include "screenint.h" /* for ScreenPtr */ +#include "pixmap.h" /* for DrawablePtr */ + +/* clientClipType field in GC */ +#define CT_NONE 0 +#define CT_PIXMAP 1 +#define CT_REGION 2 +#define CT_UNSORTED 6 +#define CT_YSORTED 10 +#define CT_YXSORTED 14 +#define CT_YXBANDED 18 + +#define GC_CHANGE_SERIAL_BIT (((unsigned long)1)<<31) + +#define DRAWABLE_SERIAL_BITS (~(GC_CHANGE_SERIAL_BIT)) + +#define MAX_SERIAL_NUM (1L<<28) + +#define NEXT_SERIAL_NUMBER ((++globalSerialNumber) > MAX_SERIAL_NUM ? \ + (globalSerialNumber = 1): globalSerialNumber) + +typedef struct _GCInterest *GCInterestPtr; +typedef struct _GC *GCPtr; +typedef struct _GCOps *GCOpsPtr; + +extern _X_EXPORT void ValidateGC(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ ); + +typedef union { + CARD32 val; + void *ptr; +} ChangeGCVal, *ChangeGCValPtr; + +extern _X_EXPORT int ChangeGC(ClientPtr /*client */ , + GCPtr /*pGC */ , + BITS32 /*mask */ , + ChangeGCValPtr /*pCGCV */ ); + +extern _X_EXPORT GCPtr GetScratchGC(unsigned /*depth */ , + ScreenPtr /*pScreen */ ); + +extern _X_EXPORT void FreeScratchGC(GCPtr /*pGC */ ); + +#endif /* GC_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/gcstruct.h b/prebuilt/xlibre/usr/include/xorg/gcstruct.h new file mode 100644 index 0000000..9e3c53d --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/gcstruct.h @@ -0,0 +1,286 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef GCSTRUCT_H +#define GCSTRUCT_H + +#include + +#include "gc.h" +#include "pixmap.h" +#include "regionstr.h" +#include "screenint.h" +#include "privates.h" + +#ifndef _XTYPEDEF_CHARINFOPTR +typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */ +#define _XTYPEDEF_CHARINFOPTR +#endif + +/* + * functions which modify the state of the GC + */ + +typedef struct _GCFuncs { + void (*ValidateGC) (GCPtr /*pGC */ , + unsigned long /*stateChanges */ , + DrawablePtr /*pDrawable */ ); + + void (*ChangeGC) (GCPtr /*pGC */ , + unsigned long /*mask */ ); + + void (*CopyGC) (GCPtr /*pGCSrc */ , + unsigned long /*mask */ , + GCPtr /*pGCDst */ ); + + void (*DestroyGC) (GCPtr /*pGC */ ); + + void (*ChangeClip) (GCPtr pGC, + int type, + void *pvalue, + int nrects); + + void (*DestroyClip) (GCPtr /*pGC */ ); + + void (*CopyClip) (GCPtr /*pgcDst */ , + GCPtr /*pgcSrc */ ); +} GCFuncs; + +/* + * graphics operations invoked through a GC + */ + +typedef struct _GCOps { + void (*FillSpans) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*nInit */ , + DDXPointPtr /*pptInit */ , + int * /*pwidthInit */ , + int /*fSorted */ ); + + void (*SetSpans) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + char * /*psrc */ , + DDXPointPtr /*ppt */ , + int * /*pwidth */ , + int /*nspans */ , + int /*fSorted */ ); + + void (*PutImage) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*depth */ , + int /*x */ , + int /*y */ , + int /*w */ , + int /*h */ , + int /*leftPad */ , + int /*format */ , + char * /*pBits */ ); + + RegionPtr (*CopyArea) (DrawablePtr /*pSrc */ , + DrawablePtr /*pDst */ , + GCPtr /*pGC */ , + int /*srcx */ , + int /*srcy */ , + int /*w */ , + int /*h */ , + int /*dstx */ , + int /*dsty */ ); + + RegionPtr (*CopyPlane) (DrawablePtr /*pSrcDrawable */ , + DrawablePtr /*pDstDrawable */ , + GCPtr /*pGC */ , + int /*srcx */ , + int /*srcy */ , + int /*width */ , + int /*height */ , + int /*dstx */ , + int /*dsty */ , + unsigned long /*bitPlane */ ); + void (*PolyPoint) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*mode */ , + int /*npt */ , + DDXPointPtr /*pptInit */ ); + + void (*Polylines) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*mode */ , + int /*npt */ , + DDXPointPtr /*pptInit */ ); + + void (*PolySegment) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*nseg */ , + xSegment * /*pSegs */ ); + + void (*PolyRectangle) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*nrects */ , + xRectangle * /*pRects */ ); + + void (*PolyArc) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*narcs */ , + xArc * /*parcs */ ); + + void (*FillPolygon) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*shape */ , + int /*mode */ , + int /*count */ , + DDXPointPtr /*pPts */ ); + + void (*PolyFillRect) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*nrectFill */ , + xRectangle * /*prectInit */ ); + + void (*PolyFillArc) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*narcs */ , + xArc * /*parcs */ ); + + int (*PolyText8) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + char * /*chars */ ); + + int (*PolyText16) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + unsigned short * /*chars */ ); + + void (*ImageText8) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + char * /*chars */ ); + + void (*ImageText16) (DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + unsigned short * /*chars */ ); + + void (*ImageGlyphBlt) (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci, + void *pglyphBase); + + void (*PolyGlyphBlt) (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci, + void *pglyphBase); + + void (*PushPixels) (GCPtr /*pGC */ , + PixmapPtr /*pBitMap */ , + DrawablePtr /*pDst */ , + int /*w */ , + int /*h */ , + int /*x */ , + int /*y */ ); +} GCOps; + +/* there is padding in the bit fields because the Sun compiler doesn't + * force alignment to 32-bit boundaries. losers. + */ +typedef struct _GC { + ScreenPtr pScreen; + unsigned char depth; + unsigned char alu; + unsigned short lineWidth; + unsigned short dashOffset; + unsigned short numInDashList; + unsigned char *dash; + unsigned int lineStyle:2; + unsigned int capStyle:2; + unsigned int joinStyle:2; + unsigned int fillStyle:2; + unsigned int fillRule:1; + unsigned int arcMode:1; + unsigned int subWindowMode:1; + unsigned int graphicsExposures:1; + unsigned int miTranslate:1; /* should mi things translate? */ + unsigned int tileIsPixel:1; /* tile is solid pixel */ + unsigned int fExpose:1; /* Call exposure handling */ + unsigned int freeCompClip:1; /* Free composite clip */ + unsigned int scratch_inuse:1; /* is this GC in a pool for reuse? */ + unsigned int unused:15; /* see comment above */ + unsigned int planemask; + unsigned int fgPixel; + unsigned int bgPixel; + /* + * alas -- both tile and stipple must be here as they + * are independently specifiable + */ + PixUnion tile; + PixmapPtr stipple; + xPoint patOrg; /* origin for (tile, stipple) */ + xPoint clipOrg; + struct _Font *font; + RegionPtr clientClip; + unsigned int stateChanges; /* masked with GC_ */ + unsigned int serialNumber; + const GCFuncs *funcs; + const GCOps *ops; + PrivateRec *devPrivates; + RegionPtr pCompositeClip; +} GCRec; + +#endif /* GCSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/glamor.h b/prebuilt/xlibre/usr/include/xorg/glamor.h new file mode 100644 index 0000000..373de7c --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/glamor.h @@ -0,0 +1,427 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt + * Zhigang Gong + * + */ + +#ifndef GLAMOR_H +#define GLAMOR_H + +#include +#include +#include +#include +#include +#ifdef GLAMOR_FOR_XORG +#include +#endif + +struct glamor_context; +struct gbm_bo; +struct gbm_device; + +/* + * glamor_pixmap_type : glamor pixmap's type. + * @MEMORY: pixmap is in memory. + * @TEXTURE_DRM: pixmap is in a texture created from a DRM buffer. + * @SEPARATE_TEXTURE: The texture is created from a DRM buffer, but + * the format is incompatible, so this type of pixmap + * will never fallback to DDX layer. + * @DRM_ONLY: pixmap is in a external DRM buffer. + * @TEXTURE_ONLY: pixmap is in an internal texture. + */ +typedef enum glamor_pixmap_type { + GLAMOR_MEMORY = 0, /* Newly calloc()ed pixmaps are memory. */ + GLAMOR_TEXTURE_DRM, + GLAMOR_DRM_ONLY, + GLAMOR_TEXTURE_ONLY, +} glamor_pixmap_type_t; + +typedef Bool (*GetDrawableModifiersFuncPtr) (DrawablePtr draw, + uint32_t format, + uint32_t *num_modifiers, + uint64_t **modifiers); + +#define GLAMOR_EGL_EXTERNAL_BUFFER 3 +#define GLAMOR_USE_EGL_SCREEN (1 << 0) +#define GLAMOR_NO_DRI3 (1 << 1) +#define GLAMOR_NO_RENDER_ACCEL (1 << 2) +#define GLAMOR_VALID_FLAGS (GLAMOR_USE_EGL_SCREEN \ + | GLAMOR_NO_DRI3 \ + | GLAMOR_NO_RENDER_ACCEL) + +/* until we need geometry shaders GL3.1 should suffice. */ +#define GLAMOR_GL_CORE_VER_MAJOR 3 +#define GLAMOR_GL_CORE_VER_MINOR 1 + +/* @glamor_init: Initialize glamor internal data structure. + * + * @screen: Current screen pointer. + * @flags: Please refer the flags description above. + * + * @GLAMOR_USE_EGL_SCREEN: + * If you are using EGL layer, then please set this bit + * on, otherwise, clear it. + * + * @GLAMOR_NO_DRI3 + * Disable the built-in DRI3 support + * + * This function initializes necessary internal data structure + * for glamor. And before calling into this function, the OpenGL + * environment should be ready. Should be called before any real + * glamor rendering or texture allocation functions. And should + * be called after the DDX's screen initialization or at the last + * step of the DDX's screen initialization. + */ +extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags); +extern _X_EXPORT void glamor_fini(ScreenPtr screen); + +/* Returns is the initialized gl context is gles + * Must not be called before glamor_init + */ +extern _X_EXPORT Bool glamor_is_gles(ScreenPtr screen); + +/* This function is used to free the glamor private screen's + * resources. If the DDX driver is not set GLAMOR_USE_SCREEN, + * then, DDX need to call this function at proper stage, if + * it is the xorg DDX driver,then it should be called at free + * screen stage not the close screen stage. The reason is after + * call to this function, the xorg DDX may need to destroy the + * screen pixmap which must be a glamor pixmap and requires + * the internal data structure still exist at that time. + * Otherwise, the glamor internal structure will not be freed.*/ + +extern _X_EXPORT uint32_t glamor_get_pixmap_texture(PixmapPtr pixmap); + +extern _X_EXPORT void glamor_clear_pixmap(PixmapPtr pixmap); + +extern _X_EXPORT void glamor_block_handler(ScreenPtr screen); + +extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, + int depth, unsigned int usage); + +/* needed by Xrdp module */ +#define GLAMOR_CREATE_PIXMAP_CPU 0x100 +#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101 +#define GLAMOR_CREATE_FBO_NO_FBO 0x103 +#define GLAMOR_CREATE_NO_LARGE 0x105 +#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106 +#define GLAMOR_CREATE_FORMAT_CBCR 0x107 + +/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo). + * + * @front: front pixmap. + * @back: back pixmap. + * + * Used by the DRI2 page flip. This function will exchange the KHR images and + * fbos of the two pixmaps. + * */ +extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front, + PixmapPtr back); + +extern _X_EXPORT struct gbm_device *glamor_egl_get_gbm_device(ScreenPtr screen); + +/* @glamor_supports_pixmap_import_export: Returns whether + * glamor_fds_from_pixmap(), glamor_name_from_pixmap(), and + * glamor_pixmap_from_fds() are supported. + * + * @screen: Current screen pointer. + * + * To have DRI3 support enabled, glamor and glamor_egl need to be + * initialized. glamor also has to be compiled with gbm support. + * + * The EGL layer needs to have the following extensions working: + * + * .EGL_KHR_surfaceless_context + * */ +extern _X_EXPORT Bool glamor_supports_pixmap_import_export(ScreenPtr screen); + +/* @glamor_fds_from_pixmap: Get a dma-buf fd from a pixmap. + * + * @screen: Current screen pointer. + * @pixmap: The pixmap from which we want the fd. + * @fds, @strides, @offsets: Pointers to fill info of each plane. + * @modifier: Pointer to fill the modifier of the buffer. + * + * the pixmap and the buffer associated by the fds will share the same + * content. The caller is responsible to close the returned file descriptors. + * Returns the number of planes, -1 on error. + * + * Currently just exported for Xrdp's virtual driver - real HW drivers + * usually shouldn't need this. + * */ +_X_EXPORT int glamor_fds_from_pixmap(ScreenPtr screen, + PixmapPtr pixmap, + int *fds, + uint32_t *strides, + uint32_t *offsets, + uint64_t *modifier); + +/* @glamor_fd_from_pixmap: Get a dma-buf fd from a pixmap. + * + * @screen: Current screen pointer. + * @pixmap: The pixmap from which we want the fd. + * @stride, @size: Pointers to fill the stride and size of the + * buffer associated to the fd. + * + * the pixmap and the buffer associated by the fd will share the same + * content. + * Returns the fd on success, -1 on error. + * */ +extern _X_EXPORT int glamor_fd_from_pixmap(ScreenPtr screen, + PixmapPtr pixmap, + CARD16 *stride, CARD32 *size); + +/* @glamor_shareable_fd_from_pixmap: Get a dma-buf fd suitable for sharing + * with other GPUs from a pixmap. + * + * @screen: Current screen pointer. + * @pixmap: The pixmap from which we want the fd. + * @stride, @size: Pointers to fill the stride and size of the + * buffer associated to the fd. + * + * The returned fd will point to a buffer which is suitable for sharing + * across GPUs (not using GPU specific tiling). + * The pixmap and the buffer associated by the fd will share the same + * content. + * The pixmap's stride may be modified by this function. + * Returns the fd on success, -1 on error. + * */ +extern _X_EXPORT int glamor_shareable_fd_from_pixmap(ScreenPtr screen, + PixmapPtr pixmap, + CARD16 *stride, + CARD32 *size); + +/** + * @glamor_name_from_pixmap: Gets a gem name from a pixmap. + * + * @pixmap: The pixmap from which we want the gem name. + * + * the pixmap and the buffer associated by the gem name will share the + * same content. This function can be used by the DDX to support DRI2, + * and needs the same set of buffer export GL extensions as DRI3 + * support. + * + * Returns the name on success, -1 on error. + * */ +extern _X_EXPORT int glamor_name_from_pixmap(PixmapPtr pixmap, + CARD16 *stride, CARD32 *size); + +/* @glamor_gbm_bo_from_pixmap: Get a GBM bo from a pixmap. + * + * @screen: Current screen pointer. + * @pixmap: The pixmap from which we want the fd. + * @stride, @size: Pointers to fill the stride and size of the + * buffer associated to the fd. + * + * the pixmap and the buffer represented by the gbm_bo will share the same + * content. + * + * Returns the gbm_bo on success, NULL on error. + * */ +extern _X_EXPORT struct gbm_bo *glamor_gbm_bo_from_pixmap(ScreenPtr screen, + PixmapPtr pixmap); + +/* @glamor_pixmap_from_fds: Creates a pixmap to wrap a dma-buf fds. + * + * @screen: Current screen pointer. + * @num_fds: Number of fds to import + * @fds: The dma-buf fds to import. + * @width: The width of the buffers. + * @height: The height of the buffers. + * @stride: The stride of the buffers. + * @depth: The depth of the buffers. + * @bpp: The bpp of the buffers. + * @modifier: The modifier of the buffers. + * + * Returns a valid pixmap if the import succeeded, else NULL. + * + * Currently just exported for Xrdp's virtual driver - real HW drivers + * usually shouldn't need this. + * */ +_X_EXPORT PixmapPtr glamor_pixmap_from_fds(ScreenPtr screen, + CARD8 num_fds, + const int *fds, + CARD16 width, + CARD16 height, + const CARD32 *strides, + const CARD32 *offsets, + CARD8 depth, + CARD8 bpp, + uint64_t modifier); + +/* @glamor_pixmap_from_fd: Creates a pixmap to wrap a dma-buf fd. + * + * @screen: Current screen pointer. + * @fd: The dma-buf fd to import. + * @width: The width of the buffer. + * @height: The height of the buffer. + * @stride: The stride of the buffer. + * @depth: The depth of the buffer. + * @bpp: The bpp of the buffer. + * + * Returns a valid pixmap if the import succeeded, else NULL. + * */ +extern _X_EXPORT PixmapPtr glamor_pixmap_from_fd(ScreenPtr screen, + int fd, + CARD16 width, + CARD16 height, + CARD16 stride, + CARD8 depth, + CARD8 bpp); + +/* @glamor_back_pixmap_from_fd: Backs an existing pixmap with a dma-buf fd. + * + * @pixmap: Pixmap to change backing for + * @fd: The dma-buf fd to import. + * @width: The width of the buffer. + * @height: The height of the buffer. + * @stride: The stride of the buffer. + * @depth: The depth of the buffer. + * @bpp: The number of bpp of the buffer. + * + * Returns TRUE if successful, FALSE on failure. + * */ +extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap, + int fd, + CARD16 width, + CARD16 height, + CARD16 stride, + CARD8 depth, + CARD8 bpp); + +/* for xorgrdp */ +_X_EXPORT Bool glamor_get_formats(ScreenPtr screen, + CARD32 *num_formats, + CARD32 **formats); + +/* for xorgrdp */ +_X_EXPORT Bool glamor_get_modifiers(ScreenPtr screen, + uint32_t format, + uint32_t *num_modifiers, + uint64_t **modifiers); + +/* for xorgrdp */ +_X_EXPORT Bool glamor_get_drawable_modifiers(DrawablePtr draw, + uint32_t format, + uint32_t *num_modifiers, + uint64_t **modifiers); + +extern _X_EXPORT void glamor_set_drawable_modifiers_func(ScreenPtr screen, + GetDrawableModifiersFuncPtr func); + + +#define GLAMOR_EGL_MODULE_NAME "glamoregl" + +/* @glamor_egl_init: Initialize EGL environment. + * + * @scrn: Current screen info pointer. + * @fd: Current drm fd. + * + * This function creates and initializes EGL contexts. + * Should be called from DDX's preInit function. + * Return TRUE if success, otherwise return FALSE. + * */ +extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd); + +enum { + GLAMOR_EGL_CAP_NONE = 0, + GLAMOR_EGL_CAP_DRI3 = 1 << 0, + GLAMOR_EGL_CAP_DRI3_IMPORT = 1 << 1, + GLAMOR_EGL_CAP_DRI3_EXPORT = 1 << 2, + GLAMOR_EGL_CAP_DRI3_SYNCOBJ = 1 << 3, + GLAMOR_EGL_CAP_TEXTURE_GBM_BO = 1 << 4, +}; + +#define GLAMOR_EGL_DEFAULT_CAPS (GLAMOR_EGL_CAP_DRI3 | GLAMOR_EGL_CAP_DRI3_IMPORT | GLAMOR_EGL_CAP_DRI3_EXPORT | GLAMOR_EGL_CAP_TEXTURE_GBM_BO) + +/* @glamor_egl_init2: Initialize EGL environment. + * + * @scrn: Current screen info pointer. + * @fd: Current drm fd. + * @caps: Some capabilities that glamor can have + * + * This function creates and initializes EGL contexts. + * Should be called from DDX's preInit function. + * Return TRUE if success, otherwise return FALSE. + * + * Unlike glamor_egl_init, this function returns true + * even if some capabilities are missing. + * + * If caps is not NULL, it is set to a bitmask + * describing what glamor capabilites are available. + * */ +extern _X_EXPORT Bool glamor_egl_init2(ScrnInfoPtr scrn, int fd, int *caps, int flags); + +extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen); + +/* + * @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from + * a BO handle. + * + * @pixmap: The pixmap need to be processed. + * @handle: The BO's handle attached to this pixmap at DDX layer. + * @stride: Stride in bytes for this pixmap. + * + * This function try to create a texture from the handle and attach + * the texture to the pixmap , thus glamor can render to this pixmap + * as well. Return true if successful, otherwise return FALSE. + */ +extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap, + int handle, int stride); + +/* + * @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap + * from a gbm_bo. + * + * @pixmap: The pixmap need to be processed. + * @bo: a pointer on a gbm_bo structure attached to this pixmap at DDX layer. + * + * This function is similar to glamor_egl_create_textured_pixmap. + */ +extern _X_EXPORT Bool + glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, + struct gbm_bo *bo, + Bool used_modifiers); + +extern _X_EXPORT const char *glamor_egl_get_driver_name(ScreenPtr screen); + + +extern _X_EXPORT int glamor_create_gc(GCPtr gc); + +extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes, + DrawablePtr drawable); + +#define HAS_GLAMOR_DESTROY_GC 1 + +extern _X_EXPORT void glamor_finish(ScreenPtr screen); +#define HAS_GLAMOR_TEXT 1 + +#ifdef GLAMOR_FOR_XORG +extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen, + int num_texture_ports); +#endif + +#endif /* GLAMOR_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/globals.h b/prebuilt/xlibre/usr/include/xorg/globals.h new file mode 100644 index 0000000..ecb7b2b --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/globals.h @@ -0,0 +1,13 @@ +#ifndef _XSERV_GLOBAL_H_ +#define _XSERV_GLOBAL_H_ + +#include +#include + +/* Global X server variables that are visible to mi, dix, os, and ddx */ + +extern _X_EXPORT const char *defaultFontPath; +extern _X_EXPORT int monitorResolution; +extern _X_EXPORT int defaultColorVisualClass; + +#endif /* !_XSERV_GLOBAL_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/glxvndabi.h b/prebuilt/xlibre/usr/include/xorg/glxvndabi.h new file mode 100644 index 0000000..0767f2f --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/glxvndabi.h @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2016, NVIDIA CORPORATION. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * unaltered in all copies or substantial portions of the Materials. + * Any additions, deletions, or changes to the original source files + * must be clearly indicated in accompanying documentation. + * + * If only executable code is distributed, then the accompanying + * documentation must state that "this software is based in part on the + * work of the Khronos Group." + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + */ + +/** + * \file + * + * Defines the interface between the libglvnd server module and a vendor + * library. + * + * Each screen may have one vendor library assigned to it. The GLVND module + * will examine each GLX request to determine which screen it goes to, and then + * it will forward that request to whichever vendor is assigned to that screen. + * + * Each vendor library is represented by an opaque __GLXServerVendor handle. + * Display drivers are responsible for creating handles for its GLX + * implementations, and assigning those handles to each screen. + * + * The GLVND module keeps a list of callbacks, which are called from + * InitExtensions. Drivers should use that callback to assign a vendor + * handle to whichever screens they support. + * + * Additional notes about dispatching: + * - If a request has one or more GLXContextTag values, then the dispatch stub + * must ensure that all of the tags belong to the vendor that it forwards the + * request to. Otherwise, if a vendor library tries to look up the private + * data for the tag, it could get the data from another vendor and crash. + * - Following from the last point, if a request takes a GLXContextTag value, + * then the dispatch stub should use the tag to select a vendor. If the + * request takes two or more tags, then the vendor must ensure that they all + * map to the same vendor. + */ + +#ifndef GLXVENDORABI_H +#define GLXVENDORABI_H + +#include "xlibre_ptrtypes.h" + +#include +#include +#include + +/*! + * Current version of the ABI. + * + * This version number contains a major number in the high-order 16 bits, and + * a minor version number in the low-order 16 bits. + * + * The major version number is incremented when an interface change will break + * backwards compatibility with existing vendor libraries. The minor version + * number is incremented when there's a change but existing vendor libraries + * will still work. + */ +#define GLXSERVER_VENDOR_ABI_MAJOR_VERSION 0 +#define GLXSERVER_VENDOR_ABI_MINOR_VERSION 1 + +#if defined(__cplusplus) +extern "C" { +#endif + +/** + * An opaque pointer representing a vendor library. + */ +typedef struct GlxServerVendorRec GlxServerVendor; + +typedef int (* GlxServerDispatchProc) (ClientPtr client); + +typedef struct GlxServerImportsRec GlxServerImports; + +/** + * Functions exported by libglvnd to the vendor library. + */ +typedef struct GlxServerExportsRec { + int majorVersion; + int minorVersion; + + /** + * This callback is called during each server generation when the GLX + * extension is initialized. + * + * Drivers may create a __GLXServerVendor handle at any time, but may only + * assign a vendor to a screen from this callback. + * + * The callback is called with the ExtensionEntry pointer for the GLX + * extension. + */ + CallbackListPtr *extensionInitCallback; + + /** + * Allocates and zeroes a __GLXserverImports structure. + * + * Future versions of the GLVND interface may add optional members to the + * end of the __GLXserverImports struct. Letting the GLVND layer allocate + * the __GLXserverImports struct allows backward compatibility with + * existing drivers. + */ + GlxServerImports * (* allocateServerImports) (void); + + /** + * Frees a __GLXserverImports structure that was allocated with + * \c allocateServerImports. + */ + void (* freeServerImports) (GlxServerImports *imports); + + /** + * Creates a new vendor library handle. + */ + GlxServerVendor * (* createVendor) (const GlxServerImports *imports); + + /** + * Destroys a vendor library handle. + * + * This function may not be called while the vendor handle is assigned to a + * screen, but it may be called from the __GLXserverImports::extensionCloseDown + * callback. + */ + void (* destroyVendor) (GlxServerVendor *vendor); + + /** + * Sets the vendor library to use for a screen. + * + * This function should be called from the screen's CreateScreenResources + * callback. + */ + Bool (* setScreenVendor) (ScreenPtr screen, GlxServerVendor *vendor); + + + /** + * Adds an entry to the XID map. + * + * This mapping is used to dispatch requests based on an XID. + * + * Client-generated XID's (contexts, drawables, etc) must be added to the + * map by the dispatch stub. + * + * XID's that are generated in the server should be added by the vendor + * library. + * + * Vendor libraries are responsible for keeping track of any additional + * data they need for the XID's. + * + * Note that adding GLXFBConfig ID's appears to be unnecessary -- every GLX + * request I can find that takes a GLXFBConfig also takes a screen number. + * + * \param id The XID to add to the map. The XID must not already be in the + * map. + * \param vendor The vendor library to associate with \p id. + * \return True on success, or False on failure. + */ + Bool (* addXIDMap) (XID id, GlxServerVendor *vendor); + + /** + * Returns the vendor and data for an XID, as added with \c addXIDMap. + * + * If \p id wasn't added with \c addXIDMap (for example, if it's a regular + * X window), then libglvnd will try to look it up as a drawable and return + * the vendor for whatever screen it's on. + * + * \param id The XID to look up. + * \return The vendor that owns the XID, or \c NULL if no matching vendor + * was found. + */ + GlxServerVendor * (* getXIDMap) (XID id); + + /** + * Removes an entry from the XID map. + */ + void (* removeXIDMap) (XID id); + + /** + * Looks up a context tag. + * + * Context tags are created and managed by libglvnd to ensure that they're + * unique between vendors. + * + * \param client The client connection. + * \param tag The context tag. + * \return The vendor that owns the context tag, or \c NULL if the context + * tag is invalid. + */ + GlxServerVendor * (* getContextTag)(ClientPtr client, GLXContextTag tag); + + /** + * Assigns a pointer to vendor-private data for a context tag. + * + * Since the tag values are assigned by GLVND, vendors can use this + * function to store any private data they need for a context tag. + * + * \param client The client connection. + * \param tag The context tag. + * \param data An arbitrary pointer value. + */ + Bool (* setContextTagPrivate)(ClientPtr client, GLXContextTag tag, void *data); + + /** + * Returns the private data pointer that was assigned from + * setContextTagPrivate. + * + * This function is safe to use in __GLXserverImports::makeCurrent to look + * up the old context private pointer. + * + * However, this function is not safe to use from a ClientStateCallback, + * because GLVND may have already deleted the tag by that point. + */ + void * (* getContextTagPrivate)(ClientPtr client, GLXContextTag tag); + + GlxServerVendor * (* getVendorForScreen) (ClientPtr client, ScreenPtr screen); + + /** + * Forwards a request to a vendor library. + * + * \param vendor The vendor to send the request to. + * \param client The client. + */ + int (* forwardRequest) (GlxServerVendor *vendor, ClientPtr client); + + /** + * Sets the vendor library to use for a screen for a specific client. + * + * This function changes which vendor should handle GLX requests for a + * screen. Unlike \c setScreenVendor, this function can be called at any + * time, and only applies to requests from a single client. + * + * This function is available in GLXVND version 0.1 or later. + */ + Bool (* setClientScreenVendor) (ClientPtr client, ScreenPtr screen, GlxServerVendor *vendor); +} GlxServerExports; + +extern _X_EXPORT const GlxServerExports glxServer; + +/** + * Functions exported by the vendor library to libglvnd. + */ +struct GlxServerImportsRec { + /** + * Called on a server reset. + * + * This is called from the extension's CloseDown callback. + * + * Note that this is called after freeing all of GLVND's per-screen data, + * so the callback may destroy any vendor handles. + * + * If the server is exiting, then GLVND will free any remaining vendor + * handles after calling the extensionCloseDown callbacks. + */ + void (* extensionCloseDown) (const ExtensionEntry *extEntry); + + /** + * Handles a GLX request. + */ + int (* handleRequest) (ClientPtr client); + + /** + * Returns a dispatch function for a request. + * + * \param minorOpcode The minor opcode of the request. + * \param vendorCode The vendor opcode, if \p minorOpcode + * is \c X_GLXVendorPrivate or \c X_GLXVendorPrivateWithReply. + * \return A dispatch function, or NULL if the vendor doesn't support this + * request. + */ + GlxServerDispatchProc (* getDispatchAddress) (CARD8 minorOpcode, CARD32 vendorCode); + + /** + * Handles a MakeCurrent request. + * + * This function is called to handle any MakeCurrent request. The vendor + * library should deal with changing the current context. After the vendor + * returns GLVND will send the reply. + * + * In addition, GLVND will call this function with any current contexts + * when a client disconnects. + * + * To ensure that context tags are unique, libglvnd will select a context + * tag and pass it to the vendor library. + * + * The vendor can use \c __GLXserverExports::getContextTagPrivate to look + * up the private data pointer for \p oldContextTag. + * + * Likewise, the vendor can use \c __GLXserverExports::setContextTagPrivate + * to assign a private data pointer to \p newContextTag. + */ + int (* makeCurrent) (ClientPtr client, + GLXContextTag oldContextTag, + XID drawable, + XID readdrawable, + XID context, + GLXContextTag newContextTag); +}; + +#if defined(__cplusplus) +} +#endif + +#endif // GLXVENDORABI_H diff --git a/prebuilt/xlibre/usr/include/xorg/glyphstr.h b/prebuilt/xlibre/usr/include/xorg/glyphstr.h new file mode 100644 index 0000000..5a75ba6 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/glyphstr.h @@ -0,0 +1,62 @@ +/* + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _GLYPHSTR_H_ +#define _GLYPHSTR_H_ + +#include + +#include "picture.h" +#include "screenint.h" + +#define GlyphFormat1 0 +#define GlyphFormat4 1 +#define GlyphFormat8 2 +#define GlyphFormat16 3 +#define GlyphFormat32 4 +#define GlyphFormatNum 5 + +typedef struct _Glyph { + CARD32 refcnt; + PrivateRec *devPrivates; + unsigned char sha1[20]; + CARD32 size; /* info + bitmap */ + xGlyphInfo info; + /* per-screen pixmaps follow */ +} GlyphRec, *GlyphPtr; + +typedef struct _GlyphList { + INT16 xOff; + INT16 yOff; + CARD8 len; + PictFormatPtr format; +} GlyphListRec, *GlyphListPtr; + +#define GLYPH_HAS_GLYPH_PICTURE_ACCESSOR 1 /* used for api compat */ +extern _X_EXPORT PicturePtr + GetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen); +extern _X_EXPORT void + SetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen, PicturePtr picture); + +#endif /* _GLYPHSTR_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/i2c_def.h b/prebuilt/xlibre/usr/include/xorg/i2c_def.h new file mode 100644 index 0000000..140a071 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/i2c_def.h @@ -0,0 +1,6 @@ +#ifndef __I2C_DEF_H__ +#define __I2C_DEF_H__ + +#include "xf86i2c.h" + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/input.h b/prebuilt/xlibre/usr/include/xorg/input.h new file mode 100644 index 0000000..125322d --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/input.h @@ -0,0 +1,581 @@ +/************************************************************ + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +********************************************************/ + +#ifndef INPUT_H +#define INPUT_H + +#include "xlibre_ptrtypes.h" + +#include "misc.h" +#include "screenint.h" +#include +#include +#include +#include "window.h" /* for WindowPtr */ +#include "xkbrules.h" +#include "events.h" +#include "list.h" +#include "os.h" +#include + +#define DEFAULT_KEYBOARD_CLICK 0 +#define DEFAULT_BELL 50 +#define DEFAULT_BELL_PITCH 400 +#define DEFAULT_BELL_DURATION 100 +#define DEFAULT_AUTOREPEAT TRUE +#define DEFAULT_AUTOREPEATS {\ + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\ + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + +#define DEFAULT_LEDS 0x0 /* all off */ +#define DEFAULT_LEDS_MASK 0xffffffff /* 32 */ +#define DEFAULT_INT_RESOLUTION 1000 +#define DEFAULT_INT_MIN_VALUE 0 +#define DEFAULT_INT_MAX_VALUE 100 +#define DEFAULT_INT_DISPLAYED 0 + +#define DEFAULT_PTR_NUMERATOR 2 +#define DEFAULT_PTR_DENOMINATOR 1 +#define DEFAULT_PTR_THRESHOLD 4 + +#define DEVICE_INIT 0 +#define DEVICE_ON 1 +#define DEVICE_OFF 2 +#define DEVICE_CLOSE 3 +#define DEVICE_ABORT 4 + +#define POINTER_RELATIVE (1 << 1) +#define POINTER_ABSOLUTE (1 << 2) +#define POINTER_ACCELERATE (1 << 3) +#define POINTER_SCREEN (1 << 4) /* Data in screen coordinates */ +#define POINTER_NORAW (1 << 5) /* Don't generate RawEvents */ +#define POINTER_EMULATED (1 << 6) /* Event was emulated from another event */ +#define POINTER_DESKTOP (1 << 7) /* Data in desktop coordinates */ +#define POINTER_RAWONLY (1 << 8) /* Only generate RawEvents */ + +/* GetTouchEvent flags */ +#define TOUCH_ACCEPT (1 << 0) +#define TOUCH_REJECT (1 << 1) +#define TOUCH_PENDING_END (1 << 2) +#define TOUCH_CLIENT_ID (1 << 3) /* touch ID is the client-visible id */ +#define TOUCH_REPLAYING (1 << 4) /* event is being replayed */ +#define TOUCH_POINTER_EMULATED (1 << 5) /* touch event may be pointer emulated */ +#define TOUCH_END (1 << 6) /* really end this touch now */ + +/* GetGestureEvent flags */ +#define GESTURE_CANCELLED (1 << 0) + +/*int constants for pointer acceleration schemes*/ +#define PtrAccelNoOp 0 +#define PtrAccelPredictable 1 +#define PtrAccelLightweight 2 +#define PtrAccelDefault PtrAccelPredictable + +#define MAX_VALUATORS 36 +/* Maximum number of valuators, divided by six, rounded up, to get number + * of events. */ +#define MAX_VALUATOR_EVENTS 6 +#define MAX_BUTTONS 256 /* completely arbitrarily chosen */ + +#define NO_AXIS_LIMITS -1 + +#define MAP_LENGTH MAX_BUTTONS +#define DOWN_LENGTH (MAX_BUTTONS/8) /* 256/8 => number of bytes to hold 256 bits */ +#define NullGrab ((GrabPtr)NULL) +#define PointerRootWin ((WindowPtr)PointerRoot) +#define NoneWin ((WindowPtr)None) +#define NullDevice ((DevicePtr)NULL) + +#ifndef FollowKeyboard +#define FollowKeyboard 3 +#endif +#ifndef FollowKeyboardWin +#define FollowKeyboardWin ((WindowPtr) FollowKeyboard) +#endif +#ifndef RevertToFollowKeyboard +#define RevertToFollowKeyboard 3 +#endif + +enum InputLevel { + CORE = 1, + XI = 2, + XI2 = 3, +}; + +typedef unsigned long Leds; +typedef struct _OtherClients *OtherClientsPtr; +typedef struct _InputClients *InputClientsPtr; +typedef struct _ValuatorClassRec *ValuatorClassPtr; +typedef struct _ClassesRec *ClassesPtr; +typedef struct _SpriteRec *SpritePtr; +typedef struct _TouchClassRec *TouchClassPtr; +typedef struct _GestureClassRec *GestureClassPtr; +typedef struct _TouchPointInfo *TouchPointInfoPtr; +typedef struct _GestureInfo *GestureInfoPtr; +typedef struct _DDXTouchPointInfo *DDXTouchPointInfoPtr; +typedef union _GrabMask GrabMask; + +typedef struct _ValuatorMask ValuatorMask; + +/* The DIX stores incoming input events in this list */ +extern InternalEvent *InputEventList; + +typedef int (*DeviceProc) (DeviceIntPtr /*device */ , + int /*what */ ); + +typedef void (*ProcessInputProc) (InternalEvent * /*event */ , + DeviceIntPtr /*device */ ); + +typedef Bool (*DeviceHandleProc) (DeviceIntPtr /*device */ , + void * /*data */ + ); + +typedef void (*DeviceUnwrapProc) (DeviceIntPtr /*device */ , + DeviceHandleProc /*proc */ , + void * /*data */ + ); + +/* pointer acceleration handling */ +typedef void (*PointerAccelSchemeProc) (DeviceIntPtr /*device */ , + ValuatorMask * /*valuators */ , + CARD32 /*evtime */ ); + +typedef void (*DeviceCallbackProc) (DeviceIntPtr /*pDev */ ); + +struct _ValuatorAccelerationRec; +typedef Bool (*PointerAccelSchemeInitProc) (DeviceIntPtr /*dev */ , + struct _ValuatorAccelerationRec * + /*protoScheme */ ); + +typedef void (*DeviceSendEventsProc) (DeviceIntPtr /*dev */ , + int /* event type */ , + int /* detail, buttons or keycode */ , + int /* flags */ , + const ValuatorMask * /* valuators */ ); + +typedef struct _DeviceRec { + void *devicePrivate; + ProcessInputProc processInputProc; /* current */ + ProcessInputProc realInputProc; /* deliver */ + ProcessInputProc enqueueInputProc; /* enqueue */ + Bool on; /* used by DDX to keep state */ +} DeviceRec, *DevicePtr; + +typedef struct { + int click, bell, bell_pitch, bell_duration; + Bool autoRepeat; + unsigned char autoRepeats[32]; + Leds leds; + unsigned char id; +} KeybdCtrl; + +typedef struct { + KeySym *map; + KeyCode minKeyCode, maxKeyCode; + int mapWidth; +} KeySymsRec, *KeySymsPtr; + +typedef struct { + int num, den, threshold; + unsigned char id; +} PtrCtrl; + +typedef struct { + int resolution, min_value, max_value; + int integer_displayed; + unsigned char id; +} IntegerCtrl; + +typedef struct { + int max_symbols, num_symbols_supported; + int num_symbols_displayed; + KeySym *symbols_supported; + KeySym *symbols_displayed; + unsigned char id; +} StringCtrl; + +typedef struct { + int percent, pitch, duration; + unsigned char id; +} BellCtrl; + +typedef struct { + Leds led_values; + Mask led_mask; + unsigned char id; +} LedCtrl; + +extern _X_EXPORT KeybdCtrl defaultKeyboardControl; +extern _X_EXPORT PtrCtrl defaultPointerControl; + +typedef struct _InputOption InputOption; +typedef struct _XI2Mask XI2Mask; + +typedef struct _InputAttributes { + char *product; + char *vendor; + char *device; + char *pnp_id; + char *usb_id; + char **tags; /* null-terminated */ + uint32_t flags; +} InputAttributes; + +#define ATTR_KEYBOARD (1<<0) +#define ATTR_POINTER (1<<1) +#define ATTR_JOYSTICK (1<<2) +#define ATTR_TABLET (1<<3) +#define ATTR_TOUCHPAD (1<<4) +#define ATTR_TOUCHSCREEN (1<<5) +#define ATTR_KEY (1<<6) +#define ATTR_TABLET_PAD (1<<7) + +/* Key/Button has been run through all input processing and events sent to clients. */ +#define KEY_PROCESSED 1 +#define BUTTON_PROCESSED 1 +/* Key/Button has not been fully processed, no events have been sent. */ +#define KEY_POSTED 2 +#define BUTTON_POSTED 2 + +extern _X_EXPORT void set_key_down(DeviceIntPtr pDev, int key_code, int type); +extern _X_EXPORT void set_key_up(DeviceIntPtr pDev, int key_code, int type); +extern _X_EXPORT int key_is_down(DeviceIntPtr pDev, int key_code, int type); +extern _X_EXPORT void set_button_down(DeviceIntPtr pDev, int button, int type); +extern _X_EXPORT void set_button_up(DeviceIntPtr pDev, int button, int type); +extern _X_EXPORT int button_is_down(DeviceIntPtr pDev, int button, int type); + +extern _X_EXPORT DeviceIntPtr AddInputDevice(ClientPtr /*client */ , + DeviceProc /*deviceProc */ , + Bool /*autoStart */ ); + +extern _X_EXPORT Bool EnableDevice(DeviceIntPtr /*device */ , + BOOL /* sendevent */ ); + +extern _X_EXPORT Bool ActivateDevice(DeviceIntPtr /*device */ , + BOOL /* sendevent */ ); + +extern _X_EXPORT Bool DisableDevice(DeviceIntPtr /*device */ , + BOOL /* sendevent */ ); + +extern _X_EXPORT int RemoveDevice(DeviceIntPtr /*dev */ , + BOOL /* sendevent */ ); + +extern _X_EXPORT int NumMotionEvents(void); + +extern _X_EXPORT int dixLookupDevice(DeviceIntPtr * /* dev */ , + int /* id */ , + ClientPtr /* client */ , + Mask /* access_mode */ ); + +extern _X_EXPORT void QueryMinMaxKeyCodes(KeyCode * /*minCode */ , + KeyCode * /*maxCode */ ); + +extern _X_EXPORT Bool InitButtonClassDeviceStruct(DeviceIntPtr /*device */ , + int /*numButtons */ , + Atom * /* labels */ , + CARD8 * /*map */ ); + +extern _X_EXPORT Bool InitValuatorClassDeviceStruct(DeviceIntPtr /*device */ , + int /*numAxes */ , + Atom * /* labels */ , + int /*numMotionEvents */ , + int /*mode */ ); + +extern _X_EXPORT Bool InitPointerAccelerationScheme(DeviceIntPtr /*dev */ , + int /*scheme */ ); + +extern _X_EXPORT Bool InitFocusClassDeviceStruct(DeviceIntPtr /*device */ ); + +extern _X_EXPORT Bool InitTouchClassDeviceStruct(DeviceIntPtr /*device */ , + unsigned int /*max_touches */ , + unsigned int /*mode */ , + unsigned int /*numAxes */ ); + +extern _X_EXPORT Bool InitGestureClassDeviceStruct(DeviceIntPtr device, + unsigned int max_touches); + +typedef void (*BellProcPtr) (int percent, + DeviceIntPtr device, + void *ctrl, + int feedbackClass); + +typedef void (*KbdCtrlProcPtr) (DeviceIntPtr /*device */ , + KeybdCtrl * /*ctrl */ ); + +typedef void (*PtrCtrlProcPtr) (DeviceIntPtr /*device */ , + PtrCtrl * /*ctrl */ ); + +extern _X_EXPORT Bool InitPtrFeedbackClassDeviceStruct(DeviceIntPtr /*device */ + , + PtrCtrlProcPtr + /*controlProc */ ); + +typedef void (*StringCtrlProcPtr) (DeviceIntPtr /*device */ , + StringCtrl * /*ctrl */ ); + +extern _X_EXPORT Bool InitStringFeedbackClassDeviceStruct(DeviceIntPtr + /*device */ , + StringCtrlProcPtr + /*controlProc */ , + int /*max_symbols */ , + int + /*num_symbols_supported */ + , + KeySym * /*symbols */ + ); + +typedef void (*BellCtrlProcPtr) (DeviceIntPtr /*device */ , + BellCtrl * /*ctrl */ ); + +extern _X_EXPORT Bool InitBellFeedbackClassDeviceStruct(DeviceIntPtr /*device */ + , + BellProcPtr + /*bellProc */ , + BellCtrlProcPtr + /*controlProc */ ); + +typedef void (*LedCtrlProcPtr) (DeviceIntPtr /*device */ , + LedCtrl * /*ctrl */ ); + +extern _X_EXPORT Bool InitLedFeedbackClassDeviceStruct(DeviceIntPtr /*device */ + , + LedCtrlProcPtr + /*controlProc */ ); + +typedef void (*IntegerCtrlProcPtr) (DeviceIntPtr /*device */ , + IntegerCtrl * /*ctrl */ ); + +extern _X_EXPORT Bool InitIntegerFeedbackClassDeviceStruct(DeviceIntPtr + /*device */ , + IntegerCtrlProcPtr + /*controlProc */ ); + +extern _X_EXPORT Bool InitPointerDeviceStruct(DevicePtr /*device */ , + CARD8 * /*map */ , + int /*numButtons */ , + Atom * /* btn_labels */ , + PtrCtrlProcPtr /*controlProc */ , + int /*numMotionEvents */ , + int /*numAxes */ , + Atom * /* axes_labels */ ); + +extern _X_EXPORT Bool InitKeyboardDeviceStruct(DeviceIntPtr /*device */ , + XkbRMLVOSet * /*rmlvo */ , + BellProcPtr /*bellProc */ , + KbdCtrlProcPtr /*controlProc */ + ); + +extern _X_EXPORT Bool InitKeyboardDeviceStructFromString(DeviceIntPtr dev, + const char *keymap, + int keymap_length, + BellProcPtr bell_func, + KbdCtrlProcPtr ctrl_func); + +extern _X_EXPORT void ProcessInputEvents(void); + +extern _X_EXPORT void InitInput(int /*argc */ , + char ** /*argv */ ); +extern _X_EXPORT void CloseInput(void); + +extern _X_EXPORT int GetMaximumEventsNum(void); + +extern _X_EXPORT InternalEvent *InitEventList(int num_events); +extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events); + +extern _X_EXPORT int GetPointerEvents(InternalEvent *events, + DeviceIntPtr pDev, + int type, + int buttons, + int flags, const ValuatorMask *mask); + +extern _X_EXPORT void QueuePointerEvents(DeviceIntPtr pDev, + int type, + int buttons, + int flags, const ValuatorMask *mask); + +extern _X_EXPORT int GetKeyboardEvents(InternalEvent *events, + DeviceIntPtr pDev, + int type, + int key_code); + +extern _X_EXPORT void QueueKeyboardEvents(DeviceIntPtr pDev, + int type, + int key_code); + +extern _X_EXPORT int GetProximityEvents(InternalEvent *events, + DeviceIntPtr pDev, + int type, const ValuatorMask *mask); + +extern _X_EXPORT void QueueProximityEvents(DeviceIntPtr pDev, + int type, const ValuatorMask *mask); + +extern _X_EXPORT int GetMotionHistorySize(void); + +extern _X_EXPORT void AllocateMotionHistory(DeviceIntPtr pDev); + +extern _X_EXPORT int GetMotionHistory(DeviceIntPtr pDev, + xTimecoord ** buff, + unsigned long start, + unsigned long stop, + ScreenPtr pScreen, BOOL core); + +extern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd); +extern _X_EXPORT DeviceIntPtr GetMaster(DeviceIntPtr dev, int type); + +extern _X_EXPORT int AllocDevicePair(ClientPtr client, + const char *name, + DeviceIntPtr *ptr, + DeviceIntPtr *keybd, + DeviceProc ptr_proc, + DeviceProc keybd_proc, Bool master); + +/* Helper functions. */ +extern _X_EXPORT int generate_modkeymap(ClientPtr client, DeviceIntPtr dev, + KeyCode **modkeymap, + int *max_keys_per_mod); + +enum TouchListenerState { + TOUCH_LISTENER_AWAITING_BEGIN = 0, /**< Waiting for a TouchBegin event */ + TOUCH_LISTENER_AWAITING_OWNER, /**< Waiting for a TouchOwnership event */ + TOUCH_LISTENER_EARLY_ACCEPT, /**< Waiting for ownership, has already + accepted */ + TOUCH_LISTENER_IS_OWNER, /**< Is the current owner, hasn't + accepted */ + TOUCH_LISTENER_HAS_ACCEPTED, /**< Is the current owner, has accepted */ + TOUCH_LISTENER_HAS_END, /**< Has already received the end event */ +}; + +enum TouchListenerType { + TOUCH_LISTENER_GRAB, + TOUCH_LISTENER_POINTER_GRAB, + TOUCH_LISTENER_REGULAR, + TOUCH_LISTENER_POINTER_REGULAR, +}; + +enum GestureListenerType { + GESTURE_LISTENER_GRAB, + GESTURE_LISTENER_NONGESTURE_GRAB, + GESTURE_LISTENER_REGULAR +}; + +extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes * + attrs); + +extern _X_EXPORT void FreeInputAttributes(InputAttributes * attrs); + +/* Implemented by the DDX. */ +extern _X_EXPORT int NewInputDeviceRequest(InputOption *options, + InputAttributes * attrs, + DeviceIntPtr *dev); +extern _X_EXPORT void DeleteInputDeviceRequest(DeviceIntPtr dev); +extern _X_EXPORT void RemoveInputDeviceTraces(const char *config_info); +extern _X_EXPORT void DDXRingBell(int volume, int pitch, int duration); +extern _X_EXPORT ValuatorMask *valuator_mask_new(int num_valuators); +extern _X_EXPORT void valuator_mask_free(ValuatorMask **mask); +extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask, + int first_valuator, + int num_valuators, + const int *valuators); +extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask, int valuator, + int data); +extern _X_EXPORT void valuator_mask_set_double(ValuatorMask *mask, int valuator, + double data); +extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask); +extern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask); +extern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit); +extern _X_EXPORT void valuator_mask_unset(ValuatorMask *mask, int bit); +extern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask); +extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest, + const ValuatorMask *src); +extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum); +extern _X_EXPORT double valuator_mask_get_double(const ValuatorMask *mask, + int valnum); +extern _X_EXPORT Bool valuator_mask_fetch(const ValuatorMask *mask, + int valnum, int *val); +extern _X_EXPORT Bool valuator_mask_fetch_double(const ValuatorMask *mask, + int valnum, double *val); +extern _X_EXPORT Bool valuator_mask_has_unaccelerated(const ValuatorMask *mask); +extern _X_EXPORT void valuator_mask_set_unaccelerated(ValuatorMask *mask, + int valuator, + double accel, + double unaccel); +extern _X_EXPORT void valuator_mask_set_absolute_unaccelerated(ValuatorMask *mask, + int valuator, + int absolute, + double unaccel); +extern _X_EXPORT double valuator_mask_get_accelerated(const ValuatorMask *mask, + int valuator); +extern _X_EXPORT double valuator_mask_get_unaccelerated(const ValuatorMask *mask, + int valuator); +extern _X_EXPORT Bool valuator_mask_fetch_unaccelerated(const ValuatorMask *mask, + int valuator, + double *accel, + double *unaccel); +/* InputOption handling interface */ +extern _X_EXPORT InputOption *input_option_new(InputOption *list, + const char *key, + const char *value); +extern _X_EXPORT void input_option_free_list(InputOption **opt); +extern _X_EXPORT InputOption *input_option_free_element(InputOption *opt, + const char *key); +extern _X_EXPORT InputOption *input_option_find(InputOption *list, + const char *key); +extern _X_EXPORT const char *input_option_get_key(const InputOption *opt); +extern _X_EXPORT const char *input_option_get_value(const InputOption *opt); +extern _X_EXPORT void input_option_set_key(InputOption *opt, const char *key); +extern _X_EXPORT void input_option_set_value(InputOption *opt, + const char *value); + +extern _X_EXPORT void input_lock(void); +extern _X_EXPORT void input_unlock(void); +extern _X_EXPORT void input_force_unlock(void); +extern _X_EXPORT int in_input_thread(void); + +extern _X_EXPORT Bool InputThreadEnable; + +#endif /* INPUT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/inputstr.h b/prebuilt/xlibre/usr/include/xorg/inputstr.h new file mode 100644 index 0000000..9b60d7f --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/inputstr.h @@ -0,0 +1,672 @@ +/************************************************************ + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +********************************************************/ + +#ifndef INPUTSTRUCT_H +#define INPUTSTRUCT_H + +#include + +#include +#include "input.h" +#include "window.h" +#include "dixstruct.h" +#include "cursorstr.h" +#include "privates.h" + +#define BitIsOn(ptr, bit) (!!(((const BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))) +#define SetBit(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7))) +#define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7))) + +#define EMASKSIZE (MAXDEVICES + 2) + +/* This is the last XI2 event supported by the server. If you add + * events to the protocol, the server will not support these events until + * this number here is bumped. + */ +#define XI2LASTEVENT XI_GestureSwipeEnd +#define XI2MASKSIZE ((XI2LASTEVENT >> 3) + 1) /* no of bytes for masks */ + +/** + * Scroll types for ::SetScrollValuator and the scroll type in the + * ::ScrollInfoPtr. + */ +enum ScrollType { + SCROLL_TYPE_NONE = 0, /**< Not a scrolling valuator */ + SCROLL_TYPE_VERTICAL = 8, + SCROLL_TYPE_HORIZONTAL = 9, +}; + +/** + * This struct stores the core event mask for each client except the client + * that created the window. + * + * Each window that has events selected from other clients has at least one of + * these masks. If multiple clients selected for events on the same window, + * these masks are in a linked list. + * + * The event mask for the client that created the window is stored in + * win->eventMask instead. + * + * The resource id is simply a fake client ID to associate this mask with a + * client. + * + * Kludge: OtherClients and InputClients must be compatible, see code. + */ +typedef struct _OtherClients { + OtherClientsPtr next; /**< Pointer to the next mask */ + XID resource; /**< id for putting into resource manager */ + Mask mask; /**< Core event mask */ +} OtherClients; + +/** + * This struct stores the XI event mask for each client. + * + * Each window that has events selected has at least one of these masks. If + * multiple client selected for events on the same window, these masks are in + * a linked list. + */ +typedef struct _InputClients { + InputClientsPtr next; /**< Pointer to the next mask */ + XID resource; /**< id for putting into resource manager */ + Mask mask[EMASKSIZE]; /**< Actual XI event mask, deviceid is index */ + /** XI2 event masks. One per device, each bit is a mask of (1 << type) */ + struct _XI2Mask *xi2mask; +} InputClients; + +/** + * Combined XI event masks from all devices. + * + * This is the XI equivalent of the deliverableEvents, eventMask and + * dontPropagate mask of the WindowRec (or WindowOptRec). + * + * A window that has an XI client selecting for events has exactly one + * OtherInputMasks struct and exactly one InputClients struct hanging off + * inputClients. Each further client appends to the inputClients list. + * Each Mask field is per-device, with the device id as the index. + * Exception: for non-device events (Presence events), the MAXDEVICES + * deviceid is used. + */ +typedef struct _OtherInputMasks { + /** + * Bitwise OR of all masks by all clients and the window's parent's masks. + */ + Mask deliverableEvents[EMASKSIZE]; + /** + * Bitwise OR of all masks by all clients on this window. + */ + Mask inputEvents[EMASKSIZE]; + /** The do-not-propagate masks for each device. */ + Mask dontPropagateMask[EMASKSIZE]; + /** The clients that selected for events */ + InputClientsPtr inputClients; + /* XI2 event masks. One per device, each bit is a mask of (1 << type) */ + struct _XI2Mask *xi2mask; +} OtherInputMasks; + +/* + * The following structure gets used for both active and passive grabs. For + * active grabs some of the fields (e.g. modifiers) are not used. However, + * that is not much waste since there aren't many active grabs (one per + * keyboard/pointer device) going at once in the server. + */ + +typedef struct _DetailRec { /* Grab details may be bit masks */ + unsigned int exact; + Mask *pMask; +} DetailRec; + +union _GrabMask { + Mask core; + Mask xi; + struct _XI2Mask *xi2mask; +}; + +/** + * Central struct for device grabs. + * The same struct is used for both core grabs and device grabs, with + * different fields being set. + * If the grab is a core grab (GrabPointer/GrabKeyboard), then the eventMask + * is a combination of standard event masks (i.e. PointerMotionMask | + * ButtonPressMask). + * If the grab is a device grab (GrabDevice), then the eventMask is a + * combination of event masks for a given XI event type (see SetEventInfo). + * + * If the grab is a result of a ButtonPress, then eventMask is the core mask + * and deviceMask is set to the XI event mask for the grab. + */ +typedef struct _GrabRec { + GrabPtr next; /* for chain of passive grabs */ + XID resource; + DeviceIntPtr device; + WindowPtr window; + unsigned ownerEvents:1; + unsigned keyboardMode:1; + unsigned pointerMode:1; + enum InputLevel grabtype; + CARD8 type; /* event type for passive grabs, 0 for active grabs */ + DetailRec modifiersDetail; + DeviceIntPtr modifierDevice; + DetailRec detail; /* key or button */ + WindowPtr confineTo; /* always NULL for keyboards */ + CursorPtr cursor; /* always NULL for keyboards */ + Mask eventMask; + Mask deviceMask; + /* XI2 event masks. One per device, each bit is a mask of (1 << type) */ + struct _XI2Mask *xi2mask; +} GrabRec; + +/** + * Sprite information for a device. + */ +typedef struct _SpriteRec { + CursorPtr current; + BoxRec hotLimits; /* logical constraints of hot spot */ + Bool confined; /* confined to screen */ + RegionPtr hotShape; /* additional logical shape constraint */ + BoxRec physLimits; /* physical constraints of hot spot */ + WindowPtr win; /* window of logical position */ + HotSpot hot; /* logical pointer position */ + HotSpot hotPhys; /* physical pointer position */ +#ifdef XINERAMA + ScreenPtr screen; /* all others are in Screen 0 coordinates */ + RegionRec Reg1; /* Region 1 for confining motion */ + RegionRec Reg2; /* Region 2 for confining virtual motion */ + WindowPtr windows[MAXSCREENS]; + WindowPtr confineWin; /* confine window */ +#endif /* XINERAMA */ + /* The window trace information is used at dix/events.c to avoid having + * to compute all the windows between the root and the current pointer + * window each time a button or key goes down. The grabs on each of those + * windows must be checked. + * spriteTraces should only be used at dix/events.c! */ + WindowPtr *spriteTrace; + int spriteTraceSize; + int spriteTraceGood; + + /* Due to delays between event generation and event processing, it is + * possible that the pointer has crossed screen boundaries between the + * time in which it begins generating events and the time when + * those events are processed. + * + * pEnqueueScreen: screen the pointer was on when the event was generated + * pDequeueScreen: screen the pointer was on when the event is processed + */ + ScreenPtr pEnqueueScreen; + ScreenPtr pDequeueScreen; + +} SpriteRec; + +typedef struct _KeyClassRec { + int sourceid; + CARD8 down[DOWN_LENGTH]; + CARD8 postdown[DOWN_LENGTH]; + int modifierKeyCount[8]; + struct _XkbSrvInfo *xkbInfo; +} KeyClassRec, *KeyClassPtr; + +typedef struct _ScrollInfo { + enum ScrollType type; + double increment; + int flags; +} ScrollInfo, *ScrollInfoPtr; + +typedef struct _AxisInfo { + int resolution; + int min_resolution; + int max_resolution; + int min_value; + int max_value; + Atom label; + CARD8 mode; + ScrollInfo scroll; +} AxisInfo, *AxisInfoPtr; + +typedef struct _ValuatorAccelerationRec { + int number; + PointerAccelSchemeProc AccelSchemeProc; + void *accelData; /* at disposal of AccelScheme */ + PointerAccelSchemeInitProc AccelInitProc; + DeviceCallbackProc AccelCleanupProc; +} ValuatorAccelerationRec, *ValuatorAccelerationPtr; + +typedef struct _ValuatorClassRec { + int sourceid; + int numMotionEvents; + int first_motion; + int last_motion; + void *motion; /* motion history buffer. Different layout + for MDs and SDs! */ + WindowPtr motionHintWindow; + + AxisInfoPtr axes; + unsigned short numAxes; + double *axisVal; /* always absolute, but device-coord system */ + ValuatorAccelerationRec accelScheme; + int h_scroll_axis; /* horiz smooth-scrolling axis */ + int v_scroll_axis; /* vert smooth-scrolling axis */ +} ValuatorClassRec; + +typedef struct _TouchListener { + XID listener; /* grabs/event selection IDs receiving + * events for this touch */ + int resource_type; /* listener's resource type */ + enum TouchListenerType type; + enum TouchListenerState state; + enum InputLevel level; /* matters only for emulating touches */ + WindowPtr window; + GrabPtr grab; +} TouchListener; + +typedef struct _TouchPointInfo { + uint32_t client_id; /* touch ID as seen in client events */ + int sourceid; /* Source device's ID for this touchpoint */ + Bool active; /* whether or not the touch is active */ + Bool pending_finish; /* true if the touch is physically inactive + * but still owned by a grab */ + SpriteRec sprite; /* window trace for delivery */ + ValuatorMask *valuators; /* last recorded axis values */ + TouchListener *listeners; /* set of listeners */ + int num_listeners; + int num_grabs; /* number of open grabs on this touch + * which have not accepted or rejected */ + Bool emulate_pointer; + DeviceEvent *history; /* History of events on this touchpoint */ + size_t history_elements; /* Number of current elements in history */ + size_t history_size; /* Size of history in elements */ +} TouchPointInfoRec; + +typedef struct _TouchClassRec { + int sourceid; + TouchPointInfoPtr touches; + unsigned short num_touches; /* number of allocated touches */ + unsigned short max_touches; /* maximum number of touches, may be 0 */ + CARD8 mode; /* ::XIDirectTouch, XIDependentTouch */ + /* for pointer-emulation */ + CARD8 buttonsDown; /* number of buttons down */ + unsigned short state; /* logical button state */ + Mask motionMask; +} TouchClassRec; + +typedef struct _GestureListener { + XID listener; /* grabs/event selection IDs receiving + * events for this gesture */ + int resource_type; /* listener's resource type */ + enum GestureListenerType type; + WindowPtr window; + GrabPtr grab; +} GestureListener; + +typedef struct _GestureInfo { + int sourceid; /* Source device's ID for this gesture */ + Bool active; /* whether or not the gesture is active */ + uint8_t type; /* Gesture type: either ET_GesturePinchBegin or + ET_GestureSwipeBegin. Valid if active == TRUE */ + int num_touches; /* The number of touches in the gesture */ + SpriteRec sprite; /* window trace for delivery */ + GestureListener listener; /* the listener that will receive events */ + Bool has_listener; /* true if listener has been setup already */ +} GestureInfoRec; + +typedef struct _GestureClassRec { + int sourceid; + GestureInfoRec gesture; + unsigned short max_touches; /* maximum number of touches, may be 0 */ +} GestureClassRec; + +typedef struct _ButtonClassRec { + int sourceid; + CARD8 numButtons; + CARD8 buttonsDown; /* number of buttons currently down + This counts logical buttons, not + physical ones, i.e if some buttons + are mapped to 0, they're not counted + here */ + unsigned short state; + Mask motionMask; + CARD8 down[DOWN_LENGTH]; + CARD8 postdown[DOWN_LENGTH]; + CARD8 map[MAP_LENGTH]; + union _XkbAction *xkb_acts; + Atom labels[MAX_BUTTONS]; +} ButtonClassRec, *ButtonClassPtr; + +typedef struct _FocusClassRec { + int sourceid; + WindowPtr win; /* May be set to a int constant (e.g. PointerRootWin)! */ + int revert; + TimeStamp time; + WindowPtr *trace; + int traceSize; + int traceGood; +} FocusClassRec, *FocusClassPtr; + +typedef struct _ProximityClassRec { + int sourceid; + char in_proximity; +} ProximityClassRec, *ProximityClassPtr; + +typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr; +typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr; +typedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr; +typedef struct _StringFeedbackClassRec *StringFeedbackPtr; +typedef struct _BellFeedbackClassRec *BellFeedbackPtr; +typedef struct _LedFeedbackClassRec *LedFeedbackPtr; + +typedef struct _KbdFeedbackClassRec { + BellProcPtr BellProc; + KbdCtrlProcPtr CtrlProc; + KeybdCtrl ctrl; + KbdFeedbackPtr next; + struct _XkbSrvLedInfo *xkb_sli; +} KbdFeedbackClassRec; + +typedef struct _PtrFeedbackClassRec { + PtrCtrlProcPtr CtrlProc; + PtrCtrl ctrl; + PtrFeedbackPtr next; +} PtrFeedbackClassRec; + +typedef struct _IntegerFeedbackClassRec { + IntegerCtrlProcPtr CtrlProc; + IntegerCtrl ctrl; + IntegerFeedbackPtr next; +} IntegerFeedbackClassRec; + +typedef struct _StringFeedbackClassRec { + StringCtrlProcPtr CtrlProc; + StringCtrl ctrl; + StringFeedbackPtr next; +} StringFeedbackClassRec; + +typedef struct _BellFeedbackClassRec { + BellProcPtr BellProc; + BellCtrlProcPtr CtrlProc; + BellCtrl ctrl; + BellFeedbackPtr next; +} BellFeedbackClassRec; + +typedef struct _LedFeedbackClassRec { + LedCtrlProcPtr CtrlProc; + LedCtrl ctrl; + LedFeedbackPtr next; + struct _XkbSrvLedInfo *xkb_sli; +} LedFeedbackClassRec; + +typedef struct _ClassesRec { + KeyClassPtr key; + ValuatorClassPtr valuator; + TouchClassPtr touch; + GestureClassPtr gesture; + ButtonClassPtr button; + FocusClassPtr focus; + ProximityClassPtr proximity; + KbdFeedbackPtr kbdfeed; + PtrFeedbackPtr ptrfeed; + IntegerFeedbackPtr intfeed; + StringFeedbackPtr stringfeed; + BellFeedbackPtr bell; + LedFeedbackPtr leds; +} ClassesRec; + +/* Device properties */ +typedef struct _XIPropertyValue { + Atom type; /* ignored by server */ + short format; /* format of data for swapping - 8,16,32 */ + long size; /* size of data in (format/8) bytes */ + void *data; /* private to client */ +} XIPropertyValueRec; + +typedef struct _XIProperty { + struct _XIProperty *next; + Atom propertyName; + BOOL deletable; /* clients can delete this prop? */ + XIPropertyValueRec value; +} XIPropertyRec; + +typedef XIPropertyRec *XIPropertyPtr; +typedef XIPropertyValueRec *XIPropertyValuePtr; + +typedef struct _XIPropertyHandler { + struct _XIPropertyHandler *next; + long id; + int (*SetProperty) (DeviceIntPtr dev, + Atom property, XIPropertyValuePtr prop, BOOL checkonly); + int (*GetProperty) (DeviceIntPtr dev, Atom property); + int (*DeleteProperty) (DeviceIntPtr dev, Atom property); +} XIPropertyHandler, *XIPropertyHandlerPtr; + +typedef struct _GrabInfoRec { + TimeStamp grabTime; + Bool fromPassiveGrab; /* true if from passive grab */ + Bool implicitGrab; /* implicit from ButtonPress */ + GrabPtr unused; /* Kept for ABI stability, remove soon */ + GrabPtr grab; + CARD8 activatingKey; + void (*ActivateGrab) (DeviceIntPtr /*device */ , + GrabPtr /*grab */ , + TimeStamp /*time */ , + Bool /*autoGrab */ ); + void (*DeactivateGrab) (DeviceIntPtr /*device */ ); + struct { + Bool frozen; + int state; + GrabPtr other; /* if other grab has this frozen */ + InternalEvent *event; /* saved to be replayed */ + } sync; +} GrabInfoRec, *GrabInfoPtr; + +typedef struct _SpriteInfoRec { + /* sprite must always point to a valid sprite. For devices sharing the + * sprite, let sprite point to a paired spriteOwner's sprite. */ + SpritePtr sprite; /* sprite information */ + Bool spriteOwner; /* True if device owns the sprite */ + DeviceIntPtr paired; /* The paired device. Keyboard if + spriteOwner is TRUE, otherwise the + pointer that owns the sprite. */ + + /* keep states for animated cursor */ + struct { + CursorPtr pCursor; + ScreenPtr pScreen; + int elt; + } anim; +} SpriteInfoRec, *SpriteInfoPtr; + +/* device types */ +#define MASTER_POINTER 1 +#define MASTER_KEYBOARD 2 +#define SLAVE 3 +/* special types for GetMaster */ +#define MASTER_ATTACHED 4 /* Master for this device */ +#define KEYBOARD_OR_FLOAT 5 /* Keyboard master for this device or this device if floating */ +#define POINTER_OR_FLOAT 6 /* Pointer master for this device or this device if floating */ + +typedef struct _DeviceIntRec { + DeviceRec public; + DeviceIntPtr next; + Bool startup; /* true if needs to be turned on at + server initialization time */ + DeviceProc deviceProc; /* proc(DevicePtr, DEVICE_xx). It is + used to initialize, turn on, or + turn off the device */ + Bool inited; /* TRUE if INIT returns Success */ + Bool enabled; /* TRUE if ON returns Success */ + Bool coreEvents; /* TRUE if device also sends core */ + GrabInfoRec deviceGrab; /* grab on the device */ + int type; /* MASTER_POINTER, MASTER_KEYBOARD, SLAVE */ + Atom xinput_type; + char *name; + int id; + KeyClassPtr key; + ValuatorClassPtr valuator; + TouchClassPtr touch; + GestureClassPtr gesture; + ButtonClassPtr button; + FocusClassPtr focus; + ProximityClassPtr proximity; + KbdFeedbackPtr kbdfeed; + PtrFeedbackPtr ptrfeed; + IntegerFeedbackPtr intfeed; + StringFeedbackPtr stringfeed; + BellFeedbackPtr bell; + LedFeedbackPtr leds; + struct _XkbInterest *xkb_interest; + char *config_info; /* used by the hotplug layer */ + ClassesPtr unused_classes; /* for master devices */ + int saved_master_id; /* for slaves while grabbed */ + PrivateRec *devPrivates; + DeviceUnwrapProc unwrapProc; + SpriteInfoPtr spriteInfo; + DeviceIntPtr master; /* master device */ + DeviceIntPtr lastSlave; /* last slave device used */ + + /* last valuator values recorded, not posted to client; + * for slave devices, valuators is in device coordinates, mapped to the + * desktop + * for master devices, valuators is in desktop coordinates. + * see dix/getevents.c + * remainder supports acceleration + */ + struct { + double valuators[MAX_VALUATORS]; + int numValuators; + DeviceIntPtr slave; + ValuatorMask *scroll; + int num_touches; /* size of the touches array */ + DDXTouchPointInfoPtr touches; + } last; + + /* Input device property handling. */ + struct { + XIPropertyPtr properties; + XIPropertyHandlerPtr handlers; /* NULL-terminated */ + } properties; + + /* coordinate transformation matrix for relative movement. Matrix with + * the translation component dropped */ + struct pixman_f_transform relative_transform; + /* scale matrix for absolute devices, this is the combined matrix of + [1/scale] . [transform] . [scale]. See DeviceSetTransform */ + struct pixman_f_transform scale_and_transform; + + /* XTest related master device id */ + int xtest_master_id; + DeviceSendEventsProc sendEventsProc; + + struct _SyncCounter *idle_counter; + + Bool ignoreXkbActionsBehaviors; /* TRUE if keys don't trigger behaviors and actions */ +} DeviceIntRec; + +typedef struct { + int numDevices; /* total number of devices */ + DeviceIntPtr devices; /* all devices turned on */ + DeviceIntPtr off_devices; /* all devices turned off */ + DeviceIntPtr keyboard; /* the main one for the server */ + DeviceIntPtr pointer; + DeviceIntPtr all_devices; + DeviceIntPtr all_master_devices; +} InputInfo; + +extern _X_EXPORT InputInfo inputInfo; + +/* for keeping the events for devices grabbed synchronously */ +typedef struct _QdEvent *QdEventPtr; +typedef struct _QdEvent { + struct xorg_list next; + DeviceIntPtr device; + ScreenPtr pScreen; /* what screen the pointer was on */ + unsigned long months; /* milliseconds is in the event */ + InternalEvent *event; +} QdEventRec; + +/** + * syncEvents is the global structure for queued events. + * + * Devices can be frozen through GrabModeSync pointer grabs. If this is the + * case, events from these devices are added to "pending" instead of being + * processed normally. When the device is unfrozen, events in "pending" are + * replayed and processed as if they would come from the device directly. + */ +typedef struct _EventSyncInfo { + struct xorg_list pending; + + /** The device to replay events for. Only set in AllowEvents(), in which + * case it is set to the device specified in the request. */ + DeviceIntPtr replayDev; /* kludgy rock to put flag for */ + + /** + * The window the events are supposed to be replayed on. + * This window may be set to the grab's window (but only when + * Replay{Pointer|Keyboard} is given in the XAllowEvents() + * request. */ + WindowPtr replayWin; /* ComputeFreezes */ + /** + * Flag to indicate whether we're in the process of + * replaying events. Only set in ComputeFreezes(). */ + Bool playingEvents; + TimeStamp time; +} EventSyncInfoRec, *EventSyncInfoPtr; + +extern EventSyncInfoRec syncEvents; + +/** + * Given a sprite, returns the window at the bottom of the trace (i.e. the + * furthest window from the root). + */ +static inline WindowPtr +DeepestSpriteWin(SpritePtr sprite) +{ + return sprite->spriteTrace[sprite->spriteTraceGood - 1]; +} + +struct _XI2Mask { + unsigned char **masks; /* event mask in masks[deviceid][event type byte] */ + size_t nmasks; /* number of masks */ + size_t mask_size; /* size of each mask in bytes */ +}; + +#endif /* INPUTSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/libinput-properties.h b/prebuilt/xlibre/usr/include/xorg/libinput-properties.h new file mode 100644 index 0000000..2034338 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/libinput-properties.h @@ -0,0 +1,269 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef _LIBINPUT_PROPERTIES_H_ +#define _LIBINPUT_PROPERTIES_H_ + +/* Tapping enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP "libinput Tapping Enabled" + +/* Tapping default enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_TAP_DEFAULT "libinput Tapping Enabled Default" + +/* Tap drag enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG "libinput Tapping Drag Enabled" + +/* Tap drag default enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_TAP_DRAG_DEFAULT "libinput Tapping Drag Enabled Default" + +/* Tap drag lock enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK "libinput Tapping Drag Lock Enabled" + +/* Tap drag lock default enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT "libinput Tapping Drag Lock Enabled Default" + +/* Tap button order: BOOL, 2 values in order LRM, LMR, only one may be set + at any time */ +#define LIBINPUT_PROP_TAP_BUTTONMAP "libinput Tapping Button Mapping Enabled" + +/* Tap button default order: BOOL, 2 values in order LRM, LMR, read-only */ +#define LIBINPUT_PROP_TAP_BUTTONMAP_DEFAULT "libinput Tapping Button Mapping Default" + +/* Clickfinger button order: BOOL, 2 values in order LRM, LMR, only one may be set + at any time */ +#define LIBINPUT_PROP_CLICKFINGER_BUTTONMAP "libinput Clickfinger Button Mapping Enabled" + +/* Clickfinger button default order: BOOL, 2 values in order LRM, LMR, read-only */ +#define LIBINPUT_PROP_CLICKFINGER_BUTTONMAP_DEFAULT "libinput Clickfinger Button Mapping Default" + +/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows */ +#define LIBINPUT_PROP_CALIBRATION "libinput Calibration Matrix" + +/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows, read-only*/ +#define LIBINPUT_PROP_CALIBRATION_DEFAULT "libinput Calibration Matrix Default" + +/* Pointer accel speed: FLOAT, 1 value, 32 bit */ +#define LIBINPUT_PROP_ACCEL "libinput Accel Speed" + +/* Pointer accel speed: FLOAT, 1 value, 32 bit, read-only*/ +#define LIBINPUT_PROP_ACCEL_DEFAULT "libinput Accel Speed Default" + +/* Pointer accel profile: BOOL, 3 values in order adaptive, flat, custom + * only one is enabled at a time at max, read-only */ +#define LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE "libinput Accel Profiles Available" + +/* Pointer accel profile: BOOL, 3 values in order adaptive, flat, custom + only one is enabled at a time at max, read-only */ +#define LIBINPUT_PROP_ACCEL_PROFILE_ENABLED_DEFAULT "libinput Accel Profile Enabled Default" + +/* Pointer accel profile: BOOL, 3 values in order adaptive, flat, custom + only one is enabled at a time at max */ +#define LIBINPUT_PROP_ACCEL_PROFILE_ENABLED "libinput Accel Profile Enabled" + +/* Points for the custom accel profile: FLOAT, N values */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_FALLBACK "libinput Accel Custom Fallback Points" + +/* Steps for the custom accel profile: FLOAT, 1 value */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_FALLBACK "libinput Accel Custom Fallback Step" + +/* Points for the custom accel profile: FLOAT, N values */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_MOTION "libinput Accel Custom Motion Points" + +/* Steps for the custom accel profile: FLOAT, 1 value */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_MOTION "libinput Accel Custom Motion Step" + +/* Points for the custom accel profile: FLOAT, N values */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_SCROLL "libinput Accel Custom Scroll Points" + +/* Steps for the custom accel profile: FLOAT, 1 value */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_SCROLL "libinput Accel Custom Scroll Step" + +/* Natural scrolling: BOOL, 1 value */ +#define LIBINPUT_PROP_NATURAL_SCROLL "libinput Natural Scrolling Enabled" + +/* Natural scrolling: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_NATURAL_SCROLL_DEFAULT "libinput Natural Scrolling Enabled Default" + +/* Send-events mode: BOOL read-only, 2 values in order disabled, + disabled-on-external-mouse */ +#define LIBINPUT_PROP_SENDEVENTS_AVAILABLE "libinput Send Events Modes Available" + +/* Send-events mode: BOOL, 2 values in order disabled, + disabled-on-external-mouse */ +#define LIBINPUT_PROP_SENDEVENTS_ENABLED "libinput Send Events Mode Enabled" + +/* Send-events mode: BOOL, 2 values in order disabled, + disabled-on-external-mouse, read-only */ +#define LIBINPUT_PROP_SENDEVENTS_ENABLED_DEFAULT "libinput Send Events Mode Enabled Default" + +/* Left-handed enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_LEFT_HANDED "libinput Left Handed Enabled" + +/* Left-handed enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_LEFT_HANDED_DEFAULT "libinput Left Handed Enabled Default" + +/* Scroll method: BOOL read-only, 3 values in order 2fg, edge, button. + shows available scroll methods */ +#define LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE "libinput Scroll Methods Available" + +/* Scroll method: BOOL, 3 values in order 2fg, edge, button + only one is enabled at a time at max */ +#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED "libinput Scroll Method Enabled" + +/* Scroll method: BOOL, 3 values in order 2fg, edge, button + only one is enabled at a time at max, read-only */ +#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT "libinput Scroll Method Enabled Default" + +/* Scroll button for button scrolling: 32-bit int, 1 value */ +#define LIBINPUT_PROP_SCROLL_BUTTON "libinput Button Scrolling Button" + +/* Scroll button for button scrolling: 32-bit int, 1 value, read-only */ +#define LIBINPUT_PROP_SCROLL_BUTTON_DEFAULT "libinput Button Scrolling Button Default" + +/* Scroll button lock: BOOL, 1 value, TRUE for enabled, FALSE otherwise */ +#define LIBINPUT_PROP_SCROLL_BUTTON_LOCK "libinput Button Scrolling Button Lock Enabled" + +/* Scroll button lock: BOOL, 1 value, TRUE for enabled, FALSE otherwise, read-only*/ +#define LIBINPUT_PROP_SCROLL_BUTTON_LOCK_DEFAULT "libinput Button Scrolling Button Lock Enabled Default" + +/* Scroll pixel distance: CARD32, 1 value (with implementation-defined limits) */ +#define LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE "libinput Scrolling Pixel Distance" + +/* Scroll pixel distance: CARD32, 1 value, read-only */ +#define LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE_DEFAULT "libinput Scrolling Pixel Distance Default" + +/* Scroll factor: FLOAT, 1 value, 32 bit */ +#define LIBINPUT_PROP_SCROLL_FACTOR "libinput Scrolling Factor" + +/* Scroll factor: FLOAT, 1 value, 32 bit, read-only */ +#define LIBINPUT_PROP_SCROLL_FACTOR_DEFAULT "libinput Scrolling Factor Default" + +/* Click method: BOOL read-only, 2 values in order buttonareas, clickfinger + shows available click methods */ +#define LIBINPUT_PROP_CLICK_METHODS_AVAILABLE "libinput Click Methods Available" + +/* Click method: BOOL, 2 values in order buttonareas, clickfinger + only one enabled at a time at max */ +#define LIBINPUT_PROP_CLICK_METHOD_ENABLED "libinput Click Method Enabled" + +/* Click method: BOOL, 2 values in order buttonareas, clickfinger + only one enabled at a time at max, read-only */ +#define LIBINPUT_PROP_CLICK_METHOD_ENABLED_DEFAULT "libinput Click Method Enabled Default" + +/* Middle button emulation: BOOL, 1 value */ +#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED "libinput Middle Emulation Enabled" + +/* Middle button emulation: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT "libinput Middle Emulation Enabled Default" + +/* Disable while typing: BOOL, 1 value */ +#define LIBINPUT_PROP_DISABLE_WHILE_TYPING "libinput Disable While Typing Enabled" + +/* Disable while typing: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_DISABLE_WHILE_TYPING_DEFAULT "libinput Disable While Typing Enabled Default" + +/* Drag lock buttons, either: + CARD8, one value, the meta lock button, or + CARD8, n * 2 values, the drag lock pairs with n being the button and n+1 + the target button number */ +#define LIBINPUT_PROP_DRAG_LOCK_BUTTONS "libinput Drag Lock Buttons" + +/* Horizontal scroll events enabled: BOOL, 1 value (0 or 1). + * If disabled, horizontal scroll events are discarded */ +#define LIBINPUT_PROP_HORIZ_SCROLL_ENABLED "libinput Horizontal Scroll Enabled" + +/* Number of modes each pad mode group has available: CARD8, one for each + * pad mode group, read-only. + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUPS_AVAILABLE "libinput Pad Mode Groups Modes Available" + +/* Mode each pad mode group is currently in: CARD8, one for each pad mode + * group, read-only. + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUPS "libinput Pad Mode Groups Modes" + +/* The association of each logical button with the pad mode group: INT8, + * one for each logical button. If set to -1 the button cannot be associated + * with a mode group. read-only + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_BUTTONS "libinput Pad Mode Group Buttons" + +/* The association of each logical strip with the pad mode group: INT8, + * one for each logical strip. If set to -1 the strip cannot be associated + * with a mode group. read-only + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_STRIPS "libinput Pad Mode Group Strips" + +/* The association of each logical ring with the pad mode group: INT8, + * one for each logical ring. If set to -1 the ring cannot be associated + * with a mode group. read-only + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_RINGS "libinput Pad Mode Group Rings" + +/* Device rotation: FLOAT, 1 value, 32 bit */ +#define LIBINPUT_PROP_ROTATION_ANGLE "libinput Rotation Angle" + +/* Device rotation: FLOAT, 1 value, 32 bit, read-only */ +#define LIBINPUT_PROP_ROTATION_ANGLE_DEFAULT "libinput Rotation Angle Default" + +/* Tablet tool pressure curve: float, 8 values, 32 bit + * Value range is [0.0, 1.0], the values specify the x/y of the four + * control points for a cubic bezier curve. + * Default value: 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 + */ +#define LIBINPUT_PROP_TABLET_TOOL_PRESSURECURVE "libinput Tablet Tool Pressurecurve" + +/* Tablet tool pressure range: float, 2 values, 32 bit + * Value range is [0.0, 1.0] for min and max physical pressure to map to the logical range + * Default value: 0.0 1.0 + */ +#define LIBINPUT_PROP_TABLET_TOOL_PRESSURE_RANGE "libinput Tablet Tool Pressure Range" + +/* Tablet tool pressure range: float, 2 values, 32 bit, read-only */ +#define LIBINPUT_PROP_TABLET_TOOL_PRESSURE_RANGE_DEFAULT "libinput Tablet Tool Pressure Range Default" + +/* Tablet tool area ratio: CARD32, 2 values, w and h */ +#define LIBINPUT_PROP_TABLET_TOOL_AREA_RATIO "libinput Tablet Tool Area Ratio" + +/* High-resolution wheel scroll events enabled: BOOL, 1 value (0 or 1). + * If disabled, high-resolution wheel scroll events are discarded */ +#define LIBINPUT_PROP_HIRES_WHEEL_SCROLL_ENABLED "libinput High Resolution Wheel Scroll Enabled" + +/* The tablet tool unique serial number: CARD32, 1 value, constant for the + * lifetime of the device. + * + * If this property exists and is zero, the tool does not have a unique serial + * number. + */ +#define LIBINPUT_PROP_TABLET_TOOL_SERIAL "libinput Tablet Tool Serial" + +/* The tablet tool hardware ID: CARD32, 1 value, constant for the lifetime of the device. + * + * This property only exists if the device has a known tool ID. + * See libinput_tablet_tool_get_tool_id() in the libinput documentation for details. + */ +#define LIBINPUT_PROP_TABLET_TOOL_ID "libinput Tablet Tool ID" + +#endif /* _LIBINPUT_PROPERTIES_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/list.h b/prebuilt/xlibre/usr/include/xorg/list.h new file mode 100644 index 0000000..349d99a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/list.h @@ -0,0 +1,554 @@ +/* + * Copyright © 2010 Intel Corporation + * Copyright © 2010 Francisco Jerez + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#ifndef _XORG_LIST_H_ +#define _XORG_LIST_H_ + +#include /* offsetof() */ + +/** + * @file Classic doubly-link circular list implementation. + * For real usage examples of the linked list, see the file test/list.c + * + * Example: + * We need to keep a list of struct foo in the parent struct bar, i.e. what + * we want is something like this. + * + * struct bar { + * ... + * struct foo *list_of_foos; -----> struct foo {}, struct foo {}, struct foo{} + * ... + * } + * + * We need one list head in bar and a list element in all list_of_foos (both are of + * data type 'struct xorg_list'). + * + * struct bar { + * ... + * struct xorg_list list_of_foos; + * ... + * } + * + * struct foo { + * ... + * struct xorg_list entry; + * ... + * } + * + * Now we initialize the list head: + * + * struct bar bar; + * ... + * xorg_list_init(&bar.list_of_foos); + * + * Then we create the first element and add it to this list: + * + * struct foo *foo = malloc(...); + * .... + * xorg_list_add(&foo->entry, &bar.list_of_foos); + * + * Repeat the above for each element you want to add to the list. Deleting + * works with the element itself. + * xorg_list_del(&foo->entry); + * free(foo); + * + * Note: calling xorg_list_del(&bar.list_of_foos) will set bar.list_of_foos to an empty + * list again. + * + * Looping through the list requires a 'struct foo' as iterator and the + * name of the field the subnodes use. + * + * struct foo *iterator; + * xorg_list_for_each_entry(iterator, &bar.list_of_foos, entry) { + * if (iterator->something == ...) + * ... + * } + * + * Note: You must not call xorg_list_del() on the iterator if you continue the + * loop. You need to run the safe for-each loop instead: + * + * struct foo *iterator, *next; + * xorg_list_for_each_entry_safe(iterator, next, &bar.list_of_foos, entry) { + * if (...) + * xorg_list_del(&iterator->entry); + * } + * + * WARNING: entries MUST NOT be added to the list twice, otherwise iterating + * will end up in infinite loop. + * WARNING: entries MUST NOT be added to multiple lists - use separate entry + * nodes within the container struct, if it needs to be added to + * several lists at the same time. + */ + +/** + * The linkage struct for list nodes. This struct must be part of your + * to-be-linked struct. struct xorg_list is required for both the head of the + * list and for each list node. + * + * Position and name of the struct xorg_list field is irrelevant. + * There are no requirements that elements of a list are of the same type. + * There are no requirements for a list head, any struct xorg_list can be a list + * head. + */ +struct xorg_list { + struct xorg_list *next, *prev; +}; + +/** + * Initialize the list as an empty list. + * + * Example: + * xorg_list_init(&bar->list_of_foos); + * + * @param list The list to initialize + */ +static inline void +xorg_list_init(struct xorg_list *list) +{ + list->next = list->prev = list; +} + +static inline void +__xorg_list_autoinit(struct xorg_list *head) +{ + if ((!head->prev) && (!head->next)) + xorg_list_init(head); +} + +static inline void +__xorg_list_add(struct xorg_list *entry, + struct xorg_list *prev, struct xorg_list *next) +{ + next->prev = entry; + entry->next = next; + entry->prev = prev; + prev->next = entry; +} + +/** + * Insert a new element after the given list head. The new element does not + * need to be initialised as empty list. + * The list changes from: + * head → some element → ... + * to + * head → new element → older element → ... + * + * Example: + * struct foo *newfoo = malloc(...); + * xorg_list_add(&newfoo->entry, &bar->list_of_foos); + * + * @param entry The new element to prepend to the list. + * @param head The existing list. + */ +static inline void +xorg_list_add(struct xorg_list *entry, struct xorg_list *head) +{ + __xorg_list_autoinit(head); + __xorg_list_add(entry, head, head->next); +} + +/** + * Append a new element to the end of the list given with this list head. + * + * The list changes from: + * head → some element → ... → lastelement + * to + * head → some element → ... → lastelement → new element + * + * Example: + * struct foo *newfoo = malloc(...); + * xorg_list_append(&newfoo->entry, &bar->list_of_foos); + * + * @param entry The new element to append to the list. + * @param head The existing list. + */ +static inline void +xorg_list_append(struct xorg_list *entry, struct xorg_list *head) +{ + __xorg_list_autoinit(head); + __xorg_list_add(entry, head->prev, head); +} + +static inline void +__xorg_list_del(struct xorg_list *prev, struct xorg_list *next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * Remove the element from the list it is in. Using this function will reset + * the pointers to/from this element so it is removed from the list. It does + * NOT free the element itself or manipulate it otherwise. + * + * Using xorg_list_del on a pure list head (like in the example at the top of + * this file) will NOT remove the first element from + * the list but rather reset the list as empty list. + * + * Example: + * xorg_list_del(&foo->entry); + * + * @param entry The element to remove. + */ +static inline void +xorg_list_del(struct xorg_list *entry) +{ + __xorg_list_autoinit(entry); + __xorg_list_del(entry->prev, entry->next); + xorg_list_init(entry); +} + +/** + * Check if the list is empty. + * + * Example: + * xorg_list_is_empty(&bar->list_of_foos); + * + * @return True if the list is empty or False if the list contains one or more + * elements. + */ +static inline int +xorg_list_is_empty(struct xorg_list *head) +{ + return ((head->next == NULL) || (head->next == head)); +} + +/** + * @brief check whether element already is in list + * + * @param entry The element to check for + * @param head The existing list. + * @return zero when entry isn't present in list, otherwise non-zero + */ +static inline int +xorg_list_present(struct xorg_list *entry, struct xorg_list *head) +{ + for (struct xorg_list *l=head->next; l && (l != head); l=l->next) { + if (l == entry) + return 1; + } + return 0; +} + +/** + * @brief prepend a new element to the end of the list if not existing yet + * + * Same as xorg_list_add(), but protecting against duplicate insertion. + * + * @param entry The new element to append to the list. + * @param head The existing list. + * @return zero if element already in list, otherwise non-zero + */ +static inline int +xorg_list_add_ndup(struct xorg_list *entry, struct xorg_list *head) +{ + if (xorg_list_present(entry, head)) + return 0; + + xorg_list_add(entry, head); + return 1; +} + +/** + * @brief append a new element to the end of the list if not existing yet + * + * Same as xorg_list_append(), but protecting against duplicate insertion. + * + * @param entry The new element to append to the list. + * @param head The existing list. + * @return zero if element already in list, otherwise non-zero + */ +static inline int +xorg_list_append_ndup(struct xorg_list *entry, struct xorg_list *head) +{ + if (xorg_list_present(entry, head)) + return 0; + + xorg_list_append(entry, head); + return 1; +} + +/** + * Returns a pointer to the container of this list element. + * + * Example: + * struct foo* f; + * f = container_of(&foo->entry, struct foo, entry); + * assert(f == foo); + * + * @param ptr Pointer to the struct xorg_list. + * @param type Data type of the list element. + * @param member Member name of the struct xorg_list field in the list element. + * @return A pointer to the data struct containing the list head. + */ +#ifndef container_of +#define container_of(ptr, type, member) \ + (type *)((char *)(ptr) - offsetof(type, member)) +#endif + +/** + * Alias of container_of + */ +#define xorg_list_entry(ptr, type, member) \ + container_of((ptr), type, member) + +/** + * Retrieve the first list entry for the given list pointer. + * + * Example: + * struct foo *first; + * first = xorg_list_first_entry(&bar->list_of_foos, struct foo, list_of_foos); + * + * @param ptr The list head + * @param type Data type of the list element to retrieve + * @param member Member name of the struct xorg_list field in the list element. + * @return A pointer to the first list element. + */ +#define xorg_list_first_entry(ptr, type, member) \ + xorg_list_entry((ptr)->next, type, member) + +/** + * Retrieve the last list entry for the given listpointer. + * + * Example: + * struct foo *first; + * first = xorg_list_last_entry(&bar->list_of_foos, struct foo, list_of_foos); + * + * @param ptr The list head + * @param type Data type of the list element to retrieve + * @param member Member name of the struct xorg_list field in the list element. + * @return A pointer to the last list element. + */ +#define xorg_list_last_entry(ptr, type, member) \ + xorg_list_entry((ptr)->prev, type, member) + +#define __container_of(ptr, sample, member) \ + container_of((ptr), typeof(*(sample)), member) + +/** + * Loop through the list given by head and set pos to struct in the list. + * + * Example: + * struct foo *iterator; + * xorg_list_for_each_entry(iterator, &bar->list_of_foos, entry) { + * [modify iterator] + * } + * + * This macro is not safe for node deletion. Use xorg_list_for_each_entry_safe + * instead. + * + * @param pos Iterator variable of the type of the list elements. + * @param head List head + * @param member Member name of the struct xorg_list in the list elements. + * + */ +#define xorg_list_for_each_entry(pos, head, member) \ + for ((pos) = NULL, \ + (pos) = __container_of((head)->next, (pos), member); \ + (((head)->next != NULL) && &(pos)->member != (head)); \ + (pos) = __container_of((pos)->member.next, (pos), member)) + +/** + * Loop through the list, keeping a backup pointer to the element. This + * macro allows for the deletion of a list element while looping through the + * list. + * + * See xorg_list_for_each_entry for more details. + */ +#define xorg_list_for_each_entry_safe(pos, tmp, head, member) \ + for ((pos) = NULL, \ + (pos) = __container_of((head)->next, (pos), member), \ + (tmp) = __container_of((head)->next ? (pos)->member.next : NULL, (pos), member); \ + (((head)->next != NULL) && (&(pos)->member != (head))); \ + (pos) = (tmp), (tmp) = __container_of((pos)->member.next, (tmp), member)) + +/* NULL-Terminated List Interface + * + * The interface below does _not_ use the struct xorg_list as described above. + * It is mainly for legacy structures that cannot easily be switched to + * struct xorg_list. + * + * This interface is for structs like + * struct foo { + * [...] + * struct foo *next; + * [...] + * }; + * + * The position and field name of "next" are arbitrary. + */ + +/** + * Init the element as null-terminated list. + * + * Example: + * struct foo *list = malloc(); + * nt_list_init(list, next); + * + * @param list The list element that will be the start of the list + * @param member Member name of the field pointing to next struct + */ +#define nt_list_init(_list, _member) \ + (_list)->_member = NULL + +/** + * Returns the next element in the list or NULL on termination. + * + * Example: + * struct foo *element = list; + * while ((element = nt_list_next(element, next)) { } + * + * This macro is not safe for node deletion. Use nt_list_for_each_entry_safe + * instead. + * + * @param list The list or current element. + * @param member Member name of the field pointing to next struct. + */ +#define nt_list_next(_list, _member) \ + (_list)->_member + +/** + * Iterate through each element in the list. + * + * Example: + * struct foo *iterator; + * nt_list_for_each_entry(iterator, list, next) { + * [modify iterator] + * } + * + * @param entry Assigned to the current list element + * @param list The list to iterate through. + * @param member Member name of the field pointing to next struct. + */ +#define nt_list_for_each_entry(_entry, _list, _member) \ + for ((_entry) = (_list); (_entry); (_entry) = (_entry)->_member) + +/** + * Iterate through each element in the list, keeping a backup pointer to the + * element. This macro allows for the deletion of a list element while + * looping through the list. + * + * See nt_list_for_each_entry for more details. + * + * @param entry Assigned to the current list element + * @param tmp The pointer to the next element + * @param list The list to iterate through. + * @param member Member name of the field pointing to next struct. + */ +#define nt_list_for_each_entry_safe(_entry, _tmp, _list, _member) \ + for ((_entry) = (_list), (_tmp) = (_entry) ? (_entry)->_member : NULL;\ + (_entry); \ + (_entry) = (_tmp), (_tmp) = (_tmp) ? (_tmp)->_member: NULL) + +/** + * Append the element to the end of the list. This macro may be used to + * merge two lists. + * + * Example: + * struct foo *elem = malloc(...); + * nt_list_init(elem, next) + * nt_list_append(elem, list, struct foo, next); + * + * Resulting list order: + * list_item_0 -> list_item_1 -> ... -> elem_item_0 -> elem_item_1 ... + * + * @param entry An entry (or list) to append to the list + * @param list The list to append to. This list must be a valid list, not + * NULL. + * @param type The list type + * @param member Member name of the field pointing to next struct + */ +#define nt_list_append(_entry, _list, _type, _member) \ + do { \ + _type *__iterator = (_list); \ + while (__iterator->_member) { __iterator = __iterator->_member;}\ + __iterator->_member = (_entry); \ + } while (0) + +/** + * Insert the element at the next position in the list. This macro may be + * used to insert a list into a list. + * + * struct foo *elem = malloc(...); + * nt_list_init(elem, next) + * nt_list_insert(elem, list, struct foo, next); + * + * Resulting list order: + * list_item_0 -> elem_item_0 -> elem_item_1 ... -> list_item_1 -> ... + * + * @param entry An entry (or list) to append to the list + * @param list The list to insert to. This list must be a valid list, not + * NULL. + * @param type The list type + * @param member Member name of the field pointing to next struct + */ +#define nt_list_insert(_entry, _list, _type, _member) \ + do { \ + nt_list_append((_list)->_member, (_entry), _type, _member); \ + (_list)->_member = (_entry); \ + } while (0) + +/** + * Delete the entry from the list by iterating through the list and + * removing any reference from the list to the entry. + * + * Example: + * struct foo *elem = + * nt_list_del(elem, list, struct foo, next); + * + * @param entry The entry to delete from the list. entry is always + * re-initialized as a null-terminated list. + * @param list The list containing the entry, set to the new list without + * the removed entry. + * @param type The list type + * @param member Member name of the field pointing to the next entry + */ +#define nt_list_del(_entry, _list, _type, _member) \ + do { \ + _type *__e = (_entry); \ + if (__e == NULL || (_list) == NULL) break; \ + if ((_list) == __e) { \ + (_list) = __e->_member; \ + } else { \ + _type *__prev = (_list); \ + while (__prev->_member && __prev->_member != __e) \ + __prev = nt_list_next(__prev, _member); \ + if (__prev->_member) \ + __prev->_member = __e->_member; \ + } \ + nt_list_init(__e, _member); \ + } while(0) + +/** + * DO NOT USE THIS. + * This is a remainder of the xfree86 DDX attempt of having a set of generic + * list functions. Unfortunately, the xf86OptionRec uses it and we can't + * easily get rid of it. Do not use for new code. + */ +typedef struct generic_list_rec { + void *next; +} GenericListRec, *GenericListPtr, *glp; + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/mi.h b/prebuilt/xlibre/usr/include/xorg/mi.h new file mode 100644 index 0000000..7144fb5 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/mi.h @@ -0,0 +1,300 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef MI_H +#define MI_H + +#include +#include + +#include "regionstr.h" +#include "validate.h" +#include "window.h" +#include "gc.h" +#include "input.h" +#include "cursor.h" +#include "privates.h" +#include "colormap.h" +#include "events.h" + +#define MiBits CARD32 + +typedef struct _miDash *miDashPtr; + +#define EVEN_DASH 0 +#define ODD_DASH ~0 + +/* miarc.c */ + +extern _X_EXPORT void miPolyArc(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*narcs */ , + xArc * /*parcs */ + ); + +/* micopy.c */ + +#define miGetCompositeClip(pGC) ((pGC)->pCompositeClip) + +typedef void (*miCopyProc) (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pDstBox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, Pixel bitplane, void *closure); + +extern _X_EXPORT void + +miCopyRegion(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + RegionPtr pDstRegion, + int dx, + int dy, miCopyProc copyProc, Pixel bitPlane, void *closure); + +extern _X_EXPORT RegionPtr + +miDoCopy(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + int xIn, + int yIn, + int widthSrc, + int heightSrc, + int xOut, + int yOut, miCopyProc copyProc, Pixel bitplane, void *closure); + +/* mieq.c */ + +#ifndef INPUT_H +typedef struct _DeviceRec *DevicePtr; +#endif + +/* miexpose.c */ + +extern _X_EXPORT RegionPtr miHandleExposures(DrawablePtr /*pSrcDrawable */ , + DrawablePtr /*pDstDrawable */ , + GCPtr /*pGC */ , + int /*srcx */ , + int /*srcy */ , + int /*width */ , + int /*height */ , + int /*dstx */ , + int /*dsty */ + ); + +extern _X_EXPORT void miClearDrawable(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ + ); + +/* miglblt.c */ + +extern _X_EXPORT void miPolyGlyphBlt(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci, + void *pglyphBase + ); + +extern _X_EXPORT void miImageGlyphBlt(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci, + void *pglyphBase + ); + +/* mipoly.c */ + +extern _X_EXPORT void miFillPolygon(DrawablePtr /*dst */ , + GCPtr /*pgc */ , + int /*shape */ , + int /*mode */ , + int /*count */ , + DDXPointPtr /*pPts */ + ); + +/* mipolypnt.c */ + +extern _X_EXPORT void miPolyPoint(DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*mode */ , + int /*npt */ , + xPoint * /*pptInit */ + ); + +/* mipolyrect.c */ + +extern _X_EXPORT void miPolyRectangle(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*nrects */ , + xRectangle * /*pRects */ + ); + +/* mipolyseg.c */ + +extern _X_EXPORT void miPolySegment(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*nseg */ , + xSegment * /*pSegs */ + ); + +/* mipolytext.c */ + +extern _X_EXPORT int miPolyText8(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + char * /*chars */ + ); + +extern _X_EXPORT int miPolyText16(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + unsigned short * /*chars */ + ); + +extern _X_EXPORT void miImageText8(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + char * /*chars */ + ); + +extern _X_EXPORT void miImageText16(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*x */ , + int /*y */ , + int /*count */ , + unsigned short * /*chars */ + ); + +/* mipushpxl.c */ + +extern _X_EXPORT void miPushPixels(GCPtr /*pGC */ , + PixmapPtr /*pBitMap */ , + DrawablePtr /*pDrawable */ , + int /*dx */ , + int /*dy */ , + int /*xOrg */ , + int /*yOrg */ + ); + +/* miscrinit.c */ +extern _X_EXPORT Bool miModifyPixmapHeader(PixmapPtr pPixmap, + int width, + int height, + int depth, + int bitsPerPixel, + int devKind, + void *pPixData + ); + +extern _X_EXPORT Bool miScreenInit(ScreenPtr pScreen, + void *pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int rootDepth, + int numDepths, + DepthPtr depths, + VisualID rootVisual, + int numVisuals, + VisualPtr visuals + ); + +/* mivaltree.c */ + +extern _X_EXPORT void miWideLine(DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*mode */ , + int /*npt */ , + DDXPointPtr /*pPts */ + ); + +extern _X_EXPORT void miWideDash(DrawablePtr /*pDrawable */ , + GCPtr /*pGC */ , + int /*mode */ , + int /*npt */ , + DDXPointPtr /*pPts */ + ); + +extern _X_EXPORT void miPolylines(DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts); + +/* mizerarc.c */ + +extern _X_EXPORT void miZeroPolyArc(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*narcs */ , + xArc * /*parcs */ + ); + +_X_EXPORT void miZeroLine(DrawablePtr dst, GCPtr gc, int mode, int nptInit, xPoint* pptInit); +_X_EXPORT void miZeroDashLine(DrawablePtr dst, GCPtr pgc, int mode, int nptInit, xPoint *pptInit); + +extern _X_EXPORT void miPolyFillArc(DrawablePtr /*pDraw */ , + GCPtr /*pGC */ , + int /*narcs */ , + xArc * /*parcs */ + ); + +#endif /* MI_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/micmap.h b/prebuilt/xlibre/usr/include/xorg/micmap.h new file mode 100644 index 0000000..781b4e4 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/micmap.h @@ -0,0 +1,43 @@ +#ifndef _MICMAP_H_ +#define _MICMAP_H_ + +#include +#include +#include + +#include "colormap.h" +#include "privates.h" +#include "screenint.h" + +extern _X_EXPORT DevPrivateKeyRec micmapScrPrivateKeyRec; + +#define micmapScrPrivateKey (&micmapScrPrivateKeyRec) + +extern _X_EXPORT int miListInstalledColormaps(ScreenPtr pScreen, + Colormap * pmaps); +extern _X_EXPORT void miInstallColormap(ColormapPtr pmap); +extern _X_EXPORT void miUninstallColormap(ColormapPtr pmap); + +extern _X_EXPORT void miResolveColor(unsigned short *, unsigned short *, + unsigned short *, VisualPtr); +extern _X_EXPORT Bool miInitializeColormap(ColormapPtr); +extern _X_EXPORT Bool miCreateDefColormap(ScreenPtr); +extern _X_EXPORT void miClearVisualTypes(void); +extern _X_EXPORT Bool miSetVisualTypes(int, int, int, int); +extern _X_EXPORT Bool miSetPixmapDepths(void); +extern _X_EXPORT Bool miSetVisualTypesAndMasks(int depth, int visuals, + int bitsPerRGB, int preferredCVC, + Pixel redMask, Pixel greenMask, + Pixel blueMask); +extern _X_EXPORT int miGetDefaultVisualMask(int); +extern _X_EXPORT Bool miInitVisuals(VisualPtr *, DepthPtr *, int *, int *, + int *, VisualID *, unsigned long, int, int); + +#define MAX_PSEUDO_DEPTH 10 + +#define StaticColorMask (1 << StaticColor) +#define PseudoColorMask (1 << PseudoColor) +#define TrueColorMask (1 << TrueColor) +#define DirectColorMask (1 << DirectColor) + +#endif /* _MICMAP_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/micoord.h b/prebuilt/xlibre/usr/include/xorg/micoord.h new file mode 100644 index 0000000..20f467a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/micoord.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + * + */ + +#ifndef _MICOORD_H_ +#define _MICOORD_H_ 1 + +#include "servermd.h" + +/* Macros which handle a coordinate in a single register */ + +#define GetHighWord(x) (((int) (x)) >> 16) + +#if IMAGE_BYTE_ORDER == MSBFirst +#define coordToInt(x,y) (((x) << 16) | ((y) & 0xffff)) +#define intToX(i) (GetHighWord((i))) +#define intToY(i) ((int) ((short) (i))) +#else +#define coordToInt(x,y) (((y) << 16) | ((x) & 0xffff)) +#define intToX(i) ((int) ((short) (i))) +#define intToY(i) (GetHighWord((i))) +#endif + +#endif /* _MICOORD_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/migc.h b/prebuilt/xlibre/usr/include/xorg/migc.h new file mode 100644 index 0000000..add601a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/migc.h @@ -0,0 +1,54 @@ +/* + +Copyright 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +*/ + +#ifndef _MIGC_H +#define _MIGC_H + +extern _X_EXPORT void miChangeGC(GCPtr pGC, + unsigned long mask); + +extern _X_EXPORT void miDestroyGC(GCPtr pGC); + +extern _X_EXPORT void miDestroyClip(GCPtr pGC); + +extern _X_EXPORT void miChangeClip(GCPtr pGC, + int type, + void *pvalue, + int nrects); + +extern _X_EXPORT void miCopyClip(GCPtr pgcDst, + GCPtr pgcSrc); + +extern _X_EXPORT void miCopyGC(GCPtr pGCSrc, + unsigned long changes, + GCPtr pGCDst); + +extern _X_EXPORT void miComputeCompositeClip(GCPtr pGC, + DrawablePtr pDrawable); + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/miline.h b/prebuilt/xlibre/usr/include/xorg/miline.h new file mode 100644 index 0000000..ad6b373 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/miline.h @@ -0,0 +1,152 @@ +/* + +Copyright 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifndef MILINE_H +#define MILINE_H + +#include "screenint.h" +#include "privates.h" + +/* + * Public definitions used for configuring basic pixelization aspects + * of the sample implementation line-drawing routines provided in + * {mfb,mi,cfb*} at run-time. + */ + +#define XDECREASING 4 +#define YDECREASING 2 +#define YMAJOR 1 + +#define OCTANT1 (1 << (YDECREASING)) +#define OCTANT2 (1 << (YDECREASING|YMAJOR)) +#define OCTANT3 (1 << (XDECREASING|YDECREASING|YMAJOR)) +#define OCTANT4 (1 << (XDECREASING|YDECREASING)) +#define OCTANT5 (1 << (XDECREASING)) +#define OCTANT6 (1 << (XDECREASING|YMAJOR)) +#define OCTANT7 (1 << (YMAJOR)) +#define OCTANT8 (1 << (0)) + +/* + * Devices can configure the rendering of routines in mi, mfb, and cfb* + * by specifying a thin line bias to be applied to a particular screen + * using the following function. The bias parameter is an OR'ing of + * the appropriate OCTANT constants defined above to indicate which + * octants to bias a line to prefer an axial step when the Bresenham + * error term is exactly zero. The octants are mapped as follows: + * + * \ | / + * \ 3 | 2 / + * \ | / + * 4 \ | / 1 + * \|/ + * ----------- + * /|\ + * 5 / | \ 8 + * / | \ + * / 6 | 7 \ + * / | \ + * + * For more information, see "Ambiguities in Incremental Line Rastering," + * Jack E. Bresenham, IEEE CG&A, May 1987. + */ + +extern _X_EXPORT void miSetZeroLineBias(ScreenPtr /* pScreen */ , + unsigned int /* bias */ + ); + +/* + * Private definitions needed for drawing thin (zero width) lines + * Used by the mi, mfb, and all cfb* components. + */ + +#define X_AXIS 0 +#define Y_AXIS 1 + +#define OUT_LEFT 0x08 +#define OUT_RIGHT 0x04 +#define OUT_ABOVE 0x02 +#define OUT_BELOW 0x01 + +#define OUTCODES(_result, _x, _y, _pbox) \ + if ( (_x) < (_pbox)->x1) (_result) |= OUT_LEFT; \ + else if ( (_x) >= (_pbox)->x2) (_result) |= OUT_RIGHT; \ + if ( (_y) < (_pbox)->y1) (_result) |= OUT_ABOVE; \ + else if ( (_y) >= (_pbox)->y2) (_result) |= OUT_BELOW; + +#define MIOUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \ +{\ + if ((x) < (xmin)) (outcode) |= OUT_LEFT;\ + if ((x) > (xmax)) (outcode) |= OUT_RIGHT;\ + if ((y) < (ymin)) (outcode) |= OUT_ABOVE;\ + if ((y) > (ymax)) (outcode) |= OUT_BELOW;\ +} + +#define miGetZeroLineBias(_pScreen) ((unsigned long) (unsigned long*)\ + dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey)) + +#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \ + (_octant) = 0; \ + (_sx) = (_SX); \ + if (((_adx) = (_x2) - (_x1)) < 0) { \ + (_adx) = -(_adx); \ + ((_sx) = -(_sx)); \ + (_octant) |= XDECREASING; \ + } \ + (_sy) = (_SY); \ + if (((_ady) = (_y2) - (_y1)) < 0) { \ + (_ady) = -(_ady); \ + ((_sy) = -(_sy)); \ + (_octant) |= YDECREASING; \ + } + +#define SetYMajorOctant(_octant) ((_octant) |= YMAJOR) + +#define FIXUP_ERROR(_e, _octant, _bias) \ + (_e) -= (((_bias) >> (_octant)) & 1) + +extern _X_EXPORT DevPrivateKeyRec miZeroLineScreenKeyRec; + +#define miZeroLineScreenKey (&miZeroLineScreenKeyRec) + +extern _X_EXPORT int miZeroClipLine(int /*xmin */ , + int /*ymin */ , + int /*xmax */ , + int /*ymax */ , + int * /*new_x1 */ , + int * /*new_y1 */ , + int * /*new_x2 */ , + int * /*new_y2 */ , + unsigned int /*adx */ , + unsigned int /*ady */ , + int * /*pt1_clipped */ , + int * /*pt2_clipped */ , + int /*octant */ , + unsigned int /*bias */ , + int /*oc1 */ , + int /*oc2 */ + ); + +#endif /* MILINE_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/mipict.h b/prebuilt/xlibre/usr/include/xorg/mipict.h new file mode 100644 index 0000000..5551d38 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/mipict.h @@ -0,0 +1,124 @@ +/* + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _MIPICT_H_ +#define _MIPICT_H_ + +#include "picturestr.h" + +#define MI_MAX_INDEXED 256 /* XXX depth must be <= 8 */ + +#if MI_MAX_INDEXED <= 256 +typedef CARD8 miIndexType; +#endif + +typedef struct _miIndexed { + Bool color; + CARD32 rgba[MI_MAX_INDEXED]; + miIndexType ent[32768]; +} miIndexedRec, *miIndexedPtr; + +#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \ + (((s) >> 6) & 0x03e0) | \ + (((s) >> 9) & 0x7c00)) +#define miIndexToEnt15(mif,rgb15) ((mif)->ent[(rgb15)]) +#define miIndexToEnt24(mif,rgb24) miIndexToEnt15((mif),miCvtR8G8B8to15((rgb24))) + +#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15((rgb24))]) + +extern _X_EXPORT int + miCreatePicture(PicturePtr pPicture); + +extern _X_EXPORT void + miDestroyPicture(PicturePtr pPicture); + +extern _X_EXPORT void + miCompositeSourceValidate(PicturePtr pPicture); + +extern _X_EXPORT Bool + +miComputeCompositeRegion(RegionPtr pRegion, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); + +extern _X_EXPORT Bool + miPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats); + +extern _X_EXPORT Bool + miRealizeGlyph(ScreenPtr pScreen, GlyphPtr glyph); + +extern _X_EXPORT void + miUnrealizeGlyph(ScreenPtr pScreen, GlyphPtr glyph); + +extern _X_EXPORT void + +miGlyphs(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs); + +extern _X_EXPORT void + miRenderColorToPixel(PictFormatPtr pPict, xRenderColor * color, CARD32 *pixel); + +extern _X_EXPORT void + miRenderPixelToColor(PictFormatPtr pPict, CARD32 pixel, xRenderColor * color); + +extern _X_EXPORT Bool + miIsSolidAlpha(PicturePtr pSrc); + +extern _X_EXPORT void + +miCompositeRects(CARD8 op, + PicturePtr pDst, + xRenderColor * color, int nRect, xRectangle *rects); + +extern _X_EXPORT void + miTrapezoidBounds(int ntrap, xTrapezoid * traps, BoxPtr box); + +extern _X_EXPORT void + miPointFixedBounds(int npoint, xPointFixed * points, BoxPtr bounds); + +extern _X_EXPORT void + miTriangleBounds(int ntri, xTriangle * tris, BoxPtr bounds); + +extern _X_EXPORT Bool + miInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat); + +extern _X_EXPORT void + miCloseIndexed(ScreenPtr pScreen, PictFormatPtr pFormat); + +extern _X_EXPORT void + +miUpdateIndexed(ScreenPtr pScreen, + PictFormatPtr pFormat, int ndef, xColorItem * pdef); + +#endif /* _MIPICT_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/mipointer.h b/prebuilt/xlibre/usr/include/xorg/mipointer.h new file mode 100644 index 0000000..ba1710a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/mipointer.h @@ -0,0 +1,129 @@ +/* + +Copyright 1989, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. +*/ + +#ifndef MIPOINTER_H +#define MIPOINTER_H + +#include "cursor.h" +#include "input.h" +#include "privates.h" + +typedef struct _miPointerSpriteFuncRec { + Bool (*RealizeCursor) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScr */ , + CursorPtr /* pCurs */ + ); + Bool (*UnrealizeCursor) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScr */ , + CursorPtr /* pCurs */ + ); + void (*SetCursor) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScr */ , + CursorPtr /* pCurs */ , + int /* x */ , + int /* y */ + ); + void (*MoveCursor) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScr */ , + int /* x */ , + int /* y */ + ); + Bool (*DeviceCursorInitialize) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScr */ + ); + void (*DeviceCursorCleanup) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScr */ + ); +} miPointerSpriteFuncRec, *miPointerSpriteFuncPtr; + +typedef struct _miPointerScreenFuncRec { + Bool (*CursorOffScreen) (ScreenPtr * /* ppScr */ , + int * /* px */ , + int * /* py */ + ); + void (*CrossScreen) (ScreenPtr /* pScr */ , + int /* entering */ + ); + void (*WarpCursor) (DeviceIntPtr /*pDev */ , + ScreenPtr /* pScr */ , + int /* x */ , + int /* y */ + ); +} miPointerScreenFuncRec, *miPointerScreenFuncPtr; + +extern _X_EXPORT Bool miDCInitialize(ScreenPtr /*pScreen */ , + miPointerScreenFuncPtr /*screenFuncs */ + ); + +extern _X_EXPORT ScreenPtr +miPointerGetScreen(DeviceIntPtr pDev); + +/* Returns the current cursor position. */ +extern _X_EXPORT void +miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y); + +/* Moves the cursor to the specified position. May clip the coordinates: + * x and y are modified in-place. */ +extern _X_EXPORT ScreenPtr +miPointerSetPosition(DeviceIntPtr pDev, int mode, double *x, double *y, + int *nevents, InternalEvent *events); + +extern _X_EXPORT DevPrivateKeyRec miPointerScreenKeyRec; + +#define miPointerScreenKey (&miPointerScreenKeyRec) + +/** + * @brief initialize pointer cursor with custom handling + * + * For DDX'es that need their own handling of pointer cursors, + * and can't use the generic "soft cursor" that's created via + * miDCInitialize(). + * + * That can be the case on certain video HW with it's own sprite support, + * or on remote display protocols like RDP, where the client get the cursor + * pixmaps sent over the wire and is responsible for painting it on his side. + * + * Overwrites ScreenPtr vectors: + * + * ConstrainCursor, CursorLimits, DisplayCursor, RealizeCursor, + * UnrealizeCursor, SetCursorPosition, RecolorCursor, DeviceCursorCleanup + * DeviceCursorInitialize + * + * Hooks to ScreenPtr vectors: CloseScreen + * + * @param pScreen pointer to ScreenRec the pointer handling applies to + * @param spireFuncs pointer to miPointerSpriteFuncPtr call vectors + * @param screenFuncs pointer to miPointerScreenFuncPtr call vectors + * @param waitForUpdate TRUE if MI shouldn't redraw the pointer immediately, + but wait for somebody else triggering it explicitly + * @return TRUE on success, FALSE usually indicates allocation failure + */ +_X_EXPORT Bool +miPointerInitialize(ScreenPtr pScreen, + miPointerSpriteFuncPtr spriteFuncs, + miPointerScreenFuncPtr screenFuncs, + Bool waitForUpdate); + +#endif /* MIPOINTER_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/mipointrst.h b/prebuilt/xlibre/usr/include/xorg/mipointrst.h new file mode 100644 index 0000000..7419ac1 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/mipointrst.h @@ -0,0 +1,44 @@ +/* + * mipointrst.h + * + */ + +/* + +Copyright 1989, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. +*/ + +#ifndef MIPOINTRST_H +#define MIPOINTRST_H + +#include "mipointer.h" +#include "scrnintstr.h" + +typedef struct { + miPointerSpriteFuncPtr spriteFuncs; /* sprite-specific methods */ + miPointerScreenFuncPtr screenFuncs; /* screen-specific methods */ + CloseScreenProcPtr CloseScreen; + Bool waitForUpdate; /* don't move cursor from input thread */ + Bool showTransparent; /* show empty cursors */ +} miPointerScreenRec, *miPointerScreenPtr; +#endif /* MIPOINTRST_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/misc.h b/prebuilt/xlibre/usr/include/xorg/misc.h new file mode 100644 index 0000000..d3b7088 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/misc.h @@ -0,0 +1,306 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +Copyright 1992, 1993 Data General Corporation; +Copyright 1992, 1993 OMRON Corporation + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that the +above copyright notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting documentation, and that +neither the name OMRON or DATA GENERAL be used in advertising or publicity +pertaining to distribution of the software without specific, written prior +permission of the party whose name is to be used. Neither OMRON or +DATA GENERAL make any representation about the suitability of this software +for any purpose. It is provided "as is" without express or implied warranty. + +OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. + +******************************************************************/ +#ifndef MISC_H +#define MISC_H 1 +/* + * X internal definitions + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifndef MAXSCREENS +#define MAXSCREENS 16 +#endif +#ifndef MAXGPUSCREENS +#define MAXGPUSCREENS 16 +#endif +#define MAXFORMATS 8 +#ifndef MAXDEVICES +#define MAXDEVICES 256 /* input devices */ +#endif +#define GPU_SCREEN_OFFSET 256 + +/* 128 event opcodes for core + extension events, excluding GE */ +#define MAXEVENTS 128 +#define EXTENSION_EVENT_BASE 64 +#define EXTENSION_BASE 128 + +typedef uint32_t ATOM; + +/* @brief generic X return code + * + * this type is should be used instead of plain int for all functions + * returning and X error code (that's possibly sent to the client), + * in order to make return value semantics clear to the humen reader. + * + * part of public SDK / driver API. + */ +typedef int XRetCode; + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */ +#include /* for bcopy, bzero, and bcmp */ + +#define NullBox ((BoxPtr)0) + +#undef min +#undef max +/* @deprecated */ +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) +/* abs() is a function, not a macro; include the file declaring + * it in case we haven't done that yet. + */ +/* this assumes b > 0 */ +#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b) + +/* XXX Not for modules */ +#include +#if !defined(MAXSHORT) || !defined(MINSHORT) || \ + !defined(MAXINT) || !defined(MININT) +/* + * Some implementations #define these through , so preclude + * #include'ing it later. + */ + +#include +#undef MAXSHORT +#define MAXSHORT SHRT_MAX +#undef MINSHORT +#define MINSHORT SHRT_MIN +#undef MAXINT +#define MAXINT INT_MAX +#undef MININT +#define MININT INT_MIN + +#include +#include +#include /* for fopen, etc... */ + +#endif + +/** + * Calculate the number of bytes needed to hold bits. + * @param bits The minimum number of bits needed. + * @return The number of bytes needed to hold bits. + */ +static inline int +bits_to_bytes(const int bits) +{ + return ((bits + 7) >> 3); +} + +/** + * Calculate the number of 4-byte units needed to hold the given number of + * bytes. + * @param bytes The minimum number of bytes needed. + * @return The number of 4-byte units needed to hold bytes. + */ +static inline CARD32 +bytes_to_int32(const size_t bytes) +{ + return (CARD32)(((bytes) + 3) >> 2); +} + +/** + * Calculate the number of bytes (in multiples of 4) needed to hold bytes. + * @param bytes The minimum number of bytes needed. + * @return The closest multiple of 4 that is equal or higher than bytes. + */ +static inline int +pad_to_int32(const int bytes) +{ + return (((bytes) + 3) & ~3); +} + +/** + * Calculate padding needed to bring the number of bytes to an even + * multiple of 4. + * @param bytes The minimum number of bytes needed. + * @return The bytes of padding needed to arrive at the closest multiple of 4 + * that is equal or higher than bytes. + */ +static inline int +padding_for_int32(const int bytes) +{ + return ((-bytes) & 3); +} + +/* some macros to help swap requests, replies, and events */ + +#define LengthRestS(stuff) \ + ((client->req_len << 1) - (sizeof(*(stuff)) >> 1)) + +#define SwapRestS(stuff) \ + SwapShorts((short *)((stuff) + 1), LengthRestS((stuff))) + +#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) +void __attribute__ ((error("wrong sized variable passed to swap"))) +wrong_size(void); +#else +static inline void +wrong_size(void) +{ +} +#endif + +#if !(defined(__GNUC__)) +static inline int +__builtin_constant_p(int x) +{ + return 0; +} +#endif + +static inline uint64_t +bswap_64(uint64_t x) +{ + return (((x & 0xFF00000000000000ull) >> 56) | + ((x & 0x00FF000000000000ull) >> 40) | + ((x & 0x0000FF0000000000ull) >> 24) | + ((x & 0x000000FF00000000ull) >> 8) | + ((x & 0x00000000FF000000ull) << 8) | + ((x & 0x0000000000FF0000ull) << 24) | + ((x & 0x000000000000FF00ull) << 40) | + ((x & 0x00000000000000FFull) << 56)); +} + +#define swapll(x) do { \ + if (sizeof(*(x)) != 8) \ + wrong_size(); \ + *(x) = bswap_64(*(x)); \ + } while (0) + +static inline uint32_t +bswap_32(uint32_t x) +{ + return (((x & 0xFF000000) >> 24) | + ((x & 0x00FF0000) >> 8) | + ((x & 0x0000FF00) << 8) | + ((x & 0x000000FF) << 24)); +} + +#define swapl(x) do { \ + if (sizeof(*(x)) != 4) \ + wrong_size(); \ + *(x) = bswap_32(*(x)); \ + } while (0) + +static inline uint16_t +bswap_16(uint16_t x) +{ + return (((x & 0xFF00) >> 8) | + ((x & 0x00FF) << 8)); +} + +#define swaps(x) do { \ + if (sizeof(*(x)) != 2) \ + wrong_size(); \ + *(x) = bswap_16(*(x)); \ + } while (0) + +/* copy 32-bit value from src to dst byteswapping on the way */ +#define cpswapl(src, dst) do { \ + if (sizeof((src)) != 4 || sizeof((dst)) != 4) \ + wrong_size(); \ + (dst) = bswap_32((src)); \ + } while (0) + +/* copy short from src to dst byteswapping on the way */ +#define cpswaps(src, dst) do { \ + if (sizeof((src)) != 2 || sizeof((dst)) != 2) \ + wrong_size(); \ + (dst) = bswap_16((src)); \ + } while (0) + +extern _X_EXPORT void SwapShorts(short *list, unsigned long count); + +typedef struct _xPoint *DDXPointPtr; +typedef struct pixman_box16 *BoxPtr; +typedef struct _xEvent *xEventPtr; +typedef struct _xRectangle *xRectanglePtr; +typedef struct _GrabRec *GrabPtr; + +typedef unsigned long x_server_generation_t; + +extern _X_EXPORT unsigned long globalSerialNumber; +extern _X_EXPORT x_server_generation_t serverGeneration; + +#endif /* MISC_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/miscstruct.h b/prebuilt/xlibre/usr/include/xorg/miscstruct.h new file mode 100644 index 0000000..589a6cb --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/miscstruct.h @@ -0,0 +1,65 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef MISCSTRUCT_H +#define MISCSTRUCT_H 1 + +#include "misc.h" +#include +#include + +typedef xPoint DDXPointRec; + +typedef struct pixman_box16 BoxRec; + +typedef union _DevUnion { + void *ptr; + long val; + unsigned long uval; + void *(*fptr) (void); +} DevUnion; + +#endif /* MISCSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/mistruct.h b/prebuilt/xlibre/usr/include/xorg/mistruct.h new file mode 100644 index 0000000..e7ba8eb --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/mistruct.h @@ -0,0 +1,62 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef MISTRUCT_H +#define MISTRUCT_H + +#include "mi.h" +#include "regionstr.h" + +/* information about dashes */ +typedef struct _miDash { + xPoint pt; + int e1, e2; /* keep these, so we don't have to do it again */ + int e; /* bresenham error term for this point on line */ + int which; + int newLine; /* 0 if part of same original line as previous dash */ +} miDashRec; + +#endif /* MISTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/misync.h b/prebuilt/xlibre/usr/include/xorg/misync.h new file mode 100644 index 0000000..c8f4a3a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/misync.h @@ -0,0 +1,77 @@ +/* + * Copyright © 2010 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef _MISYNC_H_ +#define _MISYNC_H_ + +#include "screenint.h" + +typedef struct _SyncObject SyncObject; +typedef struct _SyncFence SyncFence; +typedef struct _SyncTrigger SyncTrigger; + +typedef void (*SyncScreenCreateFenceFunc) (ScreenPtr pScreen, + SyncFence * pFence, + Bool initially_triggered); +typedef void (*SyncScreenDestroyFenceFunc) (ScreenPtr pScreen, + SyncFence * pFence); + +typedef struct _syncScreenFuncs { + SyncScreenCreateFenceFunc CreateFence; + SyncScreenDestroyFenceFunc DestroyFence; +} SyncScreenFuncsRec, *SyncScreenFuncsPtr; + +extern _X_EXPORT void +miSyncScreenCreateFence(ScreenPtr pScreen, SyncFence * pFence, + Bool initially_triggered); +extern _X_EXPORT void + miSyncScreenDestroyFence(ScreenPtr pScreen, SyncFence * pFence); + +typedef void (*SyncFenceSetTriggeredFunc) (SyncFence * pFence); +typedef void (*SyncFenceResetFunc) (SyncFence * pFence); +typedef Bool (*SyncFenceCheckTriggeredFunc) (SyncFence * pFence); +typedef void (*SyncFenceAddTriggerFunc) (SyncTrigger * pTrigger); +typedef void (*SyncFenceDeleteTriggerFunc) (SyncTrigger * pTrigger); + +typedef struct _syncFenceFuncs { + SyncFenceSetTriggeredFunc SetTriggered; + SyncFenceResetFunc Reset; + SyncFenceCheckTriggeredFunc CheckTriggered; + SyncFenceAddTriggerFunc AddTrigger; + SyncFenceDeleteTriggerFunc DeleteTrigger; +} SyncFenceFuncsRec, *SyncFenceFuncsPtr; + +extern _X_EXPORT void +miSyncInitFence(ScreenPtr pScreen, SyncFence * pFence, + Bool initially_triggered); + +extern _X_EXPORT void + miSyncDestroyFence(SyncFence * pFence); + +extern _X_EXPORT void + miSyncTriggerFence(SyncFence * pFence); + +extern _X_EXPORT SyncScreenFuncsPtr miSyncGetScreenFuncs(ScreenPtr pScreen); +extern _X_EXPORT Bool + miSyncSetup(ScreenPtr pScreen); + +#endif /* _MISYNC_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/misyncfd.h b/prebuilt/xlibre/usr/include/xorg/misyncfd.h new file mode 100644 index 0000000..d083067 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/misyncfd.h @@ -0,0 +1,48 @@ +/* + * Copyright © 2013 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _MISYNCFD_H_ +#define _MISYNCFD_H_ + +#include +#include + +typedef int (*SyncScreenCreateFenceFromFdFunc) (ScreenPtr screen, + SyncFence *fence, + int fd, + Bool initially_triggered); + +typedef int (*SyncScreenGetFenceFdFunc) (ScreenPtr screen, + SyncFence *fence); + +#define SYNC_FD_SCREEN_FUNCS_VERSION 1 + +typedef struct _syncFdScreenFuncs { + int version; + SyncScreenCreateFenceFromFdFunc CreateFenceFromFd; + SyncScreenGetFenceFdFunc GetFenceFd; +} SyncFdScreenFuncsRec, *SyncFdScreenFuncsPtr; + +extern _X_EXPORT Bool miSyncFdScreenInit(ScreenPtr pScreen, + const SyncFdScreenFuncsRec *funcs); + +#endif /* _MISYNCFD_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/misyncshm.h b/prebuilt/xlibre/usr/include/xorg/misyncshm.h new file mode 100644 index 0000000..29c6fa8 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/misyncshm.h @@ -0,0 +1,31 @@ +/* + * Copyright © 2013 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _MISYNCSHM_H_ +#define _MISYNCSHM_H_ + +#include +#include + +extern _X_EXPORT Bool miSyncShmScreenInit(ScreenPtr pScreen); + +#endif /* _MISYNCSHM_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/misyncstr.h b/prebuilt/xlibre/usr/include/xorg/misyncstr.h new file mode 100644 index 0000000..60055fc --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/misyncstr.h @@ -0,0 +1,78 @@ +/* + * Copyright © 2010 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef _MISYNCSTR_H_ +#define _MISYNCSTR_H_ + +#include + +#include "xlibre_ptrtypes.h" +#include "dix.h" +#include "misync.h" +#include "scrnintstr.h" +#include + +/* Sync object types */ +#define SYNC_COUNTER 0 +#define SYNC_FENCE 1 + +struct _SyncObject { + ClientPtr client; /* Owning client. 0 for system counters */ + struct _SyncTriggerList *pTriglist; /* list of triggers */ + XID id; /* resource ID */ + unsigned char type; /* SYNC_* */ + unsigned char initialized; /* FALSE if created but not initialized */ + Bool beingDestroyed; /* in process of going away */ +}; + +typedef struct _SyncCounter { + SyncObject sync; /* Common sync object data */ + int64_t value; /* counter value */ + struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */ +} SyncCounter; + +struct _SyncFence { + SyncObject sync; /* Common sync object data */ + ScreenPtr pScreen; /* Screen of this fence object */ + SyncFenceFuncsRec funcs; /* Funcs for performing ops on fence */ + Bool triggered; /* fence state */ + PrivateRec *devPrivates; /* driver-specific per-fence data */ +}; + +struct _SyncTrigger { + SyncObject *pSync; + int64_t wait_value; /* wait value */ + unsigned int value_type; /* Absolute or Relative */ + unsigned int test_type; /* transition or Comparison type */ + int64_t test_value; /* trigger event threshold value */ + Bool (*CheckTrigger)(struct _SyncTrigger *pTrigger, + int64_t newval); + void (*TriggerFired)(struct _SyncTrigger *pTrigger); + void (*CounterDestroyed)(struct _SyncTrigger *pTrigger); +}; + +typedef struct _SyncTriggerList { + SyncTrigger *pTrigger; + struct _SyncTriggerList *next; +} SyncTriggerList; + +#endif /* _MISYNCSTR_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/mizerarc.h b/prebuilt/xlibre/usr/include/xorg/mizerarc.h new file mode 100644 index 0000000..31f5596 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/mizerarc.h @@ -0,0 +1,132 @@ +/************************************************************ + +Copyright 1989, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +********************************************************/ + +#ifndef XSERVER_MIZERARC_H +#define XSERVER_MIZERARC_H + +#include +#include + +typedef struct { + int x; + int y; + int mask; +} miZeroArcPtRec; + +typedef struct { + int x, y, k1, k3, a, b, d, dx, dy; + int alpha, beta; + int xorg, yorg; + int xorgo, yorgo; + int w, h; + int initialMask; + miZeroArcPtRec start, altstart, end, altend; + int firstx, firsty; + int startAngle, endAngle; +} miZeroArcRec; + +#define miCanZeroArc(arc) (((arc)->width == (arc)->height) || \ + (((arc)->width <= 800) && ((arc)->height <= 800))) + +#define MIARCSETUP() \ + x = info.x; \ + y = info.y; \ + k1 = info.k1; \ + k3 = info.k3; \ + a = info.a; \ + b = info.b; \ + d = info.d; \ + dx = info.dx; \ + dy = info.dy + +#define MIARCOCTANTSHIFT(clause) \ + if (a < 0) \ + { \ + if (y == info.h) \ + { \ + d = -1; \ + a = b = k1 = 0; \ + } \ + else \ + { \ + dx = (k1 << 1) - k3; \ + k1 = dx - k1; \ + k3 = -k3; \ + b = b + a - (k1 >> 1); \ + d = b + ((-a) >> 1) - d + (k3 >> 3); \ + if (dx < 0) \ + a = -((-dx) >> 1) - a; \ + else \ + a = (dx >> 1) - a; \ + dx = 0; \ + dy = 1; \ + clause \ + } \ + } + +#define MIARCSTEP(move1,move2) \ + b -= k1; \ + if (d < 0) \ + { \ + x += dx; \ + y += dy; \ + a += k1; \ + d += b; \ + move1 \ + } \ + else \ + { \ + x++; \ + y++; \ + a += k3; \ + d -= a; \ + move2 \ + } + +#define MIARCCIRCLESTEP(clause) \ + b -= k1; \ + x++; \ + if (d < 0) \ + { \ + a += k1; \ + d += b; \ + } \ + else \ + { \ + y++; \ + a += k3; \ + d -= a; \ + clause \ + } + +/* mizerarc.c */ + +extern _X_EXPORT Bool miZeroArcSetup(xArc * /*arc */ , + miZeroArcRec * /*info */ , + Bool /*ok360 */ + ); + +#endif /* XSERVER_MIZERARC_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/opaque.h b/prebuilt/xlibre/usr/include/xorg/opaque.h new file mode 100644 index 0000000..b924cfa --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/opaque.h @@ -0,0 +1,38 @@ +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +*/ + +#ifndef OPAQUE_H +#define OPAQUE_H + +#include + +#include "globals.h" + +extern _X_EXPORT Bool bgNoneRoot; + +#endif /* OPAQUE_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/optionstr.h b/prebuilt/xlibre/usr/include/xorg/optionstr.h new file mode 100644 index 0000000..2189790 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/optionstr.h @@ -0,0 +1,12 @@ +#ifndef OPTIONSTR_H_ +#define OPTIONSTR_H_ + +struct _InputOption { + GenericListRec list; + char *opt_name; + char *opt_val; + int opt_used; + char *opt_comment; +}; + +#endif /* INPUTSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/os.h b/prebuilt/xlibre/usr/include/xorg/os.h new file mode 100644 index 0000000..aa5b3cf --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/os.h @@ -0,0 +1,313 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef OS_H +#define OS_H + +#include +#include +#include +#include +#ifdef MONOTONIC_CLOCK +#include +#endif + +#include + +#include "xlibre_ptrtypes.h" +#include "callback.h" +#include "misc.h" + +/* + * @brief macro for specifying non-null arguments + * + * part of public SDK / driver API + */ +#ifndef _X_ATTRIBUTE_NONNULL_ARG +#define _X_ATTRIBUTE_NONNULL_ARG(...) __attribute__((nonnull(__VA_ARGS__))) +#endif + +#ifndef _X_ATTRIBUTE_VPRINTF +# if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(__clang__) +# define _X_ATTRIBUTE_VPRINTF(fmt, firstarg) \ + __attribute__((__format__(gnu_printf, fmt, firstarg))) +# else +# define _X_ATTRIBUTE_VPRINTF(fmt, firstarg) _X_ATTRIBUTE_PRINTF(fmt,firstarg) +# endif +#endif + +#define SCREEN_SAVER_ON 0 +#define SCREEN_SAVER_OFF 1 +#define SCREEN_SAVER_FORCER 2 +#define SCREEN_SAVER_CYCLE 3 + +#ifndef MAX_REQUEST_SIZE +#define MAX_REQUEST_SIZE 65535 +#endif + +typedef struct _NewClientRec *NewClientPtr; + +#ifndef xnfalloc +#define xnfalloc(size) XNFalloc((unsigned long)(size)) +#define xnfcalloc(_num, _size) XNFcallocarray((_num), (_size)) +#define xnfrealloc(ptr, size) XNFrealloc((void *)(ptr), (unsigned long)(size)) + +#define xstrdup(s) Xstrdup((s)) +#define xnfstrdup(s) XNFstrdup((s)) +#endif + +#include +#include + +extern _X_EXPORT int ReadFdFromClient(ClientPtr client); + +/** + * @brief write @p count bytes from @p buf into the client's output buffer + * + * @deprecated Legacy entry point, kept for ABI compatibility. Drivers and + * external modules should not write to clients directly; this + * remains exported only for existing out-of-tree users. In-tree + * code uses the internal dixWriteToClient() worker instead. + * + * @param who the client to write to + * @param count number of bytes to write + * @param buf data to write + * @return number of bytes buffered, 0 on no-op, -1 on error + */ +extern _X_EXPORT int WriteToClient(ClientPtr /*who */ , int /*count */ , + const void * /*buf */ ); + +typedef void (*NotifyFdProcPtr)(int fd, int ready, void *data); + +#include "fd_notify.h" + +extern _X_EXPORT Bool SetNotifyFd(int fd, NotifyFdProcPtr notify_fd, int mask, void *data); + +static inline void RemoveNotifyFd(int fd) +{ + (void) SetNotifyFd(fd, NULL, X_NOTIFY_NONE, NULL); +} + +extern _X_EXPORT void IgnoreClient(ClientPtr /*client */ ); + +extern _X_EXPORT void AttendClient(ClientPtr /*client */ ); + +extern _X_EXPORT CARD32 GetTimeInMillis(void); +extern _X_EXPORT CARD64 GetTimeInMicros(void); + +extern _X_EXPORT void AdjustWaitForDelay(void *waitTime, int newdelay); + +typedef struct _OsTimerRec *OsTimerPtr; + +typedef CARD32 (*OsTimerCallback) (OsTimerPtr timer, + CARD32 time, + void *arg); + +#define TimerAbsolute (1<<0) +#define TimerForceOld (1<<1) + +extern _X_EXPORT OsTimerPtr TimerSet(OsTimerPtr timer, + int flags, + CARD32 millis, + OsTimerCallback func, + void *arg); + +extern _X_EXPORT void TimerCancel(OsTimerPtr /* pTimer */ ); +extern _X_EXPORT void TimerFree(OsTimerPtr /* pTimer */ ); + +extern _X_EXPORT void GiveUp(int /*sig */ ); + +/* + * This function malloc(3)s buffer, terminating the server if there is not + * enough memory. + */ +extern _X_EXPORT void * +XNFalloc(unsigned long /*amount */ ) __attribute__((returns_nonnull)); + +/* + * This function calloc(3)s buffer, terminating the server if there is not + * enough memory. + */ +extern _X_EXPORT void * +XNFcalloc(unsigned long /*amount */ ) _X_DEPRECATED; + +/* + * This function calloc(3)s buffer, terminating the server if there is not + * enough memory or the arguments overflow when multiplied + */ +extern _X_EXPORT void * +XNFcallocarray(size_t nmemb, size_t size) __attribute__((returns_nonnull)); + +/* + * This function realloc(3)s passed buffer, terminating the server if there is + * not enough memory. + */ +extern _X_EXPORT void * +XNFrealloc(void * /*ptr */ , unsigned long /*amount */ ); + +/* + * This function strdup(3)s passed string. The only difference from the library + * function that it is safe to pass NULL, as NULL will be returned. + */ +extern _X_EXPORT char * +Xstrdup(const char *s); + +/* + * This function strdup(3)s passed string, terminating the server if there is + * not enough memory. If NULL is passed to this function, NULL is returned. + */ +extern _X_EXPORT char * +XNFstrdup(const char *s); + +/* Include new X*asprintf API */ +#include "Xprintf.h" + +typedef int (*OsSigWrapperPtr) (int /* sig */ ); + +extern _X_EXPORT OsSigWrapperPtr +OsRegisterSigWrapper(OsSigWrapperPtr newWrap); + +extern _X_EXPORT Bool +PrivsElevated(void); + +extern _X_EXPORT int +GetClientFd(ClientPtr); + +/* stuff for FlushCallback */ +extern _X_EXPORT CallbackListPtr FlushCallback; + +extern _X_EXPORT int +TimeSinceLastInputEvent(void); + +/* Function fallbacks provided by AC_REPLACE_FUNCS in configure.ac */ + +#ifndef HAVE_REALLOCARRAY +#define reallocarray xreallocarray +extern _X_EXPORT void * +reallocarray(void *optr, size_t nmemb, size_t size); +#endif + +#ifndef HAVE_STRLCPY +extern _X_EXPORT size_t +strlcpy(char * _X_RESTRICT_KYWD dst, const char * _X_RESTRICT_KYWD src, size_t siz); +extern _X_EXPORT size_t +strlcat(char * _X_RESTRICT_KYWD dst, const char * _X_RESTRICT_KYWD src, size_t siz); +#endif + +#ifndef HAVE_STRNDUP +extern _X_EXPORT char * +strndup(const char *str, size_t n); +#endif + +#ifndef HAVE_TIMINGSAFE_MEMCMP +extern _X_EXPORT int +timingsafe_memcmp(const void *b1, const void *b2, size_t len); +#endif + +/* Flags for log messages. */ +typedef enum { + X_PROBED, /* Value was probed */ + X_CONFIG, /* Value was given in the config file */ + X_DEFAULT, /* Value is a default */ + X_CMDLINE, /* Value was given on the command line */ + X_NOTICE, /* Notice */ + X_ERROR, /* Error message */ + X_WARNING, /* Warning message */ + X_INFO, /* Informational message */ + X_NONE, /* No prefix */ + X_NOT_IMPLEMENTED, /* Not implemented */ + X_DEBUG, /* Debug message */ + X_UNKNOWN = -1 /* unknown -- this must always be last */ +} MessageType; + +extern _X_EXPORT void +LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) +_X_ATTRIBUTE_PRINTF(3, 0); +extern _X_EXPORT void +LogMessageVerb(MessageType type, int verb, const char *format, ...) +_X_ATTRIBUTE_PRINTF(3, 4); +extern _X_EXPORT void +LogMessage(MessageType type, const char *format, ...) +_X_ATTRIBUTE_PRINTF(2, 3); + +extern _X_EXPORT void +LogHdrMessageVerb(MessageType type, int verb, + const char *msg_format, va_list msg_args, + const char *hdr_format, ...) +_X_ATTRIBUTE_PRINTF(3, 0) +_X_ATTRIBUTE_PRINTF(5, 6); + +extern _X_EXPORT void +FatalError(const char *f, ...) +_X_ATTRIBUTE_PRINTF(1, 2) + _X_NORETURN; + +extern _X_EXPORT void +ErrorF(const char *f, ...) +_X_ATTRIBUTE_PRINTF(1, 2); + +extern _X_EXPORT void +xorg_backtrace(void); + +/* should not be used anymore, just for backwards compat with drivers */ +#define LogVMessageVerbSigSafe(...) LogVMessageVerb(__VA_ARGS__) +#define LogMessageVerbSigSafe(...) LogMessageVerb(__VA_ARGS__) +#define ErrorFSigSafe(...) ErrorF(__VA_ARGS__) +#define VErrorFSigSafe(...) VErrorF(__VA_ARGS__) +#define VErrorF(...) LogVMessageVerb(X_NONE, -1, __VA_ARGS__) + +/* only for backwards compat with drivers that haven't kept up yet + (xf86-video-intel) + + @todo revise after next stable release +*/ +_X_DEPRECATED +static inline int System(const char* cmdline) +{ + return system(cmdline); +} + +#endif /* OS_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/picture.h b/prebuilt/xlibre/usr/include/xorg/picture.h new file mode 100644 index 0000000..d219ed0 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/picture.h @@ -0,0 +1,215 @@ +/* + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _PICTURE_H_ +#define _PICTURE_H_ + +#include "privates.h" + +#include + +typedef struct _DirectFormat *DirectFormatPtr; +typedef struct _PictFormat *PictFormatPtr; +typedef struct _Picture *PicturePtr; + +/* + * While the protocol is generous in format support, the + * sample implementation allows only packed RGB and GBR + * representations for data to simplify software rendering, + */ +#define PICT_FORMAT(bpp,type,a,r,g,b) PIXMAN_FORMAT((bpp), (type), (a), (r), (g), (b)) + +/* + * gray/color formats use a visual index instead of argb + */ +#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \ + ((type) << 16) | \ + ((vi))) + +#define PICT_FORMAT_BPP(f) PIXMAN_FORMAT_BPP((f)) +#define PICT_FORMAT_TYPE(f) PIXMAN_FORMAT_TYPE((f)) +#define PICT_FORMAT_A(f) PIXMAN_FORMAT_A((f)) +#define PICT_FORMAT_R(f) PIXMAN_FORMAT_R((f)) +#define PICT_FORMAT_G(f) PIXMAN_FORMAT_G((f)) +#define PICT_FORMAT_B(f) PIXMAN_FORMAT_B((f)) +#define PICT_FORMAT_RGB(f) PIXMAN_FORMAT_RGB((f)) +#define PICT_FORMAT_VIS(f) PIXMAN_FORMAT_VIS((f)) + +#define PICT_TYPE_OTHER PIXMAN_TYPE_OTHER +#define PICT_TYPE_A PIXMAN_TYPE_A +#define PICT_TYPE_ARGB PIXMAN_TYPE_ARGB +#define PICT_TYPE_ABGR PIXMAN_TYPE_ABGR +#define PICT_TYPE_COLOR PIXMAN_TYPE_COLOR +#define PICT_TYPE_GRAY PIXMAN_TYPE_GRAY +#define PICT_TYPE_BGRA PIXMAN_TYPE_BGRA + +#define PICT_FORMAT_COLOR(f) PIXMAN_FORMAT_COLOR((f)) + +typedef pixman_format_code_t PictFormatShort; + +#define PICT_a2r10g10b10 PIXMAN_a2r10g10b10 +#define PICT_x2r10g10b10 PIXMAN_x2r10g10b10 +#define PICT_a2b10g10r10 PIXMAN_a2b10g10r10 +#define PICT_x2b10g10r10 PIXMAN_x2b10g10r10 +#define PICT_a8r8g8b8 PIXMAN_a8r8g8b8 +#define PICT_x8r8g8b8 PIXMAN_x8r8g8b8 +#define PICT_a8b8g8r8 PIXMAN_a8b8g8r8 +#define PICT_x8b8g8r8 PIXMAN_x8b8g8r8 +#define PICT_b8g8r8a8 PIXMAN_b8g8r8a8 +#define PICT_b8g8r8x8 PIXMAN_b8g8r8x8 +#define PICT_r8g8b8 PIXMAN_r8g8b8 +#define PICT_b8g8r8 PIXMAN_b8g8r8 +#define PICT_r5g6b5 PIXMAN_r5g6b5 +#define PICT_b5g6r5 PIXMAN_b5g6r5 +#define PICT_a1r5g5b5 PIXMAN_a1r5g5b5 +#define PICT_x1r5g5b5 PIXMAN_x1r5g5b5 +#define PICT_a1b5g5r5 PIXMAN_a1b5g5r5 +#define PICT_x1b5g5r5 PIXMAN_x1b5g5r5 +#define PICT_a4r4g4b4 PIXMAN_a4r4g4b4 +#define PICT_x4r4g4b4 PIXMAN_x4r4g4b4 +#define PICT_a4b4g4r4 PIXMAN_a4b4g4r4 +#define PICT_x4b4g4r4 PIXMAN_x4b4g4r4 +#define PICT_a8 PIXMAN_a8 +#define PICT_r3g3b2 PIXMAN_r3g3b2 +#define PICT_b2g3r3 PIXMAN_b2g3r3 +#define PICT_a2r2g2b2 PIXMAN_a2r2g2b2 +#define PICT_a2b2g2r2 PIXMAN_a2b2g2r2 +#define PICT_c8 PIXMAN_c8 +#define PICT_g8 PIXMAN_g8 +#define PICT_x4a4 PIXMAN_x4a4 +#define PICT_x4c4 PIXMAN_x4c4 +#define PICT_x4g4 PIXMAN_x4g4 +#define PICT_a4 PIXMAN_a4 +#define PICT_r1g2b1 PIXMAN_r1g2b1 +#define PICT_b1g2r1 PIXMAN_b1g2r1 +#define PICT_a1r1g1b1 PIXMAN_a1r1g1b1 +#define PICT_a1b1g1r1 PIXMAN_a1b1g1r1 +#define PICT_c4 PIXMAN_c4 +#define PICT_g4 PIXMAN_g4 +#define PICT_a1 PIXMAN_a1 +#define PICT_g1 PIXMAN_g1 +#define PICT_yuv2 PIXMAN_yuy2 + +/* + * For dynamic indexed visuals (GrayScale and PseudoColor), these control the + * selection of colors allocated for drawing to Pictures. The default + * policy depends on the size of the colormap: + * + * Size Default Policy + * ---------------------------- + * < 64 PolicyMono + * < 256 PolicyGray + * 256 PolicyColor (only on PseudoColor) + * + * The actual allocation code lives in miindex.c, and so is + * ostensibly server dependent, but that code does: + * + * PolicyMono Allocate no additional colors, use black and white + * PolicyGray Allocate 13 gray levels (11 cells used) + * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used) + * PolicyAll Allocate as big a cube as possible, fill with gray (all) + * + * Here's a picture to help understand how many colors are + * actually allocated (this is just the gray ramp): + * + * gray level + * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff + * b/w 0000 ffff + * 4x4x4 5555 aaaa + * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa + * + * The default colormap supplies two gray levels (black/white), the + * 4x4x4 cube allocates another two and nine more are allocated to fill + * in the 13 levels. When the 4x4x4 cube is not allocated, a total of + * 11 cells are allocated. + */ + +#define PictureCmapPolicyInvalid -1 +#define PictureCmapPolicyDefault 0 +#define PictureCmapPolicyMono 1 +#define PictureCmapPolicyGray 2 +#define PictureCmapPolicyColor 3 +#define PictureCmapPolicyAll 4 + +extern int PictureCmapPolicy; + +extern int PictureParseCmapPolicy(const char *name); + +extern int RenderErrBase; + +/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */ + +typedef pixman_fixed_32_32_t xFixed_32_32; + +typedef pixman_fixed_48_16_t xFixed_48_16; + +#define MAX_FIXED_48_16 pixman_max_fixed_48_16 +#define MIN_FIXED_48_16 pixman_min_fixed_48_16 + +typedef pixman_fixed_1_31_t xFixed_1_31; +typedef pixman_fixed_1_16_t xFixed_1_16; +typedef pixman_fixed_16_16_t xFixed_16_16; + +/* + * An unadorned "xFixed" is the same as xFixed_16_16, + * (since it's quite common in the code) + */ +typedef pixman_fixed_t xFixed; + +#define XFIXED_BITS 16 + +#define xFixedToInt(f) pixman_fixed_to_int((f)) +#define IntToxFixed(i) pixman_int_to_fixed((i)) +#define xFixedE pixman_fixed_e +#define xFixed1 pixman_fixed_1 +#define xFixed1MinusE pixman_fixed_1_minus_e +#define xFixedFrac(f) pixman_fixed_frac((f)) +#define xFixedFloor(f) pixman_fixed_floor((f)) +#define xFixedCeil(f) pixman_fixed_ceil((f)) + +#define xFixedFraction(f) pixman_fixed_fraction((f)) +#define xFixedMod2(f) pixman_fixed_mod2((f)) + +/* whether 't' is a well defined not obviously empty trapezoid */ +#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \ + (t)->right.p1.y != (t)->right.p2.y && \ + ((t)->bottom > (t)->top)) + +/* + * Standard NTSC luminance conversions: + * + * y = r * 0.299 + g * 0.587 + b * 0.114 + * + * Approximate this for a bit more speed: + * + * y = (r * 153 + g * 301 + b * 58) / 512 + * + * This gives 17 bits of luminance; to get 15 bits, lop the low two + */ + +#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \ + (((s) >> 8) & 0xff) * 301 + \ + (((s) ) & 0xff) * 58) >> 2) + +#endif /* _PICTURE_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/picturestr.h b/prebuilt/xlibre/usr/include/xorg/picturestr.h new file mode 100644 index 0000000..349f6f7 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/picturestr.h @@ -0,0 +1,534 @@ +/* + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _PICTURESTR_H_ +#define _PICTURESTR_H_ + +#include +#include "scrnintstr.h" +#include "glyphstr.h" +#include "resource.h" +#include "privates.h" + +typedef struct _DirectFormat { + CARD16 red, redMask; + CARD16 green, greenMask; + CARD16 blue, blueMask; + CARD16 alpha, alphaMask; +} DirectFormatRec; + +typedef struct _IndexFormat { + VisualID vid; + ColormapPtr pColormap; + int nvalues; + xIndexValue *pValues; + void *devPrivate; +} IndexFormatRec; + +typedef struct _PictFormat { + CARD32 id; + CARD32 format; /* except bpp */ + unsigned char type; + unsigned char depth; + DirectFormatRec direct; + IndexFormatRec index; +} PictFormatRec; + +typedef struct pixman_vector PictVector, *PictVectorPtr; +typedef struct pixman_transform PictTransform, *PictTransformPtr; + +#define SourcePictTypeSolidFill 0 +#define SourcePictTypeLinear 1 +#define SourcePictTypeRadial 2 +#define SourcePictTypeConical 3 + +typedef struct _PictSolidFill { + unsigned int type; + CARD32 color; + xRenderColor fullcolor; +} PictSolidFill, *PictSolidFillPtr; + +typedef struct _PictGradientStop { + xFixed x; + xRenderColor color; +} PictGradientStop, *PictGradientStopPtr; + +typedef struct _PictGradient { + unsigned int type; + int nstops; + PictGradientStopPtr stops; +} PictGradient, *PictGradientPtr; + +typedef struct _PictLinearGradient { + unsigned int type; + int nstops; + PictGradientStopPtr stops; + xPointFixed p1; + xPointFixed p2; +} PictLinearGradient, *PictLinearGradientPtr; + +typedef struct _PictCircle { + xFixed x; + xFixed y; + xFixed radius; +} PictCircle, *PictCirclePtr; + +typedef struct _PictRadialGradient { + unsigned int type; + int nstops; + PictGradientStopPtr stops; + PictCircle c1; + PictCircle c2; +} PictRadialGradient, *PictRadialGradientPtr; + +typedef struct _PictConicalGradient { + unsigned int type; + int nstops; + PictGradientStopPtr stops; + xPointFixed center; + xFixed angle; +} PictConicalGradient, *PictConicalGradientPtr; + +typedef union _SourcePict { + unsigned int type; + PictSolidFill solidFill; + PictGradient gradient; + PictLinearGradient linear; + PictRadialGradient radial; + PictConicalGradient conical; +} SourcePict, *SourcePictPtr; + +typedef struct _Picture { + DrawablePtr pDrawable; + PictFormatPtr pFormat; + pixman_format_code_t format; /* PIXMAN_FORMAT */ + int refcnt; + CARD32 id; + unsigned int repeat:1; + unsigned int graphicsExposures:1; + unsigned int subWindowMode:1; + unsigned int polyEdge:1; + unsigned int polyMode:1; + unsigned int freeCompClip:1; + unsigned int componentAlpha:1; + unsigned int repeatType:2; + unsigned int filter:3; + unsigned int stateChanges:CPLastBit; + unsigned int unused:18 - CPLastBit; + + PicturePtr pNext; /* chain on same drawable */ + + PicturePtr alphaMap; + xPoint alphaOrigin; + + xPoint clipOrigin; + RegionPtr clientClip; + + unsigned long serialNumber; + + RegionPtr pCompositeClip; + + PrivateRec *devPrivates; + + PictTransform *transform; + + SourcePictPtr pSourcePict; + xFixed *filter_params; + int filter_nparams; +} PictureRec; + +typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id, + xFixed * params, int nparams, + int *width, int *height); +typedef struct { + char *name; + int id; + PictFilterValidateParamsProcPtr ValidateParams; + int width, height; +} PictFilterRec, *PictFilterPtr; + +#define PictFilterNearest 0 +#define PictFilterBilinear 1 + +#define PictFilterFast 2 +#define PictFilterGood 3 +#define PictFilterBest 4 + +#define PictFilterConvolution 5 +/* if you add an 8th filter, expand the filter bitfield above */ + +typedef struct { + char *alias; + int alias_id; + int filter_id; +} PictFilterAliasRec, *PictFilterAliasPtr; + +typedef int (*CreatePictureProcPtr) (PicturePtr pPicture); +typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture); +typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture, + int clipType, void *value, int n); +typedef void (*DestroyPictureClipProcPtr) (PicturePtr pPicture); + +typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture, + PictTransform * transform); + +typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture, + int filter, + xFixed * params, int nparams); + +typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture); + +typedef void (*ChangePictureProcPtr) (PicturePtr pPicture, Mask mask); +typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture, Mask mask); +typedef void (*CompositeProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height); + +typedef void (*GlyphsProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlists, + GlyphListPtr lists, GlyphPtr * glyphs); + +typedef void (*CompositeRectsProcPtr) (CARD8 op, + PicturePtr pDst, + xRenderColor * color, + int nRect, xRectangle *rects); + +typedef void (*RasterizeTrapezoidProcPtr) (PicturePtr pMask, + xTrapezoid * trap, + int x_off, int y_off); + +typedef void (*TrapezoidsProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, int ntrap, xTrapezoid * traps); + +typedef void (*TrianglesProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, int ntri, xTriangle * tris); + +typedef void (*TriStripProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, int npoint, xPointFixed * points); + +typedef void (*TriFanProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, int npoint, xPointFixed * points); + +typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen, PictFormatPtr pFormat); + +typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen, PictFormatPtr pFormat); + +typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen, + PictFormatPtr pFormat, + int ndef, xColorItem * pdef); + +typedef void (*AddTrapsProcPtr) (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, int ntrap, xTrap * traps); + +typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, int ntri, xTriangle * tris); + +typedef Bool (*RealizeGlyphProcPtr) (ScreenPtr pScreen, GlyphPtr glyph); + +typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen, GlyphPtr glyph); + +typedef struct _PictureScreen { + PictFormatPtr formats; + PictFormatPtr fallback; + int nformats; + + CreatePictureProcPtr CreatePicture; + DestroyPictureProcPtr DestroyPicture; + ChangePictureClipProcPtr ChangePictureClip; + DestroyPictureClipProcPtr DestroyPictureClip; + + ChangePictureProcPtr ChangePicture; + ValidatePictureProcPtr ValidatePicture; + + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; /* unused */ + CompositeRectsProcPtr CompositeRects; + + void *_dummy1; // required in place of a removed field for ABI compatibility + void *_dummy2; // required in place of a removed field for ABI compatibility + + StoreColorsProcPtr StoreColors; + + InitIndexedProcPtr InitIndexed; + CloseIndexedProcPtr CloseIndexed; + UpdateIndexedProcPtr UpdateIndexed; + + int subpixel; + + PictFilterPtr filters; + int nfilters; + PictFilterAliasPtr filterAliases; + int nfilterAliases; + + /** + * Called immediately after a picture's transform is changed through the + * SetPictureTransform request. Not called for source-only pictures. + */ + ChangePictureTransformProcPtr ChangePictureTransform; + + /** + * Called immediately after a picture's transform is changed through the + * SetPictureFilter request. Not called for source-only pictures. + */ + ChangePictureFilterProcPtr ChangePictureFilter; + + DestroyPictureFilterProcPtr DestroyPictureFilter; + + TrapezoidsProcPtr Trapezoids; + TrianglesProcPtr Triangles; + + RasterizeTrapezoidProcPtr RasterizeTrapezoid; + + AddTrianglesProcPtr AddTriangles; + + AddTrapsProcPtr AddTraps; + + RealizeGlyphProcPtr RealizeGlyph; + UnrealizeGlyphProcPtr UnrealizeGlyph; + +#define PICTURE_SCREEN_VERSION 2 + TriStripProcPtr TriStrip; + TriFanProcPtr TriFan; +} PictureScreenRec, *PictureScreenPtr; + +extern _X_EXPORT DevPrivateKeyRec PictureScreenPrivateKeyRec; +extern _X_EXPORT DevPrivateKeyRec PictureWindowPrivateKeyRec; + +#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, &PictureScreenPrivateKeyRec)) +#define GetPictureScreenIfSet(s) (dixPrivateKeyRegistered(&PictureScreenPrivateKeyRec) ? GetPictureScreen((s)) : NULL) +#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, &PictureScreenPrivateKeyRec, (p)) +#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, &PictureWindowPrivateKeyRec)) +#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, &PictureWindowPrivateKeyRec, (p)) + +extern _X_EXPORT PictFormatPtr + PictureWindowFormat(WindowPtr pWindow); + +extern _X_EXPORT Bool + PictureSetSubpixelOrder(ScreenPtr pScreen, int subpixel); + +extern _X_EXPORT int + PictureGetSubpixelOrder(ScreenPtr pScreen); + +extern _X_EXPORT PictFormatPtr +PictureMatchVisual(ScreenPtr pScreen, int depth, VisualPtr pVisual); + +extern _X_EXPORT PictFormatPtr +PictureMatchFormat(ScreenPtr pScreen, int depth, CARD32 format); + +extern _X_EXPORT Bool + PictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats); + +extern _X_EXPORT int + PictureGetFilterId(const char *filter, int len, Bool makeit); + +extern _X_EXPORT char *PictureGetFilterName(int id); + +extern _X_EXPORT int +PictureAddFilter(ScreenPtr pScreen, + const char *filter, + PictFilterValidateParamsProcPtr ValidateParams, + int width, int height); + +extern _X_EXPORT Bool +PictureSetFilterAlias(ScreenPtr pScreen, const char *filter, const char *alias); + +extern _X_EXPORT Bool + PictureSetDefaultFilters(ScreenPtr pScreen); + +extern _X_EXPORT void + PictureResetFilters(ScreenPtr pScreen); + +extern _X_EXPORT PictFilterPtr +PictureFindFilter(ScreenPtr pScreen, char *name, int len); + +extern _X_EXPORT int +SetPicturePictFilter(PicturePtr pPicture, PictFilterPtr pFilter, + xFixed * params, int nparams); + +extern _X_EXPORT int +SetPictureFilter(PicturePtr pPicture, char *name, int len, + xFixed * params, int nparams); + +extern _X_EXPORT Bool + PictureFinishInit(void); + +extern _X_EXPORT PicturePtr +CreatePicture(Picture pid, + DrawablePtr pDrawable, + PictFormatPtr pFormat, + Mask mask, XID *list, ClientPtr client, int *error); + +extern _X_EXPORT int +ChangePicture(PicturePtr pPicture, + Mask vmask, XID *vlist, DevUnion *ulist, ClientPtr client); + +extern _X_EXPORT int + +SetPictureClipRects(PicturePtr pPicture, + int xOrigin, int yOrigin, int nRect, xRectangle *rects); + +extern _X_EXPORT int +SetPictureClipRegion(PicturePtr pPicture, + int xOrigin, int yOrigin, RegionPtr pRegion); + +extern _X_EXPORT int + SetPictureTransform(PicturePtr pPicture, PictTransform * transform); + +extern _X_EXPORT void + ValidatePicture(PicturePtr pPicture); + +extern _X_EXPORT int + FreePicture(void *pPicture, XID pid); + +extern _X_EXPORT void +CompositePicture(CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); + +extern _X_EXPORT void +CompositeGlyphs(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, int nlist, GlyphListPtr lists, GlyphPtr * glyphs); + +extern _X_EXPORT void +CompositeRects(CARD8 op, + PicturePtr pDst, + xRenderColor * color, int nRect, xRectangle *rects); + +extern _X_EXPORT void +CompositeTrapezoids(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps); + +extern _X_EXPORT void +CompositeTriangles(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, int ntriangles, xTriangle * triangles); + +extern _X_EXPORT void +CompositeTriStrip(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points); + +extern _X_EXPORT void +CompositeTriFan(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points); + +extern _X_EXPORT void +AddTraps(PicturePtr pPicture, + INT16 xOff, INT16 yOff, int ntraps, xTrap * traps); + +extern _X_EXPORT PicturePtr +CreateSolidPicture(Picture pid, xRenderColor * color, int *error); + +extern _X_EXPORT PicturePtr +CreateLinearGradientPicture(Picture pid, + xPointFixed * p1, + xPointFixed * p2, + int nStops, + xFixed * stops, xRenderColor * colors, int *error); + +extern _X_EXPORT PicturePtr +CreateRadialGradientPicture(Picture pid, + xPointFixed * inner, + xPointFixed * outer, + xFixed innerRadius, + xFixed outerRadius, + int nStops, + xFixed * stops, xRenderColor * colors, int *error); + +extern _X_EXPORT PicturePtr +CreateConicalGradientPicture(Picture pid, + xPointFixed * center, + xFixed angle, + int nStops, + xFixed * stops, xRenderColor * colors, int *error); + +/* + * matrix.c + */ + +extern _X_EXPORT void +PictTransform_from_xRenderTransform(PictTransformPtr pict, + xRenderTransform * render); + +extern _X_EXPORT void +xRenderTransform_from_PictTransform(xRenderTransform * render, + PictTransformPtr pict); + +extern _X_EXPORT Bool + PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector); + +extern _X_EXPORT Bool + PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector); + +#endif /* _PICTURESTR_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/pixmap.h b/prebuilt/xlibre/usr/include/xorg/pixmap.h new file mode 100644 index 0000000..6833766 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/pixmap.h @@ -0,0 +1,140 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef PIXMAP_H +#define PIXMAP_H + +#include "misc.h" +#include "screenint.h" +#include "regionstr.h" +#include +/* types for Drawable */ +#define DRAWABLE_WINDOW 0 +#define DRAWABLE_PIXMAP 1 +#define UNDRAWABLE_WINDOW 2 + +/* corresponding type masks for dixLookupDrawable() */ +#define M_DRAWABLE_WINDOW (1<<0) +#define M_DRAWABLE_PIXMAP (1<<1) +#define M_UNDRAWABLE_WINDOW (1<<2) +#define M_ANY (-1) +#define M_WINDOW (M_DRAWABLE_WINDOW|M_UNDRAWABLE_WINDOW) +#define M_DRAWABLE (M_DRAWABLE_WINDOW|M_DRAWABLE_PIXMAP) +#define M_UNDRAWABLE (M_UNDRAWABLE_WINDOW) + +/* flags to PaintWindow() */ +#define PW_BACKGROUND 0 +#define PW_BORDER 1 + +#define NullPixmap ((PixmapPtr)0) + +typedef struct _Drawable *DrawablePtr; +typedef struct _Pixmap *PixmapPtr; + +typedef struct _PixmapDirtyUpdate *PixmapDirtyUpdatePtr; + +typedef union _PixUnion { + PixmapPtr pixmap; + unsigned long pixel; +} PixUnion; + +#define SamePixUnion(a,b,isPixel)\ + ((isPixel) ? (a).pixel == (b).pixel : (a).pixmap == (b).pixmap) + +#define EqualPixUnion(as, a, bs, b) \ + ((as) == (bs) && (SamePixUnion ((a), (b), (as)))) + +#define OnScreenDrawable(type) \ + ((type) == DRAWABLE_WINDOW) + +#define WindowDrawable(type) \ + (((type) == DRAWABLE_WINDOW) || ((type) == UNDRAWABLE_WINDOW)) + +extern _X_EXPORT PixmapPtr GetScratchPixmapHeader(ScreenPtr pScreen, + int width, + int height, + int depth, + int bitsPerPixel, + int devKind, + void *pPixData); + +extern _X_EXPORT void FreeScratchPixmapHeader(PixmapPtr /*pPixmap */ ); + +extern _X_EXPORT Bool PixmapScreenInit(ScreenPtr /*pScreen */ ); + +extern _X_EXPORT PixmapPtr AllocatePixmap(ScreenPtr /*pScreen */ , + int /*pixDataSize */ ); + +extern _X_EXPORT void FreePixmap(PixmapPtr /*pPixmap */ ); + +extern _X_EXPORT PixmapPtr +PixmapShareToSecondary(PixmapPtr pixmap, ScreenPtr secondary); + +extern _X_EXPORT void +PixmapUnshareSecondaryPixmap(PixmapPtr secondary_pixmap); + +#define HAS_DIRTYTRACKING_ROTATION 1 +#define HAS_DIRTYTRACKING_DRAWABLE_SRC 1 +extern _X_EXPORT Bool +PixmapStartDirtyTracking(DrawablePtr src, + PixmapPtr slave_dst, + int x, int y, int dst_x, int dst_y, + Rotation rotation); + +extern _X_EXPORT Bool +PixmapStopDirtyTracking(DrawablePtr src, PixmapPtr slave_dst); + +/* helper function, drivers can do this themselves if they can do it more + efficiently */ +extern _X_EXPORT Bool +PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty); + +extern _X_EXPORT void +PixmapDirtyCopyArea(PixmapPtr dst, DrawablePtr src, + int x, int y, int dst_x, int dst_y, + RegionPtr dirty_region); + +#endif /* PIXMAP_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/pixmapstr.h b/prebuilt/xlibre/usr/include/xorg/pixmapstr.h new file mode 100644 index 0000000..6390462 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/pixmapstr.h @@ -0,0 +1,110 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef PIXMAPSTRUCT_H +#define PIXMAPSTRUCT_H +#include "pixmap.h" +#include "screenint.h" +#include "regionstr.h" +#include "privates.h" +#include "damage.h" +#include +#include "picturestr.h" + +typedef struct _Drawable { + unsigned char type; /* DRAWABLE_ */ + unsigned char class; /* specific to type */ + unsigned char depth; + unsigned char bitsPerPixel; + XID id; /* resource id */ + short x; /* window: screen absolute, pixmap: 0 */ + short y; /* window: screen absolute, pixmap: 0 */ + unsigned short width; + unsigned short height; + ScreenPtr pScreen; + unsigned long serialNumber; +} DrawableRec; + +/* + * PIXMAP -- device dependent + */ + +typedef struct _Pixmap { + DrawableRec drawable; + PrivateRec *devPrivates; + int refcnt; + int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */ + DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */ + short screen_x; + short screen_y; + unsigned usage_hint; /* see CREATE_PIXMAP_USAGE_* */ + + PixmapPtr primary_pixmap; /* pointer to primary copy of pixmap for pixmap sharing */ +} PixmapRec; + +typedef struct _PixmapDirtyUpdate { + DrawablePtr src; /* Root window / shared pixmap */ + PixmapPtr secondary_dst; /* Shared / scanout pixmap */ + int x, y; + DamagePtr damage; + struct xorg_list ent; + int dst_x, dst_y; + Rotation rotation; + PictTransform transform; + struct pixman_f_transform f_transform, f_inverse; +} PixmapDirtyUpdateRec; + +static inline void +PixmapRegionInit(RegionPtr region, PixmapPtr pixmap) +{ + BoxRec box = { + .x2 = (int16_t)pixmap->drawable.width, + .y2 = (int16_t)pixmap->drawable.height, + }; + RegionInit(region, &box, 1); +} + +#endif /* PIXMAPSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/present.h b/prebuilt/xlibre/usr/include/xorg/present.h new file mode 100644 index 0000000..a4abf55 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/present.h @@ -0,0 +1,162 @@ +/* + * Copyright © 2013 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _PRESENT_H_ +#define _PRESENT_H_ + +#include +#include +#include + +#include "randrstr.h" + +typedef enum { + PRESENT_FLIP_REASON_UNKNOWN, + PRESENT_FLIP_REASON_BUFFER_FORMAT, + + /* Don't add new flip reasons after the TearFree ones, since it's expected + * that the TearFree reasons are the highest ones in order to allow doing + * `reason >= PRESENT_FLIP_REASON_DRIVER_TEARFREE` to check if a reason is + * PRESENT_FLIP_REASON_DRIVER_TEARFREE{_FLIPPING}. + */ + PRESENT_FLIP_REASON_DRIVER_TEARFREE, + PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING +} PresentFlipReason; + +typedef struct present_vblank present_vblank_rec, *present_vblank_ptr; + +/* Return the current CRTC for 'window'. + */ +typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window); + +/* Return the current ust/msc for 'crtc' + */ +typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc); +typedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, uint64_t *ust, uint64_t *msc); + +/* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 'event_id' + * at or after 'msc'. Return false if it didn't happen (which might occur if 'crtc' + * is not currently generating vblanks). + */ +typedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc, + uint64_t event_id, + uint64_t msc); +typedef Bool (*present_wnmd_queue_vblank_ptr) (WindowPtr window, + RRCrtcPtr crtc, + uint64_t event_id, + uint64_t msc); + +/* Abort pending vblank. The extension is no longer interested in + * 'event_id' which was to be notified at 'msc'. If possible, the + * driver is free to de-queue the notification. + */ +typedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, uint64_t msc); +typedef void (*present_wnmd_abort_vblank_ptr) (WindowPtr window, + RRCrtcPtr crtc, + uint64_t event_id, + uint64_t msc); + +/* Flush pending drawing on 'window' to the hardware. + */ +typedef void (*present_flush_ptr) (WindowPtr window); + +/* Check if 'pixmap' is suitable for flipping to 'window'. + */ +typedef Bool (*present_check_flip_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip); + +/* Same as 'check_flip' but it can return a 'reason' why the flip would fail. + */ +typedef Bool (*present_check_flip2_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip, PresentFlipReason *reason); + +/* Flip pixmap, return false if it didn't happen. + * + * 'crtc' is to be used for any necessary synchronization. + * + * 'sync_flip' requests that the flip be performed at the next + * vertical blank interval to avoid tearing artifacts. If false, the + * flip should be performed as soon as possible. + * + * present_event_notify should be called with 'event_id' when the flip + * occurs + */ +typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc, + uint64_t event_id, + uint64_t target_msc, + PixmapPtr pixmap, + Bool sync_flip); +/* Flip pixmap for window, return false if it didn't happen. + * + * Like present_flip_ptr, additionally with: + * + * 'window' used for synchronization. + * + */ +typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window, + RRCrtcPtr crtc, + uint64_t event_id, + uint64_t target_msc, + PixmapPtr pixmap, + Bool sync_flip, + RegionPtr damage); + +/* "unflip" back to the regular screen scanout buffer + * + * present_event_notify should be called with 'event_id' when the unflip occurs. + */ +typedef void (*present_unflip_ptr) (ScreenPtr screen, + uint64_t event_id); + +/* Doing flips has been discontinued. + * + * Inform driver for potential cleanup on its side. + */ +typedef void (*present_wnmd_flips_stop_ptr) (WindowPtr window); + +#define PRESENT_SCREEN_INFO_VERSION 1 + +typedef struct present_screen_info { + uint32_t version; + + present_get_crtc_ptr get_crtc; + present_get_ust_msc_ptr get_ust_msc; + present_queue_vblank_ptr queue_vblank; + present_abort_vblank_ptr abort_vblank; + present_flush_ptr flush; + uint32_t capabilities; + present_check_flip_ptr check_flip; + present_flip_ptr flip; + present_unflip_ptr unflip; + present_check_flip2_ptr check_flip2; + +} present_screen_info_rec, *present_screen_info_ptr; + +/* + * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the + * event actually happened + */ +extern _X_EXPORT void +present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc); + +extern _X_EXPORT Bool +present_screen_init(ScreenPtr screen, present_screen_info_ptr info); + +#endif /* _PRESENT_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/privates.h b/prebuilt/xlibre/usr/include/xorg/privates.h new file mode 100644 index 0000000..cd2a8c3 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/privates.h @@ -0,0 +1,378 @@ +/*********************************************************** + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef PRIVATES_H +#define PRIVATES_H 1 + +#include +#include +#include +#include +#include "misc.h" + +/***************************************************************** + * STUFF FOR PRIVATES + *****************************************************************/ + +typedef struct _Private PrivateRec, *PrivatePtr; + +/* WARNING: the values, as well as the total number are part of public ABI. + Adding a new one will lead to increased size as well as different field + offsets within ScreenRec. +*/ +typedef enum { + /* XSELinux uses the same private keys for numerous objects + + This black magic - keys of this type have very special handling: + their corresponding space is allocated at the top of the private + areas, in *several* object types (see xselinux_private[] array), + and xselinux uses the same keys for all object types + */ + PRIVATE_XSELINUX, + + /* Otherwise, you get a private in just the requested structure + */ + /* These can have objects created before all of the keys are registered */ + PRIVATE_SCREEN, + PRIVATE_EXTENSION, + PRIVATE_COLORMAP, + PRIVATE_DEVICE, + + /* These cannot have any objects before all relevant keys are registered */ + PRIVATE_CLIENT, + PRIVATE_PROPERTY, + PRIVATE_SELECTION, + PRIVATE_WINDOW, + PRIVATE_PIXMAP, + PRIVATE_GC, + PRIVATE_CURSOR, + PRIVATE_CURSOR_BITS, + + /* extension privates */ + PRIVATE_GLYPH, + PRIVATE_GLYPHSET, + PRIVATE_PICTURE, + PRIVATE_SYNC_FENCE, + + /* last private type */ + PRIVATE_LAST, +} DevPrivateType; + +typedef struct _DevPrivateKeyRec { + int offset; + int size; + Bool initialized; + Bool allocated; + DevPrivateType type; + struct _DevPrivateKeyRec *next; +} DevPrivateKeyRec, *DevPrivateKey; + +typedef struct _DevPrivateSetRec { + DevPrivateKey key; + unsigned offset; + int created; + int allocated; +} DevPrivateSetRec, *DevPrivateSetPtr; + +typedef struct _DevScreenPrivateKeyRec { + DevPrivateKeyRec screenKey; +} DevScreenPrivateKeyRec, *DevScreenPrivateKeyPtr; + +/* + * Let drivers know how to initialize private keys + */ + +#define HAS_DEVPRIVATEKEYREC 1 +#define HAS_DIXREGISTERPRIVATEKEY 1 + +/* + * @brief Register a new private index for the private type. + * + * This initializes the specified key and optionally requests pre-allocated + * private space for your driver/module. If you request no extra space, you + * may set and get a single pointer value using this private key. Otherwise, + * you can get the address of the extra space and store whatever data you like + * there. + * + * Maybe called multiple times on the same key, but the size and type must + * match or the server will abort. + * + * Note: this may move around the private storage area to different address, + * thus any pointers taken by GetPrivateAddr() et al have to be considered + * invalid after calling this function. + * + * @param key pointer to key (will be written to) + * @param type the object type the key is used for + * @param size size of the storage reserved for that key (zero => void*) + * @return FALSE if it fails to allocate memory during its operation. + */ +_X_EXPORT Bool dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size); + +/* + * Check whether a private key has been registered + */ +static inline Bool +dixPrivateKeyRegistered(DevPrivateKey key) +{ + return key->initialized; +} + +/* + * Get the address of the private storage. + * + * For keys with pre-defined storage, this gets the base of that storage + * Otherwise, it returns the place where the private pointer is stored. + */ +static inline void * +dixGetPrivateAddr(PrivatePtr *privates, const DevPrivateKey key) +{ + assert(key->initialized); + return (char *) (*privates) + key->offset; +} + +/* + * Fetch a private pointer stored in the object + * + * Returns the pointer stored with dixSetPrivate. + * This must only be used with keys that have + * no pre-defined storage + */ +static inline void * +dixGetPrivate(PrivatePtr *privates, const DevPrivateKey key) +{ + assert(key->size == 0); + return *(void **) dixGetPrivateAddr(privates, key); +} + +/* + * Associate 'val' with 'key' in 'privates' so that later calls to + * dixLookupPrivate(privates, key) will return 'val'. + */ +static inline void +dixSetPrivate(PrivatePtr *privates, const DevPrivateKey key, void *val) +{ + assert(key->size == 0); + *(void **) dixGetPrivateAddr(privates, key) = val; +} + +#include "dix.h" +#include "resource.h" + +/* + * Lookup a pointer to the private record. + * + * For privates with defined storage, return the address of the + * storage. For privates without defined storage, return the pointer + * contents + */ +static inline void * +dixLookupPrivate(PrivatePtr *privates, const DevPrivateKey key) +{ + if (key->size) + return dixGetPrivateAddr(privates, key); + else + return dixGetPrivate(privates, key); +} + +/* + * Look up the address of the pointer to the storage + * + * This returns the place where the private pointer is stored, + * which is only valid for privates without predefined storage. + */ +static inline void ** +dixLookupPrivateAddr(PrivatePtr *privates, const DevPrivateKey key) +{ + assert(key->size == 0); + return (void **) dixGetPrivateAddr(privates, key); +} + +extern _X_EXPORT Bool + +dixRegisterScreenPrivateKey(DevScreenPrivateKeyPtr key, ScreenPtr pScreen, + DevPrivateType type, unsigned size); + +extern _X_EXPORT DevPrivateKey + _dixGetScreenPrivateKey(const DevScreenPrivateKeyPtr key, ScreenPtr pScreen); + +static inline void * +dixGetScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKeyPtr key, + ScreenPtr pScreen) +{ + return dixGetPrivateAddr(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void * +dixGetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKeyPtr key, + ScreenPtr pScreen) +{ + return dixGetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void +dixSetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKeyPtr key, + ScreenPtr pScreen, void *val) +{ + dixSetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen), val); +} + +static inline void * +dixLookupScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKeyPtr key, + ScreenPtr pScreen) +{ + return dixLookupPrivate(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void ** +dixLookupScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKeyPtr key, + ScreenPtr pScreen) +{ + return dixLookupPrivateAddr(privates, + _dixGetScreenPrivateKey(key, pScreen)); +} + +/* + * These functions relate to allocations related to a specific screen; + * space will only be available for objects allocated for use on that + * screen. As such, only objects which are related directly to a specific + * screen are candidates for allocation this way, this includes + * windows, pixmaps, gcs, pictures and colormaps. This key is + * used just like any other key using dixGetPrivate and friends. + * + * This is distinctly different from the ScreenPrivateKeys above which + * allocate space in global objects like cursor bits for a specific + * screen, allowing multiple screen-related chunks of storage in a + * single global object. + */ + +#define HAVE_SCREEN_SPECIFIC_PRIVATE_KEYS 1 + +extern _X_EXPORT Bool +dixRegisterScreenSpecificPrivateKey(ScreenPtr pScreen, DevPrivateKey key, + DevPrivateType type, unsigned size); + +/* Clean up screen-specific privates before CloseScreen */ +extern void +dixFreeScreenSpecificPrivates(ScreenPtr pScreen); + +/* Initialize screen-specific privates in AddScreen */ +extern void +dixInitScreenSpecificPrivates(ScreenPtr pScreen); + +/* is this private created - so hotplug can avoid crashing */ +Bool dixPrivatesCreated(DevPrivateType type); + +extern _X_EXPORT void * +_dixAllocateScreenObjectWithPrivates(ScreenPtr pScreen, + unsigned size, + unsigned offset, + DevPrivateType type); + +#define dixAllocateScreenObjectWithPrivates(s, t, type) _dixAllocateScreenObjectWithPrivates((s), sizeof(t), offsetof(t, devPrivates), (type)) + +extern _X_EXPORT int +dixScreenSpecificPrivatesSize(ScreenPtr pScreen, DevPrivateType type); + +extern _X_EXPORT void +_dixInitScreenPrivates(ScreenPtr pScreen, PrivatePtr *privates, void *addr, DevPrivateType type); + +#define dixInitScreenPrivates(s, o, v, type) _dixInitScreenPrivates((s), &(o)->devPrivates, (v), (type)); + +/* + * Allocates private data separately from main object. + * + * For objects created during server initialization, this allows those + * privates to be re-allocated as new private keys are registered. + * + * This includes screens, the serverClient, default colormaps and + * extensions entries. + */ +extern _X_EXPORT Bool + dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type); + +/* + * Frees separately allocated private data + */ +extern _X_EXPORT void + dixFreePrivates(PrivatePtr privates, DevPrivateType type); + +/* + * Initialize privates by zeroing them + */ +extern _X_EXPORT void +_dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type); + +#define dixInitPrivates(o, v, type) _dixInitPrivates(&(o)->devPrivates, (v), (type)); + +/* + * Clean up privates + */ +extern _X_EXPORT void + _dixFiniPrivates(PrivatePtr privates, DevPrivateType type); + +#define dixFiniPrivates(o,t) _dixFiniPrivates((o)->devPrivates,(t)) + +/* + * Allocates private data at object creation time. Required + * for almost all objects, except for the list described + * above for dixAllocatePrivates. + */ +extern _X_EXPORT void *_dixAllocateObjectWithPrivates(unsigned size, + unsigned clear, + unsigned offset, + DevPrivateType type); + +#define dixAllocateObjectWithPrivates(t, type) (t *) _dixAllocateObjectWithPrivates(sizeof(t), sizeof(t), offsetof(t, devPrivates), (type)) + +extern _X_EXPORT void + +_dixFreeObjectWithPrivates(void *object, PrivatePtr privates, + DevPrivateType type); + +#define dixFreeObjectWithPrivates(o,t) _dixFreeObjectWithPrivates((o), (o)->devPrivates, (t)) + +/* + * Return size of privates for the specified type + */ +extern _X_EXPORT int + dixPrivatesSize(DevPrivateType type); + +/* + * Dump out private stats to ErrorF + */ +extern void + dixPrivateUsage(void); + +/* + * Resets the privates subsystem. dixResetPrivates is called from the main loop + * before each server generation. This function must only be called by main(). + */ +extern _X_EXPORT void + dixResetPrivates(void); + +/* + * Looks up the offset where the devPrivates field is located. + * + * Returns -1 if the specified resource has no dev privates. + * The position of the devPrivates field varies by structure + * and calling code might only know the resource type, not the + * structure definition. + */ +extern _X_EXPORT int + dixLookupPrivateOffset(RESTYPE type); + +/* + * Convenience macro for adding an offset to an object pointer + * when making a call to one of the devPrivates functions + */ +#define DEVPRIV_AT(ptr, offset) ((PrivatePtr *)((char *)(ptr) + (offset))) + +#endif /* PRIVATES_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/property.h b/prebuilt/xlibre/usr/include/xorg/property.h new file mode 100644 index 0000000..73f5110 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/property.h @@ -0,0 +1,63 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef PROPERTY_H +#define PROPERTY_H + +#include "xlibre_ptrtypes.h" +#include "window.h" + +extern _X_EXPORT int dixChangeWindowProperty(ClientPtr pClient, + WindowPtr pWin, + Atom property, + Atom type, + int format, + int mode, + unsigned long len, + const void *value, + Bool sendevent); + +#endif /* PROPERTY_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/ptrveloc.h b/prebuilt/xlibre/usr/include/xorg/ptrveloc.h new file mode 100644 index 0000000..6a22581 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/ptrveloc.h @@ -0,0 +1,91 @@ +/* + * + * Copyright © 2006-2011 Simon Thum simon dot thum at gmx dot de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef POINTERVELOCITY_H +#define POINTERVELOCITY_H + +#include + +/* constants for acceleration profiles */ + +#define AccelProfileNone -1 +#define AccelProfileClassic 0 +#define AccelProfileDeviceSpecific 1 +#define AccelProfilePolynomial 2 +#define AccelProfileSmoothLinear 3 +#define AccelProfileSimple 4 +#define AccelProfilePower 5 +#define AccelProfileLinear 6 +#define AccelProfileSmoothLimited 7 +#define AccelProfileLAST AccelProfileSmoothLimited + +/* fwd */ +struct _DeviceVelocityRec; + +/** + * profile + * returns actual acceleration depending on velocity, acceleration control,... + */ +typedef double (*PointerAccelerationProfileFunc) + (DeviceIntPtr dev, struct _DeviceVelocityRec * vel, + double velocity, double threshold, double accelCoeff); + +typedef struct _MotionTracker MotionTracker, *MotionTrackerPtr; + +/** + * Contains all data needed to implement mouse ballistics + */ +typedef struct _DeviceVelocityRec { + MotionTrackerPtr tracker; + int num_tracker; + int cur_tracker; /* current index */ + double velocity; /* velocity as guessed by algorithm */ + double last_velocity; /* previous velocity estimate */ + double last_dx; /* last time-difference */ + double last_dy; /* phase of last/current estimate */ + double corr_mul; /* config: multiply this into velocity */ + double const_acceleration; /* config: (recipr.) const deceleration */ + double min_acceleration; /* config: minimum acceleration */ + short reset_time; /* config: reset non-visible state after # ms */ + short use_softening; /* config: use softening of mouse values */ + double max_rel_diff; /* config: max. relative difference */ + double max_diff; /* config: max. difference */ + int initial_range; /* config: max. offset used as initial velocity */ + Bool average_accel; /* config: average acceleration over velocity */ + PointerAccelerationProfileFunc Profile; + PointerAccelerationProfileFunc deviceSpecificProfile; + void *profile_private; /* extended data, see SetAccelerationProfile() */ + struct { /* to be able to query this information */ + int profile_number; + } statistics; +} DeviceVelocityRec, *DeviceVelocityPtr; + +extern _X_EXPORT DeviceVelocityPtr +GetDevicePredictableAccelData(DeviceIntPtr dev); + +extern _X_EXPORT void +SetDeviceSpecificAccelerationProfile(DeviceVelocityPtr vel, + PointerAccelerationProfileFunc profile); + +#endif /* POINTERVELOCITY_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/randrstr.h b/prebuilt/xlibre/usr/include/xorg/randrstr.h new file mode 100644 index 0000000..c0810e6 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/randrstr.h @@ -0,0 +1,830 @@ +/* + * Copyright © 2000 Compaq Computer Corporation + * Copyright © 2002 Hewlett-Packard Company + * Copyright © 2006 Intel Corporation + * Copyright © 2008 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + * Author: Jim Gettys, Hewlett-Packard Company, Inc. + * Keith Packard, Intel Corporation + */ +#ifndef _RANDRSTR_H_ +#define _RANDRSTR_H_ + +#include +#include + +#include "xlibre_ptrtypes.h" +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "resource.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "extnsionst.h" +#include "servermd.h" +#include "rrtransform.h" +#include +#include +#include /* we share subpixel order information */ +#include "picturestr.h" +#include + +/* required for ABI compatibility for now */ +#define RANDR_10_INTERFACE 1 +#define RANDR_12_INTERFACE 1 +#define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */ +#define RANDR_GET_CRTC_INTERFACE 1 + +#define RANDR_INTERFACE_VERSION 0x0104 + +typedef XID RRMode; +typedef XID RROutput; +typedef XID RRCrtc; +typedef XID RRProvider; +typedef XID RRLease; + +/* + * Modeline for a monitor. Name follows directly after this struct + */ + +#define RRModeName(pMode) ((char *) ((pMode) + 1)) +typedef struct _rrMode RRModeRec, *RRModePtr; +typedef struct _rrPropertyValue RRPropertyValueRec, *RRPropertyValuePtr; +typedef struct _rrProperty RRPropertyRec, *RRPropertyPtr; +typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; +typedef struct _rrOutput RROutputRec, *RROutputPtr; +typedef struct _rrProvider RRProviderRec, *RRProviderPtr; +typedef struct _rrMonitor RRMonitorRec, *RRMonitorPtr; +typedef struct _rrLease RRLeaseRec, *RRLeasePtr; + +struct _rrMode { + int refcnt; + xRRModeInfo mode; + char *name; + ScreenPtr userScreen; +}; + +struct _rrPropertyValue { + Atom type; /* ignored by server */ + short format; /* format of data for swapping - 8,16,32 */ + long size; /* size of data in (format/8) bytes */ + void *data; /* private to client */ +}; + +struct _rrProperty { + RRPropertyPtr next; + ATOM propertyName; + Bool is_pending; + Bool range; + Bool immutable; + int num_valid; + INT32 *valid_values; + RRPropertyValueRec current, pending; +}; + +struct _rrCrtc { + RRCrtc id; + ScreenPtr pScreen; + RRModePtr mode; + int x, y; + Rotation rotation; + Rotation rotations; + Bool changed; + int numOutputs; + RROutputPtr *outputs; + int gammaSize; + CARD16 *gammaRed; + CARD16 *gammaBlue; + CARD16 *gammaGreen; + void *devPrivate; + Bool transforms; + RRTransformRec client_pending_transform; + RRTransformRec client_current_transform; + PictTransform transform; + struct pixman_f_transform f_transform; + struct pixman_f_transform f_inverse; + + PixmapPtr scanout_pixmap; + PixmapPtr scanout_pixmap_back; +}; + +struct _rrOutput { + RROutput id; + ScreenPtr pScreen; + char *name; + int nameLength; + CARD8 connection; + CARD8 subpixelOrder; + int mmWidth; + int mmHeight; + RRCrtcPtr crtc; + int numCrtcs; + RRCrtcPtr *crtcs; + int numClones; + RROutputPtr *clones; + int numModes; + int numPreferred; + RRModePtr *modes; + int numUserModes; + RRModePtr *userModes; + Bool changed; + Bool nonDesktop; + RRPropertyPtr properties; + Bool pendingProperties; + void *devPrivate; +}; + +struct _rrProvider { + RRProvider id; + ScreenPtr pScreen; + uint32_t capabilities; + char *name; + int nameLength; + RRPropertyPtr properties; + Bool pendingProperties; + Bool changed; + struct _rrProvider *offload_sink; + struct _rrProvider *output_source; +}; + +typedef struct _rrMonitorGeometry { + BoxRec box; + CARD32 mmWidth; + CARD32 mmHeight; +} RRMonitorGeometryRec, *RRMonitorGeometryPtr; + +struct _rrMonitor { + Atom name; + ScreenPtr pScreen; + int numOutputs; + RROutput *outputs; + Bool primary; + Bool automatic; + RRMonitorGeometryRec geometry; +}; + +typedef enum _rrLeaseState { RRLeaseCreating, RRLeaseRunning, RRLeaseTerminating } RRLeaseState; + +struct _rrLease { + struct xorg_list list; + ScreenPtr screen; + RRLease id; + RRLeaseState state; + void *devPrivate; + int numCrtcs; + RRCrtcPtr *crtcs; + int numOutputs; + RROutputPtr *outputs; +}; + +typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD32 mmWidth, CARD32 mmHeight); + +typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, + RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutputs, RROutputPtr * outputs); + +typedef void (*RRCrtcGetProcPtr) (ScreenPtr pScreen, + RRCrtcPtr crtc, + xRRGetCrtcInfoReply *rep); + +typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); + +typedef Bool (*RRCrtcGetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); + +typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen, + RROutputPtr output, + Atom property, + RRPropertyValuePtr value); + +typedef Bool (*RROutputValidateModeProcPtr) (ScreenPtr pScreen, + RROutputPtr output, + RRModePtr mode); + +typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen, RRModePtr mode); + +#if RANDR_13_INTERFACE +typedef Bool (*RROutputGetPropertyProcPtr) (ScreenPtr pScreen, + RROutputPtr output, Atom property); +typedef Bool (*RRGetPanningProcPtr) (ScreenPtr pScrn, + RRCrtcPtr crtc, + BoxPtr totalArea, + BoxPtr trackingArea, INT16 *border); +typedef Bool (*RRSetPanningProcPtr) (ScreenPtr pScrn, + RRCrtcPtr crtc, + BoxPtr totalArea, + BoxPtr trackingArea, INT16 *border); + +#endif /* RANDR_13_INTERFACE */ + +typedef Bool (*RRProviderGetPropertyProcPtr) (ScreenPtr pScreen, + RRProviderPtr provider, Atom property); +typedef Bool (*RRProviderSetPropertyProcPtr) (ScreenPtr pScreen, + RRProviderPtr provider, + Atom property, + RRPropertyValuePtr value); + +typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation * rotations); +typedef Bool (*RRCloseScreenProcPtr) (ScreenPtr pScreen); + +typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr output_source); + +typedef Bool (*RRProviderSetOffloadSinkProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr offload_sink); + + +typedef void (*RRProviderDestroyProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider); + +/* Additions for 1.6 */ + +typedef int (*RRCreateLeaseProcPtr)(ScreenPtr screen, + RRLeasePtr lease, + int *fd); + +typedef void (*RRTerminateLeaseProcPtr)(ScreenPtr screen, + RRLeasePtr lease); + +typedef int (*RRRequestLeaseProcPtr)(ClientPtr client, + ScreenPtr screen, + RRLeasePtr lease); + +typedef void (*RRGetLeaseProcPtr)(ClientPtr client, + ScreenPtr screen, + RRLeasePtr *lease, + int *fd); + +/* These are for 1.0 compatibility */ + +typedef struct _rrRefresh { + CARD16 rate; + RRModePtr mode; +} RRScreenRate, *RRScreenRatePtr; + +typedef struct _rrScreenSize { + int id; + short width, height; + short mmWidth, mmHeight; + int nRates; + RRScreenRatePtr pRates; +} RRScreenSize, *RRScreenSizePtr; + +typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, + Rotation rotation, + int rate, RRScreenSizePtr pSize); + +typedef Bool (*RRCrtcSetScanoutPixmapProcPtr)(RRCrtcPtr crtc, PixmapPtr pixmap); + +typedef Bool (*RRStartFlippingPixmapTrackingProcPtr)(RRCrtcPtr, DrawablePtr, + PixmapPtr, PixmapPtr, + int x, int y, + int dst_x, int dst_y, + Rotation rotation); + +typedef Bool (*RREnableSharedPixmapFlippingProcPtr)(RRCrtcPtr, + PixmapPtr front, + PixmapPtr back); + +typedef void (*RRDisableSharedPixmapFlippingProcPtr)(RRCrtcPtr); + + +typedef struct _rrScrPriv { + /* + * 'public' part of the structure; DDXen fill this in + * as they initialize + */ + RRSetConfigProcPtr rrSetConfig; + RRGetInfoProcPtr rrGetInfo; + RRScreenSetSizeProcPtr rrScreenSetSize; + RRCrtcSetProcPtr rrCrtcSet; + RRCrtcSetGammaProcPtr rrCrtcSetGamma; + RRCrtcGetGammaProcPtr rrCrtcGetGamma; + RROutputSetPropertyProcPtr rrOutputSetProperty; + RROutputValidateModeProcPtr rrOutputValidateMode; + RRModeDestroyProcPtr rrModeDestroy; +#if RANDR_13_INTERFACE + RROutputGetPropertyProcPtr rrOutputGetProperty; + RRGetPanningProcPtr rrGetPanning; + RRSetPanningProcPtr rrSetPanning; +#endif + /* TODO #if RANDR_15_INTERFACE */ + RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap; + + RRStartFlippingPixmapTrackingProcPtr rrStartFlippingPixmapTracking; + RREnableSharedPixmapFlippingProcPtr rrEnableSharedPixmapFlipping; + RRDisableSharedPixmapFlippingProcPtr rrDisableSharedPixmapFlipping; + + RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource; + RRProviderSetOffloadSinkProcPtr rrProviderSetOffloadSink; + RRProviderGetPropertyProcPtr rrProviderGetProperty; + RRProviderSetPropertyProcPtr rrProviderSetProperty; + + RRCreateLeaseProcPtr rrCreateLease; + RRTerminateLeaseProcPtr rrTerminateLease; + + /* + * Private part of the structure; not considered part of the ABI + */ + TimeStamp lastSetTime; /* last changed by client */ + TimeStamp lastConfigTime; /* possible configs changed */ + RRCloseScreenProcPtr CloseScreen; + + Bool changed; /* some config changed */ + Bool configChanged; /* configuration changed */ + Bool layoutChanged; /* screen layout changed */ + Bool resourcesChanged; /* screen resources change */ + Bool leasesChanged; /* leases change */ + + CARD16 minWidth, minHeight; + CARD16 maxWidth, maxHeight; + CARD16 width, height; /* last known screen size */ + CARD16 mmWidth, mmHeight; /* last known screen size */ + + int numOutputs; + RROutputPtr *outputs; + RROutputPtr primaryOutput; + + int numCrtcs; + RRCrtcPtr *crtcs; + + /* Last known pointer position */ + RRCrtcPtr pointerCrtc; + + /* + * Configuration information + */ + Rotation rotations; + CARD16 reqWidth, reqHeight; + + int nSizes; + RRScreenSizePtr pSizes; + + Rotation rotation; + int rate; + int size; + + Bool discontiguous; + + RRProviderPtr provider; + + RRProviderDestroyProcPtr rrProviderDestroy; + + int numMonitors; + RRMonitorPtr *monitors; + + struct xorg_list leases; + + RRRequestLeaseProcPtr rrRequestLease; + RRGetLeaseProcPtr rrGetLease; + + RRCrtcGetProcPtr rrCrtcGet; +} rrScrPrivRec, *rrScrPrivPtr; + +extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec; + +#define rrPrivKey (&rrPrivKeyRec) + +#define rrGetScrPriv(pScr) ((rrScrPrivPtr)dixLookupPrivate(&(pScr)->devPrivates, rrPrivKey)) +#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv((pScr)) +#define SetRRScreen(s,p) dixSetPrivate(&(s)->devPrivates, rrPrivKey, (p)) + +/* + * each window has a list of clients requesting + * RRNotify events. Each client has a resource + * for each window it selects RRNotify input for, + * this resource is used to delete the RRNotifyRec + * entry from the per-window queue. + */ + +typedef struct _RREvent *RREventPtr; + +typedef struct _RREvent { + RREventPtr next; + ClientPtr client; + WindowPtr window; + XID clientResource; + int mask; +} RREventRec; + +typedef struct _RRTimes { + TimeStamp setTime; + TimeStamp configTime; +} RRTimesRec, *RRTimesPtr; + +typedef struct _RRClient { + int major_version; + int minor_version; +/* RRTimesRec times[0]; */ +} RRClientRec, *RRClientPtr; + +/* + * Set the range of sizes for the screen + */ +extern _X_EXPORT void + +RRScreenSetSizeRange(ScreenPtr pScreen, + CARD16 minWidth, + CARD16 minHeight, CARD16 maxWidth, CARD16 maxHeight); + +/* rrscreen.c */ +/* + * Notify the extension that the screen size has been changed. + * The driver is responsible for calling this whenever it has changed + * the size of the screen + */ +extern _X_EXPORT void + RRScreenSizeNotify(ScreenPtr pScreen); + +/* + * Request that the screen be resized + */ +extern _X_EXPORT Bool + +RRScreenSizeSet(ScreenPtr pScreen, + CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight); + +/* + * Send ConfigureNotify event to root window when 'something' happens + */ +extern _X_EXPORT void + RRSendConfigNotify(ScreenPtr pScreen); + +/* randr.c */ +/* set a screen change on the primary screen */ +extern _X_EXPORT void +RRSetChanged(ScreenPtr pScreen); + +/* + * Send all pending events + */ +extern _X_EXPORT void + RRTellChanged(ScreenPtr pScreen); + +/* + * Poll the driver for changed information + */ +extern _X_EXPORT Bool + RRGetInfo(ScreenPtr pScreen, Bool force_query); + +extern _X_EXPORT Bool RRScreenInit(ScreenPtr pScreen); + +extern _X_EXPORT RROutputPtr RRFirstOutput(ScreenPtr pScreen); + +/* + * This is the old interface, deprecated but left + * around for compatibility + */ + +/* + * Then, register the specific size with the screen + */ + +extern _X_EXPORT RRScreenSizePtr +RRRegisterSize(ScreenPtr pScreen, + short width, short height, short mmWidth, short mmHeight); + +extern _X_EXPORT Bool + RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate); + +/* + * Finally, set the current configuration of the screen + */ + +extern _X_EXPORT void + +RRSetCurrentConfig(ScreenPtr pScreen, + Rotation rotation, int rate, RRScreenSizePtr pSize); + +/* rrcrtc.c */ + +/* + * Create a CRTC + */ +extern _X_EXPORT RRCrtcPtr RRCrtcCreate(ScreenPtr pScreen, void *devPrivate); + +/* + * Set the allowed rotations on a CRTC + */ +extern _X_EXPORT void + RRCrtcSetRotations(RRCrtcPtr crtc, Rotation rotations); + +/* + * Notify the extension that the Crtc has been reconfigured, + * the driver calls this whenever it has updated the mode + */ +extern _X_EXPORT Bool +RRCrtcNotify(RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + RRTransformPtr transform, int numOutputs, RROutputPtr * outputs); + +/* + * Request that the Crtc be reconfigured + */ +extern _X_EXPORT Bool +RRCrtcSet(RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, Rotation rotation, int numOutput, RROutputPtr * outputs); + +/* + * Request that the Crtc gamma be changed + */ + +extern _X_EXPORT Bool + RRCrtcGammaSet(RRCrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue); + +/* + * Set the size of the gamma table at server startup time + */ + +extern _X_EXPORT Bool + RRCrtcGammaSetSize(RRCrtcPtr crtc, int size); + +/* rrmode.c */ +/* + * Find, and if necessary, create a mode + */ + +extern _X_EXPORT RRModePtr RRModeGet(xRRModeInfo * modeInfo, const char *name); + +/* + * Destroy a mode. + */ + +extern _X_EXPORT void + RRModeDestroy(RRModePtr mode); + +/* rroutput.c */ + +/* + * Notify the output of some change. configChanged indicates whether + * any external configuration (mode list, clones, connected status) + * has changed, or whether the change was strictly internal + * (which crtc is in use) + */ +extern _X_EXPORT void + RROutputChanged(RROutputPtr output, Bool configChanged); + +/* + * Create an output + */ + +extern _X_EXPORT RROutputPtr +RROutputCreate(ScreenPtr pScreen, + const char *name, int nameLength, void *devPrivate); + +/* + * Notify extension that output parameters have been changed + */ +extern _X_EXPORT Bool + RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones); + +extern _X_EXPORT Bool +RROutputSetModes(RROutputPtr output, + RRModePtr * modes, int numModes, int numPreferred); + +extern _X_EXPORT Bool + RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs); + +extern _X_EXPORT Bool + RROutputSetConnection(RROutputPtr output, CARD8 connection); + +extern _X_EXPORT Bool + RROutputSetPhysicalSize(RROutputPtr output, int mmWidth, int mmHeight); + +extern _X_EXPORT void + RROutputDestroy(RROutputPtr output); + +extern _X_EXPORT void + RRDeleteOutputProperty(RROutputPtr output, Atom property); + +extern _X_EXPORT Bool + RRPostPendingProperties(RROutputPtr output); + +extern _X_EXPORT int +RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type, + int format, int mode, unsigned long len, + const void *value, Bool sendevent, Bool pending); + +extern _X_EXPORT int +RRConfigureOutputProperty(RROutputPtr output, Atom property, + Bool pending, Bool range, Bool immutable, + int num_values, const INT32 *values); + +/* rrprovider.c */ +#define PRIME_SYNC_PROP "PRIME Synchronization" + + +/* *just* for backwards compat with legacy proprietary NVidia driver */ + +extern _X_EXPORT RESTYPE RRCrtcType; /* X resource type: Randr CRTC */ +extern _X_EXPORT RESTYPE RRModeType; /* X resource type: Randr MODE */ +extern _X_EXPORT RESTYPE RROutputType; /* X resource type: Randr OUTPUT */ + +/* + * Set non-desktop property on given output. This flag should be TRUE on + * outputs where usual desktops shouldn't expand onto (eg. head displays, + * additional display bars in various handhelds, etc) + */ +_X_EXPORT /* just for Nvidia legacy */ +Bool RROutputSetNonDesktop(RROutputPtr output, Bool non_desktop); + +/* + * Return the area of the frame buffer scanned out by the crtc, + * taking into account the current mode and rotation + * + * @param crtc the CRTC to query + * @param width return buffer for width value + * @param height return buffer for height value + */ +_X_EXPORT /* just for Nvidia legacy */ +void RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height); + +/* + * Retrieve CRTCs current transform + * + * @param crtc the CRTC to query + * @return pointer to CRTCs current transform + */ +_X_EXPORT /* just for Nvidia legacy */ +RRTransformPtr RRCrtcGetTransform(RRCrtcPtr crtc); + +/* + * Detach and free a scanout pixmap + * + * @param crtc the CRTC to act on + */ +_X_EXPORT /* just for Nvidia legacy */ +void RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc); + +/* + * Create / allocate new provider structure + * + * @param pScreen the screen the provider belongs to + * @param name name of the provider (counted string) + * @param nameLen size of the provider name + * @return new provider structure, or NULL on failure + */ +_X_EXPORT /* just for Nvidia legacy */ +RRProviderPtr RRProviderCreate(ScreenPtr pScreen, const char *name, + int nameLen); + +/* + * Set provider capabilities field + * + * @param provider the provider whose capabilities are to be set + * @param capabilities the new capabilities + */ +_X_EXPORT /* just for Nvidia legacy */ +void RRProviderSetCapabilities(RRProviderPtr provider, uint32_t capabilities); + +/* + * Check whether client is operating on recent enough protocol version + * to know about refresh rates. This has influence on reply packet formats + * + * @param pClient the client to check + * @return TRUE if client using recent enough protocol version + */ +_X_EXPORT /* just for Nvidia legacy */ +Bool RRClientKnowsRates(ClientPtr pClient); + +/* + * Set filter on transform structure + */ +_X_EXPORT /* just for Nvidia legacy */ +Bool RRTransformSetFilter(RRTransformPtr dst, PictFilterPtr filter, + xFixed *params, int nparams, int width, int height); + +/* + * Set whether transforms are allowed on a CRTC + * + * @param crtc the CRTC to set the flag on + * @param transforms TRUE if transforms are allowed + */ +_X_EXPORT /* just for Nvidia legacy */ +void RRCrtcSetTransformSupport(RRCrtcPtr crtc, Bool transforms); + +/* + * Set subpixel order on given output + * + * @param output the output to set subpixel order on + * @param order subpixel order value to set + */ +_X_EXPORT /* just for Nvidia legacy */ +void RROutputSetSubpixelOrder(RROutputPtr output, int order); + +/* + * Retrieve output property value + * + * @param output the output to query + * @param property Atom ID of the property to retrieve + * @param pending retrieve pending instead of current value + * @return pointer to property value or NULL (if not found) + */ +_X_EXPORT /* just for Nvidia legacy */ +RRPropertyValuePtr RRGetOutputProperty(RROutputPtr output, Atom property, Bool pending); + +#endif /* _RANDRSTR_H_ */ + +/* + +randr extension implementation structure + +Query state: + ProcRRGetScreenInfo/ProcRRGetScreenResources + RRGetInfo + + • Request configuration from driver, either 1.0 or 1.2 style + • These functions only record state changes, all + other actions are pended until RRTellChanged is called + + ->rrGetInfo + 1.0: + RRRegisterSize + RRRegisterRate + RRSetCurrentConfig + 1.2: + RRScreenSetSizeRange + RROutputSetCrtcs + RRModeGet + RROutputSetModes + RROutputSetConnection + RROutputSetSubpixelOrder + RROutputSetClones + RRCrtcNotify + + • Must delay scanning configuration until after ->rrGetInfo returns + because some drivers will call SetCurrentConfig in the middle + of the ->rrGetInfo operation. + + 1.0: + + • Scan old configuration, mirror to new structures + + RRScanOldConfig + RRCrtcCreate + RROutputCreate + RROutputSetCrtcs + RROutputSetConnection + RROutputSetSubpixelOrder + RROldModeAdd • This adds modes one-at-a-time + RRModeGet + RRCrtcNotify + + • send events, reset pointer if necessary + + RRTellChanged + WalkTree (sending events) + + • when layout has changed: + RRPointerScreenConfigured + RRSendConfigNotify + +Asynchronous state setting (1.2 only) + When setting state asynchronously, the driver invokes the + ->rrGetInfo function and then calls RRTellChanged to flush + the changes to the clients and reset pointer if necessary + +Set state + + ProcRRSetScreenConfig + RRCrtcSet + 1.2: + ->rrCrtcSet + RRCrtcNotify + 1.0: + ->rrSetConfig + RRCrtcNotify + RRTellChanged + */ diff --git a/prebuilt/xlibre/usr/include/xorg/region.h b/prebuilt/xlibre/usr/include/xorg/region.h new file mode 100644 index 0000000..14d283f --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/region.h @@ -0,0 +1,52 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef REGION_H +#define REGION_H + +#include "regionstr.h" + +#endif /* REGION_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/regionstr.h b/prebuilt/xlibre/usr/include/xorg/regionstr.h new file mode 100644 index 0000000..73b5efd --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/regionstr.h @@ -0,0 +1,367 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef REGIONSTRUCT_H +#define REGIONSTRUCT_H + +typedef struct pixman_region16 RegionRec, *RegionPtr; + +#include "miscstruct.h" + +/* Return values from RectIn() */ + +#define rgnOUT 0 +#define rgnIN 1 +#define rgnPART 2 + +#define NullRegion ((RegionPtr)0) + +/* + * clip region + */ + +typedef struct pixman_region16_data RegDataRec, *RegDataPtr; + +extern _X_EXPORT BoxRec RegionEmptyBox; +extern _X_EXPORT RegDataRec RegionEmptyData; +extern _X_EXPORT RegDataRec RegionBrokenData; +static inline Bool +RegionNil(RegionPtr reg) +{ + return ((reg)->data && !(reg)->data->numRects); +} + +/* not a region */ + +static inline Bool +RegionNar(RegionPtr reg) +{ + return ((reg)->data == &RegionBrokenData); +} + +static inline int +RegionNumRects(RegionPtr reg) +{ + return (int)(reg->data ? reg->data->numRects : 1); +} + +static inline int +RegionSize(RegionPtr reg) +{ + return (int)(reg->data ? reg->data->size : 0); +} + +static inline BoxPtr +RegionRects(RegionPtr reg) +{ + return ((reg)->data ? (BoxPtr) ((reg)->data + 1) : &(reg)->extents); +} + +static inline BoxPtr +RegionBoxptr(RegionPtr reg) +{ + return ((BoxPtr) ((reg)->data + 1)); +} + +static inline BoxPtr +RegionBox(RegionPtr reg, int i) +{ + return (&RegionBoxptr(reg)[i]); +} + +static inline BoxPtr +RegionTop(RegionPtr reg) +{ + return RegionBox(reg, (int)reg->data->numRects); +} + +static inline BoxPtr +RegionEnd(RegionPtr reg) +{ + return RegionBox(reg, (int)reg->data->numRects - 1); +} + +static inline size_t +RegionSizeof(size_t n) +{ + if (n < ((INT_MAX - sizeof(RegDataRec)) / sizeof(BoxRec))) + return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec))); + else + return 0; +} + +static inline void +RegionInit(RegionPtr _pReg, BoxPtr _rect, size_t _size) +{ + if ((_rect) != NULL) { + (_pReg)->extents = *(_rect); + (_pReg)->data = (RegDataPtr) NULL; + } + else { + size_t rgnSize; + (_pReg)->extents = RegionEmptyBox; + if (((_size) > 1) && ((rgnSize = RegionSizeof(_size)) > 0) && + (((_pReg)->data = (RegDataPtr) calloc(1, rgnSize)) != NULL)) { + (_pReg)->data->size = (long)(_size); + (_pReg)->data->numRects = 0; + } + else + (_pReg)->data = &RegionEmptyData; + } +} + +static inline Bool +RegionInitBoxes(RegionPtr pReg, BoxPtr boxes, int nBoxes) +{ + return pixman_region_init_rects(pReg, boxes, nBoxes); +} + +static inline void +RegionUninit(RegionPtr _pReg) +{ + if ((_pReg)->data && (_pReg)->data->size) { + if ((_pReg)->data != &RegionEmptyData) + free((_pReg)->data); + (_pReg)->data = NULL; + } +} + +static inline void +RegionReset(RegionPtr _pReg, BoxPtr _pBox) +{ + (_pReg)->extents = *(_pBox); + RegionUninit(_pReg); + (_pReg)->data = (RegDataPtr) NULL; +} + +static inline Bool +RegionNotEmpty(RegionPtr _pReg) +{ + return !RegionNil(_pReg); +} + +static inline Bool +RegionBroken(RegionPtr _pReg) +{ + return RegionNar(_pReg); +} + +static inline void +RegionEmpty(RegionPtr _pReg) +{ + RegionUninit(_pReg); + (_pReg)->extents.x2 = (_pReg)->extents.x1; + (_pReg)->extents.y2 = (_pReg)->extents.y1; + (_pReg)->data = &RegionEmptyData; +} + +static inline BoxPtr +RegionExtents(RegionPtr _pReg) +{ + return (&(_pReg)->extents); +} + +static inline void +RegionNull(RegionPtr _pReg) +{ + (_pReg)->extents = RegionEmptyBox; + (_pReg)->data = &RegionEmptyData; +} + +extern _X_EXPORT void InitRegions(void); + +extern _X_EXPORT RegionPtr RegionCreate(BoxPtr /*rect */ , + int /*size */ ); + +extern _X_EXPORT void RegionDestroy(RegionPtr /*pReg */ ); + +extern _X_EXPORT RegionPtr RegionDuplicate(RegionPtr /* pOld */); + +static inline Bool +RegionCopy(RegionPtr dst, RegionPtr src) +{ + return pixman_region_copy(dst, src); +} + +static inline Bool +RegionIntersect(RegionPtr newReg, /* destination Region */ + RegionPtr reg1, RegionPtr reg2 /* source regions */ + ) +{ + return pixman_region_intersect(newReg, reg1, reg2); +} + +static inline Bool +RegionUnion(RegionPtr newReg, /* destination Region */ + RegionPtr reg1, RegionPtr reg2 /* source regions */ + ) +{ + return pixman_region_union(newReg, reg1, reg2); +} + +extern _X_EXPORT Bool RegionAppend(RegionPtr /*dstrgn */ , + RegionPtr /*rgn */ ); + +extern _X_EXPORT Bool RegionValidate(RegionPtr /*badreg */ , + Bool * /*pOverlap */ ); + +extern _X_EXPORT RegionPtr RegionFromRects(int /*nrects */ , + xRectanglePtr /*prect */ , + int /*ctype */ ); + +/*- + *----------------------------------------------------------------------- + * Subtract -- + * Subtract regS from regM and leave the result in regD. + * S stands for subtrahend, M for minuend and D for difference. + * + * Results: + * TRUE if successful. + * + * Side Effects: + * regD is overwritten. + * + *----------------------------------------------------------------------- + */ +static inline Bool +RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS) +{ + return pixman_region_subtract(regD, regM, regS); +} + +/*- + *----------------------------------------------------------------------- + * Inverse -- + * Take a region and a box and return a region that is everything + * in the box but not in the region. The careful reader will note + * that this is the same as subtracting the region from the box... + * + * Results: + * TRUE. + * + * Side Effects: + * newReg is overwritten. + * + *----------------------------------------------------------------------- + */ + +static inline Bool +RegionInverse(RegionPtr newReg, /* Destination region */ + RegionPtr reg1, /* Region to invert */ + BoxPtr invRect /* Bounding box for inversion */ + ) +{ + return pixman_region_inverse(newReg, reg1, invRect); +} + +static inline int +RegionContainsRect(RegionPtr region, BoxPtr prect) +{ + return pixman_region_contains_rectangle(region, prect); +} + +/* TranslateRegion(pReg, x, y) + translates in place +*/ + +static inline void +RegionTranslate(RegionPtr pReg, int x, int y) +{ + pixman_region_translate(pReg, x, y); +} + +extern _X_EXPORT Bool RegionBreak(RegionPtr /*pReg */ ); + +static inline Bool +RegionContainsPoint(RegionPtr pReg, int x, int y, BoxPtr box /* "return" value */ + ) +{ + return pixman_region_contains_point(pReg, x, y, box); +} + +static inline Bool +RegionEqual(RegionPtr reg1, RegionPtr reg2) +{ + return pixman_region_equal(reg1, reg2); +} + +extern _X_EXPORT Bool RegionRectAlloc(RegionPtr /*pRgn */ , + int /*n */ + ); + +#ifdef DEBUG +extern _X_EXPORT Bool RegionIsValid(RegionPtr /*prgn */ + ); +#endif + +extern _X_EXPORT void RegionPrint(RegionPtr /*pReg */ ); + +#define INCLUDE_LEGACY_REGION_DEFINES +#ifdef INCLUDE_LEGACY_REGION_DEFINES + +#define REGION_NIL RegionNil +#define REGION_NUM_RECTS RegionNumRects +#define REGION_RECTS RegionRects +#define REGION_CREATE(pScreen, r, s) RegionCreate((r),(s)) +#define REGION_COPY(pScreen, d, r) RegionCopy((d), (r)) +#define REGION_DESTROY(pScreen, r) RegionDestroy((r)) +#define REGION_INTERSECT(pScreen, res, r1, r2) RegionIntersect((res), (r1), (r2)) +#define REGION_UNION(pScreen, res, r1, r2) RegionUnion((res), (r1), (r2)) +#define REGION_SUBTRACT(pScreen, res, r1, r2) RegionSubtract((res), (r1), (r2)) +#define REGION_TRANSLATE(pScreen, r, x, y) RegionTranslate((r), (x), (y)) +#define RECT_IN_REGION(pScreen, r, b) RegionContainsRect((r), (b)) +#define REGION_EQUAL(pScreen, r1, r2) RegionEqual((r1), (r2)) +#define RECTS_TO_REGION(pScreen, n, r, c) RegionFromRects((n), (r), (c)) +#define REGION_INIT(pScreen, r, b, s) RegionInit((r), (b), (s)) +#define REGION_UNINIT(pScreen, r) RegionUninit((r)) +#define REGION_RESET(pScreen, r, b) RegionReset((r), (b)) +#define REGION_NOTEMPTY(pScreen, r) RegionNotEmpty((r)) +#define REGION_EMPTY(pScreen, r) RegionEmpty((r)) +#define REGION_EXTENTS(pScreen, r) RegionExtents((r)) +#define REGION_NULL(pScreen, r) RegionNull((r)) + +#endif /* INCLUDE_LEGACY_REGION_DEFINES */ +#endif /* REGIONSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/resource.h b/prebuilt/xlibre/usr/include/xorg/resource.h new file mode 100644 index 0000000..783a4f2 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/resource.h @@ -0,0 +1,248 @@ +/*********************************************************** + +Copyright 1987, 1989, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef RESOURCE_H +#define RESOURCE_H 1 + +#include "xlibre_ptrtypes.h" + +#include "callback.h" +#include "misc.h" +#include "dixaccess.h" + +/***************************************************************** + * STUFF FOR RESOURCES + *****************************************************************/ + +/* classes for Resource routines */ + +typedef uint32_t RESTYPE; + +#define RC_VANILLA ((RESTYPE)0) +#define RC_CACHED ((RESTYPE)1<<31) +#define RC_DRAWABLE ((RESTYPE)1<<30) +/* Use class RC_NEVERRETAIN for resources that should not be retained + * regardless of the close down mode when the client dies. (A client's + * event selections on objects that it doesn't own are good candidates.) + * Extensions can use this too! + */ +#define RC_NEVERRETAIN ((RESTYPE)1<<29) +#define RC_LASTPREDEF RC_NEVERRETAIN +#define RC_ANY (~(RESTYPE)0) + +/* types for Resource routines */ + +// prevent namespace clash with Windows +#define X11_RESTYPE_NONE ((RESTYPE)0) +#define X11_RESTYPE_WINDOW ((RESTYPE)1|RC_DRAWABLE) +#define X11_RESTYPE_PIXMAP ((RESTYPE)2|RC_DRAWABLE) +#define X11_RESTYPE_GC ((RESTYPE)3) +#define X11_RESTYPE_FONT ((RESTYPE)4) +#define X11_RESTYPE_CURSOR ((RESTYPE)5) +#define X11_RESTYPE_COLORMAP ((RESTYPE)6) +#define X11_RESTYPE_CMAPENTRY ((RESTYPE)7) +#define X11_RESTYPE_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN) +#define X11_RESTYPE_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN) +#define X11_RESTYPE_LASTPREDEF ((RESTYPE)9) + +#define RT_WINDOW X11_RESTYPE_WINDOW +#define RT_PIXMAP X11_RESTYPE_PIXMAP +#define RT_GC X11_RESTYPE_GC +#undef RT_FONT +#undef RT_CURSOR +#define RT_FONT X11_RESTYPE_FONT +#define RT_CURSOR X11_RESTYPE_CURSOR +#define RT_COLORMAP X11_RESTYPE_COLORMAP +#define RT_CMAPENTRY X11_RESTYPE_CMAPENTRY +#define RT_OTHERCLIENT X11_RESTYPE_OTHERCLIENT +#define RT_PASSIVEGRAB X11_RESTYPE_PASSIVEGRAB +#define RT_LASTPREDEF X11_RESTYPE_LASTPREDEF +#define RT_NONE X11_RESTYPE_NONE + + +extern _X_EXPORT unsigned int ResourceClientBits(void); + +#define BAD_RESOURCE 0xe0000000 + +typedef int (*DeleteType) (void *value, + XID id); + +typedef void (*FindResType) (void *value, + XID id, + void *cdata); + +typedef void (*FindAllRes) (void *value, + XID id, + RESTYPE type, + void *cdata); + +typedef Bool (*FindComplexResType) (void *value, + XID id, + void *cdata); + +/* Structure for estimating resource memory usage. Memory usage + * consists of space allocated for the resource itself and of + * references to other resources. Currently the most important use for + * this structure is to estimate pixmap usage of different resources + * more accurately. */ +typedef struct { + /* Size of resource itself. Zero if not implemented. */ + unsigned long resourceSize; + /* Size attributed to pixmap references from the resource. */ + unsigned long pixmapRefSize; + /* Number of references to this resource; typically 1 */ + unsigned long refCnt; +} ResourceSizeRec, *ResourceSizePtr; + +typedef void (*SizeType)(void *value, + XID id, + ResourceSizePtr size); + +extern _X_EXPORT RESTYPE CreateNewResourceType(DeleteType deleteFunc, + const char *name); + +typedef void (*FindTypeSubResources)(void *value, + FindAllRes func, + void *cdata); + +extern _X_EXPORT SizeType GetResourceTypeSizeFunc( + RESTYPE /*type*/); + +extern _X_EXPORT void SetResourceTypeFindSubResFunc( + RESTYPE /*type*/, FindTypeSubResources /*findFunc*/); + +extern _X_EXPORT void SetResourceTypeSizeFunc( + RESTYPE /*type*/, SizeType /*sizeFunc*/); + +extern _X_EXPORT void SetResourceTypeErrorValue( + RESTYPE /*type*/, int /*errorValue*/); + +extern _X_EXPORT RESTYPE CreateNewResourceClass(void); + +extern _X_EXPORT Bool InitClientResources(ClientPtr /*client */ ); + +extern _X_EXPORT XID FakeClientID(int /*client */ ); + +/* Quartz support on Mac OS X uses the CarbonCore + framework whose AddResource function conflicts here. */ +#ifdef __APPLE__ +#define AddResource Darwin_X_AddResource +#endif +extern _X_EXPORT Bool AddResource(XID id, + RESTYPE type, + void *value); + +extern _X_EXPORT void FreeResource(XID /*id */ , + RESTYPE /*skipDeleteFuncType */ ); + +extern _X_EXPORT void FreeResourceByType(XID /*id */ , + RESTYPE /*type */ , + Bool /*skipFree */ ); + +extern _X_EXPORT Bool ChangeResourceValue(XID id, + RESTYPE rtype, + void *value); + +extern _X_EXPORT void FindClientResourcesByType(ClientPtr client, + RESTYPE type, + FindResType func, + void *cdata); + +extern _X_EXPORT void FindAllClientResources(ClientPtr client, + FindAllRes func, + void *cdata); + +/** @brief Iterate through all subresources of a resource. + + @note The XID argument provided to the FindAllRes function + may be 0 for subresources that don't have an XID */ +extern _X_EXPORT void FindSubResources(void *resource, + RESTYPE type, + FindAllRes func, + void *cdata); + +extern _X_EXPORT void FreeClientNeverRetainResources(ClientPtr /*client */ ); + +extern _X_EXPORT void FreeClientResources(ClientPtr /*client */ ); + +extern _X_EXPORT void FreeAllResources(void); + +extern _X_EXPORT Bool LegalNewID(XID /*id */ , + ClientPtr /*client */ ); + +extern _X_EXPORT void *LookupClientResourceComplex(ClientPtr client, + RESTYPE type, + FindComplexResType func, + void *cdata); + +extern _X_EXPORT int dixLookupResourceByType(void **result, + XID id, + RESTYPE rtype, + ClientPtr client, + Mask access_mode); + +extern _X_EXPORT int dixLookupResourceByClass(void **result, + XID id, + RESTYPE rclass, + ClientPtr client, + Mask access_mode); + +extern _X_EXPORT RESTYPE lastResourceType; +extern _X_EXPORT RESTYPE TypeMask; + +/* + * @brief allocate a XID (resource ID) for the server itself + * + * This is mostly for resource types that don't have their own API yet + * The XID is allocated within server's ID space and then can be used + * for registering a resource with it (@see AddResource()) + * + * @obsoletes FakeClientID + * @return XID the newly allocated XID + */ +_X_EXPORT XID dixAllocServerXID(void); + +#endif /* RESOURCE_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/rgb.h b/prebuilt/xlibre/usr/include/xorg/rgb.h new file mode 100644 index 0000000..449bc54 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/rgb.h @@ -0,0 +1,52 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef RGB_H +#define RGB_H +typedef struct _RGB { + unsigned short red, green, blue; +} RGB; +#endif /* RGB_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/rrtransform.h b/prebuilt/xlibre/usr/include/xorg/rrtransform.h new file mode 100644 index 0000000..0a03e11 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/rrtransform.h @@ -0,0 +1,61 @@ +/* + * Copyright © 2007 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _RRTRANSFORM_H_ +#define _RRTRANSFORM_H_ + +#include +#include "picturestr.h" + +typedef struct _rrTransform RRTransformRec, *RRTransformPtr; + +struct _rrTransform { + PictTransform transform; + struct pixman_f_transform f_transform; + struct pixman_f_transform f_inverse; + PictFilterPtr filter; + xFixed *params; + int nparams; + int width; + int height; +}; + +/* + * Compute the complete transformation matrix including + * client-specified transform, rotation/reflection values and the crtc + * offset. + * + * Return TRUE if the resulting transform is not a simple translation. + */ +extern _X_EXPORT Bool + +RRTransformCompute(int x, + int y, + int width, + int height, + Rotation rotation, + RRTransformPtr rr_transform, + PictTransformPtr transform, + struct pixman_f_transform *f_transform, + struct pixman_f_transform *f_inverse); + +#endif /* _RRTRANSFORM_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/sarea.h b/prebuilt/xlibre/usr/include/xorg/sarea.h new file mode 100644 index 0000000..1bef242 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/sarea.h @@ -0,0 +1,96 @@ +/** + * \file sarea.h + * SAREA definitions. + * + * \author Kevin E. Martin + * \author Jens Owen + * \author Rickard E. (Rik) Faith + */ + +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _SAREA_H_ +#define _SAREA_H_ + +#include "xf86drm.h" + +/* SAREA area needs to be at least a page */ +#if defined(__alpha__) +#define SAREA_MAX 0x2000 +#elif defined(__ia64__) +#define SAREA_MAX 0x10000 /* 64kB */ +#else +/* Intel 830M driver needs at least 8k SAREA */ +#define SAREA_MAX 0x2000 +#endif + +#define SAREA_MAX_DRAWABLES 256 + +#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000 + +/** + * SAREA per drawable information. + * + * \sa _XF86DRISAREA. + */ +typedef struct _XF86DRISAREADrawable { + unsigned int stamp; + unsigned int flags; +} XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr; + +/** + * SAREA frame information. + * + * \sa _XF86DRISAREA. + */ +typedef struct _XF86DRISAREAFrame { + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + unsigned int fullscreen; +} XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr; + +/** + * SAREA definition. + */ +typedef struct _XF86DRISAREA { + /** first thing is always the DRM locking structure */ + drmLock lock; + /** \todo Use readers/writer lock for drawable_lock */ + drmLock drawable_lock; + XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES]; + XF86DRISAREAFrameRec frame; + drm_context_t dummy_context; +} XF86DRISAREARec, *XF86DRISAREAPtr; + +typedef struct _XF86DRILSAREA { + drmLock lock; + drmLock otherLocks[31]; +} XF86DRILSAREARec, *XF86DRILSAREAPtr; + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/screenint.h b/prebuilt/xlibre/usr/include/xorg/screenint.h new file mode 100644 index 0000000..fc31304 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/screenint.h @@ -0,0 +1,62 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef SCREENINT_H +#define SCREENINT_H + +#include "misc.h" + +typedef struct _PixmapFormat *PixmapFormatPtr; +typedef struct _Visual *VisualPtr; +typedef struct _Depth *DepthPtr; +typedef struct _Screen *ScreenPtr; + +extern _X_EXPORT void AttachOutputGPU(ScreenPtr pScreen, ScreenPtr newScreen); +extern _X_EXPORT void DetachOutputGPU(ScreenPtr output); + +typedef struct _ColormapRec *ColormapPtr; + +#endif /* SCREENINT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/scrnintstr.h b/prebuilt/xlibre/usr/include/xorg/scrnintstr.h new file mode 100644 index 0000000..49278ee --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/scrnintstr.h @@ -0,0 +1,741 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef SCREENINTSTRUCT_H +#define SCREENINTSTRUCT_H + +#include "xlibre_ptrtypes.h" +#include "screenint.h" +#include "regionstr.h" +#include "colormap.h" +#include "cursor.h" +#include "validate.h" +#include +#include "dix.h" +#include "privates.h" +#include + +typedef struct _PixmapFormat { + unsigned char depth; + unsigned char bitsPerPixel; + unsigned char scanlinePad; +} PixmapFormatRec; + +typedef struct _Visual { + VisualID vid; + short class; + short bitsPerRGBValue; + short ColormapEntries; + short nplanes; /* = log2 (ColormapEntries). This does not + * imply that the screen has this many planes. + * it may have more or fewer */ + unsigned long redMask, greenMask, blueMask; + int offsetRed, offsetGreen, offsetBlue; +} VisualRec; + +typedef struct _Depth { + unsigned char depth; + short numVids; + VisualID *vids; /* block of visual ids for this depth */ +} DepthRec; + +typedef struct _ScreenSaverStuff { + WindowPtr pWindow; + XID wid; + char blanked; + Bool (*ExternalScreenSaver) (ScreenPtr /*pScreen */ , + int /*xstate */ , + Bool /*force */ ); +} ScreenSaverStuffRec, *ScreenSaverStuffPtr; + +typedef enum { + WINDOW_VRR_DISABLED = 0, + WINDOW_VRR_ENABLED, +} WindowVRRMode; + +/* + * There is a typedef for each screen function pointer so that code that + * needs to declare a screen function pointer (e.g. in a screen private + * or as a local variable) can easily do so and retain full type checking. + */ + +typedef Bool (*CloseScreenProcPtr) (ScreenPtr /*pScreen */ ); + +typedef void (*QueryBestSizeProcPtr) (int /*class */ , + unsigned short * /*pwidth */ , + unsigned short * /*pheight */ , + ScreenPtr /*pScreen */ ); + +typedef Bool (*SaveScreenProcPtr) (ScreenPtr /*pScreen */ , + int /*on */ ); + +typedef void (*GetImageProcPtr) (DrawablePtr /*pDrawable */ , + int /*sx */ , + int /*sy */ , + int /*w */ , + int /*h */ , + unsigned int /*format */ , + unsigned long /*planeMask */ , + char * /*pdstLine */ ); + +typedef void (*GetSpansProcPtr) (DrawablePtr /*pDrawable */ , + int /*wMax */ , + DDXPointPtr /*ppt */ , + int * /*pwidth */ , + int /*nspans */ , + char * /*pdstStart */ ); + +typedef void (*SourceValidateProcPtr) (DrawablePtr /*pDrawable */ , + int /*x */ , + int /*y */ , + int /*width */ , + int /*height */ , + unsigned int /*subWindowMode */ ); + +typedef Bool (*CreateWindowProcPtr) (WindowPtr /*pWindow */ ); + +typedef Bool (*DestroyWindowProcPtr) (WindowPtr /*pWindow */ ); + +typedef Bool (*PositionWindowProcPtr) (WindowPtr /*pWindow */ , + int /*x */ , + int /*y */ ); + +typedef Bool (*ChangeWindowAttributesProcPtr) (WindowPtr /*pWindow */ , + unsigned long /*mask */ ); + +typedef Bool (*RealizeWindowProcPtr) (WindowPtr /*pWindow */ ); + +typedef Bool (*UnrealizeWindowProcPtr) (WindowPtr /*pWindow */ ); + +typedef void (*RestackWindowProcPtr) (WindowPtr /*pWindow */ , + WindowPtr /*pOldNextSib */ ); + +typedef int (*ValidateTreeProcPtr) (WindowPtr /*pParent */ , + WindowPtr /*pChild */ , + VTKind /*kind */ ); + +typedef void (*PostValidateTreeProcPtr) (WindowPtr /*pParent */ , + WindowPtr /*pChild */ , + VTKind /*kind */ ); + +typedef void (*WindowExposuresProcPtr) (WindowPtr /*pWindow */ , + RegionPtr /*prgn */); + +typedef void (*PaintWindowProcPtr) (WindowPtr /*pWindow*/, + RegionPtr /*pRegion*/, + int /*what*/); + +typedef void (*CopyWindowProcPtr) (WindowPtr /*pWindow */ , + xPoint /*ptOldOrg */ , + RegionPtr /*prgnSrc */ ); + +typedef void (*ClearToBackgroundProcPtr) (WindowPtr /*pWindow */ , + int /*x */ , + int /*y */ , + int /*w */ , + int /*h */ , + Bool /*generateExposures */ ); + +typedef void (*ClipNotifyProcPtr) (WindowPtr /*pWindow */ , + int /*dx */ , + int /*dy */ ); + +typedef void (*SetWindowVRRModeProcPtr) (WindowPtr pWindow, WindowVRRMode mode); + +/* pixmap will exist only for the duration of the current rendering operation */ +#define CREATE_PIXMAP_USAGE_SCRATCH 1 +/* pixmap will be the backing pixmap for a redirected window */ +#define CREATE_PIXMAP_USAGE_BACKING_PIXMAP 2 +/* pixmap will contain a glyph */ +#define CREATE_PIXMAP_USAGE_GLYPH_PICTURE 3 +/* pixmap will be shared */ +#define CREATE_PIXMAP_USAGE_SHARED 4 + +typedef PixmapPtr (*CreatePixmapProcPtr) (ScreenPtr /*pScreen */ , + int /*width */ , + int /*height */ , + int /*depth */ , + unsigned /*usage_hint */ ); + +typedef Bool (*DestroyPixmapProcPtr) (PixmapPtr /*pPixmap */ ); + +typedef Bool (*RealizeFontProcPtr) (ScreenPtr /*pScreen */ , + FontPtr /*pFont */ ); + +typedef Bool (*UnrealizeFontProcPtr) (ScreenPtr /*pScreen */ , + FontPtr /*pFont */ ); + +typedef void (*ConstrainCursorProcPtr) (DeviceIntPtr /*pDev */ , + ScreenPtr /*pScreen */ , + BoxPtr /*pBox */ ); + +typedef void (*CursorLimitsProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + CursorPtr /*pCursor */ , + BoxPtr /*pHotBox */ , + BoxPtr /*pTopLeftBox */ ); + +typedef Bool (*DisplayCursorProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + CursorPtr /*pCursor */ ); + +typedef Bool (*RealizeCursorProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + CursorPtr /*pCursor */ ); + +typedef Bool (*UnrealizeCursorProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + CursorPtr /*pCursor */ ); + +typedef void (*RecolorCursorProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + CursorPtr /*pCursor */ , + Bool /*displayed */ ); + +typedef Bool (*SetCursorPositionProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + int /*x */ , + int /*y */ , + Bool /*generateEvent */ ); + +typedef void (*CursorWarpedToProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + ClientPtr /*pClient */ , + WindowPtr /*pWindow */ , + SpritePtr /*pSprite */ , + int /*x */ , + int /*y */ ); + +typedef void (*CursorConfinedToProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /*pScreen */ , + WindowPtr /*pWindow */ ); + +typedef Bool (*CreateGCProcPtr) (GCPtr /*pGC */ ); + +typedef Bool (*CreateColormapProcPtr) (ColormapPtr /*pColormap */ ); + +typedef void (*DestroyColormapProcPtr) (ColormapPtr /*pColormap */ ); + +typedef void (*InstallColormapProcPtr) (ColormapPtr /*pColormap */ ); + +typedef void (*UninstallColormapProcPtr) (ColormapPtr /*pColormap */ ); + +typedef int (*ListInstalledColormapsProcPtr) (ScreenPtr /*pScreen */ , + XID * /*pmaps */ ); + +typedef void (*StoreColorsProcPtr) (ColormapPtr /*pColormap */ , + int /*ndef */ , + xColorItem * /*pdef */ ); + +typedef void (*ResolveColorProcPtr) (unsigned short * /*pred */ , + unsigned short * /*pgreen */ , + unsigned short * /*pblue */ , + VisualPtr /*pVisual */ ); + +typedef RegionPtr (*BitmapToRegionProcPtr) (PixmapPtr /*pPix */ ); + +typedef void (*ScreenBlockHandlerProcPtr) (ScreenPtr pScreen, + void *timeout); + +/* result has three possible values: + * < 0 - error + * = 0 - timeout + * > 0 - activity + */ +typedef void (*ScreenWakeupHandlerProcPtr) (ScreenPtr pScreen, + int result); + +typedef Bool (*CreateScreenResourcesProcPtr) (ScreenPtr /*pScreen */ ); + +typedef Bool (*ModifyPixmapHeaderProcPtr) (PixmapPtr pPixmap, + int width, + int height, + int depth, + int bitsPerPixel, + int devKind, + void *pPixData); + +typedef PixmapPtr (*GetWindowPixmapProcPtr) (WindowPtr /*pWin */ ); + +typedef void (*SetWindowPixmapProcPtr) (WindowPtr /*pWin */ , + PixmapPtr /*pPix */ ); + +typedef PixmapPtr (*GetScreenPixmapProcPtr) (ScreenPtr /*pScreen */ ); + +typedef void (*SetScreenPixmapProcPtr) (PixmapPtr /*pPix */ ); + +typedef void (*MarkWindowProcPtr) (WindowPtr /*pWin */ ); + +typedef Bool (*MarkOverlappedWindowsProcPtr) (WindowPtr /*parent */ , + WindowPtr /*firstChild */ , + WindowPtr * /*pLayerWin */ ); + +typedef int (*ConfigNotifyProcPtr) (WindowPtr /*pWin */ , + int /*x */ , + int /*y */ , + int /*w */ , + int /*h */ , + int /*bw */ , + WindowPtr /*pSib */ ); + +typedef void (*MoveWindowProcPtr) (WindowPtr /*pWin */ , + int /*x */ , + int /*y */ , + WindowPtr /*pSib */ , + VTKind /*kind */ ); + +typedef void (*ResizeWindowProcPtr) (WindowPtr /*pWin */ , + int /*x */ , + int /*y */ , + unsigned int /*w */ , + unsigned int /*h */ , + WindowPtr /*pSib */ + ); + +typedef WindowPtr (*GetLayerWindowProcPtr) (WindowPtr /*pWin */ + ); + +typedef void (*HandleExposuresProcPtr) (WindowPtr /*pWin */ ); + +typedef void (*ReparentWindowProcPtr) (WindowPtr /*pWin */ , + WindowPtr /*pPriorParent */ ); + +typedef void (*SetShapeProcPtr) (WindowPtr /*pWin */ , + int /* kind */ ); + +typedef void (*ChangeBorderWidthProcPtr) (WindowPtr /*pWin */ , + unsigned int /*width */ ); + +typedef void (*MarkUnrealizedWindowProcPtr) (WindowPtr /*pChild */ , + WindowPtr /*pWin */ , + Bool /*fromConfigure */ ); + +typedef Bool (*DeviceCursorInitializeProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScreen */ ); + +typedef void (*DeviceCursorCleanupProcPtr) (DeviceIntPtr /* pDev */ , + ScreenPtr /* pScreen */ ); + +typedef void (*ConstrainCursorHarderProcPtr) (DeviceIntPtr, ScreenPtr, int, + int *, int *); + + +typedef Bool (*SharePixmapBackingProcPtr)(PixmapPtr, ScreenPtr, void **); + +typedef Bool (*SetSharedPixmapBackingProcPtr)(PixmapPtr, void *); + +#define HAS_SYNC_SHARED_PIXMAP 1 +/* The SyncSharedPixmap hook has two purposes: + * + * 1. If the primary driver has it, the secondary driver can use it to + * synchronize the shared pixmap contents with the screen pixmap. + * 2. If the secondary driver has it, the primary driver can expect the secondary + * driver to call the primary screen's SyncSharedPixmap hook, so the primary + * driver doesn't have to synchronize the shared pixmap contents itself, + * e.g. from the BlockHandler. + * + * A driver must only set the hook if it handles both cases correctly. + * + * The argument is the secondary screen's pixmap_dirty_list entry, the hook is + * responsible for finding the corresponding entry in the primary screen's + * pixmap_dirty_list. + */ +typedef void (*SyncSharedPixmapProcPtr)(PixmapDirtyUpdatePtr); + +typedef Bool (*StartPixmapTrackingProcPtr)(DrawablePtr, PixmapPtr, + int x, int y, + int dst_x, int dst_y, + Rotation rotation); + +typedef Bool (*PresentSharedPixmapProcPtr)(PixmapPtr); + +typedef Bool (*RequestSharedPixmapNotifyDamageProcPtr)(PixmapPtr); + +typedef Bool (*StopPixmapTrackingProcPtr)(DrawablePtr, PixmapPtr); + +typedef Bool (*StopFlippingPixmapTrackingProcPtr)(DrawablePtr, + PixmapPtr, PixmapPtr); + +typedef Bool (*SharedPixmapNotifyDamageProcPtr)(PixmapPtr); + +typedef Bool (*ReplaceScanoutPixmapProcPtr)(DrawablePtr, PixmapPtr, Bool); + +typedef WindowPtr (*XYToWindowProcPtr)(ScreenPtr pScreen, + SpritePtr pSprite, int x, int y); + +typedef int (*NameWindowPixmapProcPtr)(WindowPtr, PixmapPtr, CARD32); + +typedef void (*DPMSProcPtr)(ScreenPtr pScreen, int level); + +/* Wrapping Screen procedures + + There are a few modules in the X server which dynamically add and + remove themselves from various screen procedure call chains. + + For example, the BlockHandler is dynamically modified by: + + * xf86Rotate + * miSprite + * composite + * render (for animated cursors) + + Correctly manipulating this chain is complicated by the fact that + the chain is constructed through a sequence of screen private + structures, each holding the next screen->proc pointer. + + To add a module to a screen->proc chain is fairly simple; just save + the current screen->proc value in the module screen private + and store the module's function in the screen->proc location. + + Removing a screen proc is a bit trickier. It seems like all you + need to do is set the screen->proc pointer back to the value saved + in your screen private. However, if some other module has come + along and wrapped on top of you, then the right place to store the + previous screen->proc value is actually in the wrapping module's + screen private structure(!). Of course, you have no idea what + other module may have wrapped on top, nor could you poke inside + its screen private in any case. + + To make this work, we restrict the unwrapping process to happen + during the invocation of the screen proc itself, and then we + require the screen proc to take some care when manipulating the + screen proc functions pointers. + + The requirements are: + + 1) The screen proc must set the screen->proc pointer back to the + value saved in its screen private before calling outside its + module. + + 2a) If the screen proc wants to be remove itself from the chain, + it must not manipulate screen->proc pointer again before + returning. + + 2b) If the screen proc wants to remain in the chain, it must: + + 2b.1) Re-fetch the screen->proc pointer and store that in + its screen private. This ensures that any changes + to the chain will be preserved. + + 2b.2) Set screen->proc back to itself + + One key requirement here is that these steps must wrap not just + any invocation of the nested screen->proc value, but must nest + essentially any calls outside the current module. This ensures + that other modules can reliably manipulate screen->proc wrapping + using these same rules. + + For example, the animated cursor code in render has two macros, + Wrap and Unwrap. + + #define Unwrap(as,s,elt) ((s)->elt = (as)->elt) + + Unwrap takes the screen private (as), the screen (s) and the + member name (elt), and restores screen->proc to that saved in the + screen private. + + #define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func) + + Wrap takes the screen private (as), the screen (s), the member + name (elt) and the wrapping function (func). It saves the + current screen->proc value in the screen private, and then sets the + screen->proc to the local wrapping function. + + Within each of these functions, there's a pretty simple pattern: + + Unwrap(as, pScreen, UnrealizeCursor); + + // Do local stuff, including possibly calling down through + // pScreen->UnrealizeCursor + + Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor); + + The wrapping block handler is a bit different; it does the Unwrap, + the local operations, and then only re-Wraps if the hook is still + required. Unwrap occurs at the top of each function, just after + entry, and Wrap occurs at the bottom of each function, just + before returning. + + DestroyWindow() should NOT be wrapped anymore + use dixScreenHookWindowDestroy() instead. + */ + +typedef struct _Screen { + int myNum; /* index of this instance in Screens[] */ + ATOM id; + short x, y, width, height; + short mmWidth, mmHeight; + short numDepths; + unsigned char rootDepth; + DepthPtr allowedDepths; + unsigned long rootVisual; + unsigned long defColormap; + short minInstalledCmaps, maxInstalledCmaps; + char backingStoreSupport, saveUnderSupport; + unsigned long whitePixel, blackPixel; + GCPtr GCperDepth[MAXFORMATS + 1]; + /* next field is a stipple to use as default in a GC. we don't build + * default tiles of all depths because they are likely to be of a color + * different from the default fg pixel, so we don't win anything by + * building a standard one. + */ + PixmapPtr defaultStipple; + void *devPrivate; + short numVisuals; + VisualPtr visuals; + WindowPtr root; + ScreenSaverStuffRec screensaver; + + DevPrivateSetRec screenSpecificPrivates[PRIVATE_LAST]; + + /* Random screen procedures */ + + CloseScreenProcPtr CloseScreen; + QueryBestSizeProcPtr QueryBestSize; + SaveScreenProcPtr SaveScreen; + GetImageProcPtr GetImage; + GetSpansProcPtr GetSpans; + SourceValidateProcPtr SourceValidate; + + /* Window Procedures */ + + CreateWindowProcPtr CreateWindow; + DestroyWindowProcPtr DestroyWindow; + PositionWindowProcPtr PositionWindow; + ChangeWindowAttributesProcPtr ChangeWindowAttributes; + RealizeWindowProcPtr RealizeWindow; + UnrealizeWindowProcPtr UnrealizeWindow; + ValidateTreeProcPtr ValidateTree; + PostValidateTreeProcPtr PostValidateTree; + WindowExposuresProcPtr WindowExposures; + CopyWindowProcPtr CopyWindow; + ClearToBackgroundProcPtr ClearToBackground; + ClipNotifyProcPtr ClipNotify; + RestackWindowProcPtr RestackWindow; + PaintWindowProcPtr PaintWindow; + + /* Pixmap procedures */ + + CreatePixmapProcPtr CreatePixmap; + DestroyPixmapProcPtr DestroyPixmap; + + /* Font procedures */ + + RealizeFontProcPtr RealizeFont; + UnrealizeFontProcPtr UnrealizeFont; + + /* Cursor Procedures */ + + ConstrainCursorProcPtr ConstrainCursor; + ConstrainCursorHarderProcPtr ConstrainCursorHarder; + CursorLimitsProcPtr CursorLimits; + DisplayCursorProcPtr DisplayCursor; + RealizeCursorProcPtr RealizeCursor; + UnrealizeCursorProcPtr UnrealizeCursor; + RecolorCursorProcPtr RecolorCursor; + SetCursorPositionProcPtr SetCursorPosition; + CursorWarpedToProcPtr CursorWarpedTo; + CursorConfinedToProcPtr CursorConfinedTo; + + /* GC procedures */ + + CreateGCProcPtr CreateGC; + + /* Colormap procedures */ + + CreateColormapProcPtr CreateColormap; + DestroyColormapProcPtr DestroyColormap; + InstallColormapProcPtr InstallColormap; + UninstallColormapProcPtr UninstallColormap; + ListInstalledColormapsProcPtr ListInstalledColormaps; + StoreColorsProcPtr StoreColors; + ResolveColorProcPtr ResolveColor; + + /* Region procedures */ + + BitmapToRegionProcPtr BitmapToRegion; + + /* os layer procedures */ + + ScreenBlockHandlerProcPtr BlockHandler; + ScreenWakeupHandlerProcPtr WakeupHandler; + + /* anybody can get a piece of this array */ + PrivateRec *devPrivates; + + CreateScreenResourcesProcPtr CreateScreenResources; + ModifyPixmapHeaderProcPtr ModifyPixmapHeader; + + GetWindowPixmapProcPtr GetWindowPixmap; + SetWindowPixmapProcPtr SetWindowPixmap; + GetScreenPixmapProcPtr GetScreenPixmap; + SetScreenPixmapProcPtr SetScreenPixmap; + NameWindowPixmapProcPtr NameWindowPixmap; + +#ifdef CONFIG_LEGACY_NVIDIA_PADDING + /* This field is used by the 470 and 390 proprietary nvidia DDX driver, and should always be NULL */ + void* reserved_for_nvidia_470_and_390; +#endif + + unsigned int totalPixmapSize; + + MarkWindowProcPtr MarkWindow; + MarkOverlappedWindowsProcPtr MarkOverlappedWindows; + ConfigNotifyProcPtr ConfigNotify; + MoveWindowProcPtr MoveWindow; + ResizeWindowProcPtr ResizeWindow; + GetLayerWindowProcPtr GetLayerWindow; + HandleExposuresProcPtr HandleExposures; + ReparentWindowProcPtr ReparentWindow; + + SetShapeProcPtr SetShape; + + ChangeBorderWidthProcPtr ChangeBorderWidth; + MarkUnrealizedWindowProcPtr MarkUnrealizedWindow; + + /* Device cursor procedures */ + DeviceCursorInitializeProcPtr DeviceCursorInitialize; + DeviceCursorCleanupProcPtr DeviceCursorCleanup; + + /* set it in driver side if X server can copy the framebuffer content. + * Meant to be used together with '-background none' option, avoiding + * malicious users to steal framebuffer's content if that would be the + * default */ + Bool canDoBGNoneRoot; + + Bool isGPU; + + /* Info on this screen's secondarys (if any) */ + struct xorg_list secondary_list; + struct xorg_list secondary_head; + int output_secondarys; + /* Info for when this screen is a secondary */ + ScreenPtr current_primary; + Bool is_output_secondary; + Bool is_offload_secondary; + + SharePixmapBackingProcPtr SharePixmapBacking; + SetSharedPixmapBackingProcPtr SetSharedPixmapBacking; + + StartPixmapTrackingProcPtr StartPixmapTracking; + StopPixmapTrackingProcPtr StopPixmapTracking; + SyncSharedPixmapProcPtr SyncSharedPixmap; + + SharedPixmapNotifyDamageProcPtr SharedPixmapNotifyDamage; + RequestSharedPixmapNotifyDamageProcPtr RequestSharedPixmapNotifyDamage; + PresentSharedPixmapProcPtr PresentSharedPixmap; + StopFlippingPixmapTrackingProcPtr StopFlippingPixmapTracking; + + struct xorg_list pixmap_dirty_list; + + ReplaceScanoutPixmapProcPtr ReplaceScanoutPixmap; + XYToWindowProcPtr XYToWindow; + DPMSProcPtr DPMS; + + /* ===== below here is PRIVATE ==== drivers MUST NEVER touch it ===== */ + + /* additional window destructors (replaces wrapping DestroyWindow). + should NOT be touched outside of DIX core */ + CallbackListPtr hookWindowDestroy; + + /* additional window position notify hooks (replaces wrapping PositionWindow) + should NOT be touched outside of DIX core */ + CallbackListPtr hookWindowPosition; + + /* additional screen close notify hooks (replaces wrapping CloseScreen) + should NOT be touched outside of DIX core */ + CallbackListPtr hookClose; + + /* additional pixmap destroy notify hooks (replaces wrapping DestroyPixmap) + should NOT be touched outside of DIX core */ + CallbackListPtr hookPixmapDestroy; + + /* hooks run right after SUCCESSFUL CreateScreenResources + should NOT be touched outside of DIX core */ + CallbackListPtr hookPostCreateResources; + + SetWindowVRRModeProcPtr SetWindowVRRMode; + + /* additional screen post-close notify hooks (replaces wrapping CloseScreen) + should NOT be touched outside of DIX core */ + CallbackListPtr hookPostClose; + + /* xfixes cursor hiding -- this might deserve further optimization */ + struct { + DisplayCursorProcPtr DisplayCursor; /* original proc (for wrapping) */ + struct _CursorHideCountRec *pCursorHideCounts; + } xfixes; +} ScreenRec; + +static inline RegionPtr +BitmapToRegion(ScreenPtr _pScreen, PixmapPtr pPix) +{ + return (*(_pScreen)->BitmapToRegion) (pPix); /* no mi version?! */ +} + +typedef struct _ScreenInfo { + int imageByteOrder; + int bitmapScanlineUnit; + int bitmapScanlinePad; + int bitmapBitOrder; + int numPixmapFormats; + PixmapFormatRec formats[MAXFORMATS]; + int numScreens; + ScreenPtr screens[MAXSCREENS]; + int numGPUScreens; + ScreenPtr gpuscreens[MAXGPUSCREENS]; + int x; /* origin */ + int y; /* origin */ + int width; /* total width of all screens together */ + int height; /* total height of all screens together */ + + /* beyond here, NOT part of ABI */ + int numRoots; /* client-visible numer, usually equals numScreens, except for Xinerama etc */ +} ScreenInfo; + +extern _X_EXPORT ScreenInfo screenInfo; + +#endif /* SCREENINTSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/servermd.h b/prebuilt/xlibre/usr/include/xorg/servermd.h new file mode 100644 index 0000000..ffb8f6a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/servermd.h @@ -0,0 +1,107 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef SERVERMD_H +#define SERVERMD_H 1 + +#include +#include /* for X_LITTLE_ENDIAN/X_BIG_ENDIAN */ + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN +#define IMAGE_BYTE_ORDER LSBFirst +#define BITMAP_BIT_ORDER LSBFirst +#elif X_BYTE_ORDER == X_BIG_ENDIAN +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#else +#error "Too weird to live." +#endif + +#define BITMAP_SCANLINE_PAD 32 +#define LOG2_BITMAP_PAD 5 +#define LOG2_BYTES_PER_SCANLINE_PAD 2 + +#include +/* + * This returns the number of padding units, for depth d and width w. + * For bitmaps this can be calculated with the macros above. + * Other depths require either grovelling over the formats field of the + * screenInfo or hardwired constants. + */ + +typedef struct _PaddingInfo { + int padRoundUp; /* pixels per pad unit - 1 */ + int padPixelsLog2; /* log 2 (pixels per pad unit) */ + int padBytesLog2; /* log 2 (bytes per pad unit) */ + int notPower2; /* bitsPerPixel not a power of 2 */ + int bytesPerPixel; /* only set when notPower2 is TRUE */ + int bitsPerPixel; /* bits per pixel */ +} PaddingInfo; +extern _X_EXPORT PaddingInfo PixmapWidthPaddingInfo[]; + +/* The only portable way to get the bpp from the depth is to look it up */ +#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel) + +#define PixmapWidthInPadUnits(w, d) \ + (PixmapWidthPaddingInfo[d].notPower2 ? \ + (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \ + PixmapWidthPaddingInfo[d].bytesPerPixel) >> \ + PixmapWidthPaddingInfo[d].padBytesLog2) : \ + ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \ + PixmapWidthPaddingInfo[d].padPixelsLog2)) + +/* + * Return the number of bytes to which a scanline of the given + * depth and width will be padded. + */ +#define PixmapBytePad(w, d) \ + (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2) + +static inline size_t BitmapBytePad(size_t w) { + return ((((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD); +} + +#endif /* SERVERMD_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/shadow.h b/prebuilt/xlibre/usr/include/xorg/shadow.h new file mode 100644 index 0000000..88587b1 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/shadow.h @@ -0,0 +1,155 @@ +/* + * + * Copyright © 2000 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SHADOW_H_ +#define _SHADOW_H_ + +#include "scrnintstr.h" + +#include "picturestr.h" + +#include "damage.h" +#include "damagestr.h" +typedef struct _shadowBuf *shadowBufPtr; + +typedef void (*ShadowUpdateProc) (ScreenPtr pScreen, shadowBufPtr pBuf); + +#define SHADOW_WINDOW_RELOCATE 1 +#define SHADOW_WINDOW_READ 2 +#define SHADOW_WINDOW_WRITE 4 + +typedef void *(*ShadowWindowProc) (ScreenPtr pScreen, + CARD32 row, + CARD32 offset, + int mode, CARD32 *size, void *closure); + +typedef struct _shadowBuf { + DamagePtr pDamage; + ShadowUpdateProc update; + ShadowWindowProc window; + PixmapPtr pPixmap; + void *closure; + int randr; + + /* screen wrappers */ + GetImageProcPtr GetImage; + void *_dummy1; // required in place of a removed field for ABI compatibility + ScreenBlockHandlerProcPtr BlockHandler; +} shadowBufRec; + +/* Match defines from randr extension */ +#define SHADOW_ROTATE_0 1 +#define SHADOW_ROTATE_90 2 +#define SHADOW_ROTATE_180 4 +#define SHADOW_ROTATE_270 8 +#define SHADOW_ROTATE_ALL (SHADOW_ROTATE_0|SHADOW_ROTATE_90|\ + SHADOW_ROTATE_180|SHADOW_ROTATE_270) +#define SHADOW_REFLECT_X 16 +#define SHADOW_REFLECT_Y 32 +#define SHADOW_REFLECT_ALL (SHADOW_REFLECT_X|SHADOW_REFLECT_Y) + +extern _X_EXPORT Bool + shadowSetup(ScreenPtr pScreen); + +extern _X_EXPORT Bool + +shadowAdd(ScreenPtr pScreen, + PixmapPtr pPixmap, + ShadowUpdateProc update, + ShadowWindowProc window, int randr, void *closure); + +extern _X_EXPORT void + shadowRemove(ScreenPtr pScreen, PixmapPtr pPixmap); + +extern _X_EXPORT void + shadowUpdateAfb4(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateAfb8(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateIplan2p4(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateIplan2p8(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdatePlanar4(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdatePlanar4x8(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotatePacked(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate8_90(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate16_90(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate16_90YX(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate32_90(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate8_180(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate16_180(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate32_180(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate8_270(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate16_270(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate16_270YX(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate32_270(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate8(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate16(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdateRotate32(ScreenPtr pScreen, shadowBufPtr pBuf); + +extern _X_EXPORT void + shadowUpdate32to24(ScreenPtr pScreen, shadowBufPtr pBuf); + +typedef void (*shadowUpdateProc) (ScreenPtr, shadowBufPtr); + +#endif /* _SHADOW_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/shadowfb.h b/prebuilt/xlibre/usr/include/xorg/shadowfb.h new file mode 100644 index 0000000..b3dd448 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/shadowfb.h @@ -0,0 +1,39 @@ + +#ifndef _SHADOWFB_H +#define _SHADOWFB_H + +#include "xf86str.h" + +/* + * User defined callback function. Passed a pointer to the ScrnInfo struct, + * the number of dirty rectangles, and a pointer to the first dirty rectangle + * in the array. + */ +typedef void (*RefreshAreaFuncPtr) (ScrnInfoPtr, int, BoxPtr); + +/* + * ShadowFBInit initializes the shadowfb subsystem. refreshArea is a pointer + * to a user supplied callback function. This function will be called after + * any operation that modifies the framebuffer. The newly dirtied rectangles + * are passed to the callback. + * + * Returns FALSE in the event of an error. + */ +extern _X_EXPORT Bool + ShadowFBInit(ScreenPtr pScreen, RefreshAreaFuncPtr refreshArea); + +/* + * ShadowFBInit2 is a more featureful refinement of the original shadowfb. + * ShadowFBInit2 allows you to specify two callbacks, one to be called + * immediately before an operation that modifies the framebuffer, and another + * to be called immediately after. + * + * Returns FALSE in the event of an error + */ +extern _X_EXPORT Bool + +ShadowFBInit2(ScreenPtr pScreen, + RefreshAreaFuncPtr preRefreshArea, + RefreshAreaFuncPtr postRefreshArea); + +#endif /* _SHADOWFB_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/shmint.h b/prebuilt/xlibre/usr/include/xorg/shmint.h new file mode 100644 index 0000000..1cd8a77 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/shmint.h @@ -0,0 +1,76 @@ +/* + * Copyright © 2003 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SHMINT_H_ +#define _SHMINT_H_ + +#include +#include + +#include "screenint.h" +#include "pixmap.h" +#include "gc.h" + +#define XSHM_PUT_IMAGE_ARGS \ + DrawablePtr /* dst */, \ + GCPtr /* pGC */, \ + int /* depth */, \ + unsigned int /* format */, \ + int /* w */, \ + int /* h */, \ + int /* sx */, \ + int /* sy */, \ + int /* sw */, \ + int /* sh */, \ + int /* dx */, \ + int /* dy */, \ + char * /* data */ + +#define XSHM_CREATE_PIXMAP_ARGS \ + ScreenPtr /* pScreen */, \ + int /* width */, \ + int /* height */, \ + int /* depth */, \ + char * /* addr */ + +typedef struct _ShmFuncs { + PixmapPtr (*CreatePixmap) (XSHM_CREATE_PIXMAP_ARGS); + void (*PutImage) (XSHM_PUT_IMAGE_ARGS); +} ShmFuncs, *ShmFuncsPtr; + +#if XTRANS_SEND_FDS +#define SHM_FD_PASSING 1 +#endif + +#ifdef SHM_FD_PASSING +#define SHMDESC_IS_FD(shmdesc) ((shmdesc)->is_fd) +#else +#define SHMDESC_IS_FD(shmdesc) (0) +#endif + +_X_EXPORT void ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs); +_X_EXPORT void ShmRegisterFbFuncs(ScreenPtr pScreen); + +extern _X_EXPORT int ShmCompletionCode; +extern _X_EXPORT int BadShmSegCode; + +#endif /* _SHMINT_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/syncsdk.h b/prebuilt/xlibre/usr/include/xorg/syncsdk.h new file mode 100644 index 0000000..82299cf --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/syncsdk.h @@ -0,0 +1,49 @@ +/* + * Copyright © 2010 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef _SYNCSDK_H_ +#define _SYNCSDK_H_ + +#include "misync.h" + +extern _X_EXPORT int + SyncVerifyFence(SyncFence ** ppFence, XID fid, ClientPtr client, Mask mode); + +extern _X_EXPORT SyncObject* + SyncCreate(ClientPtr client, XID id, unsigned char type); + +#define VERIFY_SYNC_FENCE(pFence, fid, client, mode) \ + do { \ + int rc; \ + rc = SyncVerifyFence(&(pFence), (fid), (client), (mode)); \ + if (Success != rc) return rc; \ + } while (0) + +#define VERIFY_SYNC_FENCE_OR_NONE(pFence, fid, client, mode) \ + do { \ + (pFence) = 0; \ + if (None != (fid)) \ + VERIFY_SYNC_FENCE((pFence), (fid), (client), (mode)); \ + } while (0) + +#endif /* _SYNCSDK_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/validate.h b/prebuilt/xlibre/usr/include/xorg/validate.h new file mode 100644 index 0000000..8fcc8b8 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/validate.h @@ -0,0 +1,40 @@ + +/* + +Copyright 1989, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. +*/ + +#ifndef VALIDATE_H +#define VALIDATE_H + +#include "miscstruct.h" +#include "regionstr.h" + +typedef enum { VTOther, VTStack, VTMove, VTUnmap, VTMap, VTBroken } VTKind; + +/* union _MiValidate is now device dependent; see mivalidate.h for an example */ +typedef union _MiValidate *ValidatePtr; + +#define UnmapValData ((ValidatePtr)1) + +#endif /* VALIDATE_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/vgaHW.h b/prebuilt/xlibre/usr/include/xorg/vgaHW.h new file mode 100644 index 0000000..f03024a --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/vgaHW.h @@ -0,0 +1,217 @@ + +/* + * Copyright (c) 1997,1998 The XFree86 Project, Inc. + * + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Author: Dirk Hohndel + */ + +#ifndef _VGAHW_H +#define _VGAHW_H + +#include +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86str.h" +#include "xf86Pci.h" + +#include "xf86DDC.h" + +#include "globals.h" +#include + +extern _X_EXPORT int vgaHWGetIndex(void); + +/* + * access macro + */ +#define VGAHWPTR(p) ((vgaHWPtr)((p)->privates[vgaHWGetIndex()].ptr)) + +/* Standard VGA registers */ +#define VGA_ATTR_INDEX 0x3C0 +#define VGA_ATTR_DATA_W 0x3C0 +#define VGA_ATTR_DATA_R 0x3C1 +#define VGA_IN_STAT_0 0x3C2 /* read */ +#define VGA_MISC_OUT_W 0x3C2 /* write */ +#define VGA_ENABLE 0x3C3 +#define VGA_SEQ_INDEX 0x3C4 +#define VGA_SEQ_DATA 0x3C5 +#define VGA_DAC_MASK 0x3C6 +#define VGA_DAC_READ_ADDR 0x3C7 +#define VGA_DAC_WRITE_ADDR 0x3C8 +#define VGA_DAC_DATA 0x3C9 +#define VGA_FEATURE_R 0x3CA /* read */ +#define VGA_MISC_OUT_R 0x3CC /* read */ +#define VGA_GRAPH_INDEX 0x3CE +#define VGA_GRAPH_DATA 0x3CF + +#define VGA_IOBASE_MONO 0x3B0 +#define VGA_IOBASE_COLOR 0x3D0 + +#define VGA_CRTC_INDEX_OFFSET 0x04 +#define VGA_CRTC_DATA_OFFSET 0x05 +#define VGA_IN_STAT_1_OFFSET 0x0A /* read */ +#define VGA_FEATURE_W_OFFSET 0x0A /* write */ + +/* default number of VGA registers stored internally */ +#define VGA_NUM_CRTC 25 +#define VGA_NUM_SEQ 5 +#define VGA_NUM_GFX 9 +#define VGA_NUM_ATTR 21 + +/* Flags for vgaHWSave() and vgaHWRestore() */ +#define VGA_SR_MODE 0x01 +#define VGA_SR_FONTS 0x02 +#define VGA_SR_CMAP 0x04 +#define VGA_SR_ALL (VGA_SR_MODE | VGA_SR_FONTS | VGA_SR_CMAP) + +/* Defaults for the VGA memory window */ +#define VGA_DEFAULT_PHYS_ADDR 0xA0000 +#define VGA_DEFAULT_MEM_SIZE (64 * 1024) + +/* + * vgaRegRec contains settings of standard VGA registers. + */ +typedef struct { + unsigned char MiscOutReg; /* */ + unsigned char *CRTC; /* Crtc Controller */ + unsigned char *Sequencer; /* Video Sequencer */ + unsigned char *Graphics; /* Video Graphics */ + unsigned char *Attribute; /* Video Attribute */ + unsigned char DAC[768]; /* Internal Colorlookuptable */ + unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */ + unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */ + unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */ + unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */ +} vgaRegRec, *vgaRegPtr; + +typedef struct _vgaHWRec *vgaHWPtr; + +typedef void (*vgaHWWriteIndexProcPtr) (vgaHWPtr hwp, CARD8 indx, CARD8 value); +typedef CARD8 (*vgaHWReadIndexProcPtr) (vgaHWPtr hwp, CARD8 indx); +typedef void (*vgaHWWriteProcPtr) (vgaHWPtr hwp, CARD8 value); +typedef CARD8 (*vgaHWReadProcPtr) (vgaHWPtr hwp); +typedef void (*vgaHWMiscProcPtr) (vgaHWPtr hwp); + +/* + * vgaHWRec contains per-screen information required by the vgahw module. + * + * Note, the palette referred to by the paletteEnabled, enablePalette and + * disablePalette is the 16-entry (+overscan) EGA-compatible palette accessed + * via the first 17 attribute registers and not the main 8-bit palette. + */ +typedef struct _vgaHWRec { + void *Base; /* Address of "VGA" memory */ + int MapSize; /* Size of "VGA" memory */ + unsigned long MapPhys; /* phys location of VGA mem */ + int IOBase; /* I/O Base address */ + CARD8 *MMIOBase; /* Pointer to MMIO start */ + int MMIOOffset; /* base + offset + vgareg + = mmioreg */ + void *FontInfo1; /* save area for fonts in + plane 2 */ + void *FontInfo2; /* save area for fonts in + plane 3 */ + void *TextInfo; /* save area for text */ + vgaRegRec SavedReg; /* saved registers */ + vgaRegRec ModeReg; /* register settings for + current mode */ + Bool ShowOverscan; + Bool paletteEnabled; + Bool cmapSaved; + ScrnInfoPtr pScrn; + vgaHWWriteIndexProcPtr writeCrtc; + vgaHWReadIndexProcPtr readCrtc; + vgaHWWriteIndexProcPtr writeGr; + vgaHWReadIndexProcPtr readGr; + vgaHWReadProcPtr readST00; + vgaHWReadProcPtr readST01; + vgaHWReadProcPtr readFCR; + vgaHWWriteProcPtr writeFCR; + vgaHWWriteIndexProcPtr writeAttr; + vgaHWReadIndexProcPtr readAttr; + vgaHWWriteIndexProcPtr writeSeq; + vgaHWReadIndexProcPtr readSeq; + vgaHWWriteProcPtr writeMiscOut; + vgaHWReadProcPtr readMiscOut; + vgaHWMiscProcPtr enablePalette; + vgaHWMiscProcPtr disablePalette; + vgaHWWriteProcPtr writeDacMask; + vgaHWReadProcPtr readDacMask; + vgaHWWriteProcPtr writeDacWriteAddr; + vgaHWWriteProcPtr writeDacReadAddr; + vgaHWWriteProcPtr writeDacData; + vgaHWReadProcPtr readDacData; + void *ddc; + struct pci_io_handle *io; + vgaHWReadProcPtr readEnable; + vgaHWWriteProcPtr writeEnable; + struct pci_device *dev; +} vgaHWRec; + +/* Some macros that VGA drivers can use in their ChipProbe() function */ +#define OVERSCAN 0x11 /* Index of OverScan register */ + +/* Flags that define how overscan correction should take place */ +#define KGA_FIX_OVERSCAN 1 /* overcan correction required */ +#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */ + /* of next scanline/frame */ +#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */ + /* to total - 1 */ +#define BIT_PLANE 3 /* Which plane we write to in mono mode */ +#define BITS_PER_GUN 6 +#define COLORMAP_SIZE 256 + +#define DACDelay(hw) \ + do { \ + (hw)->readST01((hw)); \ + (hw)->readST01((hw)); \ + } while (0) + +/* Function Prototypes */ + +/* vgaHW.c */ +extern _X_EXPORT void vgaHWSetStdFuncs(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset); +extern _X_EXPORT void vgaHWProtect(ScrnInfoPtr pScrn, Bool on); +extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode); +extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on); +extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start); +_X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr pScrnInfo, vgaRegPtr restore); +_X_EXPORT void vgaHWRestore(ScrnInfoPtr pScrnInfo, vgaRegPtr restore, int flags); +_X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr pScrnInfo, vgaRegPtr save); +_X_EXPORT void vgaHWSave(ScrnInfoPtr pScrnInfo, vgaRegPtr save, int flags); +extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode); +extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src); +extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp); +extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp); +extern _X_EXPORT Bool vgaHWMapMem(ScrnInfoPtr scrp); +extern _X_EXPORT void vgaHWUnmapMem(ScrnInfoPtr scrp); +extern _X_EXPORT void vgaHWGetIOBase(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, + int flags); +extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen); +extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed); +extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, + int nBits, unsigned int Flags); +extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, + int nBits, unsigned int Flags); +extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp); + +extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void); +extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, + Bool (*ClockFunc) (ScrnInfoPtr, int), + void (*ProtectRegs) (ScrnInfoPtr, Bool), + void (*BlankScreen) (ScrnInfoPtr, Bool), + unsigned long vertsyncreg, int maskval, + int knownclkindex, int knownclkvalue); + +#endif /* _VGAHW_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/vndserver.h b/prebuilt/xlibre/usr/include/xorg/vndserver.h new file mode 100644 index 0000000..181288c --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/vndserver.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016, NVIDIA CORPORATION. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * unaltered in all copies or substantial portions of the Materials. + * Any additions, deletions, or changes to the original source files + * must be clearly indicated in accompanying documentation. + * + * If only executable code is distributed, then the accompanying + * documentation must state that "this software is based in part on the + * work of the Khronos Group." + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + */ + +#ifndef VNDSERVER_H +#define VNDSERVER_H + +#include +#include "glxvndabi.h" + +#define GLXContextID CARD32 +#define GLXDrawable CARD32 + +_X_EXPORT const GlxServerExports *glvndGetExports(void); + +#endif // VNDSERVER_H diff --git a/prebuilt/xlibre/usr/include/xorg/wfbrename.h b/prebuilt/xlibre/usr/include/xorg/wfbrename.h new file mode 100644 index 0000000..6765dbc --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/wfbrename.h @@ -0,0 +1,125 @@ +#ifndef XSERVER_WFBRENAME_H +#define XSERVER_WFBRENAME_H + +#define fbAddTraps wfbAddTraps +#define fbAddTriangles wfbAddTriangles +#define fbAllocatePrivates wfbAllocatePrivates +#define fbArc16 wfbArc16 +#define fbArc32 wfbArc32 +#define fbArc8 wfbArc8 +#define fbBlt wfbBlt +#define fbBltOne wfbBltOne +#define fbBltPlane wfbBltPlane +#define fbBltStip wfbBltStip +#define fbBres wfbBres +#define fbBresDash wfbBresDash +#define fbBresDash16 wfbBresDash16 +#define fbBresDash32 wfbBresDash32 +#define fbBresDash8 wfbBresDash8 +#define fbBresFill wfbBresFill +#define fbBresFillDash wfbBresFillDash +#define fbBresSolid wfbBresSolid +#define fbBresSolid16 wfbBresSolid16 +#define fbBresSolid32 wfbBresSolid32 +#define fbBresSolid8 wfbBresSolid8 +#define fbChangeWindowAttributes wfbChangeWindowAttributes +#define fbClearVisualTypes wfbClearVisualTypes +#define fbCloseScreen wfbCloseScreen +#define fbComposite wfbComposite +#define fbCopy1toN wfbCopy1toN +#define fbCopyArea wfbCopyArea +#define fbCopyNto1 wfbCopyNto1 +#define fbCopyNtoN wfbCopyNtoN +#define fbCopyPlane wfbCopyPlane +#define fbCopyRegion wfbCopyRegion +#define fbCopyWindow wfbCopyWindow +#define fbCopyWindowProc wfbCopyWindowProc +#define fbCreateDefColormap wfbCreateDefColormap +#define fbCreateGC wfbCreateGC +#define fbCreatePixmap wfbCreatePixmap +#define fbCreateWindow wfbCreateWindow +#define fbDestroyGlyphCache wfbDestroyGlyphCache +#define fbDestroyPixmap wfbDestroyPixmap +#define fbDestroyWindow wfbDestroyWindow +#define fbDoCopy wfbDoCopy +#define fbDots wfbDots +#define fbDots16 wfbDots16 +#define fbDots32 wfbDots32 +#define fbDots8 wfbDots8 +#define fbEvenTile wfbEvenTile +#define fbExpandDirectColors wfbExpandDirectColors +#define fbFill wfbFill +#define fbFillRegionSolid wfbFillRegionSolid +#define fbFillSpans wfbFillSpans +#define fbFixCoordModePrevious wfbFixCoordModePrevious +#define fbGCFuncs wfbGCFuncs +#define fbGCOps wfbGCOps +#define fbGetGCPrivateKey wfbGetGCPrivateKey +#define fbGetImage wfbGetImage +#define fbGetScreenPrivateKey wfbGetScreenPrivateKey +#define fbGetSpans wfbGetSpans +#define _fbGetWindowPixmap _wfbGetWindowPixmap +#define fbGlyph16 wfbGlyph16 +#define fbGlyph32 wfbGlyph32 +#define fbGlyph8 wfbGlyph8 +#define fbImageGlyphBlt wfbImageGlyphBlt +#define fbIn wfbIn +#define fbInitializeColormap wfbInitializeColormap +#define fbInitVisuals wfbInitVisuals +#define fbListInstalledColormaps wfbListInstalledColormaps +#define FbMergeRopBits wFbMergeRopBits +#define fbOddTile wfbOddTile +#define fbOver wfbOver +#define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit +#define fbOverlayGeneration wfbOverlayGeneration +#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey +#define fbPadPixmap wfbPadPixmap +#define fbPictureInit wfbPictureInit +#define fbPixmapToRegion wfbPixmapToRegion +#define fbPolyArc wfbPolyArc +#define fbPolyFillRect wfbPolyFillRect +#define fbPolyGlyphBlt wfbPolyGlyphBlt +#define fbPolyLine wfbPolyLine +#define fbPolyline16 wfbPolyline16 +#define fbPolyline32 wfbPolyline32 +#define fbPolyline8 wfbPolyline8 +#define fbPolyPoint wfbPolyPoint +#define fbPolySegment wfbPolySegment +#define fbPolySegment16 wfbPolySegment16 +#define fbPolySegment32 wfbPolySegment32 +#define fbPolySegment8 wfbPolySegment8 +#define fbPositionWindow wfbPositionWindow +#define fbPushFill wfbPushFill +#define fbPushImage wfbPushImage +#define fbPushPattern wfbPushPattern +#define fbPushPixels wfbPushPixels +#define fbPutImage wfbPutImage +#define fbPutXYImage wfbPutXYImage +#define fbPutZImage wfbPutZImage +#define fbQueryBestSize wfbQueryBestSize +#define fbRasterizeTrapezoid wfbRasterizeTrapezoid +#define fbRealizeFont wfbRealizeFont +#define fbReplicatePixel wfbReplicatePixel +#define fbResolveColor wfbResolveColor +#define fbScreenPrivateKeyRec wfbScreenPrivateKeyRec +#define fbSegment wfbSegment +#define fbSelectBres wfbSelectBres +#define fbSetSpans wfbSetSpans +#define fbSetupScreen wfbSetupScreen +#define fbSetVisualTypes wfbSetVisualTypes +#define fbSetVisualTypesAndMasks wfbSetVisualTypesAndMasks +#define _fbSetWindowPixmap _wfbSetWindowPixmap +#define fbSolid wfbSolid +#define fbSolidBoxClipped wfbSolidBoxClipped +#define fbTile wfbTile +#define fbTrapezoids wfbTrapezoids +#define fbTriangles wfbTriangles +#define fbUninstallColormap wfbUninstallColormap +#define fbUnrealizeWindow wfbUnrealizeWindow +#define fbUnrealizeFont wfbUnrealizeFont +#define fbValidateGC wfbValidateGC +#define fbWinPrivateKeyRec wfbWinPrivateKeyRec +#define free_pixman_pict wfb_free_pixman_pict +#define image_from_pict wfb_image_from_pict + +#endif /* XSERVER_WFBRENAME_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/window.h b/prebuilt/xlibre/usr/include/xorg/window.h new file mode 100644 index 0000000..6487fb6 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/window.h @@ -0,0 +1,217 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include + +#include "xlibre_ptrtypes.h" +#include "misc.h" +#include "regionstr.h" +#include "screenint.h" + +#define TOTALLY_OBSCURED 0 +#define UNOBSCURED 1 +#define OBSCURED 2 + +#define VisibilityNotViewable 3 + +/* return values for tree-walking callback procedures */ +#define WT_STOPWALKING 0 +#define WT_WALKCHILDREN 1 +#define WT_DONTWALKCHILDREN 2 +#define WT_NOMATCH 3 +#define NullWindow ((WindowPtr) 0) + +/* Forward declaration, we can't include input.h here */ +struct _Cursor; + +typedef struct _BackingStore *BackingStorePtr; +typedef struct _Property *PropertyPtr; + +enum RootClipMode { + ROOT_CLIP_NONE = 0, /**< resize the root window to 0x0 */ + ROOT_CLIP_FULL = 1, /**< resize the root window to fit screen */ + ROOT_CLIP_INPUT_ONLY = 2, /**< as above, but no rendering to screen */ +}; + +typedef int (*VisitWindowProcPtr) (WindowPtr pWin, + void *data); + +extern _X_EXPORT int TraverseTree(WindowPtr pWin, + VisitWindowProcPtr func, + void *data); + +extern _X_EXPORT int WalkTree(ScreenPtr pScreen, + VisitWindowProcPtr func, + void *data); + +extern _X_EXPORT Bool CreateRootWindow(ScreenPtr /*pScreen */ ); + +extern _X_EXPORT void InitRootWindow(WindowPtr /*pWin */ ); + +typedef WindowPtr (*RealChildHeadProc) (WindowPtr pWin); + +extern _X_EXPORT void RegisterRealChildHeadProc(RealChildHeadProc proc); + +extern _X_EXPORT WindowPtr RealChildHead(WindowPtr /*pWin */ ); + +extern _X_EXPORT int DeleteWindow(void *pWin, + XID wid); + +extern _X_EXPORT int DestroySubwindows(WindowPtr /*pWin */ , + ClientPtr /*client */ ); + +/* Quartz support on Mac OS X uses the HIToolbox + framework whose ChangeWindowAttributes function conflicts here. */ +#ifdef __APPLE__ +#define ChangeWindowAttributes Darwin_X_ChangeWindowAttributes +#endif +extern _X_EXPORT int ChangeWindowAttributes(WindowPtr /*pWin */ , + Mask /*vmask */ , + XID * /*vlist */ , + ClientPtr /*client */ ); + +extern _X_EXPORT int ChangeWindowDeviceCursor(WindowPtr /*pWin */ , + DeviceIntPtr /*pDev */ , + struct _Cursor * /*pCursor */ ); + +extern _X_EXPORT struct _Cursor *WindowGetDeviceCursor(WindowPtr /*pWin */ , + DeviceIntPtr + /*pDev */ ); + +/* Quartz support on Mac OS X uses the HIToolbox + framework whose GetWindowAttributes function conflicts here. */ +#ifdef __APPLE__ +#define GetWindowAttributes(w,c,x) Darwin_X_GetWindowAttributes((w),(c),(x)) +extern void Darwin_X_GetWindowAttributes( +#else +extern _X_EXPORT void GetWindowAttributes( +#endif + WindowPtr /*pWin */ , + ClientPtr /*client */ , + xGetWindowAttributesReply * + /* wa */ ); + +extern _X_EXPORT void GravityTranslate(int /*x */ , + int /*y */ , + int /*oldx */ , + int /*oldy */ , + int /*dw */ , + int /*dh */ , + unsigned /*gravity */ , + int * /*destx */ , + int * /*desty */ ); + +extern _X_EXPORT int ConfigureWindow(WindowPtr /*pWin */ , + Mask /*mask */ , + XID * /*vlist */ , + ClientPtr /*client */ ); + +extern _X_EXPORT int CirculateWindow(WindowPtr /*pParent */ , + int /*direction */ , + ClientPtr /*client */ ); + +extern _X_EXPORT int ReparentWindow(WindowPtr /*pWin */ , + WindowPtr /*pParent */ , + int /*x */ , + int /*y */ , + ClientPtr /*client */ ); + +extern _X_EXPORT int MapWindow(WindowPtr /*pWin */ , + ClientPtr /*client */ ); + +extern _X_EXPORT void MapSubwindows(WindowPtr /*pParent */ , + ClientPtr /*client */ ); + +extern _X_EXPORT int UnmapWindow(WindowPtr /*pWin */ , + Bool /*fromConfigure */ ); + +extern _X_EXPORT void UnmapSubwindows(WindowPtr /*pWin */ ); + +extern _X_EXPORT void HandleSaveSet(ClientPtr /*client */ ); + +extern _X_EXPORT Bool PointInWindowIsVisible(WindowPtr /*pWin */ , + int /*x */ , + int /*y */ ); + +extern _X_EXPORT RegionPtr NotClippedByChildren(WindowPtr /*pWin */ ); + +extern _X_EXPORT void SendVisibilityNotify(WindowPtr /*pWin */ ); + +extern _X_EXPORT int dixSaveScreens(ClientPtr client, int on, int mode); + +extern _X_EXPORT int SaveScreens(int on, int mode); + +extern _X_EXPORT WindowPtr FindWindowWithOptional(WindowPtr /*w */ ); + +extern _X_EXPORT void CheckWindowOptionalNeed(WindowPtr /*w */ ); + +extern _X_EXPORT WindowPtr MoveWindowInStack(WindowPtr /*pWin */ , + WindowPtr /*pNextSib */ ); + +extern _X_EXPORT void SetWinSize(WindowPtr /*pWin */ ); + +extern _X_EXPORT void SetBorderSize(WindowPtr /*pWin */ ); + +extern _X_EXPORT void ResizeChildrenWinSize(WindowPtr /*pWin */ , + int /*dx */ , + int /*dy */ , + int /*dw */ , + int /*dh */ ); + +extern _X_EXPORT void SendShapeNotify(WindowPtr /* pWin */ , + int /* which */); + +extern _X_EXPORT RegionPtr CreateBoundingShape(WindowPtr /* pWin */ ); + +extern _X_EXPORT RegionPtr CreateClipShape(WindowPtr /* pWin */ ); + +extern _X_EXPORT void SetRootClip(ScreenPtr pScreen, int enable); + +extern _X_EXPORT VisualPtr WindowGetVisual(WindowPtr /*pWin*/); +#endif /* WINDOW_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/windowstr.h b/prebuilt/xlibre/usr/include/xorg/windowstr.h new file mode 100644 index 0000000..d7fbb3c --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/windowstr.h @@ -0,0 +1,175 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef WINDOWSTRUCT_H +#define WINDOWSTRUCT_H + +#include "xlibre_ptrtypes.h" +#include "window.h" +#include "pixmapstr.h" +#include "regionstr.h" +#include "cursor.h" +#include "property.h" +#include "resource.h" /* for ROOT_WINDOW_ID_BASE */ +#include "dix.h" +#include "privates.h" +#include "miscstruct.h" +#include +#include "opaque.h" + + +/* used as NULL-terminated list */ +typedef struct _DevCursorNode { + CursorPtr cursor; + DeviceIntPtr dev; + struct _DevCursorNode *next; +} DevCursNodeRec, *DevCursNodePtr, *DevCursorList; + +typedef struct _WindowOpt { + CursorPtr cursor; /* default: window.cursorNone */ + VisualID visual; /* default: same as parent */ + Colormap colormap; /* default: same as parent */ + Mask dontPropagateMask; /* default: window.dontPropagate */ + Mask otherEventMasks; /* default: 0 */ + struct _OtherClients *otherClients; /* default: NULL */ + struct _GrabRec *passiveGrabs; /* default: NULL */ + CARD32 backingBitPlanes; /* default: ~0L */ + CARD32 backingPixel; /* default: 0 */ + RegionPtr boundingShape; /* default: NULL */ + RegionPtr clipShape; /* default: NULL */ + RegionPtr inputShape; /* default: NULL */ + struct _OtherInputMasks *inputMasks; /* default: NULL */ + DevCursorList deviceCursors; /* default: NULL */ +} WindowOptRec, *WindowOptPtr; + +#define BackgroundPixel 2L +#define BackgroundPixmap 3L + +/* + * The redirectDraw field can have one of three values: + * + * RedirectDrawNone + * A normal window; painted into the same pixmap as the parent + * and clipping parent and siblings to its geometry. These + * windows get a clip list equal to the intersection of their + * geometry with the parent geometry, minus the geometry + * of overlapping None and Clipped siblings. + * RedirectDrawAutomatic + * A redirected window which clips parent and sibling drawing. + * Contents for these windows are manage inside the server. + * These windows get an internal clip list equal to their + * geometry. + * RedirectDrawManual + * A redirected window which does not clip parent and sibling + * drawing; the window must be represented within the parent + * geometry by the client performing the redirection management. + * Contents for these windows are managed outside the server. + * These windows get an internal clip list equal to their + * geometry. + */ + +#define RedirectDrawNone 0 +#define RedirectDrawAutomatic 1 +#define RedirectDrawManual 2 + +struct _Window { + DrawableRec drawable; + PrivateRec *devPrivates; + WindowPtr parent; /* ancestor chain */ + WindowPtr nextSib; /* next lower sibling */ + WindowPtr prevSib; /* next higher sibling */ + WindowPtr firstChild; /* top-most child */ + WindowPtr lastChild; /* bottom-most child */ + RegionRec clipList; /* clipping rectangle for output */ + RegionRec borderClip; /* NotClippedByChildren + border */ + union _MiValidate *valdata; + RegionRec winSize; + RegionRec borderSize; + xPoint origin; /* position relative to parent */ + unsigned short borderWidth; + unsigned short deliverableEvents; /* all masks from all clients */ + Mask eventMask; /* mask from the creating client */ + PixUnion background; + PixUnion border; + WindowOptPtr optional; + unsigned backgroundState:2; /* None, Relative, Pixel, Pixmap */ + unsigned borderIsPixel:1; + unsigned cursorIsNone:1; /* else real cursor (might inherit) */ + unsigned backingStore:2; + unsigned saveUnder:1; + unsigned bitGravity:4; + unsigned winGravity:4; + unsigned overrideRedirect:1; + unsigned visibility:2; + unsigned mapped:1; + unsigned realized:1; /* ancestors are all mapped */ + unsigned viewable:1; /* realized && InputOutput */ + unsigned dontPropagate:3; /* index into DontPropagateMasks */ + unsigned redirectDraw:2; /* COMPOSITE rendering redirect */ + unsigned forcedBG:1; /* must have an opaque background */ + unsigned unhittable:1; /* doesn't hit-test, for rootless */ + unsigned damagedDescendants:1; /* some descendants are damaged */ + unsigned inhibitBGPaint:1; /* paint the background? */ + + PropertyPtr properties; /* default: NULL */ +}; + +extern _X_EXPORT Mask DontPropagateMasks[]; + +#define wBorderWidth(w) ((int) (w)->borderWidth) + +static inline PropertyPtr wUserProps(WindowPtr pWin) { return pWin->properties; } + +/* true when w needs a border drawn. */ + +#define HasBorder(w) ((w)->borderWidth || wClipShape((w))) + +#define SCREEN_IS_BLANKED 0 +#define SCREEN_ISNT_SAVED 1 +#define SCREEN_IS_TILED 2 +#define SCREEN_IS_BLACK 3 + +#endif /* WINDOWSTRUCT_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xaarop.h b/prebuilt/xlibre/usr/include/xorg/xaarop.h new file mode 100644 index 0000000..5b1a35c --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xaarop.h @@ -0,0 +1,268 @@ +#ifndef _XAAROP_H +#define _XAAROP_H + +#define ROP_DST 0x00000001 +#define ROP_SRC 0x00000002 +#define ROP_PAT 0x00000004 + +#define ROP_0 0x00 +#define ROP_DPSoon 0x01 +#define ROP_DPSona 0x02 +#define ROP_PSon 0x03 +#define ROP_SDPona 0x04 +#define ROP_DPon 0x05 +#define ROP_PDSxnon 0x06 +#define ROP_PDSaon 0x07 +#define ROP_SDPnaa 0x08 +#define ROP_PDSxon 0x09 +#define ROP_DPna 0x0A +#define ROP_PSDnaon 0x0B +#define ROP_SPna 0x0C +#define ROP_PDSnaon 0x0D +#define ROP_PDSonon 0x0E +#define ROP_Pn 0x0F +#define ROP_PDSona 0x10 +#define ROP_DSon 0x11 +#define ROP_SDPxnon 0x12 +#define ROP_SDPaon 0x13 +#define ROP_DPSxnon 0x14 +#define ROP_DPSaon 0x15 +#define ROP_PSDPSanaxx 0x16 +#define ROP_SSPxDSxaxn 0x17 +#define ROP_SPxPDxa 0x18 +#define ROP_SDPSanaxn 0x19 +#define ROP_PDSPaox 0x1A +#define ROP_SDPSxaxn 0x1B +#define ROP_PSDPaox 0x1C +#define ROP_DSPDxaxn 0x1D +#define ROP_PDSox 0x1E +#define ROP_PDSoan 0x1F +#define ROP_DPSnaa 0x20 +#define ROP_SDPxon 0x21 +#define ROP_DSna 0x22 +#define ROP_SPDnaon 0x23 +#define ROP_SPxDSxa 0x24 +#define ROP_PDSPanaxn 0x25 +#define ROP_SDPSaox 0x26 +#define ROP_SDPSxnox 0x27 +#define ROP_DPSxa 0x28 +#define ROP_PSDPSaoxxn 0x29 +#define ROP_DPSana 0x2A +#define ROP_SSPxPDxaxn 0x2B +#define ROP_SPDSoax 0x2C +#define ROP_PSDnox 0x2D +#define ROP_PSDPxox 0x2E +#define ROP_PSDnoan 0x2F +#define ROP_PSna 0x30 +#define ROP_SDPnaon 0x31 +#define ROP_SDPSoox 0x32 +#define ROP_Sn 0x33 +#define ROP_SPDSaox 0x34 +#define ROP_SPDSxnox 0x35 +#define ROP_SDPox 0x36 +#define ROP_SDPoan 0x37 +#define ROP_PSDPoax 0x38 +#define ROP_SPDnox 0x39 +#define ROP_SPDSxox 0x3A +#define ROP_SPDnoan 0x3B +#define ROP_PSx 0x3C +#define ROP_SPDSonox 0x3D +#define ROP_SPDSnaox 0x3E +#define ROP_PSan 0x3F +#define ROP_PSDnaa 0x40 +#define ROP_DPSxon 0x41 +#define ROP_SDxPDxa 0x42 +#define ROP_SPDSanaxn 0x43 +#define ROP_SDna 0x44 +#define ROP_DPSnaon 0x45 +#define ROP_DSPDaox 0x46 +#define ROP_PSDPxaxn 0x47 +#define ROP_SDPxa 0x48 +#define ROP_PDSPDaoxxn 0x49 +#define ROP_DPSDoax 0x4A +#define ROP_PDSnox 0x4B +#define ROP_SDPana 0x4C +#define ROP_SSPxDSxoxn 0x4D +#define ROP_PDSPxox 0x4E +#define ROP_PDSnoan 0x4F +#define ROP_PDna 0x50 +#define ROP_DSPnaon 0x51 +#define ROP_DPSDaox 0x52 +#define ROP_SPDSxaxn 0x53 +#define ROP_DPSonon 0x54 +#define ROP_Dn 0x55 +#define ROP_DPSox 0x56 +#define ROP_DPSoan 0x57 +#define ROP_PDSPoax 0x58 +#define ROP_DPSnox 0x59 +#define ROP_DPx 0x5A +#define ROP_DPSDonox 0x5B +#define ROP_DPSDxox 0x5C +#define ROP_DPSnoan 0x5D +#define ROP_DPSDnaox 0x5E +#define ROP_DPan 0x5F +#define ROP_PDSxa 0x60 +#define ROP_DSPDSaoxxn 0x61 +#define ROP_DSPDoax 0x62 +#define ROP_SDPnox 0x63 +#define ROP_SDPSoax 0x64 +#define ROP_DSPnox 0x65 +#define ROP_DSx 0x66 +#define ROP_SDPSonox 0x67 +#define ROP_DSPDSonoxxn 0x68 +#define ROP_PDSxxn 0x69 +#define ROP_DPSax 0x6A +#define ROP_PSDPSoaxxn 0x6B +#define ROP_SDPax 0x6C +#define ROP_PDSPDoaxxn 0x6D +#define ROP_SDPSnoax 0x6E +#define ROP_PDSxnan 0x6F +#define ROP_PDSana 0x70 +#define ROP_SSDxPDxaxn 0x71 +#define ROP_SDPSxox 0x72 +#define ROP_SDPnoan 0x73 +#define ROP_DSPDxox 0x74 +#define ROP_DSPnoan 0x75 +#define ROP_SDPSnaox 0x76 +#define ROP_DSan 0x77 +#define ROP_PDSax 0x78 +#define ROP_DSPDSoaxxn 0x79 +#define ROP_DPSDnoax 0x7A +#define ROP_SDPxnan 0x7B +#define ROP_SPDSnoax 0x7C +#define ROP_DPSxnan 0x7D +#define ROP_SPxDSxo 0x7E +#define ROP_DPSaan 0x7F +#define ROP_DPSaa 0x80 +#define ROP_SPxDSxon 0x81 +#define ROP_DPSxna 0x82 +#define ROP_SPDSnoaxn 0x83 +#define ROP_SDPxna 0x84 +#define ROP_PDSPnoaxn 0x85 +#define ROP_DSPDSoaxx 0x86 +#define ROP_PDSaxn 0x87 +#define ROP_DSa 0x88 +#define ROP_SDPSnaoxn 0x89 +#define ROP_DSPnoa 0x8A +#define ROP_DSPDxoxn 0x8B +#define ROP_SDPnoa 0x8C +#define ROP_SDPSxoxn 0x8D +#define ROP_SSDxPDxax 0x8E +#define ROP_PDSanan 0x8F +#define ROP_PDSxna 0x90 +#define ROP_SDPSnoaxn 0x91 +#define ROP_DPSDPoaxx 0x92 +#define ROP_SPDaxn 0x93 +#define ROP_PSDPSoaxx 0x94 +#define ROP_DPSaxn 0x95 +#define ROP_DPSxx 0x96 +#define ROP_PSDPSonoxx 0x97 +#define ROP_SDPSonoxn 0x98 +#define ROP_DSxn 0x99 +#define ROP_DPSnax 0x9A +#define ROP_SDPSoaxn 0x9B +#define ROP_SPDnax 0x9C +#define ROP_DSPDoaxn 0x9D +#define ROP_DSPDSaoxx 0x9E +#define ROP_PDSxan 0x9F +#define ROP_DPa 0xA0 +#define ROP_PDSPnaoxn 0xA1 +#define ROP_DPSnoa 0xA2 +#define ROP_DPSDxoxn 0xA3 +#define ROP_PDSPonoxn 0xA4 +#define ROP_PDxn 0xA5 +#define ROP_DSPnax 0xA6 +#define ROP_PDSPoaxn 0xA7 +#define ROP_DPSoa 0xA8 +#define ROP_DPSoxn 0xA9 +#define ROP_D 0xAA +#define ROP_DPSono 0xAB +#define ROP_SPDSxax 0xAC +#define ROP_DPSDaoxn 0xAD +#define ROP_DSPnao 0xAE +#define ROP_DPno 0xAF +#define ROP_PDSnoa 0xB0 +#define ROP_PDSPxoxn 0xB1 +#define ROP_SSPxDSxox 0xB2 +#define ROP_SDPanan 0xB3 +#define ROP_PSDnax 0xB4 +#define ROP_DPSDoaxn 0xB5 +#define ROP_DPSDPaoxx 0xB6 +#define ROP_SDPxan 0xB7 +#define ROP_PSDPxax 0xB8 +#define ROP_DSPDaoxn 0xB9 +#define ROP_DPSnao 0xBA +#define ROP_DSno 0xBB +#define ROP_SPDSanax 0xBC +#define ROP_SDxPDxan 0xBD +#define ROP_DPSxo 0xBE +#define ROP_DPSano 0xBF +#define ROP_Psa 0xC0 +#define ROP_SPDSnaoxn 0xC1 +#define ROP_SPDSonoxn 0xC2 +#define ROP_PSxn 0xC3 +#define ROP_SPDnoa 0xC4 +#define ROP_SPDSxoxn 0xC5 +#define ROP_SDPnax 0xC6 +#define ROP_PSDPoaxn 0xC7 +#define ROP_SDPoa 0xC8 +#define ROP_SPDoxn 0xC9 +#define ROP_DPSDxax 0xCA +#define ROP_SPDSaoxn 0xCB +#define ROP_S 0xCC +#define ROP_SDPono 0xCD +#define ROP_SDPnao 0xCE +#define ROP_SPno 0xCF +#define ROP_PSDnoa 0xD0 +#define ROP_PSDPxoxn 0xD1 +#define ROP_PDSnax 0xD2 +#define ROP_SPDSoaxn 0xD3 +#define ROP_SSPxPDxax 0xD4 +#define ROP_DPSanan 0xD5 +#define ROP_PSDPSaoxx 0xD6 +#define ROP_DPSxan 0xD7 +#define ROP_PDSPxax 0xD8 +#define ROP_SDPSaoxn 0xD9 +#define ROP_DPSDanax 0xDA +#define ROP_SPxDSxan 0xDB +#define ROP_SPDnao 0xDC +#define ROP_SDno 0xDD +#define ROP_SDPxo 0xDE +#define ROP_SDPano 0xDF +#define ROP_PDSoa 0xE0 +#define ROP_PDSoxn 0xE1 +#define ROP_DSPDxax 0xE2 +#define ROP_PSDPaoxn 0xE3 +#define ROP_SDPSxax 0xE4 +#define ROP_PDSPaoxn 0xE5 +#define ROP_SDPSanax 0xE6 +#define ROP_SPxPDxan 0xE7 +#define ROP_SSPxDSxax 0xE8 +#define ROP_DSPDSanaxxn 0xE9 +#define ROP_DPSao 0xEA +#define ROP_DPSxno 0xEB +#define ROP_SDPao 0xEC +#define ROP_SDPxno 0xED +#define ROP_DSo 0xEE +#define ROP_SDPnoo 0xEF +#define ROP_P 0xF0 +#define ROP_PDSono 0xF1 +#define ROP_PDSnao 0xF2 +#define ROP_PSno 0xF3 +#define ROP_PSDnao 0xF4 +#define ROP_PDno 0xF5 +#define ROP_PDSxo 0xF6 +#define ROP_PDSano 0xF7 +#define ROP_PDSao 0xF8 +#define ROP_PDSxno 0xF9 +#define ROP_DPo 0xFA +#define ROP_DPSnoo 0xFB +#define ROP_PSo 0xFC +#define ROP_PSDnoo 0xFD +#define ROP_DPSoo 0xFE +#define ROP_1 0xFF + +#define NO_SRC_ROP(rop) \ + (((rop) == GXnoop) || ((rop) == GXset) || ((rop) == GXclear) || ((rop) == GXinvert)) + +#endif /* _XAAROP_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86.h b/prebuilt/xlibre/usr/include/xorg/xf86.h new file mode 100644 index 0000000..d122b79 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86.h @@ -0,0 +1,284 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains declarations for public XFree86 functions and variables, + * and definitions of public macros. + * + * "public" means available to video drivers. + */ + +#ifndef _XF86_H +#define _XF86_H + +#include "xlibre_ptrtypes.h" +#include "xf86str.h" +#include "xf86Opt.h" +#include +#include +#include + +/* General parameters */ +extern _X_EXPORT Bool xorgHWAccess; + +extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec; + +#define xf86ScreenKey (&xf86ScreenKeyRec) + +extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ +extern _X_EXPORT const unsigned char byte_reversed[256]; + +#define XF86SCRNINFO(p) xf86ScreenToScrn((p)) + +/* Compatibility functions for pre-input-thread drivers */ +static inline _X_DEPRECATED int xf86BlockSIGIO(void) { input_lock(); return 0; } +static inline _X_DEPRECATED void xf86UnblockSIGIO(_X_UNUSED int wasset) { input_unlock(); } + +/* PCI related */ +#ifdef XSERVER_LIBPCIACCESS +#include +extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *); +extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active); +extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *, GDevPtr dev); +extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus, + int *device, int *func); +extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device *pPci); +extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device *pPci, + memType base); +extern _X_EXPORT struct pci_device *xf86GetPciInfoForEntity(int entityIndex); +extern _X_EXPORT int xf86MatchPciInstances(const char *driverName, + int vendorID, SymTabPtr chipsets, + PciChipsets * PCIchipsets, + GDevPtr * devList, int numDevs, + DriverPtr drvp, int **foundEntities); +extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, + int scrnFlag, int entityIndex, + PciChipsets * p_chip, + void *dummy, EntityProc init, + EntityProc enter, + EntityProc leave, + void *private); +#endif + +/* xf86Bus.c */ + +extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, + Bool active); +extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, + Bool active); +extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex); +extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, + int entityIndex, + int instance); +extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex); +extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance); +extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex); + +#define xf86SetLastScrnFlag(e, s) do { } while (0) + +extern _X_EXPORT Bool xf86IsEntityShared(int entityIndex); +extern _X_EXPORT void xf86SetEntityShared(int entityIndex); +extern _X_EXPORT Bool xf86IsEntitySharable(int entityIndex); +extern _X_EXPORT void xf86SetEntitySharable(int entityIndex); +extern _X_EXPORT Bool xf86IsPrimInitDone(int entityIndex); +extern _X_EXPORT void xf86SetPrimInitDone(int entityIndex); +extern _X_EXPORT void xf86ClearPrimInitDone(int entityIndex); +extern _X_EXPORT int xf86AllocateEntityPrivateIndex(void); +extern _X_EXPORT DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex); + +/* xf86Configure.c */ +extern _X_EXPORT GDevPtr xf86AddBusDeviceToConfigure(const char *driver, + BusType bus, void *busData, + int chipset); + +/* xf86Cursor.c */ + +extern _X_EXPORT void xf86SetViewport(ScreenPtr pScreen, int x, int y); +extern _X_EXPORT Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode); +extern _X_EXPORT void *xf86GetPointerScreenFuncs(void); +extern _X_EXPORT void xf86ReconfigureLayout(void); + +/* xf86DPMS.c */ + +extern _X_EXPORT Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, + int flags); + +/* xf86DGA.c */ + +#ifdef XFreeXDGA +extern _X_EXPORT Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, + DGAModePtr modes, int num); +extern _X_EXPORT Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, + int num); +extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode; +#endif + +/* xf86Events.c */ + +typedef struct _InputInfoRec *InputInfoPtr; + +extern _X_EXPORT void SetTimeSinceLastInputEvent(void); +extern _X_EXPORT void *xf86AddGeneralHandler(int fd, InputHandlerProc proc, + void *data); +extern _X_EXPORT int xf86RemoveGeneralHandler(void *handler); + +/* xf86Helper.c */ + +extern _X_EXPORT void xf86AddDriver(DriverPtr driver, void *module, + int flags); +extern _X_EXPORT ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags); +extern _X_EXPORT int xf86AllocateScrnInfoPrivateIndex(void); +extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, + int fbbpp, int depth24flags); +extern _X_EXPORT void xf86PrintDepthBpp(ScrnInfoPtr scrp); +extern _X_EXPORT Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask); +extern _X_EXPORT Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual); +extern _X_EXPORT Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma); +extern _X_EXPORT void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y); +extern _X_EXPORT void xf86SetBlackWhitePixels(ScreenPtr pScreen); +extern _X_EXPORT void xf86EnableDisableFBAccess(ScrnInfoPtr pScrn, Bool enable); +extern _X_EXPORT void +xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, + const char *format, va_list args) +_X_ATTRIBUTE_PRINTF(4, 0); +extern _X_EXPORT void +xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, + const char *format, ...) +_X_ATTRIBUTE_PRINTF(4, 5); +extern _X_EXPORT void +xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...) +_X_ATTRIBUTE_PRINTF(3, 4); +extern _X_EXPORT void +xf86ErrorFVerb(int verb, const char *format, ...) +_X_ATTRIBUTE_PRINTF(2, 3); +extern _X_EXPORT void +xf86ErrorF(const char *format, ...) +_X_ATTRIBUTE_PRINTF(1, 2); +extern _X_EXPORT const char * +xf86TokenToString(SymTabPtr table, int token); +extern _X_EXPORT int +xf86StringToToken(SymTabPtr table, const char *string); +extern _X_EXPORT void +xf86ShowClocks(ScrnInfoPtr scrp, MessageType from); +extern _X_EXPORT void +xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips); +extern _X_EXPORT int +xf86MatchDevice(const char *drivername, GDevPtr ** driversectlist); +extern _X_EXPORT const char * +xf86GetVisualName(int visual); +extern _X_EXPORT int +xf86GetVerbosity(void); +extern _X_EXPORT Gamma +xf86GetGamma(void); +extern _X_EXPORT Bool +xf86ServerIsExiting(void); +extern _X_EXPORT Bool +xf86ServerIsOnlyDetecting(void); +extern _X_EXPORT Bool +xf86GetAllowMouseOpenFail(void); +extern _X_EXPORT CARD32 +xorgGetVersion(void); +extern _X_EXPORT CARD32 +xf86GetModuleVersion(void *module); +extern _X_EXPORT void * +xf86LoadDrvSubModule(DriverPtr drv, const char *name); +extern _X_EXPORT void * +xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name); +extern _X_EXPORT void * +xf86LoadOneModule(const char *name, void *optlist); +extern _X_EXPORT void +xf86UnloadSubModule(void *mod); +extern _X_EXPORT Bool +xf86LoaderCheckSymbol(const char *name); +extern _X_EXPORT void +xf86SetBackingStore(ScreenPtr pScreen); +extern _X_EXPORT void +xf86SetSilkenMouse(ScreenPtr pScreen); +extern _X_EXPORT ScrnInfoPtr +xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, + int entityIndex, EntityProc init, + EntityProc enter, EntityProc leave, void *private); + +extern _X_EXPORT Bool +xf86IsUnblank(int mode); + +/* xf86Init.c */ + +extern _X_EXPORT PixmapFormatPtr +xf86GetPixFormat(ScrnInfoPtr pScrn, int depth); +extern _X_EXPORT int +xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth); + +/* xf86Mode.c */ + +extern _X_EXPORT ModeStatus +xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor); +extern _X_EXPORT int +xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, + const char **modeNames, ClockRangePtr clockRanges, + int *linePitches, int minPitch, int maxPitch, + int minHeight, int maxHeight, int pitchInc, + int virtualX, int virtualY, int apertureSize, + LookupModeFlags strategy); +extern _X_EXPORT void +xf86DeleteMode(DisplayModePtr * modeList, DisplayModePtr mode); +extern _X_EXPORT void +xf86PruneDriverModes(ScrnInfoPtr scrp); +extern _X_EXPORT void +xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags); +extern _X_EXPORT void +xf86PrintModes(ScrnInfoPtr scrp); + +/* xf86Option.c */ + +extern _X_EXPORT void +xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts); + +/* convert ScreenPtr to ScrnInfoPtr */ +extern _X_EXPORT ScrnInfoPtr xf86ScreenToScrn(ScreenPtr pScreen); +/* convert ScrnInfoPtr to ScreenPtr */ +extern _X_EXPORT ScreenPtr xf86ScrnToScreen(ScrnInfoPtr pScrn); + +#define XF86_HAS_SCRN_CONV 1 /* define for drivers to use in api compat */ + +#define XF86_SCRN_INTERFACE 1 /* define for drivers to use in api compat */ + +/* flags passed to xf86 allocate screen */ +#define XF86_ALLOCATE_GPU_SCREEN 1 + +/* only for backwards (source) compatibility */ +#define xf86MsgVerb LogMessageVerb +#define xf86Msg(type, ...) LogMessageVerb((type), 1, __VA_ARGS__) + +/* + * retrieve file descriptor to opened console device. + * only for some legacy keyboard drivers (xf86-input-keyboard) + */ +_X_EXPORT int xf86GetConsoleFd(void); + +#endif /* _XF86_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Crtc.h b/prebuilt/xlibre/usr/include/xorg/xf86Crtc.h new file mode 100644 index 0000000..4237bd8 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Crtc.h @@ -0,0 +1,1142 @@ +/* + * Copyright © 2006 Keith Packard + * Copyright © 2011 Aaron Plattner + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#ifndef _XF86CRTC_H_ +#define _XF86CRTC_H_ + +#include +#include "randrstr.h" +#include "xf86Modes.h" +#include "xf86Cursor.h" +#include "xf86i2c.h" +#include "damage.h" +#include "picturestr.h" + +/* Compat definitions for older X Servers. */ +#ifndef M_T_PREFERRED +#define M_T_PREFERRED 0x08 +#endif +#ifndef M_T_DRIVER +#define M_T_DRIVER 0x40 +#endif +#ifndef M_T_USERPREF +#define M_T_USERPREF 0x80 +#endif +#ifndef HARDWARE_CURSOR_ARGB +#define HARDWARE_CURSOR_ARGB 0x00004000 +#endif + +typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr; +typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr; +typedef struct _xf86Lease xf86LeaseRec, *xf86LeasePtr; + +/* define a standard for connector types */ +typedef enum _xf86ConnectorType { + XF86ConnectorNone, + XF86ConnectorVGA, + XF86ConnectorDVI_I, + XF86ConnectorDVI_D, + XF86ConnectorDVI_A, + XF86ConnectorComposite, + XF86ConnectorSvideo, + XF86ConnectorComponent, + XF86ConnectorLFP, + XF86ConnectorProprietary, + XF86ConnectorHDMI, + XF86ConnectorDisplayPort, +} xf86ConnectorType; + +typedef enum _xf86OutputStatus { + XF86OutputStatusConnected, + XF86OutputStatusDisconnected, + XF86OutputStatusUnknown +} xf86OutputStatus; + +typedef enum _xf86DriverTransforms { + XF86DriverTransformNone = 0, + XF86DriverTransformOutput = 1 << 0, + XF86DriverTransformCursorImage = 1 << 1, + XF86DriverTransformCursorPosition = 1 << 2, +} xf86DriverTransforms; + + +struct xf86CrtcTileInfo { + uint32_t group_id; + uint32_t flags; + uint32_t num_h_tile; + uint32_t num_v_tile; + uint32_t tile_h_loc; + uint32_t tile_v_loc; + uint32_t tile_h_size; + uint32_t tile_v_size; +}; + +typedef struct _xf86CrtcFuncs { + /** + * Turns the crtc on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to + * be safe to call mode_set. + */ + void + (*dpms) (xf86CrtcPtr crtc, int mode); + + /** + * Saves the crtc's state for restoration on VT switch. + */ + void + (*save) (xf86CrtcPtr crtc); + + /** + * Restore's the crtc's state at VT switch. + */ + void + (*restore) (xf86CrtcPtr crtc); + + /** + * Lock CRTC prior to mode setting, mostly for DRI. + * Returns whether unlock is needed + */ + Bool + (*lock) (xf86CrtcPtr crtc); + + /** + * Unlock CRTC after mode setting, mostly for DRI + */ + void + (*unlock) (xf86CrtcPtr crtc); + + /** + * Callback to adjust the mode to be set in the CRTC. + * + * This allows a CRTC to adjust the clock or even the entire set of + * timings, which is used for panels with fixed timings or for + * buses with clock limitations. + */ + Bool + (*mode_fixup) (xf86CrtcPtr crtc, + DisplayModePtr mode, DisplayModePtr adjusted_mode); + + /** + * Prepare CRTC for an upcoming mode set. + */ + void + (*prepare) (xf86CrtcPtr crtc); + + /** + * Callback for setting up a video mode after fixups have been made. + */ + void + (*mode_set) (xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode, int x, int y); + + /** + * Commit mode changes to a CRTC + */ + void + (*commit) (xf86CrtcPtr crtc); + + /* Set the color ramps for the CRTC to the given values. */ + void + (*gamma_set) (xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, + int size); + + /** + * Allocate the shadow area, delay the pixmap creation until needed + */ + void *(*shadow_allocate) (xf86CrtcPtr crtc, int width, int height); + + /** + * Create shadow pixmap for rotation support + */ + PixmapPtr + (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height); + + /** + * Destroy shadow pixmap + */ + void + (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data); + + /** + * Set cursor colors + */ + void + (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg); + + /** + * Set cursor position + */ + void + (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y); + + /** + * Show cursor + */ + void + (*show_cursor) (xf86CrtcPtr crtc); + Bool + (*show_cursor_check) (xf86CrtcPtr crtc); + + /** + * Hide cursor + */ + void + (*hide_cursor) (xf86CrtcPtr crtc); + + /** + * Load monochrome image + */ + void + (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image); + Bool + (*load_cursor_image_check) (xf86CrtcPtr crtc, CARD8 *image); + + /** + * Load ARGB image + */ + void + (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image); + Bool + (*load_cursor_argb_check) (xf86CrtcPtr crtc, CARD32 *image); + + /** + * Clean up driver-specific bits of the crtc + */ + void + (*destroy) (xf86CrtcPtr crtc); + + /** + * Less fine-grained mode setting entry point for kernel modesetting + */ + Bool + (*set_mode_major) (xf86CrtcPtr crtc, DisplayModePtr mode, + Rotation rotation, int x, int y); + + /** + * Callback for panning. Doesn't change the mode. + * Added in ABI version 2 + */ + void + (*set_origin) (xf86CrtcPtr crtc, int x, int y); + + /** + */ + Bool + (*set_scanout_pixmap)(xf86CrtcPtr crtc, PixmapPtr pixmap); + +} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; + +#define XF86_CRTC_VERSION 8 + +struct _xf86Crtc { + /** + * ABI versioning + */ + int version; + + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Desired state of this CRTC + * + * Set when this CRTC should be driving one or more outputs + */ + Bool enabled; + + /** + * Active mode + * + * This reflects the mode as set in the CRTC currently + * It will be cleared when the VT is not active or + * during server startup + */ + DisplayModeRec mode; + Rotation rotation; + PixmapPtr rotatedPixmap; + void *rotatedData; + + /** + * Position on screen + * + * Locates this CRTC within the frame buffer + */ + int x, y; + + /** + * Desired mode + * + * This is set to the requested mode, independent of + * whether the VT is active. In particular, it receives + * the startup configured mode and saves the active mode + * on VT switch. + */ + DisplayModeRec desiredMode; + Rotation desiredRotation; + int desiredX, desiredY; + + /** crtc-specific functions */ + const xf86CrtcFuncsRec *funcs; + + /** + * Driver private + * + * Holds driver-private information + */ + void *driver_private; + + /** + * RandR crtc + * + * When RandR 1.2 is available, this + * points at the associated crtc object + */ + RRCrtcPtr randr_crtc; + + /** + * Current cursor is ARGB + */ + Bool cursor_argb; + /** + * Track whether cursor is within CRTC range + */ + Bool cursor_in_range; + /** + * Track state of cursor associated with this CRTC + */ + Bool cursor_shown; + + /** + * Current transformation matrix + */ + PictTransform crtc_to_framebuffer; + /* framebuffer_to_crtc was removed in ABI 2 */ + struct pixman_f_transform f_crtc_to_framebuffer; /* ABI 2 */ + struct pixman_f_transform f_framebuffer_to_crtc; /* ABI 2 */ + PictFilterPtr filter; /* ABI 2 */ + xFixed *params; /* ABI 2 */ + int nparams; /* ABI 2 */ + int filter_width; /* ABI 2 */ + int filter_height; /* ABI 2 */ + Bool transform_in_use; + RRTransformRec transform; /* ABI 2 */ + Bool transformPresent; /* ABI 2 */ + RRTransformRec desiredTransform; /* ABI 2 */ + Bool desiredTransformPresent; /* ABI 2 */ + /** + * Bounding box in screen space + */ + BoxRec bounds; + /** + * Panning: + * TotalArea: total panning area, larger than CRTC's size + * TrackingArea: Area of the pointer for which the CRTC is panned + * border: Borders of the displayed CRTC area which induces panning if the pointer reaches them + * Added in ABI version 2 + */ + BoxRec panningTotalArea; + BoxRec panningTrackingArea; + INT16 panningBorder[4]; + + /** + * Current gamma, especially useful after initial config. + * Added in ABI version 3 + */ + CARD16 *gamma_red; + CARD16 *gamma_green; + CARD16 *gamma_blue; + int gamma_size; + + /** + * Actual state of this CRTC + * + * Set to TRUE after modesetting, set to FALSE if no outputs are connected + * Added in ABI version 3 + */ + Bool active; + /** + * Clear the shadow + */ + Bool shadowClear; + + /** + * Indicates that the driver is handling some or all transforms: + * + * XF86DriverTransformOutput: The driver handles the output transform, so + * the shadow surface should be disabled. The driver writes this field + * before calling xf86CrtcRotate to indicate that it is handling the + * transform (including rotation and reflection). + * + * XF86DriverTransformCursorImage: Setting this flag causes the server to + * pass the untransformed cursor image to the driver hook. + * + * XF86DriverTransformCursorPosition: Setting this flag causes the server + * to pass the untransformed cursor position to the driver hook. + * + * Added in ABI version 4, changed to xf86DriverTransforms in ABI version 7 + */ + xf86DriverTransforms driverIsPerformingTransform; + + /* Added in ABI version 5 + */ + PixmapPtr current_scanout; + + /* Added in ABI version 6 + */ + PixmapPtr current_scanout_back; +}; + +typedef struct _xf86OutputFuncs { + /** + * Called to allow the output a chance to create properties after the + * RandR objects have been created. + */ + void + (*create_resources) (xf86OutputPtr output); + + /** + * Turns the output on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the output must be disabled, as the DPLL may be + * disabled afterwards. + */ + void + (*dpms) (xf86OutputPtr output, int mode); + + /** + * Saves the output's state for restoration on VT switch. + */ + void + (*save) (xf86OutputPtr output); + + /** + * Restore's the output's state at VT switch. + */ + void + (*restore) (xf86OutputPtr output); + + /** + * Callback for testing a video mode for a given output. + * + * This function should only check for cases where a mode can't be supported + * on the output specifically, and not represent generic CRTC limitations. + * + * \return MODE_OK if the mode is valid, or another MODE_* otherwise. + */ + int + (*mode_valid) (xf86OutputPtr output, DisplayModePtr pMode); + + /** + * Callback to adjust the mode to be set in the CRTC. + * + * This allows an output to adjust the clock or even the entire set of + * timings, which is used for panels with fixed timings or for + * buses with clock limitations. + */ + Bool + (*mode_fixup) (xf86OutputPtr output, + DisplayModePtr mode, DisplayModePtr adjusted_mode); + + /** + * Callback for preparing mode changes on an output + */ + void + (*prepare) (xf86OutputPtr output); + + /** + * Callback for committing mode changes on an output + */ + void + (*commit) (xf86OutputPtr output); + + /** + * Callback for setting up a video mode after fixups have been made. + * + * This is only called while the output is disabled. The dpms callback + * must be all that's necessary for the output, to turn the output on + * after this function is called. + */ + void + (*mode_set) (xf86OutputPtr output, + DisplayModePtr mode, DisplayModePtr adjusted_mode); + + /** + * Probe for a connected output, and return detect_status. + */ + xf86OutputStatus(*detect) (xf86OutputPtr output); + + /** + * Query the device for the modes it provides. + * + * This function may also update MonInfo, mm_width, and mm_height. + * + * \return singly-linked list of modes or NULL if no modes found. + */ + DisplayModePtr(*get_modes) (xf86OutputPtr output); + + /** + * Callback when an output's property has changed. + */ + Bool + (*set_property) (xf86OutputPtr output, + Atom property, RRPropertyValuePtr value); +#ifdef RANDR_13_INTERFACE + /** + * Callback to get an updated property value + */ + Bool + (*get_property) (xf86OutputPtr output, Atom property); +#endif +#ifdef RANDR_GET_CRTC_INTERFACE + /** + * Callback to get current CRTC for a given output + */ + xf86CrtcPtr(*get_crtc) (xf86OutputPtr output); +#endif + /** + * Clean up driver-specific bits of the output + */ + void + (*destroy) (xf86OutputPtr output); +} xf86OutputFuncsRec, *xf86OutputFuncsPtr; + +#define XF86_OUTPUT_VERSION 3 + +struct _xf86Output { + /** + * ABI versioning + */ + int version; + + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Currently connected crtc (if any) + * + * If this output is not in use, this field will be NULL. + */ + xf86CrtcPtr crtc; + + /** + * Possible CRTCs for this output as a mask of crtc indices + */ + CARD32 possible_crtcs; + + /** + * Possible outputs to share the same CRTC as a mask of output indices + */ + CARD32 possible_clones; + + /** + * Whether this output can support interlaced modes + */ + Bool interlaceAllowed; + + /** + * Whether this output can support double scan modes + */ + Bool doubleScanAllowed; + + /** + * List of available modes on this output. + * + * This should be the list from get_modes(), plus perhaps additional + * compatible modes added later. + */ + DisplayModePtr probed_modes; + + /** + * Options parsed from the related monitor section + */ + OptionInfoPtr options; + + /** + * Configured monitor section + */ + XF86ConfMonitorPtr conf_monitor; + + /** + * Desired initial position + */ + int initial_x, initial_y; + + /** + * Desired initial rotation + */ + Rotation initial_rotation; + + /** + * Current connection status + * + * This indicates whether a monitor is known to be connected + * to this output or not, or whether there is no way to tell + */ + xf86OutputStatus status; + + /** EDID monitor information */ + xf86MonPtr MonInfo; + + /** subpixel order */ + int subpixel_order; + + /** Physical size of the currently attached output device. */ + int mm_width, mm_height; + + /** Output name */ + char *name; + + /** output-specific functions */ + const xf86OutputFuncsRec *funcs; + + /** driver private information */ + void *driver_private; + + /** Whether to use the old per-screen Monitor config section */ + Bool use_screen_monitor; + + /** For pre-init, whether the output should be excluded from the + * desktop when there are other viable outputs to use + */ + Bool non_desktop; + + /** + * RandR 1.2 output structure. + * + * When RandR 1.2 is available, this points at the associated + * RandR output structure and is created when this output is created + */ + RROutputPtr randr_output; + /** + * Desired initial panning + * Added in ABI version 2 + */ + BoxRec initialTotalArea; + BoxRec initialTrackingArea; + INT16 initialBorder[4]; + + struct xf86CrtcTileInfo tile_info; +}; + +typedef struct _xf86ProviderFuncs { + /** + * Called to allow the provider a chance to create properties after the + * RandR objects have been created. + */ + void + (*create_resources) (ScrnInfoPtr scrn); + + /** + * Callback when an provider's property has changed. + */ + Bool + (*set_property) (ScrnInfoPtr scrn, + Atom property, RRPropertyValuePtr value); + + /** + * Callback to get an updated property value + */ + Bool + (*get_property) (ScrnInfoPtr provider, Atom property); + +} xf86ProviderFuncsRec, *xf86ProviderFuncsPtr; + +#define XF86_LEASE_VERSION 1 + +struct _xf86Lease { + /** + * ABI versioning + */ + int version; + + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Driver private + */ + void *driver_private; + + /** + * RandR lease + */ + RRLeasePtr randr_lease; + + /* + * Contents of the lease + */ + + /** + * Number of leased CRTCs + */ + int num_crtc; + + /** + * Number of leased outputs + */ + int num_output; + + /** + * Array of pointers to leased CRTCs + */ + RRCrtcPtr *crtcs; + + /** + * Array of pointers to leased outputs + */ + RROutputPtr *outputs; +}; + +typedef struct _xf86CrtcConfigFuncs { + /** + * Requests that the driver resize the screen. + * + * The driver is responsible for updating scrn->virtualX and scrn->virtualY. + * If the requested size cannot be set, the driver should leave those values + * alone and return FALSE. + * + * A naive driver that cannot reallocate the screen may simply change + * virtual[XY]. A more advanced driver will want to also change the + * devPrivate.ptr and devKind of the screen pixmap, update any offscreen + * pixmaps it may have moved, and change pScrn->displayWidth. + */ + Bool + (*resize) (ScrnInfoPtr scrn, int width, int height); + + /** + * Requests that the driver create a lease + */ + int (*create_lease)(RRLeasePtr lease, int *fd); + + /** + * Ask the driver to terminate a lease, freeing all + * driver resources + */ + void (*terminate_lease)(RRLeasePtr lease); +} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr; + +/* + * The driver calls this when it detects that a lease + * has been terminated + */ +extern _X_EXPORT void +xf86CrtcLeaseTerminated(RRLeasePtr lease); + +extern _X_EXPORT void +xf86CrtcLeaseStarted(RRLeasePtr lease); + +typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen); + +typedef struct _xf86CrtcConfig { + int num_output; + xf86OutputPtr *output; + /** + * compat_output is used whenever we deal + * with legacy code that only understands a single + * output. pScrn->modes will be loaded from this output, + * adjust frame will whack this output, etc. + */ + int compat_output; + + int num_crtc; + xf86CrtcPtr *crtc; + + int minWidth, minHeight; + int maxWidth, maxHeight; + + /* For crtc-based rotation */ + DamagePtr rotation_damage; + Bool rotation_damage_registered; + + /* DGA */ + unsigned int dga_flags; + unsigned long dga_address; + DGAModePtr dga_modes; + int dga_nmode; + int dga_width, dga_height, dga_stride; + DisplayModePtr dga_save_mode; + + const xf86CrtcConfigFuncsRec *funcs; + + CreateScreenResourcesProcPtr CreateScreenResources; + + void *_dummy1; // required in place of a removed field for ABI compatibility + + /* Cursor information */ + xf86CursorInfoPtr cursor_info; + CursorPtr cursor; + CARD8 *cursor_image; + Bool cursor_on; + CARD32 cursor_fg, cursor_bg; + + /** + * Options parsed from the related device section + */ + OptionInfoPtr options; + + Bool debug_modes; + + /* wrap screen BlockHandler for rotation */ + ScreenBlockHandlerProcPtr BlockHandler; + + /* callback when crtc configuration changes */ + xf86_crtc_notify_proc_ptr xf86_crtc_notify; + + char *name; + const xf86ProviderFuncsRec *provider_funcs; + RRProviderPtr randr_provider; +} xf86CrtcConfigRec, *xf86CrtcConfigPtr; + +extern _X_EXPORT int xf86CrtcConfigPrivateIndex; + +#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr)) + +static _X_INLINE xf86OutputPtr +xf86CompatOutput(ScrnInfoPtr pScrn) +{ + xf86CrtcConfigPtr config; + + if (xf86CrtcConfigPrivateIndex == -1) + return NULL; + config = XF86_CRTC_CONFIG_PTR(pScrn); + if ((config == NULL) || (config->compat_output < 0)) + return NULL; + return config->output[config->compat_output]; +} + +static _X_INLINE xf86CrtcPtr +xf86CompatCrtc(ScrnInfoPtr pScrn) +{ + xf86OutputPtr compat_output = xf86CompatOutput(pScrn); + + if (!compat_output) + return NULL; + return compat_output->crtc; +} + +static _X_INLINE RRCrtcPtr +xf86CompatRRCrtc(ScrnInfoPtr pScrn) +{ + xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn); + + if (!compat_crtc) + return NULL; + return compat_crtc->randr_crtc; +} + +/* + * Initialize xf86CrtcConfig structure + */ + +extern _X_EXPORT void + xf86CrtcConfigInit(ScrnInfoPtr scrn, const xf86CrtcConfigFuncsRec * funcs); + +extern _X_EXPORT void + +xf86CrtcSetSizeRange(ScrnInfoPtr scrn, + int minWidth, int minHeight, int maxWidth, int maxHeight); + +/* + * Crtc functions + */ +extern _X_EXPORT xf86CrtcPtr +xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs); + +extern _X_EXPORT void + xf86CrtcDestroy(xf86CrtcPtr crtc); + +/** + * Sets the given video mode on the given crtc + */ + +extern _X_EXPORT Bool + +xf86CrtcSetModeTransform(xf86CrtcPtr crtc, DisplayModePtr mode, + Rotation rotation, RRTransformPtr transform, int x, + int y); + +extern _X_EXPORT Bool + +xf86CrtcSetMode(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, + int x, int y); + +extern _X_EXPORT void + xf86CrtcSetOrigin(xf86CrtcPtr crtc, int x, int y); + +/* + * Assign crtc rotation during mode set + */ +extern _X_EXPORT Bool + xf86CrtcRotate(xf86CrtcPtr crtc); + +extern _X_EXPORT void + xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, PixmapPtr dst_pixmap, + DrawableRec *src_drawable, RegionPtr region, + Bool transform_src); + +/* + * Clean up any rotation data, used when a crtc is turned off + * as well as when rotation is disabled. + */ +extern _X_EXPORT void + xf86RotateDestroy(xf86CrtcPtr crtc); + +/* + * free shadow memory allocated for all crtcs + */ +extern _X_EXPORT void + xf86RotateFreeShadow(ScrnInfoPtr pScrn); + +/* + * Clean up rotation during CloseScreen + */ +extern _X_EXPORT void + xf86RotateCloseScreen(ScreenPtr pScreen); + +/** + * Return whether any output is assigned to the crtc + */ +extern _X_EXPORT Bool + xf86CrtcInUse(xf86CrtcPtr crtc); + +/* + * Output functions + */ +extern _X_EXPORT xf86OutputPtr +xf86OutputCreate(ScrnInfoPtr scrn, + const xf86OutputFuncsRec * funcs, const char *name); + +extern _X_EXPORT void + xf86OutputUseScreenMonitor(xf86OutputPtr output, Bool use_screen_monitor); + +extern _X_EXPORT Bool + xf86OutputRename(xf86OutputPtr output, const char *name); + +extern _X_EXPORT void + xf86OutputDestroy(xf86OutputPtr output); + +extern _X_EXPORT void + xf86ProbeOutputModes(ScrnInfoPtr pScrn, int maxX, int maxY); + +extern _X_EXPORT void + xf86SetScrnInfoModes(ScrnInfoPtr pScrn); + +#ifdef RANDR_13_INTERFACE +#define ScreenInitRetType int +#else +#define ScreenInitRetType Bool +#endif + +extern _X_EXPORT ScreenInitRetType xf86CrtcScreenInit(ScreenPtr pScreen); + +extern _X_EXPORT void +xf86AssignNoOutputInitialSize(ScrnInfoPtr scrn, const OptionInfoRec *options, + int *no_output_width, int *no_output_height); + +extern _X_EXPORT Bool + xf86InitialConfiguration(ScrnInfoPtr pScrn, Bool canGrow); + +extern _X_EXPORT void + xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); + +extern _X_EXPORT Bool + xf86SaveScreen(ScreenPtr pScreen, int mode); + +extern _X_EXPORT void + xf86DisableUnusedFunctions(ScrnInfoPtr pScrn); + +extern _X_EXPORT DisplayModePtr +xf86OutputFindClosestMode(xf86OutputPtr output, DisplayModePtr desired); + +extern _X_EXPORT Bool + +xf86SetSingleMode(ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation); + +/** + * Set the EDID information for the specified output + */ +extern _X_EXPORT void + xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon); + +/** + * Set the TILE information for the specified output + */ +extern _X_EXPORT void +xf86OutputSetTile(xf86OutputPtr output, struct xf86CrtcTileInfo *tile_info); + +extern _X_EXPORT Bool +xf86OutputParseKMSTile(const char *tile_data, int tile_length, struct xf86CrtcTileInfo *tile_info); + +/** + * Return the list of modes supported by the EDID information + * stored in 'output' + */ +extern _X_EXPORT DisplayModePtr xf86OutputGetEDIDModes(xf86OutputPtr output); + +extern _X_EXPORT xf86MonPtr +xf86OutputGetEDID(xf86OutputPtr output, I2CBusPtr pDDCBus); + +/** + * Initialize dga for this screen + */ + +#ifdef XFreeXDGA +extern _X_EXPORT Bool + xf86DiDGAInit(ScreenPtr pScreen, unsigned long dga_address); + +/* this is the real function, used only internally */ +_X_INTERNAL Bool + _xf86_di_dga_init_internal(ScreenPtr pScreen); + +/** + * Re-initialize dga for this screen (as when the set of modes changes) + */ + +extern _X_EXPORT Bool + xf86DiDGAReInit(ScreenPtr pScreen); +#endif + +/* This is the real function, used only internally */ +_X_INTERNAL Bool + _xf86_di_dga_reinit_internal(ScreenPtr pScreen); + +/* + * Set the subpixel order reported for the screen using + * the information from the outputs + */ + +extern _X_EXPORT void + xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen); + +/* + * Get a standard string name for a connector type + */ +extern _X_EXPORT const char *xf86ConnectorGetName(xf86ConnectorType connector); + +/* + * Using the desired mode information in each crtc, set + * modes (used in EnterVT functions, or at server startup) + */ + +extern _X_EXPORT Bool + xf86SetDesiredModes(ScrnInfoPtr pScrn); + +/** + * Initialize the CRTC-based cursor code. CRTC function vectors must + * contain relevant cursor setting functions. + * + * Driver should call this from ScreenInit function + */ +extern _X_EXPORT Bool + xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags); + +/** + * Superseded by xf86CursorResetCursor, which is getting called + * automatically when necessary. + */ +static _X_INLINE _X_DEPRECATED void xf86_reload_cursors(ScreenPtr screen) {} + +/** + * Called from EnterVT to turn the cursors back on + */ +extern _X_EXPORT Bool + xf86_show_cursors(ScrnInfoPtr scrn); + +/** + * Called by the driver to turn a single crtc's cursor off + */ +extern _X_EXPORT void +xf86_crtc_hide_cursor(xf86CrtcPtr crtc); + +/** + * Called by the driver to turn a single crtc's cursor on + */ +extern _X_EXPORT Bool +xf86_crtc_show_cursor(xf86CrtcPtr crtc); + +/** + * Called by the driver to turn cursors off + */ +extern _X_EXPORT void + xf86_hide_cursors(ScrnInfoPtr scrn); + +/** + * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time. + */ +extern _X_EXPORT void + xf86_cursors_fini(ScreenPtr screen); + +#ifdef XV +/* + * For overlay video, compute the relevant CRTC and + * clip video to that. + * wraps xf86XVClipVideoHelper() + */ + +extern _X_EXPORT Bool + +xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, + xf86CrtcPtr * crtc_ret, + xf86CrtcPtr desired_crtc, + BoxPtr dst, + INT32 *xa, + INT32 *xb, + INT32 *ya, + INT32 *yb, + RegionPtr reg, INT32 width, INT32 height); +#endif + +extern _X_EXPORT xf86_crtc_notify_proc_ptr +xf86_wrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new); + +extern _X_EXPORT void + xf86_unwrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr old); + +extern _X_EXPORT void + xf86_crtc_notify(ScreenPtr pScreen); + +/** + * Gamma + */ + +extern _X_EXPORT Bool + xf86_crtc_supports_gamma(ScrnInfoPtr pScrn); + +extern _X_EXPORT void +xf86ProviderSetup(ScrnInfoPtr scrn, + const xf86ProviderFuncsRec * funcs, const char *name); + +extern _X_EXPORT void +xf86DetachAllCrtc(ScrnInfoPtr scrn); + +Bool xf86OutputForceEnabled(xf86OutputPtr output); +#endif /* _XF86CRTC_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Cursor.h b/prebuilt/xlibre/usr/include/xorg/xf86Cursor.h new file mode 100644 index 0000000..11a03b6 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Cursor.h @@ -0,0 +1,98 @@ + +#ifndef _XF86CURSOR_H +#define _XF86CURSOR_H + +#include "xf86str.h" +#include "mipointer.h" + +typedef struct _xf86CursorInfoRec { + ScrnInfoPtr pScrn; + int Flags; + int MaxWidth; + int MaxHeight; + void (*SetCursorColors) (ScrnInfoPtr pScrn, int bg, int fg); + void (*SetCursorPosition) (ScrnInfoPtr pScrn, int x, int y); + void (*LoadCursorImage) (ScrnInfoPtr pScrn, unsigned char *bits); + Bool (*LoadCursorImageCheck) (ScrnInfoPtr pScrn, unsigned char *bits); + void (*HideCursor) (ScrnInfoPtr pScrn); + void (*ShowCursor) (ScrnInfoPtr pScrn); + Bool (*ShowCursorCheck) (ScrnInfoPtr pScrn); + unsigned char *(*RealizeCursor) (struct _xf86CursorInfoRec *, CursorPtr); + Bool (*UseHWCursor) (ScreenPtr, CursorPtr); + + Bool (*UseHWCursorARGB) (ScreenPtr, CursorPtr); + void (*LoadCursorARGB) (ScrnInfoPtr, CursorPtr); + Bool (*LoadCursorARGBCheck) (ScrnInfoPtr, CursorPtr); + +} xf86CursorInfoRec, *xf86CursorInfoPtr; + +static inline Bool +xf86DriverHasLoadCursorImage(xf86CursorInfoPtr infoPtr) +{ + return infoPtr->LoadCursorImageCheck || infoPtr->LoadCursorImage; +} + +static inline Bool +xf86DriverLoadCursorImage(xf86CursorInfoPtr infoPtr, unsigned char *bits) +{ + if(infoPtr->LoadCursorImageCheck) + return infoPtr->LoadCursorImageCheck(infoPtr->pScrn, bits); + infoPtr->LoadCursorImage(infoPtr->pScrn, bits); + return TRUE; +} + +static inline Bool +xf86DriverHasShowCursor(xf86CursorInfoPtr infoPtr) +{ + return infoPtr->ShowCursorCheck || infoPtr->ShowCursor; +} + +static inline Bool +xf86DriverShowCursor(xf86CursorInfoPtr infoPtr) +{ + if(infoPtr->ShowCursorCheck) + return infoPtr->ShowCursorCheck(infoPtr->pScrn); + infoPtr->ShowCursor(infoPtr->pScrn); + return TRUE; +} + +static inline Bool +xf86DriverHasLoadCursorARGB(xf86CursorInfoPtr infoPtr) +{ + return infoPtr->LoadCursorARGBCheck || infoPtr->LoadCursorARGB; +} + +static inline Bool +xf86DriverLoadCursorARGB(xf86CursorInfoPtr infoPtr, CursorPtr pCursor) +{ + if(infoPtr->LoadCursorARGBCheck) + return infoPtr->LoadCursorARGBCheck(infoPtr->pScrn, pCursor); + infoPtr->LoadCursorARGB(infoPtr->pScrn, pCursor); + return TRUE; +} + +extern _X_EXPORT Bool xf86InitCursor(ScreenPtr pScreen, + xf86CursorInfoPtr infoPtr); +extern _X_EXPORT xf86CursorInfoPtr xf86CreateCursorInfoRec(void); +extern _X_EXPORT void xf86DestroyCursorInfoRec(xf86CursorInfoPtr); +extern _X_EXPORT void xf86CursorResetCursor(ScreenPtr pScreen); +extern _X_EXPORT void xf86ForceHWCursor(ScreenPtr pScreen, Bool on); +extern _X_EXPORT CursorPtr xf86CurrentCursor(ScreenPtr pScreen); + +#define HARDWARE_CURSOR_INVERT_MASK 0x00000001 +#define HARDWARE_CURSOR_AND_SOURCE_WITH_MASK 0x00000002 +#define HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK 0x00000004 +#define HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED 0x00000008 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 0x00000010 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 0x00000020 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 0x00000040 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 0x00000080 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 0x00000100 +#define HARDWARE_CURSOR_TRUECOLOR_AT_8BPP 0x00000200 +#define HARDWARE_CURSOR_BIT_ORDER_MSBFIRST 0x00000400 +#define HARDWARE_CURSOR_NIBBLE_SWAPPED 0x00000800 +#define HARDWARE_CURSOR_SHOW_TRANSPARENT 0x00001000 +#define HARDWARE_CURSOR_UPDATE_UNHIDDEN 0x00002000 +#define HARDWARE_CURSOR_ARGB 0x00004000 + +#endif /* _XF86CURSOR_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86DDC.h b/prebuilt/xlibre/usr/include/xorg/xf86DDC.h new file mode 100644 index 0000000..7972a1c --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86DDC.h @@ -0,0 +1,66 @@ + +/* xf86DDC.h + * + * This file contains all information to interpret a standard EDIC block + * transmitted by a display device via DDC (Display Data Channel). So far + * there is no information to deal with optional EDID blocks. + * DDC is a Trademark of VESA (Video Electronics Standard Association). + * + * Copyright 1998 by Egbert Eich + */ + +#ifndef XF86_DDC_H +#define XF86_DDC_H + +#include "edid.h" +#include "xf86i2c.h" +#include "xf86str.h" + +/* speed up / slow down */ +typedef enum { + DDC_SLOW, + DDC_FAST +} xf86ddcSpeed; + +typedef void (*DDC1SetSpeedProc) (ScrnInfoPtr, xf86ddcSpeed); + +extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC1(ScrnInfoPtr pScrn, + DDC1SetSpeedProc DDC1SetSpeed, + unsigned + int (*DDC1Read) (ScrnInfoPtr) + ); + +extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC2(ScrnInfoPtr pScrn, I2CBusPtr pBus); + +extern _X_EXPORT xf86MonPtr xf86DoEEDID(ScrnInfoPtr pScrn, I2CBusPtr pBus, Bool); + +extern _X_EXPORT xf86MonPtr xf86PrintEDID(xf86MonPtr monPtr); + +extern _X_EXPORT xf86MonPtr xf86InterpretEDID(int screenIndex, uint8_t * block); + +extern _X_EXPORT xf86MonPtr xf86InterpretEEDID(int screenIndex, uint8_t * block); + +extern _X_EXPORT Bool xf86SetDDCproperties(ScrnInfoPtr pScreen, xf86MonPtr DDC); + +/** + * @brief xf86DoInterpretHDRMetadata fill hdr structure using raw edid data + * This function is necessary because xf86InterpretEDID have no indication if this whole EDID or not + * @param monPtr + * @return true if colorimetry & hdr static metadata is found + */ +_X_EXPORT bool xf86DoInterpretHDRMetadata(xf86MonPtr monPtr); + +/* + * parse EDID block and return a newly allocated xf86Monitor + * + * the data block will be copied into the structure (actually right after the struct) + * and thus automatically be freed when the returned struct is freed. + * + * @param screenIndex index of the screen, will be recorded in the xf86Monitor + * @param block the EDID block to parse + * @param size size of the EDID block (128 or larger for extended types) + * @return newly allocated xf86MonRec or NULL on failure + */ +_X_EXPORT xf86MonPtr xf86ParseEDID(ScrnInfoPtr pScreen, uint8_t *block, size_t size); + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Modes.h b/prebuilt/xlibre/usr/include/xorg/xf86Modes.h new file mode 100644 index 0000000..5458918 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Modes.h @@ -0,0 +1,117 @@ +/* + * Copyright © 2006 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + * Eric Anholt + * + */ + +#ifndef _XF86MODES_H_ +#define _XF86MODES_H_ + +#include +#include +#include + +#include "xf86.h" +#include "xorgVersion.h" +#include "edid.h" +#include "xf86Parser.h" + +extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec * mode); +extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec * mode); +extern _X_EXPORT unsigned int xf86ModeBandwidth(DisplayModePtr mode, int depth); + +extern _X_EXPORT int + xf86ModeWidth(const DisplayModeRec * mode, Rotation rotation); + +extern _X_EXPORT int + xf86ModeHeight(const DisplayModeRec * mode, Rotation rotation); + +extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec * pMode); +extern _X_EXPORT DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, + DisplayModePtr modeList); +extern _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode); +extern _X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags); +extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec * pMode1, + const DisplayModeRec * pMode2); +extern _X_EXPORT void xf86PrintModeline(int scrnIndex, DisplayModePtr mode); +extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes, + DisplayModePtr new); + +extern _X_EXPORT DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC); +extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, + float VRefresh, Bool Reduced, + Bool Interlaced); +extern _X_EXPORT DisplayModePtr xf86GTFMode(int h_pixels, int v_lines, + float freq, int interlaced, + int margins); + +extern _X_EXPORT Bool + xf86ModeIsReduced(const DisplayModeRec * mode); + +extern _X_EXPORT void + xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, int flags); + +extern _X_EXPORT void + +xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int *min, int *max, int n_ranges); + +extern _X_EXPORT void + +xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int maxX, int maxY, int maxPitch); + +extern _X_EXPORT void + xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, MonPtr mon); + +extern _X_EXPORT void + +xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList, + unsigned int bandwidth, int depth); + +extern _X_EXPORT void + xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList); + +extern _X_EXPORT void + +xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr * modeList, + Bool verbose); + +extern _X_EXPORT DisplayModePtr xf86PruneDuplicateModes(DisplayModePtr modes); + +extern _X_EXPORT void + xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList); + +extern _X_EXPORT DisplayModePtr +xf86GetMonitorModes(ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor); + +extern _X_EXPORT DisplayModePtr xf86GetDefaultModes(void); + +extern _X_EXPORT void +xf86SaveModeContents(DisplayModePtr intern, const DisplayModeRec *mode); + +extern _X_EXPORT void + xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC); + +#endif /* _XF86MODES_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Module.h b/prebuilt/xlibre/usr/include/xorg/xf86Module.h new file mode 100644 index 0000000..2bd6bdb --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Module.h @@ -0,0 +1,240 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the parts of the loader interface that are visible + * to modules. This is the only loader-related header that modules should + * include. + * + * It should include a bare minimum of other headers. + * + * Longer term, the module/loader code should probably live directly under + * Xserver/. + * + * XXX This file arguably belongs in xfree86/loader/. + */ + +#ifndef _XF86MODULE_H +#define _XF86MODULE_H + +#include +#include +#include + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define DEFAULT_LIST ((char *)-1) + +/* Built-in ABI classes. These definitions must not be changed. */ +#define ABI_CLASS_NONE NULL +#define ABI_CLASS_ANSIC "X.Org ANSI C Emulation" +#define ABI_CLASS_VIDEODRV "X.Org Video Driver" +#define ABI_CLASS_XINPUT "X.Org XInput driver" +#define ABI_CLASS_EXTENSION "X.Org Server Extension" + +#define ABI_MINOR_MASK 0x0000FFFF +#define ABI_MAJOR_MASK 0xFFFF0000 +#define GET_ABI_MINOR(v) ((v) & ABI_MINOR_MASK) +#define GET_ABI_MAJOR(v) (((v) & ABI_MAJOR_MASK) >> 16) +#define SET_ABI_VERSION(maj, min) \ + ((((maj) << 16) & ABI_MAJOR_MASK) | ((min) & ABI_MINOR_MASK)) + +/* + * ABI versions. Each version has a major and minor revision. Modules + * using lower minor revisions must work with servers of a higher minor + * revision. There is no compatibility between different major revisions. + * Whenever the ABI_ANSIC_VERSION is changed, the others must also be + * changed. The minor revision mask is 0x0000FFFF and the major revision + * mask is 0xFFFF0000. + */ +#define ABI_ANSIC_VERSION SET_ABI_VERSION(1, 4) + +/* XXX This is a compile-time option that changes abi XXX */ +/* TODO: Remove this toggle in 26.0 */ +#ifdef CONFIG_LEGACY_NVIDIA_PADDING +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(28, 1) +#else +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(28, 0) +#endif +#define ABI_XINPUT_VERSION SET_ABI_VERSION(26, 0) +#define ABI_EXTENSION_VERSION SET_ABI_VERSION(11, 0) + +/* hack to get both modern and ancient nvidia DDX drivers to work at the same time */ +#define ABI_NVIDIA_VERSION SET_ABI_VERSION(25, 2) + +#define MODINFOSTRING1 0xef23fdc5 +#define MODINFOSTRING2 0x10dc023a + +#ifndef MODULEVENDORSTRING +#define MODULEVENDORSTRING "X.Org Foundation" +#endif + +/* Error return codes for errmaj */ +typedef enum { + LDR_NOERROR = 0, + LDR_NOMEM, /* memory allocation failed */ + LDR_NOENT, /* Module file does not exist */ + LDR_NOLOAD, /* type specific loader failed */ + LDR_ONCEONLY, /* Module should only be loaded once (not an error) */ + LDR_MISMATCH, /* the module didn't match the spec'd requirements */ + LDR_BADUSAGE, /* LoadModule is called with bad arguments */ + LDR_INVALID, /* The module doesn't have a valid ModuleData object */ + LDR_BADOS, /* The module doesn't support the OS */ + LDR_MODSPECIFIC /* A module-specific error in the SetupProc */ +} LoaderErrorCode; + +/* + * Some common module classes. The moduleclass can be used to identify + * that modules loaded are of the correct type. This is a finer + * classification than the ABI classes even though the default set of + * classes have the same names. For example, not all modules that require + * the video driver ABI are themselves video drivers. + */ +#define MOD_CLASS_NONE NULL +#define MOD_CLASS_VIDEODRV "X.Org Video Driver" +#define MOD_CLASS_XINPUT "X.Org XInput Driver" +#define MOD_CLASS_EXTENSION "X.Org Server Extension" + +/* This structure is expected to be returned by the initfunc */ +typedef struct { + const char *modname; /* name of module, e.g. "foo" */ + const char *vendor; /* vendor specific string */ + CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */ + CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */ + CARD32 xf86version; /* contains XF86_VERSION_CURRENT */ + CARD8 majorversion; /* module-specific major version */ + CARD8 minorversion; /* module-specific minor version */ + CARD16 patchlevel; /* module-specific patch level */ + const char *abiclass; /* ABI class that the module uses */ + CARD32 abiversion; /* ABI version */ + const char *moduleclass; /* module class description */ + CARD32 checksum[4]; /* contains a digital signature of the */ + /* version info structure */ +} XF86ModuleVersionInfo; + +/* + * This structure can be used to callers of LoadModule and LoadSubModule to + * specify version and/or ABI requirements. + */ +typedef struct { + CARD8 majorversion; /* module-specific major version */ + CARD8 minorversion; /* module-specific minor version */ + CARD16 patchlevel; /* module-specific patch level */ + const char *abiclass; /* ABI class that the module uses */ + CARD32 abiversion; /* ABI version */ + const char *moduleclass; /* module class */ +} XF86ModReqInfo; + +#define MODULE_VERSION_NUMERIC(maj, min, patch) \ + ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | ((patch) & 0xFFFF)) + +/* Prototypes for Loader functions that are exported to modules */ +extern _X_EXPORT void *LoadSubModule(void *, const char *, const char **, + const char **, void *, + const XF86ModReqInfo *, int *, int *); +extern _X_EXPORT void *LoaderSymbol(const char *); +extern _X_EXPORT void *LoaderSymbolFromModule(void *, const char *); +extern _X_EXPORT void LoaderErrorMsg(const char *, const char *, int, int); + +/* deprecated, only kept for backwards compat w/ proprietary NVidia driver */ +extern _X_EXPORT Bool LoaderShouldIgnoreABI(void) _X_DEPRECATED; +extern _X_EXPORT int LoaderGetABIVersion(const char *abiclass) _X_DEPRECATED; + +typedef void *(*ModuleSetupProc) (void *, void *, int *, int *); +typedef void (*ModuleTearDownProc) (void *); + +#define MODULESETUPPROTO(func) void *(func)(void *, void *, int*, int*) + +/* + * Module information header. Every loadable module needs to export a symbol + * of that type, so the loader can call into the module for initialization. + * The symbol must be named + "ModuleData". + */ +typedef struct { + /* must point to structure with version information */ + XF86ModuleVersionInfo *vers; + /* called on module load (if not null) */ + ModuleSetupProc setup; + /* called on module teardown with setup()'s result as parameter (if not null) */ + ModuleTearDownProc teardown; +} XF86ModuleData; + +/* + * declare module version info structure for an input driver module + */ +#define XF86_MODULE_VERSION_INPUT(_name, _major, _minor, _patchlevel) \ + static XF86ModuleVersionInfo modVersion = { \ + .modname = (_name), \ + .vendor = MODULEVENDORSTRING, \ + ._modinfo1_ = MODINFOSTRING1, \ + ._modinfo2_ = MODINFOSTRING2, \ + .xf86version = XORG_VERSION_CURRENT, \ + .majorversion = (_major), \ + .minorversion = (_minor), \ + .patchlevel = (_patchlevel), \ + .abiclass = ABI_CLASS_XINPUT, \ + .abiversion = ABI_XINPUT_VERSION, \ + .moduleclass = MOD_CLASS_XINPUT, \ + }; + +/* + * declare module version info structure for an video driver module + */ +#define XF86_MODULE_VERSION_VIDEO(_name, _major, _minor, _patchlevel) \ + static XF86ModuleVersionInfo modVersion = { \ + .modname = (_name), \ + .vendor = MODULEVENDORSTRING, \ + ._modinfo1_ = MODINFOSTRING1, \ + ._modinfo2_ = MODINFOSTRING2, \ + .xf86version = XORG_VERSION_CURRENT, \ + .majorversion = (_major), \ + .minorversion = (_minor), \ + .patchlevel = (_patchlevel), \ + .abiclass = ABI_CLASS_VIDEODRV, \ + .abiversion = ABI_VIDEODRV_VERSION, \ + .moduleclass = MOD_CLASS_VIDEODRV, \ + }; + +#define XF86_MODULE_DATA_INPUT(_modname, _setup, _teardown, _name, _major, _minor, _patchlevel) \ + XF86_MODULE_VERSION_INPUT(_name, _major, _minor, _patchlevel) \ + _X_EXPORT XF86ModuleData _modname##ModuleData = { \ + .vers = &modVersion, \ + .setup = _setup, \ + .teardown = _teardown, \ + }; + +#define XF86_MODULE_DATA_VIDEO(_modname, _setup, _teardown, _name, _major, _minor, _patchlevel) \ + XF86_MODULE_VERSION_VIDEO(_name, _major, _minor, _patchlevel) \ + _X_EXPORT XF86ModuleData _modname##ModuleData = { \ + .vers = &modVersion, \ + .setup = _setup, \ + .teardown = _teardown, \ + }; + +#endif /* _XF86MODULE_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Opt.h b/prebuilt/xlibre/usr/include/xorg/xf86Opt.h new file mode 100644 index 0000000..b9087e2 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Opt.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1998-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Option handling things that ModuleSetup procs can use */ + +#ifndef _XF86_OPT_H_ +#define _XF86_OPT_H_ + +#include +#include + +#include "xf86Optionstr.h" + +typedef struct { + double freq; + int units; +} OptFrequency; + +typedef union { + unsigned long num; + const char *str; + double realnum; + Bool boolean; + OptFrequency freq; +} ValueUnion; + +typedef enum { + OPTV_NONE = 0, + OPTV_INTEGER, + OPTV_STRING, /* a non-empty string */ + OPTV_ANYSTR, /* Any string, including an empty one */ + OPTV_REAL, + OPTV_BOOLEAN, + OPTV_PERCENT, + OPTV_FREQ +} OptionValueType; + +typedef enum { + OPTUNITS_HZ = 1, + OPTUNITS_KHZ, + OPTUNITS_MHZ +} OptFreqUnits; + +typedef struct { + int token; + const char *name; + OptionValueType type; + ValueUnion value; + Bool found; +} OptionInfoRec, *OptionInfoPtr; + +extern _X_EXPORT int xf86SetIntOption(XF86OptionPtr optlist, const char *name, + int deflt); +extern _X_EXPORT double xf86SetRealOption(XF86OptionPtr optlist, + const char *name, double deflt); +extern _X_EXPORT char *xf86SetStrOption(XF86OptionPtr optlist, const char *name, + const char *deflt); +extern _X_EXPORT int xf86SetBoolOption(XF86OptionPtr list, const char *name, + int deflt); +extern _X_EXPORT double xf86SetPercentOption(XF86OptionPtr list, + const char *name, double deflt); +extern _X_EXPORT int xf86CheckIntOption(XF86OptionPtr optlist, const char *name, + int deflt); +extern _X_EXPORT char *xf86CheckStrOption(XF86OptionPtr optlist, + const char *name, const char *deflt); +extern _X_EXPORT int xf86CheckBoolOption(XF86OptionPtr list, const char *name, + int deflt); +extern _X_EXPORT double xf86CheckPercentOption(XF86OptionPtr list, + const char *name, double deflt); +extern _X_EXPORT XF86OptionPtr xf86AddNewOption(XF86OptionPtr head, + const char *name, + const char *val); +extern _X_EXPORT XF86OptionPtr xf86NextOption(XF86OptionPtr list); +extern _X_EXPORT XF86OptionPtr xf86OptionListCreate(const char **options, + int count, int used); +extern _X_EXPORT XF86OptionPtr xf86OptionListMerge(XF86OptionPtr head, + XF86OptionPtr tail); +extern _X_EXPORT XF86OptionPtr xf86OptionListDuplicate(XF86OptionPtr list); +extern _X_EXPORT void xf86OptionListFree(XF86OptionPtr opt); +extern _X_EXPORT char *xf86OptionName(XF86OptionPtr opt); +extern _X_EXPORT char *xf86OptionValue(XF86OptionPtr opt); +extern _X_EXPORT XF86OptionPtr xf86FindOption(XF86OptionPtr options, + const char *name); +extern _X_EXPORT const char *xf86FindOptionValue(XF86OptionPtr options, + const char *name); +extern _X_EXPORT void xf86MarkOptionUsedByName(XF86OptionPtr options, + const char *name); +extern _X_EXPORT void xf86ShowUnusedOptions(int scrnIndex, + XF86OptionPtr options); +extern _X_EXPORT void xf86ProcessOptions(int scrnIndex, XF86OptionPtr options, + OptionInfoPtr optinfo); +extern _X_EXPORT OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec * table, + int token); +extern _X_EXPORT const char *xf86TokenToOptName(const OptionInfoRec * table, + int token); +extern _X_EXPORT Bool xf86IsOptionSet(const OptionInfoRec * table, int token); +extern _X_EXPORT const char *xf86GetOptValString(const OptionInfoRec * table, + int token); +extern _X_EXPORT Bool xf86GetOptValInteger(const OptionInfoRec * table, + int token, int *value); +extern _X_EXPORT Bool xf86GetOptValULong(const OptionInfoRec * table, int token, + unsigned long *value); +extern _X_EXPORT Bool xf86GetOptValFreq(const OptionInfoRec * table, int token, + OptFreqUnits expectedUnits, + double *value); +extern _X_EXPORT Bool xf86GetOptValBool(const OptionInfoRec * table, int token, + Bool *value); +extern _X_EXPORT Bool xf86ReturnOptValBool(const OptionInfoRec * table, + int token, Bool def); +extern _X_EXPORT int xf86NameCmp(const char *s1, const char *s2); +extern _X_EXPORT char *xf86NormalizeName(const char *s); +extern _X_EXPORT XF86OptionPtr xf86ReplaceIntOption(XF86OptionPtr optlist, + const char *name, + const int val); +extern _X_EXPORT XF86OptionPtr xf86ReplaceBoolOption(XF86OptionPtr optlist, + const char *name, + const Bool val); +extern _X_EXPORT XF86OptionPtr xf86ReplaceStrOption(XF86OptionPtr optlist, + const char *name, + const char *val); +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Optionstr.h b/prebuilt/xlibre/usr/include/xorg/xf86Optionstr.h new file mode 100644 index 0000000..4ef917d --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Optionstr.h @@ -0,0 +1,42 @@ +/* + * Copyright © 2011 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef XF86OPTIONSTR_H +#define XF86OPTIONSTR_H +#include "list.h" + +/* + * All options are stored using this data type. + */ +typedef struct _XF86OptionRec { + GenericListRec list; + const char *opt_name; + const char *opt_val; + int opt_used; + const char *opt_comment; +} XF86OptionRec; + +typedef struct _InputOption *XF86OptionPtr; + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Optrec.h b/prebuilt/xlibre/usr/include/xorg/xf86Optrec.h new file mode 100644 index 0000000..8447d7d --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Optrec.h @@ -0,0 +1,90 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the Option Record that is passed between the Parser, + * and Module setup procs. + */ +#ifndef _xf86Optrec_h_ +#define _xf86Optrec_h_ + +#include +#include +#include "xf86Optionstr.h" + +#include + +extern _X_EXPORT XF86OptionPtr xf86addNewOption(XF86OptionPtr head, char *name, + char *val); +extern _X_EXPORT XF86OptionPtr xf86optionListDup(XF86OptionPtr opt); +extern _X_EXPORT void xf86optionListFree(XF86OptionPtr opt); +extern _X_EXPORT char *xf86optionName(XF86OptionPtr opt); +extern _X_EXPORT char *xf86optionValue(XF86OptionPtr opt); +extern _X_EXPORT XF86OptionPtr xf86newOption(char *name, char *value); +extern _X_EXPORT XF86OptionPtr xf86nextOption(XF86OptionPtr list); +extern _X_EXPORT XF86OptionPtr xf86findOption(XF86OptionPtr list, + const char *name); +extern _X_EXPORT const char *xf86findOptionValue(XF86OptionPtr list, + const char *name); +extern _X_EXPORT XF86OptionPtr xf86optionListCreate(const char **options, + int count, int used); +extern _X_EXPORT XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, + XF86OptionPtr tail); +extern _X_EXPORT int xf86nameCompare(const char *s1, const char *s2); +extern _X_EXPORT char *xf86uLongToString(unsigned long i); +extern _X_EXPORT XF86OptionPtr xf86parseOption(XF86OptionPtr head); +extern _X_EXPORT void xf86printOptionList(FILE * fp, XF86OptionPtr list, + int tabs); + +#endif /* _xf86Optrec_h_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Parser.h b/prebuilt/xlibre/usr/include/xorg/xf86Parser.h new file mode 100644 index 0000000..b4c33a3 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Parser.h @@ -0,0 +1,487 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the external interfaces for the XFree86 configuration + * file parser. + */ +#ifndef _xf86Parser_h_ +#define _xf86Parser_h_ + +#include +#include "xf86Optrec.h" +#include "list.h" + +#include +#include + +#define HAVE_PARSER_DECLS + +typedef struct { + char *file_logfile; + char *file_modulepath; + char *file_fontpath; + char *file_comment; + char *file_xkbdir; +} XF86ConfFilesRec, *XF86ConfFilesPtr; + +/* Values for load_type */ +#define XF86_LOAD_MODULE 0 +#define XF86_LOAD_DRIVER 1 +#define XF86_DISABLE_MODULE 2 + +typedef struct { + GenericListRec list; + int load_type; + const char *load_name; + XF86OptionPtr load_opt; + char *load_comment; + int ignore; +} XF86LoadRec, *XF86LoadPtr; + +typedef struct { + XF86LoadPtr mod_load_lst; + XF86LoadPtr mod_disable_lst; + char *mod_comment; +} XF86ConfModuleRec, *XF86ConfModulePtr; + +#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard" + +#define CONF_IMPLICIT_POINTER "Implicit Core Pointer" + +#define XF86CONF_PHSYNC 0x0001 +#define XF86CONF_NHSYNC 0x0002 +#define XF86CONF_PVSYNC 0x0004 +#define XF86CONF_NVSYNC 0x0008 +#define XF86CONF_INTERLACE 0x0010 +#define XF86CONF_DBLSCAN 0x0020 +#define XF86CONF_CSYNC 0x0040 +#define XF86CONF_PCSYNC 0x0080 +#define XF86CONF_NCSYNC 0x0100 +#define XF86CONF_HSKEW 0x0200 /* hskew provided */ +#define XF86CONF_BCAST 0x0400 +#define XF86CONF_VSCAN 0x1000 + +typedef struct { + GenericListRec list; + const char *ml_identifier; + int ml_clock; + int ml_hdisplay; + int ml_hsyncstart; + int ml_hsyncend; + int ml_htotal; + int ml_vdisplay; + int ml_vsyncstart; + int ml_vsyncend; + int ml_vtotal; + int ml_vscan; + int ml_flags; + int ml_hskew; + char *ml_comment; +} XF86ConfModeLineRec, *XF86ConfModeLinePtr; + +typedef struct { + GenericListRec list; + const char *vp_identifier; + XF86OptionPtr vp_option_lst; + char *vp_comment; +} XF86ConfVideoPortRec, *XF86ConfVideoPortPtr; + +typedef struct { + GenericListRec list; + const char *va_identifier; + const char *va_vendor; + const char *va_board; + const char *va_busid; + const char *va_driver; + XF86OptionPtr va_option_lst; + XF86ConfVideoPortPtr va_port_lst; + const char *va_fwdref; + char *va_comment; +} XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr; + +#define CONF_MAX_HSYNC 8 +#define CONF_MAX_VREFRESH 8 + +typedef struct { + float hi, lo; +} parser_range; + +typedef struct { + int red, green, blue; +} parser_rgb; + +typedef struct { + GenericListRec list; + const char *modes_identifier; + XF86ConfModeLinePtr mon_modeline_lst; + char *modes_comment; +} XF86ConfModesRec, *XF86ConfModesPtr; + +typedef struct { + GenericListRec list; + const char *ml_modes_str; + XF86ConfModesPtr ml_modes; +} XF86ConfModesLinkRec, *XF86ConfModesLinkPtr; + +typedef struct { + GenericListRec list; + const char *mon_identifier; + const char *mon_vendor; + char *mon_modelname; + int mon_width; /* in mm */ + int mon_height; /* in mm */ + XF86ConfModeLinePtr mon_modeline_lst; + int mon_n_hsync; + parser_range mon_hsync[CONF_MAX_HSYNC]; + int mon_n_vrefresh; + parser_range mon_vrefresh[CONF_MAX_VREFRESH]; + float mon_gamma_red; + float mon_gamma_green; + float mon_gamma_blue; + XF86OptionPtr mon_option_lst; + XF86ConfModesLinkPtr mon_modes_sect_lst; + char *mon_comment; +} XF86ConfMonitorRec, *XF86ConfMonitorPtr; + +#define CONF_MAXDACSPEEDS 4 +#define CONF_MAXCLOCKS 128 + +typedef struct { + GenericListRec list; + const char *dev_identifier; + const char *dev_vendor; + const char *dev_board; + const char *dev_chipset; + const char *dev_busid; + const char *dev_card; + const char *dev_driver; + const char *dev_ramdac; + int dev_dacSpeeds[CONF_MAXDACSPEEDS]; + int dev_videoram; + unsigned long dev_mem_base; + unsigned long dev_io_base; + const char *dev_clockchip; + int dev_clocks; + int dev_clock[CONF_MAXCLOCKS]; + int dev_chipid; + int dev_chiprev; + int dev_irq; + int dev_screen; + XF86OptionPtr dev_option_lst; + char *dev_comment; + char *match_seat; +} XF86ConfDeviceRec, *XF86ConfDevicePtr; + +typedef struct { + GenericListRec list; + const char *mode_name; +} XF86ModeRec, *XF86ModePtr; + +typedef struct { + GenericListRec list; + int disp_frameX0; + int disp_frameY0; + int disp_virtualX; + int disp_virtualY; + int disp_depth; + int disp_bpp; + const char *disp_visual; + parser_rgb disp_weight; + parser_rgb disp_black; + parser_rgb disp_white; + XF86ModePtr disp_mode_lst; + XF86OptionPtr disp_option_lst; + char *disp_comment; +} XF86ConfDisplayRec, *XF86ConfDisplayPtr; + +typedef struct { + XF86OptionPtr flg_option_lst; + char *flg_comment; +} XF86ConfFlagsRec, *XF86ConfFlagsPtr; + +typedef struct { + GenericListRec list; + const char *al_adaptor_str; + XF86ConfVideoAdaptorPtr al_adaptor; +} XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr; + +#define CONF_MAXGPUDEVICES 4 +typedef struct { + GenericListRec list; + const char *scrn_identifier; + const char *scrn_obso_driver; + int scrn_defaultdepth; + int scrn_defaultbpp; + int scrn_defaultfbbpp; + const char *scrn_monitor_str; + XF86ConfMonitorPtr scrn_monitor; + const char *scrn_device_str; + XF86ConfDevicePtr scrn_device; + XF86ConfAdaptorLinkPtr scrn_adaptor_lst; + XF86ConfDisplayPtr scrn_display_lst; + XF86OptionPtr scrn_option_lst; + char *scrn_comment; + int scrn_virtualX, scrn_virtualY; + char *match_seat; + + int num_gpu_devices; + const char *scrn_gpu_device_str[CONF_MAXGPUDEVICES]; + XF86ConfDevicePtr scrn_gpu_devices[CONF_MAXGPUDEVICES]; +} XF86ConfScreenRec, *XF86ConfScreenPtr; + +typedef struct { + GenericListRec list; + char *inp_identifier; + char *inp_driver; + XF86OptionPtr inp_option_lst; + char *inp_comment; +} XF86ConfInputRec, *XF86ConfInputPtr; + +typedef struct { + GenericListRec list; + XF86ConfInputPtr iref_inputdev; + char *iref_inputdev_str; + XF86OptionPtr iref_option_lst; +} XF86ConfInputrefRec, *XF86ConfInputrefPtr; + +typedef struct { + Bool set; + Bool val; +} xf86TriState; + +typedef struct { + struct xorg_list entry; + struct xorg_list patterns; + Bool is_negated; +} xf86MatchGroup; + +typedef enum { + MATCH_IS_INVALID, + MATCH_EXACT, + MATCH_EXACT_NOCASE, + MATCH_AS_SUBSTRING, + MATCH_AS_SUBSTRING_NOCASE, + MATCH_AS_FILENAME, + MATCH_AS_PATHNAME, + MATCH_SUBSTRINGS_SEQUENCE, + MATCH_REGEX +} xf86MatchMode; + +typedef struct { + struct xorg_list entry; + xf86MatchMode mode; + Bool is_negated; + char *str; + regex_t *regex; +} xf86MatchPattern; + +typedef struct { + GenericListRec list; + char *identifier; + char *driver; + struct xorg_list match_product; + struct xorg_list match_vendor; + struct xorg_list match_device; + struct xorg_list match_os; + struct xorg_list match_pnpid; + struct xorg_list match_usbid; + struct xorg_list match_driver; + struct xorg_list match_tag; + struct xorg_list match_layout; + xf86TriState is_keyboard; + xf86TriState is_pointer; + xf86TriState is_joystick; + xf86TriState is_tablet; + xf86TriState is_tablet_pad; + xf86TriState is_touchpad; + xf86TriState is_touchscreen; + XF86OptionPtr option_lst; + char *comment; +} XF86ConfInputClassRec, *XF86ConfInputClassPtr; + +typedef struct { + GenericListRec list; + char *identifier; + char *driver; + char *modules; + char *modulepath; + struct xorg_list match_driver; + struct xorg_list match_layout; + XF86OptionPtr option_lst; + char *comment; +} XF86ConfOutputClassRec, *XF86ConfOutputClassPtr; + +/* Values for adj_where */ +#define CONF_ADJ_OBSOLETE -1 +#define CONF_ADJ_ABSOLUTE 0 +#define CONF_ADJ_RIGHTOF 1 +#define CONF_ADJ_LEFTOF 2 +#define CONF_ADJ_ABOVE 3 +#define CONF_ADJ_BELOW 4 +#define CONF_ADJ_RELATIVE 5 + +typedef struct { + GenericListRec list; + int adj_scrnum; + XF86ConfScreenPtr adj_screen; + const char *adj_screen_str; + XF86ConfScreenPtr adj_top; + const char *adj_top_str; + XF86ConfScreenPtr adj_bottom; + const char *adj_bottom_str; + XF86ConfScreenPtr adj_left; + const char *adj_left_str; + XF86ConfScreenPtr adj_right; + const char *adj_right_str; + int adj_where; + int adj_x; + int adj_y; + const char *adj_refscreen; +} XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr; + +typedef struct { + GenericListRec list; + const char *inactive_device_str; + XF86ConfDevicePtr inactive_device; +} XF86ConfInactiveRec, *XF86ConfInactivePtr; + +typedef struct { + GenericListRec list; + const char *lay_identifier; + XF86ConfAdjacencyPtr lay_adjacency_lst; + XF86ConfInactivePtr lay_inactive_lst; + XF86ConfInputrefPtr lay_input_lst; + XF86OptionPtr lay_option_lst; + char *match_seat; + char *lay_comment; +} XF86ConfLayoutRec, *XF86ConfLayoutPtr; + +typedef struct { + GenericListRec list; + const char *vs_name; + const char *vs_identifier; + XF86OptionPtr vs_option_lst; + char *vs_comment; +} XF86ConfVendSubRec, *XF86ConfVendSubPtr; + +typedef struct { + GenericListRec list; + const char *vnd_identifier; + XF86OptionPtr vnd_option_lst; + XF86ConfVendSubPtr vnd_sub_lst; + char *vnd_comment; +} XF86ConfVendorRec, *XF86ConfVendorPtr; + +typedef struct { + XF86OptionPtr ext_option_lst; + char *extensions_comment; +} XF86ConfExtensionsRec, *XF86ConfExtensionsPtr; + +typedef struct { + XF86ConfFilesPtr conf_files; + XF86ConfModulePtr conf_modules; + XF86ConfFlagsPtr conf_flags; + XF86ConfVideoAdaptorPtr conf_videoadaptor_lst; + XF86ConfModesPtr conf_modes_lst; + XF86ConfMonitorPtr conf_monitor_lst; + XF86ConfDevicePtr conf_device_lst; + XF86ConfScreenPtr conf_screen_lst; + XF86ConfInputPtr conf_input_lst; + XF86ConfInputClassPtr conf_inputclass_lst; + XF86ConfOutputClassPtr conf_outputclass_lst; + XF86ConfLayoutPtr conf_layout_lst; + XF86ConfVendorPtr conf_vendor_lst; + void *padding0; + XF86ConfExtensionsPtr conf_extensions; + char *conf_comment; +} XF86ConfigRec, *XF86ConfigPtr; + +typedef struct { + int token; /* id of the token */ + const char *name; /* pointer to the LOWERCASED name */ +} xf86ConfigSymTabRec, *xf86ConfigSymTabPtr; + +/* + * prototypes for public functions + */ +extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, + XF86ConfDevicePtr p); +extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, + XF86ConfLayoutPtr list); +extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, + XF86ConfMonitorPtr p); +extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, + XF86ConfModesPtr p); +extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, + XF86ConfModeLinePtr p); +extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, + XF86ConfScreenPtr p); +extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, + XF86ConfInputPtr p); +extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, + XF86ConfInputPtr p); +extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident, + XF86ConfVideoAdaptorPtr + p); +extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, + GenericListPtr c_new); +extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, + GenericListPtr list_2); +extern _X_EXPORT int xf86pathIsAbsolute(const char *path); +extern _X_EXPORT int xf86pathIsSafe(const char *path); +extern _X_EXPORT char *xf86addComment(char *cur, const char *add); +extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str); + +#endif /* _xf86Parser_h_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Pci.h b/prebuilt/xlibre/usr/include/xorg/xf86Pci.h new file mode 100644 index 0000000..6b31616 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Pci.h @@ -0,0 +1,234 @@ +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This file is derived in part from the original xf86_PCI.h that included + * following copyright message: + * + * Copyright 1995 by Robin Cutshaw + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains just the public interface to the PCI code. + * Drivers should use this file rather than Pci.h. + */ + +#ifndef _XF86PCI_H +#define _XF86PCI_H 1 +#include +#include +#include "misc.h" +#include + +/* + * PCI cfg space definitions (e.g. stuff right out of the PCI spec) + */ + +/* Device identification register */ +#define PCI_ID_REG 0x00 + +/* Command and status register */ +#define PCI_CMD_STAT_REG 0x04 +#define PCI_CMD_BASE_REG 0x10 +#define PCI_CMD_BIOS_REG 0x30 +#define PCI_CMD_MASK 0xffff +#define PCI_CMD_IO_ENABLE 0x01 +#define PCI_CMD_MEM_ENABLE 0x02 +#define PCI_CMD_MASTER_ENABLE 0x04 +#define PCI_CMD_SPECIAL_ENABLE 0x08 +#define PCI_CMD_INVALIDATE_ENABLE 0x10 +#define PCI_CMD_PALETTE_ENABLE 0x20 +#define PCI_CMD_PARITY_ENABLE 0x40 +#define PCI_CMD_STEPPING_ENABLE 0x80 +#define PCI_CMD_SERR_ENABLE 0x100 +#define PCI_CMD_BACKTOBACK_ENABLE 0x200 +#define PCI_CMD_BIOS_ENABLE 0x01 + +/* base class */ +#define PCI_CLASS_REG 0x08 +#define PCI_CLASS_MASK 0xff000000 +#define PCI_CLASS_SHIFT 24 +#define PCI_CLASS_EXTRACT(x) \ + (((x) & PCI_CLASS_MASK) >> PCI_CLASS_SHIFT) + +/* base class values */ +#define PCI_CLASS_PREHISTORIC 0x00 +#define PCI_CLASS_MASS_STORAGE 0x01 +#define PCI_CLASS_NETWORK 0x02 +#define PCI_CLASS_DISPLAY 0x03 +#define PCI_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MEMORY 0x05 +#define PCI_CLASS_BRIDGE 0x06 +#define PCI_CLASS_COMMUNICATIONS 0x07 +#define PCI_CLASS_SYSPERIPH 0x08 +#define PCI_CLASS_INPUT 0x09 +#define PCI_CLASS_DOCKING 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIALBUS 0x0c +#define PCI_CLASS_WIRELESS 0x0d +#define PCI_CLASS_I2O 0x0e +#define PCI_CLASS_SATELLITE 0x0f +#define PCI_CLASS_CRYPT 0x10 +#define PCI_CLASS_DATA_ACQUISITION 0x11 +#define PCI_CLASS_UNDEFINED 0xff + +/* sub class */ +#define PCI_SUBCLASS_MASK 0x00ff0000 +#define PCI_SUBCLASS_SHIFT 16 +#define PCI_SUBCLASS_EXTRACT(x) \ + (((x) & PCI_SUBCLASS_MASK) >> PCI_SUBCLASS_SHIFT) + +/* Sub class values */ +/* 0x00 prehistoric subclasses */ +#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00 +#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01 + +/* 0x03 display subclasses */ +#define PCI_SUBCLASS_DISPLAY_VGA 0x00 +#define PCI_SUBCLASS_DISPLAY_XGA 0x01 +#define PCI_SUBCLASS_DISPLAY_MISC 0x80 + +/* 0x04 multimedia subclasses */ +#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00 +#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01 +#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80 + +/* 0x06 bridge subclasses */ +#define PCI_SUBCLASS_BRIDGE_HOST 0x00 +#define PCI_SUBCLASS_BRIDGE_ISA 0x01 +#define PCI_SUBCLASS_BRIDGE_EISA 0x02 +#define PCI_SUBCLASS_BRIDGE_MC 0x03 +#define PCI_SUBCLASS_BRIDGE_PCI 0x04 +#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05 +#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06 +#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07 +#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08 +#define PCI_SUBCLASS_BRIDGE_MISC 0x80 +#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01 + +/* 0x0b processor subclasses */ +#define PCI_SUBCLASS_PROCESSOR_386 0x00 +#define PCI_SUBCLASS_PROCESSOR_486 0x01 +#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02 +#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10 +#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20 +#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30 +#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40 + +/* PCI-PCI bridge mapping registers */ +#define PCI_PCI_BRIDGE_BUS_REG 0x18 +#define PCI_SUBORDINATE_BUS_MASK 0x00ff0000 +#define PCI_SECONDARY_BUS_MASK 0x0000ff00 +#define PCI_PRIMARY_BUS_MASK 0x000000ff + +#define PCI_PCI_BRIDGE_IO_REG 0x1c +#define PCI_PCI_BRIDGE_MEM_REG 0x20 +#define PCI_PCI_BRIDGE_PMEM_REG 0x24 + +#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E +#define PCI_PCI_BRIDGE_PARITY_EN 0x01 +#define PCI_PCI_BRIDGE_SERR_EN 0x02 +#define PCI_PCI_BRIDGE_ISA_EN 0x04 +#define PCI_PCI_BRIDGE_VGA_EN 0x08 +#define PCI_PCI_BRIDGE_MASTER_ABORT_EN 0x20 +#define PCI_PCI_BRIDGE_SECONDARY_RESET 0x40 +#define PCI_PCI_BRIDGE_FAST_B2B_EN 0x80 + +/* Subsystem identification register */ +#define PCI_SUBSYSTEM_ID_REG 0x2c + +/* User defined cfg space regs */ +#define PCI_REG_USERCONFIG 0x40 +#define PCI_OPTION_REG 0x40 + +/* Public PCI access functions */ +extern _X_EXPORT char *DRICreatePCIBusID(const struct pci_device *dev); + +#endif /* _XF86PCI_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Priv.h b/prebuilt/xlibre/usr/include/xorg/xf86Priv.h new file mode 100644 index 0000000..7e90f86 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Priv.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains declarations for private XFree86 functions and variables, + * and definitions of private macros. + * + * "private" means not available to video drivers. + */ + +#ifndef _XF86PRIV_H +#define _XF86PRIV_H + +#include "xlibre_ptrtypes.h" +#include "xf86Privstr.h" +#include "input.h" + +extern _X_EXPORT int xf86FbBpp; +extern _X_EXPORT int xf86Depth; + +/* Other parameters */ + +extern _X_EXPORT xf86InfoRec xf86Info; +extern _X_EXPORT serverLayoutRec xf86ConfigLayout; + +extern _X_EXPORT DriverPtr *xf86DriverList; +extern _X_EXPORT int xf86NumScreens; + +extern _X_EXPORT ScrnInfoPtr *xf86GPUScreens; /* List of pointers to ScrnInfoRecs */ +extern _X_EXPORT int xf86NumGPUScreens; +extern _X_EXPORT int xf86DRMMasterFd; /* Command line argument for DRM master file descriptor */ +#ifndef DEFAULT_DPI +#define DEFAULT_DPI 96 +#endif + +/* xf86Bus.c */ +extern _X_EXPORT void xf86BusProbe(void); +extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev); + +#endif /* _XF86PRIV_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Privstr.h b/prebuilt/xlibre/usr/include/xorg/xf86Privstr.h new file mode 100644 index 0000000..d123978 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Privstr.h @@ -0,0 +1,127 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains definitions of the private XFree86 data structures/types. + * None of the data structures here should be used by video drivers. + */ + +#ifndef _XF86PRIVSTR_H +#define _XF86PRIVSTR_H + +#include "xf86str.h" + +typedef enum { + XF86_GlxVisualsMinimal, + XF86_GlxVisualsTypical, + XF86_GlxVisualsAll, +} XF86_GlxVisuals; + +/* + * xf86InfoRec contains global parameters which the video drivers never + * need to access. Global parameters which the video drivers do need + * should be individual globals. + */ + +typedef struct { + int consoleFd; + int vtno; + + /* event handler part */ + int lastEventTime; + Bool vtRequestsPending; +#ifdef __sun + int vtPendingNum; +#endif + Bool dontVTSwitch; + Bool autoVTSwitch; + Bool ShareVTs; + Bool dontZap; + Bool dontZoom; + + /* graphics part */ + ScreenPtr currentScreen; +#ifdef CONFIG_BSD_CONSOLE + int consType; /* Which console driver? */ +#endif + + /* Other things */ + Bool allowMouseOpenFail; + Bool vidModeEnabled; /* VidMode extension enabled */ + Bool vidModeAllowNonLocal; /* allow non-local VidMode + * connections */ + Bool pmFlag; + MessageType iglxFrom; + MessageType fontserverFrom; + XF86_GlxVisuals glxVisuals; + MessageType glxVisualsFrom; + + Bool useDefaultFontPath; + Bool ignoreABI; + + Bool forceInputDevices; /* force xorg.conf or built-in input devices */ + Bool autoAddDevices; /* Whether to succeed NIDR, or ignore. */ + Bool autoEnableDevices; /* Whether to enable, or let the client + * control. */ + + Bool dri2; + MessageType dri2From; + + Bool autoAddGPU; + const char *debug; + Bool autoBindGPU; + + Bool singleDriver; /* Only the first successfully probed driver adds primary screens, + * others may add GPU secondary screens only */ +} xf86InfoRec, *xf86InfoPtr; + +/* ISC's cc can't handle ~ of UL constants, so explicitly type cast them. */ +#define XLED1 ((unsigned long) 0x00000001) +#define XLED2 ((unsigned long) 0x00000002) +#define XLED3 ((unsigned long) 0x00000004) +#define XLED4 ((unsigned long) 0x00000008) +#define XCAPS ((unsigned long) 0x20000000) +#define XNUM ((unsigned long) 0x40000000) +#define XSCR ((unsigned long) 0x80000000) +#define XCOMP ((unsigned long) 0x00008000) + +/* BSD console driver types (consType) */ +#ifdef CONFIG_BSD_CONSOLE +#define PCCONS 0 +#define CODRV011 1 +#define CODRV01X 2 +#define SYSCONS 8 +#define PCVT 16 +#define WSCONS 32 +#endif + +/* Root window property to tell clients whether our VT is currently active. + * Name chosen to match the "XFree86_VT" property. */ +#define HAS_VT_ATOM_NAME "XFree86_has_VT" + +#endif /* _XF86PRIVSTR_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86RandR12.h b/prebuilt/xlibre/usr/include/xorg/xf86RandR12.h new file mode 100644 index 0000000..e92cd64 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86RandR12.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _XF86_RANDR_H_ +#define _XF86_RANDR_H_ +#include +#include + +extern _X_EXPORT Bool xf86RandR12Init(ScreenPtr pScreen); +extern _X_EXPORT void xf86RandR12SetRotations(ScreenPtr pScreen, + Rotation rotation); +extern _X_EXPORT void xf86RandR12SetTransformSupport(ScreenPtr pScreen, + Bool transforms); +extern _X_EXPORT Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, + int rate, RRScreenSizePtr pSize); +extern _X_EXPORT Rotation xf86RandR12GetRotation(ScreenPtr pScreen); +extern _X_EXPORT void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, + int *x, int *y); +extern _X_EXPORT Bool xf86RandR12PreInit(ScrnInfoPtr pScrn); +extern _X_EXPORT void xf86RandR12TellChanged(ScreenPtr pScreen); + +#endif /* _XF86_RANDR_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86Xinput.h b/prebuilt/xlibre/usr/include/xorg/xf86Xinput.h new file mode 100644 index 0000000..1edc1ce --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86Xinput.h @@ -0,0 +1,192 @@ +/* + * Copyright 1995-1999 by Frederic Lepied, France. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * Copyright (c) 2000-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _xf86Xinput_h +#define _xf86Xinput_h + +#include + +#include "xlibre_ptrtypes.h" +#include "xf86.h" +#include "xf86str.h" +#include "inputstr.h" +#include +#include + +/* Input device flags */ +#define XI86_ALWAYS_CORE 0x04 /* device always controls the pointer */ +/* the device sends Xinput and core pointer events */ +#define XI86_SEND_CORE_EVENTS XI86_ALWAYS_CORE +/* 0x08 is reserved for legacy XI86_SEND_DRAG_EVENTS, do not use for now */ +/* server-internal only */ +#define XI86_DEVICE_DISABLED 0x10 /* device was disabled before vt switch */ +#define XI86_SERVER_FD 0x20 /* fd is managed by xserver */ + +/* Input device driver capabilities */ +#define XI86_DRV_CAP_SERVER_FD 0x01 + +/* This holds the input driver entry and module information. */ +typedef struct _InputDriverRec { + int driverVersion; + const char *driverName; + void (*Identify) (int flags); + int (*PreInit) (struct _InputDriverRec * drv, + struct _InputInfoRec * pInfo, int flags); + void (*UnInit) (struct _InputDriverRec * drv, + struct _InputInfoRec * pInfo, int flags); + void *module; + const char **default_options; + int capabilities; +} InputDriverRec, *InputDriverPtr; + +/* This is to input devices what the ScrnInfoRec is to screens. */ + +struct _InputInfoRec { + struct _InputInfoRec *next; + char *name; + char *driver; + + int flags; + + Bool (*device_control) (DeviceIntPtr device, int what); + void (*read_input) (struct _InputInfoRec * local); + int (*control_proc) (struct _InputInfoRec * local, xDeviceCtl * control); + int (*switch_mode) (ClientPtr client, DeviceIntPtr dev, int mode); + int (*set_device_valuators) + (struct _InputInfoRec * local, + int *valuators, int first_valuator, int num_valuators); + + int fd; + int major; + int minor; + DeviceIntPtr dev; + void *private; + const char *type_name; + InputDriverPtr drv; + void *module; + XF86OptionPtr options; + InputAttributes *attrs; +}; + +/* xf86Xinput.c */ +extern _X_EXPORT void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute, + int first_valuator, int num_valuators, + ...); +extern _X_EXPORT void xf86PostMotionEventM(DeviceIntPtr device, int is_absolute, + const ValuatorMask *mask); +extern _X_EXPORT void xf86PostProximityEvent(DeviceIntPtr device, int is_in, + int first_valuator, + int num_valuators, ...); +extern _X_EXPORT void xf86PostProximityEventM(DeviceIntPtr device, int is_in, + const ValuatorMask *mask); +extern _X_EXPORT void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute, + int button, int is_down, + int first_valuator, int num_valuators, + ...); +extern _X_EXPORT void xf86PostButtonEventP(DeviceIntPtr device, int is_absolute, + int button, int is_down, + int first_valuator, + int num_valuators, + const int *valuators); +extern _X_EXPORT void xf86PostButtonEventM(DeviceIntPtr device, int is_absolute, + int button, int is_down, + const ValuatorMask *mask); +extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device, + unsigned int key_code, int is_down); +extern _X_EXPORT void xf86PostTouchEvent(DeviceIntPtr dev, uint32_t touchid, + uint16_t type, uint32_t flags, + const ValuatorMask *mask); +extern _X_EXPORT void xf86PostGesturePinchEvent(DeviceIntPtr dev, uint16_t type, + uint16_t num_touches, + uint32_t flags, + double delta_x, double delta_y, + double delta_unaccel_x, + double delta_unaccel_y, + double scale, double delta_angle); +extern _X_EXPORT void xf86PostGestureSwipeEvent(DeviceIntPtr dev, uint16_t type, + uint16_t num_touches, + uint32_t flags, + double delta_x, double delta_y, + double delta_unaccel_x, + double delta_unaccel_y); + +extern _X_EXPORT InputInfoPtr xf86FirstLocalDevice(void); +extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, + int from_min); +extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, + XF86OptionPtr options); +extern _X_EXPORT Bool xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, + Atom label, int minval, + int maxval, int resolution, + int min_res, int max_res, + int mode); +extern _X_EXPORT void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum); +extern _X_EXPORT void xf86AddEnabledDevice(InputInfoPtr pInfo); +extern _X_EXPORT void xf86RemoveEnabledDevice(InputInfoPtr pInfo); +extern _X_EXPORT void xf86DisableDevice(DeviceIntPtr dev, Bool panic); + +/* xf86Helper.c */ +extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, void *module, + int flags); +extern _X_EXPORT void xf86DeleteInput(InputInfoPtr pInp, int flags); +extern _X_EXPORT void xf86MotionHistoryAllocate(InputInfoPtr pInfo); +extern _X_EXPORT void +xf86IDrvMsgVerb(InputInfoPtr dev, + MessageType type, int verb, const char *format, ...) +_X_ATTRIBUTE_PRINTF(4, 5); +extern _X_EXPORT void +xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...) +_X_ATTRIBUTE_PRINTF(3, 4); + +/* xf86Option.c */ +extern _X_EXPORT void +xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts); + +#endif /* _xf86Xinput_h */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86_OSlib.h b/prebuilt/xlibre/usr/include/xorg/xf86_OSlib.h new file mode 100644 index 0000000..aed1565 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86_OSlib.h @@ -0,0 +1,242 @@ +/* + * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1992 by David Dawes + * Copyright 1992 by Jim Tsillas + * Copyright 1992 by Rich Murphey + * Copyright 1992 by Robert Baron + * Copyright 1992 by Orest Zborowski + * Copyright 1993 by Vrije Universiteit, The Netherlands + * Copyright 1993 by David Wexelblat + * Copyright 1994, 1996 by Holger Veit + * Copyright 1997 by Takis Psarogiannakopoulos + * Copyright 1994-2003 by The XFree86 Project, Inc + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holders + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holders make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * The ARM32 code here carries the following copyright: + * + * Copyright 1997 + * Digital Equipment Corporation. All rights reserved. + * This software is furnished under license and may be used and copied only in + * accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * this software in source and/or binary form. No title or ownership is + * transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and retain + * this copyright notice and list of conditions as they appear in the + * source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of Digital + * Equipment Corporation. Neither the "Digital Equipment Corporation" + * name nor any trademark or logo of Digital Equipment Corporation may be + * used to endorse or promote products derived from this software without + * the prior written permission of Digital Equipment Corporation. + * + * 3) This software is provided "AS-IS" and any express or implied warranties, + * including but not limited to, any implied warranties of merchantability, + * fitness for a particular purpose, or non-infringement are disclaimed. + * In no event shall DIGITAL be liable for any damages whatsoever, and in + * particular, DIGITAL shall not be liable for special, indirect, + * consequential, or incidental damages or damages for lost profits, loss + * of revenue or loss of use, whether such damages arise in contract, + * negligence, tort, under statute, in equity, at law or otherwise, even + * if advised of the possibility of such damage. + * + */ + +/* + * This is private, and should not be included by any drivers. Drivers + * may include xf86_OSproc.h to get prototypes for public interfaces. + */ + +#ifndef _XF86_OSLIB_H +#define _XF86_OSLIB_H + +#include +#include + +#include +#include +#include + +/**************************************************************************/ +/* Solaris or illumos-based system */ +/**************************************************************************/ +#if defined(__SVR4) && defined(__sun) +#include +#include +#include +#include + +#include + +#ifdef HAVE_SYS_VT_H +#define HAS_USL_VTS +#endif +#ifdef HAS_USL_VTS +#include +#include +#endif + +#define CLEARDTR_SUPPORT + +#endif /* SVR4 && __sun */ + +/**************************************************************************/ +/* Linux or Glibc-based system */ +/**************************************************************************/ +#if defined(__linux__) || defined(__GLIBC__) || defined(__CYGWIN__) +#include +#include +#include +#include +#include + +#include +#ifdef __sparc__ +#include +#endif + +#include + +#ifdef __linux__ +#define HAS_USL_VTS +#include +#include +#define LDGMAP GIO_SCRNMAP +#define LDSMAP PIO_SCRNMAP +#define LDNMAP LDSMAP +#define CLEARDTR_SUPPORT +#endif + +#endif /* __linux__ || __GLIBC__ */ + +/**************************************************************************/ +/* System is BSD-like */ +/**************************************************************************/ + +#ifdef CSRG_BASED +#include +#include + +#include + +#include + +#include + +#endif /* CSRG_BASED */ + +/**************************************************************************/ +/* Kernel of *BSD */ +/**************************************************************************/ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + +#include +#if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version) +#define __FreeBSD_kernel_version __FreeBSD_version +#endif + +#ifdef SYSCONS_SUPPORT +#define COMPAT_SYSCONS +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000) +#include +#include +#else +#include +#endif /* FreeBSD 4.1 RELEASE or lator */ +#else +#if !defined(__NetBSD__) && !defined(__OpenBSD__) +#include +#endif +#endif +#endif /* SYSCONS_SUPPORT */ +#if defined(PCVT_SUPPORT) && !defined(__NetBSD__) && !defined(__OpenBSD__) +#if !defined(SYSCONS_SUPPORT) + /* no syscons, so include pcvt specific header file */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include +#else +#include +#endif /* __FreeBSD_kernel__ */ +#else /* pcvt and syscons: hard-code the ID magic */ +#define VGAPCVTID _IOWR('V',113, struct pcvtid) +struct pcvtid { + char name[16]; + int rmajor, rminor; +}; +#endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */ +#endif /* PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT +#include +#include +#endif /* WSCONS_SUPPORT */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#include +#endif + /* Include these definitions in case ioctl_pc.h didn't get included */ +#ifndef CONSOLE_X_BELL +#define CONSOLE_X_BELL _IOW('t',123,int[2]) +#endif + +#define CLEARDTR_SUPPORT + +#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */ + +/**************************************************************************/ +/* IRIX */ +/**************************************************************************/ + +/**************************************************************************/ +/* Generic */ +/**************************************************************************/ + +/* For PATH_MAX */ +#include "misc.h" + +/* + * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere, + * and it's safe, so just do it. + */ +#if !defined(O_NDELAY) && defined(O_NONBLOCK) +#define O_NDELAY O_NONBLOCK +#endif /* !O_NDELAY && O_NONBLOCK */ + +#if !defined(MAXHOSTNAMELEN) +#define MAXHOSTNAMELEN 32 +#endif /* !MAXHOSTNAMELEN */ + +#include + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) {} + +#include "xf86_OSproc.h" + +#endif /* _XF86_OSLIB_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86_OSproc.h b/prebuilt/xlibre/usr/include/xorg/xf86_OSproc.h new file mode 100644 index 0000000..b030ebd --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86_OSproc.h @@ -0,0 +1,150 @@ +/* + * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1992 by David Dawes + * Copyright 1992 by Jim Tsillas + * Copyright 1992 by Rich Murphey + * Copyright 1992 by Robert Baron + * Copyright 1992 by Orest Zborowski + * Copyright 1993 by Vrije Universiteit, The Netherlands + * Copyright 1993 by David Wexelblat + * Copyright 1994, 1996 by Holger Veit + * Copyright 1994-2003 by The XFree86 Project, Inc + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holders + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holders make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * The ARM32 code here carries the following copyright: + * + * Copyright 1997 + * Digital Equipment Corporation. All rights reserved. + * This software is furnished under license and may be used and copied only in + * accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * this software in source and/or binary form. No title or ownership is + * transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and retain + * this copyright notice and list of conditions as they appear in the + * source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of Digital + * Equipment Corporation. Neither the "Digital Equipment Corporation" + * name nor any trademark or logo of Digital Equipment Corporation may be + * used to endorse or promote products derived from this software without + * the prior written permission of Digital Equipment Corporation. + * + * 3) This software is provided "AS-IS" and any express or implied warranties, + * including but not limited to, any implied warranties of merchantability, + * fitness for a particular purpose, or non-infringement are disclaimed. + * In no event shall DIGITAL be liable for any damages whatsoever, and in + * particular, DIGITAL shall not be liable for special, indirect, + * consequential, or incidental damages or damages for lost profits, loss + * of revenue or loss of use, whether such damages arise in contract, + * negligence, tort, under statute, in equity, at law or otherwise, even + * if advised of the possibility of such damage. + * + */ + +#ifndef _XF86_OSPROC_H +#define _XF86_OSPROC_H + +/* + * The actual prototypes have been pulled into this separate file so + * that they can can be used without pulling in all of the OS specific + * stuff like sys/stat.h, etc. that causes problems for loadable modules. + */ + +/* + * OS-independent modem state flags for xf86SetSerialModemState() and + * xf86GetSerialModemState(). + */ +#define XF86_M_LE 0x001 /* line enable */ +#define XF86_M_DTR 0x002 /* data terminal ready */ +#define XF86_M_RTS 0x004 /* request to send */ +#define XF86_M_ST 0x008 /* secondary transmit */ +#define XF86_M_SR 0x010 /* secondary receive */ +#define XF86_M_CTS 0x020 /* clear to send */ +#define XF86_M_CAR 0x040 /* carrier detect */ +#define XF86_M_RNG 0x080 /* ring */ +#define XF86_M_DSR 0x100 /* data set ready */ + +/***************************************************************************/ +/* Prototypes */ +/***************************************************************************/ + +#include +#include "opaque.h" +#include "xf86Optionstr.h" + +_XFUNCPROTOBEGIN + +/* public functions */ +extern _X_EXPORT Bool xf86EnableIO(void); +extern _X_EXPORT void xf86DisableIO(void); + +extern _X_EXPORT void xf86SlowBcopy(unsigned char *, unsigned char *, int); +extern _X_EXPORT int xf86OpenSerial(XF86OptionPtr options); +extern _X_EXPORT int xf86SetSerial(int fd, XF86OptionPtr options); +extern _X_EXPORT int xf86SetSerialSpeed(int fd, int speed); +extern _X_EXPORT int xf86ReadSerial(int fd, void *buf, int count); +extern _X_EXPORT int xf86WriteSerial(int fd, const void *buf, int count); +extern _X_EXPORT int xf86CloseSerial(int fd); +extern _X_EXPORT int xf86FlushInput(int fd); +extern _X_EXPORT int xf86WaitForInput(int fd, int timeout); +extern _X_EXPORT int xf86SetSerialModemState(int fd, int state); +extern _X_EXPORT int xf86GetSerialModemState(int fd); +extern _X_EXPORT int xf86SerialModemSetBits(int fd, int bits); +extern _X_EXPORT int xf86SerialModemClearBits(int fd, int bits); +extern _X_EXPORT int xf86LoadKernelModule(const char *pathname); + +/* AGP GART interface */ + +typedef struct _AgpInfo { + CARD32 bridgeId; + CARD32 agpMode; + unsigned long base; + unsigned long size; + unsigned long totalPages; + unsigned long systemPages; + unsigned long usedPages; +} AgpInfo, *AgpInfoPtr; + +extern _X_EXPORT Bool xf86AgpGARTSupported(void); +extern _X_EXPORT AgpInfoPtr xf86GetAGPInfo(int screenNum); +extern _X_EXPORT Bool xf86AcquireGART(int screenNum); +extern _X_EXPORT Bool xf86ReleaseGART(int screenNum); +extern _X_EXPORT int xf86AllocateGARTMemory(int screenNum, unsigned long size, + int type, unsigned long *physical); +extern _X_EXPORT Bool xf86BindGARTMemory(int screenNum, int key, + unsigned long offset); +extern _X_EXPORT Bool xf86UnbindGARTMemory(int screenNum, int key); +extern _X_EXPORT Bool xf86GARTCloseScreen(int screenNum); + +/* These routines are in shared/sigio.c and are not loaded as part of the + module. These routines are small, and the code if very POSIX-signal (or + OS-signal) specific, so it seemed better to provide more complex + wrappers than to wrap each individual function called. */ +extern _X_EXPORT int xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), + void *); + +_XFUNCPROTOEND +#endif /* _XF86_OSPROC_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86cmap.h b/prebuilt/xlibre/usr/include/xorg/xf86cmap.h new file mode 100644 index 0000000..acd6035 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86cmap.h @@ -0,0 +1,67 @@ + +/* + * Copyright (c) 1998-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86CMAP_H +#define _XF86CMAP_H + +#include "xlibre_ptrtypes.h" +#include "xf86str.h" + +#define CMAP_PALETTED_TRUECOLOR 0x0000001 +#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002 +#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004 + +extern _X_EXPORT Bool xf86HandleColormaps(ScreenPtr pScreen, + int maxCol, + int sigRGBbits, + xf86LoadPaletteProc * loadPalette, + xf86SetOverscanProc * setOverscan, + unsigned int flags); + +extern _X_EXPORT Bool xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn); + +extern _X_EXPORT int + xf86ChangeGamma(ScreenPtr pScreen, Gamma newGamma); + +extern _X_EXPORT int + +xf86ChangeGammaRamp(ScreenPtr pScreen, + int size, + unsigned short *red, + unsigned short *green, unsigned short *blue); + +extern _X_EXPORT int xf86GetGammaRampSize(ScreenPtr pScreen); + +extern _X_EXPORT int + +xf86GetGammaRamp(ScreenPtr pScreen, + int size, + unsigned short *red, + unsigned short *green, unsigned short *blue); + +#endif /* _XF86CMAP_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86fbman.h b/prebuilt/xlibre/usr/include/xorg/xf86fbman.h new file mode 100644 index 0000000..64b9a31 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86fbman.h @@ -0,0 +1,113 @@ + +/* + * Copyright (c) 1998-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86FBMAN_H +#define _XF86FBMAN_H + +#include "scrnintstr.h" +#include "regionstr.h" + +#define FAVOR_AREA_THEN_WIDTH 0 +#define FAVOR_AREA_THEN_HEIGHT 1 +#define FAVOR_WIDTH_THEN_AREA 2 +#define FAVOR_HEIGHT_THEN_AREA 3 + +#define PRIORITY_LOW 0 +#define PRIORITY_NORMAL 1 +#define PRIORITY_EXTREME 2 + +typedef struct _FBArea { + ScreenPtr pScreen; + BoxRec box; + int granularity; + void (*MoveAreaCallback) (struct _FBArea *, struct _FBArea *); + void (*RemoveAreaCallback) (struct _FBArea *); + DevUnion devPrivate; +} FBArea, *FBAreaPtr; + +typedef struct _FBLinear { + ScreenPtr pScreen; + int size; + int offset; + int granularity; + void (*MoveLinearCallback) (struct _FBLinear *, struct _FBLinear *); + void (*RemoveLinearCallback) (struct _FBLinear *); + DevUnion devPrivate; +} FBLinear, *FBLinearPtr; + +typedef void (*MoveAreaCallbackProcPtr) (FBAreaPtr, FBAreaPtr); +typedef void (*RemoveAreaCallbackProcPtr) (FBAreaPtr); + +typedef void (*MoveLinearCallbackProcPtr) (FBLinearPtr, FBLinearPtr); +typedef void (*RemoveLinearCallbackProcPtr) (FBLinearPtr); + +extern _X_EXPORT Bool + xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox); + +extern _X_EXPORT Bool + xf86InitFBManagerLinear(ScreenPtr pScreen, int offset, int size); + +extern _X_EXPORT FBAreaPtr +xf86AllocateOffscreenArea(ScreenPtr pScreen, + int w, int h, + int granularity, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, void *privData); + +extern _X_EXPORT FBLinearPtr +xf86AllocateOffscreenLinear(ScreenPtr pScreen, + int length, + int granularity, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + void *privData); + +extern _X_EXPORT void xf86FreeOffscreenArea(FBAreaPtr area); +extern _X_EXPORT void xf86FreeOffscreenLinear(FBLinearPtr area); + +extern _X_EXPORT Bool + xf86ResizeOffscreenArea(FBAreaPtr resize, int w, int h); + +extern _X_EXPORT Bool + xf86ResizeOffscreenLinear(FBLinearPtr resize, int size); + +extern _X_EXPORT Bool + xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen); + +extern _X_EXPORT Bool + +xf86QueryLargestOffscreenArea(ScreenPtr pScreen, + int *width, int *height, + int granularity, int preferences, int priority); + +extern _X_EXPORT Bool + +xf86QueryLargestOffscreenLinear(ScreenPtr pScreen, + int *size, int granularity, int priority); + +#endif /* _XF86FBMAN_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86i2c.h b/prebuilt/xlibre/usr/include/xorg/xf86i2c.h new file mode 100644 index 0000000..e4f10f9 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86i2c.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 1998 Itai Nahshon, Michael Schimek + */ + +#ifndef _XF86I2C_H +#define _XF86I2C_H + +#include "regionstr.h" +#include "xf86.h" + +typedef unsigned char I2CByte; +typedef unsigned short I2CSlaveAddr; + +typedef struct _I2CBusRec *I2CBusPtr; +typedef struct _I2CDevRec *I2CDevPtr; + +/* I2C masters have to register themselves */ + +typedef struct _I2CBusRec { + const char *BusName; + int scrnIndex; + ScrnInfoPtr pScrn; + + void (*I2CUDelay) (I2CBusPtr b, int usec); + + void (*I2CPutBits) (I2CBusPtr b, int scl, int sda); + void (*I2CGetBits) (I2CBusPtr b, int *scl, int *sda); + + /* Look at the generic routines to see how these functions should behave. */ + + Bool (*I2CStart) (I2CBusPtr b, int timeout); + Bool (*I2CAddress) (I2CDevPtr d, I2CSlaveAddr); + void (*I2CStop) (I2CDevPtr d); + Bool (*I2CPutByte) (I2CDevPtr d, I2CByte data); + Bool (*I2CGetByte) (I2CDevPtr d, I2CByte * data, Bool); + + DevUnion DriverPrivate; + + int HoldTime; /* 1 / bus clock frequency, 5 or 2 usec */ + + int BitTimeout; /* usec */ + int ByteTimeout; /* usec */ + int AcknTimeout; /* usec */ + int StartTimeout; /* usec */ + int RiseFallTime; /* usec */ + + I2CDevPtr FirstDev; + I2CBusPtr NextBus; + Bool (*I2CWriteRead) (I2CDevPtr d, I2CByte * WriteBuffer, int nWrite, + I2CByte * ReadBuffer, int nRead); +} I2CBusRec; + +#define CreateI2CBusRec xf86CreateI2CBusRec +extern _X_EXPORT I2CBusPtr xf86CreateI2CBusRec(void); + +#define DestroyI2CBusRec xf86DestroyI2CBusRec +extern _X_EXPORT void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc, + Bool devs_too); +#define I2CBusInit xf86I2CBusInit +extern _X_EXPORT Bool xf86I2CBusInit(I2CBusPtr pI2CBus); + +extern _X_EXPORT I2CBusPtr xf86I2CFindBus(int scrnIndex, const char *name); +extern _X_EXPORT int xf86I2CGetScreenBuses(int scrnIndex, + I2CBusPtr ** pppI2CBus); + +/* I2C slave devices */ + +typedef struct _I2CDevRec { + const char *DevName; + + int BitTimeout; /* usec */ + int ByteTimeout; /* usec */ + int AcknTimeout; /* usec */ + int StartTimeout; /* usec */ + + I2CSlaveAddr SlaveAddr; + I2CBusPtr pI2CBus; + I2CDevPtr NextDev; + DevUnion DriverPrivate; +} I2CDevRec; + +#define CreateI2CDevRec xf86CreateI2CDevRec +extern _X_EXPORT I2CDevPtr xf86CreateI2CDevRec(void); +extern _X_EXPORT void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev, Bool unalloc); + +#define I2CDevInit xf86I2CDevInit +extern _X_EXPORT Bool xf86I2CDevInit(I2CDevPtr pI2CDev); +extern _X_EXPORT I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr); + +/* See descriptions of these functions in xf86i2c.c */ + +#define I2CProbeAddress xf86I2CProbeAddress +extern _X_EXPORT Bool xf86I2CProbeAddress(I2CBusPtr pI2CBus, I2CSlaveAddr); + +#define I2C_WriteRead xf86I2CWriteRead +extern _X_EXPORT Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte * WriteBuffer, + int nWrite, I2CByte * ReadBuffer, + int nRead); +#define xf86I2CRead(d, rb, nr) xf86I2CWriteRead(d, NULL, 0, rb, nr) + +extern _X_EXPORT Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, + I2CByte * pbyte); +extern _X_EXPORT Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, + I2CByte * pbyte, int n); +#define xf86I2CWrite(d, wb, nw) xf86I2CWriteRead(d, wb, nw, NULL, 0) +extern _X_EXPORT Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, + I2CByte byte); +extern _X_EXPORT Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte * vec, int nValues); + +#endif /*_XF86I2C_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86platformBus.h b/prebuilt/xlibre/usr/include/xorg/xf86platformBus.h new file mode 100644 index 0000000..8f9b7c6 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86platformBus.h @@ -0,0 +1,92 @@ +/* + * Copyright © 2012 Red Hat. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Dave Airlie + */ +#ifndef XF86_PLATFORM_BUS_H +#define XF86_PLATFORM_BUS_H + +struct xf86_platform_device { + struct OdevAttributes *attribs; + /* for PCI devices */ + struct pci_device *pdev; + int flags; +}; + +/* xf86_platform_device flags */ +#define XF86_PDEV_UNOWNED 0x01 +#define XF86_PDEV_SERVER_FD 0x02 +#define XF86_PDEV_PAUSED 0x04 + +#ifdef XSERVER_PLATFORM_BUS + +/* + * Define the legacy API only for external builds + */ + +/* path to kernel device node - Linux e.g. /dev/dri/card0 */ +#define ODEV_ATTRIB_PATH 1 +/* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ +#define ODEV_ATTRIB_SYSPATH 2 +/* DRI-style bus id */ +#define ODEV_ATTRIB_BUSID 3 +/* Server managed FD */ +#define ODEV_ATTRIB_FD 4 +/* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ +#define ODEV_ATTRIB_MAJOR 5 +/* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ +#define ODEV_ATTRIB_MINOR 6 +/* kernel driver name */ +#define ODEV_ATTRIB_DRIVER 7 + +_X_EXPORT char * +_xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]); + +_X_EXPORT int +_xf86_get_platform_device_int_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]); + +/* Protect against a mismatch attribute type by generating a compiler + * error using a negative array size when an incorrect attribute is + * passed + */ + +#define _ODEV_ATTRIB_IS_STRING(x) ((x) == ODEV_ATTRIB_PATH || \ + (x) == ODEV_ATTRIB_SYSPATH || \ + (x) == ODEV_ATTRIB_BUSID || \ + (x) == ODEV_ATTRIB_DRIVER) + +#define _ODEV_ATTRIB_STRING_CHECK(x) ((int (*)[_ODEV_ATTRIB_IS_STRING((x))-1]) 0) + +#define xf86_get_platform_device_attrib(device, attrib) _xf86_get_platform_device_attrib((device),(attrib),_ODEV_ATTRIB_STRING_CHECK((attrib))) + +#define _ODEV_ATTRIB_IS_INT(x) ((x) == ODEV_ATTRIB_FD || (x) == ODEV_ATTRIB_MAJOR || (x) == ODEV_ATTRIB_MINOR) +#define _ODEV_ATTRIB_INT_DEFAULT(x) ((x) == ODEV_ATTRIB_FD ? -1 : 0) +#define _ODEV_ATTRIB_DEFAULT_CHECK(x,def) (_ODEV_ATTRIB_INT_DEFAULT(x) == (def)) +#define _ODEV_ATTRIB_INT_CHECK(x,def) ((int (*)[_ODEV_ATTRIB_IS_INT(x)*_ODEV_ATTRIB_DEFAULT_CHECK(x,def)-1]) 0) + +#define xf86_get_platform_device_int_attrib(device, attrib, def) _xf86_get_platform_device_int_attrib(device,attrib,_ODEV_ATTRIB_INT_CHECK(attrib,def)) + +extern _X_EXPORT Bool +xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *busid); + +#endif + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/xf86sbusBus.h b/prebuilt/xlibre/usr/include/xorg/xf86sbusBus.h new file mode 100644 index 0000000..307eda5 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86sbusBus.h @@ -0,0 +1,74 @@ +/* + * SBUS bus-specific declarations + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _XF86_SBUSBUS_H +#define _XF86_SBUSBUS_H + +#include "xf86str.h" + +#define SBUS_DEVICE_CG3 0x0003 +#define SBUS_DEVICE_CG6 0x0005 +#define SBUS_DEVICE_CG14 0x0008 +#define SBUS_DEVICE_LEO 0x0009 +#define SBUS_DEVICE_TCX 0x000a +#define SBUS_DEVICE_FFB 0x000b + +typedef struct sbus_prom_node { + int node; + /* Because of misdesigned openpromio */ + int cookie[2]; +} sbusPromNode, *sbusPromNodePtr; + +typedef struct sbus_device { + int devId; + int fbNum; + int fd; + int width, height; + sbusPromNode node; + const char *descr; + const char *device; +} sbusDevice, *sbusDevicePtr; + +extern _X_EXPORT int xf86MatchSbusInstances(const char *driverName, + int sbusDevId, GDevPtr * devList, + int numDevs, DriverPtr drvp, + int **foundEntities); +extern _X_EXPORT sbusDevicePtr xf86GetSbusInfoForEntity(int entityIndex); +extern _X_EXPORT void xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, + sbusDevicePtr psdp); +extern _X_EXPORT void *xf86MapSbusMem(sbusDevicePtr psdp, + unsigned long offset, + unsigned long size); +extern _X_EXPORT void xf86UnmapSbusMem(sbusDevicePtr psdp, void *addr, + unsigned long size); +extern _X_EXPORT void xf86SbusHideOsHwCursor(sbusDevicePtr psdp); +extern _X_EXPORT void xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg, + int fg); +extern _X_EXPORT Bool xf86SbusHandleColormaps(ScreenPtr pScreen, + sbusDevicePtr psdp); + +extern _X_EXPORT int sparcPromInit(void); +extern _X_EXPORT void sparcPromClose(void); +extern _X_EXPORT int sparcPromGetBool(sbusPromNodePtr pnode, const char *prop); + +#endif /* _XF86_SBUSBUS_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xf86str.h b/prebuilt/xlibre/usr/include/xorg/xf86str.h new file mode 100644 index 0000000..7841002 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xf86str.h @@ -0,0 +1,749 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains definitions of the public XFree86 data structures/types. + * Any data structures that video drivers need to access should go here. + */ + +#ifndef _XF86STR_H +#define _XF86STR_H + +#include "xlibre_ptrtypes.h" +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "colormapst.h" +#include "xf86Module.h" +#include "xf86Opt.h" +#include "displaymode.h" + +/** + * Integer type that is of the size of the addressable memory (machine size). + * On most platforms \c uintptr_t will suffice. However, on some mixed + * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this + * must be 64-bits. + */ +#include +#if defined(__powerpc__) +typedef uint64_t memType; +#else +typedef uintptr_t memType; +#endif + +/* Video mode flags */ + +typedef enum { + V_PHSYNC = 0x0001, + V_NHSYNC = 0x0002, + V_PVSYNC = 0x0004, + V_NVSYNC = 0x0008, + V_INTERLACE = 0x0010, + V_DBLSCAN = 0x0020, + V_CSYNC = 0x0040, + V_PCSYNC = 0x0080, + V_NCSYNC = 0x0100, + V_HSKEW = 0x0200, /* hskew provided */ + V_BCAST = 0x0400, + V_PIXMUX = 0x1000, + V_DBLCLK = 0x2000, + V_CLKDIV2 = 0x4000 +} ModeFlags; + +typedef enum { + INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */ +} CrtcAdjustFlags; + +/* Flags passed to ChipValidMode() */ +typedef enum { + MODECHECK_INITIAL = 0, + MODECHECK_FINAL = 1 +} ModeCheckFlags; + +/* + * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN. + * Preferred will bubble a mode to the top within a set. + */ +#define M_T_BUILTIN 0x01 /* built-in mode */ +#define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */ +#define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */ +#define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C) + /* built-in mode - configure CRTC and clock */ +#define M_T_PREFERRED 0x08 /* preferred mode within a set */ +#define M_T_DEFAULT 0x10 /* (VESA) default modes */ +#define M_T_USERDEF 0x20 /* One of the modes from the config file */ +#define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */ +#define M_T_USERPREF 0x80 /* mode preferred by the user config */ + +/* The monitor description */ + +#define MAX_HSYNC 8 +#define MAX_VREFRESH 8 + +typedef struct { + float hi, lo; +} range; + +typedef struct { + CARD32 red, green, blue; +} rgb; + +typedef struct { + float red, green, blue; +} Gamma; + +/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */ +#define GAMMA_MAX 10.0 +#define GAMMA_MIN (1.0 / GAMMA_MAX) +#define GAMMA_ZERO (GAMMA_MIN / 100.0) + +typedef struct { + const char *id; + const char *vendor; + const char *model; + int nHsync; + range hsync[MAX_HSYNC]; + int nVrefresh; + range vrefresh[MAX_VREFRESH]; + DisplayModePtr Modes; /* Start of the monitor's mode list */ + DisplayModePtr Last; /* End of the monitor's mode list */ + Gamma gamma; /* Gamma of the monitor */ + int widthmm; + int heightmm; + void *options; + void *DDC; + Bool reducedblanking; /* Allow CVT reduced blanking modes? */ + int maxPixClock; /* in kHz, like mode->Clock */ +} MonRec, *MonPtr; + +/* the list of clock ranges */ +typedef struct x_ClockRange { + struct x_ClockRange *next; + int minClock; /* (kHz) */ + int maxClock; /* (kHz) */ + int clockIndex; /* -1 for programmable clocks */ + Bool interlaceAllowed; + Bool doubleScanAllowed; + int ClockMulFactor; + int ClockDivFactor; + int PrivFlags; +} ClockRange, *ClockRangePtr; + +/* + * The driverFunc. xorgDriverFuncOp specifies the action driver should + * perform. If requested option is not supported function should return + * FALSE. pointer can be used to pass arguments to the function or + * to return data to the caller. + */ + +/* do not change order */ +typedef enum { + RR_GET_INFO, + RR_SET_CONFIG, + RR_GET_MODE_MM, + GET_REQUIRED_HW_INTERFACES = 10, + SUPPORTS_SERVER_FDS = 11, +} xorgDriverFuncOp; + +typedef Bool xorgDriverFuncProc(ScrnInfoPtr, xorgDriverFuncOp, void *); + +/* RR_GET_INFO, RR_SET_CONFIG */ +typedef struct { + int rotation; + int rate; + int width; + int height; +} xorgRRConfig; + +typedef union { + short RRRotations; + xorgRRConfig RRConfig; +} xorgRRRotation, *xorgRRRotationPtr; + +/* RR_GET_MODE_MM */ +typedef struct { + DisplayModePtr mode; + int virtX; + int virtY; + int mmWidth; + int mmHeight; +} xorgRRModeMM, *xorgRRModeMMPtr; + +/* GET_REQUIRED_HW_INTERFACES */ +#define HW_IO 1 +#define HW_MMIO 2 +#define HW_SKIP_CONSOLE 4 +#define NEED_IO_ENABLED(x) ((x) & HW_IO) + +typedef CARD32 xorgHWFlags; + +/* + * The driver list struct. This contains the information required for each + * driver before a ScrnInfoRec has been allocated. + */ +struct _DriverRec; + +struct _SymTabRec; +struct _PciChipsets; + +struct pci_device; +struct xf86_platform_device; + +typedef struct _DriverRec { + int driverVersion; + const char *driverName; + void (*Identify) (int flags); + Bool (*Probe) (struct _DriverRec * drv, int flags); + const OptionInfoRec *(*AvailableOptions) (int chipid, int bustype); + void *module; + int refCount; + xorgDriverFuncProc *driverFunc; + + const struct pci_id_match *supported_devices; + Bool (*PciProbe) (struct _DriverRec * drv, int entity_num, + struct pci_device * dev, intptr_t match_data); + Bool (*platformProbe) (struct _DriverRec * drv, int entity_num, int flags, + struct xf86_platform_device * dev, intptr_t match_data); +} DriverRec, *DriverPtr; + +/* + * platform probe flags + */ +#define PLATFORM_PROBE_GPU_SCREEN 1 + +/* + * AddDriver flags + */ +#define HaveDriverFuncs 1 + +/* + * These are the private bus types. New types can be added here. Types + * required for the public interface should be added to xf86str.h, with + * function prototypes added to xf86.h. + */ + +/* Tolerate prior #include */ +#if defined(__linux__) || defined(__FreeBSD__) +#undef BUS_NONE +#undef BUS_PCI +#undef BUS_SBUS +#undef BUS_PLATFORM +#undef BUS_USB +#undef BUS_last +#endif + +typedef enum { + BUS_NONE, + BUS_PCI, + BUS_SBUS, + BUS_PLATFORM, + BUS_USB, + BUS_last /* Keep last */ +} BusType; + +typedef struct { + int fbNum; +} SbusBusId; + +typedef struct _bus { + BusType type; + union { + struct pci_device *pci; + SbusBusId sbus; + struct xf86_platform_device *plat; + } id; +} BusRec, *BusPtr; + +typedef enum { + DAC_BPP8 = 0, + DAC_BPP16, + DAC_BPP24, + DAC_BPP32, + MAXDACSPEEDS +} DacSpeedIndex; + +typedef struct { + const char *identifier; + const char *vendor; + const char *board; + const char *chipset; + const char *ramdac; + const char *driver; + struct _confscreenrec *myScreenSection; + Bool claimed; + int dacSpeeds[MAXDACSPEEDS]; + int numclocks; + int clock[MAXCLOCKS]; + const char *clockchip; + const char *busID; + Bool active; + Bool inUse; + int videoRam; + unsigned long MemBase; /* Frame buffer base address */ + unsigned long IOBase; + int chipID; + int chipRev; + void *options; + int irq; + int screen; /* For multi-CRTC cards */ +} GDevRec, *GDevPtr; + +typedef struct { + int frameX0; + int frameY0; + int virtualX; + int virtualY; + int depth; + int fbbpp; + rgb weight; + rgb blackColour; + rgb whiteColour; + int defaultVisual; + const char **modes; + void *options; +} DispRec, *DispPtr; + +typedef struct _confxvportrec { + const char *identifier; + void *options; +} confXvPortRec, *confXvPortPtr; + +typedef struct _confxvadaptrec { + const char *identifier; + int numports; + confXvPortPtr ports; + void *options; +} confXvAdaptorRec, *confXvAdaptorPtr; + +#define MAX_GPUDEVICES 4 +typedef struct _confscreenrec { + const char *id; + int screennum; + int defaultdepth; + int defaultbpp; + int defaultfbbpp; + MonPtr monitor; + GDevPtr device; + int numdisplays; + DispPtr *displays; + int numxvadaptors; + confXvAdaptorPtr xvadaptors; + void *options; + + int num_gpu_devices; + GDevPtr gpu_devices[MAX_GPUDEVICES]; +} confScreenRec, *confScreenPtr; + +typedef enum { + PosObsolete = -1, + PosAbsolute = 0, + PosRightOf, + PosLeftOf, + PosAbove, + PosBelow, + PosRelative +} PositionType; + +typedef struct _screenlayoutrec { + confScreenPtr screen; + const char *topname; + confScreenPtr top; + const char *bottomname; + confScreenPtr bottom; + const char *leftname; + confScreenPtr left; + const char *rightname; + confScreenPtr right; + PositionType where; + int x; + int y; + const char *refname; + confScreenPtr refscreen; +} screenLayoutRec, *screenLayoutPtr; + +typedef struct _InputInfoRec InputInfoRec; + +typedef struct _serverlayoutrec { + const char *id; + screenLayoutPtr screens; + GDevPtr inactives; + InputInfoRec **inputs; /* NULL terminated */ + void *options; +} serverLayoutRec, *serverLayoutPtr; + +#define NUM_RESERVED_INTS 4 +#define NUM_RESERVED_POINTERS 4 +#define NUM_RESERVED_FUNCS 4 + +/* let clients know they can use this */ +#define XF86_SCRN_HAS_PREFER_CLONE 1 + +typedef void *(*funcPointer) (void); + +/* Power management events: so far we only support APM */ + +typedef enum { + XF86_APM_UNKNOWN = -1, + XF86_APM_SYS_STANDBY, + XF86_APM_SYS_SUSPEND, + XF86_APM_CRITICAL_SUSPEND, + XF86_APM_USER_STANDBY, + XF86_APM_USER_SUSPEND, + XF86_APM_STANDBY_RESUME, + XF86_APM_NORMAL_RESUME, + XF86_APM_CRITICAL_RESUME, + XF86_APM_LOW_BATTERY, + XF86_APM_POWER_STATUS_CHANGE, + XF86_APM_UPDATE_TIME, + XF86_APM_CAPABILITY_CHANGED, + XF86_APM_STANDBY_FAILED, + XF86_APM_SUSPEND_FAILED +} pmEvent; + +typedef enum { + PM_WAIT, + PM_CONTINUE, + PM_FAILED, + PM_NONE +} pmWait; + +typedef struct _PciChipsets { + /** + * Key used to match this device with its name in an array of + * \c SymTabRec. + */ + int numChipset; + + /** + * This value is quirky. Depending on the driver, it can take on one of + * three meanings. In drivers that have exactly one vendor ID (e.g., + * radeon, mga, i810) the low 16-bits are the device ID. + * + * In drivers that can have multiple vendor IDs (e.g., the glint driver + * can have either 3dlabs' ID or TI's ID, the i740 driver can have either + * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and + * the high 16-bits are the vendor ID. + * + * In drivers that don't have a specific vendor (e.g., vga) contains the + * device ID for either the generic VGA or generic 8514 devices. This + * turns out to be the same as the subclass and programming interface + * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or + * 0x000101) and for 8514 is 0x030001). + */ + int PCIid; + +/* dummy place holders for drivers to build against old/new servers */ +#define RES_UNDEFINED NULL +#define RES_EXCLUSIVE_VGA NULL +#define RES_SHARED_VGA NULL + void *dummy; +} PciChipsets; + +/* Entity properties */ +typedef void (*EntityProc) (int entityIndex, void *private); + +typedef struct _entityInfo { + int index; + BusRec location; + int chipset; + Bool active; + GDevPtr device; + DriverPtr driver; +} EntityInfoRec, *EntityInfoPtr; + +/* DGA */ + +typedef struct { + int num; /* A unique identifier for the mode (num > 0) */ + DisplayModePtr mode; + int flags; /* DGA_CONCURRENT_ACCESS, etc... */ + int imageWidth; /* linear accessible portion (pixels) */ + int imageHeight; + int pixmapWidth; /* Xlib accessible portion (pixels) */ + int pixmapHeight; /* both fields ignored if no concurrent access */ + int bytesPerScanline; + int byteOrder; /* MSBFirst, LSBFirst */ + int depth; + int bitsPerPixel; + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + short visualClass; + int viewportWidth; + int viewportHeight; + int xViewportStep; /* viewport position granularity */ + int yViewportStep; + int maxViewportX; /* max viewport origin */ + int maxViewportY; + int viewportFlags; /* types of page flipping possible */ + int offset; /* offset into physical memory */ + unsigned char *address; /* server's mapped framebuffer */ + int reserved1; + int reserved2; +} DGAModeRec, *DGAModePtr; + +typedef struct { + DGAModePtr mode; + PixmapPtr pPix; +} DGADeviceRec, *DGADevicePtr; + +/* + * Flags for driver Probe() functions. + */ +#define PROBE_DEFAULT 0x00 +#define PROBE_DETECT 0x01 +#define PROBE_TRYHARD 0x02 + +/* + * Driver entry point types + */ + +typedef Bool xf86ProbeProc(DriverPtr, int); +typedef Bool xf86PreInitProc(ScrnInfoPtr, int); +typedef Bool xf86ScreenInitProc(ScreenPtr, int, char **); +typedef Bool xf86SwitchModeProc(ScrnInfoPtr, DisplayModePtr); +typedef void xf86AdjustFrameProc(ScrnInfoPtr, int, int); +typedef Bool xf86EnterVTProc(ScrnInfoPtr); +typedef void xf86LeaveVTProc(ScrnInfoPtr); +typedef void xf86FreeScreenProc(ScrnInfoPtr); +typedef ModeStatus xf86ValidModeProc(ScrnInfoPtr, DisplayModePtr, Bool, int); +typedef void xf86EnableDisableFBAccessProc(ScrnInfoPtr, Bool); +typedef int xf86SetDGAModeProc(ScrnInfoPtr, int, DGADevicePtr); +typedef int xf86ChangeGammaProc(ScrnInfoPtr, Gamma); +typedef void xf86PointerMovedProc(ScrnInfoPtr, int, int); +typedef Bool xf86PMEventProc(ScrnInfoPtr, pmEvent, Bool); +typedef void xf86DPMSSetProc(ScrnInfoPtr, int, int); +typedef void xf86LoadPaletteProc(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); +typedef void xf86SetOverscanProc(ScrnInfoPtr, int); +typedef void xf86ModeSetProc(ScrnInfoPtr); + +/* + * ScrnInfoRec + * + * There is one of these for each screen, and it holds all the screen-specific + * information. Note: No fields are to be dependent on compile-time defines. + */ +struct _ScrnInfoRec { + int driverVersion; + const char *driverName; /* canonical name used in */ + /* the config file */ + ScreenPtr pScreen; /* Pointer to the ScreenRec */ + int scrnIndex; /* Number of this screen */ + Bool configured; /* Is this screen valid */ + int origIndex; /* initial number assigned to + * this screen before + * finalising the number of + * available screens */ + + /* Display-wide screenInfo values needed by this screen */ + int imageByteOrder; + int bitmapScanlineUnit; + int bitmapScanlinePad; + int bitmapBitOrder; + int numFormats; + PixmapFormatRec formats[MAXFORMATS]; + PixmapFormatRec fbFormat; + + int bitsPerPixel; /* fb bpp */ + int depth; /* depth of default visual */ + MessageType depthFrom; /* set from config? */ + MessageType bitsPerPixelFrom; /* set from config? */ + rgb weight; /* r/g/b weights */ + rgb mask; /* rgb masks */ + rgb offset; /* rgb offsets */ + int rgbBits; /* Number of bits in r/g/b */ + Gamma gamma; /* Gamma of the monitor */ + int defaultVisual; /* default visual class */ + int virtualX; /* Virtual width */ + int virtualY; /* Virtual height */ + int xInc; /* Horizontal timing increment */ + int displayWidth; /* memory pitch */ + int frameX0; /* viewport position */ + int frameY0; + int frameX1; + int frameY1; + int zoomLocked; /* Disallow mode changes */ + DisplayModePtr modePool; /* list of compatible modes */ + DisplayModePtr modes; /* list of actual modes */ + DisplayModePtr currentMode; /* current mode + * This was previously + * overloaded with the modes + * field, which is a pointer + * into a circular list */ + confScreenPtr confScreen; /* Screen config info */ + MonPtr monitor; /* Monitor information */ + DispPtr display; /* Display information */ + int *entityList; /* List of device entities */ + int numEntities; + int widthmm; /* physical display dimensions + * in mm */ + int heightmm; + int xDpi; /* width DPI */ + int yDpi; /* height DPI */ + const char *name; /* Name to prefix messages */ + void *driverPrivate; /* Driver private area */ + DevUnion *privates; /* Other privates can hook in + * here */ + DriverPtr drv; /* xf86DriverList[] entry */ + void *module; /* Pointer to module head */ + int colorKey; + int overlayFlags; + + /* Some of these may be moved out of here into the driver private area */ + + const char *chipset; /* chipset name */ + const char *ramdac; /* ramdac name */ + const char *clockchip; /* clock name */ + Bool progClock; /* clock is programmable */ + int numClocks; /* number of clocks */ + int clock[MAXCLOCKS]; /* list of clock frequencies */ + int videoRam; /* amount of video ram (kb) */ + unsigned long memPhysBase; /* Physical address of FB */ + unsigned long fbOffset; /* Offset of FB in the above */ + void *options; + + /* Allow screens to be enabled/disabled individually */ + Bool vtSema; + + /* hw cursor moves from input thread */ + Bool silkenMouse; + + /* Storage for clockRanges and adjustFlags for use with the VidMode ext */ + ClockRangePtr clockRanges; + int adjustFlags; + + /* initial rightof support disable */ + int preferClone; + + Bool is_gpu; + uint32_t capabilities; + + int *entityInstanceList; + struct pci_device *vgaDev; + + /* + * Driver entry points. + * + */ + + xf86ProbeProc *Probe; + xf86PreInitProc *PreInit; + xf86ScreenInitProc *ScreenInit; + xf86SwitchModeProc *SwitchMode; + xf86AdjustFrameProc *AdjustFrame; + xf86EnterVTProc *EnterVT; + xf86LeaveVTProc *LeaveVT; + xf86FreeScreenProc *FreeScreen; + xf86ValidModeProc *ValidMode; + xf86EnableDisableFBAccessProc *EnableDisableFBAccess; + xf86SetDGAModeProc *SetDGAMode; + xf86ChangeGammaProc *ChangeGamma; + xf86PointerMovedProc *PointerMoved; + xf86PMEventProc *PMEvent; + xf86DPMSSetProc *DPMSSet; + xf86LoadPaletteProc *LoadPalette; + xf86SetOverscanProc *SetOverscan; + xorgDriverFuncProc *DriverFunc; + xf86ModeSetProc *ModeSet; + + int reservedInt[NUM_RESERVED_INTS]; + void *reservedPtr[NUM_RESERVED_POINTERS]; + funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; +}; + +typedef struct { + Bool (*OpenFramebuffer) (ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, int *offset, int *extra); + void (*CloseFramebuffer) (ScrnInfoPtr pScrn); + Bool (*SetMode) (ScrnInfoPtr pScrn, DGAModePtr pMode); + void (*SetViewport) (ScrnInfoPtr pScrn, int x, int y, int flags); + int (*GetViewport) (ScrnInfoPtr pScrn); + void (*Sync) (ScrnInfoPtr); + void (*FillRect) (ScrnInfoPtr pScrn, + int x, int y, int w, int h, unsigned long color); + void (*BlitRect) (ScrnInfoPtr pScrn, + int srcx, int srcy, int w, int h, int dstx, int dsty); + void (*BlitTransRect) (ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, unsigned long color); +} DGAFunctionRec, *DGAFunctionPtr; + +typedef struct _SymTabRec { + int token; /* id of the token */ + const char *name; /* token name */ +} SymTabRec, *SymTabPtr; + +/* flags for xf86LookupMode */ +typedef enum { + LOOKUP_DEFAULT = 0, /* Use default mode lookup method */ + LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */ + LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */ + LOOKUP_LIST_ORDER, /* Pick first useful mode in list */ + LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */ + LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */ +} LookupModeFlags; + +#define NoDepth24Support 0x00 +#define Support24bppFb 0x01 /* 24bpp framebuffer supported */ +#define Support32bppFb 0x02 /* 32bpp framebuffer supported */ +#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */ +#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */ +#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */ +#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */ + +/* For DPMS */ +typedef void (*DPMSSetProcPtr) (ScrnInfoPtr, int, int); + +/* Input handler proc */ +typedef void (*InputHandlerProc) (int fd, void *data); + +/* These are used by xf86GetClocks */ +#define CLK_REG_SAVE -1 +#define CLK_REG_RESTORE -2 + +/* + * misc constants + */ +#define INTERLACE_REFRESH_WEIGHT 1.5 +#define SYNC_TOLERANCE 0.01 /* 1 percent */ +#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */ + +#define OVERLAY_8_32_DUALFB 0x00000001 +#define OVERLAY_8_24_DUALFB 0x00000002 +#define OVERLAY_8_16_DUALFB 0x00000004 +#define OVERLAY_8_32_PLANAR 0x00000008 + +/* Values of xf86Info.mouseFlags */ +#define MF_CLEAR_DTR 1 +#define MF_CLEAR_RTS 2 + +#endif /* _XF86STR_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xisb.h b/prebuilt/xlibre/usr/include/xorg/xisb.h new file mode 100644 index 0000000..0559196 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xisb.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 1997 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +#ifndef _xisb_H_ +#define _xisb_H_ + +#include +#include + +/****************************************************************************** + * Definitions + * structs, typedefs, #defines, enums + *****************************************************************************/ + +typedef struct _XISBuffer { + int fd; + int trace; + int block_duration; + ssize_t current; /* bytes read */ + ssize_t end; + ssize_t buffer_size; + unsigned char *buf; +} XISBuffer; + +/****************************************************************************** + * Declarations + * variables: use xisb_LOC in front + * of globals. + * put locals in the .c file. + *****************************************************************************/ +extern _X_EXPORT XISBuffer *XisbNew(int fd, ssize_t size); +extern _X_EXPORT void XisbFree(XISBuffer * b); +extern _X_EXPORT int XisbRead(XISBuffer * b); +extern _X_EXPORT void XisbBlockDuration(XISBuffer * b, int block_duration); + +/* + * DO NOT PUT ANYTHING AFTER THIS ENDIF + */ +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/xkbrules.h b/prebuilt/xlibre/usr/include/xorg/xkbrules.h new file mode 100644 index 0000000..a781b12 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xkbrules.h @@ -0,0 +1,40 @@ +#ifndef _XKBRULES_H_ +#define _XKBRULES_H_ 1 + +/************************************************************ + Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc. + + Permission to use, copy, modify, and distribute this + software and its documentation for any purpose and without + fee is hereby granted, provided that the above copyright + notice appear in all copies and that both that copyright + notice and this permission notice appear in supporting + documentation, and that the name of Silicon Graphics not be + used in advertising or publicity pertaining to distribution + of the software without specific prior written permission. + Silicon Graphics makes no representation about the suitability + of this software for any purpose. It is provided "as is" + without any express or implied warranty. + + SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH + THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ********************************************************/ + +/***====================================================================***/ + +typedef struct _XkbRMLVOSet { + char *rules; + char *model; + char *layout; + char *variant; + char *options; +} XkbRMLVOSet; + +#endif /* _XKBRULES_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xkbsrv.h b/prebuilt/xlibre/usr/include/xorg/xkbsrv.h new file mode 100644 index 0000000..f683254 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xkbsrv.h @@ -0,0 +1,268 @@ +/************************************************************ +Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting +documentation, and that the name of Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +#ifndef _XKBSRV_H_ +#define _XKBSRV_H_ + +#define XkbFreeKeyboard SrvXkbFreeKeyboard + +#include +#include + +#include "xlibre_ptrtypes.h" +#include "xkbstr.h" +#include "xkbrules.h" +#include "inputstr.h" +#include "events.h" + +typedef struct _XkbInterest { + DeviceIntPtr dev; + ClientPtr client; + XID resource; + struct _XkbInterest *next; + CARD16 extDevNotifyMask; + CARD16 stateNotifyMask; + CARD16 namesNotifyMask; + CARD32 ctrlsNotifyMask; + CARD8 compatNotifyMask; + BOOL bellNotifyMask; + BOOL actionMessageMask; + CARD16 accessXNotifyMask; + CARD32 iStateNotifyMask; + CARD32 iMapNotifyMask; + CARD16 altSymsNotifyMask; + CARD32 autoCtrls; + CARD32 autoCtrlValues; +} XkbInterestRec, *XkbInterestPtr; + +typedef struct _XkbRadioGroup { + CARD8 flags; + CARD8 nMembers; + CARD8 dfltDown; + CARD8 currentDown; + CARD8 members[XkbRGMaxMembers]; +} XkbRadioGroupRec, *XkbRadioGroupPtr; + +typedef struct _XkbEventCause { + CARD8 kc; + CARD8 event; + CARD8 mjr; + CARD8 mnr; + ClientPtr client; +} XkbEventCauseRec, *XkbEventCausePtr; + +typedef struct _XkbFilter { + CARD16 keycode; + CARD8 what; + CARD8 active; + CARD8 filterOthers; + CARD32 priv; + XkbAction upAction; + int (*filter) (struct _XkbSrvInfo * /* xkbi */ , + struct _XkbFilter * /* filter */ , + unsigned /* keycode */ , + XkbAction * /* action */ + ); + struct _XkbFilter *next; +} XkbFilterRec, *XkbFilterPtr; + +typedef Bool (*XkbSrvCheckRepeatPtr) (DeviceIntPtr dev, + struct _XkbSrvInfo * /* xkbi */ , + unsigned /* keycode */); + +typedef struct _XkbSrvInfo { + XkbStateRec prev_state; + XkbStateRec state; + XkbDescPtr desc; + + DeviceIntPtr device; + KbdCtrlProcPtr kbdProc; + + XkbRadioGroupPtr radioGroups; + CARD8 nRadioGroups; + CARD8 clearMods; + CARD8 setMods; + INT16 groupChange; + + CARD16 dfltPtrDelta; + + double mouseKeysCurve; + double mouseKeysCurveFactor; + INT16 mouseKeysDX; + INT16 mouseKeysDY; + CARD8 mouseKeysFlags; + Bool mouseKeysAccel; + CARD8 mouseKeysCounter; + + CARD8 lockedPtrButtons; + CARD8 shiftKeyCount; + KeyCode mouseKey; + KeyCode inactiveKey; + KeyCode slowKey; + KeyCode slowKeyEnableKey; + KeyCode repeatKey; + CARD8 krgTimerActive; + CARD8 beepType; + CARD8 beepCount; + + CARD32 flags; + CARD32 lastPtrEventTime; + CARD32 lastShiftEventTime; + OsTimerPtr beepTimer; + OsTimerPtr mouseKeyTimer; + OsTimerPtr slowKeysTimer; + OsTimerPtr bounceKeysTimer; + OsTimerPtr repeatKeyTimer; + OsTimerPtr krgTimer; + + int szFilters; + XkbFilterPtr filters; + + XkbSrvCheckRepeatPtr checkRepeat; + + char overlay_perkey_state[256/8]; /* bitfield */ +} XkbSrvInfoRec, *XkbSrvInfoPtr; + +typedef struct _XkbSrvLedInfo { + CARD16 flags; + CARD16 class; + CARD16 id; + union { + KbdFeedbackPtr kf; + LedFeedbackPtr lf; + } fb; + + CARD32 physIndicators; + CARD32 autoState; + CARD32 explicitState; + CARD32 effectiveState; + + CARD32 mapsPresent; + CARD32 namesPresent; + XkbIndicatorMapPtr maps; + Atom *names; + + CARD32 usesBase; + CARD32 usesLatched; + CARD32 usesLocked; + CARD32 usesEffective; + CARD32 usesCompat; + CARD32 usesControls; + + CARD32 usedComponents; +} XkbSrvLedInfoRec, *XkbSrvLedInfoPtr; + +typedef struct { + ProcessInputProc processInputProc; + /* If processInputProc is set to something different than realInputProc, + * UNWRAP and COND_WRAP will not touch processInputProc and update only + * realInputProc. This ensures that + * processInputProc == (frozen ? EnqueueEvent : realInputProc) + * + * WRAP_PROCESS_INPUT_PROC should only be called during initialization, + * since it may destroy this invariant. + */ + ProcessInputProc realInputProc; + DeviceUnwrapProc unwrapProc; +} xkbDeviceInfoRec, *xkbDeviceInfoPtr; + +/***====================================================================***/ + +#define Status int + +extern _X_EXPORT void XkbFreeKeyboard(XkbDescPtr /* xkb */ , + unsigned int /* which */ , + Bool /* freeDesc */ + ); + +/** + * @brief get the current keysym map + * + * This call might be used after a keyboard mapping has been reloaded + * with InitKeyboardDeviceStruct() to get the information needed to + * pass to XkbApplyMappingChange() + * + * The returned value is dynamically allocated, and must be + * freed after use. + * + * @param keybd Keyboard to use to get the map + * + * @return keysym map, or NULL if an error occurs + */ +extern _X_EXPORT KeySymsPtr XkbGetCoreMap(DeviceIntPtr /* keybd */ + ); + +extern _X_EXPORT void XkbApplyMappingChange(DeviceIntPtr /* pXDev */ , + KeySymsPtr /* map */ , + KeyCode /* firstKey */ , + CARD8 /* num */ , + CARD8 * /* modmap */ , + ClientPtr /* client */ + ); + +extern _X_EXPORT void XkbDDXChangeControls(DeviceIntPtr /* dev */ , + XkbControlsPtr /* old */ , + XkbControlsPtr /* new */ + ); + +/** + * @brief Set global autorepeat / sync core protocol repeat flags + * + * This call performs one of two actions, depending on whether + * key is set to -1 or not. + * + * If the key is set to -1, the global autorepeat setting is + * set to the value specified in the onoff parameter. + * + * If the key is a keycode, the XKB repeat setting for the key is + * synchronised from the core protocol setting, and the onoff + * parameter is ignored. + * + * @param pxDev Keyboard to use + * @param key Keycode, or -1 + * @param onoff One of { AutoRepeatModeOff, AutoRepeatModeOn } + * Used only if key == -1 + * + */ +extern _X_EXPORT void XkbSetRepeatKeys(DeviceIntPtr /* pXDev */ , + int /* key */ , + int /* onoff */ + ); + +extern _X_EXPORT void XkbGetRulesDflts(XkbRMLVOSet * /* rmlvo */ + ); + +extern _X_EXPORT void XkbFreeRMLVOSet(XkbRMLVOSet * /* rmlvo */ , + Bool /* freeRMLVO */ + ); + +extern _X_EXPORT Bool XkbCopyDeviceKeymap(DeviceIntPtr /* dst */, + DeviceIntPtr /* src */); + +#include "xkbstr.h" +#include "xkbrules.h" + +#endif /* _XKBSRV_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xkbstr.h b/prebuilt/xlibre/usr/include/xorg/xkbstr.h new file mode 100644 index 0000000..9be88ef --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xkbstr.h @@ -0,0 +1,641 @@ +/************************************************************ +Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting +documentation, and that the name of Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +#ifndef _XKBSTR_H_ +#define _XKBSTR_H_ + +#include +#include + +#define XkbCharToInt(v) ((int) ((v) & 0x80 ? ((v) | (~0xff)) : ((v) & 0x7f))) +#define XkbIntTo2Chars(i, h, l) ((h) = ((i) >> 8) & 0xff, (l) = (i) & 0xff) + +#if defined(WORD64) && defined(UNSIGNEDBITFIELDS) +#define Xkb2CharsToInt(h, l) ((int) ((h) & 0x80 ? \ + (((h) << 8) | (l) | (~0xffff)) : \ + (((h) << 8) | (l) & 0x7fff)) +#else +#define Xkb2CharsToInt(h,l) ((short)(((h)<<8)|(l))) +#endif + + /* + * Common data structures and access macros + */ + +typedef struct _XkbStateRec { + unsigned char group; /* base + latched + locked */ + /* FIXME: Why are base + latched short and not char?? */ + unsigned short base_group; /* physically ... down? */ + unsigned short latched_group; + unsigned char locked_group; + + unsigned char mods; /* base + latched + locked */ + unsigned char base_mods; /* physically down */ + unsigned char latched_mods; + unsigned char locked_mods; + + unsigned char compat_state; /* mods + group for core state */ + + /* grab mods = all depressed and latched mods, _not_ locked mods */ + unsigned char grab_mods; /* grab mods minus internal mods */ + unsigned char compat_grab_mods; /* grab mods + group for core state, + but not locked groups if + IgnoreGroupLocks set */ + + /* effective mods = all mods (depressed, latched, locked) */ + unsigned char lookup_mods; /* effective mods minus internal mods */ + unsigned char compat_lookup_mods; /* effective mods + group */ + + unsigned short ptr_buttons; /* core pointer buttons */ +} XkbStateRec, *XkbStatePtr; + +#define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group) +#define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group) + +typedef struct _XkbMods { + unsigned char mask; /* effective mods */ + unsigned char real_mods; + unsigned short vmods; +} XkbModsRec, *XkbModsPtr; + +typedef struct _XkbKTMapEntry { + Bool active; + unsigned char level; + XkbModsRec mods; +} XkbKTMapEntryRec, *XkbKTMapEntryPtr; + +typedef struct _XkbKeyType { + XkbModsRec mods; + unsigned char num_levels; + unsigned char map_count; + XkbKTMapEntryPtr map; + XkbModsPtr preserve; + Atom name; + Atom *level_names; +} XkbKeyTypeRec, *XkbKeyTypePtr; + +#define XkbNumGroups(g) ((g)&0x0f) +#define XkbOutOfRangeGroupInfo(g) ((g)&0xf0) +#define XkbOutOfRangeGroupAction(g) ((g)&0xc0) +#define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4) +#define XkbSetGroupInfo(g, w, n) (((w) & 0xc0) | (((n) & 3) << 4) | \ + ((g) & 0x0f)) +#define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f)) + + /* + * Structures and access macros used primarily by the server + */ + +typedef struct _XkbBehavior { + unsigned char type; + unsigned char data; +} XkbBehavior; + +#define XkbAnyActionDataSize 7 +typedef struct _XkbAnyAction { + unsigned char type; + unsigned char data[XkbAnyActionDataSize]; +} XkbAnyAction; + +typedef struct _XkbModAction { + unsigned char type; + unsigned char flags; + unsigned char mask; + unsigned char real_mods; + /* FIXME: Make this an int. */ + unsigned char vmods1; + unsigned char vmods2; +} XkbModAction; + +#define XkbModActionVMods(a) ((short) (((a)->vmods1 << 8) | (a)->vmods2)) +#define XkbSetModActionVMods(a,v) \ + ((a)->vmods1 = (((v) >> 8) & 0xff), \ + (a)->vmods2 = (v) & 0xff) + +typedef struct _XkbGroupAction { + unsigned char type; + unsigned char flags; + /* FIXME: Make this an int. */ + char group_XXX; +} XkbGroupAction; + +#define XkbSAGroup(a) (XkbCharToInt((a)->group_XXX)) +#define XkbSASetGroup(a,g) ((a)->group_XXX=(g)) + +typedef struct _XkbISOAction { + unsigned char type; + unsigned char flags; + unsigned char mask; + unsigned char real_mods; + /* FIXME: Make this an int. */ + char group_XXX; + unsigned char affect; + unsigned char vmods1; + unsigned char vmods2; +} XkbISOAction; + +typedef struct _XkbPtrAction { + unsigned char type; + unsigned char flags; + /* FIXME: Make this an int. */ + unsigned char high_XXX; + unsigned char low_XXX; + unsigned char high_YYY; + unsigned char low_YYY; +} XkbPtrAction; + +#define XkbPtrActionX(a) (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX)) +#define XkbPtrActionY(a) (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY)) +#define XkbSetPtrActionX(a,x) (XkbIntTo2Chars((x),(a)->high_XXX,(a)->low_XXX)) +#define XkbSetPtrActionY(a,y) (XkbIntTo2Chars((y),(a)->high_YYY,(a)->low_YYY)) + +typedef struct _XkbPtrBtnAction { + unsigned char type; + unsigned char flags; + unsigned char count; + unsigned char button; +} XkbPtrBtnAction; + +typedef struct _XkbPtrDfltAction { + unsigned char type; + unsigned char flags; + unsigned char affect; + char valueXXX; +} XkbPtrDfltAction; + +#define XkbSAPtrDfltValue(a) (XkbCharToInt((a)->valueXXX)) +#define XkbSASetPtrDfltValue(a, c) ((a)->valueXXX = (c) & 0xff) + +typedef struct _XkbSwitchScreenAction { + unsigned char type; + unsigned char flags; + char screenXXX; +} XkbSwitchScreenAction; + +#define XkbSAScreen(a) (XkbCharToInt((a)->screenXXX)) +#define XkbSASetScreen(a, s) ((a)->screenXXX = (s) & 0xff) + +typedef struct _XkbCtrlsAction { + unsigned char type; + unsigned char flags; + /* FIXME: Make this an int. */ + unsigned char ctrls3; + unsigned char ctrls2; + unsigned char ctrls1; + unsigned char ctrls0; +} XkbCtrlsAction; + +#define XkbActionSetCtrls(a, c) ((a)->ctrls3 = ((c) >> 24) & 0xff, \ + (a)->ctrls2 = ((c) >> 16) & 0xff, \ + (a)->ctrls1 = ((c) >> 8) & 0xff, \ + (a)->ctrls0 = (c) & 0xff) +#define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|\ + (((unsigned int)(a)->ctrls2)<<16)|\ + (((unsigned int)(a)->ctrls1)<<8)|\ + ((unsigned int) (a)->ctrls0)) + +typedef struct _XkbMessageAction { + unsigned char type; + unsigned char flags; + unsigned char message[6]; +} XkbMessageAction; + +typedef struct _XkbRedirectKeyAction { + unsigned char type; + unsigned char new_key; + unsigned char mods_mask; + unsigned char mods; + /* FIXME: Make this an int. */ + unsigned char vmods_mask0; + unsigned char vmods_mask1; + unsigned char vmods0; + unsigned char vmods1; +} XkbRedirectKeyAction; + +#define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|\ + ((unsigned int)(a)->vmods0)) +/* FIXME: This is blatantly not setting vmods. Yeesh. */ +#define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\ + ((a)->vmods_mask0=((m)&0xff))) +#define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)|\ + ((unsigned int)(a)->vmods_mask0)) +#define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\ + ((a)->vmods_mask0=((m)&0xff))) + +typedef struct _XkbDeviceBtnAction { + unsigned char type; + unsigned char flags; + unsigned char count; + unsigned char button; + unsigned char device; +} XkbDeviceBtnAction; + +typedef struct _XkbDeviceValuatorAction { + unsigned char type; + unsigned char device; + unsigned char v1_what; + unsigned char v1_ndx; + unsigned char v1_value; + unsigned char v2_what; + unsigned char v2_ndx; + unsigned char v2_value; +} XkbDeviceValuatorAction; + +typedef union _XkbAction { + XkbAnyAction any; + XkbModAction mods; + XkbGroupAction group; + XkbISOAction iso; + XkbPtrAction ptr; + XkbPtrBtnAction btn; + XkbPtrDfltAction dflt; + XkbSwitchScreenAction screen; + XkbCtrlsAction ctrls; + XkbMessageAction msg; + XkbRedirectKeyAction redirect; + XkbDeviceBtnAction devbtn; + XkbDeviceValuatorAction devval; + unsigned char type; +} XkbAction; + +typedef struct _XkbControls { + unsigned char mk_dflt_btn; + unsigned char num_groups; + unsigned char groups_wrap; + XkbModsRec internal; + XkbModsRec ignore_lock; + unsigned int enabled_ctrls; + unsigned short repeat_delay; + unsigned short repeat_interval; + unsigned short slow_keys_delay; + unsigned short debounce_delay; + unsigned short mk_delay; + unsigned short mk_interval; + unsigned short mk_time_to_max; + unsigned short mk_max_speed; + short mk_curve; + unsigned short ax_options; + unsigned short ax_timeout; + unsigned short axt_opts_mask; + unsigned short axt_opts_values; + unsigned int axt_ctrls_mask; + unsigned int axt_ctrls_values; + unsigned char per_key_repeat[XkbPerKeyBitArraySize]; +} XkbControlsRec, *XkbControlsPtr; + +#define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask) +#define XkbAX_NeedOption(c,w) ((c)->ax_options&(w)) +#define XkbAX_NeedFeedback(c, w) (XkbAX_AnyFeedback((c)) && \ + XkbAX_NeedOption((c), (w))) + +typedef struct _XkbServerMapRec { + unsigned short num_acts; + unsigned short size_acts; + XkbAction *acts; + + XkbBehavior *behaviors; + unsigned short *key_acts; +#if defined(__cplusplus) || defined(c_plusplus) + /* explicit is a C++ reserved word */ + unsigned char *c_explicit; +#else + unsigned char *explicit; +#endif + unsigned char vmods[XkbNumVirtualMods]; + unsigned short *vmodmap; +} XkbServerMapRec, *XkbServerMapPtr; + +#define XkbSMKeyActionsPtr(m, k) (&(m)->acts[(m)->key_acts[(k)]]) + + /* + * Structures and access macros used primarily by clients + */ + +typedef struct _XkbSymMapRec { + unsigned char kt_index[XkbNumKbdGroups]; + unsigned char group_info; + unsigned char width; + unsigned short offset; +} XkbSymMapRec, *XkbSymMapPtr; + +typedef struct _XkbClientMapRec { + unsigned char size_types; + unsigned char num_types; + XkbKeyTypePtr types; + + unsigned short size_syms; + unsigned short num_syms; + KeySym *syms; + XkbSymMapPtr key_sym_map; + + unsigned char *modmap; +} XkbClientMapRec, *XkbClientMapPtr; + +#define XkbCMKeyGroupInfo(m, k) ((m)->key_sym_map[(k)].group_info) +#define XkbCMKeyNumGroups(m, k) (XkbNumGroups((m)->key_sym_map[(k)].group_info)) +#define XkbCMKeyGroupWidth(m, k, g) (XkbCMKeyType((m), (k), (g))->num_levels) +#define XkbCMKeyGroupsWidth(m, k) ((m)->key_sym_map[(k)].width) +#define XkbCMKeyTypeIndex(m, k, g) ((m)->key_sym_map[(k)].kt_index[(g) & 0x3]) +#define XkbCMKeyType(m, k, g) (&(m)->types[XkbCMKeyTypeIndex((m), (k), (g))]) +#define XkbCMKeyNumSyms(m, k) (XkbCMKeyGroupsWidth((m), (k)) * \ + XkbCMKeyNumGroups((m), (k))) +#define XkbCMKeySymsOffset(m, k) ((m)->key_sym_map[(k)].offset) +#define XkbCMKeySymsPtr(m, k) (&(m)->syms[XkbCMKeySymsOffset((m), (k))]) + + /* + * Compatibility structures and access macros + */ + +typedef struct _XkbSymInterpretRec { + KeySym sym; + unsigned char flags; + unsigned char match; + unsigned char mods; + unsigned char virtual_mod; + XkbAnyAction act; +} XkbSymInterpretRec, *XkbSymInterpretPtr; + +typedef struct _XkbCompatMapRec { + XkbSymInterpretPtr sym_interpret; + XkbModsRec groups[XkbNumKbdGroups]; + unsigned short num_si; + unsigned short size_si; +} XkbCompatMapRec, *XkbCompatMapPtr; + +typedef struct _XkbIndicatorMapRec { + unsigned char flags; + /* FIXME: For some reason, interpretation of groups is wildly + * different between which being base/latched/locked. */ + unsigned char which_groups; + unsigned char groups; + unsigned char which_mods; + XkbModsRec mods; + unsigned int ctrls; +} XkbIndicatorMapRec, *XkbIndicatorMapPtr; + +#define XkbIM_IsAuto(i) (!((i)->flags & XkbIM_NoAutomatic) && \ + (((i)->which_groups&&(i)->groups)||\ + ((i)->which_mods&&(i)->mods.mask)||\ + (i)->ctrls)) +#define XkbIM_InUse(i) ((i)->flags || (i)->which_groups || (i)->which_mods || \ + (i)->ctrls) + +typedef struct _XkbIndicatorRec { + unsigned long phys_indicators; + XkbIndicatorMapRec maps[XkbNumIndicators]; +} XkbIndicatorRec, *XkbIndicatorPtr; + +typedef struct _XkbKeyNameRec { + char name[XkbKeyNameLength]; +} XkbKeyNameRec, *XkbKeyNamePtr; + +typedef struct _XkbKeyAliasRec { + char real[XkbKeyNameLength]; + char alias[XkbKeyNameLength]; +} XkbKeyAliasRec, *XkbKeyAliasPtr; + + /* + * Names for everything + */ +typedef struct _XkbNamesRec { + Atom keycodes; + Atom geometry; + Atom symbols; + Atom types; + Atom compat; + Atom vmods[XkbNumVirtualMods]; + Atom indicators[XkbNumIndicators]; + Atom groups[XkbNumKbdGroups]; + XkbKeyNamePtr keys; + XkbKeyAliasPtr key_aliases; + Atom *radio_groups; + Atom phys_symbols; + + unsigned char num_keys; + unsigned char num_key_aliases; + unsigned short num_rg; +} XkbNamesRec, *XkbNamesPtr; + +typedef struct _XkbGeometry *XkbGeometryPtr; + + /* + * Tie it all together into one big keyboard description + */ +typedef struct _XkbDesc { + unsigned int defined; + unsigned short flags; + unsigned short device_spec; + KeyCode min_key_code; + KeyCode max_key_code; + + XkbControlsPtr ctrls; + XkbServerMapPtr server; + XkbClientMapPtr map; + XkbIndicatorPtr indicators; + XkbNamesPtr names; + XkbCompatMapPtr compat; + XkbGeometryPtr geom; +} XkbDescRec, *XkbDescPtr; + +#define XkbKeyKeyTypeIndex(d, k, g) (XkbCMKeyTypeIndex((d)->map, (k), (g))) +#define XkbKeyKeyType(d, k, g) (XkbCMKeyType((d)->map, (k), (g))) +#define XkbKeyGroupWidth(d, k, g) (XkbCMKeyGroupWidth((d)->map, (k), (g))) +#define XkbKeyGroupsWidth(d, k) (XkbCMKeyGroupsWidth((d)->map, (k))) +#define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k))) +#define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k))) +#define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k))) +#define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k))) +#define XkbKeySym(d, k, n) (XkbKeySymsPtr((d), (k))[(n)]) +#define XkbKeySymEntry(d,k,sl,g) \ + (XkbKeySym((d), (k), (XkbKeyGroupsWidth((d), (k)) * (g)) + (sl))) +#define XkbKeyAction(d,k,n) \ + (XkbKeyHasActions((d), (k)) ? & XkbKeyActionsPtr((d), (k))[(n)] : NULL) +#define XkbKeyActionEntry(d,k,sl,g) \ + (XkbKeyHasActions((d), (k)) ? \ + XkbKeyAction((d), (k), ((XkbKeyGroupsWidth((d), (k)) * (g)) + (sl))) : \ + NULL) + +#define XkbKeyHasActions(d, k) (!!(d)->server->key_acts[(k)]) +#define XkbKeyNumActions(d, k) (XkbKeyHasActions((d), (k)) ? \ + XkbKeyNumSyms((d), (k)) : 1) +#define XkbKeyActionsPtr(d, k) (XkbSMKeyActionsPtr((d)->server, (k))) +#define XkbKeycodeInRange(d, k) ((k) >= (d)->min_key_code && \ + (k) <= (d)->max_key_code) +#define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1) + + /* + * The following structures can be used to track changes + * to a keyboard device + */ +typedef struct _XkbMapChanges { + unsigned short changed; + KeyCode min_key_code; + KeyCode max_key_code; + unsigned char first_type; + unsigned char num_types; + KeyCode first_key_sym; + unsigned char num_key_syms; + KeyCode first_key_act; + unsigned char num_key_acts; + KeyCode first_key_behavior; + unsigned char num_key_behaviors; + KeyCode first_key_explicit; + unsigned char num_key_explicit; + KeyCode first_modmap_key; + unsigned char num_modmap_keys; + KeyCode first_vmodmap_key; + unsigned char num_vmodmap_keys; + unsigned char pad; + unsigned short vmods; +} XkbMapChangesRec, *XkbMapChangesPtr; + +typedef struct _XkbControlsChanges { + unsigned int changed_ctrls; + unsigned int enabled_ctrls_changes; + Bool num_groups_changed; +} XkbControlsChangesRec, *XkbControlsChangesPtr; + +typedef struct _XkbIndicatorChanges { + unsigned int state_changes; + unsigned int map_changes; +} XkbIndicatorChangesRec, *XkbIndicatorChangesPtr; + +typedef struct _XkbNameChanges { + unsigned int changed; + unsigned char first_type; + unsigned char num_types; + unsigned char first_lvl; + unsigned char num_lvls; + unsigned char num_aliases; + unsigned char num_rg; + unsigned char first_key; + unsigned char num_keys; + unsigned short changed_vmods; + unsigned long changed_indicators; + unsigned char changed_groups; +} XkbNameChangesRec, *XkbNameChangesPtr; + +typedef struct _XkbCompatChanges { + unsigned char changed_groups; + unsigned short first_si; + unsigned short num_si; +} XkbCompatChangesRec, *XkbCompatChangesPtr; + +typedef struct _XkbChanges { + unsigned short device_spec; + unsigned short state_changes; + XkbMapChangesRec map; + XkbControlsChangesRec ctrls; + XkbIndicatorChangesRec indicators; + XkbNameChangesRec names; + XkbCompatChangesRec compat; +} XkbChangesRec, *XkbChangesPtr; + + /* + * These data structures are used to construct a keymap from + * a set of components or to list components in the server + * database. + */ +typedef struct _XkbComponentNames { + char *keycodes; + char *types; + char *compat; + char *symbols; + char *geometry; +} XkbComponentNamesRec, *XkbComponentNamesPtr; + +typedef struct _XkbComponentName { + unsigned short flags; + char *name; +} XkbComponentNameRec, *XkbComponentNamePtr; + +typedef struct _XkbComponentList { + int num_keymaps; + int num_keycodes; + int num_types; + int num_compat; + int num_symbols; + int num_geometry; + XkbComponentNamePtr keymaps; + XkbComponentNamePtr keycodes; + XkbComponentNamePtr types; + XkbComponentNamePtr compat; + XkbComponentNamePtr symbols; + XkbComponentNamePtr geometry; +} XkbComponentListRec, *XkbComponentListPtr; + + /* + * The following data structures describe and track changes to a + * non-keyboard extension device + */ +typedef struct _XkbDeviceLedInfo { + unsigned short led_class; + unsigned short led_id; + unsigned int phys_indicators; + unsigned int maps_present; + unsigned int names_present; + unsigned int state; + Atom names[XkbNumIndicators]; + XkbIndicatorMapRec maps[XkbNumIndicators]; +} XkbDeviceLedInfoRec, *XkbDeviceLedInfoPtr; + +typedef struct _XkbDeviceInfo { + char *name; + Atom type; + unsigned short device_spec; + Bool has_own_state; + unsigned short supported; + unsigned short unsupported; + + unsigned short num_btns; + XkbAction *btn_acts; + + unsigned short sz_leds; + unsigned short num_leds; + unsigned short dflt_kbd_fb; + unsigned short dflt_led_fb; + XkbDeviceLedInfoPtr leds; +} XkbDeviceInfoRec, *XkbDeviceInfoPtr; + +#define XkbXI_DevHasBtnActs(d) ((d)->num_btns > 0 && (d)->btn_acts) +#define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d) && (b) < (d)->num_btns) +#define XkbXI_DevHasLeds(d) ((d)->num_leds > 0 && (d)->leds) + +typedef struct _XkbDeviceLedChanges { + unsigned short led_class; + unsigned short led_id; + unsigned int defined; /* names or maps changed */ + struct _XkbDeviceLedChanges *next; +} XkbDeviceLedChangesRec, *XkbDeviceLedChangesPtr; + +typedef struct _XkbDeviceChanges { + unsigned int changed; + unsigned short first_btn; + unsigned short num_btns; + XkbDeviceLedChangesRec leds; +} XkbDeviceChangesRec, *XkbDeviceChangesPtr; + +#endif /* _XKBSTR_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xlibre-server.h b/prebuilt/xlibre/usr/include/xorg/xlibre-server.h new file mode 100644 index 0000000..28fb7b9 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xlibre-server.h @@ -0,0 +1,218 @@ +/* xorg-server.h.in -*- c -*- + * + * This file is the template file for the xorg-server.h file which gets + * installed as part of the SDK. The #defines in this file overlap + * with those from config.h, but only for those options that we want + * to export to external modules. Boilerplate autotool #defines such + * as HAVE_STUFF and PACKAGE_NAME is kept in config.h + * + * It is still possible to update config.h.in using autoheader, since + * autoheader only creates a .h.in file for the first + * AM_CONFIG_HEADER() line, and thus does not overwrite this file. + * + * However, it should be kept in sync with this file. + */ + +#ifndef _XORG_SERVER_H_ +#define _XORG_SERVER_H_ + +#ifdef HAVE_XORG_CONFIG_H +#error Include xorg-config.h when building the X server +#endif + +/* Default font path */ +#define COMPILEDDEFAULTFONTPATH "/usr/share/fonts/misc,/usr/share/fonts/TTF,/usr/share/fonts/OTF" + +/* Support Composite Extension */ +#define COMPOSITE 1 + +/* Build DPMS extension */ +#define DPMSExtension 1 + +/* Build DRI3 extension */ +#define DRI3 1 + +/* Build GLX extension */ +#undef GLXEXT + +/* Support XDM-AUTH*-1 */ +#define HASXDMAUTH 1 + +/* Add a padding for legacy nvidia drivers that support old ABI */ +#undef CONFIG_LEGACY_NVIDIA_PADDING + +/* Define to 1 if you have the `reallocarray' function. */ +#define HAVE_REALLOCARRAY 1 + +/* Define to 1 if you have the `strlcat' function. */ +#define HAVE_STRLCAT 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the `strndup' function. */ +#define HAVE_STRNDUP 1 + +/* Support IPv6 for TCP connections */ +#define IPv6 1 + +/* Support MIT-SHM Extension */ +#define MITSHM 1 +#define CONFIG_MITSHM 1 + +/* Internal define for Xinerama */ +#define PANORAMIX 1 +#define XINERAMA 1 + +/* Support Present extension */ +#define PRESENT 1 + +/* Support RANDR extension */ +#define RANDR 1 + +/* Support RENDER extension */ +#define RENDER 1 + +/* Support X resource extension */ +#define RES 1 + +/* Support MIT-SCREEN-SAVER extension */ +#define SCREENSAVER 1 + +/* Support SHAPE extension */ +#define SHAPE 1 + +/* Define to 1 on systems derived from System V Release 4 */ +#undef SVR4 + +/* Support UNIX socket connections */ +#define UNIXCONN 1 + +/* Support XCMisc extension */ +#define XCMISC 1 + +/* Support Xdmcp */ +#define XDMCP 1 + +/* Support XFree86 Video Mode extension */ +#define XF86VIDMODE 1 + +/* Build XDGA support */ +#undef XFreeXDGA + +/* Support Xinerama extension */ +#define XINERAMA 1 + +/* Support X Input extension */ +#define XINPUT 1 + +/* XKB default rules */ +#define XKB_DFLT_RULES "evdev" + +/* Build DRI extension */ +#undef XF86DRI + +/* Build DRI2 extension */ +#define DRI2 1 + +/* Build Xorg server */ +#define XORGSERVER 1 + +/* Current Xorg version */ +#define XORG_VERSION_CURRENT 12502000 + +/* Build Xv Extension */ +#undef XvExtension + +/* Build XvMC Extension */ +#undef XvMCExtension + +/* Support XSync extension */ +#define XSYNC 1 + +/* Support XTest extension */ +#define XTEST 1 + +/* Support Xv Extension */ +#undef XV + +/* BSD-compliant source */ +/* #undef _BSD_SOURCE */ + +/* POSIX-compliant source */ +/* #undef _POSIX_SOURCE */ + +/* X/Open-compliant source */ +/* #undef _XOPEN_SOURCE */ + +/* Location of configuration file */ +#define XCONFIGFILE "xorg.conf" + +/* Name of X server */ +#define __XSERVERNAME__ "Xorg" + +/* Building vgahw module */ +#undef WITH_VGAHW + +/* System is BSD-like */ +#undef CSRG_BASED + +/* System has PCVT console */ +#undef PCVT_SUPPORT + +/* System has syscons console */ +#undef SYSCONS_SUPPORT + +/* System has wscons console */ +#undef WSCONS_SUPPORT + +/* BSD console support (xf86Info.consType machinery + console_*.c backends) */ +#undef CONFIG_BSD_CONSOLE + +/* Loadable XFree86 server awesomeness */ +#define XFree86LOADER + +/* Use libpciaccess */ +#define XSERVER_LIBPCIACCESS 1 + +/* Have the pci_device_is_boot_display function */ +#define HAVE_PCI_DEVICE_IS_BOOT_DISPLAY 1 + +/* X Access Control Extension */ +#define XACE 1 + +/* Have X server platform bus support */ +#define XSERVER_PLATFORM_BUS 1 + +#ifdef _LP64 +#define _XSERVER64 1 +#endif + +/* Have support for X shared memory fence library (xshmfence) */ +#define HAVE_XSHMFENCE 1 + +/* Use XTrans FD passing support */ +#define XTRANS_SEND_FDS 1 + +/* Ask fontsproto to make font path element names const */ +#define FONT_PATH_ELEMENT_NAME_CONST 1 + +/* byte order */ +#define X_BYTE_ORDER X_LITTLE_ENDIAN + +/* maximum number of clients */ +#define MAXCLIENTS 2048 + +/* announce server API features */ +#define XORG_API_DIX_SCREEN_HOOK_WINDOW_DESTROY 1 +#define XORG_API_DIX_SCREEN_HOOK_WINDOW_POSITION 1 +#define XORG_API_DIX_SCREEN_HOOK_CLOSE 1 +#define XORG_API_DIX_SCREEN_HOOK_PIXMAP_DESTROY 1 + +/* needed for os.h to prevent redefinition of timingsafe_memcmp in drivers */ +#undef HAVE_TIMINGSAFE_MEMCMP + +/* Xserver has xf86ParseEDID() et al (since 25.2) */ +#define XLIBRE_API_EDID_PARSE_v1 1 + +#endif /* _XORG_SERVER_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xlibre_membarrier.h b/prebuilt/xlibre/usr/include/xorg/xlibre_membarrier.h new file mode 100644 index 0000000..c116b68 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xlibre_membarrier.h @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: X11 OR MIT OR AGPL-3.0-or-later + * + * @brief platform/architecture specific memory barrier functions + * + * Copyright © 2026 Enrico Weigelt, metux IT consult + */ +#ifndef __XLIBRE_SDK_MEMBARRIER_H +#define __XLIBRE_SDK_MEMBARRIER_H + +__attribute__((always_inline)) static inline void xlibre_mem_barrier_read(void) +{ +#ifdef __i386__ +# ifdef __SSE2__ + __asm__ __volatile__ ("mfence" : : : "memory"); +# else + __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory"); +# endif +#elif defined __alpha__ + __asm__ __volatile__ ("mb" : : : "memory"); +#elif defined __amd64__ + __asm__ __volatile__ ("mfence" : : : "memory"); +#elif defined __ia64__ + __asm__ __volatile__ ("mf" : : : "memory"); +#elif defined __mips__ + __asm__ __volatile__( + ".set push\n\t" + ".set noreorder\n\t" + ".set mips2\n\t" + "sync\n\t" + ".set pop" + : /* no output */ + : /* no input */ + : "memory"); +#elif defined __powerpc__ +# if defined(__powerpc64__) || !defined(__has_builtin) || !__has_builtin(__builtin_ppc_eieio) + __asm__ __volatile__ ("eieio" : : : "memory"); +# else + __builtin_ppc_eieio(); +# endif +#elif defined __sparc__ + /* NOP */ +#endif +} + +__attribute__((always_inline)) static inline void xlibre_mem_barrier_write(void) +{ +#ifdef __i386__ +#ifdef __SSE__ + __asm__ __volatile__ ("sfence" : : : "memory"); +#else + __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory"); +#endif +#elif defined __alpha__ + __asm__ __volatile__ ("wmb" : : : "memory"); +#elif defined __amd64__ + __asm__ __volatile__ ("sfence" : : : "memory"); +#elif defined __ia64__ + __asm__ __volatile__ ("mf" : : : "memory"); +#elif defined __mips__ + xlibre_mem_barrier_read(); +#elif defined __powerpc__ +# if defined(__powerpc64__) || !defined(__has_builtin) || !__has_builtin(__builtin_ppc_eieio) + __asm__ __volatile__ ("eieio" : : : "memory"); +# else + __builtin_ppc_eieio(); +# endif +#elif defined __sparc__ + /* NOP */ +#endif +} + +/* + * @deprecated just backwards compat with older drivers - will be removed in ABI-26 + */ +__attribute__((always_inline)) static inline void mem_barrier(void) { + xlibre_mem_barrier_read(); +} + +/* + * @deprecated just backwards compat with older drivers - will be removed in ABI-26 + */ +__attribute__((always_inline)) static inline void write_mem_barrier(void) { + xlibre_mem_barrier_write(); +} + +#endif /* __XLIBRE_SDK_MEMBARRIER_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xlibre_ptrtypes.h b/prebuilt/xlibre/usr/include/xorg/xlibre_ptrtypes.h new file mode 100644 index 0000000..640f2fd --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xlibre_ptrtypes.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: X11 OR MIT OR AGPL-3.0-or-later + * + * Copyright © 2024 Enrico Weigelt, metux IT consult + * + * @brief + * This header holds forward definitions for pointer types used in many places. + * Helpful for uncluttering the includes a bit, so we have less complex dependencies. + * + * External drivers rarely have a reason for directly including it. + */ +#ifndef _XLIBRE_SDK_PTRTYPES_H +#define _XLIBRE_SDK_PTRTYPES_H + +struct _Client; +#ifndef _XTYPEDEF_CLIENTPTR +typedef struct _Client *ClientPtr; +# define _XTYPEDEF_CLIENTPTR +#endif +typedef struct _Client ClientRec; + +struct _ClientId; +typedef struct _ClientId *ClientIdPtr; + +struct _Window; +typedef struct _Window *WindowPtr; +typedef struct _Window WindowRec; + +struct _ScrnInfoRec; +typedef struct _ScrnInfoRec *ScrnInfoPtr; +typedef struct _ScrnInfoRec ScrnInfoRec; + +struct _DeviceIntRec; +typedef struct _DeviceIntRec *DeviceIntPtr; + +#endif /* _XLIBRE_SDK_PTRTYPES_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xorg-server.h b/prebuilt/xlibre/usr/include/xorg/xorg-server.h new file mode 100644 index 0000000..28fb7b9 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xorg-server.h @@ -0,0 +1,218 @@ +/* xorg-server.h.in -*- c -*- + * + * This file is the template file for the xorg-server.h file which gets + * installed as part of the SDK. The #defines in this file overlap + * with those from config.h, but only for those options that we want + * to export to external modules. Boilerplate autotool #defines such + * as HAVE_STUFF and PACKAGE_NAME is kept in config.h + * + * It is still possible to update config.h.in using autoheader, since + * autoheader only creates a .h.in file for the first + * AM_CONFIG_HEADER() line, and thus does not overwrite this file. + * + * However, it should be kept in sync with this file. + */ + +#ifndef _XORG_SERVER_H_ +#define _XORG_SERVER_H_ + +#ifdef HAVE_XORG_CONFIG_H +#error Include xorg-config.h when building the X server +#endif + +/* Default font path */ +#define COMPILEDDEFAULTFONTPATH "/usr/share/fonts/misc,/usr/share/fonts/TTF,/usr/share/fonts/OTF" + +/* Support Composite Extension */ +#define COMPOSITE 1 + +/* Build DPMS extension */ +#define DPMSExtension 1 + +/* Build DRI3 extension */ +#define DRI3 1 + +/* Build GLX extension */ +#undef GLXEXT + +/* Support XDM-AUTH*-1 */ +#define HASXDMAUTH 1 + +/* Add a padding for legacy nvidia drivers that support old ABI */ +#undef CONFIG_LEGACY_NVIDIA_PADDING + +/* Define to 1 if you have the `reallocarray' function. */ +#define HAVE_REALLOCARRAY 1 + +/* Define to 1 if you have the `strlcat' function. */ +#define HAVE_STRLCAT 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the `strndup' function. */ +#define HAVE_STRNDUP 1 + +/* Support IPv6 for TCP connections */ +#define IPv6 1 + +/* Support MIT-SHM Extension */ +#define MITSHM 1 +#define CONFIG_MITSHM 1 + +/* Internal define for Xinerama */ +#define PANORAMIX 1 +#define XINERAMA 1 + +/* Support Present extension */ +#define PRESENT 1 + +/* Support RANDR extension */ +#define RANDR 1 + +/* Support RENDER extension */ +#define RENDER 1 + +/* Support X resource extension */ +#define RES 1 + +/* Support MIT-SCREEN-SAVER extension */ +#define SCREENSAVER 1 + +/* Support SHAPE extension */ +#define SHAPE 1 + +/* Define to 1 on systems derived from System V Release 4 */ +#undef SVR4 + +/* Support UNIX socket connections */ +#define UNIXCONN 1 + +/* Support XCMisc extension */ +#define XCMISC 1 + +/* Support Xdmcp */ +#define XDMCP 1 + +/* Support XFree86 Video Mode extension */ +#define XF86VIDMODE 1 + +/* Build XDGA support */ +#undef XFreeXDGA + +/* Support Xinerama extension */ +#define XINERAMA 1 + +/* Support X Input extension */ +#define XINPUT 1 + +/* XKB default rules */ +#define XKB_DFLT_RULES "evdev" + +/* Build DRI extension */ +#undef XF86DRI + +/* Build DRI2 extension */ +#define DRI2 1 + +/* Build Xorg server */ +#define XORGSERVER 1 + +/* Current Xorg version */ +#define XORG_VERSION_CURRENT 12502000 + +/* Build Xv Extension */ +#undef XvExtension + +/* Build XvMC Extension */ +#undef XvMCExtension + +/* Support XSync extension */ +#define XSYNC 1 + +/* Support XTest extension */ +#define XTEST 1 + +/* Support Xv Extension */ +#undef XV + +/* BSD-compliant source */ +/* #undef _BSD_SOURCE */ + +/* POSIX-compliant source */ +/* #undef _POSIX_SOURCE */ + +/* X/Open-compliant source */ +/* #undef _XOPEN_SOURCE */ + +/* Location of configuration file */ +#define XCONFIGFILE "xorg.conf" + +/* Name of X server */ +#define __XSERVERNAME__ "Xorg" + +/* Building vgahw module */ +#undef WITH_VGAHW + +/* System is BSD-like */ +#undef CSRG_BASED + +/* System has PCVT console */ +#undef PCVT_SUPPORT + +/* System has syscons console */ +#undef SYSCONS_SUPPORT + +/* System has wscons console */ +#undef WSCONS_SUPPORT + +/* BSD console support (xf86Info.consType machinery + console_*.c backends) */ +#undef CONFIG_BSD_CONSOLE + +/* Loadable XFree86 server awesomeness */ +#define XFree86LOADER + +/* Use libpciaccess */ +#define XSERVER_LIBPCIACCESS 1 + +/* Have the pci_device_is_boot_display function */ +#define HAVE_PCI_DEVICE_IS_BOOT_DISPLAY 1 + +/* X Access Control Extension */ +#define XACE 1 + +/* Have X server platform bus support */ +#define XSERVER_PLATFORM_BUS 1 + +#ifdef _LP64 +#define _XSERVER64 1 +#endif + +/* Have support for X shared memory fence library (xshmfence) */ +#define HAVE_XSHMFENCE 1 + +/* Use XTrans FD passing support */ +#define XTRANS_SEND_FDS 1 + +/* Ask fontsproto to make font path element names const */ +#define FONT_PATH_ELEMENT_NAME_CONST 1 + +/* byte order */ +#define X_BYTE_ORDER X_LITTLE_ENDIAN + +/* maximum number of clients */ +#define MAXCLIENTS 2048 + +/* announce server API features */ +#define XORG_API_DIX_SCREEN_HOOK_WINDOW_DESTROY 1 +#define XORG_API_DIX_SCREEN_HOOK_WINDOW_POSITION 1 +#define XORG_API_DIX_SCREEN_HOOK_CLOSE 1 +#define XORG_API_DIX_SCREEN_HOOK_PIXMAP_DESTROY 1 + +/* needed for os.h to prevent redefinition of timingsafe_memcmp in drivers */ +#undef HAVE_TIMINGSAFE_MEMCMP + +/* Xserver has xf86ParseEDID() et al (since 25.2) */ +#define XLIBRE_API_EDID_PARSE_v1 1 + +#endif /* _XORG_SERVER_H_ */ diff --git a/prebuilt/xlibre/usr/include/xorg/xorgVersion.h b/prebuilt/xlibre/usr/include/xorg/xorgVersion.h new file mode 100644 index 0000000..c8e5176 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xorgVersion.h @@ -0,0 +1,49 @@ + +/* + * Copyright (c) 2004, X.Org Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef XORG_VERSION_H +#define XORG_VERSION_H + +#ifndef XORG_VERSION_CURRENT +#error +#endif + +#define XORG_VERSION_NUMERIC(major,minor,patch,snap,dummy) \ + (((major) * 10000000) + ((minor) * 100000) + ((patch) * 1000) + (snap)) + +#define XORG_GET_MAJOR_VERSION(vers) ((vers) / 10000000) +#define XORG_GET_MINOR_VERSION(vers) (((vers) % 10000000) / 100000) +#define XORG_GET_PATCH_VERSION(vers) (((vers) % 100000) / 1000) +#define XORG_GET_SNAP_VERSION(vers) ((vers) % 1000) + +#define XORG_VERSION_MAJOR XORG_GET_MAJOR_VERSION(XORG_VERSION_CURRENT) +#define XORG_VERSION_MINOR XORG_GET_MINOR_VERSION(XORG_VERSION_CURRENT) +#define XORG_VERSION_PATCH XORG_GET_PATCH_VERSION(XORG_VERSION_CURRENT) +#define XORG_VERSION_SNAP XORG_GET_SNAP_VERSION(XORG_VERSION_CURRENT) + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/xserver-properties.h b/prebuilt/xlibre/usr/include/xorg/xserver-properties.h new file mode 100644 index 0000000..5cf43ec --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xserver-properties.h @@ -0,0 +1,205 @@ +/* + * Copyright 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software") + * to deal in the software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * them Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* Properties managed by the server. */ + +#ifndef _XSERVER_PROPERTIES_H_ +#define _XSERVER_PROPERTIES_H_ + +/* Type for a 4 byte float. Storage format IEEE 754 in client's default + * byte-ordering. */ +#define XATOM_FLOAT "FLOAT" + +/* STRING. Seat name of this display */ +#define SEAT_ATOM_NAME "Xorg_Seat" + +/* BOOL. 0 - device disabled, 1 - device enabled */ +#define XI_PROP_ENABLED "Device Enabled" +/* BOOL. If present, device is a virtual XTEST device */ +#define XI_PROP_XTEST_DEVICE "XTEST Device" + +/* CARD32, 2 values, vendor, product. + * This property is set by the driver and may not be available for some + * drivers. Read-Only */ +#define XI_PROP_PRODUCT_ID "Device Product ID" + +/* Coordinate transformation matrix for absolute input devices + * FLOAT, 9 values in row-major order, coordinates in 0..1 range: + * [c0 c1 c2] [x] + * [c3 c4 c5] * [y] + * [c6 c7 c8] [1] */ +#define XI_PROP_TRANSFORM "Coordinate Transformation Matrix" + +/* STRING. Device node path of device */ +#define XI_PROP_DEVICE_NODE "Device Node" + +/* Pointer acceleration properties */ +/* INTEGER of any format */ +#define ACCEL_PROP_PROFILE_NUMBER "Device Accel Profile" +/* FLOAT, format 32 */ +#define ACCEL_PROP_CONSTANT_DECELERATION "Device Accel Constant Deceleration" +/* FLOAT, format 32 */ +#define ACCEL_PROP_ADAPTIVE_DECELERATION "Device Accel Adaptive Deceleration" +/* FLOAT, format 32 */ +#define ACCEL_PROP_VELOCITY_SCALING "Device Accel Velocity Scaling" + +/* Axis labels */ +#define AXIS_LABEL_PROP "Axis Labels" + +#define AXIS_LABEL_PROP_REL_X "Rel X" +#define AXIS_LABEL_PROP_REL_Y "Rel Y" +#define AXIS_LABEL_PROP_REL_Z "Rel Z" +#define AXIS_LABEL_PROP_REL_RX "Rel Rotary X" +#define AXIS_LABEL_PROP_REL_RY "Rel Rotary Y" +#define AXIS_LABEL_PROP_REL_RZ "Rel Rotary Z" +#define AXIS_LABEL_PROP_REL_HWHEEL "Rel Horiz Wheel" +#define AXIS_LABEL_PROP_REL_DIAL "Rel Dial" +#define AXIS_LABEL_PROP_REL_WHEEL "Rel Vert Wheel" +#define AXIS_LABEL_PROP_REL_MISC "Rel Misc" +#define AXIS_LABEL_PROP_REL_VSCROLL "Rel Vert Scroll" +#define AXIS_LABEL_PROP_REL_HSCROLL "Rel Horiz Scroll" + +/* + * Absolute axes + */ + +#define AXIS_LABEL_PROP_ABS_X "Abs X" +#define AXIS_LABEL_PROP_ABS_Y "Abs Y" +#define AXIS_LABEL_PROP_ABS_Z "Abs Z" +#define AXIS_LABEL_PROP_ABS_RX "Abs Rotary X" +#define AXIS_LABEL_PROP_ABS_RY "Abs Rotary Y" +#define AXIS_LABEL_PROP_ABS_RZ "Abs Rotary Z" +#define AXIS_LABEL_PROP_ABS_THROTTLE "Abs Throttle" +#define AXIS_LABEL_PROP_ABS_RUDDER "Abs Rudder" +#define AXIS_LABEL_PROP_ABS_WHEEL "Abs Wheel" +#define AXIS_LABEL_PROP_ABS_GAS "Abs Gas" +#define AXIS_LABEL_PROP_ABS_BRAKE "Abs Brake" +#define AXIS_LABEL_PROP_ABS_HAT0X "Abs Hat 0 X" +#define AXIS_LABEL_PROP_ABS_HAT0Y "Abs Hat 0 Y" +#define AXIS_LABEL_PROP_ABS_HAT1X "Abs Hat 1 X" +#define AXIS_LABEL_PROP_ABS_HAT1Y "Abs Hat 1 Y" +#define AXIS_LABEL_PROP_ABS_HAT2X "Abs Hat 2 X" +#define AXIS_LABEL_PROP_ABS_HAT2Y "Abs Hat 2 Y" +#define AXIS_LABEL_PROP_ABS_HAT3X "Abs Hat 3 X" +#define AXIS_LABEL_PROP_ABS_HAT3Y "Abs Hat 3 Y" +#define AXIS_LABEL_PROP_ABS_PRESSURE "Abs Pressure" +#define AXIS_LABEL_PROP_ABS_DISTANCE "Abs Distance" +#define AXIS_LABEL_PROP_ABS_TILT_X "Abs Tilt X" +#define AXIS_LABEL_PROP_ABS_TILT_Y "Abs Tilt Y" +#define AXIS_LABEL_PROP_ABS_TOOL_WIDTH "Abs Tool Width" +#define AXIS_LABEL_PROP_ABS_VOLUME "Abs Volume" +#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR "Abs MT Touch Major" +#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR "Abs MT Touch Minor" +#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR "Abs MT Width Major" +#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR "Abs MT Width Minor" +#define AXIS_LABEL_PROP_ABS_MT_ORIENTATION "Abs MT Orientation" +#define AXIS_LABEL_PROP_ABS_MT_POSITION_X "Abs MT Position X" +#define AXIS_LABEL_PROP_ABS_MT_POSITION_Y "Abs MT Position Y" +#define AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE "Abs MT Tool Type" +#define AXIS_LABEL_PROP_ABS_MT_BLOB_ID "Abs MT Blob ID" +#define AXIS_LABEL_PROP_ABS_MT_TRACKING_ID "Abs MT Tracking ID" +#define AXIS_LABEL_PROP_ABS_MT_PRESSURE "Abs MT Pressure" +#define AXIS_LABEL_PROP_ABS_MT_DISTANCE "Abs MT Distance" +#define AXIS_LABEL_PROP_ABS_MT_TOOL_X "Abs MT Tool X" +#define AXIS_LABEL_PROP_ABS_MT_TOOL_Y "Abs MT Tool Y" +#define AXIS_LABEL_PROP_ABS_MISC "Abs Misc" + +/* Button names */ +#define BTN_LABEL_PROP "Button Labels" + +/* Default label */ +#define BTN_LABEL_PROP_BTN_UNKNOWN "Button Unknown" +/* Wheel buttons */ +#define BTN_LABEL_PROP_BTN_WHEEL_UP "Button Wheel Up" +#define BTN_LABEL_PROP_BTN_WHEEL_DOWN "Button Wheel Down" +#define BTN_LABEL_PROP_BTN_HWHEEL_LEFT "Button Horiz Wheel Left" +#define BTN_LABEL_PROP_BTN_HWHEEL_RIGHT "Button Horiz Wheel Right" + +/* The following are from linux/input.h */ +#define BTN_LABEL_PROP_BTN_0 "Button 0" +#define BTN_LABEL_PROP_BTN_1 "Button 1" +#define BTN_LABEL_PROP_BTN_2 "Button 2" +#define BTN_LABEL_PROP_BTN_3 "Button 3" +#define BTN_LABEL_PROP_BTN_4 "Button 4" +#define BTN_LABEL_PROP_BTN_5 "Button 5" +#define BTN_LABEL_PROP_BTN_6 "Button 6" +#define BTN_LABEL_PROP_BTN_7 "Button 7" +#define BTN_LABEL_PROP_BTN_8 "Button 8" +#define BTN_LABEL_PROP_BTN_9 "Button 9" + +#define BTN_LABEL_PROP_BTN_LEFT "Button Left" +#define BTN_LABEL_PROP_BTN_RIGHT "Button Right" +#define BTN_LABEL_PROP_BTN_MIDDLE "Button Middle" +#define BTN_LABEL_PROP_BTN_SIDE "Button Side" +#define BTN_LABEL_PROP_BTN_EXTRA "Button Extra" +#define BTN_LABEL_PROP_BTN_FORWARD "Button Forward" +#define BTN_LABEL_PROP_BTN_BACK "Button Back" +#define BTN_LABEL_PROP_BTN_TASK "Button Task" + +#define BTN_LABEL_PROP_BTN_TRIGGER "Button Trigger" +#define BTN_LABEL_PROP_BTN_THUMB "Button Thumb" +#define BTN_LABEL_PROP_BTN_THUMB2 "Button Thumb2" +#define BTN_LABEL_PROP_BTN_TOP "Button Top" +#define BTN_LABEL_PROP_BTN_TOP2 "Button Top2" +#define BTN_LABEL_PROP_BTN_PINKIE "Button Pinkie" +#define BTN_LABEL_PROP_BTN_BASE "Button Base" +#define BTN_LABEL_PROP_BTN_BASE2 "Button Base2" +#define BTN_LABEL_PROP_BTN_BASE3 "Button Base3" +#define BTN_LABEL_PROP_BTN_BASE4 "Button Base4" +#define BTN_LABEL_PROP_BTN_BASE5 "Button Base5" +#define BTN_LABEL_PROP_BTN_BASE6 "Button Base6" +#define BTN_LABEL_PROP_BTN_DEAD "Button Dead" + +#define BTN_LABEL_PROP_BTN_A "Button A" +#define BTN_LABEL_PROP_BTN_B "Button B" +#define BTN_LABEL_PROP_BTN_C "Button C" +#define BTN_LABEL_PROP_BTN_X "Button X" +#define BTN_LABEL_PROP_BTN_Y "Button Y" +#define BTN_LABEL_PROP_BTN_Z "Button Z" +#define BTN_LABEL_PROP_BTN_TL "Button T Left" +#define BTN_LABEL_PROP_BTN_TR "Button T Right" +#define BTN_LABEL_PROP_BTN_TL2 "Button T Left2" +#define BTN_LABEL_PROP_BTN_TR2 "Button T Right2" +#define BTN_LABEL_PROP_BTN_SELECT "Button Select" +#define BTN_LABEL_PROP_BTN_START "Button Start" +#define BTN_LABEL_PROP_BTN_MODE "Button Mode" +#define BTN_LABEL_PROP_BTN_THUMBL "Button Thumb Left" +#define BTN_LABEL_PROP_BTN_THUMBR "Button Thumb Right" + +#define BTN_LABEL_PROP_BTN_TOOL_PEN "Button Tool Pen" +#define BTN_LABEL_PROP_BTN_TOOL_RUBBER "Button Tool Rubber" +#define BTN_LABEL_PROP_BTN_TOOL_BRUSH "Button Tool Brush" +#define BTN_LABEL_PROP_BTN_TOOL_PENCIL "Button Tool Pencil" +#define BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH "Button Tool Airbrush" +#define BTN_LABEL_PROP_BTN_TOOL_FINGER "Button Tool Finger" +#define BTN_LABEL_PROP_BTN_TOOL_MOUSE "Button Tool Mouse" +#define BTN_LABEL_PROP_BTN_TOOL_LENS "Button Tool Lens" +#define BTN_LABEL_PROP_BTN_TOUCH "Button Touch" +#define BTN_LABEL_PROP_BTN_STYLUS "Button Stylus" +#define BTN_LABEL_PROP_BTN_STYLUS2 "Button Stylus2" +#define BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP "Button Tool Doubletap" +#define BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP "Button Tool Tripletap" + +#define BTN_LABEL_PROP_BTN_GEAR_DOWN "Button Gear down" +#define BTN_LABEL_PROP_BTN_GEAR_UP "Button Gear up" + +#endif diff --git a/prebuilt/xlibre/usr/include/xorg/xvdix.h b/prebuilt/xlibre/usr/include/xorg/xvdix.h new file mode 100644 index 0000000..853c65e --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xvdix.h @@ -0,0 +1,185 @@ +/*********************************************************** +Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, +and the Massachusetts Institute of Technology, Cambridge, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Digital or MIT not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef XVDIX_H +#define XVDIX_H +/* +** File: +** +** xvdix.h --- Xv device independent header file +** +** Author: +** +** David Carver (Digital Workstation Engineering/Project Athena) +** +** Revisions: +** +** 29.08.91 Carver +** - removed UnrealizeWindow wrapper unrealizing windows no longer +** preempts video +** +** 11.06.91 Carver +** - changed SetPortControl to SetPortAttribute +** - changed GetPortControl to GetPortAttribute +** - changed QueryBestSize +** +** 15.05.91 Carver +** - version 2.0 upgrade +** +** 24.01.91 Carver +** - version 1.4 upgrade +** +*/ + +#include "scrnintstr.h" +#include + +typedef struct { + int numerator; + int denominator; +} XvRationalRec, *XvRationalPtr; + +typedef struct { + char depth; + unsigned long visual; +} XvFormatRec, *XvFormatPtr; + +typedef struct { + unsigned long id; + ClientPtr client; +} XvGrabRec, *XvGrabPtr; + +typedef struct _XvPortNotifyRec *XvPortNotifyPtr; + +typedef struct { + int id; + ScreenPtr pScreen; + char *name; + unsigned short width, height; + XvRationalRec rate; +} XvEncodingRec, *XvEncodingPtr; + +typedef struct _XvAttributeRec { + int flags; + int min_value; + int max_value; + char *name; +} XvAttributeRec, *XvAttributePtr; + +typedef struct { + int id; + int type; + int byte_order; + char guid[16]; + int bits_per_pixel; + int format; + int num_planes; + + /* for RGB formats only */ + int depth; + unsigned int red_mask; + unsigned int green_mask; + unsigned int blue_mask; + + /* for YUV formats only */ + unsigned int y_sample_bits; + unsigned int u_sample_bits; + unsigned int v_sample_bits; + unsigned int horz_y_period; + unsigned int horz_u_period; + unsigned int horz_v_period; + unsigned int vert_y_period; + unsigned int vert_u_period; + unsigned int vert_v_period; + char component_order[32]; + int scanline_order; +} XvImageRec, *XvImagePtr; + +typedef struct { + unsigned long base_id; + unsigned char type; + char *name; + int nEncodings; + XvEncodingPtr pEncodings; + int nFormats; + XvFormatPtr pFormats; + int nAttributes; + XvAttributePtr pAttributes; + int nImages; + XvImagePtr pImages; + int nPorts; + struct _XvPortRec *pPorts; + ScreenPtr pScreen; + int (*ddPutVideo) (DrawablePtr, struct _XvPortRec *, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + int (*ddPutStill) (DrawablePtr, struct _XvPortRec *, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + int (*ddGetVideo) (DrawablePtr, struct _XvPortRec *, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + int (*ddGetStill) (DrawablePtr, struct _XvPortRec *, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + int (*ddStopVideo) (struct _XvPortRec *, DrawablePtr); + int (*ddSetPortAttribute) (struct _XvPortRec *, Atom, INT32); + int (*ddGetPortAttribute) (struct _XvPortRec *, Atom, INT32 *); + int (*ddQueryBestSize) (struct _XvPortRec *, CARD8, + CARD16, CARD16, CARD16, CARD16, + unsigned int *, unsigned int *); + int (*ddPutImage) (DrawablePtr, struct _XvPortRec *, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16, + XvImagePtr, unsigned char *, Bool, CARD16, CARD16); + int (*ddQueryImageAttributes) (struct _XvPortRec *, XvImagePtr, + CARD16 *, CARD16 *, int *, int *); + DevUnion devPriv; +} XvAdaptorRec, *XvAdaptorPtr; + +typedef struct _XvPortRec { + unsigned long id; + XvAdaptorPtr pAdaptor; + XvPortNotifyPtr pNotify; + DrawablePtr pDraw; + ClientPtr client; + XvGrabRec grab; + TimeStamp time; + DevUnion devPriv; +} XvPortRec, *XvPortPtr; + +typedef struct { + int version, revision; + int nAdaptors; + XvAdaptorPtr pAdaptors; + void *_dummy1; // required in place of a removed field for ABI compatibility + void *_dummy2; // required in place of a removed field for ABI compatibility + void *_dummy3; // required in place of a removed field for ABI compatibility +} XvScreenRec, *XvScreenPtr; + +extern _X_EXPORT int XvScreenInit(ScreenPtr); +extern _X_EXPORT DevPrivateKey XvGetScreenKey(void); +extern _X_EXPORT unsigned long XvGetRTPort(void); + +#endif /* XVDIX_H */ diff --git a/prebuilt/xlibre/usr/include/xorg/xvmcext.h b/prebuilt/xlibre/usr/include/xorg/xvmcext.h new file mode 100644 index 0000000..acfbee7 --- /dev/null +++ b/prebuilt/xlibre/usr/include/xorg/xvmcext.h @@ -0,0 +1,94 @@ + +#ifndef _XVMC_H +#define _XVMC_H +#include +#include "xvdix.h" + +typedef struct { + int num_xvimages; + int *xvimage_ids; +} XvMCImageIDList; + +typedef struct { + int surface_type_id; + int chroma_format; + int color_description; + unsigned short max_width; + unsigned short max_height; + unsigned short subpicture_max_width; + unsigned short subpicture_max_height; + int mc_type; + int flags; + XvMCImageIDList *compatible_subpictures; +} XvMCSurfaceInfoRec, *XvMCSurfaceInfoPtr; + +typedef struct { + XID context_id; + ScreenPtr pScreen; + int adapt_num; + int surface_type_id; + unsigned short width; + unsigned short height; + CARD32 flags; + int refcnt; + void *port_priv; + void *driver_priv; +} XvMCContextRec, *XvMCContextPtr; + +typedef struct { + XID surface_id; + int surface_type_id; + XvMCContextPtr context; + void *driver_priv; +} XvMCSurfaceRec, *XvMCSurfacePtr; + +typedef struct { + XID subpicture_id; + int xvimage_id; + unsigned short width; + unsigned short height; + int num_palette_entries; + int entry_bytes; + char component_order[4]; + XvMCContextPtr context; + void *driver_priv; +} XvMCSubpictureRec, *XvMCSubpicturePtr; + +typedef int (*XvMCCreateContextProcPtr) (XvPortPtr port, + XvMCContextPtr context, + int *num_priv, CARD32 **priv); + +typedef void (*XvMCDestroyContextProcPtr) (XvMCContextPtr context); + +typedef int (*XvMCCreateSurfaceProcPtr) (XvMCSurfacePtr surface, + int *num_priv, CARD32 **priv); + +typedef void (*XvMCDestroySurfaceProcPtr) (XvMCSurfacePtr surface); + +typedef int (*XvMCCreateSubpictureProcPtr) (XvMCSubpicturePtr subpicture, + int *num_priv, CARD32 **priv); + +typedef void (*XvMCDestroySubpictureProcPtr) (XvMCSubpicturePtr subpicture); + +typedef struct { + XvAdaptorPtr xv_adaptor; + int num_surfaces; + XvMCSurfaceInfoPtr *surfaces; + int num_subpictures; + XvImagePtr *subpictures; + XvMCCreateContextProcPtr CreateContext; + XvMCDestroyContextProcPtr DestroyContext; + XvMCCreateSurfaceProcPtr CreateSurface; + XvMCDestroySurfaceProcPtr DestroySurface; + XvMCCreateSubpictureProcPtr CreateSubpicture; + XvMCDestroySubpictureProcPtr DestroySubpicture; +} XvMCAdaptorRec, *XvMCAdaptorPtr; + +extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen, + int num, XvMCAdaptorPtr adapt); + +extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name, + const char *busID, int major, int minor, + int patchLevel); + +#endif /* _XVMC_H */ diff --git a/prebuilt/xlibre/usr/lib/pkgconfig/xlibre-server.pc b/prebuilt/xlibre/usr/lib/pkgconfig/xlibre-server.pc new file mode 100644 index 0000000..dbe38b4 --- /dev/null +++ b/prebuilt/xlibre/usr/lib/pkgconfig/xlibre-server.pc @@ -0,0 +1,34 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +datarootdir=${prefix}/share +moduledir=${exec_prefix}/lib/xorg/modules/xlibre-25 +input_drivers_dir=${exec_prefix}/lib/xorg/modules/xlibre-25/drivers/input +video_drivers_dir=${exec_prefix}/lib/xorg/modules/xlibre-25/drivers/video +sdkdir=${prefix}/include/xorg +sysconfigdir=${datarootdir}/X11/xorg.conf.d +xserverconfigdir=${datarootdir}/X11/xorg.conf.d +driver_man_dir=/usr/share/man/man4 +driver_man_section=4 +app_man_dir=/usr/share/man/man1 +app_man_section=1 +misc_man_dir=/usr/share/man/man7 +misc_man_section=7 +file_man_dir=/usr/share/man/man5 +file_man_section=5 +server_name=Xorg +server_config=xorg.conf + +abi_ansic=1.4 +abi_videodrv=28.128.0 +abi_xinput=26.0 +abi_extension=11.0 + +Name: xlibre-server +Description: Modular XLibre X Server +URL: https://github.com/X11Libre/xserver/ +Version: 25.2.0 +Requires.private: pixman-1 >= 0.27.2 xproto >= 7.0.31 xfont2 >= 2.0 +Cflags: -I${sdkdir} -fvisibility=hidden +Libs: -L${libdir} diff --git a/prebuilt/xlibre/usr/lib/pkgconfig/xorg-libinput.pc b/prebuilt/xlibre/usr/lib/pkgconfig/xorg-libinput.pc new file mode 100644 index 0000000..a68089d --- /dev/null +++ b/prebuilt/xlibre/usr/lib/pkgconfig/xorg-libinput.pc @@ -0,0 +1,6 @@ +sdkdir=/usr/include/xorg + +Name: xorg-libinput +Description: X.Org libinput input driver. +Version: 25.0.1 +Cflags: -I${sdkdir} diff --git a/prebuilt/xlibre/usr/lib/pkgconfig/xorg-server.pc b/prebuilt/xlibre/usr/lib/pkgconfig/xorg-server.pc new file mode 100644 index 0000000..0aca4ec --- /dev/null +++ b/prebuilt/xlibre/usr/lib/pkgconfig/xorg-server.pc @@ -0,0 +1,34 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +datarootdir=${prefix}/share +moduledir=${exec_prefix}/lib/xorg/modules/xlibre-25 +input_drivers_dir=${exec_prefix}/lib/xorg/modules/xlibre-25/drivers/input +video_drivers_dir=${exec_prefix}/lib/xorg/modules/xlibre-25/drivers/video +sdkdir=${prefix}/include/xorg +sysconfigdir=${datarootdir}/X11/xorg.conf.d +xserverconfigdir=${datarootdir}/X11/xorg.conf.d +driver_man_dir=/usr/share/man/man4 +driver_man_section=4 +app_man_dir=/usr/share/man/man1 +app_man_section=1 +misc_man_dir=/usr/share/man/man7 +misc_man_section=7 +file_man_dir=/usr/share/man/man5 +file_man_section=5 +server_name=Xorg +server_config=xorg.conf + +abi_ansic=1.4 +abi_videodrv=28.128.0 +abi_xinput=26.0 +abi_extension=11.0 + +Name: xorg-server +Description: Modular XLibre X Server +URL: https://github.com/X11Libre/xserver/ +Version: 25.2.0 +Requires.private: pixman-1 >= 0.27.2 xproto >= 7.0.31 xfont2 >= 2.0 +Cflags: -I${sdkdir} -fvisibility=hidden +Libs: -L${libdir} diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/fbdev_drv.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/fbdev_drv.so new file mode 100755 index 0000000..f01954b Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/fbdev_drv.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/modesetting_drv.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/modesetting_drv.so new file mode 100755 index 0000000..bf5c65a Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/modesetting_drv.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/input/libinput_drv.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/input/libinput_drv.so new file mode 100755 index 0000000..3c0ba8d Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/input/libinput_drv.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libexa.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libexa.so new file mode 100755 index 0000000..4113689 Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libexa.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libfbdevhw.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libfbdevhw.so new file mode 100755 index 0000000..9ed3c97 Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libfbdevhw.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libshadow.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libshadow.so new file mode 100755 index 0000000..3993eb7 Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libshadow.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libshadowfb.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libshadowfb.so new file mode 100755 index 0000000..e147777 Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libshadowfb.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libwfb.so b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libwfb.so new file mode 100755 index 0000000..f5bae7e Binary files /dev/null and b/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libwfb.so differ diff --git a/prebuilt/xlibre/usr/lib/xorg/protocol.txt b/prebuilt/xlibre/usr/lib/xorg/protocol.txt new file mode 100644 index 0000000..8751f1b --- /dev/null +++ b/prebuilt/xlibre/usr/lib/xorg/protocol.txt @@ -0,0 +1,885 @@ +# Registry of protocol names used by X Server +# This will eventually be replaced by server-side XCB +# +# Format is Xnnn : +# R=Request, V=Event, E=Error +# +# This is a security-sensitive file, please set permissions as appropriate. +# +R000 Apple-DRI:QueryVersion +R001 Apple-DRI:QueryDirectRenderingCapable +R002 Apple-DRI:CreateSurface +R003 Apple-DRI:DestroySurface +R004 Apple-DRI:AuthConnection +V000 Apple-DRI:ObsoleteEvent1 +V001 Apple-DRI:ObsoleteEvent2 +V002 Apple-DRI:ObsoleteEvent3 +V003 Apple-DRI:SurfaceNotify +E000 Apple-DRI:ClientNotLocal +E001 Apple-DRI:OperationNotSupported +R000 Apple-WM:QueryVersion +R001 Apple-WM:FrameGetRect +R002 Apple-WM:FrameHitTest +R003 Apple-WM:FrameDraw +R004 Apple-WM:DisableUpdate +R005 Apple-WM:ReenableUpdate +R006 Apple-WM:SelectInput +R007 Apple-WM:SetWindowMenuCheck +R008 Apple-WM:SetFrontProcess +R009 Apple-WM:SetWindowLevel +R010 Apple-WM:SetCanQuit +R011 Apple-WM:SetWindowMenu +V000 Apple-WM:ControllerNotify +V001 Apple-WM:ActivationNotify +V002 Apple-WM:PasteboardNotify +E000 Apple-WM:ClientNotLocal +E001 Apple-WM:OperationNotSupported +R000 BIG-REQUESTS:Enable +R000 Composite:CompositeQueryVersion +R001 Composite:CompositeRedirectWindow +R002 Composite:CompositeRedirectSubwindows +R003 Composite:CompositeUnredirectWindow +R004 Composite:CompositeUnredirectSubwindows +R005 Composite:CompositeCreateRegionFromBorderClip +R006 Composite:CompositeNameWindowPixmap +R007 Composite:CompositeGetOverlayWindow +R008 Composite:CompositeReleaseOverlayWindow +R000 DAMAGE:QueryVersion +R001 DAMAGE:Create +R002 DAMAGE:Destroy +R003 DAMAGE:Subtract +R004 DAMAGE:Add +V000 DAMAGE:Notify +E000 DAMAGE:BadDamage +R000 DOUBLE-BUFFER:GetVersion +R001 DOUBLE-BUFFER:AllocateBackBufferName +R002 DOUBLE-BUFFER:DeallocateBackBufferName +R003 DOUBLE-BUFFER:SwapBuffers +R004 DOUBLE-BUFFER:BeginIdiom +R005 DOUBLE-BUFFER:EndIdiom +R006 DOUBLE-BUFFER:GetVisualInfo +R007 DOUBLE-BUFFER:GetBackBufferAttributes +E000 DOUBLE-BUFFER:BadBuffer +R000 DPMS:GetVersion +R001 DPMS:Capable +R002 DPMS:GetTimeouts +R003 DPMS:SetTimeouts +R004 DPMS:Enable +R005 DPMS:Disable +R006 DPMS:ForceLevel +R007 DPMS:Info +R000 DRI2:QueryVersion +R001 DRI2:Connect +R002 DRI2:Authenticate +R003 DRI2:CreateDrawable +R004 DRI2:DestroyDrawable +R005 DRI2:GetBuffers +R006 DRI2:CopyRegion +R007 DRI2:GetBuffersWithFormat +R008 DRI2:SwapBuffers +R009 DRI2:GetMSC +R010 DRI2:WaitMSC +R011 DRI2:WaitSBC +R012 DRI2:SwapInterval +V000 DRI2:BufferSwapComplete +V001 DRI2:InvalidateBuffers +R000 DRI3:QueryVersion +R001 DRI3:Open +R002 DRI3:PixmapFromBuffer +R003 DRI3:BufferFromPixmap +R004 DRI3:FenceFromFD +R005 DRI3:FDFromFence +R000 Extended-Visual-Information:QueryVersion +R001 Extended-Visual-Information:GetVisualInfo +R000 FontCache:QueryVersion +R001 FontCache:GetCacheSettings +R002 FontCache:ChangeCacheSettings +R003 FontCache:GetCacheStatistics +E000 FontCache:BadProtocol +E001 FontCache:CannotAllocMemory +R001 GLX: +R002 GLX:Large +R003 GLX:CreateContext +R004 GLX:DestroyContext +R005 GLX:MakeCurrent +R006 GLX:IsDirect +R007 GLX:QueryVersion +R008 GLX:WaitGL +R009 GLX:WaitX +R010 GLX:CopyContext +R011 GLX:SwapBuffers +R012 GLX:UseXFont +R013 GLX:CreateGLXPixmap +R014 GLX:GetVisualConfigs +R015 GLX:DestroyGLXPixmap +R016 GLX:VendorPrivate +R017 GLX:VendorPrivateWithReply +R018 GLX:QueryExtensionsString +R019 GLX:QueryServerString +R020 GLX:ClientInfo +R021 GLX:GetFBConfigs +R022 GLX:CreatePixmap +R023 GLX:DestroyPixmap +R024 GLX:CreateNewContext +R025 GLX:QueryContext +R026 GLX:MakeContextCurrent +R027 GLX:CreatePbuffer +R028 GLX:DestroyPbuffer +R029 GLX:GetDrawableAttributes +R030 GLX:ChangeDrawableAttributes +R031 GLX:CreateWindow +R032 GLX:DeleteWindow +R033 GLX:SetClientInfoARB +R034 GLX:CreateContextAttribsARB +R035 GLX:SetClientInfo2ARB +R101 GLX:NewList +R102 GLX:EndList +R103 GLX:DeleteLists +R104 GLX:GenLists +R105 GLX:FeedbackBuffer +R106 GLX:SelectBuffer +R107 GLX:Mode +R108 GLX:Finish +R109 GLX:PixelStoref +R110 GLX:PixelStorei +R111 GLX:ReadPixels +R112 GLX:GetBooleanv +R113 GLX:GetClipPlane +R114 GLX:GetDoublev +R115 GLX:GetError +R116 GLX:GetFloatv +R117 GLX:GetIntegerv +R118 GLX:GetLightfv +R119 GLX:GetLightiv +R120 GLX:GetMapdv +R121 GLX:GetMapfv +R122 GLX:GetMapiv +R123 GLX:GetMaterialfv +R124 GLX:GetMaterialiv +R125 GLX:GetPixelfv +R126 GLX:GetPixelMapuiv +R127 GLX:GetPixelMapusv +R128 GLX:GetPolygonStipple +R129 GLX:GetString +R130 GLX:GetTexEnvfv +R131 GLX:GetTexEnviv +R132 GLX:GetTexGendv +R133 GLX:GetTexGenfv +R134 GLX:GetTexGeniv +R135 GLX:GetTexImage +R136 GLX:GetTexParameterfv +R137 GLX:GetTexParameteriv +R138 GLX:GetTexLevelParameterfv +R139 GLX:GetTexLevelParameteriv +R140 GLX:IsEnabled +R141 GLX:IsList +R142 GLX:Flush +R143 GLX:AreTexturesResident +R144 GLX:DeleteTextures +R145 GLX:GenTextures +R146 GLX:IsTexture +R147 GLX:GetColorTable +R148 GLX:GetColorTableParameterfv +R149 GLX:GetColorTableParameterfv +R150 GLX:GetConvolutionFilter +R151 GLX:GetConvolutionParameterfv +R152 GLX:GetConvolutionParameteriv +R153 GLX:GetSeparableFilter +R154 GLX:GetHistogram +R155 GLX:GetHistogramParameterfv +R156 GLX:GetHistogramParameteriv +R157 GLX:GetMinmax +R158 GLX:GetMinmaxParameterfv +R159 GLX:GetMinmaxParameteriv +R160 GLX:GetCompressedTexImage +V000 GLX:PbufferClobber +V001 GLX:BufferSwapComplete +E000 GLX:BadContext +E001 GLX:BadContextState +E002 GLX:BadDrawable +E003 GLX:BadPixmap +E004 GLX:BadContextTag +E005 GLX:BadCurrentWindow +E006 GLX:BadRenderRequest +E007 GLX:BadLargeRequest +E008 GLX:UnsupportedPrivateRequest +E009 GLX:BadFBConfig +E010 GLX:BadPbuffer +E011 GLX:BadCurrentDrawable +E012 GLX:BadWindow +R000 MIT-SCREEN-SAVER:QueryVersion +R001 MIT-SCREEN-SAVER:QueryInfo +R002 MIT-SCREEN-SAVER:SelectInput +R003 MIT-SCREEN-SAVER:SetAttributes +R004 MIT-SCREEN-SAVER:UnsetAttributes +R005 MIT-SCREEN-SAVER:Suspend +V000 MIT-SCREEN-SAVER:Notify +R000 MIT-SHM:QueryVersion +R001 MIT-SHM:Attach +R002 MIT-SHM:Detach +R003 MIT-SHM:PutImage +R004 MIT-SHM:GetImage +R005 MIT-SHM:CreatePixmap +R006 MIT-SHM:AttachFd +R007 MIT-SHM:CreateSegment +V000 MIT-SHM:Completion +E000 MIT-SHM:BadShmSeg +R000 MIT-SUNDRY-NONSTANDARD:SetBugMode +R001 MIT-SUNDRY-NONSTANDARD:GetBugMode +R000 Present:QueryVersion +R001 Present:Pixmap +R002 Present:NotifyMSC +R003 Present:SelectInput +R004 Present:QueryCapabilities +R000 RANDR:QueryVersion +R001 RANDR:OldGetScreenInfo +R002 RANDR:SetScreenConfig +R003 RANDR:OldScreenChangeSelectInput +R004 RANDR:SelectInput +R005 RANDR:GetScreenInfo +R006 RANDR:GetScreenSizeRange +R007 RANDR:SetScreenSize +R008 RANDR:GetScreenResources +R009 RANDR:GetOutputInfo +R010 RANDR:ListOutputProperties +R011 RANDR:QueryOutputProperty +R012 RANDR:ConfigureOutputProperty +R013 RANDR:ChangeOutputProperty +R014 RANDR:DeleteOutputProperty +R015 RANDR:GetOutputProperty +R016 RANDR:CreateMode +R017 RANDR:DestroyMode +R018 RANDR:AddOutputMode +R019 RANDR:DeleteOutputMode +R020 RANDR:GetCrtcInfo +R021 RANDR:SetCrtcConfig +R022 RANDR:GetCrtcGammaSize +R023 RANDR:GetCrtcGamma +R024 RANDR:SetCrtcGamma +R025 RANDR:GetScreenResourcesCurrent +R026 RANDR:SetCrtcTransform +R027 RANDR:GetCrtcTransform +R028 RANDR:GetPanning +R029 RANDR:SetPanning +R030 RANDR:SetOutputPrimary +R031 RANDR:GetOutputPrimary +R032 RANDR:RRGetProviders +R033 RANDR:RRGetProviderInfo +R034 RANDR:RRSetProviderOffloadSink +R035 RANDR:RRSetProviderOutputSource +R036 RANDR:RRListProviderProperties +R037 RANDR:RRQueryProviderProperty +R038 RANDR:RRConfigureProviderProperty +R039 RANDR:RRChangeProviderProperty +R040 RANDR:RRDeleteProviderProperty +R041 RANDR:RRGetProviderProperty +R042 RANDR:GetMonitors +R043 RANDR:SetMonitor +R044 RANDR:DeleteMonitor +V000 RANDR:ScreenChangeNotify +V001 RANDR:Notify +E000 RANDR:BadRROutput +E001 RANDR:BadRRCrtc +E002 RANDR:BadRRMode +E003 RANDR:BadRRProvider +R000 RECORD:QueryVersion +R001 RECORD:CreateContext +R002 RECORD:RegisterClients +R003 RECORD:UnregisterClients +R004 RECORD:GetContext +R005 RECORD:EnableContext +R006 RECORD:DisableContext +R007 RECORD:FreeContext +E000 RECORD:BadContext +R000 RENDER:QueryVersion +R001 RENDER:QueryPictFormats +R002 RENDER:QueryPictIndexValues +R003 RENDER:QueryDithers +R004 RENDER:CreatePicture +R005 RENDER:ChangePicture +R006 RENDER:SetPictureClipRectangles +R007 RENDER:FreePicture +R008 RENDER:Composite +R009 RENDER:Scale +R010 RENDER:Trapezoids +R011 RENDER:Triangles +R012 RENDER:TriStrip +R013 RENDER:TriFan +R014 RENDER:ColorTrapezoids +R015 RENDER:ColorTriangles +R016 RENDER:Transform +R017 RENDER:CreateGlyphSet +R018 RENDER:ReferenceGlyphSet +R019 RENDER:FreeGlyphSet +R020 RENDER:AddGlyphs +R021 RENDER:AddGlyphsFromPicture +R022 RENDER:FreeGlyphs +R023 RENDER:CompositeGlyphs8 +R024 RENDER:CompositeGlyphs16 +R025 RENDER:CompositeGlyphs32 +R026 RENDER:FillRectangles +R027 RENDER:CreateCursor +R028 RENDER:SetPictureTransform +R029 RENDER:QueryFilters +R030 RENDER:SetPictureFilter +R031 RENDER:CreateAnimCursor +R032 RENDER:AddTraps +R033 RENDER:CreateSolidFill +R034 RENDER:CreateLinearGradient +R035 RENDER:CreateRadialGradient +R036 RENDER:CreateConicalGradient +E000 RENDER:BadPictFormat +E001 RENDER:BadPicture +E002 RENDER:BadPictOp +E003 RENDER:BadGlyphSet +E004 RENDER:BadGlyph +R000 SECURITY:QueryVersion +R001 SECURITY:GenerateAuthorization +R002 SECURITY:RevokeAuthorization +V000 SECURITY:AuthorizationRevoked +E000 SECURITY:BadAuthorization +E001 SECURITY:BadAuthorizationProtocol +R000 SELinux:SELinuxQueryVersion +R001 SELinux:SELinuxSetDeviceCreateContext +R002 SELinux:SELinuxGetDeviceCreateContext +R003 SELinux:SELinuxSetDeviceContext +R004 SELinux:SELinuxGetDeviceContext +R005 SELinux:SELinuxSetWindowCreateContext +R006 SELinux:SELinuxGetWindowCreateContext +R007 SELinux:SELinuxGetWindowContext +R008 SELinux:SELinuxSetPropertyCreateContext +R009 SELinux:SELinuxGetPropertyCreateContext +R010 SELinux:SELinuxSetPropertyUseContext +R011 SELinux:SELinuxGetPropertyUseContext +R012 SELinux:SELinuxGetPropertyContext +R013 SELinux:SELinuxGetPropertyDataContext +R014 SELinux:SELinuxListProperties +R015 SELinux:SELinuxSetSelectionCreateContext +R016 SELinux:SELinuxGetSelectionCreateContext +R017 SELinux:SELinuxSetSelectionUseContext +R018 SELinux:SELinuxGetSelectionUseContext +R019 SELinux:SELinuxGetSelectionContext +R020 SELinux:SELinuxGetSelectionDataContext +R021 SELinux:SELinuxListSelections +R022 SELinux:SELinuxGetClientContext +R000 SHAPE:QueryVersion +R001 SHAPE:Rectangles +R002 SHAPE:Mask +R003 SHAPE:Combine +R004 SHAPE:Offset +R005 SHAPE:QueryExtents +R006 SHAPE:SelectInput +R007 SHAPE:InputSelected +R008 SHAPE:GetRectangles +V000 SHAPE:Notify +R000 SYNC:Initialize +R001 SYNC:ListSystemCounters +R002 SYNC:CreateCounter +R003 SYNC:SetCounter +R004 SYNC:ChangeCounter +R005 SYNC:QueryCounter +R006 SYNC:DestroyCounter +R007 SYNC:Await +R008 SYNC:CreateAlarm +R009 SYNC:ChangeAlarm +R010 SYNC:QueryAlarm +R011 SYNC:DestroyAlarm +R012 SYNC:SetPriority +R013 SYNC:GetPriority +V000 SYNC:CounterNotify +V001 SYNC:AlarmNotify +E000 SYNC:BadCounter +E001 SYNC:BadAlarm +R000 TOG-CUP:QueryVersion +R001 TOG-CUP:GetReservedColormapEntries +R002 TOG-CUP:StoreColors +R000 Windows-WM:QueryVersion +R001 Windows-WM:FrameGetRect +R002 Windows-WM:FrameDraw +R003 Windows-WM:FrameSetTitle +R004 Windows-WM:DisableUpdate +R005 Windows-WM:ReenableUpdate +R006 Windows-WM:SelectInput +R007 Windows-WM:SetFrontProcess +V000 Windows-WM:ControllerNotify +V001 Windows-WM:ActivationNotify +E000 Windows-WM:ClientNotLocal +E001 Windows-WM:OperationNotSupported +R000 X-Resource:QueryVersion +R001 X-Resource:QueryClients +R002 X-Resource:QueryClientResources +R003 X-Resource:QueryClientPixmapBytes +R001 X11:CreateWindow +R002 X11:ChangeWindowAttributes +R003 X11:GetWindowAttributes +R004 X11:DestroyWindow +R005 X11:DestroySubwindows +R006 X11:ChangeSaveSet +R007 X11:ReparentWindow +R008 X11:MapWindow +R009 X11:MapSubwindows +R010 X11:UnmapWindow +R011 X11:UnmapSubwindows +R012 X11:ConfigureWindow +R013 X11:CirculateWindow +R014 X11:GetGeometry +R015 X11:QueryTree +R016 X11:InternAtom +R017 X11:GetAtomName +R018 X11:ChangeProperty +R019 X11:DeleteProperty +R020 X11:GetProperty +R021 X11:ListProperties +R022 X11:SetSelectionOwner +R023 X11:GetSelectionOwner +R024 X11:ConvertSelection +R025 X11:SendEvent +R026 X11:GrabPointer +R027 X11:UngrabPointer +R028 X11:GrabButton +R029 X11:UngrabButton +R030 X11:ChangeActivePointerGrab +R031 X11:GrabKeyboard +R032 X11:UngrabKeyboard +R033 X11:GrabKey +R034 X11:UngrabKey +R035 X11:AllowEvents +R036 X11:GrabServer +R037 X11:UngrabServer +R038 X11:QueryPointer +R039 X11:GetMotionEvents +R040 X11:TranslateCoords +R041 X11:WarpPointer +R042 X11:SetInputFocus +R043 X11:GetInputFocus +R044 X11:QueryKeymap +R045 X11:OpenFont +R046 X11:CloseFont +R047 X11:QueryFont +R048 X11:QueryTextExtents +R049 X11:ListFonts +R050 X11:ListFontsWithInfo +R051 X11:SetFontPath +R052 X11:GetFontPath +R053 X11:CreatePixmap +R054 X11:FreePixmap +R055 X11:CreateGC +R056 X11:ChangeGC +R057 X11:CopyGC +R058 X11:SetDashes +R059 X11:SetClipRectangles +R060 X11:FreeGC +R061 X11:ClearArea +R062 X11:CopyArea +R063 X11:CopyPlane +R064 X11:PolyPoint +R065 X11:PolyLine +R066 X11:PolySegment +R067 X11:PolyRectangle +R068 X11:PolyArc +R069 X11:FillPoly +R070 X11:PolyFillRectangle +R071 X11:PolyFillArc +R072 X11:PutImage +R073 X11:GetImage +R074 X11:PolyText8 +R075 X11:PolyText16 +R076 X11:ImageText8 +R077 X11:ImageText16 +R078 X11:CreateColormap +R079 X11:FreeColormap +R080 X11:CopyColormapAndFree +R081 X11:InstallColormap +R082 X11:UninstallColormap +R083 X11:ListInstalledColormaps +R084 X11:AllocColor +R085 X11:AllocNamedColor +R086 X11:AllocColorCells +R087 X11:AllocColorPlanes +R088 X11:FreeColors +R089 X11:StoreColors +R090 X11:StoreNamedColor +R091 X11:QueryColors +R092 X11:LookupColor +R093 X11:CreateCursor +R094 X11:CreateGlyphCursor +R095 X11:FreeCursor +R096 X11:RecolorCursor +R097 X11:QueryBestSize +R098 X11:QueryExtension +R099 X11:ListExtensions +R100 X11:ChangeKeyboardMapping +R101 X11:GetKeyboardMapping +R102 X11:ChangeKeyboardControl +R103 X11:GetKeyboardControl +R104 X11:Bell +R105 X11:ChangePointerControl +R106 X11:GetPointerControl +R107 X11:SetScreenSaver +R108 X11:GetScreenSaver +R109 X11:ChangeHosts +R110 X11:ListHosts +R111 X11:SetAccessControl +R112 X11:SetCloseDownMode +R113 X11:KillClient +R114 X11:RotateProperties +R115 X11:ForceScreenSaver +R116 X11:SetPointerMapping +R117 X11:GetPointerMapping +R118 X11:SetModifierMapping +R119 X11:GetModifierMapping +R127 X11:NoOperation +V000 X11:X_Error +V001 X11:X_Reply +V002 X11:KeyPress +V003 X11:KeyRelease +V004 X11:ButtonPress +V005 X11:ButtonRelease +V006 X11:MotionNotify +V007 X11:EnterNotify +V008 X11:LeaveNotify +V009 X11:FocusIn +V010 X11:FocusOut +V011 X11:KeymapNotify +V012 X11:Expose +V013 X11:GraphicsExpose +V014 X11:NoExpose +V015 X11:VisibilityNotify +V016 X11:CreateNotify +V017 X11:DestroyNotify +V018 X11:UnmapNotify +V019 X11:MapNotify +V020 X11:MapRequest +V021 X11:ReparentNotify +V022 X11:ConfigureNotify +V023 X11:ConfigureRequest +V024 X11:GravityNotify +V025 X11:ResizeRequest +V026 X11:CirculateNotify +V027 X11:CirculateRequest +V028 X11:PropertyNotify +V029 X11:SelectionClear +V030 X11:SelectionRequest +V031 X11:SelectionNotify +V032 X11:ColormapNotify +V033 X11:ClientMessage +V034 X11:MappingNotify +V035 X11:GenericEvent +E000 X11:Success +E001 X11:BadRequest +E002 X11:BadValue +E003 X11:BadWindow +E004 X11:BadPixmap +E005 X11:BadAtom +E006 X11:BadCursor +E007 X11:BadFont +E008 X11:BadMatch +E009 X11:BadDrawable +E010 X11:BadAccess +E011 X11:BadAlloc +E012 X11:BadColor +E013 X11:BadGC +E014 X11:BadIDChoice +E015 X11:BadName +E016 X11:BadLength +E017 X11:BadImplementation +R000 XC-APPGROUP:QueryVersion +R001 XC-APPGROUP:Create +R002 XC-APPGROUP:Destroy +R003 XC-APPGROUP:GetAttr +R004 XC-APPGROUP:Query +R005 XC-APPGROUP:CreateAssoc +R006 XC-APPGROUP:DestroyAssoc +E000 XC-APPGROUP:BadAppGroup +R000 XC-MISC:GetVersion +R001 XC-MISC:GetXIDRange +R002 XC-MISC:GetXIDList +R000 XFIXES:QueryVersion +R001 XFIXES:ChangeSaveSet +R002 XFIXES:SelectSelectionInput +R003 XFIXES:SelectCursorInput +R004 XFIXES:GetCursorImage +R005 XFIXES:CreateRegion +R006 XFIXES:CreateRegionFromBitmap +R007 XFIXES:CreateRegionFromWindow +R008 XFIXES:CreateRegionFromGC +R009 XFIXES:CreateRegionFromPicture +R010 XFIXES:DestroyRegion +R011 XFIXES:SetRegion +R012 XFIXES:CopyRegion +R013 XFIXES:UnionRegion +R014 XFIXES:IntersectRegion +R015 XFIXES:SubtractRegion +R016 XFIXES:InvertRegion +R017 XFIXES:TranslateRegion +R018 XFIXES:RegionExtents +R019 XFIXES:FetchRegion +R020 XFIXES:SetGCClipRegion +R021 XFIXES:SetWindowShapeRegion +R022 XFIXES:SetPictureClipRegion +R023 XFIXES:SetCursorName +R024 XFIXES:GetCursorName +R025 XFIXES:GetCursorImageAndName +R026 XFIXES:ChangeCursor +R027 XFIXES:ChangeCursorByName +R028 XFIXES:ExpandRegion +R029 XFIXES:HideCursor +R030 XFIXES:ShowCursor +V000 XFIXES:SelectionNotify +V001 XFIXES:CursorNotify +E000 XFIXES:BadRegion +R000 XFree86-DGA:QueryVersion +R001 XFree86-DGA:GetVideoLL +R002 XFree86-DGA:DirectVideo +R003 XFree86-DGA:GetViewPortSize +R004 XFree86-DGA:SetViewPort +R005 XFree86-DGA:GetVidPage +R006 XFree86-DGA:SetVidPage +R007 XFree86-DGA:InstallColormap +R008 XFree86-DGA:QueryDirectVideo +R009 XFree86-DGA:ViewPortChanged +R010 XFree86-DGA:Obsolete1 +R011 XFree86-DGA:Obsolete2 +R012 XFree86-DGA:QueryModes +R013 XFree86-DGA:SetMode +R014 XFree86-DGA:SetViewport +R015 XFree86-DGA:InstallColormap +R016 XFree86-DGA:SelectInput +R017 XFree86-DGA:FillRectangle +R018 XFree86-DGA:CopyArea +R019 XFree86-DGA:CopyTransparentArea +R020 XFree86-DGA:GetViewportStatus +R021 XFree86-DGA:Sync +R022 XFree86-DGA:OpenFramebuffer +R023 XFree86-DGA:CloseFramebuffer +R024 XFree86-DGA:SetClientVersion +R025 XFree86-DGA:ChangePixmapMode +R026 XFree86-DGA:CreateColormap +E000 XFree86-DGA:ClientNotLocal +E001 XFree86-DGA:NoDirectVideoMode +E002 XFree86-DGA:ScreenNotActive +E003 XFree86-DGA:DirectNotActivated +E004 XFree86-DGA:OperationNotSupported +R000 XFree86-DRI:QueryVersion +R001 XFree86-DRI:QueryDirectRenderingCapable +R002 XFree86-DRI:OpenConnection +R003 XFree86-DRI:CloseConnection +R004 XFree86-DRI:GetClientDriverName +R005 XFree86-DRI:CreateContext +R006 XFree86-DRI:DestroyContext +R007 XFree86-DRI:CreateDrawable +R008 XFree86-DRI:DestroyDrawable +R009 XFree86-DRI:GetDrawableInfo +R010 XFree86-DRI:GetDeviceInfo +R011 XFree86-DRI:AuthConnection +R012 XFree86-DRI:OpenFullScreen +R013 XFree86-DRI:CloseFullScreen +E000 XFree86-DRI:ClientNotLocal +E001 XFree86-DRI:OperationNotSupported +R000 XFree86-Misc:QueryVersion +R001 XFree86-Misc:GetSaver +R002 XFree86-Misc:SetSaver +R003 XFree86-Misc:GetMouseSettings +R004 XFree86-Misc:GetKbdSettings +R005 XFree86-Misc:SetMouseSettings +R006 XFree86-Misc:SetKbdSettings +R007 XFree86-Misc:SetGrabKeysState +R008 XFree86-Misc:SetClientVersion +R009 XFree86-Misc:GetFilePaths +R010 XFree86-Misc:PassMessage +E000 XFree86-Misc:BadMouseProtocol +E001 XFree86-Misc:BadMouseBaudRate +E002 XFree86-Misc:BadMouseFlags +E003 XFree86-Misc:BadMouseCombo +E004 XFree86-Misc:BadKbdType +E005 XFree86-Misc:ModInDevDisabled +E006 XFree86-Misc:ModInDevClientNotLocal +E007 XFree86-Misc:NoModule +R000 XFree86-VidModeExtension:QueryVersion +R001 XFree86-VidModeExtension:GetModeLine +R002 XFree86-VidModeExtension:ModModeLine +R003 XFree86-VidModeExtension:SwitchMode +R004 XFree86-VidModeExtension:GetMonitor +R005 XFree86-VidModeExtension:LockModeSwitch +R006 XFree86-VidModeExtension:GetAllModeLines +R007 XFree86-VidModeExtension:AddModeLine +R008 XFree86-VidModeExtension:DeleteModeLine +R009 XFree86-VidModeExtension:ValidateModeLine +R010 XFree86-VidModeExtension:SwitchToMode +R011 XFree86-VidModeExtension:GetViewPort +R012 XFree86-VidModeExtension:SetViewPort +R013 XFree86-VidModeExtension:GetDotClocks +R014 XFree86-VidModeExtension:SetClientVersion +R015 XFree86-VidModeExtension:SetGamma +R016 XFree86-VidModeExtension:GetGamma +R017 XFree86-VidModeExtension:GetGammaRamp +R018 XFree86-VidModeExtension:SetGammaRamp +R019 XFree86-VidModeExtension:GetGammaRampSize +R020 XFree86-VidModeExtension:GetPermissions +V000 XFree86-VidModeExtension:Notify +E000 XFree86-VidModeExtension:BadClock +E001 XFree86-VidModeExtension:BadHTimings +E002 XFree86-VidModeExtension:BadVTimings +E003 XFree86-VidModeExtension:ModeUnsuitable +E004 XFree86-VidModeExtension:ExtensionDisabled +E005 XFree86-VidModeExtension:ClientNotLocal +E006 XFree86-VidModeExtension:ZoomLocked +R000 XINERAMA:QueryVersion +R001 XINERAMA:GetState +R002 XINERAMA:GetScreenCount +R003 XINERAMA:GetScreenSize +R004 XINERAMA:IsActive +R005 XINERAMA:QueryScreens +R001 XInputExtension:GetExtensionVersion +R002 XInputExtension:ListInputDevices +R003 XInputExtension:OpenDevice +R004 XInputExtension:CloseDevice +R005 XInputExtension:SetDeviceMode +R006 XInputExtension:SelectExtensionEvent +R007 XInputExtension:GetSelectedExtensionEvents +R008 XInputExtension:ChangeDeviceDontPropagateList +R009 XInputExtension:GetDeviceDontPropagageList +R010 XInputExtension:GetDeviceMotionEvents +R011 XInputExtension:ChangeKeyboardDevice +R012 XInputExtension:ChangePointerDevice +R013 XInputExtension:GrabDevice +R014 XInputExtension:UngrabDevice +R015 XInputExtension:GrabDeviceKey +R016 XInputExtension:UngrabDeviceKey +R017 XInputExtension:GrabDeviceButton +R018 XInputExtension:UngrabDeviceButton +R019 XInputExtension:AllowDeviceEvents +R020 XInputExtension:GetDeviceFocus +R021 XInputExtension:SetDeviceFocus +R022 XInputExtension:GetFeedbackControl +R023 XInputExtension:ChangeFeedbackControl +R024 XInputExtension:GetDeviceKeyMapping +R025 XInputExtension:ChangeDeviceKeyMapping +R026 XInputExtension:GetDeviceModifierMapping +R027 XInputExtension:SetDeviceModifierMapping +R028 XInputExtension:GetDeviceButtonMapping +R029 XInputExtension:SetDeviceButtonMapping +R030 XInputExtension:QueryDeviceState +R031 XInputExtension:SendExtensionEvent +R032 XInputExtension:DeviceBell +R033 XInputExtension:SetDeviceValuators +R034 XInputExtension:GetDeviceControl +R035 XInputExtension:ChangeDeviceControl +R036 XInputExtension:ListDeviceProperties +R037 XInputExtension:ChangeDeviceProperty +R038 XInputExtension:DeleteDeviceProperty +R039 XInputExtension:GetDeviceProperty +R040 XInputExtension:QueryPointer +R041 XInputExtension:WarpPointer +R042 XInputExtension:ChangeCursor +R043 XInputExtension:ChangeHierarchy +R044 XInputExtension:SetClientPointer +R045 XInputExtension:GetClientPointer +R046 XInputExtension:SelectEvents +R047 XInputExtension:QueryVersion +R048 XInputExtension:QueryDevice +R049 XInputExtension:SetFocus +R050 XInputExtension:GetFocus +R051 XInputExtension:GrabDevice +R052 XInputExtension:UngrabDevice +R053 XInputExtension:AllowEvents +R054 XInputExtension:PassiveGrabDevice +R055 XInputExtension:PassiveUngrabDevice +R056 XInputExtension:ListProperties +R057 XInputExtension:ChangeProperty +R058 XInputExtension:DeleteProperty +R059 XInputExtension:GetProperty +R060 XInputExtension:GetSelectedEvents +V000 XInputExtension:DeviceValuator +V001 XInputExtension:DeviceKeyPress +V002 XInputExtension:DeviceKeyRelease +V003 XInputExtension:DeviceButtonPress +V004 XInputExtension:DeviceButtonRelease +V005 XInputExtension:DeviceMotionNotify +V006 XInputExtension:DeviceFocusIn +V007 XInputExtension:DeviceFocusOut +V008 XInputExtension:ProximityIn +V009 XInputExtension:ProximityOut +V010 XInputExtension:DeviceStateNotify +V011 XInputExtension:DeviceMappingNotify +V012 XInputExtension:ChangeDeviceNotify +V013 XInputExtension:DeviceKeystateNotify +V014 XInputExtension:DeviceButtonstateNotify +V015 XInputExtension:DevicePresenceNotify +V016 XInputExtension:DevicePropertyNotify +E000 XInputExtension:BadDevice +E001 XInputExtension:BadEvent +E002 XInputExtension:BadMode +E003 XInputExtension:DeviceBusy +E004 XInputExtension:BadClass +R000 XKEYBOARD:UseExtension +R001 XKEYBOARD:SelectEvents +R002 XKEYBOARD:Obsolete +R003 XKEYBOARD:Bell +R004 XKEYBOARD:GetState +R005 XKEYBOARD:LatchLockState +R006 XKEYBOARD:GetControls +R007 XKEYBOARD:SetControls +R008 XKEYBOARD:GetMap +R009 XKEYBOARD:SetMap +R010 XKEYBOARD:GetCompatMap +R011 XKEYBOARD:SetCompatMap +R012 XKEYBOARD:GetIndicatorState +R013 XKEYBOARD:GetIndicatorMap +R014 XKEYBOARD:SetIndicatorMap +R015 XKEYBOARD:GetNamedIndicator +R016 XKEYBOARD:SetNamedIndicator +R017 XKEYBOARD:GetNames +R018 XKEYBOARD:SetNames +R019 XKEYBOARD:GetGeometry +R020 XKEYBOARD:SetGeometry +R021 XKEYBOARD:PerClientFlags +R022 XKEYBOARD:ListComponents +R023 XKEYBOARD:GetKbdByName +R024 XKEYBOARD:GetDeviceInfo +R025 XKEYBOARD:SetDeviceInfo +R101 XKEYBOARD:SetDebuggingFlags +V000 XKEYBOARD:EventCode +E000 XKEYBOARD:BadKeyboard +R000 XTEST:GetVersion +R001 XTEST:CompareCursor +R002 XTEST:FakeInput +R003 XTEST:GrabControl +R000 XVideo:QueryExtension +R001 XVideo:QueryAdaptors +R002 XVideo:QueryEncodings +R003 XVideo:GrabPort +R004 XVideo:UngrabPort +R005 XVideo:PutVideo +R006 XVideo:PutStill +R007 XVideo:GetVideo +R008 XVideo:GetStill +R009 XVideo:StopVideo +R010 XVideo:SelectVideoNotify +R011 XVideo:SelectPortNotify +R012 XVideo:QueryBestSize +R013 XVideo:SetPortAttribute +R014 XVideo:GetPortAttribute +R015 XVideo:QueryPortAttributes +R016 XVideo:ListImageFormats +R017 XVideo:QueryImageAttributes +R018 XVideo:PutImage +R019 XVideo:ShmPutImage +V000 XVideo:VideoNotify +V001 XVideo:PortNotify +E000 XVideo:BadPort +E001 XVideo:BadEncoding +E002 XVideo:BadControl +R000 XVideo-MotionCompensation:QueryVersion +R001 XVideo-MotionCompensation:ListSurfaceTypes +R002 XVideo-MotionCompensation:CreateContext +R003 XVideo-MotionCompensation:DestroyContext +R004 XVideo-MotionCompensation:CreateSurface +R005 XVideo-MotionCompensation:DestroySurface +R006 XVideo-MotionCompensation:CreateSubpicture +R007 XVideo-MotionCompensation:DestroySubpicture +R008 XVideo-MotionCompensation:ListSubpictureTypes +R009 XVideo-MotionCompensation:GetDRInfo +E000 XVideo-MotionCompensation:BadContext +E001 XVideo-MotionCompensation:BadSurface +E002 XVideo-MotionCompensation:BadSubpicture diff --git a/prebuilt/xlibre/usr/share/X11/xorg.conf.d/10-quirks.conf b/prebuilt/xlibre/usr/share/X11/xorg.conf.d/10-quirks.conf new file mode 100644 index 0000000..54dd908 --- /dev/null +++ b/prebuilt/xlibre/usr/share/X11/xorg.conf.d/10-quirks.conf @@ -0,0 +1,48 @@ +# Collection of quirks and blacklist/whitelists for specific devices. + + +# Accelerometer device, posts data through ABS_X/ABS_Y, making X unusable +# http://bugs.freedesktop.org/show_bug.cgi?id=22442 +Section "InputClass" + Identifier "ThinkPad HDAPS accelerometer blacklist" + MatchProduct "ThinkPad HDAPS accelerometer data" + Option "Ignore" "on" +EndSection + +# https://bugzilla.redhat.com/show_bug.cgi?id=523914 +# Mouse does not move in PV Xen guest +# Explicitly tell evdev to not ignore the absolute axes. +Section "InputClass" + Identifier "Xen Virtual Pointer axis blacklist" + MatchProduct "Xen Virtual Pointer" + Option "IgnoreAbsoluteAxes" "off" + Option "IgnoreRelativeAxes" "off" +EndSection + +# https://bugs.freedesktop.org/show_bug.cgi?id=55867 +# Bug 55867 - Doesn't know how to tag XI_TRACKBALL +Section "InputClass" + Identifier "Tag trackballs as XI_TRACKBALL" + MatchProduct "trackball" + MatchDriver "evdev" + Option "TypeName" "TRACKBALL" +EndSection + +# https://bugs.freedesktop.org/show_bug.cgi?id=62831 +# Bug 62831 - Mionix Naos 5000 mouse detected incorrectly +Section "InputClass" + Identifier "Tag Mionix Naos 5000 mouse XI_MOUSE" + MatchProduct "La-VIEW Technology Naos 5000 Mouse" + MatchDriver "evdev" + Option "TypeName" "MOUSE" +EndSection + +# https://bugzilla.redhat.com/show_bug.cgi?id=2152414 +# Xorg server does not correctly select the DCP for the display without +# a quirk on Apple Silicon +Section "OutputClass" + Identifier "appledrm" + MatchDriver "apple" + Driver "modesetting" + Option "PrimaryGPU" "true" +EndSection diff --git a/prebuilt/xlibre/usr/share/X11/xorg.conf.d/40-libinput.conf b/prebuilt/xlibre/usr/share/X11/xorg.conf.d/40-libinput.conf new file mode 100644 index 0000000..eb33ad0 --- /dev/null +++ b/prebuilt/xlibre/usr/share/X11/xorg.conf.d/40-libinput.conf @@ -0,0 +1,52 @@ +# Match on all types of devices but joysticks +# +# If you want to configure your devices, do not copy this file. +# Instead, use a config snippet that contains something like this: +# +# Section "InputClass" +# Identifier "something or other" +# MatchDriver "libinput" +# +# MatchIsTouchpad "on" +# ... other Match directives ... +# Option "someoption" "value" +# EndSection +# +# This applies the option any libinput device also matched by the other +# directives. See the xorg.conf(5) man page for more info on +# matching devices. + +Section "InputClass" + Identifier "libinput pointer catchall" + MatchIsPointer "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput keyboard catchall" + MatchIsKeyboard "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput touchpad catchall" + MatchIsTouchpad "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput touchscreen catchall" + MatchIsTouchscreen "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput tablet catchall" + MatchIsTablet "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection diff --git a/prebuilt/xlibre/usr/share/aclocal/xorg-server.m4 b/prebuilt/xlibre/usr/share/aclocal/xorg-server.m4 new file mode 100644 index 0000000..85ead61 --- /dev/null +++ b/prebuilt/xlibre/usr/share/aclocal/xorg-server.m4 @@ -0,0 +1,121 @@ +dnl Copyright 2005 Red Hat, Inc +dnl +dnl Permission to use, copy, modify, distribute, and sell this software and its +dnl documentation for any purpose is hereby granted without fee, provided that +dnl the above copyright notice appear in all copies and that both that +dnl copyright notice and this permission notice appear in supporting +dnl documentation. +dnl +dnl The above copyright notice and this permission notice shall be included +dnl in all copies or substantial portions of the Software. +dnl +dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +dnl OTHER DEALINGS IN THE SOFTWARE. +dnl +dnl Except as contained in this notice, the name of the copyright holders shall +dnl not be used in advertising or otherwise to promote the sale, use or +dnl other dealings in this Software without prior written authorization +dnl from the copyright holders. +dnl + +# XORG_DRIVER_CHECK_EXT(MACRO, PROTO) +# -------------------------- +# Checks for the MACRO define in xorg-server.h (from the sdk). If it +# is defined, then add the given PROTO to $REQUIRED_MODULES. + +AC_DEFUN([XORG_DRIVER_CHECK_EXT],[ + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS `$PKG_CONFIG --cflags xorg-server`" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include "xorg-server.h" +#if !defined $1 +#error $1 not defined +#endif + ]])], + [_EXT_CHECK=yes], + [_EXT_CHECK=no]) + CFLAGS="$SAVE_CFLAGS" + AC_MSG_CHECKING([if $1 is defined]) + AC_MSG_RESULT([$_EXT_CHECK]) + if test "$_EXT_CHECK" != no; then + REQUIRED_MODULES="$REQUIRED_MODULES $2" + fi +]) + +# XLIBRE_MODULE_VERSION +# -------------------- +# Defines XLIBRE_MODULE_VERSION_{MAJOR|MINOR|PATCHLEVEL} for modules to use. + +AC_DEFUN([XLIBRE_MODULE_VERSION],[ + AC_DEFINE_UNQUOTED([XLIBRE_MODULE_VERSION_MAJOR], + [`echo $PACKAGE_VERSION | cut -d . -f 1`], [major version]) + PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1` + if test "x$PVM" = "x"; then + PVM="0" + fi + AC_DEFINE_UNQUOTED([XLIBRE_MODULE_VERSION_MINOR], [$PVM], [minor version]) + PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1` + if test "x$PVP" = "x"; then + PVP="0" + fi + AC_DEFINE_UNQUOTED([XLIBRE_MODULE_VERSION_PATCH], [$PVP], [patch version]) +]) + +AC_DEFUN([XLIBRE_SDK_VAR], [ + $1=`$PKG_CONFIG xlibre-server --variable=$2` + if test "x$1" == "x" ; then + AC_MSG_ERROR([xlibre-server.pc missing '$2' variable]) + fi + AC_MSG_NOTICE([$1=${$1}]) + AC_SUBST($1) +]) + +AC_DEFUN([XLIBRE_PROBE_SDK], [ + PKG_PROG_PKG_CONFIG([0.25]) + PKG_CHECK_MODULES(XLIBRE_SERVER, xlibre-server xproto $XLIBRE_EXTRA_MODULES) + + XLIBRE_SDK_VAR([xlibre_server_name], [server_name]) + XLIBRE_SDK_VAR([xlibre_server_config], [server_config]) + XLIBRE_SDK_VAR([xlibre_module_dir], [moduledir]) + XLIBRE_SDK_VAR([xlibre_libtool_flags], [libtool_flags]) + XLIBRE_SDK_VAR([xlibre_input_drivers_dir], [input_drivers_dir]) + XLIBRE_SDK_VAR([xlibre_video_drivers_dir], [video_drivers_dir]) + XLIBRE_SDK_VAR([xlibre_sdk_dir], [sdkdir]) + XLIBRE_SDK_VAR([xlibre_conf_dir], [xserverconfigdir]) + XLIBRE_SDK_VAR([xlibre_driver_man_dir], [driver_man_dir]) + XLIBRE_SDK_VAR([xlibre_driver_man_section],[driver_man_section]) + XLIBRE_SDK_VAR([xlibre_misc_man_dir], [misc_man_dir]) + XLIBRE_SDK_VAR([xlibre_misc_man_section], [misc_man_section]) + XLIBRE_SDK_VAR([xlibre_app_man_dir], [app_man_dir]) + XLIBRE_SDK_VAR([xlibre_app_man_section], [app_man_section]) + XLIBRE_SDK_VAR([xlibre_file_man_dir], [file_man_dir]) + XLIBRE_SDK_VAR([xlibre_file_man_section], [file_man_section]) +]) + +AC_DEFUN([XLIBRE_INIT_MODULE], [ + XLIBRE_MODULE_VERSION + XLIBRE_PROBE_SDK + + dnl AC_CONFIG_AUX_DIR(build-aux) + AC_CONFIG_AUX_DIR(.) + AC_DISABLE_STATIC + AC_PROG_LIBTOOL + AC_PROG_CC + + AH_TOP([#include "xorg-server.h"]) + xlibre_driver_name="$1" + AC_SUBST(xlibre_driver_name) +]) + +AC_DEFUN([XLIBRE_INIT_MODULE_AM], [ + XLIBRE_INIT_MODULE($1) + AC_CONFIG_SRCDIR([Makefile.am]) + AM_INIT_AUTOMAKE([dist-bzip2]) + AC_CONFIG_HEADERS([config.h]) +]) diff --git a/prebuilt/xlibre/usr/share/man/man1/Xorg.1 b/prebuilt/xlibre/usr/share/man/man1/Xorg.1 new file mode 100644 index 0000000..c85fffb --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man1/Xorg.1 @@ -0,0 +1,677 @@ +.\" $XdotOrg: xserver/xorg/hw/xfree86/doc/man/Xorg.man.pre,v 1.3 2005/07/04 18:41:01 ajax Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH Xorg 1 "xorg-server 25.2.0" "X Version 11" +.SH NAME +Xorg - X11R7 X server +.SH SYNOPSIS +.B Xorg +.RI [\fB:\fP display ] +.RI [ option +.IR ... ] +.SH DESCRIPTION +.B Xorg +is a full featured X server that was originally designed for UNIX and +UNIX-like operating systems running on Intel x86 hardware. It now runs +on a wider range of hardware and OS platforms. +.PP +This work was derived by the X.Org Foundation from the XFree86 Project's +.I "XFree86\ 4.4rc2" +release. +The XFree86 release was originally derived from +.I "X386\ 1.2" +by Thomas Roell which was contributed to X11R5 by Snitily Graphics +Consulting Service. +.SH PLATFORMS +.B Xorg +operates under a wide range of operating systems and hardware platforms. +The Intel x86 (IA32) architecture is the most widely supported hardware +platform. Other hardware platforms include Compaq Alpha, Intel IA64, AMD64, +SPARC and PowerPC. The most widely supported operating systems are the +free/OpenSource UNIX-like systems such as Linux, FreeBSD, NetBSD, +OpenBSD, and Solaris. Commercial UNIX operating systems such as +UnixWare are also supported. Other supported operating systems include +GNU Hurd. Mac OS X is supported with the +.BR Xquartz (1) +X server. Win32/Cygwin is supported with the +.BR XWin (1) +X server. +.SH "NETWORK CONNECTIONS" +.B Xorg +supports connections made using the following reliable +byte-streams: +.TP 4 +.I "Local" +On most platforms, the "Local" connection type is a UNIX-domain socket. +On some System V platforms, the "local" connection types also include +STREAMS pipes, named pipes, and some other mechanisms. +See the "LOCAL CONNECTIONS" section of +.BR X (7) +for details. +.TP 4 +.I TCP/IP +.B Xorg +listens on port +.RI 6000+ n , +where +.I n +is the display number. This connection type is usually disabled by default, +but may be enabled with the +.B \-listen +option (see the +.BR Xserver (1) +man page for details). +.SH OPTIONS +.B Xorg +supports several mechanisms for supplying/obtaining configuration and +run-time parameters: command line options, environment variables, the +.BR xorg.conf (5) +configuration files, auto-detection, and +fallback defaults. When the same information is supplied in more than +one way, the highest precedence mechanism is used. The list of mechanisms +is ordered from highest precedence to lowest. Note that not all parameters +can be supplied via all methods. The available command line options +and environment variables (and some defaults) are described here and in the +.BR Xserver (1) +manual page. Most configuration file +parameters, with their defaults, are described in the +.BR xorg.conf (5) +manual page. Driver and module specific +configuration parameters are described in the relevant driver or module +manual page. +.PP +In addition to the normal server options described in the +.BR Xserver (1) +manual page, +.B Xorg +accepts the following command line switches: +.TP 8 +.BI vt XX +.I XX +specifies the Virtual Terminal device number which +.B Xorg +will use. Without this option, +.B Xorg +will pick the first available Virtual Terminal that it can locate. This +option applies only to platforms that have virtual terminal support, such +as Linux, BSD, OpenSolaris, SVR3, and SVR4. +.TP +.B \-allowMouseOpenFail +Allow the server to start up even if the mouse device can't be opened +or initialised. This is equivalent to the +.B AllowMouseOpenFail +.BR xorg.conf (5) +file option. +.TP 8 +.B \-allowNonLocalXvidtune +Make the VidMode extension available to remote clients. This allows +the xvidtune client to connect from another host. This is equivalent +to the +.B AllowNonLocalXvidtune +.BR xorg.conf (5) +file option. +By default non-local connections are not allowed. +.TP 8 +.BI \-bgamma " value" +Set the blue gamma correction. +.I value +must be between 0.1 and 10. +The default is 1.0. Not all drivers support this. See also the +.BR \-gamma , +.BR \-rgamma , +and +.B \-ggamma +options. +.TP 8 +.BI \-bpp " n" +No longer supported. Use +.B \-depth +to set the color depth, and use +.B \-fbbpp +if you really need to force a non-default framebuffer (hardware) pixel +format. +.TP 8 +.BI \-config " file" +Read the server configuration from +.IR file . +This option will work for any file when the server is run as root (i.e, +with real-uid 0), or for files relative to a directory in the config +search path for all other users. +.TP 8 +.BI \-configdir " directory" +Read the server configuration files from +.IR directory . +This option will work for any directory when the server is run as root +(i.e, with real-uid 0), or for directories relative to a directory in the +config directory search path for all other users. +.TP 8 +.B \-configure +When this option is specified, the +.B Xorg +server loads all video driver modules, probes for available hardware, +and writes out an initial +.BR xorg.conf (5) +file based on what was detected. +This option currently has some problems on some platforms, +but in most cases it is a good way to bootstrap the configuration process. +This option is only available when the server +is run as root (i.e, with real-uid 0). +.TP 8 +.BI "\-crt /dev/tty" XX +SCO only. This is the same as the +.B vt +option, and is provided for compatibility with the native SCO X server. +.TP 8 +.BI \-depth " n" +Sets the default color depth. Legal values are 1, 4, 8, 15, 16, and +24. Not all drivers support all values. +.TP 8 +.B \-disableVidMode +Disable the parts of the VidMode extension (used by the xvidtune +client) that can be used to change the video modes. This is equivalent +to the +.B DisableVidModeExtension +.BR xorg.conf (5) +file option. +.TP 8 +.B \-fbbpp \fIn\fP +Sets the number of framebuffer bits per pixel. You should only set this +if you're sure it's necessary; normally the server can deduce the correct +value from +.B \-depth +above. Useful if you want to run a depth 24 configuration with a 24 +bpp framebuffer rather than the (possibly default) 32 bpp framebuffer +(or vice versa). Legal values are 1, 8, 16, 24, 32. Not all drivers +support all values. +.TP 8 +.B \-flipPixels +Swap the default values for the black and white pixels. +.TP 8 +.BI \-gamma " value" +Set the gamma correction. +.I value +must be between 0.1 and 10. The default is 1.0. This value is applied +equally to the R, G and B values. Those values can be set independently +with the +.BR \-rgamma , +.BR \-bgamma , +and +.B \-ggamma +options. Not all drivers support this. +.TP 8 +.BI \-ggamma " value" +Set the green gamma correction. +.I value +must be between 0.1 and 10. The default is 1.0. Not all drivers support +this. See also the +.BR \-gamma , +.BR \-rgamma , +and +.B \-bgamma +options. +.TP 8 +.B \-ignoreABI +The +.B Xorg +server checks the ABI revision levels of each module that it loads. It +will normally refuse to load modules with ABI revisions that are newer +than the server's. This is because such modules might use interfaces +that the server does not have. When this option is specified, mismatches +like this are downgraded from fatal errors to warnings. This option +should be used with care. +.TP 8 +.B \-isolateDevice \fIbus\-id\fP +Restrict device resets to the device at +.IR bus\-id . +The +.I bus\-id +string has the form +.IB bustype : bus : device : function +(e.g., \(oqPCI:1:0:0\(cq). +At present, only isolation of PCI devices is supported; i.e., this option +is ignored if +.I bustype +is anything other than \(oqPCI\(cq. +.TP 8 +.B \-keeptty +Prevent the server from detaching its initial controlling terminal. If you +want to use systemd-logind integration you must specify this option. +Not all platforms support (or can use) this option. +.TP 8 +.BI \-keyboard " keyboard-name" +Use the +.BR xorg.conf (5) +file +.B InputDevice +section called +.I keyboard-name +as the core keyboard. This option is ignored when the +.B Layout +section specifies a core keyboard. In the absence of both a Layout +section and this option, the first relevant +.B InputDevice +section is used for the core keyboard. +.TP 8 +.BI \-layout " layout-name" +Use the +.BR xorg.conf (5) +file +.B Layout +section called +.IR layout-name . +By default the first +.B Layout +section is used. +.TP 8 +.BI \-logfile " filename" +Use the file called +.I filename +as the +.B Xorg +server log file. The default log file when running as root is +.BI /tmp/Xorg. n .log +and for non root it is +.BI $XDG_STATE_HOME/xorg/Xorg. n .log +where +.I n +is the display number of the +.B Xorg +server. The default may be in a different directory on some platforms. +This option is only available when the server is run as root (i.e, with +real-uid 0). +.TP 8 +.BR \-logverbose " [\fIn\fP]" +Sets the verbosity level for information printed to the +.B Xorg +server log file. If the +.I n +value isn't supplied, each occurrence of this option increments the log +file verbosity level. When the +.I n +value is supplied, the log file verbosity level is set to that value. +The default log file verbosity level is 3. +.TP 8 +.BR \-syslogverbose " [\fIn\fP]" +Sets the verbosity level for information printed to syslog. If the +.I n +value isn't supplied, each occurrence of this option increments the log +file verbosity level. When the +.I n +value is supplied, the log file verbosity level is set to that value. +The default log file verbosity level is 0 (silent). +.TP 8 +.BI \-modulepath " searchpath" +Set the module search path to +.IR searchpath . +.I searchpath +is a comma separated list of directories to search for +.B Xorg +server modules. This option is only available when the server is run +as root (i.e, with real-uid 0). +.TP 8 +.B \-noautoBindGPU +Disable automatically setting secondary GPUs up as output sinks and offload +sources. This is equivalent to setting the +.B AutoBindGPU +.BR xorg.conf (5) +file option. To +.B false. +.TP 8 +.B \-nosilk +Disable Silken Mouse support. +.TP 8 +.B \-novtswitch +Disable the automatic switching on X server reset and shutdown to the +VT that was active when the server started, if supported by the OS. +.TP 8 +.BI \-pointer " pointer-name" +Use the +.BR xorg.conf (5) +file +.B InputDevice +section called +.I pointer-name +as the core pointer. This option is ignored when the +.B Layout +section specifies a core pointer. In the absence of both a Layout +section and this option, the first relevant +.B InputDevice +section is used for the core pointer. +.TP 8 +.B \-quiet +Suppress most informational messages at startup. The verbosity level +is set to zero. +.TP 8 +.BI \-rgamma " value" +Set the red gamma correction. +.I value +must be between 0.1 and 10. The default is 1.0. Not all drivers support +this. See also the +.BR \-gamma , +.BR \-bgamma , +and +.B \-ggamma +options. +.TP 8 +.B \-sharevts +Share virtual terminals with another X server, if supported by the OS. +.TP 8 +.BI \-screen " screen-name" +Use the +.BR xorg.conf (5) +file +.B Screen +section called +.IR screen-name . +By default the screens referenced by the default +.B Layout +section are used, or the first +.B Screen +section when there are no +.B Layout +sections. +.TP 8 +.B \-showconfig +This is the same as the +.B \-version +option, and is included for compatibility reasons. It may be removed +in a future release, so the +.B \-version +option should be used instead. +.TP 8 +.B \-showDefaultModulePath +Print out the default module path the server was compiled with. +.TP 8 +.B \-showDefaultLibPath +Print out the path libraries should be installed to. +.TP 8 +.B \-showopts +For each driver module installed, print out the list of options and their +argument types. +.TP 8 +.BI \-weight " nnn" +Set RGB weighting at 16 bpp. The default is 565. This applies only to +those drivers which support 16 bpp. +.TP 8 +.BR \-verbose " [\fIn\fP]" +Sets the verbosity level for information printed on stderr. If the +.I n +value isn't supplied, each occurrence of this option increments the +verbosity level. When the +.I n +value is supplied, the verbosity level is set to that value. The default +verbosity level is 0. +.TP 8 +.B \-version +Print out the server version, patchlevel, release date, the operating +system/platform it was built on, and whether it includes module loader +support. +.SH "KEYBOARD" +The +.B Xorg +server is normally configured to recognize various special combinations +of key presses that instruct the server to perform some action, rather +than just sending the key press event to a client application. These actions +depend on the XKB keymap loaded by a particular keyboard device and may or +may not be available on a given configuration. +.PP +The following key combinations are commonly part of the default XKEYBOARD +keymap. +.TP 8 +.B Ctrl+Alt+Backspace +Immediately kills the server -- no questions asked. It can be disabled by +setting the +.B DontZap +.BR xorg.conf (5) +file option to a TRUE value. +.PP +.RS 8 +It should be noted that zapping is triggered by the +.B Terminate_Server +action in the keyboard map. This action is not part of the default keymaps +but can be enabled with the XKB option +.B \*qterminate:ctrl_alt_bksp\*q. +.RE +.TP 8 +.B Ctrl+Alt+Keypad-Plus +Change video mode to next one specified in the configuration file. +This can be disabled with the +.B DontZoom +.BR xorg.conf (5) +file option. +.TP 8 +.B Ctrl+Alt+Keypad-Minus +Change video mode to previous one specified in the configuration file. +This can be disabled with the +.B DontZoom +.BR xorg.conf (5) +file option. +.TP 8 +.B Ctrl+Alt+F1...F12 +For systems with virtual terminal support, these keystroke +combinations are used to switch to virtual terminals 1 through 12, +respectively. This can be disabled with the +.B DontVTSwitch +.BR xorg.conf (5) +file option. +.SH CONFIGURATION +.B Xorg +typically uses a configuration file called +.B xorg.conf +and configuration files with the suffix +.I .conf +in a directory called +.B xorg.conf.d +for its initial setup. +Refer to the +.BR xorg.conf (5) +manual page for information about the format of this file. +.PP +.B Xorg +has a mechanism for automatically generating a built-in configuration +at run-time when no +.B xorg.conf +file or +.B xorg.conf.d +files are present. The current version of this automatic configuration +mechanism works in two ways. +.PP +The first is via enhancements that have made many components of the +.B xorg.conf +file optional. This means that information that can be probed or +reasonably deduced doesn't need to be specified explicitly, greatly +reducing the amount of built-in configuration information that needs to +be generated at run-time. +.PP +The second is to have "safe" fallbacks for most configuration information. +This maximises the likelihood that the +.B Xorg +server will start up in some usable configuration even when information +about the specific hardware is not available. +.PP +The automatic configuration support for Xorg is work in progress. +It is currently aimed at the most popular hardware and software platforms +supported by Xorg. Enhancements are planned for future releases. +.SH FILES +The +.B Xorg +server config files can be found in a range of locations. +These are documented fully in the +.BR xorg.conf (5) +manual page. +The most commonly used locations are shown here. +.TP 30 +.B /etc/X11/xorg.conf +Server configuration file. +.TP 30 +.B /etc/X11/xorg.conf-4 +Server configuration file. +.TP 30 +.B /etc/xorg.conf +Server configuration file. +.TP 30 +.B /usr/etc/xorg.conf +Server configuration file. +.TP 30 +.B /usr/lib/X11/xorg.conf +Server configuration file. +.TP 30 +.B /etc/X11/xorg.conf.d +Server configuration directory. +.TP 30 +.B /etc/X11/xorg.conf.d-4 +Server configuration directory. +.TP 30 +.B /etc/xorg.conf.d +Server configuration directory. +.TP 30 +.B /usr/etc/xorg.conf.d +Server configuration directory. +.TP 30 +.B /usr/lib/X11/xorg.conf.d +Server configuration directory. +.TP 30 +.BI /tmp/Xorg. n .log +Server log file for display +.IR n . +.TP 30 +.B /usr/bin/\(** +Client binaries. +.TP 30 +.B /usr/include/\(** +Header files. +.TP 30 +.B /usr/lib/\(** +Libraries. +.TP 30 +.B /usr/share/fonts/X11/\(** +Fonts. +.TP 30 +.B /usr/share/X11/XErrorDB +Client error message database. +.TP 30 +.B /usr/lib/X11/app-defaults/\(** +Client resource specifications. +.TP 30 +.B /usr/share/man/man?/\(** +Manual pages. +.TP 30 +.BI /etc/X n .hosts +Initial access control list for display +.IR n . +.SH "SEE ALSO" +.BR X (7), +.BR Xserver (1), +.BR xdm (1), +.BR xinit (1), +.BR xorg.conf (5), +.BR xvidtune (1), +.BR xkeyboard-config (7), +.BR apm (4), +.BR ati (4), +.BR chips (4), +.BR cirrus (4), +.BR cyrix (4), +.BR fbdev (4), +.BR glide (4), +.BR glint (4), +.BR i128 (4), +.BR i740 (4), +.BR imstt (4), +.BR intel (4), +.BR mga (4), +.BR neomagic (4), +.BR nsc (4), +.BR nv (4), +.BR openchrome (4), +.BR r128 (4), +.BR rendition (4), +.BR s3virge (4), +.BR siliconmotion (4), +.BR sis (4), +.BR sunbw2 (4), +.BR suncg14 (4), +.BR suncg3 (4), +.BR suncg6 (4), +.BR sunffb (4), +.BR sunleo (4), +.BR suntcx (4), +.BR tdfx (4), +.BR tga (4), +.BR trident (4), +.BR tseng (4), +.BR v4l (4), +.BR vesa (4), +.BR vmware (4), +.br +Web site +.IR . + +.SH AUTHORS +Xorg has many contributors world wide. The names of most of them +can be found in the documentation, ChangeLog files in the source tree, +and in the actual source code. +.PP +Xorg was originally based on XFree86 4.4rc2. +That was originally based on \fIX386 1.2\fP by Thomas Roell, which +was contributed to the then X Consortium's X11R5 distribution by SGCS. +.PP +Xorg is released by the X.Org Foundation. +.PP +The project that became XFree86 was originally founded in 1992 by +David Dawes, Glenn Lai, Jim Tsillas and David Wexelblat. +.PP +XFree86 was later integrated in the then X Consortium's X11R6 release +by a group of dedicated XFree86 developers, including the following: +.PP +.RS 4 +.nf +Stuart Anderson \fIanderson@metrolink.com\fP +Doug Anson \fIdanson@lgc.com\fP +Gertjan Akkerman \fIakkerman@dutiba.twi.tudelft.nl\fP +Mike Bernson \fImike@mbsun.mlb.org\fP +Robin Cutshaw \fIrobin@XFree86.org\fP +David Dawes \fIdawes@XFree86.org\fP +Marc Evans \fImarc@XFree86.org\fP +Pascal Haible \fIhaible@izfm.uni-stuttgart.de\fP +Matthieu Herrb \fIMatthieu.Herrb@laas.fr\fP +Dirk Hohndel \fIhohndel@XFree86.org\fP +David Holland \fIdavidh@use.com\fP +Alan Hourihane \fIalanh@fairlite.demon.co.uk\fP +Jeffrey Hsu \fIhsu@soda.berkeley.edu\fP +Glenn Lai \fIglenn@cs.utexas.edu\fP +Ted Lemon \fImellon@ncd.com\fP +Rich Murphey \fIrich@XFree86.org\fP +Hans Nasten \fInasten@everyware.se\fP +Mark Snitily \fImark@sgcs.com\fP +Randy Terbush \fIrandyt@cse.unl.edu\fP +Jon Tombs \fItombs@XFree86.org\fP +Kees Verstoep \fIversto@cs.vu.nl\fP +Paul Vixie \fIpaul@vix.com\fP +Mark Weaver \fIMark_Weaver@brown.edu\fP +David Wexelblat \fIdwex@XFree86.org\fP +Philip Wheatley \fIPhilip.Wheatley@ColumbiaSC.NCR.COM\fP +Thomas Wolfram \fIwolf@prz.tu-berlin.de\fP +Orest Zborowski \fIorestz@eskimo.com\fP +.fi +.RE +.PP +Xlibre source is available via git \fI\fP. + +.SH LEGAL +.B Xorg +is copyright software, provided under licenses that permit modification +and redistribution in source and binary form without fee. +.B Xorg is copyright by numerous authors and +contributors from around the world. Licensing information can be found +at +.IR . +Refer to the source code for specific copyright notices. +.PP +.B XFree86(TM) +is a trademark of The XFree86 Project, Inc. +.PP +.B X11(TM) +and +.B X Window System(TM) +are trademarks of The Open Group. diff --git a/prebuilt/xlibre/usr/share/man/man1/Xserver.1 b/prebuilt/xlibre/usr/share/man/man1/Xserver.1 new file mode 100644 index 0000000..866f701 --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man1/Xserver.1 @@ -0,0 +1,664 @@ +'\" t +.\" +.\" Copyright 1984 - 1991, 1993, 1994, 1998 The Open Group +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and its +.\" documentation for any purpose is hereby granted without fee, provided that +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation. +.\" +.\" The above copyright notice and this permission notice shall be included +.\" in all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +.\" OTHER DEALINGS IN THE SOFTWARE. +.\" +.\" Except as contained in this notice, the name of The Open Group shall +.\" not be used in advertising or otherwise to promote the sale, use or +.\" other dealings in this Software without prior written authorization +.\" from The Open Group. +.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.31 2004/01/10 22:27:46 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH XSERVER 1 "xorg-server 25.2.0" "X Version 11" +.SH NAME +Xserver \- X Window System display server +.SH SYNOPSIS +.B X +[option \&...\&] +.SH DESCRIPTION +.I X +is the generic name for the X Window System display server. It is +frequently a link or a copy of the appropriate server binary for +driving the most frequently used server on a given machine. +.SH "STARTING THE SERVER" +The X server is usually started from the X Display Manager program +.BR xdm (1) +or a similar display manager program. +This utility is run from the system boot files and takes care of keeping +the server running, prompting for usernames and passwords, and starting up +the user sessions. +.PP +Installations that run more than one window system may need to use the +.BR xinit (1) +utility instead of a display manager. However, \fIxinit\fP is +to be considered a tool for building startup scripts and is not +intended for use by end users. Site administrators are \fBstrongly\fP +urged to use a display manager, or build other interfaces for novice users. +.PP +The X server may also be started directly by the user, though this +method is usually reserved for testing and is not recommended for +normal operation. On some platforms, the user must have special +permission to start the X server, often because access to certain +devices (e.g.\& \fI/dev/mouse\fP) is restricted. Where applicable, the +X server notifies systemd when it is ready to process requests. +.PP +When the X server starts up, it typically takes over the display. If +you are running on a workstation whose console is the display, you may +not be able to log into the console while the server is running. +.SH OPTIONS +Many X servers have device-specific command line options. See the manual +pages for the individual servers for more details; a list of +server-specific manual pages is provided in the SEE ALSO section below. +.PP +All of the X servers accept the command line options described below. +Some X servers may have alternative ways of providing the parameters +described here, but the values provided via the command line options +should override values specified via other mechanisms. +.TP 8 +.B :\fIdisplaynumber\fP +The X server runs as the given \fIdisplaynumber\fP, which by default is 0. +If multiple X servers are to run simultaneously on a host, each must have +a unique display number. +See the DISPLAY NAMES section of the +.BR X (7) +manual page to learn how to +specify which display number clients should try to use. +.TP 8 +.B \-a \fInumber\fP +sets pointer acceleration (i.e., the ratio of how much is reported to how much +the user actually moved the pointer). +.TP 8 +.B \-ac +disables host-based access control mechanisms. Enables access by any host, +and permits any host to modify the access control list. +Use with extreme caution. +This option exists primarily for running test suites remotely. +.TP 8 +.B \-audit \fIlevel\fP +sets the audit trail level. The default level is 1, meaning only connection +rejections are reported. Level 2 additionally reports all successful +connections and disconnects. Level 4 enables messages from the +SECURITY extension, if present, including generation and revocation of +authorizations and violations of the security policy. +Level 0 turns off the audit trail. +Audit lines are sent as standard error output. +.TP 8 +.B \-auth \fIauthorization-file\fP +specifies a file which contains a collection of authorization records used +to authenticate access. +See also the +.BR xdm (1) +and +.BR Xsecurity (7) +manual pages. +.TP 8 +.B \-background none +Asks the driver not to clear the background on startup, +if the driver supports that. +May be useful for smooth transition with e.g.\& fbdev driver. +For security reasons this is not the default as the screen contents might +show a previous user session. +.TP 8 +.B \-br +sets the default root window to solid black instead of the standard root weave +pattern. +This is the default unless \-retro or \-wr is specified. +.TP 8 +.B \-bs +disables backing store support on all screens. +.TP 8 +.B +byteswappedclients +Allow connections from clients with an endianness different to that of the +server. +.TP 8 +.B \-byteswappedclients +Prohibit connections from clients with an endianness different to that of the +server. +This is the default unless \fB+byteswappedclients\fP is specified. +.TP 8 +.B \-c +turns off key-click. +.TP 8 +.B c \fIvolume\fP +sets key-click volume (allowable range: 0\(en100). +.TP 8 +.B \-cc \fIclass\fP +sets the visual class for the root window of color screens. +The class numbers are as specified in the X protocol. +Not obeyed by all servers. +.TP 8 +.B \-core +causes the server to generate a core dump on fatal errors. +.TP 8 +.B \-displayfd \fIfd\fP +specifies a file descriptor in the launching process. Rather than specify +a display number, the X server will attempt to listen on successively higher +display numbers, and upon finding a free one, will write the display number back +on this file descriptor as a newline-terminated string. The \-pn option is +ignored when using \-displayfd. +.TP 8 +.B \-deferglyphs \fIwhichfonts\fP +specifies the types of fonts for which the server should attempt to use +deferred glyph loading. \fIwhichfonts\fP can be all (all fonts), +none (no fonts), or 16 (16 bit fonts only). +.TP 8 +.B \-dpi \fIresolution\fP +sets the resolution for all screens, in dots per inch. +To be used when the server cannot determine the screen size(s) from the +hardware. +.TP 8 +.B dpms +enables DPMS (display power management services), where supported. The +default state is platform and configuration specific. +.TP 8 +.B \-dpms +disables DPMS (display power management services). The default state +is platform and configuration specific. +.TP 8 +.BI "\-extension " extensionName +disables named extension. +If an unknown extension name is specified, +a list of accepted extension names is printed. +.TP 8 +.BI "+extension " extensionName +enables named extension. +If an unknown extension name is specified, +a list of accepted extension names is printed. +.TP 8 +.B \-f \fIvolume\fP +sets beep (bell) volume (allowable range: 0\(en100). +.TP 8 +.B \-fakescreenfps \fIfps\fP +sets fake presenter screen default fps (allowable range: 1\(en600). +.TP 8 +.B \-fp \fIfontPath\fP +sets the search path for fonts. This path is a comma-separated list +of directories which the X server searches for font databases. +See the FONTS section of this manual page for more information and the default +list. +.TP 8 +.B \-fontserverconnections +Prohibit font server connections in the font path. Font servers are +rarely used and are a source of security vulnerabilities. +This is the default unless +fontserverconnections is specified. +.TP 8 +.B +fontserverconnections +Allow font server connections in the font path. +.TP 8 +.B \-help +prints a usage message. +.TP 8 +.B \-I +causes all remaining command line arguments to be ignored. +.TP 8 +.B \-iglx +Prohibit creating indirect GLX contexts. Indirect GLX is of limited use, +since it lacks support for many modern OpenGL features and extensions; +it's slower than direct contexts; and it opens a large attack surface for +protocol parsing errors. +This is the default unless +iglx is specified. +.TP 8 +.B +iglx +Allow creating indirect GLX contexts. +.TP 8 +.B \-maxbigreqsize \fIsize\fP +sets the maximum big request to +.I size +MB. +.TP 8 +.B \-nocursor +disable the display of the pointer cursor. +.TP 8 +.B \-nolisten \fItrans-type\fP +disables a transport type. For example, TCP/IP connections can be disabled +with +.BR "\-nolisten tcp" . +This option may be issued multiple times to disable listening to different +transport types. +Supported transport types are platform dependent, but commonly include: +.TS +l l. +tcp TCP over IPv4 or IPv6 +inet TCP over IPv4 only +inet6 TCP over IPv6 only +unix UNIX Domain Sockets +local Platform preferred local connection method +.TE +.TP 8 +.B \-listen \fItrans-type\fP +enables a transport type. For example, TCP/IP connections can be enabled +with +.BR "\-listen tcp" . +This option may be issued multiple times to enable listening to different +transport types. +.TP 8 +.B \-terminate +command line option. +.TP 8 +.B \-p \fIminutes\fP +sets screen-saver pattern cycle time in minutes. +.TP 8 +.B \-pn +permits the server to continue running if it fails to establish all of +its well-known sockets (connection points for clients), but +establishes at least one. This option is set by default. +.TP 8 +.B \-nopn +causes the server to exit if it fails to establish all of its well-known +sockets (connection points for clients). +.TP 8 +.B \-r +turns off auto-repeat. +.TP 8 +.B r +turns on auto-repeat. +.TP 8 +.B \-retro +starts the server with the classic stipple and cursor visible. The default +is to start with a black root window, and to suppress display of the cursor +until the first time an application calls XDefineCursor(). +For kdrive servers, this implies \-zap. +.TP 8 +.B \-s \fIminutes\fP +sets screen-saver timeout time in minutes. +.TP 8 +.B \-su +disables save under support on all screens. +.TP 8 +.B \-seat \fIseat\fP +seat to run on. Takes a string identifying a seat in a platform +specific syntax. On platforms which support this feature this may be +used to limit the server to expose only a specific subset of devices +connected to the system. +.TP 8 +.B \-t \fInumber\fP +sets pointer acceleration threshold in pixels (i.e., after how many pixels +pointer acceleration should take effect). +.TP 8 +.BR \-terminate " ["\c +.IR delay ] +causes the server to terminate at server reset, instead of continuing to run. +This overrides a previous +.B \-noreset +command line option. +If a delay in seconds is specified, the server waits for at least +the delay. At the end of this grace period if no client is +connected, the server terminates immediately. +.TP 8 +.B \-tst +disables all testing extensions (e.g., XTEST, XTrap, XTestExtension1, RECORD). +.TP 8 +.B tty\fIxx\fP +ignored, for servers started the ancient way (from init). +.TP 8 +.B v +sets video-off screen-saver preference. +.TP 8 +.B \-v +sets video-on screen-saver preference. +.TP 8 +.BR \-verbose " [\fIn\fP]" +Sets the verbosity level for information printed on stderr. If the +.I n +value isn't supplied, each occurrence of this option increments the +verbosity level. When the +.I n +value is supplied, the verbosity level is set to that value. The default +verbosity level is 0. +.TP 8 +.B \-wr +sets the default root window to solid white instead of the standard root weave +pattern. +.TP 8 +.B \-x \fIextension\fP +loads the specified extension at init. +This is a no-op for most implementations. +.TP 8 +.RB [ +\- ] xinerama +enables(+) or disables(\-) the XINERAMA extension. The default state is +platform and configuration specific. +.SH SERVER DEPENDENT OPTIONS +Some X servers accept the following options: +.TP 8 +.B \-maxclients +.BR 64 | 128 | 256 | 512 +Set the maximum number of clients allowed to connect to the X server. +Acceptable values are 64, 128, 256 or 512. +.TP 8 +.B \-render +.BR default | mono | gray | color +sets the color allocation policy that will be used by the render extension. +.RS 8 +.TP 8 +.I default +selects the default policy defined for the display depth of the X +server. +.TP 8 +.I mono +don't use any color cell. +.TP 8 +.I gray +use a gray map of 13 color cells for the X render extension. +.TP 8 +.I color +use a color cube of at most 4*4*4 colors (that is 64 color cells). +.RE +.TP 8 +.B \-dumbSched +disables smart scheduling on platforms that support the smart scheduler. +.TP +.B \-schedInterval \fIinterval\fP +sets the smart scheduler's scheduling interval to +.I interval +milliseconds. +.SH XDMCP OPTIONS +X servers that support XDMCP have the following options. +See the \fIX Display Manager Control Protocol\fP specification for more +information. +.TP 8 +.B \-query \fIhostname\fP +enables XDMCP and sends Query packets to the specified +.IR hostname . +.TP 8 +.B \-broadcast +enable XDMCP and broadcasts BroadcastQuery packets to the network. The +first responding display manager will be chosen for the session. +.TP 8 +.BR \-multicast " ["\c +.IR address " [" "hop count" ]] +Enable XDMCP and multicast BroadcastQuery packets to the network. +The first responding display manager is chosen for the session. If an +address is specified, the multicast is sent to that address. If no +address is specified, the multicast is sent to the default XDMCP IPv6 +multicast group. If a hop count is specified, it is used as the maximum +hop count for the multicast. If no hop count is specified, the multicast +is set to a maximum of 1 hop, to prevent the multicast from being routed +beyond the local network. +.TP 8 +.B \-indirect \fIhostname\fP +enables XDMCP and send IndirectQuery packets to the specified +.IR hostname . +.TP 8 +.B \-port \fIport-number\fP +uses the specified \fIport-number\fP for XDMCP packets, instead of the +default. This option must be specified before any \-query, \-broadcast, +\-multicast, or \-indirect options. +.TP 8 +.B \-from \fIlocal-address\fP +specifies the local address to connect from (useful if the connecting host +has multiple network interfaces). The \fIlocal-address\fP may be expressed +in any form acceptable to the host platform's \fIgethostbyname\fP(3) +implementation. +.TP 8 +.B \-class \fIdisplay-class\fP +XDMCP has an additional display qualifier used in resource lookup for +display-specific options. This option sets that value, by default it +is "MIT-unspecified" (not a very useful value). +.TP 8 +.B \-cookie \fIxdm-auth-bits\fP +When testing XDM-AUTHENTICATION-1, a private key is shared between the +server and the manager. This option sets the value of that private +data (not that it is very private, being on the command line!). +.TP 8 +.B \-displayID \fIdisplay-id\fP +Yet another XDMCP specific value, this one allows the display manager to +identify each display so that it can locate the shared key. +.SH XKEYBOARD OPTIONS +X servers that support the XKEYBOARD (a.k.a.\& \*qXKB\*q) extension accept the +following options. All layout files specified on the command line must be +located in the XKB base directory or a subdirectory, and specified as the +relative path from the XKB base directory. The default XKB base directory is +.IR /usr/lib/X11/xkb . +.TP 8 +.RB [ +\- ] accessx " [ \fItimeout\fP [ \fItimeout_mask\fP [ \ +\fIfeedback\fP [ \fIoptions_mask\fP ] ] ] ]" +enables(+) or disables(\-) AccessX key sequences. +.TP 8 +.B \-xkbdir \fIdirectory\fP +base directory for keyboard layout files. This option is not available +for setuid X servers (i.e., when the X server's real and effective uids +are different). +.TP 8 +.B \-ardelay \fImilliseconds\fP +sets the autorepeat delay (length of time in milliseconds that a key must +be depressed before autorepeat starts). +.TP 8 +.B \-arinterval \fImilliseconds\fP +sets the autorepeat interval (length of time in milliseconds that should +elapse between autorepeat-generated keystrokes). +.TP 8 +.B \-xkbmap \fIfilename\fP +loads keyboard description in \fIfilename\fP on server startup. +.SH "NETWORK CONNECTIONS" +The X server supports client connections via a platform-dependent subset of +the following transport types: TCP/IP, Unix Domain sockets, +and several varieties of SVR4 local connections. +See the DISPLAY NAMES section of the +.BR X (7) +manual page to learn how to +specify which transport type clients should try to use. +.SH GRANTING ACCESS +The X server implements a platform-dependent subset of the following +authorization protocols: MIT-MAGIC-COOKIE-1, XDM-AUTHORIZATION-1, +Host Access, and Server Interpreted. +See the +.BR Xsecurity (7) +manual page for information on the operation of these protocols. +.PP +Authorization data required by the above protocols is passed to the +server in a private file named with the \fB\-auth\fP command line +option. Each time the server is about to accept the first connection +after a reset (or when the server is starting), it reads this file. +If this file contains any authorization records, the local host is not +automatically allowed access to the server, and only clients which +send one of the authorization records contained in the file in the +connection setup information will be allowed access. See the +.BR Xau (3) +manual page for a description of the binary format of this file. See +.BR xauth (1) +for maintenance of this file, and distribution of its contents to remote hosts. +.PP +The X server also uses a host-based access control list for deciding +whether or not to accept connections from clients on a particular machine. +If no other authorization mechanism is being used, +this list initially consists of the host on which the server is running as +well as any machines listed in the file \fI/etc/X\fBn\fI.hosts\fR, where +\fBn\fP is the display number of the server. Each line of the file should +contain either an Internet hostname (e.g., expo.lcs.mit.edu) +or a complete name in the format +\fIfamily\fP:\fIname\fP as described in the +.BR xhost (1) +manual page. +There should be no leading or trailing spaces on any lines. For example: +.sp +.in +8 +.nf +joesworkstation +corporate.company.com +inet:bigcpu +local: +.fi +.in -8 +.PP +Users can add or remove hosts from this list and enable or disable access +control using the \fIxhost\fP command from the same machine as the server. +.PP +The X protocol intrinsically does not have any notion of window operation +permissions or place any restrictions on what a client can do; if a program can +connect to a display, it has full run of the screen. +X servers that support the SECURITY extension fare better because clients +can be designated untrusted via the authorization they use to connect; see the +.BR xauth (1) +manual page for details. Restrictions are imposed +on untrusted clients that curtail the mischief they can do. See the SECURITY +extension specification for a complete list of these restrictions. +.PP +Sites that have better +authentication and authorization systems might wish to make +use of the hooks in the libraries and the server to provide additional +security models. +.SH SIGNALS +The X server attaches special meaning to the following signals: +.TP 8 +.I SIGHUP +This signal causes the server to close all existing connections, free all +resources, and restore all defaults. It is sent by the display manager +whenever the main user's main application (usually an \fIxterm\fP or window +manager) exits to force the server to clean up and prepare for the next +user. +.TP 8 +.I SIGTERM +This signal causes the server to exit cleanly. +.TP 8 +.I SIGUSR1 +This signal is used quite differently from either of the above. When the +server starts, it checks to see if it has inherited SIGUSR1 as SIG_IGN +instead of the usual SIG_DFL. In this case, the server sends a SIGUSR1 to +its parent process after it has set up the various connection schemes. +\fIXdm\fP uses this feature to recognize when connecting to the server +is possible. +.SH FONTS +The X server can obtain fonts from directories and/or from font servers. +The list of directories and font servers +the X server uses when trying to open a font is controlled +by the \fIfont path\fP. +.LP +The default font path is +/usr/share/fonts/misc,\:/usr/share/fonts/TTF,\:/usr/share/fonts/OTF . +.LP +A special kind of directory can be specified using the \fBcatalogue\fP: +prefix. Directories specified this way can contain symlinks pointing to the +real font directories. See the FONTPATH.D section for details. +.LP +The font path can be set with the \fB\-fp\fP option or by +.BR xset (1) +after the server has started. +.SH "FONTPATH.D" +You can specify a special kind of font path in the form \fBcatalogue:\fR. +The directory specified after the catalogue: prefix will be scanned for symlinks +and each symlink destination will be added as a local fontfile FPE. +.PP +The symlink can be suffixed by attributes such as \&'\fBunscaled\fR', +which will be passed through to the underlying fontfile FPE. +The only exception is the newly introduced \&'\fBpri\fR' attribute, +which will be used for ordering the font paths specified by the symlinks. + +An example configuration: + +.nf + 75dpi:unscaled:pri=20 \-> /usr/share/X11/fonts/75dpi + ghostscript:pri=60 \-> /usr/share/fonts/default/ghostscript + misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc + type1:pri=40 \-> /usr/share/X11/fonts/Type1 + type1:pri=50 \-> /usr/share/fonts/default/Type1 +.fi + +This will add /usr/share/X11/fonts/misc as the first FPE with the attribute +\N'39'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with +the attribute \&'unscaled' etc. +This is functionally equivalent to setting the following font path: + +.nf + /usr/share/X11/fonts/misc:unscaled, + /usr/share/X11/fonts/75dpi:unscaled, + /usr/share/X11/fonts/Type1, + /usr/share/fonts/default/Type1, + /usr/share/fonts/default/ghostscript +.fi + +.SH FILES +.TP 30 +.I /etc/X\fBn\fP.hosts +Initial access control list for display number \fBn\fP +.TP 30 +.IR /usr/share/fonts/X11/misc ", " /usr/share/fonts/X11/75dpi ", " /usr/share/fonts/X11/100dpi +Bitmap font directories +.TP 30 +.IR /usr/share/fonts/X11/TTF ", " /usr/share/fonts/X11/Type1 +Outline font directories +.TP 30 +.I /tmp/.X11-unix/X\fBn\fP +Unix domain socket for display number \fBn\fP +.TP 30 +.I /usr/adm/X\fBn\fPmsgs +Error log file for display number \fBn\fP if run from +.BR init (8) +.TP 30 +.I /usr/lib/X11/xdm/xdm\-errors +Default error log file if the server is run from +.BR xdm (1) +.SH "SEE ALSO" +General information: +.BR X (7) +.PP +Protocols: +.I "X Window System Protocol," +.I "The X Font Service Protocol," +.I "X Display Manager Control Protocol" +.PP +Fonts: +.BR bdftopcf (1), +.BR mkfontdir (1), +.BR mkfontscale (1), +.BR xfs (1), +.BR xlsfonts (1), +.BR xfontsel (1), +.BR xfd (1), +.I "X Logical Font Description Conventions" +.PP +Keyboards: +.BR xkeyboard\-config (7) +.PP +Security: +.BR Xsecurity (7), +.BR xauth (1), +.BR Xau (3), +.BR xdm (1), +.BR xhost (1), +.I "Security Extension Specification" +.PP +Starting the server: +.BR startx (1), +.BR xdm (1), +.BR xinit (1) +.PP +Controlling the server once started: +.BR xset (1), +.BR xsetroot (1), +.BR xhost (1), +.BR xinput (1), +.BR xrandr (1) +.PP +Server-specific man pages: +.BR Xorg (1), +.BR Xephyr (1), +.BR Xnest (1), +.BR Xvfb (1), +.BR Xquartz (1), +.BR XWin (1). +.PP +Server internal documentation: +.I "Definition of the Porting Layer for the X v11 Sample Server" +.SH AUTHORS +The sample server was originally written by Susan Angebranndt, Raymond +Drewry, Philip Karlton, and Todd Newman, from Digital Equipment +Corporation, with support from a large cast. It has since been +extensively rewritten by Keith Packard and Bob Scheifler, from MIT. +Dave Wiggins took over post-R5 and made substantial improvements. diff --git a/prebuilt/xlibre/usr/share/man/man1/gtf.1 b/prebuilt/xlibre/usr/share/man/man1/gtf.1 new file mode 100644 index 0000000..f1ee5b1 --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man1/gtf.1 @@ -0,0 +1,45 @@ +.TH GTF 1 "xorg-server 25.2.0" "X Version 11" +.SH NAME +gtf - calculate VESA GTF mode lines +.SH SYNOPSIS +.B gtf +.I h-resolution +.I v-resolution +.I refresh +.RB [ \-v | \-\-verbose ] +.RB [ \-f | \-\-fbmode ] +.RB [ \-x | \-\-xorgmode ] +.SH DESCRIPTION +.I Gtf +is a utility for calculating VESA GTF modes. Given the desired +horizontal and vertical resolutions and refresh rate (in Hz), the parameters +for a matching VESA GTF mode are printed out. Two output formats are +supported: mode lines suitable for the Xorg +.BR xorg.conf (5) +file, and mode parameters suitable for the Linux +.BR fbset (8) +utility. + +.SH OPTIONS +.TP 8 +.BR \-v | \-\-verbose +Enable verbose printouts This shows a trace for each step of the +computation. +.TP 8 +.BR \-x | \-\-xorgmode +Print the mode parameters as Xorg-style mode lines. This is the +default format. +.TP 8 +.BR \-f | \-\-fbset +Print the mode parameters in a format suitable for +.BR fbset (8). +.SH "SEE ALSO" +.BR xorg.conf (5), +.BR cvt (1) +.SH AUTHOR +Andy Ritger. +.PP +This program is based on the Generalized Timing Formula (GTF(TM)) Standard +Version: 1.0, Revision: 1.0. The GTF Excel(TM) spreadsheet, a sample +(and the definitive) implementation of the GTF Timing Standard is +available at . diff --git a/prebuilt/xlibre/usr/share/man/man4/exa.4 b/prebuilt/xlibre/usr/share/man/man4/exa.4 new file mode 100644 index 0000000..ca55af1 --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man4/exa.4 @@ -0,0 +1,52 @@ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH EXA 4 "xorg-server 25.2.0" "X Version 11" +.SH NAME +exa \- new 2D acceleration architecture for X.Org +.SH DESCRIPTION +.B EXA +provides a simple API for video drivers to implement for 2D acceleration. +It is a module loaded by drivers, +and is not intended to be loaded on its own. +See your driver's manual page for how to enable +.BR EXA . +.PP +The +.B EXA +architecture is designed to make accelerating the Render extension simple +and efficient, +and results in various performance tradeoffs compared to XAA. +Some xorg.conf options are available for debugging performance issues +or driver rendering problems. +They are not intended for general use. +.TP +.BI "Option \*qEXANoComposite\*q \*q" boolean \*q +Disables acceleration of the Composite operation, +which is at the heart of the Render extension. +Not related to the Composite extension. +Default: No. +.TP +.BI "Option \*qEXANoUploadToScreen\*q \*q" boolean \*q +Disables acceleration of uploading pixmap data to the framebuffer. +Default: No. +.TP +.BI "Option \*qEXANoDownloadFromScreen\*q \*q" boolean \*q +Disables acceleration of downloading of pixmap data from the framebuffer. +.B NOTE: +Not usable with drivers which rely on DownloadFromScreen succeeding. +Default: No. +.TP +.BI "Option \*qMigrationHeuristic\*q \*q" anystr \*q +Chooses an alternate pixmap migration heuristic, +for debugging purposes. +The default is intended to be the best performing one for general use, +though others may help with specific use cases. +Available options include \*qalways\*q, +\*qgreedy\*q, +and \*qsmart\*q. +Default: always. +.SH SEE ALSO +.BR Xorg (1), +.BR xorg.conf (5). +.SH AUTHORS +Authors include: Keith Packard, Eric Anholt, Zack Rusin, and Michel D\(:anzer diff --git a/prebuilt/xlibre/usr/share/man/man4/fbdevhw.4 b/prebuilt/xlibre/usr/share/man/man4/fbdevhw.4 new file mode 100644 index 0000000..4718967 --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man4/fbdevhw.4 @@ -0,0 +1,32 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.man,v 1.1 2001/01/24 00:06:34 dawes Exp $ +.TH FBDEVHW 4 "xorg-server 25.2.0" "X Version 11" +.SH NAME +fbdevhw \- os-specific submodule for framebuffer device access +.SH DESCRIPTION +.B fbdevhw +provides functions for talking to a framebuffer device. It is +os-specific. It is a submodule used by other video drivers. +A +.B fbdevhw +module is currently available for linux framebuffer devices. +.PP +.BR fbdev (4) +is a non-accelerated driver which runs on top of the +fbdevhw module. fbdevhw can be used by other drivers too, this +is usually activated with `Option "UseFBDev"' in the device section. +.SH CONFIGURATION DETAILS +Drivers using this module, like fbdev, usually have options +for setting the desired framebuffer device in xorg.conf. +For drivers that don't, or if this isn't set in xorg.conf, +fbdevhw also reads the FRAMEBUFFER environment variable for +the path to the framebuffer device it should use. +.SH "SEE ALSO" +.BR Xorg (1), +.BR xorg.conf (5), +.BR xorgconfig (1), +.BR Xserver (1), +.BR X (7), +.BR fbdev (4) +.SH AUTHORS +Authors include: Gerd Knorr, based on the XF68_FBDev Server code +(Martin Schaller, Geert Uytterhoeven). diff --git a/prebuilt/xlibre/usr/share/man/man4/libinput.4 b/prebuilt/xlibre/usr/share/man/man4/libinput.4 new file mode 100644 index 0000000..e184d9f --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man4/libinput.4 @@ -0,0 +1,612 @@ +'\" t +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH LIBINPUT 4 2025-06-01 "xf86-input-libinput 25.0.1" +.SH NAME +libinput \- libinput-based X.Org input driver +.SH SYNOPSIS +.nf +.B "Section \*qInputDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qlibinput\*q" +.BI " Option \*qDevice\*q \*q" devpath \*q +\ \ ... +.B EndSection +.fi + +.SH NOTE +This is the man page for the X input driver. +If you are looking for the library documentation, go to +.B http://wayland.freedesktop.org/libinput/doc/ + +.SH DESCRIPTION +.B libinput +is an XLibre input driver based on libinput. +It therefore supports all input devices that libinput can handle, including +most mice, keyboards, tablets and touchscreens. +.PP +It is recommended that +.B libinput +devices are configured through the +.B InputClass +directive (refer to +.BR xorg.conf (5)) +instead of manual per-device configuration. +Devices configured using the +.B InputDevice +directive in the +.BR xorg.conf (5) +file are not hot-plug capable. + +.SH CONFIGURATION DETAILS +Please refer to +.BR xorg.conf (5) +for general configuration details +and for options that can be used with all input drivers. +This section only covers configuration details specific to this driver. +.PP +The following driver +.B Options +are supported: +.TP 7 +.BI "Option \*qAccelProfile\*q \*q" string \*q +Sets the pointer acceleration profile to the given profile. +Permitted values are +.BR adaptive , +.BR flat , +.BR custom . +Not all devices support this option or all profiles. +If a profile is unsupported, the default profile for this device is used. +For a description on the profiles and their behavior, +see the libinput documentation. +.TP 7 +.BI "Option \*qAccelSpeed\*q \*q" float \*q +Sets the pointer acceleration speed within the range [-1, 1]. +This only applies to the flat or adaptive profile. +.TP 7 +.BI "Option \*qAccelPointsFallback\*q \*q" string \*q +.TQ +.BI "Option \*qAccelPointsMotion\*q \*q" string \*q +.TQ +.BI "Option \*qAccelPointsScroll\*q \*q" string \*q +Sets the points of the Fallback/Motion/Scroll acceleration functions. +The string must be a space-separated list of +floating point non-negative numbers, e.g., +"0.0 1.0 2.4 2.5". +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.BI "Option \*qAccelStepFallback\*q \*q" float \*q +.TQ +.BI "Option \*qAccelStepMotion\*q \*q" float \*q +.TQ +.BI "Option \*qAccelStepScroll\*q \*q" float \*q +Sets the step between the points of the Fallback/Motion/Scroll +acceleration functions. +When a step of 0.0 is provided, +libinput's Fallback acceleration function is used. +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.BI "Option \*qButtonMapping\*q \*q" string \*q +Sets the logical button mapping for this device, see +.BR XSetPointerMapping (3). +The string must be a space-separated list of button mappings in the order of the +logical buttons on the device, starting with button 1. +The default mapping is "1 2 3 ... 32". +A mapping of 0 deactivates the button. +Multiple buttons can have the same mapping. +Invalid mapping strings are discarded and the default mapping +is used for all buttons. +Buttons not specified in the user's mapping use the default mapping. +See section +.B BUTTON MAPPING +for more details. +.TP 7 +.BI "Option \*qCalibrationMatrix\*q \*q" string \*q +A string of 9 space-separated floating point numbers, in the order +\*qa b c d e f g h i\*q. +Sets the calibration matrix to the 3x3 matrix where the first row is (abc), +the second row is (def) and the third row is (ghi). +.TP 7 +.BI "Option \*qClickMethod\*q \*q" string \*q +Enables a click method. +Permitted values are +.BR none , +.BR buttonareas , +.BR clickfinger . +Not all devices support all methods. +If an option is unsupported, the default click method for this device is used. +.TP 7 +.BI "Option \*qDisableWhileTyping\*q \*q" bool \*q +Indicates if the touchpad should be disabled while typing on the keyboard +(this does not apply to modifier keys such as Ctrl or Alt). +.TP 7 +.BI "Option \*qDevice\*q \*q" string \*q +Specifies the device through which the device can be accessed. +This will generally be of the form \*q/dev/input/eventX\*q, +where X is some integer. +When using +.B InputClass +directives, this option is set by the server. +The mapping from device node to hardware is system-dependent. +Property: "Device Node" (read-only). +.TP 7 +.BI "Option \*qDragLockButtons\*q \*q" "L1 B1 L2 B2 ..." \*q +Sets "drag lock buttons" that simulate a button logically down even when it has +been physically released. +To logically release a locked button, +a second click of the same button is required. +.IP +If the option is a single button number, that button acts as the +"meta" locking button for the next button number. +See section +.B BUTTON DRAG LOCK +for details. +.IP +If the option is a list of button number pairs, the first number of each +number pair is the lock button, the second number the logical button number +to be locked. +See section +.B BUTTON DRAG LOCK +for details. +.IP +For both meta and button pair configuration, +the button numbers are device button numbers, i.e. the +.B ButtonMapping +applies after drag lock. +.TP 7 +.BI "Option \*qHighResolutionWheelScrolling\*q \*q" bool \*q +Disables high-resolution wheel scroll events, enabled by default. When enabled, +the driver forwards only high-resolution wheel scroll events from libinput. +When disabled, the driver forwards legacy wheel scroll events instead. +.TP 7 +.BI "Option \*qHorizontalScrolling\*q \*q" bool \*q +Enables or disables horizontal scrolling. +When disabled, +this driver will discard any horizontal scroll events from libinput. +This does not disable horizontal scroll events from libinput; +it merely discards the horizontal axis from any scroll events. +Default is enabled. +.TP 7 +.BI "Option \*qLeftHanded\*q \*q" bool \*q +Enables left-handed button orientation, i.e. swapping left and right buttons. +.TP 7 +.BI "Option \*qMiddleEmulation\*q \*q" bool \*q +Enables middle button emulation. +When enabled, pressing the left and right +buttons simultaneously produces a middle mouse button click. +A synonym +.IP +.BI "Option \*qEmulate3Buttons\*q \*q" bool \*q +.IP +is preserved for compatibility with +.B evdev +driver, with +.BI "\*qMiddleEmulation\*q +having preference if both are set. +.TP 7 +.BI "Option \*qNaturalScrolling\*q \*q" bool \*q +Enables or disables natural scrolling behavior. +.TP 7 +.BI "Option \*qRotationAngle\*q \*q" float \*q +Sets the rotation angle of the device to the given angle, in degrees clockwise. +The angle must be between 0.0 (inclusive) and 360.0 (exclusive). +.TP 7 +.BI "Option \*qScrollButton\*q \*q" int \*q +Designates a button as scroll button. +If the +.B ScrollMethod +is +.B button +and the button is logically down, x/y axis movement is converted into +scroll events. +.TP 7 +.BI "Option \*qScrollButtonLock\*q \*q" bool \*q +Enables or disables the scroll button lock. +If enabled, the +.B ScrollButton +is considered logically down after the first click and remains down until +the second click of that button. +If disabled (the default), the +.B ScrollButton +button is considered logically down while held down and up once physically +released. +.TP 7 +.BI "Option \*qScrollFactor\*q \*q" float \*q +Sets the scroll factor for scroll events. A value higher than 1.0 means faster scrolling. +Applications that don't support xi2 input will instead receive scroll button events +less or more frequently depending on the scroll factor value, instead of scrolling "smoother". +.TP 7 +.BI "Option \*qScrollMethod\*q \*q" string \*q +Enables a scroll method. Permitted values are +.BR none , +.BR twofinger , +.BR edge , +.BR button . +Not all devices support all options. +If an option is unsupported, the default scroll option for this device is used. +.TP 7 +.BI "Option \*qScrollPixelDistance\*q \*q" int \*q +Sets the movement distance, in "pixels", required to trigger one logical +wheel click. +This option only applies to the scroll methods +.BR twofinger , +.BR edge , +.BR button . +See section +.B SCROLL PIXEL DISTANCE +for more details. +.TP 7 +.BI "Option \*qSendEventsMode\*q \*q" (disabled|enabled|disabled-on-external-mouse) \*q +Sets the send events mode to disabled, enabled, +or "disable when an external mouse is connected". +.TP 7 +.BI "Option \*qTabletToolPressureCurve\*q \*q" "x0/y0 x1/y1 x2/y2 x3/y3" \*q +Set the pressure curve for a tablet stylus to the bezier formed by the four +points. +The respective x/y coordinate must be in the [0.0, 1.0] range. +For more information see section +.B TABLET TOOL PRESSURE CURVE. +.TP 7 +.BI "Option \*qTabletToolPressureRange\*q \*q" "min max" \*q +Set the pressure range for a tablet stylus to the given subset of the physical +range. +The min/max values must be in the [0.0, 1.0] range. +For example, a min of 0.3 means the tablet will send 0 pressure for anything +equal or below 30% of the physical pressure range and a max of 0.7 means +the tablet sends its maximum pressure value for any pressure equal or higher to +70% of the physical pressure range. +.TP 7 +.BI "Option \*qTabletToolAreaRatio\*q \*q" "w:h" \*q +Sets the area ratio for a tablet tool. +The area always starts at the origin (0/0) and +expands to the largest available area with the specified aspect ratio. +Events outside this area are cropped to the area. +The special value "default" is used for the default mapping +(i.e. the device-native mapping). +For more information see section +.B TABLET TOOL AREA RATIO. +.TP 7 +.BI "Option \*qTapping\*q \*q" bool \*q +Enables or disables tap-to-click behavior. +.TP 7 +.BI "Option \*qTappingButtonMap\*q \*q" (lrm|lmr) \*q +Set the button mapping for 1/2/3-finger taps to left/right/middle or +left/middle/right, respectively. +.TP 7 +.BI "Option \*qTappingDrag\*q \*q" bool \*q +Enables or disables drag during tapping behavior ("tap-and-drag"). +When enabled, a tap followed by a finger held down causes a single button down +only, all motions of that finger thus translate into dragging motion. +Tap-and-drag requires option +.B Tapping +to be enabled. +.TP 7 +.BI "Option \*qTappingDragLock\*q \*q" bool \*q +Enables or disables drag lock during tapping behavior. +When enabled, +a finger up during tap-and-drag will not immediately release the button. +If the finger is set down again within the timeout, +the dragging process continues. +.PP +For all options, the options are only parsed if the device supports that +configuration option. +For all options, the default value is the one used by libinput. +On configuration failure, the default value is applied. + +.SH SUPPORTED PROPERTIES +.B libinput +exports runtime-configurable options as properties. +If a property listed below is not available, +the matching configuration option is not available on the device. +This however does not imply that the feature is not available on the device. +The following properties are provided by the +.B libinput +driver. +.TP 7 +.B "libinput Accel Profiles Available" +3 boolean values (8 bit, 0 or 1), in order "adaptive", "flat", "custom". +Indicates which acceleration profiles are available on this device. +.TP 7 +.B "libinput Accel Profile Enabled" +3 boolean values (8 bit, 0 or 1), in order "adaptive", "flat", "custom". +Indicates which acceleration profile is currently enabled on this device. +.TP 7 +.B "libinput Accel Speed" +1 32-bit float value, defines the pointer speed. +Value range -1, 1. +This only applies to the flat or adaptive profile. +.TP 7 +.B "libinput Accel Custom Fallback Points" +.TQ +.B "libinput Accel Custom Motion Points" +.TQ +.B "libinput Accel Custom Scroll Points" +A space-separated list of 32-bit floating point non-negative numbers, e.g. +"0.0 1.0 2.4 2.5". +Sets the points of the Fallback/Motion/Scroll acceleration functions. +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.B "libinput Accel Custom Fallback Step" +.TQ +.B "libinput Accel Custom Motion Step" +.TQ +.B "libinput Accel Custom Scroll Step" +1 32-bit float value, sets the step between the points of the +Fallback/Motion/Scroll acceleration functions. +When a step of 0.0 is provided, libinput's Fallback acceleration +function is used. +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.B "libinput Button Scrolling Button" +1 32-bit value. Sets the button number to use for button scrolling. +This setting is independent of the scroll method, to enable button scrolling the +method must be set to button-scrolling and a valid button must be set. +.TP 7 +.B "libinput Button Scrolling Button Lock Enabled" +1 boolean value. If true, the scroll button lock is enabled. +This setting is independent of the scroll method or the scroll button, to enable +button scrolling the method must be set to button-scrolling and a valid +button must be set. +.TP 7 +.B "libinput Calibration Matrix" +9 32-bit float values, representing a 3x3 calibration matrix, order is row +1, row 2, row 3 +.TP 7 +.B "libinput Click Methods Available" +2 boolean values (8 bit, 0 or 1), in order "buttonareas", "clickfinger". +Indicates which click methods are available on this device. +.TP 7 +.B "libinput Click Methods Enabled" +2 boolean values (8 bit, 0 or 1), in order "buttonareas", "clickfinger". +Indicates which click methods are enabled on this device. +.TP 7 +.B "libinput Drag Lock Buttons" +Either one 8-bit value specifying the meta drag lock button, or a list of +button pairs. +See section +.B BUTTON DRAG LOCK +for details. +.TP 7 +.B "libinput High Resolution Wheel Scroll Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates whether high-resolution wheel scroll events are enabled or not. +.TP 7 +.B "libinput Horizontal Scroll Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates whether horizontal scrolling events are enabled or not. +.TP 7 +.B "libinput Left Handed Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates if left-handed mode is enabled or disabled. +.TP 7 +.B "libinput Middle Emulation Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates if middle emulation is enabled or disabled. +.TP 7 +.B "libinput Natural Scrolling Enabled" +1 boolean value (8 bit, 0 or 1). +1 enables natural scrolling. +.TP 7 +.B "libinput Rotation Angle" +1 32-bit float value [0.0 to 360.0). +Sets the rotation angle of the device, +clockwise of its natural neutral position. +.TP 7 +.B "libinput Scrolling Factor" +1 32-bit float value. +Sets the scroll factor for scroll events. A value higher than 1.0 means faster scrolling. +Applications that don't support xi2 input will instead receive scroll button events +less or more frequently depending on the scroll factor value, instead of scrolling "smoother". +.TP 7 +.B "libinput Scroll Methods Available" +3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button". +Indicates which scroll methods are available on this device. +.TP 7 +.B "libinput Scroll Method Enabled" +3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button". +Indicates which scroll method is currently enabled on this device. +.TP 7 +.B "libinput Scrolling Pixel Distance" +1 32-bit value (nonzero, with additional implementation-defined range checks). +Changes the movement distance required to trigger one logical wheel click. +.TP 7 +.B "libinput Send Events Modes Available" +2 boolean values (8 bit, 0 or 1), in order "disabled" and +"disabled-on-external-mouse". +Indicates which send-event modes are available on this device. +.TP 7 +.B "libinput Send Events Mode Enabled" +2 boolean values (8 bit, 0 or 1), in order "disabled" and +"disabled-on-external-mouse". +Indicates which send-event mode is currently enabled on this device. +.TP 7 +.B "libinput Tablet Tool Pressurecurve" +4 32-bit float values [0.0 to 1.0]. +See section +.B TABLET TOOL PRESSURE CURVE +.TP 7 +.B "libinput Tablet Tool Area Ratio" +2 32-bit values, corresponding to width and height. +Special value 0, 0 resets to the default ratio. +See section +.B TABLET TOOL AREA RATIO +for more information. +.TP 7 +.B "libinput Tapping Enabled" +1 boolean value (8 bit, 0 or 1). +1 enables tapping. +.TP 7. +.B "libinput Tapping Button Mapping Enabled" +2 boolean value (8 bit, 0 or 1), in order "lrm" and "lmr". +Indicates which button mapping is currently enabled on this device. +.TP 7 +.B "libinput Tapping Drag Lock Enabled" +1 boolean value (8 bit, 0 or 1). +1 enables drag lock during tapping. +.TP 7 +.B "libinput Disable While Typing Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates if disable while typing is enabled or disabled. +.PP +Most properties have a +.B "libinput Default" +equivalent that indicates the default value for this setting on this device. + +.SH BUTTON MAPPING +X clients receive events with logical button numbers, +where 1, 2, 3 are usually interpreted as left, middle, right; +and logical buttons 4, 5, 6, 7 are usually interpreted +as scroll up, down, left, right. +The fourth and fifth physical buttons on a device +will thus send logical buttons 8 and 9. +The +.B ButtonMapping +option adjusts the logical button mapping, it does not affect how a physical +button is mapped to a logical button. +.PP +Traditionally, a device was set to left-handed button mode by applying a +button mapping of +.B "\*q3 2 1 ...\*q" +On systems using the +.B libinput +XLibre input driver it is recommended to use the +.B LeftHanded +option instead. +.PP +The +.B libinput +XLibre input driver does not use the button mapping after setup. +Use +.BR XSetPointerMapping (3) +to modify the button mapping at runtime. + +.SH BUTTON DRAG LOCK +Button drag lock holds a button logically down even when the button itself +has been physically released since. +Button drag lock comes in two modes. +.PP +If in "meta" mode, a meta button click activates drag lock for the next +button press of any other button. +A button click in the future will keep that button held logically down +until a subsequent click of that same button. +The meta button events themselves are discarded. +A separate meta button click is required each time a drag lock should be +activated for a button in the future. +.PP +If in "pairs" mode, each button can be assigned a target locking button. +On button click, the target lock button is held logically down until the +next click of the same button. +The button events themselves are discarded +and only the target button events are sent. +.PP +This feature is provided by this driver, not by libinput. + +.SH TABLET TOOL PRESSURE CURVE +The pressure curve affects how stylus pressure is reported. +By default, the hardware pressure is reported as-is. +By setting a pressure curve, the feel of the stylus can be adjusted +to be more like e.g. a pencil or a brush. +.PP +The pressure curve is a cubic Bezier curve, drawn within a normalized range +of 0.0 to 1.0 between the four points provided. +This normalized range is applied to the tablet's pressure input +so that the highest pressure maps to 1.0. +The points must have increasing x coordinates, if x0 is larger than 0.0 +all pressure values lower than x0 are equivalent to y0. +If x3 is less than 1.0, +all pressure values higher than x3 are equivalent to y3. +.PP +The input for a linear curve (default) is "0.0/0.0 0.0/0.0 1.0/1.0 1.0/1.0"; +a slightly depressed curve (firmer) might be +"0.0/0.0 0.05/0.0 1.0/0.95 1.0/1.0"; +a slightly raised curve (softer) might be "0.0/0.0 0.0/0.05 0.95/1.0 1.0/1.0". +.PP +This feature is provided by this driver, not by libinput. + +.SH TABLET TOOL AREA RATIO +By default, a tablet tool can access the whole sensor area and the tablet +area is mapped to the available screen area. +For external tablets like the Wacom Intuos series, +the height:width ratio of the tablet may be different to that of the monitor, +causing the skew of input data. +.PP +To avoid this skew of input data, an area ratio may be set to match the +ratio of the screen device. +For example, a ratio of 4:3 will reduce the available area of the tablet +to the largest available area with a ratio of 4:3. +Events within this area will scale to the tablet's announced axis range, +the area ratio is thus transparent to the X server. +Any events outside this area will send events equal to the maximum value of +that axis. +The area always starts at the device's origin in it's current rotation, i.e., +it takes left-handed-ness into account. +.PP +This feature is provided by this driver, not by libinput. + +.SH SCROLL PIXEL DISTANCE +The X server does not support per-pixel scrolling but it does support +smooth scrolling. +All scroll events however are based around a logical unit of scrolling +(traditionally corresponding to a wheel click). +It is thus not possible to scroll by 10 pixels, but it is possible for a +driver to scroll by 1/10th of a logical wheel click. +.PP +libinput provides scroll data in pixels. +The \fBScrollPixelDistance\fR option defines the amount of movement equivalent +to one wheel click. +For example, a value of 50 means the user has to move a finger by 50 pixels to +generate one logical click event and each pixel is 1/50th of a wheel click. + +.SH CUSTOM ACCELERATION PROFILE +The custom pointer acceleration profile gives users full control over the +acceleration behavior at different speeds. +libinput exposes an acceleration function \fIf(x)\fP +where the x-axis is the device speed in device units per millisecond +and the y-axis is the pointer speed. +.PP +The custom acceleration function is defined using n points which are spaced +uniformly along the x-axis, starting from 0 and continuing in constant steps. +Thus the points defining the custom function are: +.EX +(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1]) +.EE +When a velocity value does not lie exactly on those points, +a linear interpolation/extrapolation of the two closest points +will be calculated. +.PP +There are 3 custom acceleration functions, +which are used for different movement types: +.TS +tab(;) allbox; +l l l. +Movement type; Uses; supported by +Fallback; Catch-all default movement type; All devices +Motion; Used for pointer motion; All devices +Scroll; Used for scroll movement; Mouse, Touchpad +.TE +.PP +See libinput library documentation for more details: +https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html#the-custom-acceleration-profile + +.SH BUGS +This driver does not work with \fBOption \*qDevice\*q\fR set to an event +node in \fI/dev/input/by-id\fR and \fI/dev/input/by-path\fR. +This can be usually be worked by using \fBSection \*qInputClass\*q\fR with an +appropriate \fBMatch*\fR statement in the +.BR xorg.conf (5). + +.SH AUTHORS +Peter Hutterer +.SH "SEE ALSO" +.BR XLibre (1), +.BR xorg.conf (5), +.BR Xserver (1), +.BR X (7) diff --git a/prebuilt/xlibre/usr/share/man/man4/modesetting.4 b/prebuilt/xlibre/usr/share/man/man4/modesetting.4 new file mode 100644 index 0000000..3466a6d --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man4/modesetting.4 @@ -0,0 +1,149 @@ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH MODESETTING 4 "xorg-server 25.2.0" "X Version 11" +.SH NAME +modesetting \- video driver for framebuffer device +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qmodesetting\*q" +.BI " BusID \*qpci:" bus : dev : func \*q +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B modesetting +is an Xorg driver for KMS devices. This driver supports +TrueColor visuals at framebuffer depths of 15, 16, 24, and 30. RandR +1.2 is supported for multi-head configurations. Acceleration is available +through glamor for devices supporting at least OpenGL ES 2.0 or OpenGL 2.1. +If glamor is not enabled, a shadow framebuffer is configured based on the +KMS drivers' preference (unless the framebuffer is 24 bits per pixel, in +which case the shadow framebuffer is always used). +.SH SUPPORTED HARDWARE +The +.B modesetting +driver supports all hardware where a KMS driver is available. +modesetting uses the Linux DRM KMS ioctls and dumb object create/map. +.SH CONFIGURATION DETAILS +Please refer to +.BR xorg.conf (5) +for general configuration details. +This section only covers configuration details specific to this driver. +.PP +For this driver it is not required to specify modes in the screen +section of the config file. The +.B modesetting +driver can pick up the currently used video mode from the kernel +driver and will use it if there are no video modes configured. +.PP +For PCI boards you might have to add a BusID line to the Device +section. See above for a sample line. +.PP +The following driver +.B Options +are supported: +.TP +.BI "Option \*qSWcursor\*q \*q" boolean \*q +Selects software cursor. The default is +.B off. + +Note: due to issues with cursor rendering this option will be forced +.B on +if it is running under bochs-drm, evdi, vboxvideo, virtio_gpu, vkms, vmwgfx or qxl drm driver. +.TP +.BI "Option \*qCursorSize\*q \*q" string \*q +The size of the cursor. +By default we use various probes to determine what cursor size to use. +If for some reason these probes don't work, or you just want to use +a different size, use this option. +The value is passed as either "x", or "" + +Note: On failure (for example the hardware doesn't support the chosen size) +the X server silently falls back to software cursor. +.TP +.BI "Option \*qkmsdev\*q \*q" string \*q +The framebuffer device to use. Default: /dev/dri/card0. +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Enable or disable use of the shadow framebuffer layer. Default: on. +.TP +.BI "Option \*qDoubleShadow\*q \*q" boolean \*q +Double-buffer shadow updates. When enabled, the driver will keep two copies of +the shadow framebuffer. When the shadow framebuffer is flushed, the old and new +versions of the shadow are compared, and only tiles that have actually changed +are uploaded to the device. This is an optimization for server-class GPUs with +a remote display function (typically VNC), where remote updates are triggered +by any framebuffer write, so minimizing the amount of data uploaded is crucial. +This defaults to enabled for ASPEED and Matrox G200 devices, and disabled +otherwise. +.TP +.BI "Option \*qAccelMethod\*q \*q" string \*q +One of \*qglamor\*q or \*qdri3_only\*q or \*qnone\*q. Default: glamor. +dri3_only means that glamor is used only for DRI3, but not for accelerating any other pixmaps. +.TP +.BI "Option \*qPageFlip\*q \*q" boolean \*q +Enable DRI3 page flipping. The default is +.B on. +.TP +.BI "Option \*qVariableRefresh\*q \*q" boolean \*q +Enables support for enabling variable refresh on the Screen's CRTCs +when an suitable application is flipping via the Present extension. +.br +The default is +.B off. +.TP +.BI "Option \*qAsyncFlipSecondaries\*q \*q" boolean \*q +Use async flips for secondary video outputs on multi-display setups. If a screen +has multiple displays attached and DRI3 page flipping is used, then only one of +the displays will have its page flip synchronized to vblank for tear-free +presentation. This is the display that is used for presentation timing and +timestamping, usually the one covering the biggest pixel area of the screen. +All other displays ("Secondaries") will not synchronize their flips. This may +cause some tearing on these displays, but it prevents a permanent or periodic +slowdown or irritating judder of animations if not all video outputs are running +synchronized with each other and with the same refresh rate. There is no perfect +solution apart from perfectly synchronized outputs, but this option may give +preferable results if the displays in a multi-display setup mirror or clone +each other. The default is +.B off. +.TP +.BI "Option \*qZaphodHeads\*q \*q" string \*q +Specify the RandR output(s) to use with zaphod mode for a particular driver +instance. If you use this option you must use this option for all instances +of the driver. +.br +For example: +.B +Option \*qZaphodHeads\*q \*qLVDS,VGA-0\*q +will assign xrandr outputs LVDS and VGA-0 to this instance of the driver. +.TP +.BI "Option \*qUseGammaLUT\*q \*q" boolean \*q +Enable or disable use of the GAMMA_LUT property, when available. +When enabled, this option allows the driver to use gamma ramps with more +entries, if supported by the kernel. By default, GAMMA_LUT will be used for +kms drivers which are known to be safe for use of GAMMA_LUT. +.TP +.BI "Option \*qTearFree\*q \*q" boolean \*q +Enable tearing prevention using the hardware page flipping mechanism. +It allocates two extra scanout buffers for each CRTC and utilizes damage +tracking to minimize buffer copying and skip unnecessary flips when the +screen's contents have not changed. It works on transformed screens too, such +as rotated and scaled CRTCs. When PageFlip is enabled, fullscreen DRI +applications will still have the discretion to not use tearing prevention. +.br +The default is +.B on. +.TP +.BI "Option \*qAtomic\*q \*q" boolean \*q +Enable atomic modesetting when supported. The default is +.B off. +.TP +.SH "SEE ALSO" +.BR Xorg (1), +.BR xorg.conf (5), +.BR Xserver (1), +.BR X (7) +.SH AUTHORS +Authors include: Dave Airlie diff --git a/prebuilt/xlibre/usr/share/man/man5/xorg.conf.5 b/prebuilt/xlibre/usr/share/man/man5/xorg.conf.5 new file mode 100644 index 0000000..e53d948 --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man5/xorg.conf.5 @@ -0,0 +1,2769 @@ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH xorg.conf 5 "xorg-server 25.2.0" "X Version 11" +.SH NAME +xorg.conf, xorg.conf.d \- configuration files for +Xorg X server +.SH INTRODUCTION +.B Xorg +supports several mechanisms for supplying/obtaining configuration and +run-time parameters: command line options, environment variables, the +xorg.conf and xorg.conf.d configuration files, auto-detection, +and fallback defaults. When the same information is supplied in more +than one way, the highest precedence mechanism is used. The list of +mechanisms is ordered from highest precedence to lowest. Note that not +all parameters can be supplied via all methods. The available command +line options and environment variables (and some defaults) are +described in the +.BR Xserver (1) +and +.BR Xorg (1) +manual pages. Most configuration file +parameters, with their defaults, are described below. Driver and module +specific configuration parameters are described in the relevant driver +or module manual page. +.SH DESCRIPTION +.B Xorg +uses a configuration file called +.I xorg.conf +and files ending in the suffix +.I .conf +from the directory +.I xorg.conf.d +for its initial setup. +The +.I xorg.conf +configuration file is searched for in the following places when the +server is started as a normal user: +.PP +.RS 4 +.nf +.IR /etc/X11/ +.IR /usr/etc/X11/ +.I /etc/X11/xorg.conf +.I /etc/xorg.conf +.IR /usr/etc/X11/xorg.conf. +.I /usr/etc/X11/xorg.conf +.IR /usr/lib/X11/xorg.conf. +.I /usr/lib/X11/xorg.conf +.fi +.RE +.PP +where +.I +is a relative path (with no \(lq..\&\(rq components) specified with the +.B \-config +command line option, +.I +is the machine's hostname as reported by +.BR gethostname (3). +.PP +When the Xorg server is started by the \(lqroot\(rq user, the config file +search locations are as follows: +.PP +.RS 4 +.nf + +.IR /etc/X11/ +.IR /usr/etc/X11/ +.I /etc/X11/xorg.conf +.I /etc/xorg.conf +.IR /usr/etc/X11/xorg.conf. +.I /usr/etc/X11/xorg.conf +.IR /usr/lib/X11/xorg.conf. +.I /usr/lib/X11/xorg.conf +.fi +.RE +.PP +where +.I +is the path specified with the +.B \-config +command line option (which may be absolute or relative), +.B $HOME +is the path specified by that environment variable (usually the home +directory), and +.I +is the machine's hostname as reported by +.BR gethostname (3). +.PP +Additional configuration files are searched for in the following +directories when the server is started as a normal user: +.PP +.RS 4 +.nf +.IR /etc/X11/ +.IR /etc/X11/ +.I /etc/X11/xorg.conf.d +.I /etc/X11/xorg.conf.d +.fi +.RE +.PP +where +.I +is a relative path (with no \(lq..\&\(rq components) specified with the +.B \-configdir +command line option. +.PP +When the Xorg server is started by the \(lqroot\(rq user, the +config directory search locations are as follows: +.PP +.RS 4 +.nf + +.IR /etc/X11/ +.IR /etc/X11/ +.I /etc/X11/xorg.conf.d +.I /etc/X11/xorg.conf.d +.fi +.RE +.PP +where +.I +is the path specified with the +.B \-configdir +command line option (which may be absolute or relative). +.PP +Finally, configuration files will also be searched for in a directory reserved +for system use. +This is to separate configuration files from the vendor or 3rd party packages +from those of local administration. +These files are found in the following directory: +.PP +.RS 4 +.nf +.I /usr/share/X11/xorg.conf.d +.fi +.RE +.PP +The +.I xorg.conf +and +.I xorg.conf.d +files are composed of a number of sections which may be present in any order, +or omitted to use default configuration values. +Each section has the form: +.PP +.RS 4 +.nf +.BI "Section \*q" SectionName \*q +.RI " " SectionEntry + \&... +.B EndSection +.fi +.RE +.PP +The section names are: +.PP +.RS 4 +.nf +.BR "Files " "File pathnames" +.BR "ServerFlags " "Server flags" +.BR "Module " "Dynamic module loading" +.BR "Extensions " "Extension enabling" +.BR "InputDevice " "Input device description" +.BR "InputClass " "Input class description" +.BR "OutputClass " "Output class description" +.BR "Device " "Graphics device description" +.BR "VideoAdaptor " "Xv video adaptor description" +.BR "Monitor " "Monitor description" +.BR "Modes " "Video modes descriptions" +.BR "Screen " "Screen configuration" +.BR "ServerLayout " "Overall layout" +.BR "DRI " "DRI\-specific configuration" +.BR "Vendor " "Vendor\-specific configuration" +.fi +.RE +.PP +The following obsolete section names are still recognised for compatibility +purposes. +In new config files, the +.B InputDevice +section should be used instead. +.PP +.RS 4 +.nf +.BR "Keyboard " "Keyboard configuration" +.BR "Pointer " "Pointer/mouse configuration" +.fi +.RE +.PP +The old +.B XInput +section is no longer recognised. +.PP +The +.B ServerLayout +sections are at the highest level. +They bind together the input and output devices that will be used in a session. +The input devices are described in the +.B InputDevice +sections. +Output devices usually consist of multiple independent components (e.g., +a graphics board and a monitor). +These multiple components are bound together in the +.B Screen +sections, and it is these that are referenced by the +.B ServerLayout +section. +Each +.B Screen +section binds together a graphics board and a monitor. +The graphics boards are described in the +.B Device +sections, and the monitors are described in the +.B Monitor +sections. +.PP +Config file keywords are case\-insensitive, and \(lq_\(rq characters are +ignored. +Most strings (including +.B Option +names) are also case-insensitive, and insensitive to white space and +\(lq_\(rq characters. +.PP +Each config file entry usually takes up a single line in the file. They +consist of a keyword, which is possibly followed by one or more arguments, +with the number and types of the arguments depending on the keyword. +The argument types are: +.PP +.RS 4 +.nf +.BR "Integer " "an integer number in decimal, hex or octal" +.BR "Real " "a floating point number" +.BR "String " "a string enclosed in double quote marks (\*q)" +.fi +.RE +.PP +Note: hex integer values must be prefixed with \(lq0x\(rq, and octal values +with \(lq0\(rq. +.PP +A special keyword called +.B Option +may be used to provide free\-form data to various components of the server. +The +.B Option +keyword takes either one or two string arguments. +The first is the option name, and the optional second argument is the +option value. +Some commonly used option value types include: +.PP +.RS 4 +.nf +.BR "Integer " "an integer number in decimal, hex or octal" +.BR "Real " "a floating point number" +.BR "String " "a sequence of characters" +.BR "Boolean " "a boolean value (see below)" +.BR "Frequency " "a frequency value (see below)" +.fi +.RE +.PP +Note that +.I all +.B Option +values, not just strings, must be enclosed in quotes. +.PP +Boolean options may optionally have a value specified. +When no value is specified, the option's value is +.BR TRUE . +The following boolean option values are recognised as +.BR TRUE : +.PP +.RS 4 +.BR 1 , +.BR on , +.BR true , +.B yes +.RE +.PP +and the following boolean option values are recognised as +.BR FALSE : +.PP +.RS 4 +.BR 0 , +.BR off , +.BR false , +.B no +.RE +.PP +If an option name is prefixed with +.RB \*q No \*q, +then the option value is negated. +.PP +Example: the following option entries are equivalent: +.PP +.RS 4 +.nf +.B "Option \*qAccel\*q \*qOff\*q" +.B "Option \*qNoAccel\*q" +.B "Option \*qNoAccel\*q \*qOn\*q" +.B "Option \*qAccel\*q \*qfalse\*q" +.B "Option \*qAccel\*q \*qno\*q" +.fi +.RE +.PP +Frequency option values consist of a real number that is optionally +followed by one of the following frequency units: +.PP +.RS 4 +.BR Hz , +.BR k , +.BR kHz , +.BR M , +.B MHz +.RE +.PP +When the unit name is omitted, the correct units will be determined from +the value and the expectations of the appropriate range of the value. +It is recommended that the units always be specified when using frequency +option values to avoid any errors in determining the value. +.SH "FILES SECTION" +The +.B Files +section is used to specify some path names required by the server. +Some of these paths can also be set from the command line (see +.BR Xserver (1) +and +.BR Xorg (1)). +The command line settings override the values specified in the config +file. +The +.B Files +section is optional, as are all of the entries that may appear in it. +.PP +The entries that can appear in this section are: +.TP 7 +.BI "FontPath \*q" path \*q +sets the search path for fonts. +This path is a comma separated list of font path elements which the Xorg +server searches for font databases. +Multiple +.B FontPath +entries may be specified, and they will be concatenated to build up the +fontpath used by the server. Font path elements can be absolute +directory paths, catalogue directories or a font server identifier. The +formats of the later two are explained below: +.PP +.RS 7 +Catalogue directories: +.PP +.RS 4 +Catalogue directories can be specified using the prefix \fBcatalogue:\fR +before the directory name. The directory can then be populated with +symlinks pointing to the real font directories, using the following +syntax in the symlink name: +.PP +.RS 4 +.IR : [attribute]: pri= +.RE +.PP +where +.I +is an alphanumeric identifier, +.I [attribute] +is an attribute which will be passed to the underlying FPE and +.I +is a number used to order the fontfile FPEs. Examples: +.PP +.RS 4 +.nf +.I 75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi +.I gscript:pri=60 -> /usr/share/fonts/default/ghostscript +.I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc +.fi +.RE +.RE +.RE +.PP +.RS 7 +Font server identifiers: +.PP +.RS 4 +Font server identifiers have the form: +.RS 4 +.PP +.IR / : +.RE +.PP +where +.I +is the transport type to use to connect to the font server (e.g., +.B unix +for UNIX\-domain sockets or +.B tcp +for a TCP/IP connection), +.I +is the hostname of the machine running the font server, and +.I +is the port number that the font server is listening on (usually 7100). +.RE +.PP +When this entry is not specified in the config file, the server falls back +to the compiled\-in default font path, which contains the following +font path elements (which can be set inside a catalogue directory): +.PP +.RS 4 +.nf +.I /usr/share/fonts/X11/misc/ +.I /usr/share/fonts/X11/TTF/ +.I /usr/share/fonts/X11/OTF/ +.I /usr/share/fonts/X11/Type1/ +.I /usr/share/fonts/X11/100dpi/ +.I /usr/share/fonts/X11/75dpi/ +.fi +.RE +.PP +Font path elements that are found to be invalid are removed from the +font path when the server starts up. +.RE +.TP 7 +.BI "ModulePath \*q" path \*q +sets the search path for loadable Xorg server modules. +This path is a comma separated list of directories which the Xorg server +searches for loadable modules loading in the order specified. +Multiple +.B ModulePath +entries may be specified, and they will be concatenated to build the +module search path used by the server. The standard default module path is +.PP +.RS 11 +lib/xorg/modules +.RE +.\" The LogFile keyword is not currently implemented +.ig +.TP 7 +.BI "LogFile \*q" path \*q +sets the name of the Xorg server log file. +The default log file name when running as root is +.PP +.RS 11 +.RI /tmp/Xorg. .log +.RE +and for non root it is +.RS 11 +.RI $XDG_STATE_HOME/xorg/Xorg. .log +.RE +.PP +.RS 7 +where +.I +is the display number for the Xorg server. +.. +.TP 7 +.BI "XkbDir \*q" path \*q +sets the base directory for keyboard layout files. The +.B \-xkbdir +command line option can be used to override this. The default directory is +.PP +.RS 11 +/usr/share/X11/xkb +.RE +.SH "SERVERFLAGS SECTION" +In addition to options specific to this section (described below), the +.B ServerFlags +section is used to specify some global +Xorg server options. +All of the entries in this section are +.BR Options , +although for compatibility purposes some of the old style entries are +still recognised. +Those old style entries are not documented here, and using them is +discouraged. +The +.B ServerFlags +section is optional, as are the entries that may be specified in it. +.PP +.B Options +specified in this section (with the exception of the +.B \*qDefaultServerLayout\*q +.BR Option ) +may be overridden by +.B Options +specified in the active +.B ServerLayout +section. +Options with command line equivalents are overridden when their command +line equivalent is used. +The options recognised by this section are: +.TP 7 +.BI "Option \*qDebug\*q \*q" string \*q +This comma-separated list provides a way to control various debugging switches +from the config file. +At the moment the only defined value is +.B dmabuf_capable +which instructs glamor to enable some unstable buffer management code. +.TP 7 +.BI "Option \*qDefaultServerLayout\*q \*q" layout\-id \*q +This specifies the default +.B ServerLayout +section to use in the absence of the +.B \-layout +command line option. +.TP 7 +.BI "Option \*qDontVTSwitch\*q \*q" boolean \*q +This disallows the use of the +.BI Ctrl+Alt+F n +sequence (where +.RI F n +refers to one of the numbered function keys). +That sequence is normally used to switch to another \*qvirtual terminal\*q +on operating systems that have this feature. +When this option is enabled, that key sequence has no special meaning and +is passed to clients. +Default: off. +.TP 7 +.BI "Option \*qDontZap\*q \*q" boolean \*q +This disallows the use of the +.B Terminate_Server +XKB action (usually on Ctrl+Alt+Backspace, depending on XKB options). +This action is normally used to terminate the Xorg server. +When this option is enabled, the action has no effect. +Default: off. +.TP 7 +.BI "Option \*qDontZoom\*q \*q" boolean \*q +This disallows the use of the +.B Ctrl+Alt+Keypad\-Plus +and +.B Ctrl+Alt+Keypad\-Minus +sequences. +These sequences allows you to switch between video modes. +When this option is enabled, those key sequences have no special meaning +and are passed to clients. +Default: off. +.TP 7 +.BI "Option \*qDisableVidModeExtension\*q \*q" boolean \*q +This disables the parts of the VidMode extension used by the xvidtune client +that can be used to change the video modes. +Default: the VidMode extension is enabled. +.TP 7 +.BI "Option \*qAllowNonLocalXvidtune\*q \*q" boolean \*q +This allows the xvidtune client (and other clients that use the VidMode +extension) to connect from another host. +Default: off. +.TP 7 +.BI "Option \*qAllowMouseOpenFail\*q \*q" boolean \*q +This tells the +.BR mousedrv (4) +and +.BR vmmouse (4) +drivers to not report failure if the mouse device can't be opened/initialised. +It has no effect on the +.BR evdev (4) +or other drivers. +Default: false. +.TP 7 +.BI "Option \*qBlankTime\*q \*q" time \*q +sets the inactivity timeout for the +.B blank +phase of the screensaver. +.I time +is in minutes. +This is equivalent to the Xorg server's +.B \-s +flag, and the value can be changed at run\-time with +.BR xset (1). +Default: 10 minutes. +.TP 7 +.BI "Option \*qStandbyTime\*q \*q" time \*q +sets the inactivity timeout for the +.B standby +phase of DPMS mode. +.I time +is in minutes, and the value can be changed at run\-time with +.BR xset (1). +Default: 10 minutes. +This is only suitable for VESA DPMS compatible monitors, and may not be +supported by all video drivers. +It is only enabled for screens that have the +.B \*qDPMS\*q +option set (see the MONITOR section below). +.TP 7 +.BI "Option \*qSuspendTime\*q \*q" time \*q +sets the inactivity timeout for the +.B suspend +phase of DPMS mode. +.I time +is in minutes, and the value can be changed at run\-time with +.BR xset (1). +Default: 10 minutes. +This is only suitable for VESA DPMS compatible monitors, and may not be +supported by all video drivers. +It is only enabled for screens that have the +.B \*qDPMS\*q +option set (see the MONITOR section below). +.TP 7 +.BI "Option \*qOffTime\*q \*q" time \*q +sets the inactivity timeout for the +.B off +phase of DPMS mode. +.I time +is in minutes, and the value can be changed at run\-time with +.BR xset (1). +Default: 10 minutes. +This is only suitable for VESA DPMS compatible monitors, and may not be +supported by all video drivers. +It is only enabled for screens that have the +.B \*qDPMS\*q +option set (see the MONITOR section below). +.TP 7 +.BI "Option \*qMaxClients\*q \*q" integer \*q +Set the maximum number of clients allowed to connect to the X server. +Acceptable values are 64, 128, 256 or 512. +.TP 7 +.BI "Option \*qNoPM\*q \*q" boolean \*q +Disables something to do with power management events. +Default: PM enabled on platforms that support it. +.TP 7 +.BI "Option \*qXinerama\*q \*q" boolean \*q +enable or disable XINERAMA extension. +Default is disabled. +.TP 7 +.BI "Option \*qIndirectGLX\*q \*q" boolean \*q +enable or disable indirect GLX contexts. Indirect GLX contexts are disabled by +default. +.TP 7 +.BI "Option \*qDRI2\*q \*q" boolean \*q +enable or disable DRI2. DRI2 is disabled by default. +.TP 7 +.BI "Option \*qGlxVisuals\*q \*q" string \*q +This option controls how many GLX visuals the GLX modules sets up. +The default value is +.BR "typical" , +which will setup up a typical subset of +the GLXFBConfigs provided by the driver as GLX visuals. Other options are +.BR minimal , +which will set up the minimal set allowed by the GLX specification and +.B all +which will setup GLX visuals for all GLXFBConfigs. +.TP 7 +.BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q +Include the default font path even if other paths are specified in +xorg.conf. If enabled, other font paths are included as well. Enabled by +default. +.TP 7 +.BI "Option \*qFontServerConnections\*q \*q" boolean \*q +Allow connections to font servers (e.g.\& +.BR tcp/fontserver:7100 ) +in the font path. Font servers are rarely used and are a source of +security vulnerabilities. Disabled by default. +Can also be set with the +.B +fontserverconnections +command line option. +.TP 7 +.BI "Option \*qIgnoreABI\*q \*q" boolean \*q +Allow modules built for a different, potentially incompatible version of +the X server to load. Disabled by default. +.TP 7 +.BI "Option \*qAutoAddDevices\*q \*q" boolean \*q +If this option is disabled, then no devices will be added from the HAL or +udev backends. Enabled by default. +.TP 7 +.BI "Option \*qAutoEnableDevices\*q \*q" boolean \*q +If this option is disabled, then the devices will be added (and the +DevicePresenceNotify event sent), but not enabled, thus leaving policy up +to the client. +Enabled by default. +.TP 7 +.BI "Option \*qAutoAddGPU\*q \*q" boolean \*q +If this option is disabled, then no GPU devices will be added from the udev +backend. Enabled by default. (May need to be disabled to setup Xinerama). +.TP 7 +.BI "Option \*qAutoBindGPU\*q \*q" boolean \*q +If enabled then secondary GPUs will be automatically set up as output-sinks and +offload-sources. Making e.g. laptop outputs connected only to the secondary +GPU directly available for use without needing to run +"xrandr --setprovideroutputsource". Enabled by default. +.TP 7 +.BI "Option \*qLog\*q \*q" string \*q +This option controls whether the log is flushed and/or synced to disk after +each message. +Possible values are +.B flush +or +.BR sync . +Unset by default. +.TP 7 +.BI "Option \*qAllowByteSwappedClients\*q \*q" boolean \*q +Allow clients with a different byte-order than the server. Disabled by default. +.TP 7 +.BI "Option \*qSingleDriver\*q \*q" boolean \*q +Only the first successfully probed driver is allowed to add screens to the current layout, others may +add secondary GPU screens only (e.g., if non-primary GPUs are used for offloading). +Disabled by default. +.SH "MODULE SECTION" +The +.B Module +section is used to specify which Xorg server modules should be loaded. +This section is ignored when the Xorg server is built in static form. +The type of modules normally loaded in this section are Xorg server +extension modules. +Most other module types are loaded automatically when they are needed via +other mechanisms. +The +.B Module +section is optional, as are all of the entries that may be specified in +it. +.PP +Entries in this section may be in two forms. +The first and most commonly used form is an entry that uses the +.B Load +keyword, as described here: +.TP 7 +.BI "Load \*q" modulename \*q +This instructs the server to load the module called +.IR modulename . +The module name given should be the module's standard name, not the +module file name. +The standard name is case\-sensitive, and does not include the \(lqlib\(rq +or \(lqcyg\(rq prefixes, or the \(lq.so\(rq or \(lq.dll\(rq suffixes. +.PP +.RS 7 +Example: the DRI extension module can be loaded with the following entry: +.PP +.RS 4 +.B "Load \*qdri\*q" +.RE +.RE +.TP 7 +.BI "Disable \*q" modulename \*q +This instructs the server to not load the module called +.IR modulename . +Some modules are loaded by default in the server, and this overrides that +default. If a +.B Load +instruction is given for the same module, it overrides the +.B Disable +instruction and the module is loaded. The module name given should be the +module's standard name, not the module file name. As with the +.B Load +instruction, the standard name is case-sensitive, and does not include the +"lib" prefix, or the ".a", ".o", or ".so" suffixes. +.PP +The second form of entry is a +.BR SubSection , +with the subsection name being the module name, and the contents of the +.B SubSection +being +.B Options +that are passed to the module when it is loaded. +.PP +Example: the extmod module (which contains a miscellaneous group of +server extensions) can be loaded, with the XFree86\-DGA extension +disabled by using the following entry: +.PP +.RS 4 +.nf +.B "SubSection \*qextmod\*q" +.B " Option \*qomit XFree86\-DGA\*q" +.B EndSubSection +.fi +.RE +.PP +Modules are searched for in each directory specified in the +.B ModulePath +search path, and in the drivers, extensions, input, internal, and +multimedia subdirectories of each of those directories. +In addition to this, operating system specific subdirectories of all +the above are searched first if they exist. +.PP +To see what extension modules are available, check the extensions +subdirectory under: +.PP +.RS 4 +.nf +lib/xorg/modules +.fi +.RE +.PP +The \(lqextmod\(rq, \(lqdbe\(rq, \(lqdri\(rq, \(lqdri2\(rq, \(lqglx\(rq, +and \(lqrecord\(rq extension modules are loaded automatically, if they +are present, unless disabled with \*qDisable\*q entries. +It is recommended +that at very least the \(lqextmod\(rq extension module be loaded. +If it isn't, some commonly used server extensions (like the SHAPE +extension) will not be available. +.SH "EXTENSIONS SECTION" +The +.B Extensions +section is used to specify which X11 protocol extensions should be enabled +or disabled. +The +.B Extensions +section is optional, as are all of the entries that may be specified in +it. +.PP +Entries in this section are listed as Option statements with the name of +the extension as the first argument, and a boolean value as the second. +The extension name is case\-sensitive, and matches the form shown in the output +of \*qXorg \-extension ?\*q. +.PP +.RS 7 +Example: the MIT-SHM extension can be disabled with the following entry: +.PP +.RS 4 +.nf +.B "Section \*qExtensions\*q" +.B " Option \*qMIT-SHM\*q \*qDisable\*q" +.B EndSection +.fi +.RE +.RE +.SH "INPUTDEVICE SECTION" +The config file may have multiple +.B InputDevice +sections. +Recent X servers employ HAL or udev backends for input device enumeration +and input hotplugging. It is usually not +necessary to provide +.B InputDevice +sections in the xorg.conf if hotplugging is in use (i.e., AutoAddDevices is +enabled). If hotplugging is enabled, +.B InputDevice +sections using the +.B mouse, kbd +and +.B vmmouse +driver will be ignored. +.PP +If hotplugging is disabled, there will normally +be at least two: one for the core (primary) keyboard +and one for the core pointer. +If either of these two is missing, a default configuration for the missing +ones will be used. In the absence of an explicitly specified core input +device, the first +.B InputDevice +marked as +.B CorePointer +(or +.BR CoreKeyboard ) +is used. +If there is no match there, the first +.B InputDevice +that uses the \(lqmouse\(rq (or \(lqkbd\(rq) driver is used. +The final fallback is to use built\-in default configurations. +Currently the default configuration may not work as expected on all platforms. +.PP +.B InputDevice +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qInputDevice\*q" +.BI " Identifier \*q" name \*q +.BI " Driver \*q" inputdriver \*q +.I " options" +.I " ..." +.B EndSection +.fi +.RE +.PP +The +.B Identifier +and +.B Driver +entries are required in all +.B InputDevice +sections. +All other entries are optional. +.PP +The +.B Identifier +entry specifies the unique name for this input device. +The +.B Driver +entry specifies the name of the driver to use for this input device. +When using the loadable server, the input driver module +.RI \*q inputdriver \*q +will be loaded for each active +.B InputDevice +section. +An +.B InputDevice +section is considered active if it is referenced by an active +.B ServerLayout +section, if it is referenced by the +.B \-keyboard +or +.B \-pointer +command line options, or if it is selected implicitly as the core pointer +or keyboard device in the absence of such explicit references. +The most commonly used input drivers are +.BR evdev (4) +on Linux systems, and +.BR kbd (4) +and +.BR mousedrv (4) +on other platforms. +.PP +.B InputDevice +sections recognise some driver\-independent +.BR Options , +which are described here. +See the individual input driver manual pages for a description of the +device\-specific options. +.TP 7 +.BI "Option \*qAutoServerLayout\*q \*q" boolean \*q +Always add the device to the ServerLayout section used by this instance of +the server. This affects implied layouts as well as explicit layouts +specified in the configuration and/or on the command line. +.TP 7 +.B "Option \*qCorePointer\*q" +Deprecated, see +.B Floating +.TP 7 +.B "Option \*qCoreKeyboard\*q" +Deprecated, see +.B Floating +.TP 7 +.BI "Option \*qAlwaysCore\*q \*q" boolean \*q +Deprecated, see +.B Floating +.TP 7 +.BI "Option \*qSendCoreEvents\*q \*q" boolean \*q +Deprecated, see +.B Floating + +.TP 7 +.BI "Option \*qFloating\*q \*q" boolean \*q +When enabled, the input device is set up floating and does not +report events through any master device or control a cursor. The device is +only available to clients using the X Input Extension API. This option is +disabled by default. +The options +.B CorePointer, +.B CoreKeyboard, +.B AlwaysCore, +and +.B SendCoreEvents, +are the inverse of option +.B Floating +(i.e., +.B SendCoreEvents \*qon\*q +is equivalent to +.B Floating \*qoff\*q +). + +This option controls the startup behavior only, a device +may be reattached or set floating at runtime. +.TP 7 +.BI "Option \*qTransformationMatrix\*q \*q" a " " b " " c " " d " " e " " f " " g " " h " " i \*q +Specifies the 3x3 transformation matrix for absolute input devices. The +input device will be bound to the area given in the matrix. In most +configurations, "a" and "e" specify the width and height of the area the +device is bound to, and "c" and "f" specify the x and y offset of the area. +The value range is 0 to 1, where 1 represents the width or height of all +root windows together, 0.5 represents half the area, etc. The values +represent a 3x3 matrix, with the first, second and third group of three +values representing the first, second and third row of the matrix, +respectively. The identity matrix is "1 0 0 0 1 0 0 0 1". +.SS POINTER ACCELERATION +For pointing devices, the following options control how the pointer +is accelerated or decelerated with respect to physical device motion. Most of +these can be adjusted at runtime, see the +.BR xinput (1) +man page for details. +Only the most important acceleration options are discussed here. +.TP 7 +.BI "Option \*qAccelerationProfile\*q \*q" integer \*q +Select the profile. In layman's terms, the profile constitutes the "feeling" of +the acceleration. More formally, it defines how the transfer function (actual +acceleration as a function of current device velocity and acceleration controls) +is constructed. This is mainly a matter of personal preference. +.PP +.RS 6 +.nf +.B " 0 classic (mostly compatible)" +.B "\-1 none (only constant deceleration is applied)" +.B " 1 device-dependent" +.B " 2 polynomial (polynomial function)" +.B " 3 smooth linear (soft knee, then linear)" +.B " 4 simple (normal when slow, otherwise accelerated)" +.B " 5 power (power function)" +.B " 6 linear (more speed, more acceleration)" +.B " 7 limited (like linear, but maxes out at threshold)" +.fi +.RE +.TP 7 +.BI "Option \*qConstantDeceleration\*q \*q" real \*q +Makes the pointer go +.B deceleration +times slower than normal. Most useful for high-resolution devices. A value +between 0 and 1 will speed up the pointer. +.TP 7 +.BI "Option \*qAdaptiveDeceleration\*q \*q" real \*q +Allows to actually decelerate the pointer when going slow. At most, it will be +.B adaptive deceleration +times slower. Enables precise pointer placement without sacrificing speed. +.TP 7 +.BI "Option \*qAccelerationScheme\*q \*q" string \*q +Selects the scheme, which is the underlying algorithm. +.PP +.RS 7 +.nf +.B "predictable default algorithm (behaving more predictable)" +.B "lightweight old acceleration code (as specified in the X protocol spec)" +.B "none no acceleration or deceleration" +.fi +.RE +.TP 7 +.BI "Option \*qAccelerationNumerator\*q \*q" integer \*q +.TP 7 +.BI "Option \*qAccelerationDenominator\*q \*q" integer \*q +Set numerator and denominator of the acceleration factor. The acceleration +factor is a rational which, together with threshold, can be used to tweak +profiles to suit the users needs. The +.B simple +and +.B limited +profiles use it directly (i.e., they accelerate by the factor), for other +profiles it should hold that a higher acceleration factor leads to a faster +pointer. Typically, 1 is unaccelerated and values up to 5 are sensible. +.TP 7 +.BI "Option \*qAccelerationThreshold\*q \*q" integer \*q +Set the threshold, which is roughly the velocity (usually device units per 10 +ms) required for acceleration to become effective. The precise effect varies +with the profile however. + +.SH "INPUTCLASS SECTION" +The config file may have multiple +.B InputClass +sections. +These sections are optional and are used to provide configuration for a +class of input devices as they are automatically added. An input device can +match more than one +.B InputClass +section. Each class can override settings from a previous class, so it is +best to arrange the sections with the most generic matches first. +.PP +.B InputClass +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qInputClass\*q" +.BI " Identifier \*q" name \*q +.I " entries" +.I " ..." +.I " options" +.I " ..." +.B EndSection +.fi +.RE +.PP +The +.B Identifier +entry is required in all +.B InputClass +sections. +All other entries are optional. +.PP +The +.B Identifier +entry specifies the unique name for this input class. +The +.B Driver +entry specifies the name of the driver to use for this input device. +After all classes have been examined, the +.RI \*q inputdriver \*q +module from the first +.B Driver +entry will be enabled when using the loadable server. +.PP +When an input device is automatically added, its characteristics are +checked against all +.B InputClass +sections. Each section can contain optional entries to narrow the match +of the class. If none of the optional entries appear, the +.B InputClass +section is generic and will match any input device. If more than one of +these entries appear, they all must match for the configuration to apply. +.PP +There are two types of match entries used in +.B InputClass +sections. The first allows various tokens to be matched against attributes +of the device. An entry can be constructed to match attributes from different +devices by separating arguments with a '|' character. If an argument is prepended +with '!', then it should NOT be contained in an attribute. If one or more '&' +characters are present in an argument, they split it into parts that ALL must +be disjoint substrings of an attribute in exactly the same order. Multiple +entries of the same type may be supplied to add multiple matching conditions +on the same attribute. For example: +.PP +.RS 4 +.nf +.B "Section \*qInputClass\*q" +.B " Identifier \*qMy Class\*q" +.B " # product string may not contain example and must" +.B " # either contain gizmo and then gremlin, or contain gadget" +.B " MatchProduct \*q!example\*q" +.B " MatchProduct \*qgizmo\^&\^gremlin\^|\^gadget\*q" +.B " NoMatchDriver \*qdrivername\*q" +.I " \&.\|.\|.\&" +.B EndSection +.fi +.RE +.TP 7 +.BI "MatchProduct \*q" matchproduct \*q +This entry can be used to check if the substring +.RI \*q matchproduct \*q +occurs in the device's product name. +.TP 7 +.BI "MatchVendor \*q" matchvendor \*q +This entry can be used to check if the substring +.RI \*q matchvendor \*q +occurs in the device's vendor name. +.TP 7 +.BI "MatchDevicePath \*q" matchdevice \*q +This entry can be used to check if the device file matches the +.RI \*q matchdevice \*q +pathname pattern. +.TP 7 +.BI "MatchOS \*q" matchos \*q +This entry can be used to check if the operating system matches the +case-insensitive +.RI \*q matchos \*q +string. This entry is only supported on platforms providing the +.BR uname (2) +system call. +.TP 7 +.BI "MatchPnPID \*q" matchpnp \*q +The device's Plug and Play (PnP) ID can be checked against the +.RI \*q matchpnp \*q +shell wildcard pattern. +.TP 7 +.BI "MatchUSBID \*q" matchusb \*q +The device's USB ID can be checked against the +.RI \*q matchusb \*q +shell wildcard pattern. The ID is constructed as lowercase hexadecimal numbers +separated by a ':'. This is the same format as the +.BR lsusb (8) +program. +.TP 7 +.BI "MatchDriver \*q" matchdriver \*q +Check the case-sensitive string +.RI \*q matchdriver \*q +against the currently configured driver of the device. Ordering of sections +using this entry is important since it will not match unless the driver has +been set by the config backend or a previous +.B InputClass +section. +.TP 7 +.BI "MatchTag \*q" matchtag \*q +This entry can be used to check if tags assigned by the config backend +matches the +.RI \*q matchtag \*q +pattern. A match is found if at least one of the tags given in +.RI \*q matchtag \*q +matches at least one of the tags assigned by the backend. +.TP 7 +.BI "MatchLayout \*q" matchlayout \*q +Check the case-sensitive string +.RI \*q matchlayout \*q +against the currently active +.B ServerLayout +section. The empty string "" matches an implicit layout which appears +if no named +.B ServerLayout +sections have been found. +.PP +The above directives have equivalents for negative matching with the +.B NoMatchProduct, +.B NoMatchVendor, +.B NoMatchDevicePath, +.B NoMatchOS, +.B NoMatchPnPID, +.B NoMatchUSBID, +.B NoMatchDriver, +.B NoMatchTag, +and +.B NoMatchLayout +directives. These NoMatch directives match if the subsequent match is not +met by the device. +.PP +To apply more sophicticated conditions, an entire attribute can be matched +against an extended regular expression (see +.BR regex (7) +or +.BR re_format (7) +): +.PP +.RS 4 +.nf +.B " # product string must start with Experimental +.B " # and end with Device +.B " MatchProduct \*q~_^Experimental.*Device$_\*q" +.fi +.RE +.PP +Such a pattern is prefixed with '~', and the next character, which +may be arbitrary, is used as a two-side delimiter, i.e. the regular +expression starts after it and lasts until its next occurrence, or to +the end of the argument, if the delimiting character has not been found +again. +.PP +Negated and non-negated patterns, strings and regular expressions can be mixed +in one line, e.g., +.PP +.RS 4 +.nf +.B " # accept product names that either do not end with \*qMouse\*q" +.B " # or contain \*qUSB\*q" and \*qReceiver\*q" +.B " MatchProduct \*q!~@Mouse$@|USB&Receiver\*q" +.fi +.RE +.PP +The second type of entry is used to match device types. These entries take a +boolean argument similar to +.B Option +entries. +.TP 7 +.BI "MatchIsKeyboard \*q" bool \*q +.TP 7 +.BI "MatchIsPointer \*q" bool \*q +.TP 7 +.BI "MatchIsJoystick \*q" bool \*q +.TP 7 +.BI "MatchIsTablet \*q" bool \*q +.TP 7 +.BI "MatchIsTabletPad \*q" bool \*q +.TP 7 +.BI "MatchIsTouchpad \*q" bool \*q +.TP 7 +.BI "MatchIsTouchscreen \*q" bool \*q +.PP +When an input device has been matched to the +.B InputClass +section, any +.B Option +entries are applied to the device. One +.B InputClass +specific +.B Option +is recognized. See the +.B InputDevice +section above for a description of the remaining +.B Option +entries. +.TP 7 +.BI "Option \*qIgnore\*q \*q" boolean \*q +This optional entry specifies that the device should be ignored entirely, +and not added to the server. This can be useful when the device is handled +by another program and no X events should be generated. +.SH "OUTPUTCLASS SECTION" +The config file may have multiple +.B OutputClass +sections. +These sections are optional and are used to provide configuration for a +class of output devices as they are automatically added. +An output device can match more than one +.B OutputClass +section. +Each class can override settings from a previous class, so it is best to +arrange the sections with the most generic matches first. +.PP +.B OutputClass +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qOutputClass\*q" +.BI " Identifier \*q" name \*q +.I " entries" +.I " ..." +.B EndSection +.fi +.RE +.PP +The +.B Identifier +entry is required in all +.B OutputClass +sections. +All other entries are optional. +.PP +The +.B Identifier +entry specifies the unique name for this output class. +The +.B Driver +entry specifies the name of the driver to use for this output device. +After all classes have been examined, the +.RI \*q outputdriver \*q +module from the first +.B Driver +entry will be enabled when using the loadable server. +.PP +When an output device is automatically added, its characteristics and the active layout are +checked against all +.B OutputClass +sections. +Each section can contain optional entries to narrow the match of the class. +.RE +.TP 7 +.BI "MatchDriver \*q" matchdriver \*q +Check the case-sensitive string +.RI \*q matchdriver \*q +against the kernel driver of the device. +.RE +.TP 7 +.BI "MatchLayout \*q" matchlayout \*q +Check the case-sensitive string +.RI \*q matchlayout \*q +against the currently active +.B ServerLayout +section or against +.RI \*q\*q +, if no named +.B ScreenLayout +sections are present. +.PP +If none of the optional entries appear, the +.B OutputClass +section is generic and will match any output device. +If more than one of these entries appear, they all must match for the +configuration to apply. +.PP +An entry can be constructed to match attributes from different devices or +different screen layouts by separating arguments with a '|' character. +.PP +For example: +.PP +.RS 4 +.nf +.B "Section \*qOutputClass\*q" +.B " Identifier \*qMy Class\*q" +.B " # kernel driver must be either foo or bar" +.B " MatchDriver \*qfoo\^|\^bar\*q" +.B " # active layout must be either Seat1 or implicit" +.B " MatchLayout \*qSeat1|\*q" +.I " \&.\|.\|.\&" +.B EndSection +.fi +.RE +.PP +When an output device has been matched to the +.B OutputClass +section, any +.B Option +entries are applied to the device. Two +.B OutputClass +specific kinds of +.B Option +are recognized. See the +.B Device +section below for a description of the remaining +.B Option +entries. +.TP 7 +.BI "Option \*qPrimaryGPU\*q \*q" boolean \*q +This option specifies that the matched device should be treated as the +primary GPU, replacing the selection of the GPU used as output by the +firmware. If multiple output devices match an OutputClass section with +the PrimaryGPU option set, the first one enumerated becomes the primary GPU. +.TP 7 +.BI "Option \*qHotplugDriver\*q \*q" driver \*q +This option specifies that the matched driver should be used to handle a +hot-plugged GPU device. +The module specified by +.I driver +will be loaded during setup of the GPU device. +If loading of this module fails or there is no driver by that name, the +modesetting driver will be used, which is the default behavior. +If multiple output devices match an +.B OutputClass +section with the +.B HotplugDriver +option, the first one enumerated becomes the hotplug driver. +.RE +.PP +.TP 7 +An +.B OutputClass +section may contain multiple +.TP 7 +.BI "ModulePath \*q" path \*q +entries. When an output device with DRM enabled matches an +.B OutputClass +section and +.B Driver +.I \*qdriver\*q +is set, then for this driver module, and all modules loaded until the next driver +for a DRM-enabled GPU, a search path is created by prepending all +.B ModulePath +entries in that +.B OutputClass +to the +.I standard +search path \(lqlib/xorg/modules\(rq for loadable Xorg server modules (not the +.I effective +default set path, which can undergo changes, see below). If there is a single +.PP +.RS 11 +.nf +.B " ModulePath \*q\*q +.fi +.RE +.PP +.RS 7 +entry in an +.B OutputClass +for a +.I driver +, then only the +.I standard +path \(lqlib/xorg/modules\(rq is searched from now on. It there no +.B ModulePath +entries at all, then the +.I effective +default search path (set globally) becomes active. Note that each +.B OutputClass +.I overrides +search path for a +.I driver +, not +.I extends +it. +.PP +If a matching +.B OutputClass +contains +.B ModulePath +entries, but not a +.B Driver +entry, then paths are +.I prepended +to the +.I effective +default search path, which initially is standard \(lqlib/xorg/modules\(rq, thus extending it. +.PP +These entries have no effect if a search path for loadable modules is set through command line. See +.B ModulePath +in the +.B Files +section for more info. +.RE +.PP +.B OutputClass +section may contain an arbitrary number of +.PP +.RS 4 +.nf +.BI " Module \*q" module\*q +.fi +.RE +.PP +entries, which are quite equivalent to +.B Driver +except that +.I \*qmodule\*q +is not added to the list of autoconfigured video drivers. This may be useful to extend +ABI version ignoring and special search paths to modules like "glx". +.SH "DEVICE SECTION" +The config file may have multiple +.B Device +sections. +There must be at least one, for the video card being used. +.PP +.B Device +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" name \*q +.BI " Driver \*q" driver \*q +.I " entries" +.I " ..." +.B EndSection +.fi +.RE +.PP +The +.B Identifier +and +.B Driver +entries are required in all +.B Device +sections. All other entries are optional. +.PP +The +.B Identifier +entry specifies the unique name for this graphics device. +The +.B Driver +entry specifies the name of the driver to use for this graphics device. +When using the loadable server, the driver module +.RI \*q driver \*q +will be loaded for each active +.B Device +section. +A +.B Device +section is considered active if it is referenced by an active +.B Screen +section. +.PP +.B Device +sections recognise some driver\-independent entries and +.BR Options , +which are described here. +Not all drivers make use of these +driver\-independent entries, and many of those that do don't require them +to be specified because the information is auto\-detected. +See the individual graphics driver manual pages for further information +about this, and for a description of the device\-specific options. +Note that most of the +.B Options +listed here (but not the other entries) may be specified in the +.B Screen +section instead of here in the +.B Device +section. +.TP 7 +.BI "BusID \*q" bus\-id \*q +This specifies the bus location of the graphics card. +For PCI/AGP cards, +the +.I bus\-id +string has the form +.BI PCI: bus @ domain : device : function +(e.g., \(lqPCI:1@0:0:0\(rq might be appropriate for an AGP card). The +"@domain" part can be left out for PCI domain 0. This field is usually +optional in single-head configurations when using the primary graphics card. +In multi-head configurations, or when using a secondary graphics card in a +single-head configuration, this entry is mandatory. +Its main purpose is to make an unambiguous connection between the device +section and the hardware it is representing. +This information can usually be found by running the pciaccess tool +scanpci. +.TP 7 +.BI "Screen " number +This option is mandatory for cards where a single PCI entity can drive more +than one display (i.e., multiple CRTCs sharing a single graphics accelerator +and video memory). +One +.B Device +section is required for each head, and this +parameter determines which head each of the +.B Device +sections applies to. +The valid values of +.I number +range from 0 to one less than the total number of heads per entity. +Most drivers require that the primary screen (0) be present. +.TP 7 +.BI "Chipset \*q" chipset \*q +This usually optional entry specifies the chipset used on the graphics +board. +In most cases this entry is not required because the drivers will probe the +hardware to determine the chipset type. +Don't specify it unless the driver-specific documentation recommends that you +do. +.TP 7 +.BI "Ramdac \*q" ramdac\-type \*q +This optional entry specifies the type of RAMDAC used on the graphics +board. +This is only used by a few of the drivers, and in most cases it is not +required because the drivers will probe the hardware to determine the +RAMDAC type where possible. +Don't specify it unless the driver-specific documentation recommends that you +do. +.TP 7 +.BI "DacSpeed " speed +.TP 7 +.BI "DacSpeed " "speed\-8 speed\-16 speed\-24 speed\-32" +This optional entry specifies the RAMDAC speed rating (which is usually +printed on the RAMDAC chip). +The speed is in MHz. +When one value is given, it applies to all framebuffer pixel sizes. +When multiple values are given, they apply to the framebuffer pixel sizes +8, 16, 24 and 32 respectively. +This is not used by many drivers, and only needs to be specified when the +speed rating of the RAMDAC is different from the defaults built in to +driver, or when the driver can't auto-detect the correct defaults. +Don't specify it unless the driver-specific documentation recommends that you +do. +.TP 7 +.BI "Clocks " "clock ..." +specifies the pixel that are on your graphics board. +The clocks are in MHz, and may be specified as a floating point number. +The value is stored internally to the nearest kHz. +The ordering of the clocks is important. +It must match the order in which they are selected on the graphics board. +Multiple +.B Clocks +lines may be specified, and each is concatenated to form the list. +Most drivers do not use this entry, and it is only required for some older +boards with non-programmable clocks. +Don't specify this entry unless the driver-specific documentation explicitly +recommends that you do. +.TP +.BI "ClockChip \*q" clockchip\-type \*q +This optional entry is used to specify the clock chip type on graphics +boards which have a programmable clock generator. +Only a few Xorg drivers support programmable clock chips. +For details, see the appropriate driver manual page. +.TP 7 +.BI "VideoRam " "mem" +This optional entry specifies the amount of video ram that is installed +on the graphics board. +This is measured in kilobytes. +In most cases this is not required because the Xorg server probes +the graphics board to determine this quantity. +The driver-specific documentation should indicate when it might be needed. +.TP 7 +.BI "MemBase " "baseaddress" +This optional entry specifies the memory base address of a graphics +board's linear frame buffer. +This entry is not used by many drivers, and it should only be specified if +the driver-specific documentation recommends it. +.TP 7 +.BI "IOBase " "baseaddress" +This optional entry specifies the IO base address. +This entry is not used by many drivers, and it should only be specified if +the driver-specific documentation recommends it. +.TP 7 +.BI "ChipID " "id" +This optional entry specifies a numerical ID representing the chip type. +For PCI cards, it is usually the device ID. +This can be used to override the auto-detection, but that should only be done +when the driver-specific documentation recommends it. +.TP 7 +.BI "ChipRev " "rev" +This optional entry specifies the chip revision number. +This can be used to override the auto-detection, but that should only be done +when the driver-specific documentation recommends it. +.TP 7 +.BI "MatchSeat " "seat\-id" +Only apply this +.B Device +section if X server was started with +.B \-seat +.I seat\-id +option. +.TP 7 +.BI "Option \*qModeDebug\*q \*q" boolean \*q +Enable printing of additional debugging information about modesetting to +the server log. +.TP 7 +.BI "Option \*qNoOutputInitialSize\*q \*q" width " " height \*q +Normally, the X server infers the initial screen size based on any +connected outputs. +However, if no outputs are connected, the X server picks a default screen size +of 1024 x 768. +This option overrides the default screen size to use when no outputs are +connected. +In contrast to the \*qVirtual\*q Display SubSection entry, which applies +unconditionally, \*qNoOutputInitialSize\*q is only used if no outputs are +detected when the X server starts. +.TP 7 +.BI "Option \*qPreferCloneMode\*q \*q" boolean \*q +If enabled, bring up monitors of a screen in clone mode instead of horizontal +extended layout by default. (Defaults to off; the video driver can change the +default value, but this option can always override it) +.ig +.TP 7 +This optional entry allows an IRQ number to be specified. +.. +.TP 7 +.B Options +Option flags may be specified in the +.B Device +sections. +These include driver\-specific options and driver\-independent options. +The former are described in the driver\-specific documentation. +Some of the latter are described below in the section about the +.B Screen +section, and they may also be included here. + +.SH "VIDEOADAPTOR SECTION" +Nobody wants to say how this works. +Maybe nobody knows \&... + +.SH "MONITOR SECTION" +The config file may have multiple +.B Monitor +sections. +There should normally be at least one, for the monitor being used, +but a default configuration will be created when one isn't specified. +.PP +.B Monitor +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qMonitor\*q" +.BI " Identifier \*q" name \*q +.I " entries" +.I " ..." +.B EndSection +.fi +.RE +.PP +The only mandatory entry in a +.B Monitor +section is the +.B Identifier +entry. +.PP +The +.B Identifier +entry specifies the unique name for this monitor. +The +.B Monitor +section may be used to provide information about the specifications of the +monitor, monitor-specific +.BR Options , +and information about the video modes to use with the monitor. +.PP +With RandR 1.2-enabled drivers, monitor sections may be tied to specific +outputs of the video card. Using the name of the output defined by the video +driver plus the identifier of a monitor section, one associates a monitor +section with an output by adding an option to the Device section in the +following format: + +.BI "Option \*qMonitor-" outputname "\*q \*q" monitorsection \*q + +(for example, +.B Option \*qMonitor-VGA\*q \*qVGA monitor\*q +for a VGA output) +.PP +In the absence of specific association of monitor sections to outputs, if a +monitor section is present the server will associate it with an output to +preserve compatibility for previous single-head configurations. +.PP +Specifying video modes is optional because the server will use the DDC or other +information provided by the monitor to automatically configure the list of +modes available. +When modes are specified explicitly in the +.B Monitor +section (with the +.BR Mode , +.BR ModeLine , +or +.B UseModes +keywords), built-in modes with the same names are not included. +Built-in modes with different names are, however, still implicitly included, +when they meet the requirements of the monitor. +.PP +The entries that may be used in +.B Monitor +sections are described below. +.TP 7 +.BI "VendorName \*q" vendor \*q +This optional entry specifies the monitor's manufacturer. +.TP 7 +.BI "ModelName \*q" model \*q +This optional entry specifies the monitor's model. +.TP 7 +.BI "HorizSync " "horizsync\-range" +gives the range(s) of horizontal sync frequencies supported by the +monitor. +.I horizsync\-range +may be a comma separated list of either discrete values or ranges of +values. +A range of values is two values separated by a dash. +By default the values are in units of kHz. +They may be specified in MHz or Hz +if +.B MHz +or +.B Hz +is added to the end of the line. +The data given here is used by the Xorg server to determine if video +modes are within the specifications of the monitor. +This information should be available in the monitor's handbook. +If this entry is omitted, a default range of 28\(en33\ kHz is used. +.TP 7 +.BI "VertRefresh " "vertrefresh\-range" +gives the range(s) of vertical refresh frequencies supported by the +monitor. +.I vertrefresh\-range +may be a comma separated list of either discrete values or ranges of +values. +A range of values is two values separated by a dash. +By default the values are in units of Hz. +They may be specified in MHz or kHz +if +.B MHz +or +.B kHz +is added to the end of the line. +The data given here is used by the Xorg server to determine if video +modes are within the specifications of the monitor. +This information should be available in the monitor's handbook. +If this entry is omitted, a default range of 43\(en72\ Hz is used. +.TP 7 +.BI "DisplaySize " "width height" +This optional entry gives the width and height, in millimetres, of the +picture area of the monitor. +If given this is used to calculate the horizontal and vertical pitch (DPI) of +the screen. +.TP 7 +.BI "Gamma " "gamma\-value" +.TP 7 +.BI "Gamma " "red\-gamma green\-gamma blue\-gamma" +This is an optional entry that can be used to specify the gamma correction +for the monitor. +It may be specified as either a single value or as three separate RGB values. +The values should be in the range 0.1 to 10.0, and the default is 1.0. +Not all drivers are capable of using this information. +.TP 7 +.BI "UseModes \*q" modesection\-id \*q +Include the set of modes listed in the +.B Modes +section called +.IR modesection\-id . +This makes all of the modes defined in that section available for use by +this monitor. +.TP 7 +.BI "Mode \*q" name \*q +This is an optional multi-line entry that can be used to provide +definitions for video modes for the monitor. +In most cases this isn't necessary because the built-in set of VESA standard +modes will be sufficient. +The +.B Mode +keyword indicates the start of a multi-line video mode description. +The mode description is terminated with the +.B EndMode +keyword. +The mode description consists of the following entries: +.RS 7 +.TP 4 +.BI "DotClock " clock +is the dot (pixel) clock rate to be used for the mode. +.TP 4 +.BI "HTimings " "hdisp hsyncstart hsyncend htotal" +specifies the horizontal timings for the mode. +.TP 4 +.BI "VTimings " "vdisp vsyncstart vsyncend vtotal" +specifies the vertical timings for the mode. +.TP 4 +.BI "Flags \*q" flag \*q " ..." +specifies an optional set of mode flags, each of which is a separate +string in double quotes. +.B \*qInterlace\*q +indicates that the mode is interlaced. +.B \*qDoubleScan\*q +indicates a mode where each scanline is doubled. +.B \*q+HSync\*q +and +.B \*q\-HSync\*q +can be used to select the polarity of the HSync signal. +.B \*q+VSync\*q +and +.B \*q\-VSync\*q +can be used to select the polarity of the VSync signal. +.B \*qComposite\*q +can be used to specify composite sync on hardware where this is supported. +Additionally, on some hardware, +.B \*q+CSync\*q +and +.B \*q\-CSync\*q +may be used to select the composite sync polarity. +.TP 4 +.BI "HSkew " hskew +specifies the number of pixels (towards the right edge of the screen) by +which the display enable signal is to be skewed. +Not all drivers use this information. +This option might become necessary to override the default value supplied +by the server (if any). +\(lqRoving\(rq horizontal lines indicate this value needs to be increased. +If the last few pixels on a scan line appear on the left of the screen, +this value should be decreased. +.TP 4 +.BI "VScan " vscan +specifies the number of times each scanline is painted on the screen. +Not all drivers use this information. +Values less than 1 are treated as 1, which is the default. +Generally, the +.B \*qDoubleScan\*q +.B Flag +mentioned above doubles this value. +.RE +.TP 7 +.BI "ModeLine \*q" name \*q " mode\-description" +This entry is a more compact version of the +.B Mode +entry, and it also can be used to specify video modes for the monitor. +This is a single line format for specifying video modes. +In most cases this isn't necessary because the built\-in set of VESA +standard modes will be sufficient. +.PP +.RS 7 +The +.I mode\-description +is in four sections, the first three of which are mandatory. +The first is the dot (pixel) clock. +This is a single number specifying the pixel clock rate for the mode in +MHz. +The second section is a list of four numbers specifying the horizontal +timings. +These numbers are the +.IR hdisp , +.IR hsyncstart , +.IR hsyncend , +and +.I htotal +values. +The third section is a list of four numbers specifying the vertical +timings. +These numbers are the +.IR vdisp , +.IR vsyncstart , +.IR vsyncend , +and +.I vtotal +values. +The final section is a list of flags specifying other characteristics of +the mode. +.B Interlace +indicates that the mode is interlaced. +.B DoubleScan +indicates a mode where each scanline is doubled. +.B +HSync +and +.B \-HSync +can be used to select the polarity of the HSync signal. +.B +VSync +and +.B \-VSync +can be used to select the polarity of the VSync signal. +.B Composite +can be used to specify composite sync on hardware where this is supported. +Additionally, on some hardware, +.B +CSync +and +.B \-CSync +may be used to select the composite sync polarity. +The +.B HSkew +and +.B VScan +options mentioned above in the +.B Mode +entry description can also be used here. +.RE +.TP 7 +.BI "Option \*qDPMS\*q \*q" bool \*q +This option controls whether the server should enable the DPMS extension +for power management for this screen. The default is to enable the +extension. +.TP 7 +.BI "Option \*qSyncOnGreen\*q \*q" bool \*q +This option controls whether the video card should drive the sync signal +on the green color pin. Not all cards support this option, and most +monitors do not require it. The default is off. +.TP 7 +.BI "Option \*qPrimary\*q \*q" bool \*q +This optional entry specifies that the monitor should be treated as the primary +monitor. (RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qPreferredMode\*q \*q" name \*q +This optional entry specifies a mode to be marked as the preferred initial mode +of the monitor. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qZoomModes\*q \*q" name " " name " " ... \*q +This optional entry specifies modes to be marked as zoom modes. +It is possible to switch to the next and previous mode via +.BR Ctrl+Alt+Keypad\-Plus " and " Ctrl+Alt+Keypad\-Minus . +All these keypad available modes are selected from the screen mode list. +This list is a copy of the compatibility output monitor mode list. +Since this output is the output connected to the lowest +dot-area monitor, as determined from its largest size mode, that +monitor defines the available zoom modes. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qPosition\*q \*q" x " " y \*q +This optional entry specifies the position of the monitor within the X +screen. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qLeftOf\*q \*q" output \*q +This optional entry specifies that the monitor should be positioned to the +left of the output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qRightOf\*q \*q" output \*q +This optional entry specifies that the monitor should be positioned to the +right of the output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qAbove\*q \*q" output \*q +This optional entry specifies that the monitor should be positioned above the +output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qBelow\*q \*q" output \*q +This optional entry specifies that the monitor should be positioned below the +output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qEnable\*q \*q" bool \*q +This optional entry specifies whether the monitor should be turned on +at startup. By default, the server will attempt to enable all connected +monitors. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qDisable\*q \*q" bool \*q +This optional entry specifies whether the monitor should be turned off +at startup. By default, the server will attempt to enable all connected +monitors. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qDefaultModes\*q \*q" bool \*q +This optional entry specifies whether the server should add supported default +modes to the list of modes offered on this monitor. By default, the server +will add default modes; you should only disable this if you can guarantee +that EDID will be available at all times, or if you have added custom modelines +which the server can use. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qMinClock\*q \*q" frequency \*q +This optional entry specifies the minimum dot clock, in kHz, that is supported +by the monitor. +.TP 7 +.BI "Option \*qMaxClock\*q \*q" frequency \*q +This optional entry specifies the maximum dot clock, in kHz, that is supported +by the monitor. +.TP 7 +.BI "Option \*qIgnore\*q \*q" bool \*q +This optional entry specifies that the monitor should be ignored entirely, +and not reported through RandR. This is useful if the hardware reports the +presence of outputs that don't exist. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option \*qRotate\*q \*q" rotation \*q +This optional entry specifies the initial rotation of the given monitor. +Valid values for rotation are \*qnormal\*q, \*qleft\*q, \*qright\*q, and +\*qinverted\*q. +(RandR 1.2-supporting drivers only) + +.SH "MODES SECTION" +The config file may have multiple +.B Modes +sections, or none. +These sections provide a way of defining sets of video modes independently +of the +.B Monitor +sections. +.B Monitor +sections may include the definitions provided in these sections by +using the +.B UseModes +keyword. +In most cases the +.B Modes +sections are not necessary because the built\-in set of VESA standard modes +will be sufficient. +.PP +.B Modes +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qModes\*q" +.BI " Identifier \*q" name \*q +.I " entries" +.I " ..." +.B EndSection +.fi +.RE +.PP +The +.B Identifier +entry specifies the unique name for this set of mode descriptions. +The other entries permitted in +.B Modes +sections are the +.B Mode +and +.B ModeLine +entries that are described above in the +.B Monitor +section. +.SH "SCREEN SECTION" +The config file may have multiple +.B Screen +sections. +There must be at least one, for the \(lqscreen\(rq being used. +A \(lqscreen\(rq represents the binding of a graphics device +.RB ( Device +section) and a monitor +.RB ( Monitor +section). +A +.B Screen +section is considered \(lqactive\(rq if it is referenced by an active +.B ServerLayout +section or by the +.B \-screen +command line option. +If neither of those is present, the first +.B Screen +section found in the config file is considered the active one. +.PP +.B Screen +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qScreen\*q" +.BI " Identifier \*q" name \*q +.BI " Device \*q" devid \*q +.BI " GPUDevice \*q" devid \*q +.BI " Monitor \*q" monid \*q +.I " entries" +.I " ..." +.B " SubSection \*qDisplay\*q" +.I " entries" +.I " \&.\|.\|.\&" +.B " EndSubSection" +.I " \&.\|.\|.\&" +.B EndSection +.fi +.RE +.PP +The +.B Identifier +entry is mandatory. +All others are optional. +.PP +The +.B Identifier +entry specifies the unique name for this screen. +The +.B Screen +section provides information specific to the whole screen, including +screen\-specific +.BR Options . +In multi\-head configurations, there will be multiple active +.B Screen +sections, one for each head. +The entries available +for this section are: +.TP 7 +.BI "Device \*q" device\-id \*q +This entry specifies the +.B Device +section to be used for this screen. When multiple graphics cards are +present, this is what ties a specific card to a screen. The +.I device\-id +must match the +.B Identifier +of a +.B Device +section in the config file. +.TP 7 +.BI "GPUDevice \*q" device\-id \*q +This entry specifies the +.B Device +section to be used as a secondary GPU device for this screen. +When multiple graphics cards are present, this is what ties a specific +secondary card to a screen. +The +.I device\-id +must match the +.B Identifier +of a +.B Device +section in the config file. +This can be specified up to 4 times for a single screen. +.TP 7 +.BI "Monitor \*q" monitor\-id \*q +specifies which monitor description is to be used for this screen. +If a +.B Monitor +name is not specified, a default configuration is used. +Currently the default configuration may not function as expected on all +platforms. +.TP 7 +.BI "VideoAdaptor \*q" xv\-id \*q +specifies an optional Xv video adaptor description to be used with this +screen. +.TP 7 +.BI "DefaultDepth " depth +specifies which color depth the server should use by default. +The +.B \-depth +command line option can be used to override this. +If neither is specified, the default depth is driver\-specific, but in most +cases is 8. +.TP 7 +.BI "DefaultFbBpp " bpp +specifies which framebuffer layout to use by default. +The +.B \-fbbpp +command line option can be used to override this. +In most cases the driver will chose the best default value for this. +The only case where there is even a choice in this value is for depth 24, +where some hardware supports both a packed 24 bit framebuffer layout and a +sparse 32 bit framebuffer layout. +.TP 7 +.BI "MatchSeat " "seat\-id" +Only apply this +.B Screen +section if X server was started with +.B \-seat +.I seat\-id +option. +.TP 7 +.B Options +Various +.B Option +flags may be specified in the +.B Screen +section. +Some are driver\-specific and are described in the driver documentation. +Others are driver\-independent, and will eventually be described here. +.\" XXX These should really be in an xaa man page. +.TP 7 +.B "Option \*qAccel\*q" +Enables 2D hardware acceleration. +This option is on by default, but it may be necessary to turn it off if +there are bugs in the driver. +There are many options to disable specific accelerated operations, listed +below. +Note that disabling an operation will have no effect if the operation is +not accelerated (whether due to lack of support in the hardware or in the +driver). +.TP 7 +.BI "Option \*qGlxVendorLibrary\*q \*q" string \*q +This option specifies a space-separated list of OpenGL vendor libraries to +use for the screen. This may be used to select an alternate implementation +for development, debugging, or alternate feature sets. +Default: mesa. +.TP 7 +.BI "Option \*qRenderingAPI\*q \*q" string \*q +This option specifies an rendering API for use in conjunction with Glamor +accel method. You can specify OpenGL with a value "gl" and OpenGL ES with a +value "es", and the default is both, when Glamor fallbacks to GLES if GL 2.1 is +not available. This may be useful for embedded and old cards, where GL ES +feature set works faster than GL feature set. +Default: gl. +.TP 7 +.BI "Option \*qDirectDRI3\*q \*q" boolean \*q +This option tells glamor to use the direct implementation of DRI3. +This option is experimental, and there are known bugs with it. +.TP 7 +.BI "Option \*qInitPrimary\*q \*q" boolean \*q +Use the Int10 module to initialize the primary graphics card. +Normally, only secondary cards are soft-booted using the Int10 module, as the +primary card has already been initialized by the BIOS at boot time. +Default: false. +.TP 7 +.BI "Option \*qNoInt10\*q \*q" boolean \*q +Disables the Int10 module, a module that uses the int10 call to the BIOS +of the graphics card to initialize it. +Default: false. +.PP +Each +.B Screen +section may optionally contain one or more +.B Display +subsections. +Those subsections provide depth/fbbpp specific configuration information, +and the one chosen depends on the depth and/or fbbpp that is being used for +the screen. +The +.B Display +subsection format is described in the section below. + +.SH "DISPLAY SUBSECTION" +Each +.B Screen +section may have multiple +.B Display +subsections. +The \(lqactive\(rq +.B Display +subsection is the first that matches the depth and/or fbbpp values being +used, or failing that, the first that has neither a depth or fbbpp value +specified. +The +.B Display +subsections are optional. +When there isn't one that matches the depth and/or fbbpp values being used, +all the parameters that can be specified here fall back to their defaults. +.PP +.B Display +subsections have the following format: +.PP +.RS 4 +.nf +.B " SubSection \*qDisplay\*q" +.BI " Depth " depth +.I " entries" +.I " ..." +.B " EndSubSection" +.fi +.RE +.TP 7 +.BI "Depth " depth +This entry specifies what colour depth the +.B Display +subsection is to be used for. +This entry is usually specified, but it may be omitted to create a match\-all +.B Display +subsection or when wishing to match only against the +.B FbBpp +parameter. +The range of +.I depth +values that are allowed depends on the driver. +Most drivers support 8, 15, 16 and 24. +Some also support 1 and/or 4, and some may support other values (like 30). +Note: +.I depth +means the number of bits in a pixel that are actually used to determine +the pixel colour. +32 is not a valid +.I depth +value. +Most hardware that uses 32 bits per pixel only uses 24 of them to hold the +colour information, which means that the colour depth is 24, not 32. +.TP 7 +.BI "FbBpp " bpp +This entry specifies the framebuffer format this +.B Display +subsection is to be used for. +This entry is only needed when providing depth 24 configurations that allow +a choice between a 24\ bpp packed framebuffer format and a 32\ bpp sparse +framebuffer format. +In most cases this entry should not be used. +.TP 7 +.BI "Weight " "red\-weight green\-weight blue\-weight" +This optional entry specifies the relative RGB weighting to be used +for a screen is being used at depth 16 for drivers that allow multiple +formats. +This may also be specified from the command line with the +.B \-weight +option (see +.BR Xorg (1)). +.TP 7 +.BI "Virtual " "xdim ydim" +This optional entry specifies the virtual screen resolution to be used. +.I xdim +must be a multiple of either 8 or 16 for most drivers, and a multiple +of 32 when running in monochrome mode. +The given value will be rounded down if this is not the case. +Video modes which are too large for the specified virtual size will be +rejected. +If this entry is not present, the virtual screen resolution will be set to +accommodate all the valid video modes given in the +.B Modes +entry. +Some drivers/hardware combinations do not support virtual screens. +Refer to the appropriate driver\-specific documentation for details. +.TP 7 +.BI "ViewPort " "x0 y0" +This optional entry sets the upper left corner of the initial display. +This is only relevant when the virtual screen resolution is different +from the resolution of the initial video mode. +If this entry is not given, then the initial display will be centered in +the virtual display area. +.TP 7 +.BI "Modes \*q" mode\-name \*q " ..." +This optional entry specifies the list of video modes to use. +Each +.I mode\-name +specified must be in double quotes. +They must correspond to those specified or referenced in the appropriate +.B Monitor +section (including implicitly referenced built\-in VESA standard modes). +The server will delete modes from this list which don't satisfy various +requirements. +The first valid mode in this list will be the default display mode for +startup. +The list of valid modes is converted internally into a circular list. +It is possible to switch to the next mode with +.B Ctrl+Alt+Keypad\-Plus +and to the previous mode with +.BR Ctrl+Alt+Keypad\-Minus . +When this entry is omitted, the valid modes referenced by the appropriate +.B Monitor +section will be used. If the +.B Monitor +section contains no modes, then the selection will be taken from the +built-in VESA standard modes. +.TP 7 +.BI "Visual \*q" visual\-name \*q +This optional entry sets the default root visual type. +This may also be specified from the command line (see the +.BR Xserver (1) +man page). +The visual types available for depth 8 are (default is +.BR PseudoColor ): +.PP +.RS 11 +.nf +.B StaticGray +.B GrayScale +.B StaticColor +.B PseudoColor +.B TrueColor +.B DirectColor +.fi +.RE +.PP +.RS 7 +The visual type available for the depths 15, 16 and 24 are (default is +.BR TrueColor ): +.PP +.RS 4 +.nf +.B TrueColor +.B DirectColor +.fi +.RE +.PP +Not all drivers support +.B DirectColor +at these depths. +.PP +The visual types available for the depth 4 are (default is +.BR StaticColor ): +.PP +.RS 4 +.nf +.B StaticGray +.B GrayScale +.B StaticColor +.B PseudoColor +.fi +.RE +.PP +The visual type available for the depth 1 (monochrome) is +.BR StaticGray . +.RE +.TP 7 +.BI "Black " "red green blue" +This optional entry allows the \(lqblack\(rq colour to be specified. +This is only supported at depth 1. +The default is black. +.TP 7 +.BI "White " "red green blue" +This optional entry allows the \(lqwhite\(rq colour to be specified. +This is only supported at depth 1. +The default is white. +.TP 7 +.B Options +Option flags may be specified in the +.B Display +subsections. +These may include driver\-specific options and driver\-independent options. +The former are described in the driver\-specific documentation. +Some of the latter are described above in the section about the +.B Screen +section, and they may also be included here. +.SH "SERVERLAYOUT SECTION" +The config file may have multiple +.B ServerLayout +sections. +A \(lqserver layout\(rq represents the binding of one or more screens +.RB ( Screen +sections) and one or more input devices +.RB ( InputDevice +sections) to form a complete configuration. +In multi\-head configurations, it also specifies the relative layout of the +heads. +A +.B ServerLayout +section is considered \(lqactive\(rq if it is referenced by the +.B \-layout +command line option or by an +.B "Option \*qDefaultServerLayout\*q" +entry in the +.B ServerFlags +section (the former takes precedence over the latter). +If those options are not used, the first +.B ServerLayout +section found in the config file is considered the active one. +If no +.B ServerLayout +sections are present, the single active screen and two active (core) +input devices are selected as described in the relevant sections above. +.PP +.B ServerLayout +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qServerLayout\*q" +.BI " Identifier \*q" name \*q +.BI " Screen \*q" screen\-id \*q +.I " ..." +.BI " InputDevice \*q" idev\-id \*q +.I " ..." +.I " options" +.I " ..." +.B EndSection +.fi +.RE +.PP +Each +.B ServerLayout +section must have an +.B Identifier +entry and at least one +.B Screen +entry. +.PP +The +.B Identifier +entry specifies the unique name for this server layout. +The +.B ServerLayout +section provides information specific to the whole session, including +session\-specific +.BR Options . +The +.B ServerFlags +options (described above) may be specified here, and ones given here +override those given in the +.B ServerFlags +section. +.PP +The entries that may be used in this section are described here. +.TP 7 +.BI "Screen " "screen\-num" " \*qscreen\-id\*q " "position\-information" +One of these entries must be given for each screen being used in +a session. +The +.I screen\-id +field is mandatory, and specifies the +.B Screen +section being referenced. +The +.I screen\-num +field is optional, and may be used to specify the screen number +in multi\-head configurations. +When this field is omitted, the screens will be numbered in the order that +they are listed in. +The numbering starts from 0, and must be consecutive. +The +.I position\-information +field describes the way multiple screens are positioned. +There are a number of different ways that this information can be provided: +.RS 7 +.TP 4 +.I "x y" +.TP 4 +.BI "Absolute " "x y" +These both specify that the upper left corner's coordinates are +.RI ( x , y ). +The +.B Absolute +keyword is optional. +Some older versions of XFree86 (4.2 and earlier) don't recognise the +.B Absolute +keyword, so it's safest to just specify the coordinates without it. +.TP 4 +.BI "RightOf \*q" screen\-id \*q +.TP 4 +.BI "LeftOf \*q" screen\-id \*q +.TP 4 +.BI "Above \*q" screen\-id \*q +.TP 4 +.BI "Below \*q" screen\-id \*q +.TP 4 +.BI "Relative \*q" screen\-id \*q " x y" +These give the screen's location relative to another screen. +The first four position the screen immediately to the right, left, above or +below the other screen. +When positioning to the right or left, the top edges are aligned. +When positioning above or below, the left edges are aligned. +The +.B Relative +form specifies the offset of the screen's origin (upper left corner) +relative to the origin of another screen. +.RE +.TP 7 +.BI "InputDevice \*q" idev\-id "\*q \*q" option \*q " ..." +One of these entries should be given for each input device being used in +a session. +Normally at least two are required, one each for the core pointer and +keyboard devices. +If either of those is missing, suitable +.B InputDevice +entries are searched for using the method described above in the +.B INPUTDEVICE +section. The +.I idev\-id +field is mandatory, and specifies the name of the +.B InputDevice +section being referenced. +Multiple +.I option +fields may be specified, each in double quotes. +The options permitted here are any that may also be given in the +.B InputDevice +sections. +Normally only session\-specific input device options would be used here. +The most commonly used options are: +.PP +.RS 11 +.nf +.B \*qCorePointer\*q +.B \*qCoreKeyboard\*q +.B \*qSendCoreEvents\*q +.fi +.RE +.PP +.RS 7 +and the first two should normally be used to indicate the core pointer +and core keyboard devices respectively. +.RE +.TP 7 +.BI "MatchSeat " "seat\-id" +Only apply this +.B ServerLayout +section if X server was started with +.B \-seat +.I seat\-id +option. +.TP 7 +.B Options +In addition to the following, any option permitted in the +.B ServerFlags +section may also be specified here. +When the same option appears in both places, the value given here overrides +the one given in the +.B ServerFlags +section. +.TP 7 +.BI "Option \*qIsolateDevice\*q \*q" bus\-id \*q +Restrict device resets to the specified +.IR bus\-id . +See the +.B BusID +option (described in +.BR "DEVICE SECTION" , +above) for the format of the +.I bus\-id +parameter. +This option overrides +.BR SingleCard , +if specified. +At present, only PCI devices can be isolated in this manner. +.TP 7 +.BI "Option \*qSingleCard\*q \*q" boolean \*q +As +.BR IsolateDevice , +except that the bus ID of the first device in the layout is used. +.PP +Here is an example of a +.B ServerLayout +section for a dual headed configuration with two mice: +.PP +.RS 4 +.nf +.B "Section \*qServerLayout\*q" +.B " Identifier \*qLayout 1\*q" +.B " Screen \*qMGA 1\*q" +.B " Screen \*qMGA 2\*q RightOf \*qMGA 1\*q" +.B " InputDevice \*qKeyboard 1\*q \*qCoreKeyboard\*q" +.B " InputDevice \*qMouse 1\*q \*qCorePointer\*q" +.B " InputDevice \*qMouse 2\*q \*qSendCoreEvents\*q" +.B " Option \*qBlankTime\*q \*q5\*q" +.B EndSection +.fi +.RE +.SH "DRI SECTION" +This optional section is used to provide some information for the +Direct Rendering Infrastructure. +Details about the format of this section can be found on-line at +.IR . +.SH "VENDOR SECTION" +The optional +.B Vendor +section may be used to provide vendor\-specific configuration information. +Multiple +.B Vendor +sections may be present, and they may contain an +.B Identifier +entry and multiple +.B Option +flags. +The data therein is not used in this release. +.SH "SEE ALSO" +General: +.BR X (7), +.BR Xserver (1), +.BR Xorg (1), +.BR cvt (1), +.BR gtf (1). +.PP +.B "Not all modules or interfaces are available on all platforms." +.PP +Display drivers: +.BR apm (4), +.BR ati (4), +.BR chips (4), +.BR cirrus (4), +.BR cyrix (4), +.BR fbdev (4), +.BR glide (4), +.BR glint (4), +.BR i128 (4), +.BR i740 (4), +.BR imstt (4), +.BR intel (4), +.BR mga (4), +.BR neomagic (4), +.BR nv (4), +.BR openchrome (4), +.BR r128 (4), +.BR radeon (4), +.BR rendition (4), +.BR savage (4), +.BR s3virge (4), +.BR siliconmotion (4), +.BR sis (4), +.BR sisusb (4), +.BR sunbw2 (4), +.BR suncg14 (4), +.BR suncg3 (4), +.BR suncg6 (4), +.BR sunffb (4), +.BR sunleo (4), +.BR suntcx (4), +.BR tdfx (4), +.\" .BR tga (4), +.BR trident (4), +.BR tseng (4), +.BR vesa (4), +.BR vmware (4), +.BR voodoo (4), +.BR wsfb (4), +.BR xgi (4), +.BR xgixp (4). +.PP +Input drivers: +.BR acecad (4), +.BR citron (4), +.BR elographics (4), +.BR evdev (4), +.BR fpit (4), +.BR joystick (4), +.BR kbd (4), +.BR libinput (4), +.BR mousedrv (4), +.BR mutouch (4), +.BR penmount (4), +.BR synaptics (4), +.BR vmmouse (4), +.BR void (4), +.BR wacom (4). +.PP +Other modules and interfaces: +.BR exa (4), +.BR fbdevhw (4), +.\" .BR shadowfb (4), +.BR v4l (4). +.br +.SH AUTHORS +This manual page was largely rewritten by David Dawes +.IR . diff --git a/prebuilt/xlibre/usr/share/man/man5/xorg.conf.d.5 b/prebuilt/xlibre/usr/share/man/man5/xorg.conf.d.5 new file mode 100644 index 0000000..304cc4f --- /dev/null +++ b/prebuilt/xlibre/usr/share/man/man5/xorg.conf.d.5 @@ -0,0 +1 @@ +.so man5/xorg.conf.5 diff --git a/rebuild-image.sh b/rebuild-image.sh index e0e91e2..f3247ac 100755 --- a/rebuild-image.sh +++ b/rebuild-image.sh @@ -49,6 +49,8 @@ done mkdir -p "$IMAGES_HOST" +docker run --rm -v "$ROOTFS_HOST:/rootfs" alpine:3.24 chown -R "$(id -u):$(id -g)" /rootfs + if [ -x "$BANANARCHY_DIR/scripts/apply-bananarchy-overlay.sh" ]; then "$BANANARCHY_DIR/scripts/apply-bananarchy-overlay.sh" "$ROOTFS_HOST" "$TARGET_DEVICE" fi @@ -139,6 +141,7 @@ EOF "$ROOTFS/bin/su" \ "$ROOTFS/bin/mount" \ "$ROOTFS/bin/umount" \ + "$ROOTFS/usr/bin/Xorg" \ "$ROOTFS/usr/bin/doas" \ "$ROOTFS/usr/bin/sudo" \ "$ROOTFS/usr/bin/pkexec" \ diff --git a/scripts/apply-bananarchy-overlay.sh b/scripts/apply-bananarchy-overlay.sh index b48bcf0..26c04d3 100755 --- a/scripts/apply-bananarchy-overlay.sh +++ b/scripts/apply-bananarchy-overlay.sh @@ -42,8 +42,11 @@ esac echo "[1/4] Installing Bananarchy rootfs overlay (artwork, branding, Sxmo 240x320, UCM, udev)..." rm -f "$TARGET_ROOTFS/usr/bin/bantam" "$TARGET_ROOTFS/usr/local/bin/bantam" "$TARGET_ROOTFS/etc/doas.d/wheel.conf" cp -af "$BASE_DIR/overlay/rootfs/." "$TARGET_ROOTFS/" +chown -R 10000:10000 "$TARGET_ROOTFS/home/user" 2>/dev/null || true chown 0:0 "$TARGET_ROOTFS/etc/doas.d/50-sxmo.conf" 2>/dev/null || true chmod 640 "$TARGET_ROOTFS/etc/doas.d/50-sxmo.conf" 2>/dev/null || true +chown 0:0 "$TARGET_ROOTFS/usr/bin/sudo" "$TARGET_ROOTFS/usr/bin/doas" "$TARGET_ROOTFS/bin/su" 2>/dev/null || true +chmod 4755 "$TARGET_ROOTFS/usr/bin/sudo" "$TARGET_ROOTFS/usr/bin/doas" "$TARGET_ROOTFS/bin/su" 2>/dev/null || true echo "[2/4] Installing prebuilt QDSP6/Q6Voice kernel modules, torch LED module, camera module, and DTBs..." if [ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/qcom/qdsp6" ]; then @@ -65,14 +68,60 @@ mkdir -p "$TARGET_ROOTFS/boot/dtbs" cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/dtbs/"*.dtb "$TARGET_ROOTFS/boot/dtbs/" cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/dtbs/$DTB_FILE" "$TARGET_ROOTFS/boot/$DTB_FILE" -echo "[3/4] Installing prebuilt multi-mode fcitx5-t9 and Bantam AI agent..." +echo "[3/4] Installing prebuilt Xlibre, Sxmo X11 (dwm/dmenu/st), fcitx5-t9, and Bantam AI agent..." +if [ -d "$BASE_DIR/prebuilt/xlibre/usr" ]; then + cp -af "$BASE_DIR/prebuilt/xlibre/usr/bin/." "$TARGET_ROOTFS/usr/bin/" + cp -af "$BASE_DIR/prebuilt/xlibre/usr/lib/xorg/." "$TARGET_ROOTFS/usr/lib/xorg/" + cp -af "$BASE_DIR/prebuilt/xlibre/usr/share/X11/xorg.conf.d/." "$TARGET_ROOTFS/usr/share/X11/xorg.conf.d/" +fi +if [ -d "$BASE_DIR/prebuilt/sxmo-x11/usr" ]; then + cp -af "$BASE_DIR/prebuilt/sxmo-x11/usr/." "$TARGET_ROOTFS/usr/" +fi cp -af "$BASE_DIR/prebuilt/fcitx5-t9/usr/." "$TARGET_ROOTFS/usr/" cp -af "$BASE_DIR/prebuilt/bantam/bantam" "$TARGET_ROOTFS/usr/bin/bantam" cp -af "$BASE_DIR/prebuilt/bantam/bantam" "$TARGET_ROOTFS/usr/local/bin/bantam" -rm -f \ +rm -rf \ + "$TARGET_ROOTFS/usr/bin/sxmo_swayinitconf.sh" \ + "$TARGET_ROOTFS/usr/bin/sxmo_swayinit.sh" \ + "$TARGET_ROOTFS/usr/bin/sxmo_riverinit.sh" \ + "$TARGET_ROOTFS/usr/bin/sxmo_riverbar.sh" \ + "$TARGET_ROOTFS/usr/bin/bemenu" \ + "$TARGET_ROOTFS/usr/bin/bemenu-run" \ + "$TARGET_ROOTFS/usr/lib/bemenu" \ + "$TARGET_ROOTFS/usr/share/wayland-sessions" \ + "$TARGET_ROOTFS/usr/share/sxmo/appcfg/sway_template" \ + "$TARGET_ROOTFS/usr/share/sxmo/appcfg/wob.ini" \ + "$TARGET_ROOTFS/usr/share/sxmo/appcfg/river" \ + "$TARGET_ROOTFS/usr/share/sxmo/appcfg/wofi.config" \ + "$TARGET_ROOTFS/usr/share/sxmo/appcfg/wofi.css" \ + "$TARGET_ROOTFS/usr/share/sxmo/appcfg/foot.ini" \ + "$TARGET_ROOTFS/usr/share/sxmo/sessions/sxmo_river.desktop" \ + "$TARGET_ROOTFS/usr/share/sxmo/services/sxmo_riverbar.service" \ + "$TARGET_ROOTFS/usr/share/sxmo/services/sxmo_wob.service" \ + "$TARGET_ROOTFS/usr/share/sxmo/appscripts/sxmo_record.sh" \ + "$TARGET_ROOTFS/usr/share/sxmo/appscripts/sxmo_screenshot.sh" \ + "$TARGET_ROOTFS/usr/share/sxmo/appscripts/sxmo_websearch.sh" \ + "$TARGET_ROOTFS/usr/share/sxmo/appscripts/sxmo_youtube.sh" \ + "$TARGET_ROOTFS/usr/share/sxmo/appscripts/sxmo_youtube_audio.sh" \ + "$TARGET_ROOTFS/usr/lib/fcitx5/libwayland.so" \ + "$TARGET_ROOTFS/usr/lib/fcitx5/libwaylandim.so" \ + "$TARGET_ROOTFS/usr/share/fcitx5/addon/wayland.conf" \ + "$TARGET_ROOTFS/usr/share/fcitx5/addon/waylandim.conf" \ + "$TARGET_ROOTFS/home/user/.config/fcitx5/conf/waylandim.conf" \ + "$TARGET_ROOTFS/etc/skel/.config/fcitx5/conf/waylandim.conf" \ + "$TARGET_ROOTFS/home/user/.config/wob" \ + "$TARGET_ROOTFS/etc/skel/.config/wob" \ + "$TARGET_ROOTFS/home/user/.config/wofi" \ + "$TARGET_ROOTFS/etc/skel/.config/wofi" \ + "$TARGET_ROOTFS/home/user/.config/foot" \ + "$TARGET_ROOTFS/etc/skel/.config/foot" \ + "$TARGET_ROOTFS/home/user/.config/sxmo/sway" \ + "$TARGET_ROOTFS/etc/skel/.config/sxmo/sway" \ "$TARGET_ROOTFS/home/user/.bantam.cfg" \ "$TARGET_ROOTFS/etc/skel/.bantam.cfg" \ "$TARGET_ROOTFS/root/.bantam.cfg" +mkdir -p "$TARGET_ROOTFS/var/lib/tinydm" +ln -sf /usr/share/xsessions/sxmo.desktop "$TARGET_ROOTFS/var/lib/tinydm/default-session.desktop" echo "[4/4] Installing deviceinfo for $DEVICE ($DTB_FILE)..." if [ -f "$BASE_DIR/devices/$DEVICE/deviceinfo" ]; then diff --git a/scripts/build-kernel-audio.sh b/scripts/build-kernel-audio.sh index c3a0c0d..f89b7ad 100755 --- a/scripts/build-kernel-audio.sh +++ b/scripts/build-kernel-audio.sh @@ -58,7 +58,7 @@ EOF if [ -d /kcache ] && [ -f /kcache/Makefile ]; then echo "[1/5] Using cached kernel tree in /kcache..." cd /kcache - if ! grep -q "Q6VOICE_PATH_VOICE" include/dt-bindings/sound/qcom,q6voice.h 2>/dev/null; then + if ! grep -q "VOICEMMODE1" include/dt-bindings/sound/qcom,q6voice.h 2>/dev/null; then echo "[2/5] Applying Bananarchy QDSP6/Q6Voice and MSM8905/MSM8909 DTS patches..." patch -p1 < /bananarchy/patches/kernel/0001-msm8909-qdsp6-voice-sound-nokia-argon-6.12.patch fi diff --git a/scripts/build-sxmo-x11.sh b/scripts/build-sxmo-x11.sh new file mode 100755 index 0000000..e3fc4d9 --- /dev/null +++ b/scripts/build-sxmo-x11.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# Cross-compile Bananarchy X11 UI components for armv7 (Cortex-A7 + NEON-VFPv4): +# - sxmo-st (patched with HarfBuzz ligatures for Fira Code + XIM) +# - sxmo-dmenu (patched with XIM + 240x320 vertical search bar + Fira Code) +# - sxmo-dwm (configured for 240x320 + Fira Code + Pango statusbar + Nokia keypad) +set -eu + +BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)" +ROOTFS_DIR="${ROOTFS_DIR:-$BASE_DIR/rootfs}" +if [ -e "$ROOTFS_DIR" ]; then + ROOTFS_DIR="$(realpath "$ROOTFS_DIR")" +fi + +exec docker run --rm --network=host \ + -e HOST_UID="$(id -u)" \ + -e HOST_GID="$(id -g)" \ + -v "$BASE_DIR:/bananarchy" \ + -v "$ROOTFS_DIR:/target-rootfs" \ + alpine:3.24 sh -eu -c ' + cat > /etc/apk/repositories </dev/null + + echo "[2/5] Preparing armv7 sysroot (X11, Xft, HarfBuzz, Pango, FreeType, Fontconfig)..." + SYSROOT="/tmp/armv7-sysroot" + mkdir -p "$SYSROOT/etc/apk/keys" + cp /etc/apk/repositories "$SYSROOT/etc/apk/repositories" + cp /etc/apk/keys/* "$SYSROOT/etc/apk/keys/" + apk --root "$SYSROOT" --initdb --arch armv7 add --no-scripts \ + alpine-baselayout \ + musl-dev \ + linux-headers \ + libx11-dev \ + libxft-dev \ + libxinerama-dev \ + libxext-dev \ + libxrender-dev \ + libxcb-dev \ + xcb-util-dev \ + fontconfig-dev \ + freetype-dev \ + harfbuzz-dev \ + pango-dev \ + glib-dev \ + cairo-dev >/dev/null + + export PKG_CONFIG_SYSROOT_DIR="$SYSROOT" + export PKG_CONFIG_LIBDIR="$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/share/pkgconfig" + CC="armv7-alpine-linux-musleabihf-gcc --sysroot=$SYSROOT" + STRIP="armv7-alpine-linux-musleabihf-strip" + OPT_CFLAGS="-O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fno-plt -fomit-frame-pointer" + + mkdir -p /bananarchy/prebuilt/sxmo-x11/usr/bin + + echo "[3/5] Compiling patched sxmo-st (with HarfBuzz Fira Code ligatures + XIM)..." + cd /bananarchy/src/sxmo-st + cp -f config.def.h config.h + ST_INCS="$(pkgconf --cflags x11 xft fontconfig freetype2 harfbuzz)" + ST_LIBS="$(pkgconf --libs x11 xft fontconfig freetype2 harfbuzz) -lm -lrt -lutil" + $CC $OPT_CFLAGS -DVERSION=\"0.8.4.1-bananarchy\" -D_XOPEN_SOURCE=600 $ST_INCS \ + st.c x.c hb.c $ST_LIBS -o /bananarchy/prebuilt/sxmo-x11/usr/bin/st + $STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/st + + echo "[4/5] Compiling patched sxmo-dmenu (with XIM + 240x320 vertical layout + Fira Code)..." + cd /bananarchy/src/sxmo-dmenu + cp -f config.def.h config.h + DMENU_INCS="$(pkgconf --cflags x11 xinerama xft fontconfig freetype2)" + DMENU_LIBS="$(pkgconf --libs x11 xinerama xft fontconfig freetype2)" + $CC $OPT_CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"5.0.14-bananarchy\" -DXINERAMA $DMENU_INCS \ + dmenu.c drw.c util.c $DMENU_LIBS -o /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu + $CC $OPT_CFLAGS -D_DEFAULT_SOURCE -DVERSION=\"5.0.14-bananarchy\" \ + stest.c -o /bananarchy/prebuilt/sxmo-x11/usr/bin/stest + cp -f dmenu_path dmenu_run /bananarchy/prebuilt/sxmo-x11/usr/bin/ + chmod 755 /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu_path /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu_run + $STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu /bananarchy/prebuilt/sxmo-x11/usr/bin/stest + + echo "[5/5] Compiling patched sxmo-dwm (240x320 + Fira Code + Pango statusbar + Nokia keypad)..." + cd /bananarchy/src/sxmo-dwm + cp -f config.def.h config.h + DWM_INCS="$(pkgconf --cflags x11 xinerama xft fontconfig freetype2 pango pangoxft xcb xcb-res)" + DWM_LIBS="$(pkgconf --libs x11 xinerama xft fontconfig freetype2 pango pangoxft xcb xcb-res) -lX11-xcb -lrt" + $CC $OPT_CFLAGS -std=c99 -Wno-deprecated-declarations -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"6.3.1-bananarchy\" -DXINERAMA -DNOBONSAI $DWM_INCS \ + dwm.c drw.c util.c $DWM_LIBS -o /bananarchy/prebuilt/sxmo-x11/usr/bin/dwm + $STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/dwm + + mkdir -p /bananarchy/overlay/rootfs/usr/bin + cp -a /bananarchy/prebuilt/sxmo-x11/usr/bin/. /bananarchy/overlay/rootfs/usr/bin/ + if [ -d /target-rootfs/usr/bin ]; then + cp -a /bananarchy/prebuilt/sxmo-x11/usr/bin/. /target-rootfs/usr/bin/ + fi + + chown -R "$HOST_UID:$HOST_GID" /bananarchy/prebuilt/sxmo-x11 /bananarchy/overlay/rootfs/usr/bin /bananarchy/src/sxmo-st /bananarchy/src/sxmo-dmenu /bananarchy/src/sxmo-dwm + ls -lh /bananarchy/prebuilt/sxmo-x11/usr/bin/st /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu /bananarchy/prebuilt/sxmo-x11/usr/bin/dwm +' diff --git a/scripts/build-xlibre.sh b/scripts/build-xlibre.sh new file mode 100755 index 0000000..d983e89 --- /dev/null +++ b/scripts/build-xlibre.sh @@ -0,0 +1,283 @@ +#!/bin/sh +# Cross-compile Xlibre (X11Libre/xserver) + xf86-input-libinput + xf86-video-fbdev +# optimized for Qualcomm MSM8905/MSM8909 (ARMv7 Cortex-A7 + NEON-VFPv4, 240x320 KMS/SPI) +set -eu + +BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)" +ROOTFS_DIR="${ROOTFS_DIR:-$BASE_DIR/rootfs}" +if [ -e "$ROOTFS_DIR" ]; then + ROOTFS_DIR="$(realpath "$ROOTFS_DIR")" +fi + +exec docker run --rm --network=host \ + -e HOST_UID="$(id -u)" \ + -e HOST_GID="$(id -g)" \ + -e FORCE_REBUILD="${FORCE_REBUILD:-0}" \ + -v "$BASE_DIR:/bananarchy" \ + -v "$ROOTFS_DIR:/target-rootfs" \ + alpine:3.24 sh -eu -c ' + cat > /etc/apk/repositories </dev/null + + XLIBRE_SRC="/bananarchy/src/xlibre" + if [ ! -f "$XLIBRE_SRC/meson.build" ]; then + echo "[1b/5] Cloning X11Libre/xserver and applying Bananarchy MSM8905 SPI DRM patch..." + XLIBRE_SRC="/tmp/xlibre-src" + rm -rf "$XLIBRE_SRC" + git clone --depth 1 https://github.com/X11Libre/xserver.git "$XLIBRE_SRC" + patch -d "$XLIBRE_SRC" -p1 < /bananarchy/patches/xlibre/0001-xlibre-msm8905-spi-drm-and-shared-vt.patch + fi + + echo "[2/5] Preparing armv7 sysroot for Xlibre + DDX drivers..." + SYSROOT="/tmp/armv7-sysroot" + mkdir -p "$SYSROOT/etc/apk/keys" + cp /etc/apk/repositories "$SYSROOT/etc/apk/repositories" + cp /etc/apk/keys/* "$SYSROOT/etc/apk/keys/" + apk --root "$SYSROOT" --initdb --arch armv7 add --no-scripts \ + alpine-baselayout \ + musl-dev \ + linux-headers \ + xorgproto \ + xtrans \ + font-util-dev \ + pixman-dev \ + libx11-dev \ + libxext-dev \ + libxfont2-dev \ + libxkbfile-dev \ + libxshmfence-dev \ + libxdmcp-dev \ + libxau-dev \ + libxcvt-dev \ + libdrm-dev \ + mesa-dev \ + eudev-dev \ + dbus-dev \ + libpciaccess-dev \ + openssl-dev \ + libinput-dev \ + mtdev-dev >/dev/null + + OPT_CFLAGS="-O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fno-plt -fomit-frame-pointer" + + cat > /tmp/armv7-cross.ini </dev/null; then + echo "[3/5] Configuring and compiling Xlibre (X11Libre/xserver) for armv7..." + rm -rf /tmp/build-xlibre + meson setup /tmp/build-xlibre "$XLIBRE_SRC" \ + --cross-file=/tmp/armv7-cross.ini \ + --prefix=/usr \ + --libdir=lib \ + --libexecdir=libexec \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --buildtype=release \ + -Dxorg=true \ + -Dxorg-sdk=true \ + -Dglamor=false \ + -Dglx=false \ + -Ddri1=false \ + -Ddri2=true \ + -Ddri3=true \ + -Ddrm=true \ + -Dgbm=true \ + -Dudev=true \ + -Dudev_kms=true \ + -Dsystemd_logind=true \ + -Dseatd_libseat=false \ + -Dsuid_wrapper=false \ + -Dpciaccess=true \ + -Dvgahw=false \ + -Dint10=false \ + -Ddga=false \ + -Dxv=false \ + -Dxvmc=false \ + -Dxephyr=false \ + -Dxnest=false \ + -Dxvfb=false \ + -Dxfake=false \ + -Dxfbdev=false \ + -Dxmodesetting=false \ + -Dxf86-input-inputtest=false \ + -Dxf86-input-null=false \ + -Dlegacy_nvidia_340x=false \ + -Dlegacy_nvidia_padding=false \ + -Ddocs=false \ + -Ddevel-docs=false \ + -Dtests=false \ + -Dlibunwind=false \ + -Dsha1=libcrypto \ + -Dinput_thread=true \ + -Ddefault_font_path=/usr/share/fonts/misc,/usr/share/fonts/TTF,/usr/share/fonts/OTF \ + -Dxkb_dir=/usr/share/X11/xkb \ + -Dxkb_output_dir=/tmp \ + -Dxkb_bin_dir=/usr/bin \ + -Dlog_dir=/tmp + + ninja -C /tmp/build-xlibre -j"$(nproc)" + rm -rf /bananarchy/prebuilt/xlibre + mkdir -p /bananarchy/prebuilt/xlibre + DESTDIR="/bananarchy/prebuilt/xlibre" ninja -C /tmp/build-xlibre install + elif ! grep -q "Failed to allocate cursor BOs" "/bananarchy/prebuilt/xlibre$ABI_MOD_DIR/drivers/modesetting_drv.so" 2>/dev/null; then + echo "[3/5] Rebuilding patched modesetting_drv.so in Xlibre..." + rm -rf /tmp/build-xlibre + meson setup /tmp/build-xlibre "$XLIBRE_SRC" \ + --cross-file=/tmp/armv7-cross.ini \ + --prefix=/usr \ + --libdir=lib \ + --libexecdir=libexec \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --buildtype=release \ + -Dxorg=true \ + -Dxorg-sdk=true \ + -Dglamor=false \ + -Dglx=false \ + -Ddri1=false \ + -Ddri2=true \ + -Ddri3=true \ + -Ddrm=true \ + -Dgbm=true \ + -Dudev=true \ + -Dudev_kms=true \ + -Dsystemd_logind=true \ + -Dseatd_libseat=false \ + -Dsuid_wrapper=false \ + -Dpciaccess=true \ + -Dvgahw=false \ + -Dint10=false \ + -Ddga=false \ + -Dxv=false \ + -Dxvmc=false \ + -Dxephyr=false \ + -Dxnest=false \ + -Dxvfb=false \ + -Dxfake=false \ + -Dxfbdev=false \ + -Dxmodesetting=false \ + -Dxf86-input-inputtest=false \ + -Dxf86-input-null=false \ + -Dlegacy_nvidia_340x=false \ + -Dlegacy_nvidia_padding=false \ + -Ddocs=false \ + -Ddevel-docs=false \ + -Dtests=false \ + -Dlibunwind=false \ + -Dsha1=libcrypto \ + -Dinput_thread=true \ + -Dxkb_dir=/usr/share/X11/xkb \ + -Dxkb_output_dir=/tmp \ + -Dxkb_bin_dir=/usr/bin \ + -Dlog_dir=/tmp + ninja -C /tmp/build-xlibre -j"$(nproc)" hw/xfree86/drivers/video/modesetting/modesetting_drv.so + cp -f /tmp/build-xlibre/hw/xfree86/drivers/video/modesetting/modesetting_drv.so "/bananarchy/prebuilt/xlibre$ABI_MOD_DIR/drivers/modesetting_drv.so" + else + echo "[3/5] Reusing compiled Xlibre in /bananarchy/prebuilt/xlibre..." + fi + + if [ -d /bananarchy/prebuilt/xlibre/tmp/armv7-sysroot/usr ]; then + cp -a /bananarchy/prebuilt/xlibre/tmp/armv7-sysroot/usr/. /bananarchy/prebuilt/xlibre/usr/ + rm -rf /bananarchy/prebuilt/xlibre/tmp + fi + + cp -a /bananarchy/prebuilt/xlibre/usr/. "$SYSROOT/usr/" + + echo "[4/5] Compiling X11Libre/xf86-input-libinput and xf86-video-fbdev against Xlibre SDK..." + ABI_MOD_DIR="/usr/lib/xorg/modules/xlibre-25" + if [ ! -f "/bananarchy/prebuilt/xlibre$ABI_MOD_DIR/input/libinput_drv.so" ]; then + rm -rf /tmp/build-libinput + meson setup /tmp/build-libinput /bananarchy/src/xf86-input-libinput \ + --cross-file=/tmp/armv7-cross.ini \ + --prefix=/usr \ + --libdir=lib \ + --sysconfdir=/etc \ + --buildtype=release \ + -Dxorg-module-dir="$ABI_MOD_DIR/input" \ + -Dsdkdir=/usr/include/xorg \ + -Dxorg-conf-dir=/usr/share/X11/xorg.conf.d + ninja -C /tmp/build-libinput -j"$(nproc)" + DESTDIR="/bananarchy/prebuilt/xlibre" ninja -C /tmp/build-libinput install + fi + + mkdir -p "/bananarchy/prebuilt/xlibre$ABI_MOD_DIR/drivers" /tmp/fbdev-inc + cat > /tmp/fbdev-inc/config.h </dev/null || true + ls -lh /bananarchy/prebuilt/xlibre/usr/bin/Xorg "/bananarchy/prebuilt/xlibre$ABI_MOD_DIR/drivers/"*.so "/bananarchy/prebuilt/xlibre$ABI_MOD_DIR/input/"*.so +' diff --git a/scripts/configure-rootfs-from-scratch.sh b/scripts/configure-rootfs-from-scratch.sh index 07cdff8..2892095 100755 --- a/scripts/configure-rootfs-from-scratch.sh +++ b/scripts/configure-rootfs-from-scratch.sh @@ -343,21 +343,35 @@ Layout= EOF cp "$ROOTFS/etc/skel/.config/fcitx5/profile" "$ROOTFS/home/user/.config/fcitx5/profile" - cat > "$ROOTFS/etc/profile.d/fcitx5-t9.sh" < "$ROOTFS/etc/profile.d/fcitx5-t9.sh" <<'EOF' export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx export SXMO_MENU=wofi +export SXMO_BEMENU_PORTRAIT_LINES=11 +export SXMO_BEMENU_LANDSCAPE_LINES=8 +export BEMENU_OPTS='--fn "Sxmo 11.5" -H 24 -B 2 --hp 4 -s --no-overlap --fixed-height --scrollbar none --cw 2 --bdr "#005577" --tb "#383838" --tf "#aaaaaa" --fb "#383838" --ff "#ffffff" --cb "#ffffff" --cf "#383838" --nb "#1c1c1c" --nf "#ffffff" --ab "#1c1c1c" --af "#ffffff" --hb "#005577" --hf "#ffffff" -w -i' EOF chmod 755 "$ROOTFS/etc/profile.d/fcitx5-t9.sh" if ! grep -q "GTK_IM_MODULE=fcitx" "$ROOTFS/etc/skel/.profile" 2>/dev/null; then - cat >> "$ROOTFS/etc/skel/.profile" <> "$ROOTFS/etc/skel/.profile" <<'EOF' +export PATH="$HOME/.local/bin:$PATH" +export WLR_RENDERER=pixman +export WLR_NO_HARDWARE_CURSORS=1 +export SXMO_DISABLE_LEDS=1 +export SXMO_NO_VIRTUAL_KEYBOARD=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx export SXMO_MENU=wofi +export SXMO_BEMENU_PORTRAIT_LINES=11 +export SXMO_BEMENU_LANDSCAPE_LINES=8 +export BEMENU_OPTS='--fn "Sxmo 11.5" -H 24 -B 2 --hp 4 -s --no-overlap --fixed-height --scrollbar none --cw 2 --bdr "#005577" --tb "#383838" --tf "#aaaaaa" --fb "#383838" --ff "#ffffff" --cb "#ffffff" --cf "#383838" --nb "#1c1c1c" --nf "#ffffff" --ab "#1c1c1c" --af "#ffffff" --hb "#005577" --hf "#ffffff" -w -i' EOF fi cp "$ROOTFS/etc/skel/.profile" "$ROOTFS/home/user/.profile" @@ -446,8 +460,16 @@ export SXMO_ENTER_BUTTON="0:352:KEY_OK" # Nokia 8110 4G has a physical keypad and no touchscreen export SXMO_NO_VIRTUAL_KEYBOARD=1 +export SXMO_DISABLE_LEDS=1 export KEYBOARD_ARGS="-H 1 -L 1" +export WLR_RENDERER=pixman +export WLR_NO_HARDWARE_CURSORS=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 export SXMO_MENU=wofi +export SXMO_BEMENU_PORTRAIT_LINES=11 +export SXMO_BEMENU_LANDSCAPE_LINES=8 EOF chmod 755 "$ROOTFS/usr/bin/sxmo_deviceprofile_nokia,argon.sh" @@ -667,12 +689,23 @@ PYEOF "$target_home/.config/fontconfig/conf.d" cp "$ROOTFS/usr/share/sxmo/appcfg/profile_template" "$target_home/.config/sxmo/profile" if ! grep -q "SXMO_MENU=wofi" "$target_home/.config/sxmo/profile"; then - cat >> "$target_home/.config/sxmo/profile" <> "$target_home/.config/sxmo/profile" <<'EOF' +export PATH="$HOME/.local/bin:$PATH" +export WLR_RENDERER=pixman +export WLR_NO_HARDWARE_CURSORS=1 +export SXMO_DISABLE_LEDS=1 +export SXMO_NO_VIRTUAL_KEYBOARD=1 +export NO_AT_BRIDGE=1 +export GTK_A11Y=none +export GTK_USE_PORTAL=0 export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx export SXMO_MENU=wofi +export SXMO_BEMENU_PORTRAIT_LINES=11 +export SXMO_BEMENU_LANDSCAPE_LINES=8 +export BEMENU_OPTS='--fn "Sxmo 11.5" -H 24 -B 2 --hp 4 -s --no-overlap --fixed-height --scrollbar none --cw 2 --bdr "#005577" --tb "#383838" --tf "#aaaaaa" --fb "#383838" --ff "#ffffff" --cb "#ffffff" --cf "#383838" --nb "#1c1c1c" --nf "#ffffff" --ab "#1c1c1c" --af "#ffffff" --hb "#005577" --hf "#ffffff" -w -i' EOF fi cp "$ROOTFS/usr/share/sxmo/appcfg/sway_template" "$target_home/.config/sxmo/sway" diff --git a/src/fcitx5-t9/src/t9.cpp b/src/fcitx5-t9/src/t9.cpp index 1298345..d8342bb 100644 --- a/src/fcitx5-t9/src/t9.cpp +++ b/src/fcitx5-t9/src/t9.cpp @@ -5,64 +5,18 @@ #include #include +#include #include #include -#include +#include +#include #include - -#include +#include namespace { -struct wl_proxy; -struct wl_interface; - -using WlProxyGetVersionFn = uint32_t (*)(struct wl_proxy*); -using WlProxyMarshalFlagsFn = struct wl_proxy* (*)( - struct wl_proxy*, uint32_t, const struct wl_interface*, uint32_t, uint32_t, - ...); - -void sendWaylandVkModifiers(fcitx::InputContext* ic, uint32_t modsDepressed) { - if (!ic || ic->frontendName() != std::string_view("wayland_v2")) { - return; - } - static void* wlHandle = dlopen("libwayland-client.so.0", RTLD_LAZY); - static auto getVer = - wlHandle ? reinterpret_cast( - dlsym(wlHandle, "wl_proxy_get_version")) - : nullptr; - static auto marshalFlags = - wlHandle ? reinterpret_cast( - dlsym(wlHandle, "wl_proxy_marshal_flags")) - : nullptr; - if (!getVer || !marshalFlags) { - return; - } - auto* raw = reinterpret_cast(ic); - std::string_view typeName(typeid(*ic).name()); - if (typeName.find("VirtualInputContext") != std::string_view::npos) { - raw = *reinterpret_cast(raw + 3 * sizeof(void*)); - if (!raw) { - return; - } - } - if (!raw[54]) { - return; - } - void* vkObj = *reinterpret_cast(raw + 40); - if (!vkObj) { - return; - } - auto* proxy = *reinterpret_cast( - reinterpret_cast(vkObj) + 2 * sizeof(void*)); - if (!proxy) { - return; - } - constexpr uint32_t kZwpVirtualKeyboardV1ModifiersOpcode = 2; - uint32_t ver = getVer(proxy); - marshalFlags(proxy, kZwpVirtualKeyboardV1ModifiersOpcode, nullptr, ver, 0, - modsDepressed, 0u, 0u, 0u); -} +const fcitx::Rect kFixedPopupRect(1, 289, 2, 290); +constexpr size_t kFixedPreeditChars = 28; constexpr int kKey1 = 1; constexpr int kKey2 = 2; @@ -237,24 +191,50 @@ bool charToCtrlKey(char ch, fcitx::KeySym* symOut, uint32_t* xkbCodeOut) { } int mapHardwareKey(const fcitx::Key& key) { + if (key.states().testAny(fcitx::KeyState::Ctrl_Alt) || + key.states().test(fcitx::KeyState::Super)) { + return -1; + } uint32_t code = key.code(); // XKB keycodes: KEY_1..KEY_9 = 10..18, KEY_0 = 19 if (code >= 10 && code <= 19) { return static_cast(code - 9); } - // KEY_NUMERIC_STAR (evdev 522 -> XKB 530) - if (code == 530 || key.sym() == FcitxKey_asterisk || + // KEY_NUMERIC_STAR (evdev 522 -> XKB 530, or remapped KEY_KPASTERISK -> XKB 63) + if (code == 530 || code == 63 || key.sym() == FcitxKey_asterisk || + key.sym() == FcitxKey_KP_Multiply || static_cast(key.sym()) == 0x1008ffaa) { return kKeyStar; } - // KEY_NUMERIC_POUND (evdev 523 -> XKB 531) - if (code == 531 || key.sym() == FcitxKey_numbersign || + // KEY_NUMERIC_POUND (evdev 523 -> XKB 531, or remapped KEY_KPSLASH -> XKB 106) + if (code == 531 || code == 106 || key.sym() == FcitxKey_numbersign || + key.sym() == FcitxKey_KP_Divide || static_cast(key.sym()) == 0x1008ffab) { return kKeyPound; } return -1; } +void writeStatusIndicator(const std::string& badge) { + const char* runtimeDir = std::getenv("XDG_RUNTIME_DIR"); + std::string base = (runtimeDir && runtimeDir[0]) ? runtimeDir : "/run/user/10000"; + std::string statusDir = base + "/sxmo_status/default"; + ::mkdir((base + "/sxmo_status").c_str(), 0700); + ::mkdir(statusDir.c_str(), 0700); + + std::string modeFile = base + "/sxmo_t9_mode"; + if (FILE* fp = std::fopen(modeFile.c_str(), "w")) { + std::fprintf(fp, "%s\n", badge.c_str()); + std::fclose(fp); + } + + std::string barFile = statusDir + "/005-input-method"; + if (FILE* fp = std::fopen(barFile.c_str(), "w")) { + std::fprintf(fp, "%s\n", badge.c_str()); + std::fclose(fp); + } +} + } // namespace T9Engine::T9Engine(fcitx::Instance* instance) @@ -262,6 +242,17 @@ T9Engine::T9Engine(fcitx::Instance* instance) return new T9State(this, &ic); }) { instance->inputContextManager().registerProperty("t9State", &factory); + cursorWatcher = instance->watchEvent( + fcitx::EventType::InputContextCursorRectChanged, + fcitx::EventWatcherPhase::PreInputMethod, + [](fcitx::Event& event) { + auto& icEvent = static_cast(event); + auto* ic = icEvent.inputContext(); + if (ic && ic->cursorRect() != kFixedPopupRect) { + ic->setCursorRect(kFixedPopupRect); + } + }); + writeStatusIndicator("[abc]"); } std::vector T9Engine::listInputMethods() { @@ -273,6 +264,14 @@ std::vector T9Engine::listInputMethods() { return result; } +void T9Engine::activate(const fcitx::InputMethodEntry& entry, + fcitx::InputContextEvent& event) { + FCITX_UNUSED(entry); + auto* ic = event.inputContext(); + auto* state = ic->propertyFor(&factory); + state->reset(); +} + void T9Engine::keyEvent(const fcitx::InputMethodEntry& entry, fcitx::KeyEvent& keyEvent) { FCITX_UNUSED(entry); @@ -296,6 +295,10 @@ void T9Engine::reset(const fcitx::InputMethodEntry& entry, FCITX_ADDON_FACTORY(T9EngineFactory); +void T9State::updateStatusBar() const { + writeStatusIndicator("[" + modePrefix() + "]"); +} + std::string T9State::modePrefix() const { std::string p; switch (mode) { @@ -520,6 +523,8 @@ void T9State::cycleMode() { mode = T9Mode::Lower; break; } + engine->sharedMode = mode; + updateStatusBar(); showStatusBanner("[Mode: " + modePrefix() + "]"); } @@ -560,6 +565,7 @@ void T9State::stepCandidate(int delta) { } bool T9State::handleKeyEvent(fcitx::KeyEvent& keyEvent) { + mode = engine->sharedMode; fcitx::Key key = keyEvent.key(); uint32_t code = key.code(); fcitx::KeySym sym = key.sym(); @@ -654,45 +660,52 @@ bool T9State::handleKeyEvent(fcitx::KeyEvent& keyEvent) { if (releasedId != keyId && releasedId != -1) { return true; } - if (keyId == kKeyPound) { - if (!activeItems.empty()) { - toggleCurrentCase(); - } else { - cycleMode(); - } - return true; + if (!activeItems.empty()) { + uint64_t delayUs = (activeItems.size() > 10) ? 1800000 : 1500000; + scheduleCommit(delayUs); } - if (mode == T9Mode::Num) { - if (bannerTimer) { - bannerTimer.reset(); - resetUI(); - } - if (keyId >= kKey1 && keyId <= kKey9) { - sendItem(makeChar(static_cast('0' + keyId))); - } else if (keyId == kKey0) { - sendItem(makeChar('0')); - } else if (keyId == kKeyStar) { - sendItem(makeChar('*')); - } - return true; - } - handleMultiTap(keyId); return true; } // Key press event - if (pressedKeyId != keyId) { - pressedKeyId = keyId; - isLongPressHandled = false; - startLongPressTimer(keyId); + if (pressedKeyId == keyId) { + // Ignore X11 auto-repeat key presses while holding the same key + return true; } + pressedKeyId = keyId; + isLongPressHandled = false; + startLongPressTimer(keyId); + + if (keyId == kKeyPound) { + if (!activeItems.empty()) { + toggleCurrentCase(); + } else { + cycleMode(); + } + return true; + } + if (mode == T9Mode::Num) { + if (bannerTimer) { + bannerTimer.reset(); + resetUI(); + } + if (keyId >= kKey1 && keyId <= kKey9) { + sendItem(makeChar(static_cast('0' + keyId))); + } else if (keyId == kKey0) { + sendItem(makeChar('0')); + } else if (keyId == kKeyStar) { + sendItem(makeChar('*')); + } + return true; + } + handleMultiTap(keyId); return true; } void T9State::startLongPressTimer(int keyId) { cancelLongPressTimer(); longPressTimer = engine->instance->eventLoop().addTimeEvent( - CLOCK_MONOTONIC, fcitx::now(CLOCK_MONOTONIC) + 450000, 0, + CLOCK_MONOTONIC, fcitx::now(CLOCK_MONOTONIC) + 550000, 0, [this, keyId](fcitx::EventSourceTime*, uint64_t) { onLongPress(keyId); return true; @@ -707,9 +720,11 @@ void T9State::cancelLongPressTimer() { void T9State::onLongPress(int keyId) { isLongPressHandled = true; - if (!activeItems.empty()) { - commit(); - } + // Discard current key's uncommitted multi-tap candidate and commit long-press action + cancelCommit(); + activeItems.clear(); + lastKeyId = -1; + currentIndex = 0; if (keyId >= kKey1 && keyId <= kKey9) { sendItem(makeChar(static_cast('0' + keyId))); resetUI(); @@ -722,6 +737,7 @@ void T9State::onLongPress(int keyId) { resetUI(); } else { ctrlLatch = !ctrlLatch; + updateStatusBar(); showStatusBanner(ctrlLatch ? "[Ctrl+ LATCH ON]" : "[Ctrl+ LATCH OFF]"); } } else if (keyId == kKeyPound) { @@ -747,7 +763,7 @@ void T9State::handleMultiTap(int keyId) { if (activeItems.empty()) { return; } - uint64_t delayUs = (activeItems.size() > 10) ? 750000 : 600000; + uint64_t delayUs = (activeItems.size() > 10) ? 1800000 : 1500000; scheduleCommit(delayUs); showPreview(activeItems, currentIndex); } @@ -758,21 +774,20 @@ void T9State::reset() { if (bannerTimer) { bannerTimer.reset(); } + mode = engine->sharedMode; lastKeyId = -1; pressedKeyId = -1; currentIndex = 0; activeItems.clear(); isLongPressHandled = false; ctrlLatch = false; + updateStatusBar(); } void T9State::forwardKeyTap(fcitx::KeySym sym, fcitx::KeyStates states, uint32_t xkbCode) { if (states.test(fcitx::KeyState::Ctrl)) { - constexpr uint32_t kXkbModCtrl = (1u << 2); - sendWaylandVkModifiers(ic, kXkbModCtrl); ic->forwardKey(fcitx::Key(sym, fcitx::KeyState::Ctrl, xkbCode), false); - sendWaylandVkModifiers(ic, 0u); } else { ic->forwardKey(fcitx::Key(sym, states, xkbCode), false); } @@ -783,12 +798,16 @@ void T9State::sendItem(const T9Item& item) { fcitx::KeySym cSym = FcitxKey_None; uint32_t cCode = 0; ctrlLatch = false; + updateStatusBar(); if (charToCtrlKey(item.commitText[0], &cSym, &cCode)) { forwardKeyTap(cSym, fcitx::KeyState::Ctrl, cCode); return; } } - ctrlLatch = false; + if (ctrlLatch) { + ctrlLatch = false; + updateStatusBar(); + } if (item.sym != FcitxKey_None) { forwardKeyTap(item.sym, item.states, item.xkbCode); } else if (!item.commitText.empty()) { @@ -796,6 +815,8 @@ void T9State::sendItem(const T9Item& item) { if (mode == T9Mode::Shift && std::isalpha(static_cast(item.commitText[0]))) { mode = T9Mode::Lower; + engine->sharedMode = mode; + updateStatusBar(); } } } @@ -849,19 +870,19 @@ void T9State::showStatusBanner(const std::string& msg) { if (bannerTimer) { bannerTimer.reset(); } + std::string padded = msg; + if (padded.size() < kFixedPreeditChars) { + padded.append(kFixedPreeditChars - padded.size(), ' '); + } + ic->setCursorRect(kFixedPopupRect); auto& inputPanel = ic->inputPanel(); inputPanel.reset(); fcitx::Text text; - text.append(msg); - if (ic->capabilityFlags().test(fcitx::CapabilityFlag::Preedit)) { - inputPanel.setClientPreedit(text); - ic->updatePreedit(); - } else { - inputPanel.setPreedit(text); - } + text.append(padded); + inputPanel.setPreedit(text); ic->updateUserInterface(fcitx::UserInterfaceComponent::InputPanel); bannerTimer = engine->instance->eventLoop().addTimeEvent( - CLOCK_MONOTONIC, fcitx::now(CLOCK_MONOTONIC) + 900000, 0, + CLOCK_MONOTONIC, fcitx::now(CLOCK_MONOTONIC) + 1500000, 0, [this](fcitx::EventSourceTime*, uint64_t) { resetUI(); return true; @@ -873,50 +894,35 @@ void T9State::showPreview(const std::vector& items, int index) { if (total == 0) { return; } - constexpr int kMaxVisible = 7; - int start = 0; - int end = total; - if (total > kMaxVisible) { - start = index - (kMaxVisible / 2); - if (start < 0) { - start = 0; - } - end = start + kMaxVisible; - if (end > total) { - end = total; - start = end - kMaxVisible; - } - } + constexpr int kPageSize = 7; + int page = index / kPageSize; + int start = page * kPageSize; + int end = std::min(start + kPageSize, total); - std::string preedit = modePrefix() + ": "; - if (start > 0) { - preedit += "< "; - } + std::string preedit = modePrefix() + ":"; for (int i = start; i < end; ++i) { if (i == index) { preedit += "["; preedit += items[i].label; preedit += "]"; } else { + preedit += " "; preedit += items[i].label; - } - if (i < end - 1) { preedit += " "; } } - if (end < total) { - preedit += " >"; + if (total > kPageSize) { + preedit += (end < total) ? ">" : "<"; + } + if (preedit.size() < kFixedPreeditChars) { + preedit.append(kFixedPreeditChars - preedit.size(), ' '); } + ic->setCursorRect(kFixedPopupRect); auto& inputPanel = ic->inputPanel(); inputPanel.reset(); fcitx::Text text; text.append(preedit); - if (ic->capabilityFlags().test(fcitx::CapabilityFlag::Preedit)) { - inputPanel.setClientPreedit(text); - ic->updatePreedit(); - } else { - inputPanel.setPreedit(text); - } + inputPanel.setPreedit(text); ic->updateUserInterface(fcitx::UserInterfaceComponent::InputPanel); } diff --git a/src/fcitx5-t9/src/t9.h b/src/fcitx5-t9/src/t9.h index b88cf85..2ece94a 100644 --- a/src/fcitx5-t9/src/t9.h +++ b/src/fcitx5-t9/src/t9.h @@ -46,13 +46,14 @@ class T9State : public fcitx::InputContextProperty { private: std::vector getItemsForKey(int keyId) const; std::string modePrefix() const; + void updateStatusBar() const; void cycleMode(); void toggleCurrentCase(); void stepCandidate(int delta); void startLongPressTimer(int keyId); void cancelLongPressTimer(); void onLongPress(int keyId); - void scheduleCommit(uint64_t delayUs = 600000); + void scheduleCommit(uint64_t delayUs = 1500000); void commit(); void sendItem(const T9Item& item); void forwardKeyTap(fcitx::KeySym sym, fcitx::KeyStates states, @@ -80,14 +81,18 @@ class T9Engine : public fcitx::InputMethodEngineV2 { public: explicit T9Engine(fcitx::Instance* instance); std::vector listInputMethods() override; + void activate(const fcitx::InputMethodEntry& entry, + fcitx::InputContextEvent& event) override; void keyEvent(const fcitx::InputMethodEntry& entry, fcitx::KeyEvent& keyEvent) override; void reset(const fcitx::InputMethodEntry& entry, fcitx::InputContextEvent& event) override; fcitx::Instance* instance; + T9Mode sharedMode = T9Mode::Lower; private: fcitx::FactoryFor factory; + std::unique_ptr> cursorWatcher; }; class T9EngineFactory : public fcitx::AddonFactory { diff --git a/src/leds-msm8905-torch/leds-msm8905-torch.c b/src/leds-msm8905-torch/leds-msm8905-torch.c index 8df07cb..95e2ee6 100644 --- a/src/leds-msm8905-torch/leds-msm8905-torch.c +++ b/src/leds-msm8905-torch/leds-msm8905-torch.c @@ -42,7 +42,8 @@ #define RCGR_D_TORCH_50PCT 0xff7fU #define RCGR_CMD_ENABLE_UPDATE 0x0003U /* ROOT_EN | CMD_UPDATE */ -/* PM8909 PON registers for PS_HOLD shutdown vs warm reset configuration */ +/* PM8909 PON registers for PS_HOLD shutdown vs hard reset configuration */ +#define QPNP_PON_REVISION2 0x0801U #define QPNP_PON_PS_HOLD_RST_CTL 0x085aU #define QPNP_PON_PS_HOLD_RST_CTL2 0x085bU #define QPNP_PON_S2_CNTL_EN 0x80U @@ -54,6 +55,8 @@ static void __iomem *tlmm_gpio32_base; static void __iomem *gcc_camss_base; static struct regmap *pon_regmap; +static struct sys_off_handler *pon_poweroff_handler; +static struct sys_off_handler *pon_restart_handler; static DEFINE_SPINLOCK(torch_lock); static enum led_brightness current_brightness = LED_OFF; @@ -131,51 +134,66 @@ static struct led_classdev msm8905_torch_led = { .flags = LED_CORE_SUSPENDRESUME, }; +static void msm8905_pon_config_reset(unsigned int rst_type) +{ + unsigned int rev2 = 0; + unsigned int ctl_reg = QPNP_PON_PS_HOLD_RST_CTL2; + + if (!pon_regmap) + return; + + if (regmap_read(pon_regmap, QPNP_PON_REVISION2, &rev2) == 0 && rev2 == 0) + ctl_reg = QPNP_PON_PS_HOLD_RST_CTL; + + /* + * Match Qualcomm qpnp_pon_system_pwr_off(): + * 1. Disable S2_CNTL_EN (bit 7 of 0x085b on Gen2 / 0x085a on Gen1) + * 2. Wait >10 sleep clock cycles (~350 us) + * 3. Program PS_HOLD_RST_CTL (0x085a) to SHUTDOWN (0x04) or HARD_RESET (0x07) + * 4. Re-enable S2_CNTL_EN (bit 7) and wait ~350 us + */ + regmap_update_bits(pon_regmap, ctl_reg, QPNP_PON_S2_CNTL_EN, 0); + udelay(350); + + regmap_update_bits(pon_regmap, QPNP_PON_PS_HOLD_RST_CTL, + QPNP_PON_RST_TYPE_MASK, rst_type); + udelay(350); + + regmap_update_bits(pon_regmap, ctl_reg, + QPNP_PON_S2_CNTL_EN, QPNP_PON_S2_CNTL_EN); + udelay(350); + + pr_info("leds-msm8905-torch: configured PM8909 PON PS_HOLD_RST_CTL=0x%02x (%s)\n", + rst_type, (rst_type == PON_POWER_OFF_SHUTDOWN) ? "shutdown" : "hard-reset"); +} + +static int msm8905_pon_sys_poweroff(struct sys_off_data *data) +{ + msm8905_torch_hw_disable(); + msm8905_pon_config_reset(PON_POWER_OFF_SHUTDOWN); + return NOTIFY_DONE; +} + +static int msm8905_pon_sys_restart(struct sys_off_data *data) +{ + msm8905_torch_hw_disable(); + msm8905_pon_config_reset(PON_POWER_OFF_HARD_RESET); + return NOTIFY_DONE; +} + static int msm8905_pon_reboot_notify(struct notifier_block *nb, unsigned long action, void *data) { - unsigned int ctl1 = 0; - unsigned int ctl2 = 0; unsigned int rst_type; msm8905_torch_hw_disable(); - if (!pon_regmap) - return NOTIFY_DONE; - if (action == SYS_POWER_OFF || action == SYS_HALT) rst_type = PON_POWER_OFF_SHUTDOWN; else - rst_type = PON_POWER_OFF_WARM_RESET; + rst_type = PON_POWER_OFF_HARD_RESET; - /* - * Match Qualcomm qpnp_pon_system_pwr_off(): - * 1. Disable S2_CNTL_EN (bit 7 of 0x085b) - * 2. Wait >10 sleep clock cycles (~500 us) - * 3. Program PS_HOLD_RST_CTL (0x085a) to SHUTDOWN (0x04) or WARM_RESET (0x01) - * 4. Re-enable S2_CNTL_EN (bit 7 of 0x085b) and wait ~500 us - */ - if (regmap_read(pon_regmap, QPNP_PON_PS_HOLD_RST_CTL2, &ctl2) == 0) - regmap_write(pon_regmap, QPNP_PON_PS_HOLD_RST_CTL2, ctl2 & ~QPNP_PON_S2_CNTL_EN); - else - regmap_write(pon_regmap, QPNP_PON_PS_HOLD_RST_CTL2, 0x00U); - - udelay(500); - - if (regmap_read(pon_regmap, QPNP_PON_PS_HOLD_RST_CTL, &ctl1) == 0) - ctl1 = (ctl1 & ~QPNP_PON_RST_TYPE_MASK) | rst_type; - else - ctl1 = rst_type; - regmap_write(pon_regmap, QPNP_PON_PS_HOLD_RST_CTL, ctl1); - - udelay(500); - - regmap_write(pon_regmap, QPNP_PON_PS_HOLD_RST_CTL2, - (ctl2 & ~QPNP_PON_S2_CNTL_EN) | QPNP_PON_S2_CNTL_EN); - udelay(500); - - pr_info("leds-msm8905-torch: configured PM8909 PON PS_HOLD_RST_CTL=0x%02x for %s\n", - ctl1, (rst_type == PON_POWER_OFF_SHUTDOWN) ? "shutdown" : "reboot"); + msm8905_pon_config_reset(rst_type); return NOTIFY_OK; } @@ -253,7 +271,16 @@ static int __init msm8905_torch_init(void) } msm8905_pon_lookup_regmap(); + msm8905_pon_config_reset(PON_POWER_OFF_HARD_RESET); register_reboot_notifier(&msm8905_pon_reboot_nb); + pon_poweroff_handler = register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_HIGH, + msm8905_pon_sys_poweroff, + NULL); + pon_restart_handler = register_sys_off_handler(SYS_OFF_MODE_RESTART, + SYS_OFF_PRIO_HIGH, + msm8905_pon_sys_restart, + NULL); pr_info("leds-msm8905-torch: registered white:torch on GPIO_32 (cci_timer1 150kHz PWM), pon_regmap=%s\n", pon_regmap ? "ready" : "none"); @@ -262,6 +289,10 @@ static int __init msm8905_torch_init(void) static void __exit msm8905_torch_exit(void) { + if (!IS_ERR_OR_NULL(pon_restart_handler)) + unregister_sys_off_handler(pon_restart_handler); + if (!IS_ERR_OR_NULL(pon_poweroff_handler)) + unregister_sys_off_handler(pon_poweroff_handler); unregister_reboot_notifier(&msm8905_pon_reboot_nb); led_classdev_unregister(&msm8905_torch_led); msm8905_torch_hw_disable(); diff --git a/src/sxmo-dmenu/.build.yml b/src/sxmo-dmenu/.build.yml new file mode 100644 index 0000000..9980d9c --- /dev/null +++ b/src/sxmo-dmenu/.build.yml @@ -0,0 +1,15 @@ +image: alpine/edge +packages: + - editorconfig-checker + - libxft-dev + - libx11-dev + - libxinerama-dev +sources: + - https://git.sr.ht/~mil/sxmo-dmenu +tasks: + - editorconfig-check: | + cd sxmo-dmenu + ec + - make: | + cd sxmo-dmenu + make diff --git a/src/sxmo-dmenu/.editorconfig b/src/sxmo-dmenu/.editorconfig new file mode 100644 index 0000000..b9e964e --- /dev/null +++ b/src/sxmo-dmenu/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*.{sh|c}] +end_of_line = lf +insert_final_newline = true +indent_style = tab +#max_line_length = 80 +spaces_around_operators = true +charset = utf-8 +trim_trailing_whitespace = true diff --git a/src/sxmo-dmenu/LICENSE b/src/sxmo-dmenu/LICENSE new file mode 100644 index 0000000..3afd28e --- /dev/null +++ b/src/sxmo-dmenu/LICENSE @@ -0,0 +1,30 @@ +MIT/X Consortium License + +© 2006-2019 Anselm R Garbe +© 2006-2008 Sander van Dijk +© 2006-2007 Michał Janeczek +© 2007 Kris Maglione +© 2009 Gottox +© 2009 Markus Schnalke +© 2009 Evan Gates +© 2010-2012 Connor Lane Smith +© 2014-2020 Hiltjo Posthuma +© 2015-2019 Quentin Rameau + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/sxmo-dmenu/Makefile b/src/sxmo-dmenu/Makefile new file mode 100644 index 0000000..a03a95c --- /dev/null +++ b/src/sxmo-dmenu/Makefile @@ -0,0 +1,64 @@ +# dmenu - dynamic menu +# See LICENSE file for copyright and license details. + +include config.mk + +SRC = drw.c dmenu.c stest.c util.c +OBJ = $(SRC:.c=.o) + +all: options dmenu stest + +options: + @echo dmenu build options: + @echo "CFLAGS = $(CFLAGS)" + @echo "LDFLAGS = $(LDFLAGS)" + @echo "CC = $(CC)" + +.c.o: + $(CC) -c $(CFLAGS) $< + +config.h: + cp config.def.h $@ + +$(OBJ): arg.h config.h config.mk drw.h + +dmenu: dmenu.o drw.o util.o + $(CC) -o $@ dmenu.o drw.o util.o $(LDFLAGS) + +stest: stest.o + $(CC) -o $@ stest.o $(LDFLAGS) + +clean: + rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz + +dist: clean + mkdir -p dmenu-$(VERSION) + cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\ + drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\ + dmenu-$(VERSION) + tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION) + gzip dmenu-$(VERSION).tar + rm -rf dmenu-$(VERSION) + +install: all + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu + chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path + chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run + chmod 755 $(DESTDIR)$(PREFIX)/bin/stest + mkdir -p $(DESTDIR)$(MANPREFIX)/man1 + sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 + sed "s/VERSION/$(VERSION)/g" < stest.1 > $(DESTDIR)$(MANPREFIX)/man1/stest.1 + chmod 644 $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 + chmod 644 $(DESTDIR)$(MANPREFIX)/man1/stest.1 + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\ + $(DESTDIR)$(PREFIX)/bin/dmenu_path\ + $(DESTDIR)$(PREFIX)/bin/dmenu_run\ + $(DESTDIR)$(PREFIX)/bin/stest\ + $(DESTDIR)$(MANPREFIX)/man1/dmenu.1\ + $(DESTDIR)$(MANPREFIX)/man1/stest.1 + +.PHONY: all options clean dist install uninstall diff --git a/src/sxmo-dmenu/README.md b/src/sxmo-dmenu/README.md new file mode 100644 index 0000000..23e8765 --- /dev/null +++ b/src/sxmo-dmenu/README.md @@ -0,0 +1,27 @@ +dmenu - dynamic menu +==================== + +[![builds.sr.ht status](https://builds.sr.ht/~mil/sxmo-dmenu.svg)](https://builds.sr.ht/~mil/sxmo-dmenu?) + +dmenu is an efficient dynamic menu for X. + + +Requirements +------------ +In order to build dmenu you need the Xlib header files. + + +Installation +------------ +Edit config.mk to match your local setup (dmenu is installed into +the /usr/local namespace by default). + +Afterwards enter the following command to build and install dmenu +(if necessary as root): + + make clean install + + +Running dmenu +------------- +See the man page for details. diff --git a/src/sxmo-dmenu/arg.h b/src/sxmo-dmenu/arg.h new file mode 100644 index 0000000..e94e02b --- /dev/null +++ b/src/sxmo-dmenu/arg.h @@ -0,0 +1,49 @@ +/* + * Copy me if you can. + * by 20h + */ + +#ifndef ARG_H__ +#define ARG_H__ + +extern char *argv0; + +/* use main(int argc, char *argv[]) */ +#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ + argv[0] && argv[0][0] == '-'\ + && argv[0][1];\ + argc--, argv++) {\ + char argc_;\ + char **argv_;\ + int brk_;\ + if (argv[0][1] == '-' && argv[0][2] == '\0') {\ + argv++;\ + argc--;\ + break;\ + }\ + for (brk_ = 0, argv[0]++, argv_ = argv;\ + argv[0][0] && !brk_;\ + argv[0]++) {\ + if (argv_ != argv)\ + break;\ + argc_ = argv[0][0];\ + switch (argc_) + +#define ARGEND }\ + } + +#define ARGC() argc_ + +#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ + ((x), abort(), (char *)0) :\ + (brk_ = 1, (argv[0][1] != '\0')?\ + (&argv[0][1]) :\ + (argc--, argv++, argv[0]))) + +#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ + (char *)0 :\ + (brk_ = 1, (argv[0][1] != '\0')?\ + (&argv[0][1]) :\ + (argc--, argv++, argv[0]))) + +#endif diff --git a/src/sxmo-dmenu/config.def.h b/src/sxmo-dmenu/config.def.h new file mode 100644 index 0000000..9a14f85 --- /dev/null +++ b/src/sxmo-dmenu/config.def.h @@ -0,0 +1,41 @@ +/* See LICENSE file for copyright and license details. */ +/* Default settings; can be overriden by command line. */ + +static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ +static int colorprompt = 1; /* -p option; if 1, prompt uses SchemeSel, otherwise SchemeNorm */ +static int centered = 0; /* -c option; centers dmenu on screen */ +static int min_width = 240; /* minimum width when centered */ +static unsigned int lineheight = 26; +static unsigned int min_lineheight = 24; + +/* -fn option overrides fonts[0]; default X11 font or font set */ +static const char *defaultfonts[] = { + "Fira Code:pixelsize=18:style=Regular:antialias=true:autohint=true", + "DejaVuSansM Nerd Font:pixelsize=18:style=Regular:antialias=true:autohint=true" +}; +static const char *prompt = NULL; /* -p option; prompt to the left of input field */ +static const char *defaultcolors[SchemeLast][2] = { + /* fg bg */ + [SchemeNorm] = { "#ffffff", "#1c1c1c" }, + [SchemeSel] = { "#ffffff", "#005577" }, + [SchemeSelHighlight] = { "#ffc978", "#005577" }, + [SchemeNormHighlight] = { "#ffc978", "#1c1c1c" }, + [SchemeOut] = { "#ffffff", "#383838" }, +}; +/* -l option; if nonzero, dmenu uses vertical list with given number of lines */ +static unsigned int lines = 9; + +/* + * Characters not considered part of a word while deleting words + * for example: " /?\"&[]" + */ +static const char worddelimiters[] = " "; + +/* Size of the window border */ +static const unsigned int border_width = 0; + +/* Whether to wrap around to the top and bottom of the menu */ +static int wrap_around = 1; + +/* height of each scroll region above and below the menu, in units of menu items */ +static int scrollregion = 4; diff --git a/src/sxmo-dmenu/config.h b/src/sxmo-dmenu/config.h new file mode 100644 index 0000000..9a14f85 --- /dev/null +++ b/src/sxmo-dmenu/config.h @@ -0,0 +1,41 @@ +/* See LICENSE file for copyright and license details. */ +/* Default settings; can be overriden by command line. */ + +static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ +static int colorprompt = 1; /* -p option; if 1, prompt uses SchemeSel, otherwise SchemeNorm */ +static int centered = 0; /* -c option; centers dmenu on screen */ +static int min_width = 240; /* minimum width when centered */ +static unsigned int lineheight = 26; +static unsigned int min_lineheight = 24; + +/* -fn option overrides fonts[0]; default X11 font or font set */ +static const char *defaultfonts[] = { + "Fira Code:pixelsize=18:style=Regular:antialias=true:autohint=true", + "DejaVuSansM Nerd Font:pixelsize=18:style=Regular:antialias=true:autohint=true" +}; +static const char *prompt = NULL; /* -p option; prompt to the left of input field */ +static const char *defaultcolors[SchemeLast][2] = { + /* fg bg */ + [SchemeNorm] = { "#ffffff", "#1c1c1c" }, + [SchemeSel] = { "#ffffff", "#005577" }, + [SchemeSelHighlight] = { "#ffc978", "#005577" }, + [SchemeNormHighlight] = { "#ffc978", "#1c1c1c" }, + [SchemeOut] = { "#ffffff", "#383838" }, +}; +/* -l option; if nonzero, dmenu uses vertical list with given number of lines */ +static unsigned int lines = 9; + +/* + * Characters not considered part of a word while deleting words + * for example: " /?\"&[]" + */ +static const char worddelimiters[] = " "; + +/* Size of the window border */ +static const unsigned int border_width = 0; + +/* Whether to wrap around to the top and bottom of the menu */ +static int wrap_around = 1; + +/* height of each scroll region above and below the menu, in units of menu items */ +static int scrollregion = 4; diff --git a/src/sxmo-dmenu/config.mk b/src/sxmo-dmenu/config.mk new file mode 100644 index 0000000..cf236d4 --- /dev/null +++ b/src/sxmo-dmenu/config.mk @@ -0,0 +1,31 @@ +# dmenu version +VERSION = 5.0.12 + +# paths +PREFIX = /usr/local +MANPREFIX = $(PREFIX)/share/man + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# Xinerama, comment if you don't want it +XINERAMALIBS = -lXinerama +XINERAMAFLAGS = -DXINERAMA + +# freetype +FREETYPELIBS = -lfontconfig -lXft +FREETYPEINC = /usr/include/freetype2 +# OpenBSD (uncomment) +#FREETYPEINC = $(X11INC)/freetype2 + +# includes and libs +INCS = -I$(X11INC) -I$(FREETYPEINC) +LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS) + +# flags +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS) +CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS) +LDFLAGS = $(LIBS) + +# compiler and linker +CC = cc diff --git a/src/sxmo-dmenu/dmenu.1 b/src/sxmo-dmenu/dmenu.1 new file mode 100644 index 0000000..7467883 --- /dev/null +++ b/src/sxmo-dmenu/dmenu.1 @@ -0,0 +1,252 @@ +.TH DMENU 1 dmenu\-VERSION +.SH NAME +dmenu \- dynamic menu +.SH SYNOPSIS +.B dmenu +.RB [ \-bfitv ] +.RB [ \-l +.IR lines ] +.RB [ \-m +.IR monitor ] +.RB [ \-p +.IR prompt ] +.RB [ \-fn +.IR font ] +.RB [ \-nb +.IR color ] +.RB [ \-nf +.IR color ] +.RB [ \-sb +.IR color ] +.RB [ \-sf +.IR color ] +.RB [ \-H +.IR height ] +.RB [ \-w +.IR windowid ] +.RB [ \-idx +.IR index ] +.RB [ \-wm ] +.P +.BR dmenu_run " ..." +.SH DESCRIPTION +.B dmenu +is a dynamic menu for X, which reads a list of newline\-separated items from +stdin. When the user selects an item and presses Return, their choice is printed +to stdout and dmenu terminates. Entering text will narrow the items to those +matching the tokens in the input. +.P +.B dmenu_run +is a script used by +.IR dwm (1) +which lists programs in the user's $PATH and runs the result in their $SHELL. +.SH OPTIONS +.TP +.B \-b +dmenu appears at the bottom of the screen. +.TP +.B \-nc +dmenu appears not centered on the screen. +.TP +.B \-f +dmenu grabs the keyboard before reading stdin if not reading from a tty. This +is faster, but will lock up X until stdin reaches end\-of\-file. +.TP +.B \-i +dmenu matches menu items case insensitively. +.TP +.BI \-l " lines" +dmenu lists items vertically, with the given number of lines. +.TP +.BI \-H " height" +dmenu uses a menu line of at least 'height' pixels tall, but no less than 8 +.TP +.BI \-m " monitor" +dmenu is displayed on the monitor number supplied. Monitor numbers are starting +from 0. +.TP +.BI \-p " prompt" +defines the prompt to be displayed to the left of the input field. +.TP +.BI \-fn " font" +defines the font or font set used. +.TP +.BI \-nb " color" +defines the normal background color. +.IR #RGB , +.IR #RRGGBB , +and X color names are supported. +.TP +.BI \-nf " color" +defines the normal foreground color. +.TP +.BI \-sb " color" +defines the selected background color. +.TP +.BI \-sf " color" +defines the selected foreground color. +.TP +.B \-t +Return key prints input text instead of selection. +.TP +.B \-v +prints version information to stdout, then exits. +.TP +.BI \-w " windowid" +embed into windowid. +.TP +.BI \-idx " index" +specify the initial selection index number. +.TP +.BI \-wm +Display as a managed WM window (e.g. don't set overide_redirect flag) +.SH USAGE +dmenu is completely controlled by the keyboard. Items are selected using the +arrow keys, page up, page down, home, and end. +.TP +.B Tab +Copy the selected item to the input field. +.TP +.B Return +Confirm selection. Prints the selected item to stdout and exits, returning +success. If \-t option is given it confirms input instead of selection. +.TP +.B Ctrl-Return +Confirm selection. Prints the selected item to stdout and continues. +.TP +.B Shift\-Return +Confirm input. Prints the input text to stdout and exits, returning success. +If \-t option is given it confirms selection instead of input. +.TP +.B Escape +Exit without selecting an item, returning failure. +.TP +.B Ctrl-Left +Move cursor to the start of the current word +.TP +.B Ctrl-Right +Move cursor to the end of the current word +.TP +.B C\-a +Home +.TP +.B C\-b +Left +.TP +.B C\-nc +Escape +.TP +.B C\-d +Delete +.TP +.B C\-e +End +.TP +.B C\-f +Right +.TP +.B C\-g +Escape +.TP +.B C\-h +Backspace +.TP +.B C\-i +Tab +.TP +.B C\-j +Return +.TP +.B C\-J +Shift-Return +.TP +.B C\-k +Delete line right +.TP +.B C\-m +Return +.TP +.B C\-M +Shift-Return +.TP +.B C\-n +Down +.TP +.B C\-p +Up +.TP +.B C\-u +Delete line left +.TP +.B C\-w +Delete word left +.TP +.B C\-y +Paste from primary X selection +.TP +.B C\-Y +Paste from X clipboard +.TP +.B M\-b +Move cursor to the start of the current word +.TP +.B M\-f +Move cursor to the end of the current word +.TP +.B M\-g +Home +.TP +.B M\-G +End +.TP +.B M\-h +Up +.TP +.B M\-j +Page down +.TP +.B M\-k +Page up +.TP +.B M\-l +Down +.SH X Resources +.TP +.BI dmenu.font +defines the font or font set used. +.TP +.BI dmenu.background +defines the normal background color. +.IR #RGB , +.IR #RRGGBB , +and X color names are supported. +.TP +.BI dmenu.foreground +defines the normal foreground color. +.TP +.BI dmenu.selbackground +defines the selected background color. +.TP +.BI dmenu.selforeground +defines the selected foreground color. +.TP +.BI dmenu.selhighlightbackground +defines the highlighted selected background color. +.TP +.BI dmenu.selhighlightforeground +defines the highlighted selected foreground color. +.TP +.BI dmenu.highlightbackground +defines the highlighted background color. +.TP +.BI dmenu.highlightforeground +defines the highlighted foreground color. +.TP +.BI dmenu.outbackground +defines the out background color. +.TP +.BI dmenu.outforeground +defines the out foreground color. +.SH SEE ALSO +.IR dwm (1), +.IR stest (1) diff --git a/src/sxmo-dmenu/dmenu.c b/src/sxmo-dmenu/dmenu.c new file mode 100644 index 0000000..788f48c --- /dev/null +++ b/src/sxmo-dmenu/dmenu.c @@ -0,0 +1,1283 @@ +/* See LICENSE file for copyright and license details. */ +#include +#ifndef _EVDEVK +#define _EVDEVK(_v) (0x10081000 + (_v)) +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#ifdef XINERAMA +#include +#endif +#include +#include + +#include "drw.h" +#include "util.h" + +/* macros */ +#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ + * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) +#define LENGTH(X) (sizeof X / sizeof X[0]) +#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) +#define NUMBERSMAXDIGITS 100 +#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1 + +/* enums */ +enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeLast }; /* color schemes */ + +struct item { + char *text; + struct item *left, *right; + int out; +}; + +static char numbers[NUMBERSBUFSIZE] = ""; +static char text[BUFSIZ] = ""; +static char *embed; +static int bh, mw, mh; +static int inputw = 0, promptw; +static int lrpad; /* sum of left and right padding */ +static size_t cursor; +static struct item *items = NULL; +static struct item *matches, *matchend; +static struct item *prev, *curr, *next, *sel, *nav; +static int mon = -1, screen; +static int use_text_input = 0; +static int initialindex; +static int managed = 0; + +static Atom clip, utf8; +static Display *dpy; +static Window root, parentwin, win; +static XIC xic; + +static Drw *drw; +static Clr *scheme[SchemeLast]; + +/* Empty arrays to be filled from command line, Xresources, and defaults, in decreasing order of precedence */ +static char *colors[SchemeLast][2]; +static const char *fonts[3] = { NULL, NULL, NULL }; + +#include "config.h" + +static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; +static char *(*fstrstr)(const char *, const char *) = strstr; + +static void +appenditem(struct item *item, struct item **list, struct item **last) +{ + if (*last) + (*last)->right = item; + else + *list = item; + + item->left = *last; + item->right = NULL; + *last = item; +} + +static void +calcoffsets(void) +{ + int i, n; + + if (lines > 0) + n = lines * bh; + else + n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">")); + /* calculate which items will begin the next page and previous page */ + for (i = 0, next = curr; next; next = next->right) + if ((i += (lines > 0) ? bh : MIN(TEXTW(next->text), n)) > n) + break; + for (i = 0, prev = curr; prev && prev->left; prev = prev->left) + if ((i += (lines > 0) ? bh : MIN(TEXTW(prev->left->text), n)) > n) + break; +} + +static int +max_textw(void) +{ + int len = 0; + for (struct item *item = items; item && item->text; item++) + len = MAX(TEXTW(item->text), len); + return len; +} + +static Window prevfocuswin = None; + +static int +ignore_xerror(Display *d, XErrorEvent *ee) +{ + (void)d; + (void)ee; + return 0; +} + +static void +cleanup(void) +{ + size_t i; + + if (xic) { + XUnsetICFocus(xic); + XDestroyIC(xic); + xic = NULL; + } + XUngrabKey(dpy, AnyKey, AnyModifier, root); + XSetErrorHandler(ignore_xerror); + if (prevfocuswin && prevfocuswin != win && prevfocuswin != PointerRoot) + XSetInputFocus(dpy, prevfocuswin, RevertToParent, CurrentTime); + for (i = 0; i < SchemeLast; i++) + free(scheme[i]); + drw_free(drw); + XSync(dpy, False); + XCloseDisplay(dpy); +} + +static char * +cistrstr(const char *s, const char *sub) +{ + size_t len; + + for (len = strlen(sub); *s; s++) + if (!strncasecmp(s, sub, len)) + return (char *)s; + return NULL; +} + +static void +drawhighlights(struct item *item, int x, int y, int maxw) +{ + char restorechar, tokens[sizeof text], *highlight, *token; + int indentx, highlightlen; + + drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]); + strcpy(tokens, text); + for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) { + highlight = fstrstr(item->text, token); + while (highlight) { + // Move item str end, calc width for highlight indent, & restore + highlightlen = highlight - item->text; + restorechar = *highlight; + item->text[highlightlen] = '\0'; + indentx = TEXTW(item->text); + item->text[highlightlen] = restorechar; + + // Move highlight str end, draw highlight, & restore + restorechar = highlight[strlen(token)]; + highlight[strlen(token)] = '\0'; + drw_text( + drw, + x + indentx - (lrpad / 2) - 1, + y, + MIN(maxw - indentx, TEXTW(highlight) - lrpad), + bh, 0, highlight, 0 + ); + highlight[strlen(token)] = restorechar; + + if (strlen(highlight) - strlen(token) < strlen(token)) break; + highlight = fstrstr(highlight + strlen(token), token); + } + } +} + +static int +drawitem(struct item *item, int x, int y, int w) +{ + if (item == sel) + drw_setscheme(drw, scheme[SchemeSel]); + else if (item->out) + drw_setscheme(drw, scheme[SchemeOut]); + else + drw_setscheme(drw, scheme[SchemeNorm]); + + int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); + drawhighlights(item, x, y, w); + return r; +} + +static void +recalculatenumbers() +{ + unsigned int numer = 0, denom = 0; + struct item *item; + if (matchend) { + numer++; + for (item = matchend; item && item->left; item = item->left) + numer++; + } + for (item = items; item && item->text; item++) + denom++; + if (numer == denom) + snprintf(numbers, NUMBERSBUFSIZE, "%d", numer); + else + snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom); +} + +static void +drawmenu(void) +{ + static int curpos, oldcurlen; + struct item *item; + int x = 0, y = 0, fh = drw->fonts->h, w; + int curlen, rcurlen; + + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, 0, 0, mw, mh, 1, 1); + + /* draw top search bar background in SchemeOut (#383838) */ + drw_setscheme(drw, scheme[SchemeOut]); + drw_rect(drw, 0, 0, mw, bh, 1, 1); + + if (prompt && *prompt) { + if (colorprompt) + drw_setscheme(drw, scheme[SchemeSel]); + x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0); + } + + recalculatenumbers(); + + /* draw input field */ + w = (lines > 0 || !matches) ? mw - x : inputw; + w -= lrpad / 2; + x += lrpad / 2; + + rcurlen = drw_fontset_getwidth(drw, text + cursor); + curlen = drw_fontset_getwidth(drw, text) - rcurlen; + curpos += curlen - oldcurlen; + curpos = MIN(w - TEXTW(numbers), MAX(0, curpos)); + curpos = MAX(curpos, w - rcurlen - TEXTW(numbers)); + curpos = MIN(curpos, curlen); + oldcurlen = curlen; + + drw_setscheme(drw, scheme[SchemeOut]); + drw_text_align(drw, x, 0, curpos, bh, text, cursor, AlignR); + drw_text_align(drw, x + curpos, 0, w - curpos - TEXTW(numbers), bh, text + cursor, strlen(text) - cursor, AlignL); + drw_rect(drw, x + curpos - 1, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0); + + if (lines > 0) { + /* draw vertical list */ + x -= lrpad / 2; + for (item = curr; item != next; item = item->right) + drawitem(item, 0, y += bh, mw); + } else if (matches) { + /* draw horizontal list */ + x += inputw; + w = TEXTW("<"); + if (curr->left) { + drw_setscheme(drw, scheme[SchemeNorm]); + drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0); + } + x += w; + for (item = curr; item != next; item = item->right) + x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">") - TEXTW(numbers))); + if (next) { + w = TEXTW(">"); + drw_setscheme(drw, scheme[SchemeNorm]); + drw_text(drw, mw - w - TEXTW(numbers), 0, w, bh, lrpad / 2, ">", 0); + } + } + drw_setscheme(drw, scheme[SchemeOut]); + drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0); + drw_map(drw, win, 0, 0, mw, mh); +} + +static void +grabfocus(void) +{ + struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 }; + Window focuswin; + int i, revertwin; + + for (i = 0; i < 100; ++i) { + XGetInputFocus(dpy, &focuswin, &revertwin); + if (focuswin == win) + return; + if (!prevfocuswin && focuswin != None && focuswin != PointerRoot) + prevfocuswin = focuswin; + XSetInputFocus(dpy, win, RevertToParent, CurrentTime); + XGetInputFocus(dpy, &focuswin, &revertwin); + if (focuswin == win) + return; + nanosleep(&ts, NULL); + } + die("cannot grab focus"); +} + +static void +grabkeyboard(void) +{ + struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 }; + int i; + + if (embed || managed) + return; + /* try to grab keyboard, we may have to wait for another process to ungrab */ + for (i = 0; i < 1000; i++) { + if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync, + GrabModeAsync, CurrentTime) == GrabSuccess) + return; + nanosleep(&ts, NULL); + } + die("cannot grab keyboard"); +} + +static void +match(void) +{ + static char **tokv = NULL; + static int tokn = 0; + + char buf[sizeof text], *s; + int i, tokc = 0; + size_t len, textsize; + struct item *item, *lprefix, *lsubstr, *prefixend, *substrend; + + strcpy(buf, text); + /* separate input text into tokens to be matched individually */ + for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " ")) + if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv))) + die("cannot realloc %u bytes:", tokn * sizeof *tokv); + len = tokc ? strlen(tokv[0]) : 0; + + matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; + textsize = strlen(text) + 1; + for (item = items; item && item->text; item++) { + for (i = 0; i < tokc; i++) + if (!fstrstr(item->text, tokv[i])) + break; + if (i != tokc) /* not all tokens match */ + continue; + /* exact matches go first, then prefixes, then substrings */ + if (!tokc || !fstrncmp(text, item->text, textsize)) + appenditem(item, &matches, &matchend); + else if (!fstrncmp(tokv[0], item->text, len)) + appenditem(item, &lprefix, &prefixend); + else + appenditem(item, &lsubstr, &substrend); + } + if (lprefix) { + if (matches) { + matchend->right = lprefix; + lprefix->left = matchend; + } else + matches = lprefix; + matchend = prefixend; + } + if (lsubstr) { + if (matches) { + matchend->right = lsubstr; + lsubstr->left = matchend; + } else + matches = lsubstr; + matchend = substrend; + } + curr = sel = matches; + calcoffsets(); +} + +static void +insert(const char *str, ssize_t n) +{ + if (strlen(text) + n > sizeof text - 1) + return; + /* move existing text out of the way, insert new text, and update cursor */ + memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0)); + if (n > 0) + memcpy(&text[cursor], str, n); + cursor += n; + match(); +} + +static size_t +nextrune(int inc) +{ + ssize_t n; + + /* return location of next utf8 rune in the given direction (+1 or -1) */ + for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc) + ; + return n; +} + +static void +movewordedge(int dir) +{ + if (dir < 0) { /* move cursor to the start of the word*/ + while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) + cursor = nextrune(-1); + while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) + cursor = nextrune(-1); + } else { /* move cursor to the end of the word */ + while (text[cursor] && strchr(worddelimiters, text[cursor])) + cursor = nextrune(+1); + while (text[cursor] && !strchr(worddelimiters, text[cursor])) + cursor = nextrune(+1); + } +} + +static void +keypress(XKeyEvent *ev) +{ + char buf[32]; + int len; + KeySym ksym; + Status status; + + ksym = NoSymbol; + if (xic && ev->keycode == 0) + len = Xutf8LookupString(xic, ev, buf, sizeof buf, &ksym, &status); + else { + len = XLookupString(ev, buf, sizeof buf, &ksym, NULL); + status = (len > 0 && ksym != NoSymbol) ? XLookupBoth : + (len > 0) ? XLookupChars : + (ksym != NoSymbol) ? XLookupKeySym : XLookupNone; + } + switch (status) { + default: /* XLookupNone, XBufferOverflow */ + return; + case XLookupChars: + goto insert; + case XLookupKeySym: + case XLookupBoth: + break; + } + + if (ev->state & ControlMask) { + switch(ksym) { + case XK_a: ksym = XK_Home; break; + case XK_b: ksym = XK_Left; break; + case XK_c: ksym = XK_Escape; break; + case XK_d: ksym = XK_Delete; break; + case XK_e: ksym = XK_End; break; + case XK_f: ksym = XK_Right; break; + case XK_g: ksym = XK_Escape; break; + case XK_h: ksym = XK_BackSpace; break; + case XK_i: ksym = XK_Tab; break; + case XK_j: /* fallthrough */ + case XK_J: /* fallthrough */ + case XK_m: /* fallthrough */ + case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break; + case XK_n: ksym = XK_Down; break; + case XK_p: ksym = XK_Up; break; + + case XK_k: /* delete right */ + text[cursor] = '\0'; + match(); + break; + case XK_u: /* delete left */ + insert(NULL, 0 - cursor); + break; + case XK_w: /* delete word */ + while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) + insert(NULL, nextrune(-1) - cursor); + while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) + insert(NULL, nextrune(-1) - cursor); + break; + case XK_y: /* paste selection */ + case XK_Y: + XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, + utf8, utf8, win, CurrentTime); + return; + case XK_Left: + movewordedge(-1); + goto draw; + case XK_Right: + movewordedge(+1); + goto draw; + case XK_Return: + case XK_KP_Enter: + break; + case XK_bracketleft: + cleanup(); + exit(1); + default: + return; + } + } else if (ev->state & Mod1Mask) { + switch(ksym) { + case XK_b: + movewordedge(-1); + goto draw; + case XK_f: + movewordedge(+1); + goto draw; + case XK_g: ksym = XK_Home; break; + case XK_G: ksym = XK_End; break; + case XK_h: ksym = XK_Up; break; + case XK_j: ksym = XK_Next; break; + case XK_k: ksym = XK_Prior; break; + case XK_l: ksym = XK_Down; break; + default: + return; + } + } + + switch(ksym) { + default: +insert: + if (!iscntrl(*buf)) + insert(buf, len); + break; + case XK_Delete: + if (text[cursor] == '\0') + return; + cursor = nextrune(+1); + /* fallthrough */ + case XK_BackSpace: + if (cursor == 0) + return; + insert(NULL, nextrune(-1) - cursor); + break; + case XK_End: + if (text[cursor] != '\0') { + cursor = strlen(text); + break; + } + if (next) { + /* jump to end of list and position items in reverse */ + curr = matchend; + calcoffsets(); + curr = prev; + calcoffsets(); + while (next && (curr = curr->right)) + calcoffsets(); + } + sel = matchend; + break; + case XK_Escape: + case XF86XK_Back: + case XF86XK_KbdLcdMenu2: + case XF86XK_PowerOff: + cleanup(); + exit(1); + case XK_Home: + if (sel == matches) { + cursor = 0; + break; + } + sel = curr = matches; + calcoffsets(); + break; + case XK_Left: + if (cursor > 0 && (!sel || !sel->left || lines > 0)) { + cursor = nextrune(-1); + break; + } + if (lines > 0) + return; + /* fallthrough */ + case XF86XK_AudioRaiseVolume: + case XK_Up: + if (sel && sel->left) { + sel = sel->left; + if (sel->right == curr) { + curr = prev; + calcoffsets(); + } + } else if (wrap_around) { + // if there is no previous item, jump to the bottom of the list + curr = matchend; + calcoffsets(); + curr = prev; + calcoffsets(); + while (next && (curr = curr->right)) + calcoffsets(); + sel = matchend; + } + break; + case XK_Next: + if (!next) + return; + sel = curr = next; + calcoffsets(); + break; + case XK_Prior: + if (!prev) + return; + sel = curr = prev; + calcoffsets(); + break; + case XK_Menu: + case XF86XK_KbdLcdMenu1: + case XF86XK_Phone: + case XF86XK_PickupPhone: + case XK_Return: + case XK_KP_Enter: + if (use_text_input) + puts((sel && (ev->state & ShiftMask)) ? sel->text : text); + else + puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); + if (!(ev->state & ControlMask)) { + cleanup(); + exit(0); + } + if (sel) + sel->out = 1; + break; + case XK_Right: + if (text[cursor] != '\0') { + cursor = nextrune(+1); + break; + } + if (lines > 0) + return; + /* fallthrough */ + case XF86XK_AudioLowerVolume: + case XK_Down: + if (sel && sel->right) { + sel = sel->right; + if (sel == next) { + curr = next; + } + } else if (wrap_around) { + // if there is no next item, jump to the top of the list + sel = curr = matches; + } + calcoffsets(); + break; + case XK_Tab: + if (!sel) + return; + strncpy(text, sel->text, sizeof text - 1); + text[sizeof text - 1] = '\0'; + cursor = strlen(text); + match(); + break; + } + +draw: + drawmenu(); +} + +static void +motionnotify(XEvent *e) +{ + struct item *item; + XMotionEvent *ev = &e->xmotion; + int y = 0, h = bh; + char *pageup = "Page up", *pagedown = "Page down"; + char *gotop = "Go to top", *gobottom = "Go to bottom"; + char *alreadytop = "Already at top", *alreadybottom = "Already at bottom"; + + if (ev->window != win){ + return; + } + + if (ev->state & ~Button1Mask) + return; + + if (lines > 0) { + /* vertical list: (ctrl)left-click on item */ + for (item = curr; item != next; item = item->right) { + y += h; + if (ev->y >= y && ev->y <= (y + h)) { + sel = item; + drawmenu(); + return; + } + } + /* display page up/down or jump top/bottom as appropriate */ + if(ev->y > mh || ev->y < 0){ + if (ev->y >= (mh) && ev->y <= (mh + bh*scrollregion )) { + nav->text = next ? pagedown : alreadybottom; + drw_setscheme(drw, scheme[SchemeSel]); + y=mh-bh; + } else if (ev->y >= (mh + bh*scrollregion ) && ev->y < (mh + bh*scrollregion*2 )) { + nav->text = next ? gobottom : alreadybottom; + drw_setscheme(drw, scheme[SchemeSel]); + y=mh-bh; + } else if (ev->y >= (0 - h*scrollregion) && ev->y <= (0)) { + nav->text = curr != matches ? pageup : alreadytop; + drw_setscheme(drw, scheme[SchemeSel]); + y=0+bh; + } else if (ev->y >= (0 - h*scrollregion*2) && ev->y <= (0 - h*scrollregion)) { + nav->text = curr != matches ? gotop : alreadytop; + drw_setscheme(drw, scheme[SchemeSel]); + y=0+bh; + } else { + drawmenu(); + return; + } + drw_setscheme(drw, scheme[SchemeOut]); + drw_text(drw, 0, y, mw, bh, lrpad / 2, nav->text, 0); + drw_map(drw, win, 0, 0, mw, mh); + XFlush(dpy); + return; + } + } + return; +} + + +static void +buttonpress(XEvent *e) +{ + struct item *item; + XButtonPressedEvent *ev = &e->xbutton; + int x = 0, y = 0, h = bh, w; + + if (ev->window != win) + return; + + /* right-click: exit */ + if (ev->button == Button3) + exit(1); + + if (prompt && *prompt) + x += promptw; + + /* input field */ + w = (lines > 0 || !matches) ? mw - x : inputw; + + /* left-click on input: clear input, + * NOTE: if there is no left-arrow the space for < is reserved so + * add that to the input width */ + if (ev->button == Button1 && + ((lines <= 0 && ev->x >= 0 && ev->x <= x + w + + ((!prev || !curr->left) ? TEXTW("<") : 0)) || + (lines > 0 && ev->y >= y && ev->y <= y + h))) { + insert(NULL, -cursor); + drawmenu(); + return; + } + /* middle-mouse click: paste selection */ + if (ev->button == Button2) { + XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, + utf8, utf8, win, CurrentTime); + drawmenu(); + return; + } + /* jump to top */ + if (ev->y >= (0 - h*scrollregion*2) && ev->y <= (0 - h*scrollregion)) { + sel = curr = matches; + calcoffsets(); + drawmenu(); + return; + } + /* scroll up */ + if ( (ev->button == Button4 && prev) + || (ev->y >= (0 - h*scrollregion) && ev->y <= (0)) + ) { + sel = curr = prev; + calcoffsets(); + drawmenu(); + return; + } + /* scroll down */ + if ( (ev->button == Button5 && next) + || (ev->y >= (mh) && ev->y <= (mh + bh*scrollregion )) + ) { + if(next) + sel = curr = next; + calcoffsets(); + drawmenu(); + return; + } + /* jump to bottom */ + if (ev->y >= (mh + bh*scrollregion ) && ev->y < (mh + bh*scrollregion*2 )) { + if (next) { + /* jump to end of list and position items in reverse */ + curr = matchend; + calcoffsets(); + curr = prev; + calcoffsets(); + while (next && (curr = curr->right)) + calcoffsets(); + } + sel = matchend; + drawmenu(); + return; + } + + if (ev->button != Button1) + return; + if (ev->state & ~ControlMask & ~Button1Mask) + return; + if (lines > 0) { + /* vertical list: (ctrl)left-click on item */ + w = mw - x; + for (item = curr; item != next; item = item->right) { + y += h; + if (ev->y >= y && ev->y <= (y + h)) { + puts(item->text); + if (!(ev->state & ControlMask)) + exit(0); + sel = item; + if (sel) { + sel->out = 1; + drawmenu(); + } + return; + } + } + } else if (matches) { + /* left-click on left arrow */ + x += inputw; + w = TEXTW("<"); + if (prev && curr->left) { + if (ev->x >= x && ev->x <= x + w) { + sel = curr = prev; + calcoffsets(); + drawmenu(); + return; + } + } + /* horizontal list: (ctrl)left-click on item */ + for (item = curr; item != next; item = item->right) { + x += w; + w = MIN(TEXTW(item->text), mw - x - TEXTW(">")); + if (ev->x >= x && ev->x <= x + w) { + puts(item->text); + if (!(ev->state & ControlMask)) + exit(0); + sel = item; + if (sel) { + sel->out = 1; + drawmenu(); + } + return; + } + } + /* left-click on right arrow */ + w = TEXTW(">"); + x = mw - w; + if (next && ev->x >= x && ev->x <= x + w) { + sel = curr = next; + calcoffsets(); + drawmenu(); + return; + } + } +} + +static void +paste(void) +{ + char *p, *q; + int di; + unsigned long dl; + Atom da; + + /* we have been given the current selection, now insert it into input */ + if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False, + utf8, &da, &di, &dl, &dl, (unsigned char **)&p) + == Success && p) { + insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p)); + XFree(p); + } + drawmenu(); +} + +static void +readstdin(void) +{ + char buf[sizeof text], *p; + size_t i, imax = 0, size = 0; + unsigned int tmpmax = 0; + + /* read each line from stdin and add it to the item list */ + for (i = 0; fgets(buf, sizeof buf, stdin); i++) { + if (i + 1 >= size / sizeof *items) + if (!(items = realloc(items, (size += BUFSIZ)))) + die("cannot realloc %u bytes:", size); + if ((p = strchr(buf, '\n'))) + *p = '\0'; + if (!(items[i].text = strdup(buf))) + die("cannot strdup %u bytes:", strlen(buf) + 1); + items[i].out = 0; + if (lines == 0 && !centered) { + drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL); + if (tmpmax > inputw) { + inputw = tmpmax; + imax = i; + } + } + } + if (items) + items[i].text = NULL; + inputw = (items && lines == 0 && !centered) ? TEXTW(items[imax].text) : 0; + lines = MIN(lines, i); +} + +static int +issoftkey(unsigned int keycode) +{ + /* X11 keycodes: Power=124, Menu(Left Softkey)=135, Back(Right Softkey)=166, Phone(Call)=177 */ + return keycode == 124 || keycode == 135 || keycode == 166 || keycode == 177; +} + +static void +run(void) +{ + XEvent ev; + + while (!XNextEvent(dpy, &ev)) { + if (ev.type == KeyPress || ev.type == KeyRelease) { + if (!issoftkey(ev.xkey.keycode)) { + ev.xkey.window = win; + if (XFilterEvent(&ev, None)) + continue; + } + } else if (XFilterEvent(&ev, None)) { + continue; + } + switch(ev.type) { + case MotionNotify: + motionnotify(&ev); + break; + case ButtonRelease: + buttonpress(&ev); + break; + case DestroyNotify: + if (ev.xdestroywindow.window != win) + break; + cleanup(); + exit(1); + case Expose: + if (ev.xexpose.count == 0) + drw_map(drw, win, 0, 0, mw, mh); + break; + case FocusIn: + /* regrab focus from parent window */ + if (ev.xfocus.window != win) + grabfocus(); + if (xic) + XSetICFocus(xic); + break; + case KeyPress: + keypress(&ev.xkey); + break; + case SelectionNotify: + if (ev.xselection.property == utf8) + paste(); + break; + } + } +} + +static void +setup(void) +{ + int x, y, i, j; + unsigned int du; + XSetWindowAttributes swa; + XIM xim; + Window w, dw, *dws; + XWindowAttributes wa; + XClassHint ch = {"dmenu", "dmenu"}; +#ifdef XINERAMA + XineramaScreenInfo *info; + Window pw; + int a, di, n, area = 0; +#endif + /* init appearance */ + for (j = 0; j < SchemeLast; j++) { + scheme[j] = drw_scm_create(drw, (const char**)colors[j], 2); + } + for (j = 0; j < SchemeLast; ++j) { + free(colors[j][ColFg]); + free(colors[j][ColBg]); + } + + clip = XInternAtom(dpy, "CLIPBOARD", False); + utf8 = XInternAtom(dpy, "UTF8_STRING", False); + + /* calculate menu geometry */ + const int bar_h = 24; + bh = drw->fonts->h + 2; + bh = MAX(bh, lineheight); + lines = MAX(lines, 0); + mh = (lines + 1) * bh; + promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; +#ifdef XINERAMA + i = 0; + if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { + int avail_h; + XGetInputFocus(dpy, &w, &di); + if (mon >= 0 && mon < n) + i = mon; + else if (w != root && w != PointerRoot && w != None) { + /* find top-level window containing current input focus */ + do { + if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws) + XFree(dws); + } while (w != root && w != pw); + /* find xinerama screen with which the window intersects most */ + if (XGetWindowAttributes(dpy, pw, &wa)) + for (j = 0; j < n; j++) + if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) { + area = a; + i = j; + } + } + /* no focused window is on screen, so use pointer location instead */ + if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du)) + for (i = 0; i < n; i++) + if (INTERSECT(x, y, 1, 1, info[i])) + break; + + avail_h = MAX((int)bh * 2, (int)info[i].height - bar_h); + if (lines > 0 && (int)mh > avail_h) { + lines = MAX(1, (avail_h / (int)bh) - 1); + mh = (lines + 1) * bh; + } + x = info[i].x_org; + mw = info[i].width; + y = info[i].y_org + (topbar ? bar_h : MAX(bar_h, (int)info[i].height - (int)mh)); + + XFree(info); + } else +#endif + { + int avail_h; + if (!XGetWindowAttributes(dpy, parentwin, &wa)) + die("could not get embedding window attributes: 0x%lx", + parentwin); + + avail_h = MAX((int)bh * 2, (int)wa.height - bar_h); + if (lines > 0 && (int)mh > avail_h) { + lines = MAX(1, (avail_h / (int)bh) - 1); + mh = (lines + 1) * bh; + } + x = 0; + mw = wa.width; + y = topbar ? bar_h : MAX(bar_h, (int)wa.height - (int)mh); + } + inputw = MIN(inputw, mw/3); + match(); + + /* create menu window */ + swa.override_redirect = managed ? False : True; + swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + swa.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask; + win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, + CopyFromParent, CopyFromParent, CopyFromParent, + CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); + XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel); + XSetClassHint(dpy, win, &ch); + + drw_resize(drw, mw, mh); + calcoffsets(); + + for (i = 0; i < initialindex; i++) { + if (sel && sel->right && (sel = sel->right) == next) { + curr = next; + calcoffsets(); + } + } + + XMapRaised(dpy, win); + drawmenu(); + XFlush(dpy); + + if (managed) { + XTextProperty prop; + char *windowtitle = prompt != NULL ? (char *)prompt : "dmenu"; + Xutf8TextListToTextProperty(dpy, &windowtitle, 1, XUTF8StringStyle, &prop); + XSetWMName(dpy, win, &prop); + XSetTextProperty(dpy, win, &prop, XInternAtom(dpy, "_NET_WM_NAME", False)); + XFree(prop.value); + } else { + grabkeyboard(); + grabfocus(); + } + + /* input methods */ + XSetLocaleModifiers(""); + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) { + XSetLocaleModifiers("@im=local"); + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) { + XSetLocaleModifiers("@im="); + xim = XOpenIM(dpy, NULL, NULL, NULL); + } + } + + if (xim) { + xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, win, XNFocusWindow, win, NULL); + if (xic) + XSetICFocus(xic); + } + + if (embed) { + XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask); + if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { + for (i = 0; i < du && dws[i] != win; ++i) + XSelectInput(dpy, dws[i], FocusChangeMask); + XFree(dws); + } + grabfocus(); + } + + if (!(nav = malloc(sizeof *nav))) + die("cannot malloc %u bytes:", sizeof *nav); + nav->out = 1; + +} + +static void +usage(void) +{ + fputs("usage: dmenu [-bfiv] [-l lines] [-H height] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); +} + +void +readxresources(void) { + XrmInitialize(); + + char* xrm; + if ((xrm = XResourceManagerString(drw->dpy))) { + char *type; + XrmDatabase xdb = XrmGetStringDatabase(xrm); + XrmValue xval; + + if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval) && !fonts[0]) + fonts[0] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval) && !colors[SchemeNorm][ColBg] ) + colors[SchemeNorm][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval) && !colors[SchemeNorm][ColFg] ) + colors[SchemeNorm][ColFg] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval) && !colors[SchemeSel][ColBg] ) + colors[SchemeSel][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval) && !colors[SchemeSel][ColFg] ) + colors[SchemeSel][ColFg] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dmenu.selhighlightbackground", "*", &type, &xval) && !colors[SchemeSelHighlight][ColBg] ) + colors[SchemeSelHighlight][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.selhighlightforeground", "*", &type, &xval) && !colors[SchemeSelHighlight][ColFg] ) + colors[SchemeSelHighlight][ColFg] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dmenu.highlightbackground", "*", &type, &xval) && !colors[SchemeNormHighlight][ColBg] ) + colors[SchemeNormHighlight][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.highlightforeground", "*", &type, &xval) && !colors[SchemeNormHighlight][ColFg] ) + colors[SchemeNormHighlight][ColFg] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dmenu.outbackground", "*", &type, &xval) && !colors[SchemeOut][ColBg] ) + colors[SchemeOut][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.outforeground", "*", &type, &xval) && !colors[SchemeOut][ColFg] ) + colors[SchemeOut][ColFg] = strdup(xval.addr); + + XrmDestroyDatabase(xdb); + } +} + +int +main(int argc, char *argv[]) +{ + XWindowAttributes wa; + int i, fast = 0; + + for (i = 1; i < argc; i++) + /* these options take no arguments */ + if (!strcmp(argv[i], "-v")) { /* prints version information */ + puts("dmenu-"VERSION); + exit(0); + } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ + topbar = 0; + else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ + fast = 1; + else if (!strcmp(argv[i], "-nc")) /* prevents centering dmenu on screen */ + centered = 0; + else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */ + centered = 1; + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + fstrncmp = strncasecmp; + fstrstr = cistrstr; + } else if (!strcmp(argv[i], "-t")) /* favors text input over selection */ + use_text_input = 1; + else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */ + managed = 1; + } else if (i + 1 == argc) + usage(); + /* these options take one argument */ + else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ + lines = atoi(argv[++i]); + else if (!strcmp(argv[i], "-H")) { + lineheight = atoi(argv[++i]); + lineheight = MAX(lineheight, min_lineheight); + } + else if (!strcmp(argv[i], "-m")) + mon = atoi(argv[++i]); + else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ + prompt = argv[++i]; + else if (!strcmp(argv[i], "-fn")) /* font or font set */ + fonts[0] = strdup(argv[++i]); + else if (!strcmp(argv[i], "-nb")) /* normal background color */ + colors[SchemeNorm][ColBg] = strdup(argv[++i]); + else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ + colors[SchemeNorm][ColFg] = strdup(argv[++i]); + else if (!strcmp(argv[i], "-sb")) /* selected background color */ + colors[SchemeSel][ColBg] = strdup(argv[++i]); + else if (!strcmp(argv[i], "-sf")) /* selected foreground color */ + colors[SchemeSel][ColFg] = strdup(argv[++i]); + else if (!strcmp(argv[i], "-w")) /* embedding window id */ + embed = argv[++i]; + else if ((!strcmp(argv[i], "--index")) || (!strcmp(argv[i], "-I"))) /* initial index selection, 0-indexed (bemenu compatible) */ + initialindex = atoi(argv[++i]); + else if (!strcmp(argv[i], "-idx")) /* initial index selection, 1-indexed */ + initialindex = atoi(argv[++i]) - 1; + else + usage(); + + if (getenv("DMENU_WRAP_AROUND")) + wrap_around = 1; + + if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) + fputs("warning: no locale support\n", stderr); + XSetLocaleModifiers(""); + if (!(dpy = XOpenDisplay(NULL))) + die("cannot open display"); + screen = DefaultScreen(dpy); + root = RootWindow(dpy, screen); + if (!embed || !(parentwin = strtol(embed, NULL, 0))) + parentwin = root; + if (!XGetWindowAttributes(dpy, parentwin, &wa)) + die("could not get embedding window attributes: 0x%lx", + parentwin); + drw = drw_create(dpy, screen, root, wa.width, wa.height); + + /* Apply defaults to font and colors*/ + if (!fonts[0]) { + fonts[0] = defaultfonts[0]; + fonts[1] = defaultfonts[1]; + } else { + fonts[1] = defaultfonts[1]; + } + for (i = 0; i < SchemeLast; ++i){ + if ( !colors[i][ColBg] ) + colors[i][ColBg] = strdup(defaultcolors[i][ColBg]); + if ( !colors[i][ColFg] ) + colors[i][ColFg] = strdup(defaultcolors[i][ColFg]); + } + + if (!drw_fontset_create(drw, fonts, 2)) + die("no fonts could be loaded."); + + lrpad = drw->fonts->h / 2; + +#ifdef __OpenBSD__ + if (pledge("stdio rpath", NULL) == -1) + die("pledge"); +#endif + + readstdin(); + setup(); + run(); + + return 1; /* unreachable */ +} diff --git a/src/sxmo-dmenu/dmenu_path b/src/sxmo-dmenu/dmenu_path new file mode 100755 index 0000000..3a7cda7 --- /dev/null +++ b/src/sxmo-dmenu/dmenu_path @@ -0,0 +1,13 @@ +#!/bin/sh + +cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +cache="$cachedir/dmenu_run" + +[ ! -e "$cachedir" ] && mkdir -p "$cachedir" + +IFS=: +if stest -dqr -n "$cache" $PATH; then + stest -flx $PATH | sort -u | tee "$cache" +else + cat "$cache" +fi diff --git a/src/sxmo-dmenu/dmenu_run b/src/sxmo-dmenu/dmenu_run new file mode 100755 index 0000000..834ede5 --- /dev/null +++ b/src/sxmo-dmenu/dmenu_run @@ -0,0 +1,2 @@ +#!/bin/sh +dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} & diff --git a/src/sxmo-dmenu/drw.c b/src/sxmo-dmenu/drw.c new file mode 100644 index 0000000..0451a48 --- /dev/null +++ b/src/sxmo-dmenu/drw.c @@ -0,0 +1,605 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include +#include + +#include "drw.h" +#include "util.h" + +#define UTF_INVALID 0xFFFD +#define UTF_SIZ 4 + +static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; +static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; +static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; +static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; + +static long +utf8decodebyte(const char c, size_t *i) +{ + for (*i = 0; *i < (UTF_SIZ + 1); ++(*i)) + if (((unsigned char)c & utfmask[*i]) == utfbyte[*i]) + return (unsigned char)c & ~utfmask[*i]; + return 0; +} + +static size_t +utf8validate(long *u, size_t i) +{ + if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF)) + *u = UTF_INVALID; + for (i = 1; *u > utfmax[i]; ++i) + ; + return i; +} + +static size_t +utf8decode(const char *c, long *u, size_t clen) +{ + size_t i, j, len, type; + long udecoded; + + *u = UTF_INVALID; + if (!clen) + return 0; + udecoded = utf8decodebyte(c[0], &len); + if (!BETWEEN(len, 1, UTF_SIZ)) + return 1; + for (i = 1, j = 1; i < clen && j < len; ++i, ++j) { + udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type); + if (type) + return j; + } + if (j < len) + return 0; + *u = udecoded; + utf8validate(u, len); + + return len; +} + +Drw * +drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h) +{ + Drw *drw = ecalloc(1, sizeof(Drw)); + + drw->dpy = dpy; + drw->screen = screen; + drw->root = root; + drw->w = w; + drw->h = h; + drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); + drw->gc = XCreateGC(dpy, root, 0, NULL); + XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); + + return drw; +} + +void +drw_resize(Drw *drw, unsigned int w, unsigned int h) +{ + if (!drw) + return; + + drw->w = w; + drw->h = h; + if (drw->drawable) + XFreePixmap(drw->dpy, drw->drawable); + drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); +} + +void +drw_free(Drw *drw) +{ + XFreePixmap(drw->dpy, drw->drawable); + XFreeGC(drw->dpy, drw->gc); + drw_fontset_free(drw->fonts); + free(drw); +} + +/* This function is an implementation detail. Library users should use + * drw_fontset_create instead. + */ +static Fnt * +xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) +{ + Fnt *font; + XftFont *xfont = NULL; + FcPattern *pattern = NULL; + + if (fontname) { + /* Using the pattern found at font->xfont->pattern does not yield the + * same substitution results as using the pattern returned by + * FcNameParse; using the latter results in the desired fallback + * behaviour whereas the former just results in missing-character + * rectangles being drawn, at least with some fonts. */ + if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) { + fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname); + return NULL; + } + if (!(pattern = FcNameParse((FcChar8 *) fontname))) { + fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname); + XftFontClose(drw->dpy, xfont); + return NULL; + } + } else if (fontpattern) { + if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) { + fprintf(stderr, "error, cannot load font from pattern.\n"); + return NULL; + } + } else { + die("no font specified."); + } + + /* Do not allow using color fonts. This is a workaround for a BadLength + * error from Xft with color glyphs. Modelled on the Xterm workaround. See + * https://bugzilla.redhat.com/show_bug.cgi?id=1498269 + * https://lists.suckless.org/dev/1701/30932.html + * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349 + * and lots more all over the internet. + */ + FcBool iscol; + if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) { + XftFontClose(drw->dpy, xfont); + return NULL; + } + + font = ecalloc(1, sizeof(Fnt)); + font->xfont = xfont; + font->pattern = pattern; + font->h = xfont->ascent + xfont->descent; + font->dpy = drw->dpy; + + return font; +} + +static void +xfont_free(Fnt *font) +{ + if (!font) + return; + if (font->pattern) + FcPatternDestroy(font->pattern); + XftFontClose(font->dpy, font->xfont); + free(font); +} + +Fnt* +drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount) +{ + Fnt *cur, *ret = NULL; + size_t i; + + if (!drw || !fonts) + return NULL; + + for (i = 1; i <= fontcount; i++) { + if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) { + cur->next = ret; + ret = cur; + } + } + return (drw->fonts = ret); +} + +void +drw_fontset_free(Fnt *font) +{ + if (font) { + drw_fontset_free(font->next); + xfont_free(font); + } +} + +void +drw_clr_create(Drw *drw, Clr *dest, const char *clrname) +{ + if (!drw || !dest || !clrname) + return; + + if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen), + clrname, dest)) + die("error, cannot allocate color '%s'", clrname); +} + +/* Wrapper to create color schemes. The caller has to call free(3) on the + * returned color scheme when done using it. */ +Clr * +drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) +{ + size_t i; + Clr *ret; + + /* need at least two colors for a scheme */ + if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor)))) + return NULL; + + for (i = 0; i < clrcount; i++) + drw_clr_create(drw, &ret[i], clrnames[i]); + return ret; +} + +void +drw_setfontset(Drw *drw, Fnt *set) +{ + if (drw) + drw->fonts = set; +} + +void +drw_setscheme(Drw *drw, Clr *scm) +{ + if (drw) + drw->scheme = scm; +} + +void +drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert) +{ + if (!drw || !drw->scheme) + return; + XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel); + if (filled) + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + else + XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1); +} + +int +drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) +{ + char buf[1024]; + int ty; + unsigned int ew; + XftDraw *d = NULL; + Fnt *usedfont, *curfont, *nextfont; + size_t i, len; + int utf8strlen, utf8charlen, render = x || y || w || h; + long utf8codepoint = 0; + const char *utf8str; + FcCharSet *fccharset; + FcPattern *fcpattern; + FcPattern *match; + XftResult result; + int charexists = 0; + + if (!drw || (render && !drw->scheme) || !text || !drw->fonts) + return 0; + + if (!render) { + w = ~w; + } else { + XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + d = XftDrawCreate(drw->dpy, drw->drawable, + DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen)); + x += lpad; + w -= lpad; + } + + usedfont = drw->fonts; + while (1) { + utf8strlen = 0; + utf8str = text; + nextfont = NULL; + while (*text) { + utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ); + for (curfont = drw->fonts; curfont; curfont = curfont->next) { + charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint); + if (charexists) { + if (curfont == usedfont) { + utf8strlen += utf8charlen; + text += utf8charlen; + } else { + nextfont = curfont; + } + break; + } + } + + if (!charexists || nextfont) + break; + else + charexists = 0; + } + + if (utf8strlen) { + drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); + /* shorten text if necessary */ + for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) + drw_font_getexts(usedfont, utf8str, len, &ew, NULL); + + if (len) { + memcpy(buf, utf8str, len); + buf[len] = '\0'; + if (len < utf8strlen) + for (i = len; i && i > len - 3; buf[--i] = '.') + ; /* NOP */ + + if (render) { + ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; + XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg], + usedfont->xfont, x, ty, (XftChar8 *)buf, len); + } + x += ew; + w -= ew; + } + } + + if (!*text) { + break; + } else if (nextfont) { + charexists = 0; + usedfont = nextfont; + } else { + /* Regardless of whether or not a fallback font is found, the + * character must be drawn. */ + charexists = 1; + + fccharset = FcCharSetCreate(); + FcCharSetAddChar(fccharset, utf8codepoint); + + if (!drw->fonts->pattern) { + /* Refer to the comment in xfont_create for more information. */ + die("the first font in the cache must be loaded from a font string."); + } + + fcpattern = FcPatternDuplicate(drw->fonts->pattern); + FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); + FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); + FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); + + FcConfigSubstitute(NULL, fcpattern, FcMatchPattern); + FcDefaultSubstitute(fcpattern); + match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result); + + FcCharSetDestroy(fccharset); + FcPatternDestroy(fcpattern); + + if (match) { + usedfont = xfont_create(drw, NULL, match); + if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) { + for (curfont = drw->fonts; curfont->next; curfont = curfont->next) + ; /* NOP */ + curfont->next = usedfont; + } else { + xfont_free(usedfont); + usedfont = drw->fonts; + } + } + } + } + if (d) + XftDrawDestroy(d); + + return x + (render ? w : 0); +} + +int +utf8nextchar(const char *str, int len, int i, int inc) +{ + int n; + + for (n = i + inc; n + inc >= 0 && n + inc <= len + && (str[n] & 0xc0) == 0x80; n += inc) + ; + return n; +} + +int +drw_text_align(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int textlen, int align) +{ + int ty; + unsigned int ew; + XftDraw *d = NULL; + Fnt *usedfont, *curfont, *nextfont; + size_t len; + int utf8strlen, utf8charlen, render = x || y || w || h; + long utf8codepoint = 0; + const char *utf8str; + FcCharSet *fccharset; + FcPattern *fcpattern; + FcPattern *match; + XftResult result; + int charexists = 0; + int i, n; + + if (!drw || (render && !drw->scheme) || !text || !drw->fonts || textlen <= 0 + || (align != AlignL && align != AlignR)) + return 0; + + if (!render) { + w = ~w; + } else { + XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + d = XftDrawCreate(drw->dpy, drw->drawable, + DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen)); + } + + usedfont = drw->fonts; + i = align == AlignL ? 0 : textlen; + x = align == AlignL ? x : x + w; + while (1) { + utf8strlen = 0; + nextfont = NULL; + /* if (align == AlignL) */ + utf8str = text + i; + + while ((align == AlignL && i < textlen) || (align == AlignR && i > 0)) { + if (align == AlignL) { + utf8charlen = utf8decode(text + i, &utf8codepoint, MIN(textlen - i, UTF_SIZ)); + if (!utf8charlen) { + textlen = i; + break; + } + } else { + n = utf8nextchar(text, textlen, i, -1); + utf8charlen = utf8decode(text + n, &utf8codepoint, MIN(textlen - n, UTF_SIZ)); + if (!utf8charlen) { + textlen -= i; + text += i; + i = 0; + break; + } + } + for (curfont = drw->fonts; curfont; curfont = curfont->next) { + charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint); + if (charexists) { + if (curfont == usedfont) { + utf8strlen += utf8charlen; + i += align == AlignL ? utf8charlen : -utf8charlen; + } else { + nextfont = curfont; + } + break; + } + } + + if (!charexists || nextfont) + break; + else + charexists = 0; + } + + if (align == AlignR) + utf8str = text + i; + + if (utf8strlen) { + drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); + /* shorten text if necessary */ + if (align == AlignL) { + for (len = utf8strlen; len && ew > w; ) { + len = utf8nextchar(utf8str, len, len, -1); + drw_font_getexts(usedfont, utf8str, len, &ew, NULL); + } + } else { + for (len = utf8strlen; len && ew > w; ) { + n = utf8nextchar(utf8str, len, 0, +1); + utf8str += n; + len -= n; + drw_font_getexts(usedfont, utf8str, len, &ew, NULL); + } + } + + if (len) { + if (render) { + ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; + XftDrawStringUtf8(d, &drw->scheme[ColFg], + usedfont->xfont, align == AlignL ? x : x - ew, ty, (XftChar8 *)utf8str, len); + } + x += align == AlignL ? ew : -ew; + w -= ew; + } + if (len < utf8strlen) + break; + } + + if ((align == AlignR && i <= 0) || (align == AlignL && i >= textlen)) { + break; + } else if (nextfont) { + charexists = 0; + usedfont = nextfont; + } else { + /* Regardless of whether or not a fallback font is found, the + * character must be drawn. */ + charexists = 1; + + fccharset = FcCharSetCreate(); + FcCharSetAddChar(fccharset, utf8codepoint); + + if (!drw->fonts->pattern) { + /* Refer to the comment in xfont_create for more information. */ + die("the first font in the cache must be loaded from a font string."); + } + + fcpattern = FcPatternDuplicate(drw->fonts->pattern); + FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); + FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); + + FcConfigSubstitute(NULL, fcpattern, FcMatchPattern); + FcDefaultSubstitute(fcpattern); + match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result); + + FcCharSetDestroy(fccharset); + FcPatternDestroy(fcpattern); + + if (match) { + usedfont = xfont_create(drw, NULL, match); + if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) { + for (curfont = drw->fonts; curfont->next; curfont = curfont->next) + ; /* NOP */ + curfont->next = usedfont; + } else { + xfont_free(usedfont); + usedfont = drw->fonts; + } + } + } + } + if (d) + XftDrawDestroy(d); + + return x; +} + +void +drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) +{ + if (!drw) + return; + + XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y); + XSync(drw->dpy, False); +} + +unsigned int +drw_fontset_getwidth(Drw *drw, const char *text) +{ + if (!drw || !drw->fonts || !text) + return 0; + return drw_text(drw, 0, 0, 0, 0, 0, text, 0); +} + +void +drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h) +{ + XGlyphInfo ext; + + if (!font || !text) + return; + + XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext); + if (w) + *w = ext.xOff; + if (h) + *h = font->h; +} + +Cur * +drw_cur_create(Drw *drw, int shape) +{ + Cur *cur; + + if (!drw || !(cur = ecalloc(1, sizeof(Cur)))) + return NULL; + + cur->cursor = XCreateFontCursor(drw->dpy, shape); + + return cur; +} + +void +drw_cur_free(Drw *drw, Cur *cursor) +{ + if (!cursor) + return; + + XFreeCursor(drw->dpy, cursor->cursor); + free(cursor); +} diff --git a/src/sxmo-dmenu/drw.h b/src/sxmo-dmenu/drw.h new file mode 100644 index 0000000..b66a83e --- /dev/null +++ b/src/sxmo-dmenu/drw.h @@ -0,0 +1,59 @@ +/* See LICENSE file for copyright and license details. */ + +typedef struct { + Cursor cursor; +} Cur; + +typedef struct Fnt { + Display *dpy; + unsigned int h; + XftFont *xfont; + FcPattern *pattern; + struct Fnt *next; +} Fnt; + +enum { ColFg, ColBg }; /* Clr scheme index */ +enum { AlignL, AlignR }; +typedef XftColor Clr; + +typedef struct { + unsigned int w, h; + Display *dpy; + int screen; + Window root; + Drawable drawable; + GC gc; + Clr *scheme; + Fnt *fonts; +} Drw; + +/* Drawable abstraction */ +Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); +void drw_resize(Drw *drw, unsigned int w, unsigned int h); +void drw_free(Drw *drw); + +/* Fnt abstraction */ +Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); +void drw_fontset_free(Fnt* set); +unsigned int drw_fontset_getwidth(Drw *drw, const char *text); +void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); + +/* Colorscheme abstraction */ +void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); + +/* Cursor abstraction */ +Cur *drw_cur_create(Drw *drw, int shape); +void drw_cur_free(Drw *drw, Cur *cursor); + +/* Drawing context manipulation */ +void drw_setfontset(Drw *drw, Fnt *set); +void drw_setscheme(Drw *drw, Clr *scm); + +/* Drawing functions */ +void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); +int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); +int drw_text_align(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int textlen, int align); + +/* Map functions */ +void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/src/sxmo-dmenu/stest.1 b/src/sxmo-dmenu/stest.1 new file mode 100644 index 0000000..2667d8a --- /dev/null +++ b/src/sxmo-dmenu/stest.1 @@ -0,0 +1,90 @@ +.TH STEST 1 dmenu\-VERSION +.SH NAME +stest \- filter a list of files by properties +.SH SYNOPSIS +.B stest +.RB [ -abcdefghlpqrsuwx ] +.RB [ -n +.IR file ] +.RB [ -o +.IR file ] +.RI [ file ...] +.SH DESCRIPTION +.B stest +takes a list of files and filters by the files' properties, analogous to +.IR test (1). +Files which pass all tests are printed to stdout. If no files are given, stest +reads files from stdin. +.SH OPTIONS +.TP +.B \-a +Test hidden files. +.TP +.B \-b +Test that files are block specials. +.TP +.B \-c +Test that files are character specials. +.TP +.B \-d +Test that files are directories. +.TP +.B \-e +Test that files exist. +.TP +.B \-f +Test that files are regular files. +.TP +.B \-g +Test that files have their set-group-ID flag set. +.TP +.B \-h +Test that files are symbolic links. +.TP +.B \-l +Test the contents of a directory given as an argument. +.TP +.BI \-n " file" +Test that files are newer than +.IR file . +.TP +.BI \-o " file" +Test that files are older than +.IR file . +.TP +.B \-p +Test that files are named pipes. +.TP +.B \-q +No files are printed, only the exit status is returned. +.TP +.B \-r +Test that files are readable. +.TP +.B \-s +Test that files are not empty. +.TP +.B \-u +Test that files have their set-user-ID flag set. +.TP +.B \-v +Invert the sense of tests, only failing files pass. +.TP +.B \-w +Test that files are writable. +.TP +.B \-x +Test that files are executable. +.SH EXIT STATUS +.TP +.B 0 +At least one file passed all tests. +.TP +.B 1 +No files passed all tests. +.TP +.B 2 +An error occurred. +.SH SEE ALSO +.IR dmenu (1), +.IR test (1) diff --git a/src/sxmo-dmenu/stest.c b/src/sxmo-dmenu/stest.c new file mode 100644 index 0000000..7a7b0bc --- /dev/null +++ b/src/sxmo-dmenu/stest.c @@ -0,0 +1,109 @@ +/* See LICENSE file for copyright and license details. */ +#include + +#include +#include +#include +#include +#include +#include + +#include "arg.h" +char *argv0; + +#define FLAG(x) (flag[(x)-'a']) + +static void test(const char *, const char *); +static void usage(void); + +static int match = 0; +static int flag[26]; +static struct stat old, new; + +static void +test(const char *path, const char *name) +{ + struct stat st, ln; + + if ((!stat(path, &st) && (FLAG('a') || name[0] != '.') /* hidden files */ + && (!FLAG('b') || S_ISBLK(st.st_mode)) /* block special */ + && (!FLAG('c') || S_ISCHR(st.st_mode)) /* character special */ + && (!FLAG('d') || S_ISDIR(st.st_mode)) /* directory */ + && (!FLAG('e') || access(path, F_OK) == 0) /* exists */ + && (!FLAG('f') || S_ISREG(st.st_mode)) /* regular file */ + && (!FLAG('g') || st.st_mode & S_ISGID) /* set-group-id flag */ + && (!FLAG('h') || (!lstat(path, &ln) && S_ISLNK(ln.st_mode))) /* symbolic link */ + && (!FLAG('n') || st.st_mtime > new.st_mtime) /* newer than file */ + && (!FLAG('o') || st.st_mtime < old.st_mtime) /* older than file */ + && (!FLAG('p') || S_ISFIFO(st.st_mode)) /* named pipe */ + && (!FLAG('r') || access(path, R_OK) == 0) /* readable */ + && (!FLAG('s') || st.st_size > 0) /* not empty */ + && (!FLAG('u') || st.st_mode & S_ISUID) /* set-user-id flag */ + && (!FLAG('w') || access(path, W_OK) == 0) /* writable */ + && (!FLAG('x') || access(path, X_OK) == 0)) != FLAG('v')) { /* executable */ + if (FLAG('q')) + exit(0); + match = 1; + puts(name); + } +} + +static void +usage(void) +{ + fprintf(stderr, "usage: %s [-abcdefghlpqrsuvwx] " + "[-n file] [-o file] [file...]\n", argv0); + exit(2); /* like test(1) return > 1 on error */ +} + +int +main(int argc, char *argv[]) +{ + struct dirent *d; + char path[PATH_MAX], *line = NULL, *file; + size_t linesiz = 0; + ssize_t n; + DIR *dir; + int r; + + ARGBEGIN { + case 'n': /* newer than file */ + case 'o': /* older than file */ + file = EARGF(usage()); + if (!(FLAG(ARGC()) = !stat(file, (ARGC() == 'n' ? &new : &old)))) + perror(file); + break; + default: + /* miscellaneous operators */ + if (strchr("abcdefghlpqrsuvwx", ARGC())) + FLAG(ARGC()) = 1; + else + usage(); /* unknown flag */ + } ARGEND; + + if (!argc) { + /* read list from stdin */ + while ((n = getline(&line, &linesiz, stdin)) > 0) { + if (n && line[n - 1] == '\n') + line[n - 1] = '\0'; + test(line, line); + } + free(line); + } else { + for (; argc; argc--, argv++) { + if (FLAG('l') && (dir = opendir(*argv))) { + /* test directory contents */ + while ((d = readdir(dir))) { + r = snprintf(path, sizeof path, "%s/%s", + *argv, d->d_name); + if (r >= 0 && (size_t)r < sizeof path) + test(path, d->d_name); + } + closedir(dir); + } else { + test(*argv, *argv); + } + } + } + return match ? 0 : 1; +} diff --git a/src/sxmo-dmenu/util.c b/src/sxmo-dmenu/util.c new file mode 100644 index 0000000..fe044fc --- /dev/null +++ b/src/sxmo-dmenu/util.c @@ -0,0 +1,35 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include + +#include "util.h" + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} + +void +die(const char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') { + fputc(' ', stderr); + perror(NULL); + } else { + fputc('\n', stderr); + } + + exit(1); +} diff --git a/src/sxmo-dmenu/util.h b/src/sxmo-dmenu/util.h new file mode 100644 index 0000000..f633b51 --- /dev/null +++ b/src/sxmo-dmenu/util.h @@ -0,0 +1,8 @@ +/* See LICENSE file for copyright and license details. */ + +#define MAX(A, B) ((A) > (B) ? (A) : (B)) +#define MIN(A, B) ((A) < (B) ? (A) : (B)) +#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) + +void die(const char *fmt, ...); +void *ecalloc(size_t nmemb, size_t size); diff --git a/src/sxmo-dwm/.build.yml b/src/sxmo-dwm/.build.yml new file mode 100644 index 0000000..c5c5243 --- /dev/null +++ b/src/sxmo-dwm/.build.yml @@ -0,0 +1,16 @@ +image: alpine/edge +packages: + - editorconfig-checker + - libxft-dev + - libx11-dev + - libxinerama-dev + - pango-dev +sources: + - https://git.sr.ht/~mil/sxmo-dwm +tasks: + - editorconfig-check: | + cd sxmo-dwm + ec + - make: | + cd sxmo-dwm + make diff --git a/src/sxmo-dwm/.editorconfig b/src/sxmo-dwm/.editorconfig new file mode 100644 index 0000000..b9e964e --- /dev/null +++ b/src/sxmo-dwm/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*.{sh|c}] +end_of_line = lf +insert_final_newline = true +indent_style = tab +#max_line_length = 80 +spaces_around_operators = true +charset = utf-8 +trim_trailing_whitespace = true diff --git a/src/sxmo-dwm/LICENSE b/src/sxmo-dwm/LICENSE new file mode 100644 index 0000000..d221f09 --- /dev/null +++ b/src/sxmo-dwm/LICENSE @@ -0,0 +1,37 @@ +MIT/X Consortium License + +© 2006-2019 Anselm R Garbe +© 2006-2009 Jukka Salmi +© 2006-2007 Sander van Dijk +© 2007-2011 Peter Hartlich +© 2007-2009 Szabolcs Nagy +© 2007-2009 Christof Musik +© 2007-2009 Premysl Hruby +© 2007-2008 Enno Gottox Boland +© 2008 Martin Hurton +© 2008 Neale Pickett +© 2009 Mate Nagy +© 2010-2016 Hiltjo Posthuma +© 2010-2012 Connor Lane Smith +© 2011 Christoph Lohmann <20h@r-36.net> +© 2015-2016 Quentin Rameau +© 2015-2016 Eric Pruitt +© 2016-2017 Markus Teich + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/sxmo-dwm/Makefile b/src/sxmo-dwm/Makefile new file mode 100644 index 0000000..77bcbc0 --- /dev/null +++ b/src/sxmo-dwm/Makefile @@ -0,0 +1,51 @@ +# dwm - dynamic window manager +# See LICENSE file for copyright and license details. + +include config.mk + +SRC = drw.c dwm.c util.c +OBJ = ${SRC:.c=.o} + +all: options dwm + +options: + @echo dwm build options: + @echo "CFLAGS = ${CFLAGS}" + @echo "LDFLAGS = ${LDFLAGS}" + @echo "CC = ${CC}" + +.c.o: + ${CC} -c ${CFLAGS} $< + +${OBJ}: config.h config.mk + +config.h: + cp config.def.h $@ + +dwm: ${OBJ} + ${CC} -o $@ ${OBJ} ${LDFLAGS} + +clean: + rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz + +dist: clean + mkdir -p dwm-${VERSION} + cp -R LICENSE Makefile README config.def.h config.mk\ + dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION} + tar -cf dwm-${VERSION}.tar dwm-${VERSION} + gzip dwm-${VERSION}.tar + rm -rf dwm-${VERSION} + +install: all + mkdir -p ${DESTDIR}${PREFIX}/bin + cp -f dwm ${DESTDIR}${PREFIX}/bin + chmod 755 ${DESTDIR}${PREFIX}/bin/dwm + mkdir -p ${DESTDIR}${MANPREFIX}/man1 + sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 + chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1 + +uninstall: + rm -f ${DESTDIR}${PREFIX}/bin/dwm\ + ${DESTDIR}${MANPREFIX}/man1/dwm.1 + +.PHONY: all options clean dist install uninstall diff --git a/src/sxmo-dwm/README.md b/src/sxmo-dwm/README.md new file mode 100644 index 0000000..4be9d64 --- /dev/null +++ b/src/sxmo-dwm/README.md @@ -0,0 +1,50 @@ +dwm - dynamic window manager +============================ +[![builds.sr.ht status](https://builds.sr.ht/~mil/sxmo-dwm.svg)](https://builds.sr.ht/~mil/sxmo-dwm?) + +dwm is an extremely fast, small, and dynamic window manager for X. + + +Requirements +------------ +In order to build dwm you need the Xlib header files. + + +Installation +------------ +Edit config.mk to match your local setup (dwm is installed into +the /usr/local namespace by default). + +Afterwards enter the following command to build and install dwm (if +necessary as root): + + make clean install + + +Running dwm +----------- +Add the following line to your .xinitrc to start dwm using startx: + + exec dwm + +In order to connect dwm to a specific display, make sure that +the DISPLAY environment variable is set correctly, e.g.: + + DISPLAY=foo.bar:1 exec dwm + +(This will start dwm on display :1 of the host foo.bar.) + +In order to display status info in the bar, you can do something +like this in your .xinitrc: + + while xsetroot -name "`date` `uptime | sed 's/.*,//'`" + do + sleep 1 + done & + exec dwm + + +Configuration +------------- +The configuration of dwm is done by creating a custom config.h +and (re)compiling the source code. diff --git a/src/sxmo-dwm/config.def.h b/src/sxmo-dwm/config.def.h new file mode 100644 index 0000000..cd21599 --- /dev/null +++ b/src/sxmo-dwm/config.def.h @@ -0,0 +1,171 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 16; /* snap pixel */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +static const char font[] = "Fira Code, DejaVuSansM Nerd Font 15px"; +static const char dmenufont[] = "Fira Code:pixelsize=18:style=Regular:antialias=true:autohint=true"; +static const char col_gray1[] = "#323232"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#dddddd"; +static const char col_gray4[] = "#ffffff"; +static const char col_cyan[] = "#005577"; +static const char *defaultcolors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeTabActive] = { col_gray2, col_gray3, col_gray2 }, + [SchemeTabInactive] = { col_gray1, col_gray3, col_gray1 } +}; + +/* 1 means attach after the currently active window */ +static const int attachbelow = 1; + +/* tagging */ +static const char *tags[] = { "1", "2", "3", "4" }; + +static const Rule rules[] = { + /* class instance title tags mask isfloating isterminal noswallow monitor */ + { "st", NULL, NULL, 0, 0, 1, 1, -1, 0}, + { "St", NULL, NULL, 0, 0, 1, 1, -1, 0}, + { "svkbd", NULL, NULL, TAGMASK, 1, 1, 0, -1, 1}, +}; + +/* layout(s) */ +static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ + +/* Bartabgroups properties */ +#define BARTAB_BORDERS 1 // 0 = off, 1 = on +#define BARTAB_BOTTOMBORDER 1 // 0 = off, 1 = on +#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on +#define BARTAB_TAGSPX 4 // # pixels for tag grid boxes +#define BARTAB_TAGSROWS 2 // # rows in tag grid (9 tags, e.g. 3x3) +static void (*bartabmonfns[])(Monitor *) = { monocle, bstack }; +static void (*bartabfloatfns[])(Monitor *) = { NULL }; + +static const Layout ppcyclelayouts[] = { + /* symbol arrange function */ + { "", bstack }, /* first entry is default (vertical stack for 240x320) */ + { "", monocle }, + { "", tile }, +}; + +static const Layout layouts[] = { + /* symbol arrange function */ + { "", bstack }, /* first entry is default */ + { "", tile }, + { "F", NULL }, + { "", monocle }, + { "DD", deckdouble }, + { "D", deck }, +}; + +/* key definitions */ +#define MODKEY Mod4Mask +#define ALTKEY Mod1Mask +#define TAGKEYS(KEY,TAG) \ + { KeyPress, MODKEY, KEY, view, {.ui = 1 << TAG} }, \ + { KeyPress, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { KeyPress, MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* commands */ +static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; + +#include +#ifndef _EVDEVK +#define _EVDEVK(_v) (0x10081000 + (_v)) +#endif +static Key keys[] = { + /* Nokia 8110 4G / MSM8909 Physical Keypad & Action Keys */ + { KeyPress, 0, XK_Menu, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", "sys", NULL } } }, + { KeyPress, 0, XF86XK_KbdLcdMenu1, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", "sys", NULL } } }, + { KeyPress, 0, XF86XK_Back, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } } }, + { KeyPress, 0, XF86XK_KbdLcdMenu2, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } } }, + { KeyPress, 0, XF86XK_Phone, spawn, { .v = (const char*[]){ "sxmo_hook_inputhandler.sh", "enter_one", NULL } } }, + { KeyPress, 0, XF86XK_PickupPhone, spawn, { .v = (const char*[]){ "sxmo_hook_inputhandler.sh", "enter_one", NULL } } }, + { KeyPress, 0, XF86XK_PowerOff, spawn, { .v = (const char*[]){ "sxmo_multikey.sh", "powerbutton", "powerbutton_one", "powerbutton_two", "powerbutton_three", NULL } } }, + { KeyPress, 0, XF86XK_AudioRaiseVolume, spawn, { .v = (const char*[]){ "sxmo_audio.sh", "vol", "up", "5", NULL } } }, + { KeyPress, 0, XF86XK_AudioLowerVolume, spawn, { .v = (const char*[]){ "sxmo_audio.sh", "vol", "down", "5", NULL } } }, + + /* Used by scripts via xdotool */ + { KeyPress, MODKEY|ShiftMask, XK_e, shiftview, {.i = -1} }, + { KeyPress, MODKEY|ShiftMask, XK_r, shiftview, {.i = +1} }, + { KeyPress, MODKEY, XK_e, clienttagpush, {.i = -1} }, + { KeyPress, MODKEY, XK_r, clienttagpush, {.i = +1} }, + + /* Quick Navigation */ + { KeyPress, MODKEY, XK_p, spawn, SHCMD("sxmo_appmenu.sh") }, + { KeyPress, MODKEY, XK_d, spawn, SHCMD("sxmo_files.sh") }, + { KeyPress, MODKEY|ShiftMask, XK_Return, spawn, SHCMD("st") }, + { KeyPress, MODKEY, XK_b, togglebar, {0} }, + { KeyPress, MODKEY, XK_j, focusstack, {.i = +1 } }, + { KeyPress, MODKEY, XK_k, focusstack, {.i = -1 } }, + { KeyPress, MODKEY, XK_Down, focusstack, {.i = +1 } }, + { KeyPress, MODKEY, XK_Up, focusstack, {.i = -1 } }, + + { KeyPress, MODKEY|ShiftMask, XK_j, pushdown, {.i = +1 } }, + { KeyPress, MODKEY|ShiftMask, XK_k, pushup, {.i = -1 } }, + + { KeyPress, MODKEY, XK_x, focusstack, {.i = +1 } }, + + { KeyPress, 0, XF86XK_MonBrightnessUp, spawn, SHCMD("sxmo_brightness.sh up") }, + { KeyPress, 0, XF86XK_MonBrightnessDown, spawn, SHCMD("sxmo_brightness.sh down") }, + { KeyPress, MODKEY|ShiftMask, XK_Down, spawn, SHCMD("sxmo_audio.sh vol down") }, + { KeyPress, MODKEY|ShiftMask, XK_Up, spawn, SHCMD("sxmo_audio.sh vol up") }, + + { KeyPress, MODKEY, XK_i, incnmaster, {.i = +1 } }, + { KeyPress, MODKEY, XK_o, incnmaster, {.i = -1 } }, + { KeyPress, MODKEY, XK_h, setmfact, {.f = -0.05} }, + { KeyPress, MODKEY, XK_l, setmfact, {.f = +0.05} }, + { KeyPress, MODKEY, XK_Return, zoom, {0} }, + { KeyPress, MODKEY, XK_Tab, view, {0} }, + { KeyPress, MODKEY|ShiftMask, XK_c, killclient, {0} }, + { KeyPress, MODKEY|ShiftMask, XK_q, killclient, {0} }, + + { KeyPress, MODKEY, XK_semicolon, switchcol, {0} }, + { KeyPress, MODKEY, XK_s, transfer, {0} }, + + /* monocle */ + { KeyPress, MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, + /* tile */ + { KeyPress, MODKEY, XK_slash, setlayout, {.v = &layouts[1]} }, + /* bstack */ + { KeyPress, MODKEY|ShiftMask, XK_slash, setlayout, {.v = &layouts[0]} }, + + { KeyPress, MODKEY, XK_f, togglefloating, {0} }, + { KeyPress, MODKEY|ShiftMask, XK_f, unfloatvisible, {0} }, + + /* cycle through the layouts in ppcyclelayouts */ + { KeyPress, MODKEY, XK_space, cyclelayout, {.i = +1} }, + { KeyPress, MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { KeyPress, MODKEY, XK_0, view, {.ui = ~0 } }, + { KeyPress, MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + + { KeyPress, MODKEY, XK_comma, focusmon, {.i = -1 } }, + { KeyPress, MODKEY, XK_period, focusmon, {.i = +1 } }, + { KeyPress, MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { KeyPress, MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) +}; + +/* button definitions */ +/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static Button buttons[] = { + /* click event mask button function argument */ + { ClkTagBar, 0, Button1, view, {0} }, + { ClkLtSymbol, 0, Button1, cyclelayout, {.i = +1} }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, +}; diff --git a/src/sxmo-dwm/config.h b/src/sxmo-dwm/config.h new file mode 100644 index 0000000..cd21599 --- /dev/null +++ b/src/sxmo-dwm/config.h @@ -0,0 +1,171 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 16; /* snap pixel */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +static const char font[] = "Fira Code, DejaVuSansM Nerd Font 15px"; +static const char dmenufont[] = "Fira Code:pixelsize=18:style=Regular:antialias=true:autohint=true"; +static const char col_gray1[] = "#323232"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#dddddd"; +static const char col_gray4[] = "#ffffff"; +static const char col_cyan[] = "#005577"; +static const char *defaultcolors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeTabActive] = { col_gray2, col_gray3, col_gray2 }, + [SchemeTabInactive] = { col_gray1, col_gray3, col_gray1 } +}; + +/* 1 means attach after the currently active window */ +static const int attachbelow = 1; + +/* tagging */ +static const char *tags[] = { "1", "2", "3", "4" }; + +static const Rule rules[] = { + /* class instance title tags mask isfloating isterminal noswallow monitor */ + { "st", NULL, NULL, 0, 0, 1, 1, -1, 0}, + { "St", NULL, NULL, 0, 0, 1, 1, -1, 0}, + { "svkbd", NULL, NULL, TAGMASK, 1, 1, 0, -1, 1}, +}; + +/* layout(s) */ +static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ + +/* Bartabgroups properties */ +#define BARTAB_BORDERS 1 // 0 = off, 1 = on +#define BARTAB_BOTTOMBORDER 1 // 0 = off, 1 = on +#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on +#define BARTAB_TAGSPX 4 // # pixels for tag grid boxes +#define BARTAB_TAGSROWS 2 // # rows in tag grid (9 tags, e.g. 3x3) +static void (*bartabmonfns[])(Monitor *) = { monocle, bstack }; +static void (*bartabfloatfns[])(Monitor *) = { NULL }; + +static const Layout ppcyclelayouts[] = { + /* symbol arrange function */ + { "", bstack }, /* first entry is default (vertical stack for 240x320) */ + { "", monocle }, + { "", tile }, +}; + +static const Layout layouts[] = { + /* symbol arrange function */ + { "", bstack }, /* first entry is default */ + { "", tile }, + { "F", NULL }, + { "", monocle }, + { "DD", deckdouble }, + { "D", deck }, +}; + +/* key definitions */ +#define MODKEY Mod4Mask +#define ALTKEY Mod1Mask +#define TAGKEYS(KEY,TAG) \ + { KeyPress, MODKEY, KEY, view, {.ui = 1 << TAG} }, \ + { KeyPress, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { KeyPress, MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* commands */ +static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; + +#include +#ifndef _EVDEVK +#define _EVDEVK(_v) (0x10081000 + (_v)) +#endif +static Key keys[] = { + /* Nokia 8110 4G / MSM8909 Physical Keypad & Action Keys */ + { KeyPress, 0, XK_Menu, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", "sys", NULL } } }, + { KeyPress, 0, XF86XK_KbdLcdMenu1, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", "sys", NULL } } }, + { KeyPress, 0, XF86XK_Back, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } } }, + { KeyPress, 0, XF86XK_KbdLcdMenu2, spawn, { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } } }, + { KeyPress, 0, XF86XK_Phone, spawn, { .v = (const char*[]){ "sxmo_hook_inputhandler.sh", "enter_one", NULL } } }, + { KeyPress, 0, XF86XK_PickupPhone, spawn, { .v = (const char*[]){ "sxmo_hook_inputhandler.sh", "enter_one", NULL } } }, + { KeyPress, 0, XF86XK_PowerOff, spawn, { .v = (const char*[]){ "sxmo_multikey.sh", "powerbutton", "powerbutton_one", "powerbutton_two", "powerbutton_three", NULL } } }, + { KeyPress, 0, XF86XK_AudioRaiseVolume, spawn, { .v = (const char*[]){ "sxmo_audio.sh", "vol", "up", "5", NULL } } }, + { KeyPress, 0, XF86XK_AudioLowerVolume, spawn, { .v = (const char*[]){ "sxmo_audio.sh", "vol", "down", "5", NULL } } }, + + /* Used by scripts via xdotool */ + { KeyPress, MODKEY|ShiftMask, XK_e, shiftview, {.i = -1} }, + { KeyPress, MODKEY|ShiftMask, XK_r, shiftview, {.i = +1} }, + { KeyPress, MODKEY, XK_e, clienttagpush, {.i = -1} }, + { KeyPress, MODKEY, XK_r, clienttagpush, {.i = +1} }, + + /* Quick Navigation */ + { KeyPress, MODKEY, XK_p, spawn, SHCMD("sxmo_appmenu.sh") }, + { KeyPress, MODKEY, XK_d, spawn, SHCMD("sxmo_files.sh") }, + { KeyPress, MODKEY|ShiftMask, XK_Return, spawn, SHCMD("st") }, + { KeyPress, MODKEY, XK_b, togglebar, {0} }, + { KeyPress, MODKEY, XK_j, focusstack, {.i = +1 } }, + { KeyPress, MODKEY, XK_k, focusstack, {.i = -1 } }, + { KeyPress, MODKEY, XK_Down, focusstack, {.i = +1 } }, + { KeyPress, MODKEY, XK_Up, focusstack, {.i = -1 } }, + + { KeyPress, MODKEY|ShiftMask, XK_j, pushdown, {.i = +1 } }, + { KeyPress, MODKEY|ShiftMask, XK_k, pushup, {.i = -1 } }, + + { KeyPress, MODKEY, XK_x, focusstack, {.i = +1 } }, + + { KeyPress, 0, XF86XK_MonBrightnessUp, spawn, SHCMD("sxmo_brightness.sh up") }, + { KeyPress, 0, XF86XK_MonBrightnessDown, spawn, SHCMD("sxmo_brightness.sh down") }, + { KeyPress, MODKEY|ShiftMask, XK_Down, spawn, SHCMD("sxmo_audio.sh vol down") }, + { KeyPress, MODKEY|ShiftMask, XK_Up, spawn, SHCMD("sxmo_audio.sh vol up") }, + + { KeyPress, MODKEY, XK_i, incnmaster, {.i = +1 } }, + { KeyPress, MODKEY, XK_o, incnmaster, {.i = -1 } }, + { KeyPress, MODKEY, XK_h, setmfact, {.f = -0.05} }, + { KeyPress, MODKEY, XK_l, setmfact, {.f = +0.05} }, + { KeyPress, MODKEY, XK_Return, zoom, {0} }, + { KeyPress, MODKEY, XK_Tab, view, {0} }, + { KeyPress, MODKEY|ShiftMask, XK_c, killclient, {0} }, + { KeyPress, MODKEY|ShiftMask, XK_q, killclient, {0} }, + + { KeyPress, MODKEY, XK_semicolon, switchcol, {0} }, + { KeyPress, MODKEY, XK_s, transfer, {0} }, + + /* monocle */ + { KeyPress, MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, + /* tile */ + { KeyPress, MODKEY, XK_slash, setlayout, {.v = &layouts[1]} }, + /* bstack */ + { KeyPress, MODKEY|ShiftMask, XK_slash, setlayout, {.v = &layouts[0]} }, + + { KeyPress, MODKEY, XK_f, togglefloating, {0} }, + { KeyPress, MODKEY|ShiftMask, XK_f, unfloatvisible, {0} }, + + /* cycle through the layouts in ppcyclelayouts */ + { KeyPress, MODKEY, XK_space, cyclelayout, {.i = +1} }, + { KeyPress, MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { KeyPress, MODKEY, XK_0, view, {.ui = ~0 } }, + { KeyPress, MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + + { KeyPress, MODKEY, XK_comma, focusmon, {.i = -1 } }, + { KeyPress, MODKEY, XK_period, focusmon, {.i = +1 } }, + { KeyPress, MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { KeyPress, MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) +}; + +/* button definitions */ +/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static Button buttons[] = { + /* click event mask button function argument */ + { ClkTagBar, 0, Button1, view, {0} }, + { ClkLtSymbol, 0, Button1, cyclelayout, {.i = +1} }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, +}; diff --git a/src/sxmo-dwm/config.mk b/src/sxmo-dwm/config.mk new file mode 100644 index 0000000..51a837f --- /dev/null +++ b/src/sxmo-dwm/config.mk @@ -0,0 +1,41 @@ +# dwm version +VERSION = 6.3.1-sxmo + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# Xinerama, comment if you don't want it +XINERAMALIBS = -lXinerama +XINERAMAFLAGS = -DXINERAMA + +# freetype +FREETYPELIBS = -lfontconfig -lXft +FREETYPEINC = /usr/include/freetype2 +# OpenBSD (uncomment) +#FREETYPEINC = ${X11INC}/freetype2 + +# Disable bonsai by uncommenting this +#NOBONSAIFLAGS = -DNOBONSAI + +# includes and libs +INCS = -I${X11INC} -I${FREETYPEINC} `pkg-config --cflags xft pango pangoxft` +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lrt `pkg-config --libs xft pango pangoxft` + +# flags +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${NOBONSAIFLAGS} +#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} +CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} +LDFLAGS = ${LIBS} + +# Solaris +#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" +#LDFLAGS = ${LIBS} + +# compiler and linker +CC = cc diff --git a/src/sxmo-dwm/drw.c b/src/sxmo-dwm/drw.c new file mode 100644 index 0000000..d026ad4 --- /dev/null +++ b/src/sxmo-dwm/drw.c @@ -0,0 +1,298 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include +#include +#include +#include + +#include "drw.h" +#include "util.h" + +Drw * +drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h) +{ + Drw *drw = ecalloc(1, sizeof(Drw)); + + drw->dpy = dpy; + drw->screen = screen; + drw->root = root; + drw->w = w; + drw->h = h; + drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); + drw->gc = XCreateGC(dpy, root, 0, NULL); + XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); + + return drw; +} + +void +drw_resize(Drw *drw, unsigned int w, unsigned int h) +{ + if (!drw) + return; + + drw->w = w; + drw->h = h; + if (drw->drawable) + XFreePixmap(drw->dpy, drw->drawable); + drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); +} + +void +drw_free(Drw *drw) +{ + XFreePixmap(drw->dpy, drw->drawable); + XFreeGC(drw->dpy, drw->gc); + drw_font_free(drw->font); + free(drw); +} + +/* This function is an implementation detail. Library users should use + * drw_font_create instead. + */ +static Fnt * +xfont_create(Drw *drw, const char *fontname) +{ + Fnt *font; + PangoFontMap *fontmap; + PangoContext *context; + PangoFontDescription *desc; + PangoFontMetrics *metrics; + + if (!fontname) { + die("no font specified."); + } + + font = ecalloc(1, sizeof(Fnt)); + font->dpy = drw->dpy; + + fontmap = pango_xft_get_font_map(drw->dpy, drw->screen); + context = pango_font_map_create_context(fontmap); + desc = pango_font_description_from_string(fontname); + font->layout = pango_layout_new(context); + pango_layout_set_font_description(font->layout, desc); + + metrics = pango_context_get_metrics(context, desc, NULL); + font->h = pango_font_metrics_get_height(metrics) / PANGO_SCALE; + + pango_font_metrics_unref(metrics); + g_object_unref(context); + + return font; +} + +static void +xfont_free(Fnt *font) +{ + if (!font) + return; + if (font->layout) + g_object_unref(font->layout); + free(font); +} + +Fnt* +drw_font_create(Drw* drw, const char font[]) +{ + Fnt *fnt = NULL; + + if (!drw || !font) + return NULL; + + fnt = xfont_create(drw, font); + + return (drw->font = fnt); +} + +void +drw_font_free(Fnt *font) +{ + if (font) { + xfont_free(font); + } +} + +void +drw_clr_create(Drw *drw, Clr *dest, const char *clrname) +{ + if (!drw || !dest || !clrname) + return; + + if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen), + clrname, dest)) + die("error, cannot allocate color '%s'", clrname); +} + +/* Wrapper to create color schemes. The caller has to call free(3) on the + * returned color scheme when done using it. */ +Clr * +drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) +{ + size_t i; + Clr *ret; + + /* need at least two colors for a scheme */ + if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor)))) + return NULL; + + for (i = 0; i < clrcount; i++) + drw_clr_create(drw, &ret[i], clrnames[i]); + return ret; +} + +void +drw_setscheme(Drw *drw, Clr *scm) +{ + if (drw) + drw->scheme = scm; +} + +void +drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert) +{ + if (!drw || !drw->scheme) + return; + XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel); + if (filled) + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + else + XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1); +} + +int +drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup) +{ + char buf[1024]; + int ty, th; + unsigned int ew, eh; + XftDraw *d = NULL; + size_t i, len; + + int render = x || y || w || h; + + if (!drw || (render && !drw->scheme) || !text || !drw->font) + return 0; + + if (!render) { + w = ~w; + } else { + XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + d = XftDrawCreate(drw->dpy, drw->drawable, + DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen)); + x += lpad; + w -= lpad; + } + + len = strlen(text); + + if (len) { + drw_font_getexts(drw->font, text, len, &ew, &eh, markup); + th = eh; + /* shorten text if necessary */ + for (len = MIN(len, sizeof(buf) - 1); len && ew > w; len--) { + drw_font_getexts(drw->font, text, len, &ew, &eh, markup); + if (eh > th) + th = eh; + } + + if (len) { + memcpy(buf, text, len); + buf[len] = '\0'; + if (len < strlen(text)) + for (i = len; i && i > len - 3; buf[--i] = '.') + ; /* NOP */ + + if (render) { + ty = y + (h - th) / 2; + if(markup) + pango_layout_set_markup(drw->font->layout, buf, len); + else + pango_layout_set_text(drw->font->layout, buf, len); + pango_xft_render_layout(d, &drw->scheme[invert ? ColBg : ColFg], + drw->font->layout, x * PANGO_SCALE, ty * PANGO_SCALE); + if(markup) /* clear markup attributes */ + pango_layout_set_attributes(drw->font->layout, NULL); + } + x += ew; + w -= ew; + } + } + + if (d) + XftDrawDestroy(d); + + return x + (render ? w : 0); +} + +void +drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) +{ + if (!drw) + return; + + XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y); + XSync(drw->dpy, False); +} + +unsigned int +drw_font_getwidth(Drw *drw, const char *text, Bool markup) +{ + if (!drw || !drw->font || !text) + return 0; + return drw_text(drw, 0, 0, 0, 0, 0, text, 0, markup); +} + +void +drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup) +{ + if (!font || !text) + return; + + PangoRectangle r; + if(markup) + pango_layout_set_markup(font->layout, text, len); + else + pango_layout_set_text(font->layout, text, len); + pango_layout_get_extents(font->layout, 0, &r); + if(markup) /* clear markup attributes */ + pango_layout_set_attributes(font->layout, NULL); + if (w) + *w = r.width / PANGO_SCALE; + if (h) + *h = r.height / PANGO_SCALE; +} + +Cur * +drw_cur_create(Drw *drw, int shape) +{ + Cur *cur; + Pixmap blank; + XColor dummy; + static const char data[1] = {0}; + + (void)shape; + if (!drw || !(cur = ecalloc(1, sizeof(Cur)))) + return NULL; + + memset(&dummy, 0, sizeof(dummy)); + blank = XCreateBitmapFromData(drw->dpy, drw->root, data, 1, 1); + cur->cursor = XCreatePixmapCursor(drw->dpy, blank, blank, &dummy, &dummy, 0, 0); + XFreePixmap(drw->dpy, blank); + + return cur; +} + +void +drw_cur_free(Drw *drw, Cur *cursor) +{ + if (!cursor) + return; + + XFreeCursor(drw->dpy, cursor->cursor); + free(cursor); +} diff --git a/src/sxmo-dwm/drw.h b/src/sxmo-dwm/drw.h new file mode 100644 index 0000000..3d3a906 --- /dev/null +++ b/src/sxmo-dwm/drw.h @@ -0,0 +1,54 @@ +/* See LICENSE file for copyright and license details. */ + +typedef struct { + Cursor cursor; +} Cur; + +typedef struct Fnt { + Display *dpy; + unsigned int h; + PangoLayout *layout; +} Fnt; + +enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */ +typedef XftColor Clr; + +typedef struct { + unsigned int w, h; + Display *dpy; + int screen; + Window root; + Drawable drawable; + GC gc; + Clr *scheme; + Fnt *font; +} Drw; + +/* Drawable abstraction */ +Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); +void drw_resize(Drw *drw, unsigned int w, unsigned int h); +void drw_free(Drw *drw); + +/* Fnt abstraction */ +Fnt *drw_font_create(Drw* drw, const char font[]); +void drw_font_free(Fnt* set); +unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup); +void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup); + +/* Colorscheme abstraction */ +void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); + +/* Cursor abstraction */ +Cur *drw_cur_create(Drw *drw, int shape); +void drw_cur_free(Drw *drw, Cur *cursor); + +/* Drawing context manipulation */ +void drw_setscheme(Drw *drw, Clr *scm); + +/* Drawing functions */ +void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); +int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup); + +/* Map functions */ +void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/src/sxmo-dwm/dwm.1 b/src/sxmo-dwm/dwm.1 new file mode 100644 index 0000000..86f497b --- /dev/null +++ b/src/sxmo-dwm/dwm.1 @@ -0,0 +1,226 @@ +.TH DWM 1 dwm\-VERSION +.SH NAME +dwm \- dynamic window manager +.SH SYNOPSIS +.B dwm +.RB [ \-v ] +.SH DESCRIPTION +dwm is a dynamic window manager for X. It manages windows in tiled, monocle +and floating layouts. Either layout can be applied dynamically, optimising the +environment for the application in use and the task performed. +.P +In tiled layouts windows are managed in a master and stacking area. The master +area on the left contains one window by default, and the stacking area on the +right contains all other windows. The number of master area windows can be +adjusted from zero to an arbitrary number. In monocle layout all windows are +maximised to the screen size. In floating layout windows can be resized and +moved freely. Dialog windows are always managed floating, regardless of the +layout applied. +.P +Windows are grouped by tags. Each window can be tagged with one or multiple +tags. Selecting certain tags displays all windows with these tags. +.P +Each screen contains a small status bar which displays all available tags, the +layout, the title of the focused window, and the text read from the root window +name property, if the screen is focused. A floating window is indicated with an +empty square and a maximised floating window is indicated with a filled square +before the windows title. The selected tags are indicated with a different +color. The tags of the focused window are indicated with a filled square in the +top left corner. The tags which are applied to one or more windows are +indicated with an empty square in the top left corner. +.P +The attach below patch makes newly spawned windows attach after the currently +selected window +.P +dwm draws a small border around windows to indicate the focus state. +.SH OPTIONS +.TP +.B \-v +prints version information to standard output, then exits. +.SH USAGE +.SS Status bar +.TP +.B X root window name +is read and displayed in the status text area. It can be set with the +.BR xsetroot (1) +command. +.TP +.B Button1 +click on a tag label to display all windows with that tag, click on the layout +label toggles between tiled and floating layout. +.TP +.B Button3 +click on a tag label adds/removes all windows with that tag to/from the view. +.TP +.B Mod4\-Button1 +click on a tag label applies that tag to the focused window. +.TP +.B Mod4\-Button3 +click on a tag label adds/removes that tag to/from the focused window. +.SS Keyboard commands +.TP +.B Mod4\-Shift\-Return +Start +.BR st(1). +.TP +.B Mod4\-p +Spawn +.BR dmenu(1) +for launching other programs. +.TP +.B Mod4\-, +Focus previous screen, if any. +.TP +.B Mod4\-. +Focus next screen, if any. +.TP +.B Mod4\-Shift\-, +Send focused window to previous screen, if any. +.TP +.B Mod4\-Shift\-. +Send focused window to next screen, if any. +.TP +.B Mod4\-b +Toggles bar on and off. +.TP +.B Mod4\-t +Sets tiled layout. +.TP +.B Mod4\-f +Sets floating layout. +.TP +.B Mod4\-m +Sets monocle layout. +.TP +.B Mod4\-space +Toggles between current and previous layout. +.TP +.B Mod4\-Control\-, +Cycles backwards in layout list. +.TP +.B Mod4\-Control\-. +Cycles forwards in layout list. +.TP +.B Mod4\-j +Focus next window. +.TP +.B Mod4\-k +Focus previous window. +.TP +.B Mod4\-i +Increase number of windows in master area. +.TP +.B Mod4\-d +Decrease number of windows in master area. +.TP +.B Mod4\-l +Increase master area size. +.TP +.B Mod4\-h +Decrease master area size. +.TP +.B Mod4\-Return +Zooms/cycles focused window to/from master area (tiled layouts only). +.TP +.B Mod4\-Shift\-c +Close focused window. +.TP +.B Mod4\-Shift\-space +Toggle focused window between tiled and floating state. +.TP +.B Mod4\-Tab +Toggles to the previously selected tags. +.TP +.B Mod4\-Shift\-[1..n] +Apply nth tag to focused window. +.TP +.B Mod4\-Shift\-0 +Apply all tags to focused window. +.TP +.B Mod4\-Control\-Shift\-[1..n] +Add/remove nth tag to/from focused window. +.TP +.B Mod4\-[1..n] +View all windows with nth tag. +.TP +.B Mod4\-0 +View all windows with any tag. +.TP +.B Mod4\-Control\-[1..n] +Add/remove all windows with nth tag to/from the view. +.TP +.B Mod4\-Shift\-q +Quit dwm. +.SS Mouse commands +.TP +.B Mod4\-Button1 +Move focused window while dragging. Tiled windows will be toggled to the floating state. +.TP +.B Mod4\-Button2 +Toggles focused window between floating and tiled state. +.TP +.B Mod4\-Button3 +Resize focused window while dragging. Tiled windows will be toggled to the floating state. +.SH CUSTOMIZATION +dwm is customized by creating a custom config.h and (re)compiling the source +code, or by setting X resources. +.P +The following X resource settings can be set: +.TP +.BI dwm.font +defines the font or font set used. +.TP +.BI dwm.background +defines the normal background color. +.IR #RGB , +.IR #RRGGBB , +and X color names are supported. +.TP +.BI dwm.border +defines the normal border color +.TP +.BI dwm.selbackground +defines the selected background color +.TP +.BI dwm.selforeground +defines the selected foreground color +.TP +.BI dwm.selborder +defines the selected border color +.TP +.BI dwm.tabactivebackground +defines the background color for active tabs +.TP +.BI dwm.tabactiveforeground +defines the foreground color for active tabs +.TP +.BI dwm.tabactiveborder +defines the border color for active tabs +.TP +.BI dwm.tabinactivebackground +defines the background color for inactive tabs +.TP +.BI dwm.tabinactiveforeground +defines the foreground color for inactive tabs +.TP +.BI dwm.tabinactiveborder +defines the border color for inactive tabs +.SH SEE ALSO +.BR dmenu (1), +.BR st (1) +.SH ISSUES +Java applications which use the XToolkit/XAWT backend may draw grey windows +only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early +JDK 1.6 versions, because it assumes a reparenting window manager. Possible workarounds +are using JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or setting the +environment variable +.BR AWT_TOOLKIT=MToolkit +(to use the older Motif backend instead) or running +.B xprop -root -f _NET_WM_NAME 32a -set _NET_WM_NAME LG3D +or +.B wmname LG3D +(to pretend that a non-reparenting window manager is running that the +XToolkit/XAWT backend can recognize) or when using OpenJDK setting the environment variable +.BR _JAVA_AWT_WM_NONREPARENTING=1 . +.SH BUGS +Send all bug reports with a patch to hackers@suckless.org. diff --git a/src/sxmo-dwm/dwm.c b/src/sxmo-dwm/dwm.c new file mode 100644 index 0000000..eac2eb0 --- /dev/null +++ b/src/sxmo-dwm/dwm.c @@ -0,0 +1,3259 @@ +/* See LICENSE file for copyright and license details. + * + * dynamic window manager is designed like any other X client as well. It is + * driven through handling X events. In contrast to other X clients, a window + * manager selects for SubstructureRedirectMask on the root window, to receive + * events about window (dis-)appearance. Only one X connection at a time is + * allowed to select for this event mask. + * + * The event handlers of dwm are organized in an array which is accessed + * whenever a new event has been fetched. This allows event dispatching + * in O(1) time. + * + * Each child of the root window is called a client, except windows which have + * set the override_redirect flag. Clients are organized in a linked client + * list on each monitor, the focus history is remembered through a stack list + * on each monitor. Each client contains a bit array to indicate the tags of a + * client. + * + * Keys and tagging rules are organized as arrays and defined in config.h. + * + * To understand everything else, start reading main(). + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef XINERAMA +#include +#endif /* XINERAMA */ +#include +#include +#include +#include +#include + +#include "drw.h" +#include "util.h" + +/* macros */ +#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) +#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) +#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ + * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) +#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) +#define LENGTH(X) (sizeof X / sizeof X[0]) +#define MOUSEMASK (BUTTONMASK|PointerMotionMask) +#define WIDTH(X) ((X)->w + 2 * (X)->bw) +#define HEIGHT(X) ((X)->h + 2 * (X)->bw) +#define TAGMASK ((1 << LENGTH(tags)) - 1) +#define TEXTW(X) (drw_font_getwidth(drw, (X), False) + lrpad) +#define TEXTWM(X) (drw_font_getwidth(drw, (X), True) + lrpad) + +/* enums */ +enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ +enum { SchemeNorm, SchemeSel, SchemeTabActive, SchemeTabInactive }; /* color schemes */ +enum { NetSupported, NetWMName, NetWMState, NetWMCheck, + NetWMFullscreen, NetActiveWindow, NetWMWindowType, + NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ +enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ +enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, + ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ + +typedef union { + int i; + unsigned int ui; + float f; + const void *v; +} Arg; + +typedef struct { + unsigned int click; + unsigned int mask; + unsigned int button; + void (*func)(const Arg *arg); + const Arg arg; +} Button; + +typedef struct Monitor Monitor; +typedef struct Client Client; +struct Client { + char name[256]; + float mina, maxa; + int x, y, w, h; + int oldx, oldy, oldw, oldh; + int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int bw, oldbw; + unsigned int tags; + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow, iskbd; + pid_t pid; + Client *next; + Client *snext; + Client *swallowing; + Monitor *mon; + Window win; +}; + +typedef struct { + int type; + unsigned int mod; + KeySym keysym; + void (*func)(const Arg *); + const Arg arg; +} Key; + +typedef struct { + const char *symbol; + void (*arrange)(Monitor *); +} Layout; + +typedef struct HoldKey { + KeySym keysym; + struct HoldKey *next; +}; + +struct Monitor { + char ltsymbol[16]; + float mfact; + int nmaster; + int num; + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; + int showbar; + int topbar; + Client *clients; + Client *sel; + Client *stack; + Monitor *next; + Window barwin; + const Layout *lt[2]; +}; + +typedef struct { + const char *class; + const char *instance; + const char *title; + unsigned int tags; + int isfloating; + int isterminal; + int noswallow; + int monitor; + int iskbd; +} Rule; + +/* function declarations */ +static void applyrules(Client *c); +static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); +static void arrange(Monitor *m); +static void arrangemon(Monitor *m); +static void attach(Client *c); +static void attachBelow(Client *c); +static void attachstack(Client *c); +static void buttonpress(XEvent *e); +static void checkotherwm(void); +static void cleanup(void); +static void cleanupmon(Monitor *mon); +static void clientmessage(XEvent *e); +static void configure(Client *c); +static void configurenotify(XEvent *e); +static void configurerequest(XEvent *e); +static Monitor *createmon(void); +static void cyclelayout(const Arg *arg); +static void deck(Monitor *m); +static void deckdouble(Monitor *m); +static void destroynotify(XEvent *e); +static void detach(Client *c); +static void detachstack(Client *c); +static Monitor *dirtomon(int dir); +static void drawbar(Monitor *m); +static void drawbars(void); +static void enternotify(XEvent *e); +static void expose(XEvent *e); +static void focus(Client *c); +static void focusin(XEvent *e); +static void focusmon(const Arg *arg); +static void focusstack(const Arg *arg); +static int getrootptr(int *x, int *y); +static long getstate(Window w); +static int gettextprop(Window w, Atom atom, char *text, unsigned int size); +static void grabbuttons(Client *c, int focused); +static void grabkeys(void); +static void incnmaster(const Arg *arg); +static void inplacerotate(const Arg *arg); +static void keypress(XEvent *e); +static void keyrelease(XEvent *e); +static void killclient(const Arg *arg); +static void manage(Window w, XWindowAttributes *wa); +static void mappingnotify(XEvent *e); +static void maprequest(XEvent *e); +static void monocle(Monitor *m); +static void motionnotify(XEvent *e); +static void movemouse(const Arg *arg); +static Client *nexttiled(Client *c); +static void pop(Client *); +static void propertynotify(XEvent *e); +static void quit(const Arg *arg); +static Monitor *recttomon(int x, int y, int w, int h); +static void resize(Client *c, int x, int y, int w, int h, int interact); +static void resizeclient(Client *c, int x, int y, int w, int h); +static void resizemouse(const Arg *arg); +static void restack(Monitor *m); +static void run(void); +static void scan(void); +static int sendevent(Client *c, Atom proto); +static void sendmon(Client *c, Monitor *m); +static void setclientstate(Client *c, long state); +static void setfocus(Client *c); +static void setfullscreen(Client *c, int fullscreen); +static void setlayout(const Arg *arg); +static void setmfact(const Arg *arg); +static void setup(void); +static void seturgent(Client *c, int urg); +static void showhide(Client *c); +static void sigchld(int unused); +static void spawn(const Arg *arg); +static void switchcol(const Arg *arg); +static void tag(const Arg *arg); +static void tagmon(const Arg *arg); +static void tile(Monitor *); +static void togglebar(const Arg *arg); +static void togglefloating(const Arg *arg); +static void toggletag(const Arg *arg); +static void toggleview(const Arg *arg); +static void transfer(const Arg *arg); +static void transferall(const Arg *arg); +static void unfloatvisible(const Arg *arg); +static void unfocus(Client *c, int setfocus); +static void unmanage(Client *c, int destroyed); +static void unmapnotify(XEvent *e); +static void updatebarpos(Monitor *m); +static void updatebars(void); +static void updateclientlist(void); +static int updategeom(void); +static void updatenumlockmask(void); +static void updatesizehints(Client *c); +static void updatestatus(void); +static void updatetitle(Client *c); +static void updatewindowtype(Client *c); +static void updatewmhints(Client *c); +static void view(const Arg *arg); +static Client *wintoclient(Window w); +static Monitor *wintomon(Window w); +static int xerror(Display *dpy, XErrorEvent *ee); +static int xerrordummy(Display *dpy, XErrorEvent *ee); +static int xerrorstart(Display *dpy, XErrorEvent *ee); +static void zoom(const Arg *arg); +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); +static void clienttagpush(const Arg *arg); +static void shiftview(const Arg *arg); +static void pushup(const Arg *arg); +static void pushdown(const Arg *arg); +static void readxresources(); + +static pid_t getparentprocess(pid_t p); +static int isdescprocess(pid_t p, pid_t c); +static Client *swallowingclient(Window w); +static Client *termforwin(const Client *c); +static pid_t winpid(Window w); + + +/* variables */ +static const char broken[] = "broken"; +static char stext[512]; +static int screen; +static int sw, sh; /* X display screen geometry width, height */ +static int bh, blw = 0; /* bar geometry */ +static int lrpad; /* sum of left and right padding for text */ +static int (*xerrorxlib)(Display *, XErrorEvent *); +static unsigned int numlockmask = 0; +static void (*handler[LASTEvent]) (XEvent *) = { + [ButtonPress] = buttonpress, + [ClientMessage] = clientmessage, + [ConfigureRequest] = configurerequest, + [ConfigureNotify] = configurenotify, + [DestroyNotify] = destroynotify, + //[EnterNotify] = enternotify, + [Expose] = expose, + [FocusIn] = focusin, + [KeyPress] = keypress, + [KeyRelease] = keyrelease, + [MappingNotify] = mappingnotify, + [MapRequest] = maprequest, + //[MotionNotify] = motionnotify, + [PropertyNotify] = propertynotify, + [UnmapNotify] = unmapnotify +}; +static Atom wmatom[WMLast], netatom[NetLast]; +static int running = 1; +static Cur *cursor[CurLast]; +static Clr **scheme; +static Display *dpy; +static Drw *drw; +static Monitor *mons, *selmon; +static Window root, wmcheckwin; + +/* Empty arrays to be filled from command line, Xresources, and defaults, in decreasing order of precedence */ +static char *colors[4][3]; /* 4 schemes, 3 colors each */ + +static xcb_connection_t *xcon; + +static struct HoldKey *holdkeyroot = NULL; + +/* configuration, allows nested code to access above variables */ +#include "config.h" + +/* compile-time check if all tags fit into an unsigned int bit array. */ +struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; + +/* function implementations */ +void +applyrules(Client *c) +{ + const char *class, *instance; + unsigned int i; + const Rule *r; + Monitor *m; + XClassHint ch = { NULL, NULL }; + + /* rule matching */ + c->isfloating = 0; + c->tags = 0; + XGetClassHint(dpy, c->win, &ch); + class = ch.res_class ? ch.res_class : broken; + instance = ch.res_name ? ch.res_name : broken; + + for (i = 0; i < LENGTH(rules); i++) { + r = &rules[i]; + if ((!r->title || strstr(c->name, r->title)) + && (!r->class || strstr(class, r->class)) + && (!r->instance || strstr(instance, r->instance))) + { + c->isterminal = r->isterminal; + c->isfloating = r->isfloating; + c->iskbd = r->iskbd; + c->tags |= r->tags; + for (m = mons; m && m->num != r->monitor; m = m->next); + if (m) + c->mon = m; + } + } + if (ch.res_class) + XFree(ch.res_class); + if (ch.res_name) + XFree(ch.res_name); + c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags]; +} + +int +applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) +{ + int baseismin; + Monitor *m = c->mon; + + /* set minimum possible */ + *w = MAX(1, *w); + *h = MAX(1, *h); + if (interact) { + if (*x > sw) + *x = sw - WIDTH(c); + if (*y > sh) + *y = sh - HEIGHT(c); + if (*x + *w + 2 * c->bw < 0) + *x = 0; + if (*y + *h + 2 * c->bw < 0) + *y = 0; + } else { + if (*x >= m->wx + m->ww) + *x = m->wx + m->ww - WIDTH(c); + if (*y >= m->wy + m->wh) + *y = m->wy + m->wh - HEIGHT(c); + if (*x + *w + 2 * c->bw <= m->wx) + *x = m->wx; + if (*y + *h + 2 * c->bw <= m->wy) + *y = m->wy; + } + if (*h < bh) + *h = bh; + if (*w < bh) + *w = bh; + if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { + /* see last two sentences in ICCCM 4.1.2.3 */ + baseismin = c->basew == c->minw && c->baseh == c->minh; + if (!baseismin) { /* temporarily remove base dimensions */ + *w -= c->basew; + *h -= c->baseh; + } + /* adjust for aspect limits */ + if (c->mina > 0 && c->maxa > 0) { + if (c->maxa < (float)*w / *h) + *w = *h * c->maxa + 0.5; + else if (c->mina < (float)*h / *w) + *h = *w * c->mina + 0.5; + } + if (baseismin) { /* increment calculation requires this */ + *w -= c->basew; + *h -= c->baseh; + } + /* adjust for increment value */ + if (c->incw) + *w -= *w % c->incw; + if (c->inch) + *h -= *h % c->inch; + /* restore base dimensions */ + *w = MAX(*w + c->basew, c->minw); + *h = MAX(*h + c->baseh, c->minh); + if (c->maxw) + *w = MIN(*w, c->maxw); + if (c->maxh) + *h = MIN(*h, c->maxh); + } + return *x != c->x || *y != c->y || *w != c->w || *h != c->h; +} + +void +bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive) { + if (!c) return; + int i, nclienttags = 0, nviewtags = 0; + + drw_setscheme(drw, scheme[ + m->sel == c ? SchemeSel : (groupactive ? SchemeTabActive: SchemeTabInactive) + ]); + drw_text(drw, x, 0, w, bh, lrpad / 2, c->name, 0, False); // pjh just a guess False + + // Floating win indicator + if (c->isfloating) drw_rect(drw, x + 2, 2, 5, 5, 0, 0); + + // Optional borders between tabs + if (BARTAB_BORDERS) { + XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBorder].pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, 0, 1, bh); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w, 0, 1, bh); + } + + // Optional tags icons + for (i = 0; i < LENGTH(tags); i++) { + if ((m->tagset[m->seltags] >> i) & 1) { nviewtags++; } + if ((c->tags >> i) & 1) { nclienttags++; } + } + if (BARTAB_TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1) { + for (i = 0; i < LENGTH(tags); i++) { + drw_rect(drw, + ( x + w - 2 - ((LENGTH(tags) / BARTAB_TAGSROWS) * BARTAB_TAGSPX) + - (i % (LENGTH(tags)/BARTAB_TAGSROWS)) + ((i % (LENGTH(tags) / BARTAB_TAGSROWS)) * BARTAB_TAGSPX) + ), + ( 2 + ((i / (LENGTH(tags)/BARTAB_TAGSROWS)) * BARTAB_TAGSPX) + - ((i / (LENGTH(tags)/BARTAB_TAGSROWS))) + ), + BARTAB_TAGSPX, BARTAB_TAGSPX, (c->tags >> i) & 1, 0 + ); + } + } +} + +void +battabclick(Monitor *m, Client *c, int passx, int x, int w, int unused) { + if (passx >= x && passx <= x + w) { + focus(c); + restack(selmon); + } +} + +void +bartabcalculate( + Monitor *m, int offx, int sw, int passx, + void(*tabfn)(Monitor *, Client *, int, int, int, int) +) { + Client *c; + int + i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0, + masteractive = 0, fulllayout = 0, floatlayout = 0, + x, w, tgactive; + + for (i = 0, c = m->clients; c; c = c->next) { + if (!ISVISIBLE(c)) continue; + if (c->isfloating) { clientsnfloating++; continue; } + if (m->sel == c) { masteractive = i < m->nmaster; } + if (i < m->nmaster) { clientsnmaster++; } else { clientsnstack++; } + i++; + } + for (i = 0; i < LENGTH(bartabfloatfns); i++) if (m ->lt[m->sellt]->arrange == bartabfloatfns[i]) { floatlayout = 1; break; } + for (i = 0; i < LENGTH(bartabmonfns); i++) if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) { fulllayout = 1; break; } + for (c = m->clients, i = 0; c; c = c->next) { + if (!ISVISIBLE(c)) continue; + if (clientsnmaster + clientsnstack == 0 || floatlayout) { + x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating)) * i); + w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating); + tgactive = 1; + } else if (!c->isfloating && (fulllayout || ((clientsnmaster == 0) ^ (clientsnstack == 0)))) { + x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack)) * i); + w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack); + tgactive = 1; + } else if (i < m->nmaster && !c->isfloating) { + x = offx + ((((m->mw * m->mfact) - offx) /clientsnmaster) * i); + w = ((m->mw * m->mfact) - offx) / clientsnmaster; + tgactive = masteractive; + } else if (!c->isfloating) { + x = (m->mw * m->mfact) + ((((m->mw * (1 - m->mfact)) - sw) / clientsnstack) * (i - m->nmaster)); + w = ((m->mw * (1 - m->mfact)) - sw) / clientsnstack; + tgactive = !masteractive; + } else continue; + tabfn(m, c, passx, x, w, tgactive); + i++; + } +} + +void +arrange(Monitor *m) +{ + if (m) + showhide(m->stack); + else for (m = mons; m; m = m->next) + showhide(m->stack); + if (m) { + arrangemon(m); + restack(m); + } else for (m = mons; m; m = m->next) + arrangemon(m); +} + +void +arrangemon(Monitor *m) +{ + strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol); + if (m->lt[m->sellt]->arrange) + m->lt[m->sellt]->arrange(m); +} + +void +attach(Client *c) +{ + c->next = c->mon->clients; + c->mon->clients = c; +} +void +attachBelow(Client *c) +{ + //If there is nothing on the monitor or the selected client is floating, attach as normal + if(c->mon->sel == NULL || c->mon->sel->isfloating) { + attach(c); + return; + } + + //Set the new client's next property to the same as the currently selected clients next + c->next = c->mon->sel->next; + //Set the currently selected clients next property to the new client + c->mon->sel->next = c; + +} + +void +attachstack(Client *c) +{ + c->snext = c->mon->stack; + c->mon->stack = c; +} + +void +swallow(Client *p, Client *c) +{ + if (c->noswallow || c->isterminal) + return; + + detach(c); + detachstack(c); + + setclientstate(c, WithdrawnState); + XUnmapWindow(dpy, p->win); + + p->swallowing = c; + c->mon = p->mon; + + Window w = p->win; + p->win = c->win; + c->win = w; + updatetitle(p); + arrange(p->mon); + XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h); + configure(p); + updateclientlist(); +} + +void +unswallow(Client *c) +{ + c->win = c->swallowing->win; + + free(c->swallowing); + c->swallowing = NULL; + + updatetitle(c); + arrange(c->mon); + XMapWindow(dpy, c->win); + XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); + configure(c); + setclientstate(c, NormalState); +} + +void +buttonpress(XEvent *e) +{ + unsigned int i, x, click; + Arg arg = {0}; + Client *c; + Monitor *m; + XButtonPressedEvent *ev = &e->xbutton; + + click = ClkRootWin; + /* focus monitor if necessary */ + if (!((c = wintoclient(ev->window)) && c->iskbd) + && (m = wintomon(ev->window)) && m != selmon) { + unfocus(selmon->sel, 1); + selmon = m; + focus(NULL); + } + if (ev->window == selmon->barwin) { + i = x = 0; + unsigned int occ = 0; + for (c = m->clients; c; c=c->next) + occ |= c->tags; + do { + /* Do not reserve space for vacant tags */ + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; + x += TEXTW(tags[i]); + } while (ev->x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + click = ClkTagBar; + arg.ui = 1 << i; + } else if (ev->x < x + blw) + click = ClkLtSymbol; + else if (ev->x > selmon->ww - TEXTWM(stext)) + click = ClkStatusText; + else // Focus clicked tab bar item + bartabcalculate(selmon, x, TEXTW(stext) - lrpad + 2, ev->x, battabclick); + } else if ((c = wintoclient(ev->window))) { + if (!c->iskbd) { + focus(c); + restack(selmon); + } + XAllowEvents(dpy, ReplayPointer, CurrentTime); + click = ClkClientWin; + } + for (i = 0; i < LENGTH(buttons); i++) + if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button + && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) + buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); +} + +void +checkotherwm(void) +{ + xerrorxlib = XSetErrorHandler(xerrorstart); + /* this causes an error if some other window manager is running */ + XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); + XSync(dpy, False); + XSetErrorHandler(xerror); + XSync(dpy, False); +} + +void +cleanup(void) +{ + Arg a = {.ui = ~0}; + Layout foo = { "", NULL }; + Monitor *m; + size_t i; + + view(&a); + selmon->lt[selmon->sellt] = &foo; + for (m = mons; m; m = m->next) + while (m->stack) + unmanage(m->stack, 0); + XUngrabKey(dpy, AnyKey, AnyModifier, root); + while (mons) + cleanupmon(mons); + for (i = 0; i < CurLast; i++) + drw_cur_free(drw, cursor[i]); + for (i = 0; i < LENGTH(colors); i++) + free(scheme[i]); + XDestroyWindow(dpy, wmcheckwin); + drw_free(drw); + XSync(dpy, False); + XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); +} + +void +deck(Monitor *m) { + unsigned int i, n, h, mw, my; + Client *c; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + if(n > m->nmaster) { + mw = m->nmaster ? m->ww * m->mfact : 0; + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster); + } + else + mw = m->ww; + for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if(i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i); + resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False); + my += HEIGHT(c); + } + else + resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False); +} + +void +deckdouble(Monitor *m) { + unsigned int i, n, h, mw, ns; + Client *c; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + if(n > m->nmaster) { + mw = m->nmaster ? m->ww * m->mfact : 0; + ns = m->nmaster > 0 ? 2 : 1; + } else { + mw = m->ww; + ns = 1; + } + for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if(i < m->nmaster) + resize(c, m->wx, m->wy, mw - (2*c->bw), m->wh - (2*c->bw), False); + else + resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False); +} + +void +cleanupmon(Monitor *mon) +{ + Monitor *m; + + if (mon == mons) + mons = mons->next; + else { + for (m = mons; m && m->next != mon; m = m->next); + m->next = mon->next; + } + XUnmapWindow(dpy, mon->barwin); + XDestroyWindow(dpy, mon->barwin); + free(mon); +} + +void +clientmessage(XEvent *e) +{ + XClientMessageEvent *cme = &e->xclient; + Client *c = wintoclient(cme->window); + + if (!c) + return; + if (cme->message_type == netatom[NetWMState]) { + if (cme->data.l[1] == netatom[NetWMFullscreen] + || cme->data.l[2] == netatom[NetWMFullscreen]) + setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ + || cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */)); + } else if (cme->message_type == netatom[NetActiveWindow]) { + if (c != selmon->sel && !c->isurgent) + seturgent(c, 1); + } +} + +void +configure(Client *c) +{ + XConfigureEvent ce; + + ce.type = ConfigureNotify; + ce.display = dpy; + ce.event = c->win; + ce.window = c->win; + ce.x = c->x; + ce.y = c->y; + ce.width = c->w; + ce.height = c->h; + ce.border_width = c->bw; + ce.above = None; + ce.override_redirect = False; + XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); +} + +void +configurenotify(XEvent *e) +{ + Monitor *m; + XConfigureEvent *ev = &e->xconfigure; + int dirty; + + /* TODO: updategeom handling sucks, needs to be simplified */ + if (ev->window == root) { + dirty = (sw != ev->width || sh != ev->height); + sw = ev->width; + sh = ev->height; + if (updategeom() || dirty) { + drw_resize(drw, sw, bh); + updatebars(); + for (m = mons; m; m = m->next) { + XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); + } + focus(NULL); + arrange(NULL); + } + } +} + +void +configurerequest(XEvent *e) +{ + Client *c; + Monitor *m; + XConfigureRequestEvent *ev = &e->xconfigurerequest; + XWindowChanges wc; + + if ((c = wintoclient(ev->window))) { + if (ev->value_mask & CWBorderWidth) + c->bw = ev->border_width; + else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) { + m = c->mon; + if (ev->value_mask & CWX) { + c->oldx = c->x; + c->x = m->mx + ev->x; + } + if (ev->value_mask & CWY) { + c->oldy = c->y; + c->y = m->my + ev->y; + } + if (ev->value_mask & CWWidth) { + c->oldw = c->w; + c->w = ev->width; + } + if (ev->value_mask & CWHeight) { + c->oldh = c->h; + c->h = ev->height; + } + if ((c->x + c->w) > m->mx + m->mw && c->isfloating) + c->x = m->mx + (m->mw / 2 - WIDTH(c) / 2); /* center in x direction */ + if ((c->y + c->h) > m->my + m->mh && c->isfloating) + c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */ + if ((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight))) + configure(c); + if (ISVISIBLE(c)) + XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); + } else + configure(c); + } else { + wc.x = ev->x; + wc.y = ev->y; + wc.width = ev->width; + wc.height = ev->height; + wc.border_width = ev->border_width; + wc.sibling = ev->above; + wc.stack_mode = ev->detail; + XConfigureWindow(dpy, ev->window, ev->value_mask, &wc); + } + XSync(dpy, False); +} + +Monitor * +createmon(void) +{ + Monitor *m; + + m = ecalloc(1, sizeof(Monitor)); + m->tagset[0] = m->tagset[1] = 1; + m->mfact = mfact; + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + return m; +} + +void +cyclelayout(const Arg *arg) { + int i; + Arg a; + + for(i = 0; i < LENGTH(ppcyclelayouts) && &ppcyclelayouts[i] != selmon->lt[selmon->sellt]; i++); + if(arg->i > 0) { + a.v = &ppcyclelayouts[i + 1 < LENGTH(ppcyclelayouts) ? i + 1 : 0]; + setlayout(&a); + } +} + +void +destroynotify(XEvent *e) +{ + Client *c; + XDestroyWindowEvent *ev = &e->xdestroywindow; + + if ((c = wintoclient(ev->window))) + unmanage(c, 1); + + else if ((c = swallowingclient(ev->window))) + unmanage(c->swallowing, 1); + + else + focus(NULL); +} + +void +detach(Client *c) +{ + Client **tc; + + for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next); + *tc = c->next; +} + +void +detachstack(Client *c) +{ + Client **tc, *t; + + for (tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext); + *tc = c->snext; + + if (c == c->mon->sel) { + for (t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext); + c->mon->sel = t; + } +} + +Monitor * +dirtomon(int dir) +{ + Monitor *m = NULL; + + if (dir > 0) { + if (!(m = selmon->next)) + m = mons; + } else if (selmon == mons) + for (m = mons; m->next; m = m->next); + else + for (m = mons; m->next != selmon; m = m->next); + return m; +} + +void +drawbar(Monitor *m) +{ + int x, w, sw = 0; + unsigned int i, occ = 0, urg = 0; + Client *c; + + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, 0, 0, m->ww, bh, 1, 1); + + for (c = m->clients; c; c = c->next) { + if (!c->iskbd) { + occ |= c->tags; + if (c->isurgent) + urg |= c->tags; + } + } + x = 0; + for (i = 0; i < LENGTH(tags); i++) { + /* Do not draw vacant tags */ + if (!(occ & 1 << i || m ->tagset[m->seltags] & 1 << i)) + continue; + w = TEXTW(tags[i]); + drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i, False); + + x += w; + } + w = blw = TEXTW(m->ltsymbol); + drw_setscheme(drw, scheme[SchemeNorm]); + x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0, False); + + if (m == selmon) { /* status is drawn on selected monitor */ + const char *s = stext; + drw_setscheme(drw, scheme[SchemeNorm]); + while (*s == ' ') + s++; + sw = TEXTWM(s) - lrpad; + while (*s && sw > m->ww - x) { + const char *next = strchr(s, ' '); + if (!next) + break; + while (*next == ' ') + next++; + if (!*next) + break; + s = next; + sw = TEXTWM(s) - lrpad; + } + drw_text(drw, MAX(x, m->ww - sw), 0, sw, bh, 0, s, 0, True); + } + drw_map(drw, m->barwin, 0, 0, m->ww, bh); +} + +void +drawbars(void) +{ + Monitor *m; + + for (m = mons; m; m = m->next) + drawbar(m); +} + +void +enternotify(XEvent *e) +{ + Client *c; + Monitor *m; + XCrossingEvent *ev = &e->xcrossing; + + if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) + return; + c = wintoclient(ev->window); + m = c ? c->mon : wintomon(ev->window); + if (m != selmon) { + unfocus(selmon->sel, 1); + selmon = m; + } else if (!c || c == selmon->sel) + return; + focus(c); +} + +void +expose(XEvent *e) +{ + Monitor *m; + XExposeEvent *ev = &e->xexpose; + + if (ev->count == 0 && (m = wintomon(ev->window))) + drawbar(m); +} + +static void +write_sysfs_str(const char *path, const char *val) +{ + int fd = open(path, O_WRONLY | O_CLOEXEC); + if (fd >= 0) { + (void)write(fd, val, strlen(val)); + close(fd); + } +} + +static void +read_sysfs_str(const char *path, char *buf, size_t len) +{ + int fd = open(path, O_RDONLY | O_CLOEXEC); + ssize_t n; + if (fd >= 0) { + n = read(fd, buf, len - 1); + close(fd); + if (n > 0) { + while (n > 0 && (buf[n - 1] == '\n' || buf[n - 1] == '\r')) + n--; + buf[n] = '\0'; + return; + } + } + buf[0] = '\0'; +} + +static void +set_hw_backlight(int on) +{ + static char saved_brightness[16] = "14"; + char cur[16] = ""; + + if (on) { + read_sysfs_str("/tmp/sxmo_saved_brightness", cur, sizeof(cur)); + if (atoi(cur) > 1) + snprintf(saved_brightness, sizeof(saved_brightness), "%s", cur); + else if (atoi(saved_brightness) <= 1) { + read_sysfs_str("/sys/class/backlight/backlight/max_brightness", cur, sizeof(cur)); + snprintf(saved_brightness, sizeof(saved_brightness), "%s", (atoi(cur) > 1) ? cur : "14"); + } + write_sysfs_str("/sys/class/backlight/backlight/bl_power", "0"); + write_sysfs_str("/sys/class/backlight/backlight/brightness", saved_brightness); + write_sysfs_str("/sys/class/leds/white:kbd_backlight/brightness", "255"); + } else { + read_sysfs_str("/sys/class/backlight/backlight/brightness", cur, sizeof(cur)); + if (atoi(cur) > 1) { + snprintf(saved_brightness, sizeof(saved_brightness), "%s", cur); + int fd = open("/tmp/sxmo_saved_brightness", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); + if (fd >= 0) { + (void)write(fd, saved_brightness, strlen(saved_brightness)); + close(fd); + } + } + write_sysfs_str("/sys/class/leds/white:kbd_backlight/brightness", "0"); + write_sysfs_str("/sys/class/backlight/backlight/brightness", "0"); + } +} + +static int +is_phone_locked(void) +{ + const char *rdir = getenv("XDG_RUNTIME_DIR"); + char path[256], buf[32]; + int fd; + ssize_t n; + + snprintf(path, sizeof(path), "%s/sxmo.state", (rdir && rdir[0]) ? rdir : "/run/user/10000"); + fd = open(path, O_RDONLY | O_CLOEXEC); + if (fd < 0) + return 0; + n = read(fd, buf, sizeof(buf) - 1); + close(fd); + if (n <= 0) + return 0; + buf[n] = '\0'; + return (!strncmp(buf, "screenoff", 9) || !strncmp(buf, "lock", 4)); +} + +static void +writefocusedwin(Client *c) +{ + const char *rdir = getenv("XDG_RUNTIME_DIR"); + char path[256], cls[256] = "", ttl[256] = ""; + XClassHint ch = { NULL, NULL }; + FILE *fp; + size_t i; + + snprintf(path, sizeof(path), "%s/sxmo.focusedwin", (rdir && rdir[0]) ? rdir : "/run/user/10000"); + if (c) { + if (XGetClassHint(dpy, c->win, &ch)) { + if (ch.res_class) { + snprintf(cls, sizeof(cls), "%s", ch.res_class); + XFree(ch.res_class); + } + if (ch.res_name) + XFree(ch.res_name); + } + snprintf(ttl, sizeof(ttl), "%s", c->name); + for (i = 0; cls[i]; i++) + cls[i] = (char)tolower((unsigned char)cls[i]); + for (i = 0; ttl[i]; i++) + ttl[i] = (char)tolower((unsigned char)ttl[i]); + } + if ((fp = fopen(path, "w"))) { + fprintf(fp, "%s\n%s\n", cls, ttl); + fclose(fp); + } +} + +static int lidfd = -1; + +void +focus(Client *c) +{ + if (!c || !ISVISIBLE(c)) + for (c = selmon->stack; c && (!ISVISIBLE(c) || c->iskbd) ; c = c->snext); + if (selmon->sel && selmon->sel != c) + unfocus(selmon->sel, 0); + if (c) { + if (c->mon != selmon) + selmon = c->mon; + if (c->isurgent) + seturgent(c, 0); + detachstack(c); + attachstack(c); + grabbuttons(c, 1); + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); + setfocus(c); + } else { + XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); + } + selmon->sel = c; + writefocusedwin(c); + drawbars(); +} + +/* there are some broken focus acquiring clients needing extra handling */ +void +focusin(XEvent *e) +{ + XFocusChangeEvent *ev = &e->xfocus; + + if (selmon->sel && ev->window != selmon->sel->win) + setfocus(selmon->sel); +} + +void +focusmon(const Arg *arg) +{ + Monitor *m; + + if (!mons->next) + return; + if ((m = dirtomon(arg->i)) == selmon) + return; + unfocus(selmon->sel, 0); + selmon = m; + focus(NULL); +} + +void +focusstack(const Arg *arg) +{ + Client *c = NULL, *i; + + if (!selmon->sel) + return; + if (arg->i > 0) { + for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->iskbd); c = c->next); + if (!c) + for (c = selmon->clients; c && (!ISVISIBLE(c) || c->iskbd); c = c->next); + } else { + for (i = selmon->clients; i != selmon->sel; i = i->next) + if (ISVISIBLE(i) && !i->iskbd) + c = i; + if (!c) + for (; i; i = i->next) + if (ISVISIBLE(i) && !i->iskbd) + c = i; + } + if (c) { + focus(c); + restack(selmon); + } +} + +Atom +getatomprop(Client *c, Atom prop) +{ + int di; + unsigned long dl; + unsigned char *p = NULL; + Atom da, atom = None; + + if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM, + &da, &di, &dl, &dl, &p) == Success && p) { + atom = *(Atom *)p; + XFree(p); + } + return atom; +} + +int +getrootptr(int *x, int *y) +{ + int di; + unsigned int dui; + Window dummy; + + return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui); +} + +long +getstate(Window w) +{ + int format; + long result = -1; + unsigned char *p = NULL; + unsigned long n, extra; + Atom real; + + if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState], + &real, &format, &n, &extra, (unsigned char **)&p) != Success) + return -1; + if (n != 0) + result = *p; + XFree(p); + return result; +} + +int +gettextprop(Window w, Atom atom, char *text, unsigned int size) +{ + char **list = NULL; + int n; + XTextProperty name; + + if (!text || size == 0) + return 0; + text[0] = '\0'; + if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems) + return 0; + if (name.encoding == XA_STRING) + strncpy(text, (char *)name.value, size - 1); + else { + if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { + strncpy(text, *list, size - 1); + XFreeStringList(list); + } + } + text[size - 1] = '\0'; + XFree(name.value); + return 1; +} + +void +grabbuttons(Client *c, int focused) +{ + updatenumlockmask(); + { + unsigned int i, j; + unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; + XUngrabButton(dpy, AnyButton, AnyModifier, c->win); + if (!focused) + XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, + BUTTONMASK, GrabModeSync, GrabModeSync, None, None); + for (i = 0; i < LENGTH(buttons); i++) + if (buttons[i].click == ClkClientWin) + for (j = 0; j < LENGTH(modifiers); j++) + XGrabButton(dpy, buttons[i].button, + buttons[i].mask | modifiers[j], + c->win, False, BUTTONMASK, + GrabModeAsync, GrabModeSync, None, None); + } +} + +void +grabkeys(void) +{ + updatenumlockmask(); + { + unsigned int i, j, k; + unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; + int start, end, skip; + KeySym *syms; + + XUngrabKey(dpy, AnyKey, AnyModifier, root); + XDisplayKeycodes(dpy, &start, &end); + syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip); + if (!syms) + return; + for (k = start; k <= end; k++) + for (i = 0; i < LENGTH(keys); i++) + /* skip modifier codes, we do that ourselves */ + if (keys[i].keysym == syms[(k - start) * skip]) + for (j = 0; j < LENGTH(modifiers); j++) + XGrabKey(dpy, k, + keys[i].mod | modifiers[j], + root, True, + GrabModeAsync, GrabModeAsync); + XFree(syms); + } +} + +void +incnmaster(const Arg *arg) +{ + selmon->nmaster = MAX(selmon->nmaster + arg->i, 1); + arrange(selmon); +} + +#ifdef XINERAMA +static int +isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) +{ + while (n--) + if (unique[n].x_org == info->x_org && unique[n].y_org == info->y_org + && unique[n].width == info->width && unique[n].height == info->height) + return 0; + return 1; +} +#endif /* XINERAMA */ + +int +iswide() { + return sw > 1000 ? 1 : 0; +} + +void +markhold(KeySym keysym) +{ + struct HoldKey *new = malloc(sizeof(struct HoldKey)); + new->keysym = keysym; + new->next = NULL; + + if (holdkeyroot == NULL) { + holdkeyroot = new; + return; + } + + struct HoldKey *cur = holdkeyroot; + while (cur->next != NULL) + cur = cur->next; + + cur->next = new; +} + +void +markreleased(KeySym keysym) +{ + if (holdkeyroot == NULL) { + return; + } + + struct HoldKey *cur = holdkeyroot; + + if (cur->keysym == keysym) { + holdkeyroot = cur->next; + free(cur); + return; + } + + while (cur->next != NULL) { + if (cur->next->keysym == keysym) { + struct HoldKey *toremove = cur->next; + cur->next = toremove->next; + free(toremove); + return; + } + cur = cur->next; + } +} + +int +ishold(KeySym keysym) +{ + struct HoldKey *cur = holdkeyroot; + while (cur != NULL) { + if (cur->keysym == keysym) + return 1; + cur = cur->next; + }; + + return 0; +} + +void +keypress(XEvent *e) +{ + unsigned int i; + KeySym keysym; + XKeyEvent *ev; + + ev = &e->xkey; + keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); + + if ((keysym == XF86XK_PowerOff || keysym == XF86XK_PickupPhone || + keysym == XF86XK_Phone || keysym == XK_Menu || keysym == XF86XK_Back || + keysym == XK_Return || + keysym == XF86XK_KbdLcdMenu1 || keysym == XF86XK_KbdLcdMenu2) && + is_phone_locked()) { + const Arg unlockcmd = SHCMD("xset dpms 0 0 0; xset dpms force on; sxmo_state.sh set unlock"); + XUngrabKeyboard(dpy, CurrentTime); + XFlush(dpy); + set_hw_backlight(1); + spawn(&unlockcmd); + return; + } + + if (!selmon->sel && CLEANMASK(ev->state) == 0) { + if (keysym == XK_Return) { + const Arg entercmd = { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } }; + XUngrabKeyboard(dpy, CurrentTime); + XFlush(dpy); + spawn(&entercmd); + return; + } else if (keysym == XK_Left) { + const Arg prevtag = { .i = -1 }; + shiftview(&prevtag); + return; + } else if (keysym == XK_Right) { + const Arg nexttag = { .i = +1 }; + shiftview(&nexttag); + return; + } + } + + for (i = 0; i < LENGTH(keys); i++) { + if (keysym == keys[i].keysym + && KeyPress == keys[i].type + && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) + && keys[i].func) { + XUngrabKeyboard(dpy, CurrentTime); + XFlush(dpy); + keys[i].func(&(keys[i].arg)); + } + } +} + +void +keyrelease(XEvent *e) +{ + unsigned int i; + KeySym keysym; + XKeyEvent *ev; + + ev = &e->xkey; + keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); + + markreleased(keysym); + + for (i = 0; i < LENGTH(keys); i++) { + if (keysym == keys[i].keysym + && KeyRelease == keys[i].type + && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) + && keys[i].func) { + keys[i].func(&(keys[i].arg)); + } + } +} + +void +killclient(const Arg *arg) +{ + if (!selmon->sel) + return; + if (!sendevent(selmon->sel, wmatom[WMDelete])) { + XGrabServer(dpy); + XSetErrorHandler(xerrordummy); + XSetCloseDownMode(dpy, DestroyAll); + XKillClient(dpy, selmon->sel->win); + XSync(dpy, False); + XSetErrorHandler(xerror); + XUngrabServer(dpy); + } +} + +void +manage(Window w, XWindowAttributes *wa) +{ + Client *c, *t = NULL, *term = NULL; + Window trans = None; + XWindowChanges wc; + + c = ecalloc(1, sizeof(Client)); + c->win = w; + c->pid = winpid(w); + /* geometry */ + c->x = c->oldx = wa->x; + c->y = c->oldy = wa->y; + c->w = c->oldw = wa->width; + c->h = c->oldh = wa->height; + c->oldbw = wa->border_width; + + if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { + c->mon = t->mon; + c->tags = t->tags; + } else { + c->mon = selmon; + applyrules(c); + term = termforwin(c); + } + + if (c->iskbd) { + c->y = c->mon->my + c->mon->mh - c->h; + c->mon->mh = c->mon->mh - HEIGHT(c); + updatebarpos(selmon); + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); + arrange(selmon); + } else { + updatetitle(c); + if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) + c->x = c->mon->mx + c->mon->mw - WIDTH(c); + if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh) + c->y = c->mon->my + c->mon->mh - HEIGHT(c); + c->x = MAX(c->x, c->mon->mx); + /* only fix client y-offset, if the client center might cover the bar */ + c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) + && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); + } + c->bw = borderpx; + + wc.border_width = c->bw; + XConfigureWindow(dpy, w, CWBorderWidth, &wc); + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); + configure(c); /* propagates border_width, if size doesn't change */ + updatewindowtype(c); + updatesizehints(c); + updatewmhints(c); + XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); + grabbuttons(c, 0); + if (!c->isfloating) + c->isfloating = c->oldstate = t || c->isfixed; + if (c->isfloating) + XRaiseWindow(dpy, c->win); + if( attachbelow ) + attachBelow(c); + else + attach(c); + attachstack(c); + XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, + (unsigned char *) &(c->win), 1); + XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ + setclientstate(c, NormalState); + if (!c->iskbd) { + if (c->mon == selmon) + unfocus(selmon->sel, 0); + c->mon->sel = c; + } + arrange(c->mon); + XMapWindow(dpy, c->win); + if (term) + swallow(term, c); + focus(NULL); +} + +void +mappingnotify(XEvent *e) +{ + XMappingEvent *ev = &e->xmapping; + + XRefreshKeyboardMapping(ev); + if (ev->request == MappingKeyboard) + grabkeys(); +} + +void +maprequest(XEvent *e) +{ + static XWindowAttributes wa; + XMapRequestEvent *ev = &e->xmaprequest; + + if (!XGetWindowAttributes(dpy, ev->window, &wa)) + return; + if (wa.override_redirect) + return; + if (!wintoclient(ev->window)) + manage(ev->window, &wa); +} + +void +monocle(Monitor *m) +{ + unsigned int n = 0; + Client *c; + + for (c = m->clients; c; c = c->next) + if (ISVISIBLE(c) && !c->iskbd) + n++; + if (n > 0) /* override layout symbol */ + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); + for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); +} + +void +motionnotify(XEvent *e) +{ + static Monitor *mon = NULL; + Monitor *m; + XMotionEvent *ev = &e->xmotion; + + if (ev->window != root) + return; + if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { + unfocus(selmon->sel, 1); + selmon = m; + focus(NULL); + } + mon = m; +} + +void +movemouse(const Arg *arg) +{ + int x, y, ocx, ocy, nx, ny; + Client *c; + Monitor *m; + XEvent ev; + Time lasttime = 0; + + if (!(c = selmon->sel)) + return; + restack(selmon); + ocx = c->x; + ocy = c->y; + if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, + None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess) + return; + if (!getrootptr(&x, &y)) + return; + do { + XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); + switch(ev.type) { + case ConfigureRequest: + case Expose: + case MapRequest: + handler[ev.type](&ev); + break; + case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / 60)) + continue; + lasttime = ev.xmotion.time; + + nx = ocx + (ev.xmotion.x - x); + ny = ocy + (ev.xmotion.y - y); + if (abs(selmon->wx - nx) < snap) + nx = selmon->wx; + else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap) + nx = selmon->wx + selmon->ww - WIDTH(c); + if (abs(selmon->wy - ny) < snap) + ny = selmon->wy; + else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap) + ny = selmon->wy + selmon->wh - HEIGHT(c); + //if (!c->isfloating && selmon->lt[selmon->sellt]->arrange + //&& (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) + // togglefloating(NULL); + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) + resize(c, nx, ny, c->w, c->h, 1); + break; + } + } while (ev.type != ButtonRelease); + XUngrabPointer(dpy, CurrentTime); + if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { + sendmon(c, m); + selmon = m; + focus(NULL); + } +} + +Client * +nexttiled(Client *c) +{ + for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next); + return c; +} + +void +pop(Client *c) +{ + detach(c); + attach(c); + focus(c); + arrange(c->mon); +} + +void +propertynotify(XEvent *e) +{ + Client *c; + Window trans; + XPropertyEvent *ev = &e->xproperty; + + if ((ev->window == root) && (ev->atom == XA_WM_NAME)) + updatestatus(); + else if (ev->state == PropertyDelete) + return; /* ignore */ + else if ((c = wintoclient(ev->window))) { + switch(ev->atom) { + default: break; + case XA_WM_TRANSIENT_FOR: + if (!c->isfloating && (XGetTransientForHint(dpy, c->win, &trans)) && + (c->isfloating = (wintoclient(trans)) != NULL)) + arrange(c->mon); + break; + case XA_WM_NORMAL_HINTS: + updatesizehints(c); + break; + case XA_WM_HINTS: + updatewmhints(c); + drawbars(); + break; + } + if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { + updatetitle(c); + if (c == c->mon->sel) + drawbar(c->mon); + } + if (ev->atom == netatom[NetWMWindowType]) + updatewindowtype(c); + } +} + +void +quit(const Arg *arg) +{ + running = 0; +} + +Monitor * +recttomon(int x, int y, int w, int h) +{ + Monitor *m, *r = selmon; + int a, area = 0; + + for (m = mons; m; m = m->next) + if ((a = INTERSECT(x, y, w, h, m)) > area) { + area = a; + r = m; + } + return r; +} + +void +resize(Client *c, int x, int y, int w, int h, int interact) +{ + if (c && c->iskbd) + return; + if (applysizehints(c, &x, &y, &w, &h, interact)) + resizeclient(c, x, y, w, h); +} + +void +resizeclient(Client *c, int x, int y, int w, int h) +{ + XWindowChanges wc; + + c->oldx = c->x; c->x = wc.x = x; + c->oldy = c->y; c->y = wc.y = y; + c->oldw = c->w; c->w = wc.width = w; + c->oldh = c->h; c->h = wc.height = h; + wc.border_width = c->bw; + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); + configure(c); + XSync(dpy, False); +} + +void +resizemouse(const Arg *arg) +{ + int ocx, ocy, nw, nh; + Client *c; + Monitor *m; + XEvent ev; + Time lasttime = 0; + + if (!(c = selmon->sel)) + return; + restack(selmon); + ocx = c->x; + ocy = c->y; + if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, + None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) + return; + + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + } else { + XWarpPointer(dpy, None, root, 0, 0, 0, 0, + selmon->mx + (selmon->ww * selmon->mfact), + selmon->my + (selmon->wh / 2) + ); + } + + do { + XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); + switch(ev.type) { + case ConfigureRequest: + case Expose: + case MapRequest: + handler[ev.type](&ev); + break; + case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / 60)) + continue; + lasttime = ev.xmotion.time; + + nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); + nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); + + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) + resize(c, c->x, c->y, nw, nh, 1); + break; + } + } while (ev.type != ButtonRelease); + + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + } else { + selmon->mfact = (double) (ev.xmotion.x_root - selmon->mx) / (double) selmon->ww; + arrange(selmon); + XWarpPointer(dpy, None, root, 0, 0, 0, 0, + selmon->mx + (selmon->ww * selmon->mfact), + selmon->my + (selmon->wh / 2) + ); + } + + XUngrabPointer(dpy, CurrentTime); + while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); + if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { + sendmon(c, m); + selmon = m; + focus(NULL); + } +} + +void +restack(Monitor *m) +{ + Client *c; + XEvent ev; + XWindowChanges wc; + + XRaiseWindow(dpy, m->barwin); + drawbar(m); + if (!m->sel) + return; + if (m->sel->isfloating || !m->lt[m->sellt]->arrange) + XRaiseWindow(dpy, m->sel->win); + if (m->lt[m->sellt]->arrange) { + wc.stack_mode = Below; + wc.sibling = m->barwin; + for (c = m->stack; c; c = c->snext) + if (!c->isfloating && ISVISIBLE(c)) { + XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); + wc.sibling = c->win; + } + } + XSync(dpy, False); + while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); +} + +void +run(void) +{ + XEvent ev; + struct pollfd fds[2]; + struct input_event ie; + int nfds, xfd; + + /* main event loop */ + XSync(dpy, False); + xfd = ConnectionNumber(dpy); + while (running) { + while (XPending(dpy)) { + if (XNextEvent(dpy, &ev)) + return; + if (handler[ev.type]) + handler[ev.type](&ev); + } + if (!running) + break; + fds[0].fd = xfd; + fds[0].events = POLLIN; + fds[0].revents = 0; + nfds = 1; + if (lidfd >= 0) { + fds[1].fd = lidfd; + fds[1].events = POLLIN; + fds[1].revents = 0; + nfds = 2; + } + if (poll(fds, nfds, -1) < 0) { + if (errno == EINTR) + continue; + break; + } + if (nfds == 2 && (fds[1].revents & POLLIN)) { + while (read(lidfd, &ie, sizeof(ie)) == (ssize_t)sizeof(ie)) { + if (ie.type == EV_SW && ie.code == SW_LID) { + if (ie.value == 1) { + const Arg offcmd = SHCMD("sxmo_dmenu.sh close; xset dpms 0 0 3; xset dpms force off; sxmo_state.sh set screenoff"); + set_hw_backlight(0); + spawn(&offcmd); + } else if (ie.value == 0) { + const Arg oncmd = SHCMD("xset dpms 0 0 0; xset dpms force on; sxmo_state.sh set unlock"); + set_hw_backlight(1); + spawn(&oncmd); + } + } + } + } + if (fds[0].revents & (POLLIN | POLLHUP | POLLERR)) { + if (XNextEvent(dpy, &ev)) + return; + if (handler[ev.type]) + handler[ev.type](&ev); + } + } +} + +void +scan(void) +{ + unsigned int i, num; + Window d1, d2, *wins = NULL; + XWindowAttributes wa; + + if (XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { + for (i = 0; i < num; i++) { + if (!XGetWindowAttributes(dpy, wins[i], &wa) + || wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) + continue; + if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState) + manage(wins[i], &wa); + } + for (i = 0; i < num; i++) { /* now the transients */ + if (!XGetWindowAttributes(dpy, wins[i], &wa)) + continue; + if (XGetTransientForHint(dpy, wins[i], &d1) + && (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)) + manage(wins[i], &wa); + } + if (wins) + XFree(wins); + } +} + +void +sendmon(Client *c, Monitor *m) +{ + if (c->mon == m) + return; + unfocus(c, 1); + detach(c); + detachstack(c); + c->mon = m; + c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ + if( attachbelow ) + attachBelow(c); + else + attach(c); + attachstack(c); + focus(NULL); + arrange(NULL); +} + +void +setclientstate(Client *c, long state) +{ + long data[] = { state, None }; + + XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, + PropModeReplace, (unsigned char *)data, 2); +} + +int +sendevent(Client *c, Atom proto) +{ + int n; + Atom *protocols; + int exists = 0; + XEvent ev; + + if (XGetWMProtocols(dpy, c->win, &protocols, &n)) { + while (!exists && n--) + exists = protocols[n] == proto; + XFree(protocols); + } + if (exists) { + ev.type = ClientMessage; + ev.xclient.window = c->win; + ev.xclient.message_type = wmatom[WMProtocols]; + ev.xclient.format = 32; + ev.xclient.data.l[0] = proto; + ev.xclient.data.l[1] = CurrentTime; + XSendEvent(dpy, c->win, False, NoEventMask, &ev); + } + return exists; +} + +void +setfocus(Client *c) +{ + if (!c->neverfocus) { + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + XChangeProperty(dpy, root, netatom[NetActiveWindow], + XA_WINDOW, 32, PropModeReplace, + (unsigned char *) &(c->win), 1); + } + sendevent(c, wmatom[WMTakeFocus]); +} + +void +setfullscreen(Client *c, int fullscreen) +{ + if (fullscreen && !c->isfullscreen) { + XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, + PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); + c->isfullscreen = 1; + } else if (!fullscreen && c->isfullscreen){ + XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, + PropModeReplace, (unsigned char*)0, 0); + c->isfullscreen = 0; + } +} + +void +setlayout(const Arg *arg) +{ + if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) + selmon->sellt ^= 1; + if (arg && arg->v) + selmon->lt[selmon->sellt] = (Layout *)arg->v; + strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); + if (selmon->sel) + arrange(selmon); + else + drawbar(selmon); +} + +/* arg > 1.0 will set mfact absolutely */ +void +setmfact(const Arg *arg) +{ + float f; + + if (!arg || !selmon->lt[selmon->sellt]->arrange) + return; + f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; + if (f < 0.1 || f > 0.9) + return; + selmon->mfact = f; + arrange(selmon); +} + +void +setup(void) +{ + int i,j; + XSetWindowAttributes wa; + Atom utf8string; + + /* clean up any zombies immediately */ + sigchld(0); + + /* init screen */ + screen = DefaultScreen(dpy); + sw = DisplayWidth(dpy, screen); + sh = DisplayHeight(dpy, screen); + root = RootWindow(dpy, screen); + drw = drw_create(dpy, screen, root, sw, sh); + + readxresources(); + /* Apply defaults to font and colors*/ + for (i = 0; i <= SchemeTabInactive; ++i){ + for (j = 0; j <= ColBorder; ++j){ + if ( !colors[i][j] ) + colors[i][j] = strdup(defaultcolors[i][j]); + } + } + + if (!drw_font_create(drw, font)) + die("no fonts could be loaded."); + lrpad = 6; + bh = MAX(drw->font->h + 4, 24); + updategeom(); + /* init atoms */ + utf8string = XInternAtom(dpy, "UTF8_STRING", False); + wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); + wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); + wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False); + netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); + netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); + netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); + netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); + netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); + netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); + netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); + netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); + netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); + /* init cursors */ + cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); + cursor[CurResize] = drw_cur_create(drw, XC_sizing); + cursor[CurMove] = drw_cur_create(drw, XC_fleur); + /* init appearance */ + scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); + for (i = 0; i < LENGTH(colors); i++) + scheme[i] = drw_scm_create(drw, (const char **)colors[i], 3); + for (j = 0; j <= SchemeTabInactive; ++j) { + free(colors[j][ColFg]); + free(colors[j][ColBg]); + } + /* init bars */ + updatebars(); + updatestatus(); + /* supporting window for NetWMCheck */ + wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0); + XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32, + PropModeReplace, (unsigned char *) &wmcheckwin, 1); + XChangeProperty(dpy, wmcheckwin, netatom[NetWMName], utf8string, 8, + PropModeReplace, (unsigned char *) "dwm", 3); + XChangeProperty(dpy, root, netatom[NetWMCheck], XA_WINDOW, 32, + PropModeReplace, (unsigned char *) &wmcheckwin, 1); + /* EWMH support per view */ + XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, + PropModeReplace, (unsigned char *) netatom, NetLast); + XDeleteProperty(dpy, root, netatom[NetClientList]); + /* select events */ + wa.cursor = cursor[CurNormal]->cursor; + wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask + |ButtonPressMask|PointerMotionMask|EnterWindowMask + |LeaveWindowMask|StructureNotifyMask|PropertyChangeMask|KeyPressMask; + XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); + XSelectInput(dpy, root, wa.event_mask); + lidfd = open("/dev/input/by-path/platform-gpio-keys-event", O_RDONLY | O_NONBLOCK | O_CLOEXEC); + if (lidfd < 0) + lidfd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK | O_CLOEXEC); + grabkeys(); + focus(NULL); +} + + +void +seturgent(Client *c, int urg) +{ + XWMHints *wmh; + + c->isurgent = urg; + if (!(wmh = XGetWMHints(dpy, c->win))) + return; + wmh->flags = urg ? (wmh->flags | XUrgencyHint) : (wmh->flags & ~XUrgencyHint); + XSetWMHints(dpy, c->win, wmh); + XFree(wmh); +} + +void +showhide(Client *c) +{ + if (!c) + return; + if (ISVISIBLE(c)) { + /* show clients top down */ + XMoveWindow(dpy, c->win, c->x, c->y); + if (!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) + resize(c, c->x, c->y, c->w, c->h, 0); + showhide(c->snext); + } else { + /* hide clients bottom up */ + showhide(c->snext); + XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y); + } +} + +void +sigchld(int unused) +{ + if (signal(SIGCHLD, sigchld) == SIG_ERR) + die("can't install SIGCHLD handler:"); + while (0 < waitpid(-1, NULL, WNOHANG)); +} + +void +spawn(const Arg *arg) +{ + if (arg->v == dmenucmd) + dmenumon[0] = '0' + selmon->num; + if (fork() == 0) { + if (dpy) + close(ConnectionNumber(dpy)); + setsid(); + execvp(((char **)arg->v)[0], (char **)arg->v); + fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); + perror(" failed"); + exit(EXIT_SUCCESS); + } +} + +void +switchcol(const Arg *arg) +{ + Client *c, *t; + int col = 0; + int i; + + if (!selmon->sel) + return; + for (i = 0, c = nexttiled(selmon->clients); c ; + c = nexttiled(c->next), i++) { + if (c == selmon->sel) + col = (i + 1) > selmon->nmaster; + } + if (i <= selmon->nmaster) + return; + for (c = selmon->stack; c; c = c->snext) { + if (!ISVISIBLE(c)) + continue; + for (i = 0, t = nexttiled(selmon->clients); t && t != c; + t = nexttiled(t->next), i++); + if (t && (i + 1 > selmon->nmaster) != col) { + focus(c); + restack(selmon); + break; + } + } +} + +void +tag(const Arg *arg) +{ + if (selmon->sel && arg->ui & TAGMASK) { + selmon->sel->tags = arg->ui & TAGMASK; + focus(NULL); + arrange(selmon); + } +} + +void +tagmon(const Arg *arg) +{ + if (!selmon->sel || !mons->next) + return; + sendmon(selmon->sel, dirtomon(arg->i)); +} + +void +tile(Monitor *m) +{ + unsigned int i, n, h, mw, my, ty; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + if (n > m->nmaster) + mw = m->nmaster ? m->ww * m->mfact : 0; + else + mw = m->ww; + for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i); + resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); + my += HEIGHT(c); + } else { + h = (m->wh - ty) / (n - i); + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); + ty += HEIGHT(c); + } +} + +void +togglebar(const Arg *arg) +{ + selmon->showbar = !selmon->showbar; + updatebarpos(selmon); + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); + arrange(selmon); +} + +void +togglefloating(const Arg *arg) +{ + if (!selmon->sel) + return; + selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; + if (selmon->sel->isfloating) + resize(selmon->sel, selmon->sel->x, selmon->sel->y, + selmon->sel->w, selmon->sel->h, 0); + arrange(selmon); +} + +void +toggletag(const Arg *arg) +{ + unsigned int newtags; + + if (!selmon->sel) + return; + newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); + if (newtags) { + selmon->sel->tags = newtags; + focus(NULL); + arrange(selmon); + } +} + +void +toggleview(const Arg *arg) +{ + unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); + + if (newtagset) { + selmon->tagset[selmon->seltags] = newtagset; + focus(NULL); + arrange(selmon); + } +} + +void +unfocus(Client *c, int setfocus) +{ + if (!c) + return; + grabbuttons(c, 0); + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); + if (setfocus) { + XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); + } +} + +void +unmanage(Client *c, int destroyed) +{ + Monitor *m = c->mon; + XWindowChanges wc; + + if (c->iskbd) + updategeom(); + + if (c->swallowing) { + unswallow(c); + return; + } + + Client *s = swallowingclient(c->win); + if (s) { + free(s->swallowing); + s->swallowing = NULL; + arrange(m); + focus(NULL); + return; + } + + detach(c); + detachstack(c); + if (!destroyed) { + wc.border_width = c->oldbw; + XGrabServer(dpy); /* avoid race conditions */ + XSetErrorHandler(xerrordummy); + XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */ + XUngrabButton(dpy, AnyButton, AnyModifier, c->win); + setclientstate(c, WithdrawnState); + XSync(dpy, False); + XSetErrorHandler(xerror); + XUngrabServer(dpy); + } + free(c); + + if (!s) { + arrange(m); + focus(NULL); + updateclientlist(); + } +} + +void +unmapnotify(XEvent *e) +{ + Client *c; + XUnmapEvent *ev = &e->xunmap; + + if ((c = wintoclient(ev->window))) { + if (ev->send_event) + setclientstate(c, WithdrawnState); + else + unmanage(c, 0); + } +} + +void +updatebars(void) +{ + Monitor *m; + XSetWindowAttributes wa = { + .override_redirect = True, + .background_pixmap = ParentRelative, + .event_mask = ButtonPressMask|ExposureMask + }; + XClassHint ch = {"dwm", "dwm"}; + for (m = mons; m; m = m->next) { + if (m->barwin) + continue; + m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), + CopyFromParent, DefaultVisual(dpy, screen), + CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); + XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); + XMapRaised(dpy, m->barwin); + XSetClassHint(dpy, m->barwin, &ch); + } +} + +void +updatebarpos(Monitor *m) +{ + m->wy = m->my; + m->wh = m->mh; + if (m->showbar) { + m->wh -= bh; + m->by = m->topbar ? m->wy : m->wy + m->wh; + m->wy = m->topbar ? m->wy + bh : m->wy; + } else + m->by = -bh; +} + +void +updateclientlist() +{ + Client *c; + Monitor *m; + + XDeleteProperty(dpy, root, netatom[NetClientList]); + for (m = mons; m; m = m->next) + for (c = m->clients; c; c = c->next) + XChangeProperty(dpy, root, netatom[NetClientList], + XA_WINDOW, 32, PropModeAppend, + (unsigned char *) &(c->win), 1); +} + +int +updategeom(void) +{ + int dirty = 0; + +#ifdef XINERAMA + if (XineramaIsActive(dpy)) { + int i, j, n, nn; + Client *c; + Monitor *m; + XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn); + XineramaScreenInfo *unique = NULL; + + for (n = 0, m = mons; m; m = m->next, n++); + /* only consider unique geometries as separate screens */ + unique = ecalloc(nn, sizeof(XineramaScreenInfo)); + for (i = 0, j = 0; i < nn; i++) + if (isuniquegeom(unique, j, &info[i])) + memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); + XFree(info); + nn = j; + if (n <= nn) { /* new monitors available */ + for (i = 0; i < (nn - n); i++) { + for (m = mons; m && m->next; m = m->next); + if (m) + m->next = createmon(); + else + mons = createmon(); + } + for (i = 0, m = mons; i < nn && m; m = m->next, i++) + if (i >= n + || unique[i].x_org != m->mx || unique[i].y_org != m->my + || unique[i].width != m->mw || unique[i].height != m->mh) + { + dirty = 1; + m->num = i; + m->mx = m->wx = unique[i].x_org; + m->my = m->wy = unique[i].y_org; + m->mw = m->ww = unique[i].width; + m->mh = m->wh = unique[i].height; + updatebarpos(m); + } + } else { /* less monitors available nn < n */ + for (i = nn; i < n; i++) { + for (m = mons; m && m->next; m = m->next); + while ((c = m->clients)) { + dirty = 1; + m->clients = c->next; + detachstack(c); + c->mon = mons; + if( attachbelow ) + attachBelow(c); + else + attach(c); + attachstack(c); + } + if (m == selmon) + selmon = mons; + cleanupmon(m); + } + } + free(unique); + } else +#endif /* XINERAMA */ + { /* default monitor setup */ + if (!mons) + mons = createmon(); + if (mons->mw != sw || mons->mh != sh) { + dirty = 1; + mons->mw = mons->ww = sw; + mons->mh = mons->wh = sh; + updatebarpos(mons); + } + } + if (dirty) { + selmon = mons; + selmon = wintomon(root); + } + return dirty; +} + +void +updatenumlockmask(void) +{ + unsigned int i, j; + XModifierKeymap *modmap; + + numlockmask = 0; + modmap = XGetModifierMapping(dpy); + for (i = 0; i < 8; i++) + for (j = 0; j < modmap->max_keypermod; j++) + if (modmap->modifiermap[i * modmap->max_keypermod + j] + == XKeysymToKeycode(dpy, XK_Num_Lock)) + numlockmask = (1 << i); + XFreeModifiermap(modmap); +} + +void +updatesizehints(Client *c) +{ + long msize; + XSizeHints size; + + if (!XGetWMNormalHints(dpy, c->win, &size, &msize)) + /* size is uninitialized, ensure that size.flags aren't used */ + size.flags = PSize; + if (size.flags & PBaseSize) { + c->basew = size.base_width; + c->baseh = size.base_height; + } else if (size.flags & PMinSize) { + c->basew = size.min_width; + c->baseh = size.min_height; + } else + c->basew = c->baseh = 0; + if (size.flags & PResizeInc) { + c->incw = size.width_inc; + c->inch = size.height_inc; + } else + c->incw = c->inch = 0; + if (size.flags & PMaxSize) { + c->maxw = size.max_width; + c->maxh = size.max_height; + } else + c->maxw = c->maxh = 0; + if (size.flags & PMinSize) { + c->minw = size.min_width; + c->minh = size.min_height; + } else if (size.flags & PBaseSize) { + c->minw = size.base_width; + c->minh = size.base_height; + } else + c->minw = c->minh = 0; + if (size.flags & PAspect) { + c->mina = (float)size.min_aspect.y / size.min_aspect.x; + c->maxa = (float)size.max_aspect.x / size.max_aspect.y; + } else + c->maxa = c->mina = 0.0; + c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh); +} + +void +updatestatus(void) +{ + size_t len; + if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) + strcpy(stext, "dwm-"VERSION); + len = strlen(stext); + while (len > 0 && (stext[len - 1] == ' ' || stext[len - 1] == '\n' || stext[len - 1] == '\r')) + stext[--len] = '\0'; + drawbar(selmon); +} + +void +updatetitle(Client *c) +{ + if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) + gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name); + if (c->name[0] == '\0') /* hack to mark broken clients */ + strcpy(c->name, broken); + if (c == selmon->sel) + writefocusedwin(c); +} + +void +updatewindowtype(Client *c) +{ + Atom state = getatomprop(c, netatom[NetWMState]); + Atom wtype = getatomprop(c, netatom[NetWMWindowType]); + + if (state == netatom[NetWMFullscreen]) + setfullscreen(c, 1); + if (wtype == netatom[NetWMWindowTypeDialog]) + c->isfloating = 1; +} + +void +updatewmhints(Client *c) +{ + XWMHints *wmh; + + if ((wmh = XGetWMHints(dpy, c->win))) { + if (c == selmon->sel && wmh->flags & XUrgencyHint) { + wmh->flags &= ~XUrgencyHint; + XSetWMHints(dpy, c->win, wmh); + } else + c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0; + if (wmh->flags & InputHint) + c->neverfocus = !wmh->input; + else + c->neverfocus = 0; + XFree(wmh); + } +} + +void +view(const Arg *arg) +{ + if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) + return; + selmon->seltags ^= 1; /* toggle sel tagset */ + if (arg->ui & TAGMASK) + selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + focus(NULL); + arrange(selmon); +} + +pid_t +winpid(Window w) +{ + pid_t result = 0; + + xcb_res_client_id_spec_t spec = {0}; + spec.client = w; + spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID; + + xcb_generic_error_t *e = NULL; + xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec); + xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e); + + if (!r) + return (pid_t)0; + + xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r); + for (; i.rem; xcb_res_client_id_value_next(&i)) { + spec = i.data->spec; + if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) { + uint32_t *t = xcb_res_client_id_value_value(i.data); + result = *t; + break; + } + } + + free(r); + + if (result == (pid_t)-1) + result = 0; + return result; +} + +pid_t +getparentprocess(pid_t p) +{ + unsigned int v = 0; + +#ifdef __linux__ + FILE *f; + char buf[256]; + snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p); + + if (!(f = fopen(buf, "r"))) + return 0; + + fscanf(f, "%*u %*s %*c %u", &v); + fclose(f); +#endif /* __linux__ */ + + return (pid_t)v; +} + +int +isdescprocess(pid_t p, pid_t c) +{ + while (p != c && c != 0) + c = getparentprocess(c); + + return (int)c; +} + +Client * +termforwin(const Client *w) +{ + Client *c; + Monitor *m; + + if (!w->pid || w->isterminal) + return NULL; + + for (m = mons; m; m = m->next) { + for (c = m->clients; c; c = c->next) { + if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid)) + return c; + } + } + + return NULL; +} + +Client * +swallowingclient(Window w) +{ + Client *c; + Monitor *m; + + for (m = mons; m; m = m->next) { + for (c = m->clients; c; c = c->next) { + if (c->swallowing && c->swallowing->win == w) + return c; + } + } + + return NULL; +} + +Client * +wintoclient(Window w) +{ + Client *c; + Monitor *m; + + for (m = mons; m; m = m->next) + for (c = m->clients; c; c = c->next) + if (c->win == w) + return c; + return NULL; +} + +Monitor * +wintomon(Window w) +{ + int x, y; + Client *c; + Monitor *m; + + if (w == root && getrootptr(&x, &y)) + return recttomon(x, y, 1, 1); + for (m = mons; m; m = m->next) + if (w == m->barwin) + return m; + if ((c = wintoclient(w))) + return c->mon; + return selmon; +} + +/* There's no way to check accesses to destroyed windows, thus those cases are + * ignored (especially on UnmapNotify's). Other types of errors call Xlibs + * default error handler, which may call exit. */ +int +xerror(Display *dpy, XErrorEvent *ee) +{ + if (ee->error_code == BadWindow + || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) + || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) + || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) + || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) + || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) + || (ee->request_code == X_GrabButton && ee->error_code == BadAccess) + || (ee->request_code == X_GrabKey && ee->error_code == BadAccess) + || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) + return 0; + fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", + ee->request_code, ee->error_code); + return xerrorxlib(dpy, ee); /* may call exit */ +} + +int +xerrordummy(Display *dpy, XErrorEvent *ee) +{ + return 0; +} + +/* Startup Error handler to check if another window manager + * is already running. */ +int +xerrorstart(Display *dpy, XErrorEvent *ee) +{ + die("dwm: another window manager is already running"); + return -1; +} + +void +zoom(const Arg *arg) +{ + Client *c = selmon->sel; + + if (!selmon->lt[selmon->sellt]->arrange + || (selmon->sel && selmon->sel->isfloating)) + return; + if (c == nexttiled(selmon->clients)) + if (!c || !(c = nexttiled(c->next))) + return; + pop(c); +} + + +void +readxresources() { + XrmInitialize(); + + char* xrm; + if ((xrm = XResourceManagerString(drw->dpy))) { + char *type; + XrmDatabase xdb = XrmGetStringDatabase(xrm); + XrmValue xval; + + if (XrmGetResource(xdb, "dwm.background", "*", &type, &xval) && !colors[SchemeNorm][ColBg] ) + colors[SchemeNorm][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.foreground", "*", &type, &xval) && !colors[SchemeNorm][ColFg] ) + colors[SchemeNorm][ColFg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.border", "*", &type, &xval) && !colors[SchemeNorm][ColBorder] ) + colors[SchemeNorm][ColBorder] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dwm.selbackground", "*", &type, &xval) && !colors[SchemeSel][ColBg] ) + colors[SchemeSel][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.selforeground", "*", &type, &xval) && !colors[SchemeSel][ColFg] ) + colors[SchemeSel][ColFg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.selborder", "*", &type, &xval) && !colors[SchemeSel][ColBorder] ) + colors[SchemeSel][ColBorder] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dwm.tabactivebackground", "*", &type, &xval) && !colors[SchemeTabActive][ColBg] ) + colors[SchemeTabActive][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.tabactiveforeground", "*", &type, &xval) && !colors[SchemeTabActive][ColFg] ) + colors[SchemeTabActive][ColFg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.tabactiveborder", "*", &type, &xval) && !colors[SchemeTabActive][ColBorder] ) + colors[SchemeTabActive][ColBorder] = strdup(xval.addr); + + if (XrmGetResource(xdb, "dwm.tabinactivebackground", "*", &type, &xval) && !colors[SchemeTabInactive][ColBg] ) + colors[SchemeTabInactive][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.tabinactiveforeground", "*", &type, &xval) && !colors[SchemeTabInactive][ColFg] ) + colors[SchemeTabInactive][ColFg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dwm.tabinactiveborder", "*", &type, &xval) && !colors[SchemeTabInactive][ColBorder] ) + colors[SchemeTabInactive][ColBorder] = strdup(xval.addr); + + XrmDestroyDatabase(xdb); + } +} + +int +main(int argc, char *argv[]) +{ + XInitThreads(); + if (argc == 2 && !strcmp("-v", argv[1])) + die("dwm-"VERSION); + else if (argc != 1) + die("usage: dwm [-v]"); + if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) + fputs("warning: no locale support\n", stderr); + if (!(dpy = XOpenDisplay(NULL))) + die("dwm: cannot open display"); + XkbSetDetectableAutoRepeat(dpy, True, NULL); + if (!(xcon = XGetXCBConnection(dpy))) + die("dwm: cannot get xcb connection\n"); + checkotherwm(); + setup(); +#ifdef __OpenBSD__ + if (pledge("stdio rpath proc exec", NULL) == -1) + die("pledge"); +#endif /* __OpenBSD__ */ + scan(); + run(); + cleanup(); + XCloseDisplay(dpy); + return EXIT_SUCCESS; +} + +static void +bstack(Monitor *m) { + int w, h, mh, mx, tx, ty, tw; + unsigned int i, n; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + tw = m->ww / (n - m->nmaster); + ty = m->wy + mh; + } else { + mh = m->wh; + tw = m->ww; + ty = m->wy; + } + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += WIDTH(c); + } else { + h = m->wh - mh; + resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); + if (tw != m->ww) + tx += WIDTH(c); + } + } +} + +static void +bstackhoriz(Monitor *m) { + int w, mh, mx, tx, ty, th; + unsigned int i, n; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + th = (m->wh - mh) / (n - m->nmaster); + ty = m->wy + mh; + } else { + th = mh = m->wh; + ty = m->wy; + } + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += WIDTH(c); + } else { + resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0); + if (th != m->wh) + ty += HEIGHT(c); + } + } +} + +void +clienttagpush(const Arg *arg) { + if (selmon->sel == NULL) return; + + if (arg->i > 0) { + if ( + (selmon->tagset[selmon->seltags] & TAGMASK) + && (selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) + ) { + selmon->sel->tags <<= 1; + } + } else { + if ( + (selmon->tagset[selmon->seltags] & TAGMASK) + && (selmon->tagset[selmon->seltags] & (TAGMASK << 1)) + ) { + selmon->sel->tags >>= 1; + } + } + + focus(NULL); + arrange(selmon); +} + +void +shiftview(const Arg *arg) { + Arg shifted; + + if(arg->i > 0) + shifted.ui = (selmon->tagset[selmon->seltags] << arg->i) + | (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i)); + + else + shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i) + | selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i); + + view(&shifted); +} + +void +unfloatvisible(const Arg *arg) +{ + Client *c; + + for (c = selmon->clients; c; c = c->next) + if (ISVISIBLE(c) && c->isfloating) + c->isfloating = c->isfixed; + + if (arg && arg->v) + setlayout(arg); + else + arrange(selmon); +} + +void +insertclient(Client *item, Client *insertItem, int after) { + Client *c; + if (item == NULL || insertItem == NULL || item == insertItem) return; + detach(insertItem); + if (!after && selmon->clients == item) { + attach(insertItem); + return; + } + if (after) { + c = item; + } else { + for (c = selmon->clients; c; c = c->next) { if (c->next == item) break; } + } + insertItem->next = c->next; + c->next = insertItem; +} + +void +inplacerotate(const Arg *arg) +{ + if(!selmon->sel || (selmon->sel->isfloating && !arg->f)) return; + + unsigned int selidx = 0, i = 0; + Client *c = NULL, *stail = NULL, *mhead = NULL, *mtail = NULL, *shead = NULL; + + // Determine positionings for insertclient + for (c = selmon->clients; c; c = c->next) { + if (ISVISIBLE(c) && !(c->isfloating)) { + if (selmon->sel == c) { selidx = i; } + if (i == selmon->nmaster - 1) { mtail = c; } + if (i == selmon->nmaster) { shead = c; } + if (mhead == NULL) { mhead = c; } + stail = c; + i++; + } + } + + // All clients rotate + if (arg->i == 2) insertclient(selmon->clients, stail, 0); + if (arg->i == -2) insertclient(stail, selmon->clients, 1); + // Stack xor master rotate + if (arg->i == -1 && selidx >= selmon->nmaster) insertclient(stail, shead, 1); + if (arg->i == 1 && selidx >= selmon->nmaster) insertclient(shead, stail, 0); + if (arg->i == -1 && selidx < selmon->nmaster) insertclient(mtail, mhead, 1); + if (arg->i == 1 && selidx < selmon->nmaster) insertclient(mhead, mtail, 0); + + // Restore focus position + i = 0; + for (c = selmon->clients; c; c = c->next) { + if (!ISVISIBLE(c) || (c->isfloating)) continue; + if (i == selidx) { focus(c); break; } + i++; + } + arrange(selmon); + focus(c); +} + +void +transfer(const Arg *arg) { + Client *c, *mtail = selmon->clients, *stail = NULL, *insertafter; + int transfertostack = 0, i, nmasterclients; + + for (i = 0, c = selmon->clients; c; c = c->next) { + if (!ISVISIBLE(c) || c->isfloating) continue; + if (selmon->sel == c) { transfertostack = i < selmon->nmaster && selmon->nmaster != 0; } + if (i < selmon->nmaster) { nmasterclients++; mtail = c; } + stail = c; + i++; + } + if (selmon->sel->isfloating || i == 0) { + return; + } else if (transfertostack) { + selmon->nmaster = MIN(i, selmon->nmaster) - 1; + insertafter = stail; + } else { + selmon->nmaster = selmon->nmaster + 1; + insertafter = mtail; + } + if (insertafter != selmon->sel) { + detach(selmon->sel); + if (selmon->nmaster == 1 && !transfertostack) { + attach(selmon->sel); // Head prepend case + } else { + selmon->sel->next = insertafter->next; + insertafter->next = selmon->sel; + } + } + arrange(selmon); +} + +void +transferall(const Arg *arg) { + Client *c, *n = selmon->clients, *attachfrom = NULL; + int i = 0, nstackclients = 0; + while (n) { + c = n; + n = c->next; + if (!ISVISIBLE(c) || c->isfloating) continue; + if (i >= selmon->nmaster) { + detach(c); + if (!attachfrom) { + attach(c); + } else { + c->next = attachfrom->next; + attachfrom->next = c; + } + attachfrom = c; + nstackclients++; + } + i++; + } + selmon->nmaster = nstackclients; + arrange(selmon); +} + +static Client * +nextc(Client *c, float f) { + if(!f) + return nexttiled(c); + + for(; c && !ISVISIBLE(c); c = c->next); + return c; +} + +static Client * +prevc(Client *c, float f) { + Client *p, *r; + + for(p = selmon->clients, r = NULL; c && p && p != c; p = p->next) + if((f || !p->isfloating) && ISVISIBLE(p)) + r = p; + return r; +} + + +static void +pushup(const Arg *arg) { + Client *sel = selmon->sel; + Client *c; + + if(!sel || (sel->isfloating && !arg->f)) + return; + if((c = prevc(sel, arg->f))) { + /* attach before c */ + detach(sel); + sel->next = c; + if(selmon->clients == c) + selmon->clients = sel; + else { + for(c = selmon->clients; c->next != sel->next; c = c->next); + c->next = sel; + } + } else { + /* move to the end */ + for(c = sel; c->next; c = c->next); + detach(sel); + sel->next = NULL; + c->next = sel; + } + focus(sel); + arrange(selmon); +} + +static void +pushdown(const Arg *arg) { + Client *sel = selmon->sel; + Client *c; + + if(!sel || (sel->isfloating && !arg->f)) + return; + if((c = nextc(sel->next, arg->f))) { + /* attach after c */ + detach(sel); + sel->next = c->next; + c->next = sel; + } else { + /* move to the front */ + detach(sel); + attach(sel); + } + focus(sel); + arrange(selmon); +} + diff --git a/src/sxmo-dwm/dwm.png b/src/sxmo-dwm/dwm.png new file mode 100644 index 0000000..b1f9ba7 Binary files /dev/null and b/src/sxmo-dwm/dwm.png differ diff --git a/src/sxmo-dwm/transient.c b/src/sxmo-dwm/transient.c new file mode 100644 index 0000000..040adb5 --- /dev/null +++ b/src/sxmo-dwm/transient.c @@ -0,0 +1,42 @@ +/* cc transient.c -o transient -lX11 */ + +#include +#include +#include +#include + +int main(void) { + Display *d; + Window r, f, t = None; + XSizeHints h; + XEvent e; + + d = XOpenDisplay(NULL); + if (!d) + exit(1); + r = DefaultRootWindow(d); + + f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0); + h.min_width = h.max_width = h.min_height = h.max_height = 400; + h.flags = PMinSize | PMaxSize; + XSetWMNormalHints(d, f, &h); + XStoreName(d, f, "floating"); + XMapWindow(d, f); + + XSelectInput(d, f, ExposureMask); + while (1) { + XNextEvent(d, &e); + + if (t == None) { + sleep(5); + t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0); + XSetTransientForHint(d, t, f); + XStoreName(d, t, "transient"); + XMapWindow(d, t); + XSelectInput(d, t, ExposureMask); + } + } + + XCloseDisplay(d); + exit(0); +} diff --git a/src/sxmo-dwm/util.c b/src/sxmo-dwm/util.c new file mode 100644 index 0000000..fe044fc --- /dev/null +++ b/src/sxmo-dwm/util.c @@ -0,0 +1,35 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include + +#include "util.h" + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} + +void +die(const char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') { + fputc(' ', stderr); + perror(NULL); + } else { + fputc('\n', stderr); + } + + exit(1); +} diff --git a/src/sxmo-dwm/util.h b/src/sxmo-dwm/util.h new file mode 100644 index 0000000..531ab25 --- /dev/null +++ b/src/sxmo-dwm/util.h @@ -0,0 +1,12 @@ +/* See LICENSE file for copyright and license details. */ + +#ifndef MAX +#define MAX(A, B) ((A) > (B) ? (A) : (B)) +#endif +#ifndef MIN +#define MIN(A, B) ((A) < (B) ? (A) : (B)) +#endif +#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) + +void die(const char *fmt, ...); +void *ecalloc(size_t nmemb, size_t size); diff --git a/src/sxmo-st/.build.yml b/src/sxmo-st/.build.yml new file mode 100644 index 0000000..fd3a091 --- /dev/null +++ b/src/sxmo-st/.build.yml @@ -0,0 +1,17 @@ +image: alpine/edge +packages: + - editorconfig-checker + - fontconfig-dev + - freetype-dev + - libx11-dev + - libxext-dev + - libxft-dev +sources: + - https://git.sr.ht/~mil/sxmo-st +tasks: + - editorconfig-check: | + cd sxmo-st + ec + - make: | + cd sxmo-st + make diff --git a/src/sxmo-st/.editorconfig b/src/sxmo-st/.editorconfig new file mode 100644 index 0000000..b9e964e --- /dev/null +++ b/src/sxmo-st/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*.{sh|c}] +end_of_line = lf +insert_final_newline = true +indent_style = tab +#max_line_length = 80 +spaces_around_operators = true +charset = utf-8 +trim_trailing_whitespace = true diff --git a/src/sxmo-st/FAQ b/src/sxmo-st/FAQ new file mode 100644 index 0000000..0f9609d --- /dev/null +++ b/src/sxmo-st/FAQ @@ -0,0 +1,250 @@ +## Why does st not handle utmp entries? + +Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task. + + +## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever! + +It means that st doesn’t have any terminfo entry on your system. Chances are +you did not `make install`. If you just want to test it without installing it, +you can manually run `tic -sx st.info`. + + +## Nothing works, and nothing is said about an unknown terminal! + +* Some programs just assume they’re running in xterm i.e. they don’t rely on + terminfo. What you see is the current state of the “xterm compliance”. +* Some programs don’t complain about the lacking st description and default to + another terminal. In that case see the question about terminfo. + + +## How do I scroll back up? + +* Using a terminal multiplexer. + * `st -e tmux` using C-b [ + * `st -e screen` using C-a ESC +* Using the excellent tool of [scroll](https://git.suckless.org/scroll/). +* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/). + + +## I would like to have utmp and/or scroll functionality by default + +You can add the absolute patch of both programs in your config.h +file. You only have to modify the value of utmp and scroll variables. + + +## Why doesn't the Del key work in some programs? + +Taken from the terminfo manpage: + + If the terminal has a keypad that transmits codes when the keys + are pressed, this information can be given. Note that it is not + possible to handle terminals where the keypad only works in + local (this applies, for example, to the unshifted HP 2621 keys). + If the keypad can be set to transmit or not transmit, give these + codes as smkx and rmkx. Otherwise the keypad is assumed to + always transmit. + +In the st case smkx=E[?1hE= and rmkx=E[?1lE>, so it is mandatory that +applications which want to test against keypad keys send these +sequences. + +But buggy applications (like bash and irssi, for example) don't do this. A fast +solution for them is to use the following command: + + $ printf '\033[?1h\033=' >/dev/tty + +or + $ tput smkx + +In the case of bash, readline is used. Readline has a different note in its +manpage about this issue: + + enable-keypad (Off) + When set to On, readline will try to enable the + application keypad when it is called. Some systems + need this to enable arrow keys. + +Adding this option to your .inputrc will fix the keypad problem for all +applications using readline. + +If you are using zsh, then read the zsh FAQ +: + + It should be noted that the O / [ confusion can occur with other keys + such as Home and End. Some systems let you query the key sequences + sent by these keys from the system's terminal database, terminfo. + Unfortunately, the key sequences given there typically apply to the + mode that is not the one zsh uses by default (it's the "application" + mode rather than the "raw" mode). Explaining the use of terminfo is + outside of the scope of this FAQ, but if you wish to use the key + sequences given there you can tell the line editor to turn on + "application" mode when it starts and turn it off when it stops: + + function zle-line-init () { echoti smkx } + function zle-line-finish () { echoti rmkx } + zle -N zle-line-init + zle -N zle-line-finish + +Putting these lines into your .zshrc will fix the problems. + + +## How can I use meta in 8bit mode? + +St supports meta in 8bit mode, but the default terminfo entry doesn't +use this capability. If you want it, you have to use the 'st-meta' value +in TERM. + + +## I cannot compile st in OpenBSD + +OpenBSD lacks librt, despite it being mandatory in POSIX +. +If you want to compile st for OpenBSD you have to remove -lrt from config.mk, and +st will compile without any loss of functionality, because all the functions are +included in libc on this platform. + + +## The Backspace Case + +St is emulating the Linux way of handling backspace being delete and delete being +backspace. + +This is an issue that was discussed in suckless mailing list +. Here is why some old grumpy +terminal users wants its backspace to be how he feels it: + + Well, I am going to comment why I want to change the behaviour + of this key. When ASCII was defined in 1968, communication + with computers was done using punched cards, or hardcopy + terminals (basically a typewriter machine connected with the + computer using a serial port). ASCII defines DELETE as 7F, + because, in punched-card terms, it means all the holes of the + card punched; it is thus a kind of 'physical delete'. In the + same way, the BACKSPACE key was a non-destructive backspace, + as on a typewriter. So, if you wanted to delete a character, + you had to BACKSPACE and then DELETE. Another use of BACKSPACE + was to type accented characters, for example 'a BACKSPACE `'. + The VT100 had no BACKSPACE key; it was generated using the + CONTROL key as another control character (CONTROL key sets to + 0 b7 b6 b5, so it converts H (code 0x48) into BACKSPACE (code + 0x08)), but it had a DELETE key in a similar position where + the BACKSPACE key is located today on common PC keyboards. + All the terminal emulators emulated the difference between + these keys correctly: the backspace key generated a BACKSPACE + (^H) and delete key generated a DELETE (^?). + + But a problem arose when Linus Torvalds wrote Linux. Unlike + earlier terminals, the Linux virtual terminal (the terminal + emulator integrated in the kernel) returned a DELETE when + backspace was pressed, due to the VT100 having a DELETE key in + the same position. This created a lot of problems (see [1] + and [2]). Since Linux has become the king, a lot of terminal + emulators today generate a DELETE when the backspace key is + pressed in order to avoid problems with Linux. The result is + that the only way of generating a BACKSPACE on these systems + is by using CONTROL + H. (I also think that emacs had an + important point here because the CONTROL + H prefix is used + in emacs in some commands (help commands).) + + From point of view of the kernel, you can change the key + for deleting a previous character with stty erase. When you + connect a real terminal into a machine you describe the type + of terminal, so getty configures the correct value of stty + erase for this terminal. In the case of terminal emulators, + however, you don't have any getty that can set the correct + value of stty erase, so you always get the default value. + For this reason, it is necessary to add 'stty erase ^H' to your + profile if you have changed the value of the backspace key. + Of course, another solution is for st itself to modify the + value of stty erase. I usually have the inverse problem: + when I connect to non-Unix machines, I have to press CONTROL + + h to get a BACKSPACE. The inverse problem occurs when a user + connects to my Unix machines from a different system with a + correct backspace key. + + [1] http://www.ibb.net/~anne/keyboard.html + [2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html + + +## But I really want the old grumpy behaviour of my terminal + +Apply [1]. + +[1] https://st.suckless.org/patches/delkey + + +## Why do images not work in st using the w3m image hack? + +w3mimg uses a hack that draws an image on top of the terminal emulator Drawable +window. The hack relies on the terminal to use a single buffer to draw its +contents directly. + +st uses double-buffered drawing so the image is quickly replaced and may show a +short flicker effect. + +Below is a patch example to change st double-buffering to a single Drawable +buffer. + +diff --git a/x.c b/x.c +--- a/x.c ++++ b/x.c +@@ -732,10 +732,6 @@ xresize(int col, int row) + win.tw = col * win.cw; + win.th = row * win.ch; + +- XFreePixmap(xw.dpy, xw.buf); +- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, +- DefaultDepth(xw.dpy, xw.scr)); +- XftDrawChange(xw.draw, xw.buf); + xclear(0, 0, win.w, win.h); + + /* resize to new width */ +@@ -1148,8 +1144,7 @@ xinit(int cols, int rows) + gcvalues.graphics_exposures = False; + dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, + &gcvalues); +- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, +- DefaultDepth(xw.dpy, xw.scr)); ++ xw.buf = xw.win; + XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); + XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); + +@@ -1632,8 +1627,6 @@ xdrawline(Line line, int x1, int y1, int x2) + void + xfinishdraw(void) + { +- XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w, +- win.h, 0, 0); + XSetForeground(xw.dpy, dc.gc, + dc.col[IS_SET(MODE_REVERSE)? + defaultfg : defaultbg].pixel); + + +## BadLength X error in Xft when trying to render emoji + +Xft makes st crash when rendering color emojis with the following error: + +"X Error of failed request: BadLength (poly request too large or internal Xlib length error)" + Major opcode of failed request: 139 (RENDER) + Minor opcode of failed request: 20 (RenderAddGlyphs) + Serial number of failed request: 1595 + Current serial number in output stream: 1818" + +This is a known bug in Xft (not st) which happens on some platforms and +combination of particular fonts and fontconfig settings. + +See also: +https://gitlab.freedesktop.org/xorg/lib/libxft/issues/6 +https://bugs.freedesktop.org/show_bug.cgi?id=107534 +https://bugzilla.redhat.com/show_bug.cgi?id=1498269 + +The solution is to remove color emoji fonts or disable this in the fontconfig +XML configuration. As an ugly workaround (which may work only on newer +fontconfig versions (FC_COLOR)), the following code can be used to mask color +fonts: + + FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); + +Please don't bother reporting this bug to st, but notify the upstream Xft +developers about fixing this bug. diff --git a/src/sxmo-st/LEGACY b/src/sxmo-st/LEGACY new file mode 100644 index 0000000..bf28b1e --- /dev/null +++ b/src/sxmo-st/LEGACY @@ -0,0 +1,17 @@ +A STATEMENT ON LEGACY SUPPORT + +In the terminal world there is much cruft that comes from old and unsup‐ +ported terminals that inherit incompatible modes and escape sequences +which noone is able to know, except when he/she comes from that time and +developed a graphical vt100 emulator at that time. + +One goal of st is to only support what is really needed. When you en‐ +counter a sequence which you really need, implement it. But while you +are at it, do not add the other cruft you might encounter while sneek‐ +ing at other terminal emulators. History has bloated them and there is +no real evidence that most of the sequences are used today. + + +Christoph Lohmann <20h@r-36.net> +2012-09-13T07:00:36.081271045+02:00 + diff --git a/src/sxmo-st/LICENSE b/src/sxmo-st/LICENSE new file mode 100644 index 0000000..d80eb47 --- /dev/null +++ b/src/sxmo-st/LICENSE @@ -0,0 +1,34 @@ +MIT/X Consortium License + +© 2014-2020 Hiltjo Posthuma +© 2018 Devin J. Pohly +© 2014-2017 Quentin Rameau +© 2009-2012 Aurélien APTEL +© 2008-2017 Anselm R Garbe +© 2012-2017 Roberto E. Vargas Caballero +© 2012-2016 Christoph Lohmann <20h at r-36 dot net> +© 2013 Eon S. Jeon +© 2013 Alexander Sedov +© 2013 Mark Edgar +© 2013-2014 Eric Pruitt +© 2013 Michael Forney +© 2013-2014 Markus Teich +© 2014-2015 Laslo Hunhold + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/sxmo-st/Makefile b/src/sxmo-st/Makefile new file mode 100644 index 0000000..0996124 --- /dev/null +++ b/src/sxmo-st/Makefile @@ -0,0 +1,58 @@ +# st - simple terminal +# See LICENSE file for copyright and license details. +.POSIX: + +include config.mk + +SRC = st.c x.c hb.c +OBJ = $(SRC:.c=.o) + +all: options st + +options: + @echo st build options: + @echo "CFLAGS = $(STCFLAGS)" + @echo "LDFLAGS = $(STLDFLAGS)" + @echo "CC = $(CC)" + +config.h: + cp config.def.h config.h + +.c.o: + $(CC) $(STCFLAGS) -c $< + +st.o: config.h st.h win.h +x.o: arg.h config.h st.h win.h hb.h +hb.o: st.h hb.h + +$(OBJ): config.h config.mk + +st: $(OBJ) + $(CC) -o $@ $(OBJ) $(STLDFLAGS) + +clean: + rm -f st $(OBJ) st-$(VERSION).tar.gz + +dist: clean + mkdir -p st-$(VERSION) + cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\ + config.def.h st.info st.1 arg.h st.h win.h $(SRC)\ + st-$(VERSION) + tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz + rm -rf st-$(VERSION) + +install: st + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f st $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/st + mkdir -p $(DESTDIR)$(MANPREFIX)/man1 + sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1 + chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1 + tic -sx st.info + @echo Please see the README file regarding the terminfo entry of st. + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/st + rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1 + +.PHONY: all options clean dist install uninstall diff --git a/src/sxmo-st/README.md b/src/sxmo-st/README.md new file mode 100644 index 0000000..159e1fc --- /dev/null +++ b/src/sxmo-st/README.md @@ -0,0 +1,37 @@ +st - simple terminal +-------------------- + +[![builds.sr.ht status](https://builds.sr.ht/~mil/sxmo-st.svg)](https://builds.sr.ht/~mil/sxmo-st?) + +st is a simple terminal emulator for X which sucks less. + + +Requirements +------------ +In order to build st you need the Xlib header files. + + +Installation +------------ +Edit config.mk to match your local setup (st is installed into +the /usr/local namespace by default). + +Afterwards enter the following command to build and install st (if +necessary as root): + + make clean install + + +Running st +---------- +If you did not install st with make clean install, you must compile +the st terminfo entry with the following command: + + tic -sx st.info + +See the man page for additional details. + +Credits +------- +Based on Aurélien APTEL bt source code. + diff --git a/src/sxmo-st/TODO b/src/sxmo-st/TODO new file mode 100644 index 0000000..5f74cd5 --- /dev/null +++ b/src/sxmo-st/TODO @@ -0,0 +1,28 @@ +vt emulation +------------ + +* double-height support + +code & interface +---------------- + +* add a simple way to do multiplexing + +drawing +------- +* add diacritics support to xdraws() + * switch to a suckless font drawing library +* make the font cache simpler +* add better support for brightening of the upper colors + +bugs +---- + +* fix shift up/down (shift selection in emacs) +* remove DEC test sequence when appropriate + +misc +---- + + $ grep -nE 'XXX|TODO' st.c + diff --git a/src/sxmo-st/arg.h b/src/sxmo-st/arg.h new file mode 100644 index 0000000..a22e019 --- /dev/null +++ b/src/sxmo-st/arg.h @@ -0,0 +1,50 @@ +/* + * Copy me if you can. + * by 20h + */ + +#ifndef ARG_H__ +#define ARG_H__ + +extern char *argv0; + +/* use main(int argc, char *argv[]) */ +#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ + argv[0] && argv[0][0] == '-'\ + && argv[0][1];\ + argc--, argv++) {\ + char argc_;\ + char **argv_;\ + int brk_;\ + if (argv[0][1] == '-' && argv[0][2] == '\0') {\ + argv++;\ + argc--;\ + break;\ + }\ + int i_;\ + for (i_ = 1, brk_ = 0, argv_ = argv;\ + argv[0][i_] && !brk_;\ + i_++) {\ + if (argv_ != argv)\ + break;\ + argc_ = argv[0][i_];\ + switch (argc_) + +#define ARGEND }\ + } + +#define ARGC() argc_ + +#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\ + ((x), abort(), (char *)0) :\ + (brk_ = 1, (argv[0][i_+1] != '\0')?\ + (&argv[0][i_+1]) :\ + (argc--, argv++, argv[0]))) + +#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\ + (char *)0 :\ + (brk_ = 1, (argv[0][i_+1] != '\0')?\ + (&argv[0][i_+1]) :\ + (argc--, argv++, argv[0]))) + +#endif diff --git a/src/sxmo-st/config.def.h b/src/sxmo-st/config.def.h new file mode 100644 index 0000000..300cd78 --- /dev/null +++ b/src/sxmo-st/config.def.h @@ -0,0 +1,520 @@ +/* See LICENSE file for copyright and license details. */ + +/* + * appearance + * + * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html + */ +static char *font = "Fira Code:pixelsize=15:style=Regular:antialias=true:autohint=true"; +static int borderpx = 2; + +/* + * What program is execed by st depends of these precedence rules: + * 1: program passed with -e + * 2: scroll and/or utmp + * 3: SHELL environment variable + * 4: value of shell in /etc/passwd + * 5: value of shell in config.h + */ +static char *shell = "/bin/sh"; +char *utmp = NULL; +/* scroll program: to enable use a string like "scroll" */ +char *scroll = NULL; +char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400"; + +/* identification sequence returned in DA and DECID */ +char *vtiden = "\033[?6c"; + +/* Kerning / character bounding-box multipliers */ +static float cwscale = 1.0; +static float chscale = 1.0; + +/* + * word delimiter string + * + * More advanced example: L" `'\"()[]{}" + */ +wchar_t *worddelimiters = L" "; + +/* selection timeouts (in milliseconds) */ +static unsigned int doubleclicktimeout = 1000; +static unsigned int tripleclicktimeout = 2000; + +/* alt screens */ +int allowaltscreen = 1; + +/* allow certain non-interactive (insecure) window operations such as: + setting the clipboard text */ +int allowwindowops = 0; + +/* + * draw latency range in ms - from new content/keypress/etc until drawing. + * within this range, st draws when content stops arriving (idle). mostly it's + * near minlatency, but it waits longer for slow updates to avoid partial draw. + * low minlatency will tear/flicker more, as it can "detect" idle too early. + */ +static double minlatency = 8; +static double maxlatency = 33; + +/* + * blinking timeout (set to 0 to disable blinking) for the terminal blinking + * attribute. + */ +static unsigned int blinktimeout = 800; + +/* + * thickness of underline and bar cursors + */ +static unsigned int cursorthickness = 2; + +/* + * bell volume. It must be a value between -100 and 100. Use 0 for disabling + * it + */ +static int bellvolume = 0; + +/* default TERM value */ +char *termname = "st-256color"; + +/* + * spaces per tab + * + * When you are changing this value, don't forget to adapt the »it« value in + * the st.info and appropriately install the st.info in the environment where + * you use this st version. + * + * it#$tabspaces, + * + * Secondly make sure your kernel is not expanding tabs. When running `stty + * -a` »tab0« should appear. You can tell the terminal to not expand tabs by + * running following command: + * + * stty tabs + */ +unsigned int tabspaces = 8; + +/* Terminal colors (16 first used in escape sequence) */ +static const char *colorname[] = { + /* 8 normal colors */ + "black", + "red3", + "green3", + "yellow3", + "blue2", + "magenta3", + "cyan3", + "gray90", + + /* 8 bright colors */ + "gray50", + "red", + "green", + "yellow", + "#5c5cff", + "magenta", + "cyan", + "white", + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", +}; + + +/* + * Default colors (colorname index) + * foreground, background, cursor, reverse cursor + */ +unsigned int defaultfg = 7; +unsigned int defaultbg = 0; +static unsigned int defaultcs = 256; +static unsigned int defaultrcs = 257; + +/* + * Default shape of cursor + * 2: Block ("█") + * 4: Underline ("_") + * 6: Bar ("|") + * 7: Snowman ("☃") + */ +static unsigned int cursorshape = 2; + +/* + * Default columns and rows numbers + */ + +static unsigned int cols = 80; +static unsigned int rows = 24; + +/* + * Default colour and shape of the mouse cursor + */ +static unsigned int mouseshape = XC_xterm; +static unsigned int mousefg = 7; +static unsigned int mousebg = 0; + +/* + * Color used to display font attributes when fontconfig selected a font which + * doesn't match the ones requested. + */ +static unsigned int defaultattr = 11; + +/* + * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set). + * Note that if you want to use ShiftMask with selmasks, set this to an other + * modifier, set to 0 to not use it. + */ +static uint forcemousemod = ShiftMask; + +/* + * Xresources preferences to load at startup + */ +ResourcePref resources[] = { + { "font", STRING, &font }, + { "color0", STRING, &colorname[0] }, + { "color1", STRING, &colorname[1] }, + { "color2", STRING, &colorname[2] }, + { "color3", STRING, &colorname[3] }, + { "color4", STRING, &colorname[4] }, + { "color5", STRING, &colorname[5] }, + { "color6", STRING, &colorname[6] }, + { "color7", STRING, &colorname[7] }, + { "color8", STRING, &colorname[8] }, + { "color9", STRING, &colorname[9] }, + { "color10", STRING, &colorname[10] }, + { "color11", STRING, &colorname[11] }, + { "color12", STRING, &colorname[12] }, + { "color13", STRING, &colorname[13] }, + { "color14", STRING, &colorname[14] }, + { "color15", STRING, &colorname[15] }, + { "background", STRING, &colorname[256] }, + { "foreground", STRING, &colorname[257] }, + { "cursorColor", STRING, &colorname[258] }, + { "termname", STRING, &termname }, + { "shell", STRING, &shell }, + { "blinktimeout", INTEGER, &blinktimeout }, + { "bellvolume", INTEGER, &bellvolume }, + { "tabspaces", INTEGER, &tabspaces }, + { "borderpx", INTEGER, &borderpx }, + { "cwscale", FLOAT, &cwscale }, + { "chscale", FLOAT, &chscale }, +}; + +/* + * Internal mouse shortcuts. + * Beware that overloading Button1 will disable the selection. + */ +static MouseShortcut mshortcuts[] = { + /* mask button function argument release */ + { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, + { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, + { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, + { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, + { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} }, +}; + +/* Internal keyboard shortcuts. */ +#define MODKEY Mod1Mask +#define TERMMOD (ControlMask|ShiftMask) + +static char *externalpipe_typecomplete[] = { "/bin/sh", "-c", "sxmo_pipecomplete.sh type $0", NULL }; +static char *externalpipe_copycomplete[] = { "/bin/sh", "-c", "sxmo_pipecomplete.sh copy $0", NULL }; + +static Shortcut shortcuts[] = { + /* mask keysym function argument */ + { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, + { ControlMask, XK_Print, toggleprinter, {.i = 0} }, + { ShiftMask, XK_Print, printscreen, {.i = 0} }, + { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, + { TERMMOD, XK_Prior, zoom, {.f = +1} }, + { TERMMOD, XK_Next, zoom, {.f = -1} }, + { TERMMOD, XK_Home, zoomreset, {.f = 0} }, + { TERMMOD, XK_C, clipcopy, {.i = 0} }, + { TERMMOD, XK_V, clippaste, {.i = 0} }, + { TERMMOD, XK_Y, selpaste, {.i = 0} }, + { ShiftMask, XK_Insert, selpaste, {.i = 0} }, + { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + + { TERMMOD, XK_S, toggleselectionmode, {.i = 0} }, + + { TERMMOD, XK_B, kscrollup, {.i = -1} }, + { TERMMOD, XK_F, kscrolldown, {.i = -1} }, + { TERMMOD, XK_X, invert, { } }, + { TERMMOD, XK_plus, zoom, {.f = +1} }, + { TERMMOD, XK_underscore, zoom, {.f = -1} }, + + { TERMMOD, XK_U, externalpipe, { .v = externalpipe_typecomplete } }, + { TERMMOD, XK_I, externalpipe, { .v = externalpipe_copycomplete } }, +}; + +/* + * Special keys (change & recompile st.info accordingly) + * + * Mask value: + * * Use XK_ANY_MOD to match the key no matter modifiers state + * * Use XK_NO_MOD to match the key alone (no modifiers) + * appkey value: + * * 0: no value + * * > 0: keypad application mode enabled + * * = 2: term.numlock = 1 + * * < 0: keypad application mode disabled + * appcursor value: + * * 0: no value + * * > 0: cursor application mode enabled + * * < 0: cursor application mode disabled + * + * Be careful with the order of the definitions because st searches in + * this table sequentially, so any XK_ANY_MOD must be in the last + * position for a key. + */ + +/* + * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF) + * to be mapped below, add them to this array. + */ +static KeySym mappedkeys[] = { -1 }; + +/* + * State bits to ignore when matching key or button events. By default, + * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored. + */ +static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; + +/* + * This is the huge key array which defines all compatibility to the Linux + * world. Please decide about changes wisely. + */ +static Key key[] = { + /* keysym mask string appkey appcursor */ + { XK_KP_Home, ShiftMask, "\033[2J", 0, -1}, + { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1}, + { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1}, + { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1}, + { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0}, + { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1}, + { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1}, + { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0}, + { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1}, + { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1}, + { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0}, + { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1}, + { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1}, + { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0}, + { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1}, + { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1}, + { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0}, + { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, + { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0}, + { XK_KP_End, ControlMask, "\033[J", -1, 0}, + { XK_KP_End, ControlMask, "\033[1;5F", +1, 0}, + { XK_KP_End, ShiftMask, "\033[K", -1, 0}, + { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0}, + { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0}, + { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0}, + { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0}, + { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0}, + { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0}, + { XK_KP_Insert, ControlMask, "\033[L", -1, 0}, + { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, + { XK_KP_Delete, ControlMask, "\033[M", -1, 0}, + { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0}, + { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0}, + { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, + { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0}, + { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0}, + { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0}, + { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0}, + { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0}, + { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0}, + { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0}, + { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0}, + { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0}, + { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0}, + { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0}, + { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0}, + { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0}, + { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0}, + { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0}, + { XK_Up, ShiftMask, "\033[1;2A", 0, 0}, + { XK_Up, Mod1Mask, "\033[1;3A", 0, 0}, + { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0}, + { XK_Up, ControlMask, "\033[1;5A", 0, 0}, + { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0}, + { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0}, + { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0}, + { XK_Up, XK_ANY_MOD, "\033[A", 0, -1}, + { XK_Up, XK_ANY_MOD, "\033OA", 0, +1}, + { XK_Down, ShiftMask, "\033[1;2B", 0, 0}, + { XK_Down, Mod1Mask, "\033[1;3B", 0, 0}, + { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0}, + { XK_Down, ControlMask, "\033[1;5B", 0, 0}, + { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0}, + { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0}, + { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0}, + { XK_Down, XK_ANY_MOD, "\033[B", 0, -1}, + { XK_Down, XK_ANY_MOD, "\033OB", 0, +1}, + { XK_Left, ShiftMask, "\033[1;2D", 0, 0}, + { XK_Left, Mod1Mask, "\033[1;3D", 0, 0}, + { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0}, + { XK_Left, ControlMask, "\033[1;5D", 0, 0}, + { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0}, + { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0}, + { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0}, + { XK_Left, XK_ANY_MOD, "\033[D", 0, -1}, + { XK_Left, XK_ANY_MOD, "\033OD", 0, +1}, + { XK_Right, ShiftMask, "\033[1;2C", 0, 0}, + { XK_Right, Mod1Mask, "\033[1;3C", 0, 0}, + { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0}, + { XK_Right, ControlMask, "\033[1;5C", 0, 0}, + { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0}, + { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0}, + { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0}, + { XK_Right, XK_ANY_MOD, "\033[C", 0, -1}, + { XK_Right, XK_ANY_MOD, "\033OC", 0, +1}, + { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0}, + { XK_Return, Mod1Mask, "\033\r", 0, 0}, + { XK_Return, XK_ANY_MOD, "\r", 0, 0}, + { XK_Insert, ShiftMask, "\033[4l", -1, 0}, + { XK_Insert, ShiftMask, "\033[2;2~", +1, 0}, + { XK_Insert, ControlMask, "\033[L", -1, 0}, + { XK_Insert, ControlMask, "\033[2;5~", +1, 0}, + { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, + { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, + { XK_Delete, ControlMask, "\033[M", -1, 0}, + { XK_Delete, ControlMask, "\033[3;5~", +1, 0}, + { XK_Delete, ShiftMask, "\033[2K", -1, 0}, + { XK_Delete, ShiftMask, "\033[3;2~", +1, 0}, + { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0}, + { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, + { XK_BackSpace, XK_NO_MOD, "\177", 0, 0}, + { XK_BackSpace, Mod1Mask, "\033\177", 0, 0}, + { XK_Home, ShiftMask, "\033[2J", 0, -1}, + { XK_Home, ShiftMask, "\033[1;2H", 0, +1}, + { XK_Home, XK_ANY_MOD, "\033[H", 0, -1}, + { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1}, + { XK_End, ControlMask, "\033[J", -1, 0}, + { XK_End, ControlMask, "\033[1;5F", +1, 0}, + { XK_End, ShiftMask, "\033[K", -1, 0}, + { XK_End, ShiftMask, "\033[1;2F", +1, 0}, + { XK_End, XK_ANY_MOD, "\033[4~", 0, 0}, + { XK_Prior, ControlMask, "\033[5;5~", 0, 0}, + { XK_Prior, ShiftMask, "\033[5;2~", 0, 0}, + { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, + { XK_Next, ControlMask, "\033[6;5~", 0, 0}, + { XK_Next, ShiftMask, "\033[6;2~", 0, 0}, + { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0}, + { XK_F1, XK_NO_MOD, "\033OP" , 0, 0}, + { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0}, + { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0}, + { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0}, + { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0}, + { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0}, + { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0}, + { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0}, + { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0}, + { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0}, + { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0}, + { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0}, + { XK_F3, XK_NO_MOD, "\033OR" , 0, 0}, + { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0}, + { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0}, + { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0}, + { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0}, + { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0}, + { XK_F4, XK_NO_MOD, "\033OS" , 0, 0}, + { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0}, + { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0}, + { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0}, + { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0}, + { XK_F5, XK_NO_MOD, "\033[15~", 0, 0}, + { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0}, + { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0}, + { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0}, + { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0}, + { XK_F6, XK_NO_MOD, "\033[17~", 0, 0}, + { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0}, + { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0}, + { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0}, + { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0}, + { XK_F7, XK_NO_MOD, "\033[18~", 0, 0}, + { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0}, + { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0}, + { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0}, + { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0}, + { XK_F8, XK_NO_MOD, "\033[19~", 0, 0}, + { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0}, + { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0}, + { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0}, + { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0}, + { XK_F9, XK_NO_MOD, "\033[20~", 0, 0}, + { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0}, + { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0}, + { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0}, + { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0}, + { XK_F10, XK_NO_MOD, "\033[21~", 0, 0}, + { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0}, + { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0}, + { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0}, + { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0}, + { XK_F11, XK_NO_MOD, "\033[23~", 0, 0}, + { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0}, + { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0}, + { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0}, + { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0}, + { XK_F12, XK_NO_MOD, "\033[24~", 0, 0}, + { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0}, + { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0}, + { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0}, + { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0}, + { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0}, + { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0}, + { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0}, + { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0}, + { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0}, + { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0}, + { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0}, + { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0}, + { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0}, + { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0}, + { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0}, + { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0}, + { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0}, + { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0}, + { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0}, + { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0}, + { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0}, + { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0}, + { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0}, + { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0}, + { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0}, + { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0}, + { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0}, +}; + +/* + * Selection types' masks. + * Use the same masks as usual. + * Button1Mask is always unset, to make masks match between ButtonPress. + * ButtonRelease and MotionNotify. + * If no match is found, regular selection is used. + */ +static uint selmasks[] = { + [SEL_RECTANGULAR] = Mod1Mask, +}; + +/* + * Printable characters in ASCII, used to estimate the advance width + * of single wide characters. + */ +static char ascii_printable[] = + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~"; diff --git a/src/sxmo-st/config.h b/src/sxmo-st/config.h new file mode 100644 index 0000000..300cd78 --- /dev/null +++ b/src/sxmo-st/config.h @@ -0,0 +1,520 @@ +/* See LICENSE file for copyright and license details. */ + +/* + * appearance + * + * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html + */ +static char *font = "Fira Code:pixelsize=15:style=Regular:antialias=true:autohint=true"; +static int borderpx = 2; + +/* + * What program is execed by st depends of these precedence rules: + * 1: program passed with -e + * 2: scroll and/or utmp + * 3: SHELL environment variable + * 4: value of shell in /etc/passwd + * 5: value of shell in config.h + */ +static char *shell = "/bin/sh"; +char *utmp = NULL; +/* scroll program: to enable use a string like "scroll" */ +char *scroll = NULL; +char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400"; + +/* identification sequence returned in DA and DECID */ +char *vtiden = "\033[?6c"; + +/* Kerning / character bounding-box multipliers */ +static float cwscale = 1.0; +static float chscale = 1.0; + +/* + * word delimiter string + * + * More advanced example: L" `'\"()[]{}" + */ +wchar_t *worddelimiters = L" "; + +/* selection timeouts (in milliseconds) */ +static unsigned int doubleclicktimeout = 1000; +static unsigned int tripleclicktimeout = 2000; + +/* alt screens */ +int allowaltscreen = 1; + +/* allow certain non-interactive (insecure) window operations such as: + setting the clipboard text */ +int allowwindowops = 0; + +/* + * draw latency range in ms - from new content/keypress/etc until drawing. + * within this range, st draws when content stops arriving (idle). mostly it's + * near minlatency, but it waits longer for slow updates to avoid partial draw. + * low minlatency will tear/flicker more, as it can "detect" idle too early. + */ +static double minlatency = 8; +static double maxlatency = 33; + +/* + * blinking timeout (set to 0 to disable blinking) for the terminal blinking + * attribute. + */ +static unsigned int blinktimeout = 800; + +/* + * thickness of underline and bar cursors + */ +static unsigned int cursorthickness = 2; + +/* + * bell volume. It must be a value between -100 and 100. Use 0 for disabling + * it + */ +static int bellvolume = 0; + +/* default TERM value */ +char *termname = "st-256color"; + +/* + * spaces per tab + * + * When you are changing this value, don't forget to adapt the »it« value in + * the st.info and appropriately install the st.info in the environment where + * you use this st version. + * + * it#$tabspaces, + * + * Secondly make sure your kernel is not expanding tabs. When running `stty + * -a` »tab0« should appear. You can tell the terminal to not expand tabs by + * running following command: + * + * stty tabs + */ +unsigned int tabspaces = 8; + +/* Terminal colors (16 first used in escape sequence) */ +static const char *colorname[] = { + /* 8 normal colors */ + "black", + "red3", + "green3", + "yellow3", + "blue2", + "magenta3", + "cyan3", + "gray90", + + /* 8 bright colors */ + "gray50", + "red", + "green", + "yellow", + "#5c5cff", + "magenta", + "cyan", + "white", + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", +}; + + +/* + * Default colors (colorname index) + * foreground, background, cursor, reverse cursor + */ +unsigned int defaultfg = 7; +unsigned int defaultbg = 0; +static unsigned int defaultcs = 256; +static unsigned int defaultrcs = 257; + +/* + * Default shape of cursor + * 2: Block ("█") + * 4: Underline ("_") + * 6: Bar ("|") + * 7: Snowman ("☃") + */ +static unsigned int cursorshape = 2; + +/* + * Default columns and rows numbers + */ + +static unsigned int cols = 80; +static unsigned int rows = 24; + +/* + * Default colour and shape of the mouse cursor + */ +static unsigned int mouseshape = XC_xterm; +static unsigned int mousefg = 7; +static unsigned int mousebg = 0; + +/* + * Color used to display font attributes when fontconfig selected a font which + * doesn't match the ones requested. + */ +static unsigned int defaultattr = 11; + +/* + * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set). + * Note that if you want to use ShiftMask with selmasks, set this to an other + * modifier, set to 0 to not use it. + */ +static uint forcemousemod = ShiftMask; + +/* + * Xresources preferences to load at startup + */ +ResourcePref resources[] = { + { "font", STRING, &font }, + { "color0", STRING, &colorname[0] }, + { "color1", STRING, &colorname[1] }, + { "color2", STRING, &colorname[2] }, + { "color3", STRING, &colorname[3] }, + { "color4", STRING, &colorname[4] }, + { "color5", STRING, &colorname[5] }, + { "color6", STRING, &colorname[6] }, + { "color7", STRING, &colorname[7] }, + { "color8", STRING, &colorname[8] }, + { "color9", STRING, &colorname[9] }, + { "color10", STRING, &colorname[10] }, + { "color11", STRING, &colorname[11] }, + { "color12", STRING, &colorname[12] }, + { "color13", STRING, &colorname[13] }, + { "color14", STRING, &colorname[14] }, + { "color15", STRING, &colorname[15] }, + { "background", STRING, &colorname[256] }, + { "foreground", STRING, &colorname[257] }, + { "cursorColor", STRING, &colorname[258] }, + { "termname", STRING, &termname }, + { "shell", STRING, &shell }, + { "blinktimeout", INTEGER, &blinktimeout }, + { "bellvolume", INTEGER, &bellvolume }, + { "tabspaces", INTEGER, &tabspaces }, + { "borderpx", INTEGER, &borderpx }, + { "cwscale", FLOAT, &cwscale }, + { "chscale", FLOAT, &chscale }, +}; + +/* + * Internal mouse shortcuts. + * Beware that overloading Button1 will disable the selection. + */ +static MouseShortcut mshortcuts[] = { + /* mask button function argument release */ + { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, + { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, + { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, + { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, + { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} }, +}; + +/* Internal keyboard shortcuts. */ +#define MODKEY Mod1Mask +#define TERMMOD (ControlMask|ShiftMask) + +static char *externalpipe_typecomplete[] = { "/bin/sh", "-c", "sxmo_pipecomplete.sh type $0", NULL }; +static char *externalpipe_copycomplete[] = { "/bin/sh", "-c", "sxmo_pipecomplete.sh copy $0", NULL }; + +static Shortcut shortcuts[] = { + /* mask keysym function argument */ + { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, + { ControlMask, XK_Print, toggleprinter, {.i = 0} }, + { ShiftMask, XK_Print, printscreen, {.i = 0} }, + { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, + { TERMMOD, XK_Prior, zoom, {.f = +1} }, + { TERMMOD, XK_Next, zoom, {.f = -1} }, + { TERMMOD, XK_Home, zoomreset, {.f = 0} }, + { TERMMOD, XK_C, clipcopy, {.i = 0} }, + { TERMMOD, XK_V, clippaste, {.i = 0} }, + { TERMMOD, XK_Y, selpaste, {.i = 0} }, + { ShiftMask, XK_Insert, selpaste, {.i = 0} }, + { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + + { TERMMOD, XK_S, toggleselectionmode, {.i = 0} }, + + { TERMMOD, XK_B, kscrollup, {.i = -1} }, + { TERMMOD, XK_F, kscrolldown, {.i = -1} }, + { TERMMOD, XK_X, invert, { } }, + { TERMMOD, XK_plus, zoom, {.f = +1} }, + { TERMMOD, XK_underscore, zoom, {.f = -1} }, + + { TERMMOD, XK_U, externalpipe, { .v = externalpipe_typecomplete } }, + { TERMMOD, XK_I, externalpipe, { .v = externalpipe_copycomplete } }, +}; + +/* + * Special keys (change & recompile st.info accordingly) + * + * Mask value: + * * Use XK_ANY_MOD to match the key no matter modifiers state + * * Use XK_NO_MOD to match the key alone (no modifiers) + * appkey value: + * * 0: no value + * * > 0: keypad application mode enabled + * * = 2: term.numlock = 1 + * * < 0: keypad application mode disabled + * appcursor value: + * * 0: no value + * * > 0: cursor application mode enabled + * * < 0: cursor application mode disabled + * + * Be careful with the order of the definitions because st searches in + * this table sequentially, so any XK_ANY_MOD must be in the last + * position for a key. + */ + +/* + * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF) + * to be mapped below, add them to this array. + */ +static KeySym mappedkeys[] = { -1 }; + +/* + * State bits to ignore when matching key or button events. By default, + * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored. + */ +static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; + +/* + * This is the huge key array which defines all compatibility to the Linux + * world. Please decide about changes wisely. + */ +static Key key[] = { + /* keysym mask string appkey appcursor */ + { XK_KP_Home, ShiftMask, "\033[2J", 0, -1}, + { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1}, + { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1}, + { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1}, + { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0}, + { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1}, + { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1}, + { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0}, + { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1}, + { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1}, + { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0}, + { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1}, + { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1}, + { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0}, + { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1}, + { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1}, + { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0}, + { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, + { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0}, + { XK_KP_End, ControlMask, "\033[J", -1, 0}, + { XK_KP_End, ControlMask, "\033[1;5F", +1, 0}, + { XK_KP_End, ShiftMask, "\033[K", -1, 0}, + { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0}, + { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0}, + { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0}, + { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0}, + { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0}, + { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0}, + { XK_KP_Insert, ControlMask, "\033[L", -1, 0}, + { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, + { XK_KP_Delete, ControlMask, "\033[M", -1, 0}, + { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0}, + { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0}, + { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, + { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0}, + { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0}, + { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0}, + { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0}, + { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0}, + { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0}, + { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0}, + { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0}, + { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0}, + { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0}, + { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0}, + { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0}, + { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0}, + { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0}, + { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0}, + { XK_Up, ShiftMask, "\033[1;2A", 0, 0}, + { XK_Up, Mod1Mask, "\033[1;3A", 0, 0}, + { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0}, + { XK_Up, ControlMask, "\033[1;5A", 0, 0}, + { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0}, + { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0}, + { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0}, + { XK_Up, XK_ANY_MOD, "\033[A", 0, -1}, + { XK_Up, XK_ANY_MOD, "\033OA", 0, +1}, + { XK_Down, ShiftMask, "\033[1;2B", 0, 0}, + { XK_Down, Mod1Mask, "\033[1;3B", 0, 0}, + { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0}, + { XK_Down, ControlMask, "\033[1;5B", 0, 0}, + { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0}, + { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0}, + { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0}, + { XK_Down, XK_ANY_MOD, "\033[B", 0, -1}, + { XK_Down, XK_ANY_MOD, "\033OB", 0, +1}, + { XK_Left, ShiftMask, "\033[1;2D", 0, 0}, + { XK_Left, Mod1Mask, "\033[1;3D", 0, 0}, + { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0}, + { XK_Left, ControlMask, "\033[1;5D", 0, 0}, + { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0}, + { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0}, + { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0}, + { XK_Left, XK_ANY_MOD, "\033[D", 0, -1}, + { XK_Left, XK_ANY_MOD, "\033OD", 0, +1}, + { XK_Right, ShiftMask, "\033[1;2C", 0, 0}, + { XK_Right, Mod1Mask, "\033[1;3C", 0, 0}, + { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0}, + { XK_Right, ControlMask, "\033[1;5C", 0, 0}, + { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0}, + { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0}, + { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0}, + { XK_Right, XK_ANY_MOD, "\033[C", 0, -1}, + { XK_Right, XK_ANY_MOD, "\033OC", 0, +1}, + { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0}, + { XK_Return, Mod1Mask, "\033\r", 0, 0}, + { XK_Return, XK_ANY_MOD, "\r", 0, 0}, + { XK_Insert, ShiftMask, "\033[4l", -1, 0}, + { XK_Insert, ShiftMask, "\033[2;2~", +1, 0}, + { XK_Insert, ControlMask, "\033[L", -1, 0}, + { XK_Insert, ControlMask, "\033[2;5~", +1, 0}, + { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, + { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, + { XK_Delete, ControlMask, "\033[M", -1, 0}, + { XK_Delete, ControlMask, "\033[3;5~", +1, 0}, + { XK_Delete, ShiftMask, "\033[2K", -1, 0}, + { XK_Delete, ShiftMask, "\033[3;2~", +1, 0}, + { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0}, + { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, + { XK_BackSpace, XK_NO_MOD, "\177", 0, 0}, + { XK_BackSpace, Mod1Mask, "\033\177", 0, 0}, + { XK_Home, ShiftMask, "\033[2J", 0, -1}, + { XK_Home, ShiftMask, "\033[1;2H", 0, +1}, + { XK_Home, XK_ANY_MOD, "\033[H", 0, -1}, + { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1}, + { XK_End, ControlMask, "\033[J", -1, 0}, + { XK_End, ControlMask, "\033[1;5F", +1, 0}, + { XK_End, ShiftMask, "\033[K", -1, 0}, + { XK_End, ShiftMask, "\033[1;2F", +1, 0}, + { XK_End, XK_ANY_MOD, "\033[4~", 0, 0}, + { XK_Prior, ControlMask, "\033[5;5~", 0, 0}, + { XK_Prior, ShiftMask, "\033[5;2~", 0, 0}, + { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, + { XK_Next, ControlMask, "\033[6;5~", 0, 0}, + { XK_Next, ShiftMask, "\033[6;2~", 0, 0}, + { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0}, + { XK_F1, XK_NO_MOD, "\033OP" , 0, 0}, + { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0}, + { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0}, + { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0}, + { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0}, + { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0}, + { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0}, + { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0}, + { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0}, + { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0}, + { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0}, + { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0}, + { XK_F3, XK_NO_MOD, "\033OR" , 0, 0}, + { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0}, + { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0}, + { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0}, + { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0}, + { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0}, + { XK_F4, XK_NO_MOD, "\033OS" , 0, 0}, + { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0}, + { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0}, + { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0}, + { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0}, + { XK_F5, XK_NO_MOD, "\033[15~", 0, 0}, + { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0}, + { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0}, + { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0}, + { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0}, + { XK_F6, XK_NO_MOD, "\033[17~", 0, 0}, + { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0}, + { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0}, + { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0}, + { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0}, + { XK_F7, XK_NO_MOD, "\033[18~", 0, 0}, + { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0}, + { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0}, + { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0}, + { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0}, + { XK_F8, XK_NO_MOD, "\033[19~", 0, 0}, + { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0}, + { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0}, + { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0}, + { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0}, + { XK_F9, XK_NO_MOD, "\033[20~", 0, 0}, + { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0}, + { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0}, + { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0}, + { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0}, + { XK_F10, XK_NO_MOD, "\033[21~", 0, 0}, + { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0}, + { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0}, + { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0}, + { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0}, + { XK_F11, XK_NO_MOD, "\033[23~", 0, 0}, + { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0}, + { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0}, + { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0}, + { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0}, + { XK_F12, XK_NO_MOD, "\033[24~", 0, 0}, + { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0}, + { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0}, + { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0}, + { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0}, + { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0}, + { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0}, + { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0}, + { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0}, + { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0}, + { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0}, + { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0}, + { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0}, + { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0}, + { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0}, + { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0}, + { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0}, + { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0}, + { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0}, + { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0}, + { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0}, + { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0}, + { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0}, + { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0}, + { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0}, + { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0}, + { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0}, + { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0}, +}; + +/* + * Selection types' masks. + * Use the same masks as usual. + * Button1Mask is always unset, to make masks match between ButtonPress. + * ButtonRelease and MotionNotify. + * If no match is found, regular selection is used. + */ +static uint selmasks[] = { + [SEL_RECTANGULAR] = Mod1Mask, +}; + +/* + * Printable characters in ASCII, used to estimate the advance width + * of single wide characters. + */ +static char ascii_printable[] = + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~"; diff --git a/src/sxmo-st/config.mk b/src/sxmo-st/config.mk new file mode 100644 index 0000000..5364926 --- /dev/null +++ b/src/sxmo-st/config.mk @@ -0,0 +1,37 @@ +# st version +VERSION = 0.8.4.1 + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = $(PREFIX)/share/man + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +PKG_CONFIG = pkg-config + +# includes and libs +INCS = -I$(X11INC) \ + `$(PKG_CONFIG) --cflags fontconfig` \ + `$(PKG_CONFIG) --cflags freetype2` \ + `$(PKG_CONFIG) --cflags harfbuzz` +LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ + `$(PKG_CONFIG) --libs fontconfig` \ + `$(PKG_CONFIG) --libs freetype2` \ + `$(PKG_CONFIG) --libs harfbuzz` + +# flags +STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 +STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS) +STLDFLAGS = $(LIBS) $(LDFLAGS) + +# OpenBSD: +#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE +#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \ +# `$(PKG_CONFIG) --libs fontconfig` \ +# `$(PKG_CONFIG) --libs freetype2` + +# compiler and linker +# CC = c99 diff --git a/src/sxmo-st/hb.c b/src/sxmo-st/hb.c new file mode 100644 index 0000000..445ccda --- /dev/null +++ b/src/sxmo-st/hb.c @@ -0,0 +1,140 @@ +#include +#include +#include +#include +#include +#include + +#include "st.h" +#include "hb.h" + +#define FEATURE(c1,c2,c3,c4) { .tag = HB_TAG(c1,c2,c3,c4), .value = 1, .start = HB_FEATURE_GLOBAL_START, .end = HB_FEATURE_GLOBAL_END } + +typedef struct { + XftFont *match; + hb_font_t *font; +} HbFontMatch; + +static int hbfontslen = 0; +static HbFontMatch *hbfontcache = NULL; +static hb_buffer_t *hbbuffer = NULL; + +static hb_feature_t features[] = { + FEATURE('l','i','g','a'), + FEATURE('c','a','l','t'), + FEATURE('c','l','i','g'), + FEATURE('d','l','i','g'), +}; + +void +hbunloadfonts(void) +{ + for (int i = 0; i < hbfontslen; i++) { + hb_font_destroy(hbfontcache[i].font); + XftUnlockFace(hbfontcache[i].match); + } + if (hbfontcache != NULL) { + free(hbfontcache); + hbfontcache = NULL; + } + hbfontslen = 0; +} + +static hb_font_t * +hbfindfont(XftFont *match) +{ + for (int i = 0; i < hbfontslen; i++) { + if (hbfontcache[i].match == match) + return hbfontcache[i].font; + } + + hbfontcache = xrealloc(hbfontcache, sizeof(HbFontMatch) * (hbfontslen + 1)); + FT_Face face = XftLockFace(match); + hb_font_t *font = hb_ft_font_create(face, NULL); + if (font == NULL) + die("Failed to load HarfBuzz font."); + + hbfontcache[hbfontslen].match = match; + hbfontcache[hbfontslen].font = font; + hbfontslen += 1; + + return font; +} + +static void +hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length) +{ + hb_font_t *font = hbfindfont(xfont); + if (font == NULL) + return; + + if (hbbuffer == NULL) + hbbuffer = hb_buffer_create(); + hb_buffer_reset(hbbuffer); + hb_buffer_set_direction(hbbuffer, HB_DIRECTION_LTR); + hb_buffer_set_script(hbbuffer, HB_SCRIPT_LATIN); + + for (int i = start; i < (start + length); i++) { + Rune rune = string[i].u; + if (string[i].mode & ATTR_WDUMMY) + rune = 0x0020; + hb_buffer_add_codepoints(hbbuffer, &rune, 1, 0, 1); + } + + hb_shape(font, hbbuffer, features, sizeof(features) / sizeof(hb_feature_t)); + + unsigned int glyph_count = 0; + hb_glyph_info_t *info = hb_buffer_get_glyph_infos(hbbuffer, &glyph_count); + + if ((int)glyph_count == length) { + for (int i = 0; i < length; i++) + codepoints[start + i] = info[i].codepoint; + } else if (glyph_count > 0 && (int)glyph_count < length) { + for (int i = 0; i < length; i++) + codepoints[start + i] = 0; + for (unsigned int g = 0; g < glyph_count; g++) { + uint32_t c = info[g].cluster; + if ((int)c < length) + codepoints[start + c] = info[g].codepoint; + } + } +} + +void +hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y) +{ + int start = 0, length = 1, gstart = 0; + hb_codepoint_t *codepoints = calloc(len, sizeof(hb_codepoint_t)); + if (!codepoints) + return; + + for (int idx = 1, specidx = 1; idx < (int)len; idx++) { + if (glyphs[idx].mode & ATTR_WDUMMY) { + length += 1; + continue; + } + + if (specs[specidx].font != specs[start].font || ATTRCMP(glyphs[gstart], glyphs[idx])) { + hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length); + length = 1; + start = specidx; + gstart = idx; + } else { + length += 1; + } + + specidx++; + } + + hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length); + + for (int i = 0, specidx = 0; i < (int)len; i++) { + if (glyphs[i].mode & ATTR_WDUMMY) + continue; + if (codepoints[i] != 0 && codepoints[i] != specs[specidx].glyph) + specs[specidx].glyph = codepoints[i]; + specidx++; + } + + free(codepoints); +} diff --git a/src/sxmo-st/hb.h b/src/sxmo-st/hb.h new file mode 100644 index 0000000..2c1d33f --- /dev/null +++ b/src/sxmo-st/hb.h @@ -0,0 +1,6 @@ +#include +#include +#include + +void hbunloadfonts(void); +void hbtransform(XftGlyphFontSpec *, const Glyph *, size_t, int, int); diff --git a/src/sxmo-st/st.1 b/src/sxmo-st/st.1 new file mode 100644 index 0000000..39120b4 --- /dev/null +++ b/src/sxmo-st/st.1 @@ -0,0 +1,177 @@ +.TH ST 1 st\-VERSION +.SH NAME +st \- simple terminal +.SH SYNOPSIS +.B st +.RB [ \-aiv ] +.RB [ \-c +.IR class ] +.RB [ \-f +.IR font ] +.RB [ \-g +.IR geometry ] +.RB [ \-n +.IR name ] +.RB [ \-o +.IR iofile ] +.RB [ \-T +.IR title ] +.RB [ \-t +.IR title ] +.RB [ \-l +.IR line ] +.RB [ \-w +.IR windowid ] +.RB [[ \-e ] +.IR command +.RI [ arguments ...]] +.PP +.B st +.RB [ \-aiv ] +.RB [ \-c +.IR class ] +.RB [ \-f +.IR font ] +.RB [ \-g +.IR geometry ] +.RB [ \-n +.IR name ] +.RB [ \-o +.IR iofile ] +.RB [ \-T +.IR title ] +.RB [ \-t +.IR title ] +.RB [ \-w +.IR windowid ] +.RB \-l +.IR line +.RI [ stty_args ...] +.SH DESCRIPTION +.B st +is a simple terminal emulator. +.SH OPTIONS +.TP +.B \-a +disable alternate screens in terminal +.TP +.BI \-c " class" +defines the window class (default $TERM). +.TP +.BI \-f " font" +defines the +.I font +to use when st is run. +.TP +.BI \-g " geometry" +defines the X11 geometry string. +The form is [=][{xX}][{+-}{+-}]. See +.BR XParseGeometry (3) +for further details. +.TP +.B \-i +will fixate the position given with the -g option. +.TP +.BI \-n " name" +defines the window instance name (default $TERM). +.TP +.BI \-o " iofile" +writes all the I/O to +.I iofile. +This feature is useful when recording st sessions. A value of "-" means +standard output. +.TP +.BI \-T " title" +defines the window title (default 'st'). +.TP +.BI \-t " title" +defines the window title (default 'st'). +.TP +.BI \-w " windowid" +embeds st within the window identified by +.I windowid +.TP +.BI \-l " line" +use a tty +.I line +instead of a pseudo terminal. +.I line +should be a (pseudo-)serial device (e.g. /dev/ttyS0 on Linux for serial port +0). +When this flag is given +remaining arguments are used as flags for +.BR stty(1). +By default st initializes the serial line to 8 bits, no parity, 1 stop bit +and a 38400 baud rate. The speed is set by appending it as last argument +(e.g. 'st -l /dev/ttyS0 115200'). Arguments before the last one are +.BR stty(1) +flags. If you want to set odd parity on 115200 baud use for example 'st -l +/dev/ttyS0 parenb parodd 115200'. Set the number of bits by using for +example 'st -l /dev/ttyS0 cs7 115200'. See +.BR stty(1) +for more arguments and cases. +.TP +.B \-v +prints version information to stderr, then exits. +.TP +.BI \-e " command " [ " arguments " "... ]" +st executes +.I command +instead of the shell. If this is used it +.B must be the last option +on the command line, as in xterm / rxvt. +This option is only intended for compatibility, +and all the remaining arguments are used as a command +even without it. +.SH SHORTCUTS +.TP +.B Break +Send a break in the serial line. +Break key is obtained in PC keyboards +pressing at the same time control and pause. +.TP +.B Ctrl-Print Screen +Toggle if st should print to the +.I iofile. +.TP +.B Shift-Print Screen +Print the full screen to the +.I iofile. +.TP +.B Print Screen +Print the selection to the +.I iofile. +.TP +.B Ctrl-Shift-Page Up +Increase font size. +.TP +.B Ctrl-Shift-Page Down +Decrease font size. +.TP +.B Ctrl-Shift-Home +Reset to default font size. +.TP +.B Ctrl-Shift-y +Paste from primary selection (middle mouse button). +.TP +.B Ctrl-Shift-c +Copy the selected text to the clipboard selection. +.TP +.B Ctrl-Shift-v +Paste from the clipboard selection. +.SH CUSTOMIZATION +.B st +can be customized by creating a custom config.h and (re)compiling the source +code. This keeps it fast, secure and simple. +.SH AUTHORS +See the LICENSE file for the authors. +.SH LICENSE +See the LICENSE file for the terms of redistribution. +.SH SEE ALSO +.BR tabbed (1), +.BR utmp (1), +.BR stty (1), +.BR scroll (1) +.SH BUGS +See the TODO file in the distribution. + diff --git a/src/sxmo-st/st.c b/src/sxmo-st/st.c new file mode 100644 index 0000000..1bb5b37 --- /dev/null +++ b/src/sxmo-st/st.c @@ -0,0 +1,2728 @@ +/* See LICENSE for license details. */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "st.h" +#include "win.h" + +#if defined(__linux) + #include +#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) + #include +#elif defined(__FreeBSD__) || defined(__DragonFly__) + #include +#endif + +/* Arbitrary sizes */ +#define UTF_INVALID 0xFFFD +#define UTF_SIZ 4 +#define ESC_BUF_SIZ (128*UTF_SIZ) +#define ESC_ARG_SIZ 16 +#define STR_BUF_SIZ ESC_BUF_SIZ +#define STR_ARG_SIZ ESC_ARG_SIZ +#define HISTSIZE 2000 + +/* macros */ +#define IS_SET(flag) ((term.mode & (flag)) != 0) +#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == 0x7f) +#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) +#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c)) +#define ISDELIM(u) (u && wcschr(worddelimiters, u)) +#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \ + term.scr + HISTSIZE + 1) % HISTSIZE] : \ + term.line[(y) - term.scr]) + +enum term_mode { + MODE_WRAP = 1 << 0, + MODE_INSERT = 1 << 1, + MODE_ALTSCREEN = 1 << 2, + MODE_CRLF = 1 << 3, + MODE_ECHO = 1 << 4, + MODE_PRINT = 1 << 5, + MODE_UTF8 = 1 << 6, +}; + +enum cursor_movement { + CURSOR_SAVE, + CURSOR_LOAD +}; + +enum cursor_state { + CURSOR_DEFAULT = 0, + CURSOR_WRAPNEXT = 1, + CURSOR_ORIGIN = 2 +}; + +enum charset { + CS_GRAPHIC0, + CS_GRAPHIC1, + CS_UK, + CS_USA, + CS_MULTI, + CS_GER, + CS_FIN +}; + +enum escape_state { + ESC_START = 1, + ESC_CSI = 2, + ESC_STR = 4, /* DCS, OSC, PM, APC */ + ESC_ALTCHARSET = 8, + ESC_STR_END = 16, /* a final string was encountered */ + ESC_TEST = 32, /* Enter in test mode */ + ESC_UTF8 = 64, +}; + +typedef struct { + Glyph attr; /* current char attributes */ + int x; + int y; + char state; +} TCursor; + +typedef struct { + int mode; + int type; + int snap; + /* + * Selection variables: + * nb – normalized coordinates of the beginning of the selection + * ne – normalized coordinates of the end of the selection + * ob – original coordinates of the beginning of the selection + * oe – original coordinates of the end of the selection + */ + struct { + int x, y; + } nb, ne, ob, oe; + + int alt; +} Selection; + +/* Internal representation of the screen */ +typedef struct { + int row; /* nb row */ + int col; /* nb col */ + Line *line; /* screen */ + Line *alt; /* alternate screen */ + Line hist[HISTSIZE]; /* history buffer */ + int histi; /* history index */ + int scr; /* scroll back */ + int *dirty; /* dirtyness of lines */ + TCursor c; /* cursor */ + int ocx; /* old cursor col */ + int ocy; /* old cursor row */ + int top; /* top scroll limit */ + int bot; /* bottom scroll limit */ + int mode; /* terminal mode flags */ + int esc; /* escape state flags */ + char trantbl[4]; /* charset table translation */ + int charset; /* current charset */ + int icharset; /* selected charset for sequence */ + int *tabs; + Rune lastc; /* last printed char outside of sequence, 0 if control */ +} Term; + +/* CSI Escape sequence structs */ +/* ESC '[' [[ [] [;]] []] */ +typedef struct { + char buf[ESC_BUF_SIZ]; /* raw string */ + size_t len; /* raw string length */ + char priv; + int arg[ESC_ARG_SIZ]; + int narg; /* nb of args */ + char mode[2]; +} CSIEscape; + +/* STR Escape sequence structs */ +/* ESC type [[ [] [;]] ] ESC '\' */ +typedef struct { + char type; /* ESC type ... */ + char *buf; /* allocated raw string */ + size_t siz; /* allocation size */ + size_t len; /* raw string length */ + char *args[STR_ARG_SIZ]; + int narg; /* nb of args */ +} STREscape; + +static void execsh(char *, char **); +static void stty(char **); +static void sigchld(int); +static void ttywriteraw(const char *, size_t); + +static void csidump(void); +static void csihandle(void); +static void csiparse(void); +static void csireset(void); +static int eschandle(uchar); +static void strdump(void); +static void strhandle(void); +static void strparse(void); +static void strreset(void); + +static void tprinter(char *, size_t); +static void tdumpsel(void); +static void tdumpline(int); +static void tdump(void); +static void tclearregion(int, int, int, int); +static void tcursor(int); +static void tdeletechar(int); +static void tdeleteline(int); +static void tinsertblank(int); +static void tinsertblankline(int); +static int tlinelen(int); +static void tmoveto(int, int); +static void tmoveato(int, int); +static void tnewline(int); +static void tputtab(int); +static void tputc(Rune); +static void treset(void); +static void tscrollup(int, int, int); +static void tscrolldown(int, int, int); +static void tsetattr(int *, int); +static void tsetchar(Rune, Glyph *, int, int); +static void tsetdirt(int, int); +static void tsetscroll(int, int); +static void tswapscreen(void); +static void tsetmode(int, int, int *, int); +static int twrite(const char *, int, int); +static void tfulldirt(void); +static void tcontrolcode(uchar ); +static void tdectest(char ); +static void tdefutf8(char); +static int32_t tdefcolor(int *, int *, int); +static void tdeftran(char); +static void tstrsequence(uchar); + +static void drawregion(int, int, int, int); + +static void selnormalize(void); +static void selscroll(int, int); +static void selsnap(int *, int *, int); + +static size_t utf8decode(const char *, Rune *, size_t); +static Rune utf8decodebyte(char, size_t *); +static char utf8encodebyte(Rune, size_t); +static size_t utf8validate(Rune *, size_t); + +static char *base64dec(const char *); +static char base64dec_getc(const char **); + +static ssize_t xwrite(int, const char *, size_t); + +/* Globals */ +static Term term; +static Selection sel; +static CSIEscape csiescseq; +static STREscape strescseq; +static int iofd = 1; +static int cmdfd; +static pid_t pid; + +static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; +static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; +static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; +static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; + +ssize_t +xwrite(int fd, const char *s, size_t len) +{ + size_t aux = len; + ssize_t r; + + while (len > 0) { + r = write(fd, s, len); + if (r < 0) + return r; + len -= r; + s += r; + } + + return aux; +} + +void * +xmalloc(size_t len) +{ + void *p; + + if (!(p = malloc(len))) + die("malloc: %s\n", strerror(errno)); + + return p; +} + +void * +xrealloc(void *p, size_t len) +{ + if ((p = realloc(p, len)) == NULL) + die("realloc: %s\n", strerror(errno)); + + return p; +} + +char * +xstrdup(char *s) +{ + if ((s = strdup(s)) == NULL) + die("strdup: %s\n", strerror(errno)); + + return s; +} + +size_t +utf8decode(const char *c, Rune *u, size_t clen) +{ + size_t i, j, len, type; + Rune udecoded; + + *u = UTF_INVALID; + if (!clen) + return 0; + udecoded = utf8decodebyte(c[0], &len); + if (!BETWEEN(len, 1, UTF_SIZ)) + return 1; + for (i = 1, j = 1; i < clen && j < len; ++i, ++j) { + udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type); + if (type != 0) + return j; + } + if (j < len) + return 0; + *u = udecoded; + utf8validate(u, len); + + return len; +} + +Rune +utf8decodebyte(char c, size_t *i) +{ + for (*i = 0; *i < LEN(utfmask); ++(*i)) + if (((uchar)c & utfmask[*i]) == utfbyte[*i]) + return (uchar)c & ~utfmask[*i]; + + return 0; +} + +size_t +utf8encode(Rune u, char *c) +{ + size_t len, i; + + len = utf8validate(&u, 0); + if (len > UTF_SIZ) + return 0; + + for (i = len - 1; i != 0; --i) { + c[i] = utf8encodebyte(u, 0); + u >>= 6; + } + c[0] = utf8encodebyte(u, len); + + return len; +} + +char +utf8encodebyte(Rune u, size_t i) +{ + return utfbyte[i] | (u & ~utfmask[i]); +} + +size_t +utf8validate(Rune *u, size_t i) +{ + if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF)) + *u = UTF_INVALID; + for (i = 1; *u > utfmax[i]; ++i) + ; + + return i; +} + +static const char base64_digits[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, + 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, -1, 0, 0, 0, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +char +base64dec_getc(const char **src) +{ + while (**src && !isprint(**src)) + (*src)++; + return **src ? *((*src)++) : '='; /* emulate padding if string ends */ +} + +char * +base64dec(const char *src) +{ + size_t in_len = strlen(src); + char *result, *dst; + + if (in_len % 4) + in_len += 4 - (in_len % 4); + result = dst = xmalloc(in_len / 4 * 3 + 1); + while (*src) { + int a = base64_digits[(unsigned char) base64dec_getc(&src)]; + int b = base64_digits[(unsigned char) base64dec_getc(&src)]; + int c = base64_digits[(unsigned char) base64dec_getc(&src)]; + int d = base64_digits[(unsigned char) base64dec_getc(&src)]; + + /* invalid input. 'a' can be -1, e.g. if src is "\n" (c-str) */ + if (a == -1 || b == -1) + break; + + *dst++ = (a << 2) | ((b & 0x30) >> 4); + if (c == -1) + break; + *dst++ = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); + if (d == -1) + break; + *dst++ = ((c & 0x03) << 6) | d; + } + *dst = '\0'; + return result; +} + +void +selinit(void) +{ + sel.mode = SEL_IDLE; + sel.snap = 0; + sel.ob.x = -1; +} + +int +tlinelen(int y) +{ + int i = term.col; + + if (TLINE(y)[i - 1].mode & ATTR_WRAP) + return i; + + while (i > 0 && TLINE(y)[i - 1].u == ' ') + --i; + + return i; +} + +void +selstart(int col, int row, int snap) +{ + selclear(); + sel.mode = SEL_EMPTY; + sel.type = SEL_REGULAR; + sel.alt = IS_SET(MODE_ALTSCREEN); + sel.snap = snap; + sel.oe.x = sel.ob.x = col; + sel.oe.y = sel.ob.y = row; + selnormalize(); + + if (sel.snap != 0) + sel.mode = SEL_READY; + //tsetdirt(sel.nb.y, sel.ne.y); +} + +void +selextend(int col, int row, int type, int done) +{ + int oldey, oldex, oldsby, oldsey, oldtype; + + if (sel.mode == SEL_IDLE) + return; + if (done && sel.mode == SEL_EMPTY) { + selclear(); + return; + } + + oldey = sel.oe.y; + oldex = sel.oe.x; + oldsby = sel.nb.y; + oldsey = sel.ne.y; + oldtype = sel.type; + + sel.oe.x = col; + sel.oe.y = row; + selnormalize(); + sel.type = type; + + if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type || sel.mode == SEL_EMPTY) + tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey)); + + sel.mode = done ? SEL_IDLE : SEL_READY; +} + +void +selnormalize(void) +{ + int i; + + if (sel.type == SEL_REGULAR && sel.ob.y != sel.oe.y) { + sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; + sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; + } else { + sel.nb.x = MIN(sel.ob.x, sel.oe.x); + sel.ne.x = MAX(sel.ob.x, sel.oe.x); + } + sel.nb.y = MIN(sel.ob.y, sel.oe.y); + sel.ne.y = MAX(sel.ob.y, sel.oe.y); + + // E.g. cancels out all selsnapping functionality since this + // the pinephone's touchscreen likes to send extra mouseup events + // causing everything to selsnap..? + // This is a temp workaround - selsnapping would be nice eventually.. + return; + + selsnap(&sel.nb.x, &sel.nb.y, -1); + selsnap(&sel.ne.x, &sel.ne.y, +1); + + /* expand selection over line breaks */ + if (sel.type == SEL_RECTANGULAR) + return; + i = tlinelen(sel.nb.y); + if (i < sel.nb.x) + sel.nb.x = i; + if (tlinelen(sel.ne.y) <= sel.ne.x) + sel.ne.x = term.col - 1; +} + +int +selected(int x, int y) +{ + if (sel.mode == SEL_EMPTY || sel.ob.x == -1 || + sel.alt != IS_SET(MODE_ALTSCREEN)) + return 0; + + if (sel.type == SEL_RECTANGULAR) + return BETWEEN(y, sel.nb.y, sel.ne.y) + && BETWEEN(x, sel.nb.x, sel.ne.x); + + return BETWEEN(y, sel.nb.y, sel.ne.y) + && (y != sel.nb.y || x >= sel.nb.x) + && (y != sel.ne.y || x <= sel.ne.x); +} + +void +selsnap(int *x, int *y, int direction) +{ + int newx, newy, xt, yt; + int delim, prevdelim; + Glyph *gp, *prevgp; + + switch (sel.snap) { + case SNAP_WORD: + /* + * Snap around if the word wraps around at the end or + * beginning of a line. + */ + prevgp = &TLINE(*y)[*x]; + prevdelim = ISDELIM(prevgp->u); + for (;;) { + newx = *x + direction; + newy = *y; + if (!BETWEEN(newx, 0, term.col - 1)) { + newy += direction; + newx = (newx + term.col) % term.col; + if (!BETWEEN(newy, 0, term.row - 1)) + break; + + if (direction > 0) + yt = *y, xt = *x; + else + yt = newy, xt = newx; + if (!(TLINE(yt)[xt].mode & ATTR_WRAP)) + break; + } + + if (newx >= tlinelen(newy)) + break; + + gp = &TLINE(newy)[newx]; + delim = ISDELIM(gp->u); + if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim + || (delim && gp->u != prevgp->u))) + break; + + *x = newx; + *y = newy; + prevgp = gp; + prevdelim = delim; + } + break; + case SNAP_LINE: + /* + * Snap around if the the previous line or the current one + * has set ATTR_WRAP at its end. Then the whole next or + * previous line will be selected. + */ + *x = (direction < 0) ? 0 : term.col - 1; + if (direction < 0) { + for (; *y > 0; *y += direction) { + if (!(TLINE(*y-1)[term.col-1].mode + & ATTR_WRAP)) { + break; + } + } + } else if (direction > 0) { + for (; *y < term.row-1; *y += direction) { + if (!(TLINE(*y)[term.col-1].mode + & ATTR_WRAP)) { + break; + } + } + } + break; + } +} + +char * +getsel(void) +{ + char *str, *ptr; + int y, bufsize, lastx, linelen; + Glyph *gp, *last; + + if (sel.ob.x == -1) + return NULL; + + bufsize = (term.col+1) * (sel.ne.y-sel.nb.y+1) * UTF_SIZ; + ptr = str = xmalloc(bufsize); + + /* append every set & selected glyph to the selection */ + for (y = sel.nb.y; y <= sel.ne.y; y++) { + if ((linelen = tlinelen(y)) == 0) { + *ptr++ = '\n'; + continue; + } + + if (sel.type == SEL_RECTANGULAR) { + gp = &TLINE(y)[sel.nb.x]; + lastx = sel.ne.x; + } else { + gp = &TLINE(y)[sel.nb.y == y ? sel.nb.x : 0]; + lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1; + } + last = &TLINE(y)[MIN(lastx, linelen-1)]; + while (last >= gp && last->u == ' ') + --last; + + for ( ; gp <= last; ++gp) { + if (gp->mode & ATTR_WDUMMY) + continue; + + ptr += utf8encode(gp->u, ptr); + } + + /* + * Copy and pasting of line endings is inconsistent + * in the inconsistent terminal and GUI world. + * The best solution seems like to produce '\n' when + * something is copied from st and convert '\n' to + * '\r', when something to be pasted is received by + * st. + * FIXME: Fix the computer world. + */ + if ((y < sel.ne.y || lastx >= linelen) && + (!(last->mode & ATTR_WRAP) || sel.type == SEL_RECTANGULAR)) + *ptr++ = '\n'; + } + *ptr = 0; + return str; +} + +void +selclear(void) +{ + if (sel.ob.x == -1) + return; + sel.mode = SEL_IDLE; + sel.ob.x = -1; + tsetdirt(sel.nb.y, sel.ne.y); +} + +void +die(const char *errstr, ...) +{ + va_list ap; + + va_start(ap, errstr); + vfprintf(stderr, errstr, ap); + va_end(ap); + exit(1); +} + +void +execsh(char *cmd, char **args) +{ + char *sh, *prog, *arg; + const struct passwd *pw; + + errno = 0; + if ((pw = getpwuid(getuid())) == NULL) { + if (errno) + die("getpwuid: %s\n", strerror(errno)); + else + die("who are you?\n"); + } + + if ((sh = getenv("SHELL")) == NULL) + sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd; + + if (args) { + prog = args[0]; + arg = NULL; + } else if (scroll) { + prog = scroll; + arg = utmp ? utmp : sh; + } else if (utmp) { + prog = utmp; + arg = NULL; + } else { + prog = sh; + arg = NULL; + } + DEFAULT(args, ((char *[]) {prog, arg, NULL})); + + unsetenv("COLUMNS"); + unsetenv("LINES"); + unsetenv("TERMCAP"); + setenv("LOGNAME", pw->pw_name, 1); + setenv("USER", pw->pw_name, 1); + setenv("SHELL", sh, 1); + setenv("HOME", pw->pw_dir, 1); + setenv("TERM", termname, 1); + + signal(SIGCHLD, SIG_DFL); + signal(SIGHUP, SIG_DFL); + signal(SIGINT, SIG_DFL); + signal(SIGQUIT, SIG_DFL); + signal(SIGTERM, SIG_DFL); + signal(SIGALRM, SIG_DFL); + + execvp(prog, args); + _exit(1); +} + +void +sigchld(int a) +{ + int stat; + pid_t p; + + if ((p = waitpid(pid, &stat, WNOHANG)) < 0) + die("waiting for pid %hd failed: %s\n", pid, strerror(errno)); + + if (pid != p) + return; + + if (WIFEXITED(stat) && WEXITSTATUS(stat)) + die("child exited with status %d\n", WEXITSTATUS(stat)); + else if (WIFSIGNALED(stat)) + die("child terminated due to signal %d\n", WTERMSIG(stat)); + _exit(0); +} + +void +stty(char **args) +{ + char cmd[_POSIX_ARG_MAX], **p, *q, *s; + size_t n, siz; + + if ((n = strlen(stty_args)) > sizeof(cmd)-1) + die("incorrect stty parameters\n"); + memcpy(cmd, stty_args, n); + q = cmd + n; + siz = sizeof(cmd) - n; + for (p = args; p && (s = *p); ++p) { + if ((n = strlen(s)) > siz-1) + die("stty parameter length too long\n"); + *q++ = ' '; + memcpy(q, s, n); + q += n; + siz -= n + 1; + } + *q = '\0'; + if (system(cmd) != 0) + perror("Couldn't call stty"); +} + +int +ttynew(char *line, char *cmd, char *out, char **args) +{ + int m, s; + + if (out) { + term.mode |= MODE_PRINT; + iofd = (!strcmp(out, "-")) ? + 1 : open(out, O_WRONLY | O_CREAT, 0666); + if (iofd < 0) { + fprintf(stderr, "Error opening %s:%s\n", + out, strerror(errno)); + } + } + + if (line) { + if ((cmdfd = open(line, O_RDWR)) < 0) + die("open line '%s' failed: %s\n", + line, strerror(errno)); + dup2(cmdfd, 0); + stty(args); + return cmdfd; + } + + /* seems to work fine on linux, openbsd and freebsd */ + if (openpty(&m, &s, NULL, NULL, NULL) < 0) + die("openpty failed: %s\n", strerror(errno)); + + switch (pid = fork()) { + case -1: + die("fork failed: %s\n", strerror(errno)); + break; + case 0: + close(iofd); + setsid(); /* create a new process group */ + dup2(s, 0); + dup2(s, 1); + dup2(s, 2); + if (ioctl(s, TIOCSCTTY, NULL) < 0) + die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); + close(s); + close(m); +#ifdef __OpenBSD__ + if (pledge("stdio getpw proc exec", NULL) == -1) + die("pledge\n"); +#endif + execsh(cmd, args); + break; + default: +#ifdef __OpenBSD__ + if (pledge("stdio rpath tty proc", NULL) == -1) + die("pledge\n"); +#endif + close(s); + cmdfd = m; + signal(SIGCHLD, sigchld); + break; + } + return cmdfd; +} + +size_t +ttyread(void) +{ + static char buf[BUFSIZ]; + static int buflen = 0; + int ret, written; + + /* append read bytes to unprocessed bytes */ + ret = read(cmdfd, buf+buflen, LEN(buf)-buflen); + + switch (ret) { + case 0: + exit(0); + case -1: + die("couldn't read from shell: %s\n", strerror(errno)); + default: + buflen += ret; + written = twrite(buf, buflen, 0); + buflen -= written; + /* keep any incomplete UTF-8 byte sequence for the next call */ + if (buflen > 0) + memmove(buf, buf + written, buflen); + return ret; + } +} + +void +ttywrite(const char *s, size_t n, int may_echo) +{ + const char *next; + Arg arg = (Arg) { .i = term.scr }; + + kscrolldown(&arg); + + if (may_echo && IS_SET(MODE_ECHO)) + twrite(s, n, 1); + + if (!IS_SET(MODE_CRLF)) { + ttywriteraw(s, n); + return; + } + + /* This is similar to how the kernel handles ONLCR for ttys */ + while (n > 0) { + if (*s == '\r') { + next = s + 1; + ttywriteraw("\r\n", 2); + } else { + next = memchr(s, '\r', n); + DEFAULT(next, s + n); + ttywriteraw(s, next - s); + } + n -= next - s; + s = next; + } +} + +void +ttywriteraw(const char *s, size_t n) +{ + fd_set wfd, rfd; + ssize_t r; + size_t lim = 256; + + /* + * Remember that we are using a pty, which might be a modem line. + * Writing too much will clog the line. That's why we are doing this + * dance. + * FIXME: Migrate the world to Plan 9. + */ + while (n > 0) { + FD_ZERO(&wfd); + FD_ZERO(&rfd); + FD_SET(cmdfd, &wfd); + FD_SET(cmdfd, &rfd); + + /* Check if we can write. */ + if (pselect(cmdfd+1, &rfd, &wfd, NULL, NULL, NULL) < 0) { + if (errno == EINTR) + continue; + die("select failed: %s\n", strerror(errno)); + } + if (FD_ISSET(cmdfd, &wfd)) { + /* + * Only write the bytes written by ttywrite() or the + * default of 256. This seems to be a reasonable value + * for a serial line. Bigger values might clog the I/O. + */ + if ((r = write(cmdfd, s, (n < lim)? n : lim)) < 0) + goto write_error; + if (r < n) { + /* + * We weren't able to write out everything. + * This means the buffer is getting full + * again. Empty it. + */ + if (n < lim) + lim = ttyread(); + n -= r; + s += r; + } else { + /* All bytes have been written. */ + break; + } + } + if (FD_ISSET(cmdfd, &rfd)) + lim = ttyread(); + } + return; + +write_error: + die("write error on tty: %s\n", strerror(errno)); +} + +void +ttyresize(int tw, int th) +{ + struct winsize w; + + w.ws_row = term.row; + w.ws_col = term.col; + w.ws_xpixel = tw; + w.ws_ypixel = th; + if (ioctl(cmdfd, TIOCSWINSZ, &w) < 0) + fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno)); +} + +void +ttyhangup() +{ + /* Send SIGHUP to shell */ + kill(pid, SIGHUP); +} + +int +tattrset(int attr) +{ + int i, j; + + for (i = 0; i < term.row-1; i++) { + for (j = 0; j < term.col-1; j++) { + if (term.line[i][j].mode & attr) + return 1; + } + } + + return 0; +} + +void +tsetdirt(int top, int bot) +{ + int i; + + LIMIT(top, 0, term.row-1); + LIMIT(bot, 0, term.row-1); + + for (i = top; i <= bot; i++) + term.dirty[i] = 1; +} + +void +tsetdirtattr(int attr) +{ + int i, j; + + for (i = 0; i < term.row-1; i++) { + for (j = 0; j < term.col-1; j++) { + if (term.line[i][j].mode & attr) { + tsetdirt(i, i); + break; + } + } + } +} + +void +tfulldirt(void) +{ + tsetdirt(0, term.row-1); +} + +void +tcursor(int mode) +{ + static TCursor c[2]; + int alt = IS_SET(MODE_ALTSCREEN); + + if (mode == CURSOR_SAVE) { + c[alt] = term.c; + } else if (mode == CURSOR_LOAD) { + term.c = c[alt]; + tmoveto(c[alt].x, c[alt].y); + } +} + +void +treset(void) +{ + uint i; + + term.c = (TCursor){{ + .mode = ATTR_NULL, + .fg = defaultfg, + .bg = defaultbg + }, .x = 0, .y = 0, .state = CURSOR_DEFAULT}; + + memset(term.tabs, 0, term.col * sizeof(*term.tabs)); + for (i = tabspaces; i < term.col; i += tabspaces) + term.tabs[i] = 1; + term.top = 0; + term.bot = term.row - 1; + term.mode = MODE_WRAP|MODE_UTF8; + memset(term.trantbl, CS_USA, sizeof(term.trantbl)); + term.charset = 0; + + for (i = 0; i < 2; i++) { + tmoveto(0, 0); + tcursor(CURSOR_SAVE); + tclearregion(0, 0, term.col-1, term.row-1); + tswapscreen(); + } +} + +void +tnew(int col, int row) +{ + term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } }; + tresize(col, row); + treset(); +} + +void +tswapscreen(void) +{ + Line *tmp = term.line; + + term.line = term.alt; + term.alt = tmp; + term.mode ^= MODE_ALTSCREEN; + tfulldirt(); +} + +void +kscrolldown(const Arg* a) +{ + int n = a->i; + + if (n < 0) + n = term.row + n; + + if (n > term.scr) + n = term.scr; + + if (term.scr > 0) { + term.scr -= n; + selscroll(0, -n); + tfulldirt(); + } +} + +void +kscrollup(const Arg* a) +{ + int n = a->i; + + if (n < 0) + n = term.row + n; + + if (term.scr <= HISTSIZE-n) { + term.scr += n; + selscroll(0, n); + tfulldirt(); + } +} + +void +tscrolldown(int orig, int n, int copyhist) +{ + int i; + Line temp; + + LIMIT(n, 0, term.bot-orig+1); + + if (copyhist) { + term.histi = (term.histi - 1 + HISTSIZE) % HISTSIZE; + temp = term.hist[term.histi]; + term.hist[term.histi] = term.line[term.bot]; + term.line[term.bot] = temp; + } + + tsetdirt(orig, term.bot-n); + tclearregion(0, term.bot-n+1, term.col-1, term.bot); + + for (i = term.bot; i >= orig+n; i--) { + temp = term.line[i]; + term.line[i] = term.line[i-n]; + term.line[i-n] = temp; + } + + if (term.scr == 0) + selscroll(orig, n); +} + +void +tscrollup(int orig, int n, int copyhist) +{ + int i; + Line temp; + + LIMIT(n, 0, term.bot-orig+1); + + if (copyhist) { + term.histi = (term.histi + 1) % HISTSIZE; + temp = term.hist[term.histi]; + term.hist[term.histi] = term.line[orig]; + term.line[orig] = temp; + } + + if (term.scr > 0 && term.scr < HISTSIZE) + term.scr = MIN(term.scr + n, HISTSIZE-1); + + tclearregion(0, orig, term.col-1, orig+n-1); + tsetdirt(orig+n, term.bot); + + for (i = orig; i <= term.bot-n; i++) { + temp = term.line[i]; + term.line[i] = term.line[i+n]; + term.line[i+n] = temp; + } + + if (term.scr == 0) + selscroll(orig, -n); +} + +void +selscroll(int orig, int n) +{ + if (sel.ob.x == -1) + return; + + if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) { + selclear(); + } else if (BETWEEN(sel.nb.y, orig, term.bot)) { + sel.ob.y += n; + sel.oe.y += n; + if (sel.ob.y < term.top || sel.ob.y > term.bot || + sel.oe.y < term.top || sel.oe.y > term.bot) { + selclear(); + } else { + selnormalize(); + } + } +} + +void +tnewline(int first_col) +{ + int y = term.c.y; + + if (y == term.bot) { + tscrollup(term.top, 1, 1); + } else { + y++; + } + tmoveto(first_col ? 0 : term.c.x, y); +} + +void +csiparse(void) +{ + char *p = csiescseq.buf, *np; + long int v; + + csiescseq.narg = 0; + if (*p == '?') { + csiescseq.priv = 1; + p++; + } + + csiescseq.buf[csiescseq.len] = '\0'; + while (p < csiescseq.buf+csiescseq.len) { + np = NULL; + v = strtol(p, &np, 10); + if (np == p) + v = 0; + if (v == LONG_MAX || v == LONG_MIN) + v = -1; + csiescseq.arg[csiescseq.narg++] = v; + p = np; + if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ) + break; + p++; + } + csiescseq.mode[0] = *p++; + csiescseq.mode[1] = (p < csiescseq.buf+csiescseq.len) ? *p : '\0'; +} + +/* for absolute user moves, when decom is set */ +void +tmoveato(int x, int y) +{ + tmoveto(x, y + ((term.c.state & CURSOR_ORIGIN) ? term.top: 0)); +} + +void +tmoveto(int x, int y) +{ + int miny, maxy; + + if (term.c.state & CURSOR_ORIGIN) { + miny = term.top; + maxy = term.bot; + } else { + miny = 0; + maxy = term.row - 1; + } + term.c.state &= ~CURSOR_WRAPNEXT; + term.c.x = LIMIT(x, 0, term.col-1); + term.c.y = LIMIT(y, miny, maxy); +} + +void +tsetchar(Rune u, Glyph *attr, int x, int y) +{ + static char *vt100_0[62] = { /* 0x41 - 0x7e */ + "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */ + 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */ + 0, 0, 0, 0, 0, 0, 0, 0, /* P - W */ + 0, 0, 0, 0, 0, 0, 0, " ", /* X - _ */ + "◆", "▒", "␉", "␌", "␍", "␊", "°", "±", /* ` - g */ + "␤", "␋", "┘", "┐", "┌", "└", "┼", "⎺", /* h - o */ + "⎻", "─", "⎼", "⎽", "├", "┤", "┴", "┬", /* p - w */ + "│", "≤", "≥", "π", "≠", "£", "·", /* x - ~ */ + }; + + /* + * The table is proudly stolen from rxvt. + */ + if (term.trantbl[term.charset] == CS_GRAPHIC0 && + BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41]) + utf8decode(vt100_0[u - 0x41], &u, UTF_SIZ); + + if (term.line[y][x].mode & ATTR_WIDE) { + if (x+1 < term.col) { + term.line[y][x+1].u = ' '; + term.line[y][x+1].mode &= ~ATTR_WDUMMY; + } + } else if (term.line[y][x].mode & ATTR_WDUMMY) { + term.line[y][x-1].u = ' '; + term.line[y][x-1].mode &= ~ATTR_WIDE; + } + + term.dirty[y] = 1; + term.line[y][x] = *attr; + term.line[y][x].u = u; +} + +void +tclearregion(int x1, int y1, int x2, int y2) +{ + int x, y, temp; + Glyph *gp; + + if (x1 > x2) + temp = x1, x1 = x2, x2 = temp; + if (y1 > y2) + temp = y1, y1 = y2, y2 = temp; + + LIMIT(x1, 0, term.col-1); + LIMIT(x2, 0, term.col-1); + LIMIT(y1, 0, term.row-1); + LIMIT(y2, 0, term.row-1); + + for (y = y1; y <= y2; y++) { + term.dirty[y] = 1; + for (x = x1; x <= x2; x++) { + gp = &term.line[y][x]; + if (selected(x, y)) + selclear(); + gp->fg = term.c.attr.fg; + gp->bg = term.c.attr.bg; + gp->mode = 0; + gp->u = ' '; + } + } +} + +void +tdeletechar(int n) +{ + int dst, src, size; + Glyph *line; + + LIMIT(n, 0, term.col - term.c.x); + + dst = term.c.x; + src = term.c.x + n; + size = term.col - src; + line = term.line[term.c.y]; + + memmove(&line[dst], &line[src], size * sizeof(Glyph)); + tclearregion(term.col-n, term.c.y, term.col-1, term.c.y); +} + +void +tinsertblank(int n) +{ + int dst, src, size; + Glyph *line; + + LIMIT(n, 0, term.col - term.c.x); + + dst = term.c.x + n; + src = term.c.x; + size = term.col - dst; + line = term.line[term.c.y]; + + memmove(&line[dst], &line[src], size * sizeof(Glyph)); + tclearregion(src, term.c.y, dst - 1, term.c.y); +} + +void +tinsertblankline(int n) +{ + if (BETWEEN(term.c.y, term.top, term.bot)) + tscrolldown(term.c.y, n, 0); +} + +void +tdeleteline(int n) +{ + if (BETWEEN(term.c.y, term.top, term.bot)) + tscrollup(term.c.y, n, 0); +} + +int32_t +tdefcolor(int *attr, int *npar, int l) +{ + int32_t idx = -1; + uint r, g, b; + + switch (attr[*npar + 1]) { + case 2: /* direct color in RGB space */ + if (*npar + 4 >= l) { + fprintf(stderr, + "erresc(38): Incorrect number of parameters (%d)\n", + *npar); + break; + } + r = attr[*npar + 2]; + g = attr[*npar + 3]; + b = attr[*npar + 4]; + *npar += 4; + if (!BETWEEN(r, 0, 255) || !BETWEEN(g, 0, 255) || !BETWEEN(b, 0, 255)) + fprintf(stderr, "erresc: bad rgb color (%u,%u,%u)\n", + r, g, b); + else + idx = TRUECOLOR(r, g, b); + break; + case 5: /* indexed color */ + if (*npar + 2 >= l) { + fprintf(stderr, + "erresc(38): Incorrect number of parameters (%d)\n", + *npar); + break; + } + *npar += 2; + if (!BETWEEN(attr[*npar], 0, 255)) + fprintf(stderr, "erresc: bad fgcolor %d\n", attr[*npar]); + else + idx = attr[*npar]; + break; + case 0: /* implemented defined (only foreground) */ + case 1: /* transparent */ + case 3: /* direct color in CMY space */ + case 4: /* direct color in CMYK space */ + default: + fprintf(stderr, + "erresc(38): gfx attr %d unknown\n", attr[*npar]); + break; + } + + return idx; +} + +void +tsetattr(int *attr, int l) +{ + int i; + int32_t idx; + + for (i = 0; i < l; i++) { + switch (attr[i]) { + case 0: + term.c.attr.mode &= ~( + ATTR_BOLD | + ATTR_FAINT | + ATTR_ITALIC | + ATTR_UNDERLINE | + ATTR_BLINK | + ATTR_REVERSE | + ATTR_INVISIBLE | + ATTR_STRUCK ); + term.c.attr.fg = defaultfg; + term.c.attr.bg = defaultbg; + break; + case 1: + term.c.attr.mode |= ATTR_BOLD; + break; + case 2: + term.c.attr.mode |= ATTR_FAINT; + break; + case 3: + term.c.attr.mode |= ATTR_ITALIC; + break; + case 4: + term.c.attr.mode |= ATTR_UNDERLINE; + break; + case 5: /* slow blink */ + /* FALLTHROUGH */ + case 6: /* rapid blink */ + term.c.attr.mode |= ATTR_BLINK; + break; + case 7: + term.c.attr.mode |= ATTR_REVERSE; + break; + case 8: + term.c.attr.mode |= ATTR_INVISIBLE; + break; + case 9: + term.c.attr.mode |= ATTR_STRUCK; + break; + case 22: + term.c.attr.mode &= ~(ATTR_BOLD | ATTR_FAINT); + break; + case 23: + term.c.attr.mode &= ~ATTR_ITALIC; + break; + case 24: + term.c.attr.mode &= ~ATTR_UNDERLINE; + break; + case 25: + term.c.attr.mode &= ~ATTR_BLINK; + break; + case 27: + term.c.attr.mode &= ~ATTR_REVERSE; + break; + case 28: + term.c.attr.mode &= ~ATTR_INVISIBLE; + break; + case 29: + term.c.attr.mode &= ~ATTR_STRUCK; + break; + case 38: + if ((idx = tdefcolor(attr, &i, l)) >= 0) + term.c.attr.fg = idx; + break; + case 39: + term.c.attr.fg = defaultfg; + break; + case 48: + if ((idx = tdefcolor(attr, &i, l)) >= 0) + term.c.attr.bg = idx; + break; + case 49: + term.c.attr.bg = defaultbg; + break; + default: + if (BETWEEN(attr[i], 30, 37)) { + term.c.attr.fg = attr[i] - 30; + } else if (BETWEEN(attr[i], 40, 47)) { + term.c.attr.bg = attr[i] - 40; + } else if (BETWEEN(attr[i], 90, 97)) { + term.c.attr.fg = attr[i] - 90 + 8; + } else if (BETWEEN(attr[i], 100, 107)) { + term.c.attr.bg = attr[i] - 100 + 8; + } else { + fprintf(stderr, + "erresc(default): gfx attr %d unknown\n", + attr[i]); + csidump(); + } + break; + } + } +} + +void +tsetscroll(int t, int b) +{ + int temp; + + LIMIT(t, 0, term.row-1); + LIMIT(b, 0, term.row-1); + if (t > b) { + temp = t; + t = b; + b = temp; + } + term.top = t; + term.bot = b; +} + +void +tsetmode(int priv, int set, int *args, int narg) +{ + int alt, *lim; + + for (lim = args + narg; args < lim; ++args) { + if (priv) { + switch (*args) { + case 1: /* DECCKM -- Cursor key */ + xsetmode(set, MODE_APPCURSOR); + break; + case 5: /* DECSCNM -- Reverse video */ + xsetmode(set, MODE_REVERSE); + break; + case 6: /* DECOM -- Origin */ + MODBIT(term.c.state, set, CURSOR_ORIGIN); + tmoveato(0, 0); + break; + case 7: /* DECAWM -- Auto wrap */ + MODBIT(term.mode, set, MODE_WRAP); + break; + case 0: /* Error (IGNORED) */ + case 2: /* DECANM -- ANSI/VT52 (IGNORED) */ + case 3: /* DECCOLM -- Column (IGNORED) */ + case 4: /* DECSCLM -- Scroll (IGNORED) */ + case 8: /* DECARM -- Auto repeat (IGNORED) */ + case 18: /* DECPFF -- Printer feed (IGNORED) */ + case 19: /* DECPEX -- Printer extent (IGNORED) */ + case 42: /* DECNRCM -- National characters (IGNORED) */ + case 12: /* att610 -- Start blinking cursor (IGNORED) */ + break; + case 25: /* DECTCEM -- Text Cursor Enable Mode */ + xsetmode(!set, MODE_HIDE); + break; + case 9: /* X10 mouse compatibility mode */ + xsetpointermotion(0); + xsetmode(0, MODE_MOUSE); + xsetmode(set, MODE_MOUSEX10); + break; + case 1000: /* 1000: report button press */ + xsetpointermotion(0); + xsetmode(0, MODE_MOUSE); + xsetmode(set, MODE_MOUSEBTN); + break; + case 1002: /* 1002: report motion on button press */ + xsetpointermotion(0); + xsetmode(0, MODE_MOUSE); + xsetmode(set, MODE_MOUSEMOTION); + break; + case 1003: /* 1003: enable all mouse motions */ + xsetpointermotion(set); + xsetmode(0, MODE_MOUSE); + xsetmode(set, MODE_MOUSEMANY); + break; + case 1004: /* 1004: send focus events to tty */ + xsetmode(set, MODE_FOCUS); + break; + case 1006: /* 1006: extended reporting mode */ + xsetmode(set, MODE_MOUSESGR); + break; + case 1034: + xsetmode(set, MODE_8BIT); + break; + case 1049: /* swap screen & set/restore cursor as xterm */ + if (!allowaltscreen) + break; + tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD); + /* FALLTHROUGH */ + case 47: /* swap screen */ + case 1047: + if (!allowaltscreen) + break; + alt = IS_SET(MODE_ALTSCREEN); + if (alt) { + tclearregion(0, 0, term.col-1, + term.row-1); + } + if (set ^ alt) /* set is always 1 or 0 */ + tswapscreen(); + if (*args != 1049) + break; + /* FALLTHROUGH */ + case 1048: + tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD); + break; + case 2004: /* 2004: bracketed paste mode */ + xsetmode(set, MODE_BRCKTPASTE); + break; + /* Not implemented mouse modes. See comments there. */ + case 1001: /* mouse highlight mode; can hang the + terminal by design when implemented. */ + case 1005: /* UTF-8 mouse mode; will confuse + applications not supporting UTF-8 + and luit. */ + case 1015: /* urxvt mangled mouse mode; incompatible + and can be mistaken for other control + codes. */ + break; + default: + fprintf(stderr, + "erresc: unknown private set/reset mode %d\n", + *args); + break; + } + } else { + switch (*args) { + case 0: /* Error (IGNORED) */ + break; + case 2: + xsetmode(set, MODE_KBDLOCK); + break; + case 4: /* IRM -- Insertion-replacement */ + MODBIT(term.mode, set, MODE_INSERT); + break; + case 12: /* SRM -- Send/Receive */ + MODBIT(term.mode, !set, MODE_ECHO); + break; + case 20: /* LNM -- Linefeed/new line */ + MODBIT(term.mode, set, MODE_CRLF); + break; + default: + fprintf(stderr, + "erresc: unknown set/reset mode %d\n", + *args); + break; + } + } + } +} + +void +csihandle(void) +{ + char buf[40]; + int len; + + switch (csiescseq.mode[0]) { + default: + unknown: + fprintf(stderr, "erresc: unknown csi "); + csidump(); + /* die(""); */ + break; + case '@': /* ICH -- Insert blank char */ + DEFAULT(csiescseq.arg[0], 1); + tinsertblank(csiescseq.arg[0]); + break; + case 'A': /* CUU -- Cursor Up */ + DEFAULT(csiescseq.arg[0], 1); + tmoveto(term.c.x, term.c.y-csiescseq.arg[0]); + break; + case 'B': /* CUD -- Cursor Down */ + case 'e': /* VPR --Cursor Down */ + DEFAULT(csiescseq.arg[0], 1); + tmoveto(term.c.x, term.c.y+csiescseq.arg[0]); + break; + case 'i': /* MC -- Media Copy */ + switch (csiescseq.arg[0]) { + case 0: + tdump(); + break; + case 1: + tdumpline(term.c.y); + break; + case 2: + tdumpsel(); + break; + case 4: + term.mode &= ~MODE_PRINT; + break; + case 5: + term.mode |= MODE_PRINT; + break; + } + break; + case 'c': /* DA -- Device Attributes */ + if (csiescseq.arg[0] == 0) + ttywrite(vtiden, strlen(vtiden), 0); + break; + case 'b': /* REP -- if last char is printable print it more times */ + DEFAULT(csiescseq.arg[0], 1); + if (term.lastc) + while (csiescseq.arg[0]-- > 0) + tputc(term.lastc); + break; + case 'C': /* CUF -- Cursor Forward */ + case 'a': /* HPR -- Cursor Forward */ + DEFAULT(csiescseq.arg[0], 1); + tmoveto(term.c.x+csiescseq.arg[0], term.c.y); + break; + case 'D': /* CUB -- Cursor Backward */ + DEFAULT(csiescseq.arg[0], 1); + tmoveto(term.c.x-csiescseq.arg[0], term.c.y); + break; + case 'E': /* CNL -- Cursor Down and first col */ + DEFAULT(csiescseq.arg[0], 1); + tmoveto(0, term.c.y+csiescseq.arg[0]); + break; + case 'F': /* CPL -- Cursor Up and first col */ + DEFAULT(csiescseq.arg[0], 1); + tmoveto(0, term.c.y-csiescseq.arg[0]); + break; + case 'g': /* TBC -- Tabulation clear */ + switch (csiescseq.arg[0]) { + case 0: /* clear current tab stop */ + term.tabs[term.c.x] = 0; + break; + case 3: /* clear all the tabs */ + memset(term.tabs, 0, term.col * sizeof(*term.tabs)); + break; + default: + goto unknown; + } + break; + case 'G': /* CHA -- Move to */ + case '`': /* HPA */ + DEFAULT(csiescseq.arg[0], 1); + tmoveto(csiescseq.arg[0]-1, term.c.y); + break; + case 'H': /* CUP -- Move to */ + case 'f': /* HVP */ + DEFAULT(csiescseq.arg[0], 1); + DEFAULT(csiescseq.arg[1], 1); + tmoveato(csiescseq.arg[1]-1, csiescseq.arg[0]-1); + break; + case 'I': /* CHT -- Cursor Forward Tabulation tab stops */ + DEFAULT(csiescseq.arg[0], 1); + tputtab(csiescseq.arg[0]); + break; + case 'J': /* ED -- Clear screen */ + switch (csiescseq.arg[0]) { + case 0: /* below */ + tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); + if (term.c.y < term.row-1) { + tclearregion(0, term.c.y+1, term.col-1, + term.row-1); + } + break; + case 1: /* above */ + if (term.c.y > 1) + tclearregion(0, 0, term.col-1, term.c.y-1); + tclearregion(0, term.c.y, term.c.x, term.c.y); + break; + case 2: /* all */ + tclearregion(0, 0, term.col-1, term.row-1); + break; + default: + goto unknown; + } + break; + case 'K': /* EL -- Clear line */ + switch (csiescseq.arg[0]) { + case 0: /* right */ + tclearregion(term.c.x, term.c.y, term.col-1, + term.c.y); + break; + case 1: /* left */ + tclearregion(0, term.c.y, term.c.x, term.c.y); + break; + case 2: /* all */ + tclearregion(0, term.c.y, term.col-1, term.c.y); + break; + } + break; + case 'S': /* SU -- Scroll line up */ + DEFAULT(csiescseq.arg[0], 1); + tscrollup(term.top, csiescseq.arg[0], 0); + break; + case 'T': /* SD -- Scroll line down */ + DEFAULT(csiescseq.arg[0], 1); + tscrolldown(term.top, csiescseq.arg[0], 0); + break; + case 'L': /* IL -- Insert blank lines */ + DEFAULT(csiescseq.arg[0], 1); + tinsertblankline(csiescseq.arg[0]); + break; + case 'l': /* RM -- Reset Mode */ + tsetmode(csiescseq.priv, 0, csiescseq.arg, csiescseq.narg); + break; + case 'M': /* DL -- Delete lines */ + DEFAULT(csiescseq.arg[0], 1); + tdeleteline(csiescseq.arg[0]); + break; + case 'X': /* ECH -- Erase char */ + DEFAULT(csiescseq.arg[0], 1); + tclearregion(term.c.x, term.c.y, + term.c.x + csiescseq.arg[0] - 1, term.c.y); + break; + case 'P': /* DCH -- Delete char */ + DEFAULT(csiescseq.arg[0], 1); + tdeletechar(csiescseq.arg[0]); + break; + case 'Z': /* CBT -- Cursor Backward Tabulation tab stops */ + DEFAULT(csiescseq.arg[0], 1); + tputtab(-csiescseq.arg[0]); + break; + case 'd': /* VPA -- Move to */ + DEFAULT(csiescseq.arg[0], 1); + tmoveato(term.c.x, csiescseq.arg[0]-1); + break; + case 'h': /* SM -- Set terminal mode */ + tsetmode(csiescseq.priv, 1, csiescseq.arg, csiescseq.narg); + break; + case 'm': /* SGR -- Terminal attribute (color) */ + tsetattr(csiescseq.arg, csiescseq.narg); + break; + case 'n': /* DSR – Device Status Report (cursor position) */ + if (csiescseq.arg[0] == 6) { + len = snprintf(buf, sizeof(buf), "\033[%i;%iR", + term.c.y+1, term.c.x+1); + ttywrite(buf, len, 0); + } + break; + case 'r': /* DECSTBM -- Set Scrolling Region */ + if (csiescseq.priv) { + goto unknown; + } else { + DEFAULT(csiescseq.arg[0], 1); + DEFAULT(csiescseq.arg[1], term.row); + tsetscroll(csiescseq.arg[0]-1, csiescseq.arg[1]-1); + tmoveato(0, 0); + } + break; + case 's': /* DECSC -- Save cursor position (ANSI.SYS) */ + tcursor(CURSOR_SAVE); + break; + case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */ + tcursor(CURSOR_LOAD); + break; + case ' ': + switch (csiescseq.mode[1]) { + case 'q': /* DECSCUSR -- Set Cursor Style */ + if (xsetcursor(csiescseq.arg[0])) + goto unknown; + break; + default: + goto unknown; + } + break; + } +} + +void +csidump(void) +{ + size_t i; + uint c; + + fprintf(stderr, "ESC["); + for (i = 0; i < csiescseq.len; i++) { + c = csiescseq.buf[i] & 0xff; + if (isprint(c)) { + putc(c, stderr); + } else if (c == '\n') { + fprintf(stderr, "(\\n)"); + } else if (c == '\r') { + fprintf(stderr, "(\\r)"); + } else if (c == 0x1b) { + fprintf(stderr, "(\\e)"); + } else { + fprintf(stderr, "(%02x)", c); + } + } + putc('\n', stderr); +} + +void +csireset(void) +{ + memset(&csiescseq, 0, sizeof(csiescseq)); +} + +void +strhandle(void) +{ + char *p = NULL, *dec; + int j, narg, par; + + term.esc &= ~(ESC_STR_END|ESC_STR); + strparse(); + par = (narg = strescseq.narg) ? atoi(strescseq.args[0]) : 0; + + switch (strescseq.type) { + case ']': /* OSC -- Operating System Command */ + switch (par) { + case 0: + case 1: + case 2: + if (narg > 1) + xsettitle(strescseq.args[1]); + return; + case 52: + if (narg > 2 && allowwindowops) { + dec = base64dec(strescseq.args[2]); + if (dec) { + xsetsel(dec); + xclipcopy(); + } else { + fprintf(stderr, "erresc: invalid base64\n"); + } + } + return; + case 4: /* color set */ + if (narg < 3) + break; + p = strescseq.args[2]; + /* FALLTHROUGH */ + case 104: /* color reset, here p = NULL */ + j = (narg > 1) ? atoi(strescseq.args[1]) : -1; + if (xsetcolorname(j, p)) { + if (par == 104 && narg <= 1) + return; /* color reset without parameter */ + fprintf(stderr, "erresc: invalid color j=%d, p=%s\n", + j, p ? p : "(null)"); + } else { + /* + * TODO if defaultbg color is changed, borders + * are dirty + */ + redraw(); + } + return; + } + break; + case 'k': /* old title set compatibility */ + xsettitle(strescseq.args[0]); + return; + case 'P': /* DCS -- Device Control String */ + case '_': /* APC -- Application Program Command */ + case '^': /* PM -- Privacy Message */ + return; + } + + fprintf(stderr, "erresc: unknown str "); + strdump(); +} + +void +strparse(void) +{ + int c; + char *p = strescseq.buf; + + strescseq.narg = 0; + strescseq.buf[strescseq.len] = '\0'; + + if (*p == '\0') + return; + + while (strescseq.narg < STR_ARG_SIZ) { + strescseq.args[strescseq.narg++] = p; + while ((c = *p) != ';' && c != '\0') + ++p; + if (c == '\0') + return; + *p++ = '\0'; + } +} + +void +externalpipe(const Arg *arg) +{ + int to[2]; + char buf[UTF_SIZ]; + void (*oldsigpipe)(int); + Glyph *bp, *end; + int lastpos, n, newline; + + if (pipe(to) == -1) + return; + + switch (fork()) { + case -1: + close(to[0]); + close(to[1]); + return; + case 0: + dup2(to[0], STDIN_FILENO); + close(to[0]); + close(to[1]); + execvp(((char **)arg->v)[0], (char **)arg->v); + fprintf(stderr, "st: execvp %s\n", ((char **)arg->v)[0]); + perror("failed"); + exit(0); + } + + close(to[0]); + /* ignore sigpipe for now, in case child exists early */ + oldsigpipe = signal(SIGPIPE, SIG_IGN); + newline = 0; + for (n = 0; n < term.row; n++) { + bp = term.line[n]; + lastpos = MIN(tlinelen(n) + 1, term.col) - 1; + if (lastpos < 0) + break; + end = &bp[lastpos + 1]; + for (; bp < end; ++bp) + if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0) + break; + if ((newline = term.line[n][lastpos].mode & ATTR_WRAP)) + continue; + if (xwrite(to[1], "\n", 1) < 0) + break; + newline = 0; + } + if (newline) + (void)xwrite(to[1], "\n", 1); + close(to[1]); + /* restore */ + signal(SIGPIPE, oldsigpipe); +} + +void +strdump(void) +{ + size_t i; + uint c; + + fprintf(stderr, "ESC%c", strescseq.type); + for (i = 0; i < strescseq.len; i++) { + c = strescseq.buf[i] & 0xff; + if (c == '\0') { + putc('\n', stderr); + return; + } else if (isprint(c)) { + putc(c, stderr); + } else if (c == '\n') { + fprintf(stderr, "(\\n)"); + } else if (c == '\r') { + fprintf(stderr, "(\\r)"); + } else if (c == 0x1b) { + fprintf(stderr, "(\\e)"); + } else { + fprintf(stderr, "(%02x)", c); + } + } + fprintf(stderr, "ESC\\\n"); +} + +void +strreset(void) +{ + strescseq = (STREscape){ + .buf = xrealloc(strescseq.buf, STR_BUF_SIZ), + .siz = STR_BUF_SIZ, + }; +} + +void +sendbreak(const Arg *arg) +{ + if (tcsendbreak(cmdfd, 0)) + perror("Error sending break"); +} + +void +tprinter(char *s, size_t len) +{ + if (iofd != -1 && xwrite(iofd, s, len) < 0) { + perror("Error writing to output file"); + close(iofd); + iofd = -1; + } +} + +void +toggleprinter(const Arg *arg) +{ + term.mode ^= MODE_PRINT; +} + +void +printscreen(const Arg *arg) +{ + tdump(); +} + +void +printsel(const Arg *arg) +{ + tdumpsel(); +} + +void +tdumpsel(void) +{ + char *ptr; + + if ((ptr = getsel())) { + tprinter(ptr, strlen(ptr)); + free(ptr); + } +} + +void +tdumpline(int n) +{ + char buf[UTF_SIZ]; + Glyph *bp, *end; + + bp = &term.line[n][0]; + end = &bp[MIN(tlinelen(n), term.col) - 1]; + if (bp != end || bp->u != ' ') { + for ( ; bp <= end; ++bp) + tprinter(buf, utf8encode(bp->u, buf)); + } + tprinter("\n", 1); +} + +void +tdump(void) +{ + int i; + + for (i = 0; i < term.row; ++i) + tdumpline(i); +} + +void +tputtab(int n) +{ + uint x = term.c.x; + + if (n > 0) { + while (x < term.col && n--) + for (++x; x < term.col && !term.tabs[x]; ++x) + /* nothing */ ; + } else if (n < 0) { + while (x > 0 && n++) + for (--x; x > 0 && !term.tabs[x]; --x) + /* nothing */ ; + } + term.c.x = LIMIT(x, 0, term.col-1); +} + +void +tdefutf8(char ascii) +{ + if (ascii == 'G') + term.mode |= MODE_UTF8; + else if (ascii == '@') + term.mode &= ~MODE_UTF8; +} + +void +tdeftran(char ascii) +{ + static char cs[] = "0B"; + static int vcs[] = {CS_GRAPHIC0, CS_USA}; + char *p; + + if ((p = strchr(cs, ascii)) == NULL) { + fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); + } else { + term.trantbl[term.icharset] = vcs[p - cs]; + } +} + +void +tdectest(char c) +{ + int x, y; + + if (c == '8') { /* DEC screen alignment test. */ + for (x = 0; x < term.col; ++x) { + for (y = 0; y < term.row; ++y) + tsetchar('E', &term.c.attr, x, y); + } + } +} + +void +tstrsequence(uchar c) +{ + switch (c) { + case 0x90: /* DCS -- Device Control String */ + c = 'P'; + break; + case 0x9f: /* APC -- Application Program Command */ + c = '_'; + break; + case 0x9e: /* PM -- Privacy Message */ + c = '^'; + break; + case 0x9d: /* OSC -- Operating System Command */ + c = ']'; + break; + } + strreset(); + strescseq.type = c; + term.esc |= ESC_STR; +} + +void +tcontrolcode(uchar ascii) +{ + switch (ascii) { + case '\t': /* HT */ + tputtab(1); + return; + case '\b': /* BS */ + tmoveto(term.c.x-1, term.c.y); + return; + case '\r': /* CR */ + tmoveto(0, term.c.y); + return; + case '\f': /* LF */ + case '\v': /* VT */ + case '\n': /* LF */ + /* go to first col if the mode is set */ + tnewline(IS_SET(MODE_CRLF)); + return; + case '\a': /* BEL */ + if (term.esc & ESC_STR_END) { + /* backwards compatibility to xterm */ + strhandle(); + } else { + xbell(); + } + break; + case '\033': /* ESC */ + csireset(); + term.esc &= ~(ESC_CSI|ESC_ALTCHARSET|ESC_TEST); + term.esc |= ESC_START; + return; + case '\016': /* SO (LS1 -- Locking shift 1) */ + case '\017': /* SI (LS0 -- Locking shift 0) */ + term.charset = 1 - (ascii - '\016'); + return; + case '\032': /* SUB */ + tsetchar('?', &term.c.attr, term.c.x, term.c.y); + /* FALLTHROUGH */ + case '\030': /* CAN */ + csireset(); + break; + case '\005': /* ENQ (IGNORED) */ + case '\000': /* NUL (IGNORED) */ + case '\021': /* XON (IGNORED) */ + case '\023': /* XOFF (IGNORED) */ + case 0177: /* DEL (IGNORED) */ + return; + case 0x80: /* TODO: PAD */ + case 0x81: /* TODO: HOP */ + case 0x82: /* TODO: BPH */ + case 0x83: /* TODO: NBH */ + case 0x84: /* TODO: IND */ + break; + case 0x85: /* NEL -- Next line */ + tnewline(1); /* always go to first col */ + break; + case 0x86: /* TODO: SSA */ + case 0x87: /* TODO: ESA */ + break; + case 0x88: /* HTS -- Horizontal tab stop */ + term.tabs[term.c.x] = 1; + break; + case 0x89: /* TODO: HTJ */ + case 0x8a: /* TODO: VTS */ + case 0x8b: /* TODO: PLD */ + case 0x8c: /* TODO: PLU */ + case 0x8d: /* TODO: RI */ + case 0x8e: /* TODO: SS2 */ + case 0x8f: /* TODO: SS3 */ + case 0x91: /* TODO: PU1 */ + case 0x92: /* TODO: PU2 */ + case 0x93: /* TODO: STS */ + case 0x94: /* TODO: CCH */ + case 0x95: /* TODO: MW */ + case 0x96: /* TODO: SPA */ + case 0x97: /* TODO: EPA */ + case 0x98: /* TODO: SOS */ + case 0x99: /* TODO: SGCI */ + break; + case 0x9a: /* DECID -- Identify Terminal */ + ttywrite(vtiden, strlen(vtiden), 0); + break; + case 0x9b: /* TODO: CSI */ + case 0x9c: /* TODO: ST */ + break; + case 0x90: /* DCS -- Device Control String */ + case 0x9d: /* OSC -- Operating System Command */ + case 0x9e: /* PM -- Privacy Message */ + case 0x9f: /* APC -- Application Program Command */ + tstrsequence(ascii); + return; + } + /* only CAN, SUB, \a and C1 chars interrupt a sequence */ + term.esc &= ~(ESC_STR_END|ESC_STR); +} + +/* + * returns 1 when the sequence is finished and it hasn't to read + * more characters for this sequence, otherwise 0 + */ +int +eschandle(uchar ascii) +{ + switch (ascii) { + case '[': + term.esc |= ESC_CSI; + return 0; + case '#': + term.esc |= ESC_TEST; + return 0; + case '%': + term.esc |= ESC_UTF8; + return 0; + case 'P': /* DCS -- Device Control String */ + case '_': /* APC -- Application Program Command */ + case '^': /* PM -- Privacy Message */ + case ']': /* OSC -- Operating System Command */ + case 'k': /* old title set compatibility */ + tstrsequence(ascii); + return 0; + case 'n': /* LS2 -- Locking shift 2 */ + case 'o': /* LS3 -- Locking shift 3 */ + term.charset = 2 + (ascii - 'n'); + break; + case '(': /* GZD4 -- set primary charset G0 */ + case ')': /* G1D4 -- set secondary charset G1 */ + case '*': /* G2D4 -- set tertiary charset G2 */ + case '+': /* G3D4 -- set quaternary charset G3 */ + term.icharset = ascii - '('; + term.esc |= ESC_ALTCHARSET; + return 0; + case 'D': /* IND -- Linefeed */ + if (term.c.y == term.bot) { + tscrollup(term.top, 1, 1); + } else { + tmoveto(term.c.x, term.c.y+1); + } + break; + case 'E': /* NEL -- Next line */ + tnewline(1); /* always go to first col */ + break; + case 'H': /* HTS -- Horizontal tab stop */ + term.tabs[term.c.x] = 1; + break; + case 'M': /* RI -- Reverse index */ + if (term.c.y == term.top) { + tscrolldown(term.top, 1, 1); + } else { + tmoveto(term.c.x, term.c.y-1); + } + break; + case 'Z': /* DECID -- Identify Terminal */ + ttywrite(vtiden, strlen(vtiden), 0); + break; + case 'c': /* RIS -- Reset to initial state */ + treset(); + resettitle(); + xloadcols(); + break; + case '=': /* DECPAM -- Application keypad */ + xsetmode(1, MODE_APPKEYPAD); + break; + case '>': /* DECPNM -- Normal keypad */ + xsetmode(0, MODE_APPKEYPAD); + break; + case '7': /* DECSC -- Save Cursor */ + tcursor(CURSOR_SAVE); + break; + case '8': /* DECRC -- Restore Cursor */ + tcursor(CURSOR_LOAD); + break; + case '\\': /* ST -- String Terminator */ + if (term.esc & ESC_STR_END) + strhandle(); + break; + default: + fprintf(stderr, "erresc: unknown sequence ESC 0x%02X '%c'\n", + (uchar) ascii, isprint(ascii)? ascii:'.'); + break; + } + return 1; +} + +void +tputc(Rune u) +{ + char c[UTF_SIZ]; + int control; + int width, len; + Glyph *gp; + + control = ISCONTROL(u); + if (u < 127 || !IS_SET(MODE_UTF8)) { + c[0] = u; + width = len = 1; + } else { + len = utf8encode(u, c); + if (!control && (width = wcwidth(u)) == -1) + width = 1; + } + + if (IS_SET(MODE_PRINT)) + tprinter(c, len); + + /* + * STR sequence must be checked before anything else + * because it uses all following characters until it + * receives a ESC, a SUB, a ST or any other C1 control + * character. + */ + if (term.esc & ESC_STR) { + if (u == '\a' || u == 030 || u == 032 || u == 033 || + ISCONTROLC1(u)) { + term.esc &= ~(ESC_START|ESC_STR); + term.esc |= ESC_STR_END; + goto check_control_code; + } + + if (strescseq.len+len >= strescseq.siz) { + /* + * Here is a bug in terminals. If the user never sends + * some code to stop the str or esc command, then st + * will stop responding. But this is better than + * silently failing with unknown characters. At least + * then users will report back. + * + * In the case users ever get fixed, here is the code: + */ + /* + * term.esc = 0; + * strhandle(); + */ + if (strescseq.siz > (SIZE_MAX - UTF_SIZ) / 2) + return; + strescseq.siz *= 2; + strescseq.buf = xrealloc(strescseq.buf, strescseq.siz); + } + + memmove(&strescseq.buf[strescseq.len], c, len); + strescseq.len += len; + return; + } + +check_control_code: + /* + * Actions of control codes must be performed as soon they arrive + * because they can be embedded inside a control sequence, and + * they must not cause conflicts with sequences. + */ + if (control) { + tcontrolcode(u); + /* + * control codes are not shown ever + */ + if (!term.esc) + term.lastc = 0; + return; + } else if (term.esc & ESC_START) { + if (term.esc & ESC_CSI) { + csiescseq.buf[csiescseq.len++] = u; + if (BETWEEN(u, 0x40, 0x7E) + || csiescseq.len >= \ + sizeof(csiescseq.buf)-1) { + term.esc = 0; + csiparse(); + csihandle(); + } + return; + } else if (term.esc & ESC_UTF8) { + tdefutf8(u); + } else if (term.esc & ESC_ALTCHARSET) { + tdeftran(u); + } else if (term.esc & ESC_TEST) { + tdectest(u); + } else { + if (!eschandle(u)) + return; + /* sequence already finished */ + } + term.esc = 0; + /* + * All characters which form part of a sequence are not + * printed + */ + return; + } + if (selected(term.c.x, term.c.y)) + selclear(); + + gp = &term.line[term.c.y][term.c.x]; + if (IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) { + gp->mode |= ATTR_WRAP; + tnewline(1); + gp = &term.line[term.c.y][term.c.x]; + } + + if (IS_SET(MODE_INSERT) && term.c.x+width < term.col) + memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph)); + + if (term.c.x+width > term.col) { + tnewline(1); + gp = &term.line[term.c.y][term.c.x]; + } + + tsetchar(u, &term.c.attr, term.c.x, term.c.y); + term.lastc = u; + + if (width == 2) { + gp->mode |= ATTR_WIDE; + if (term.c.x+1 < term.col) { + gp[1].u = '\0'; + gp[1].mode = ATTR_WDUMMY; + } + } + if (term.c.x+width < term.col) { + tmoveto(term.c.x+width, term.c.y); + } else { + term.c.state |= CURSOR_WRAPNEXT; + } +} + +int +twrite(const char *buf, int buflen, int show_ctrl) +{ + int charsize; + Rune u; + int n; + + for (n = 0; n < buflen; n += charsize) { + if (IS_SET(MODE_UTF8)) { + /* process a complete utf8 char */ + charsize = utf8decode(buf + n, &u, buflen - n); + if (charsize == 0) + break; + } else { + u = buf[n] & 0xFF; + charsize = 1; + } + if (show_ctrl && ISCONTROL(u)) { + if (u & 0x80) { + u &= 0x7f; + tputc('^'); + tputc('['); + } else if (u != '\n' && u != '\r' && u != '\t') { + u ^= 0x40; + tputc('^'); + } + } + tputc(u); + } + return n; +} + +void +tresize(int col, int row) +{ + int i, j; + int minrow = MIN(row, term.row); + int mincol = MIN(col, term.col); + int *bp; + TCursor c; + + if (col < 1 || row < 1) { + fprintf(stderr, + "tresize: error resizing to %dx%d\n", col, row); + return; + } + + /* + * slide screen to keep cursor where we expect it - + * tscrollup would work here, but we can optimize to + * memmove because we're freeing the earlier lines + */ + for (i = 0; i <= term.c.y - row; i++) { + free(term.line[i]); + free(term.alt[i]); + } + /* ensure that both src and dst are not NULL */ + if (i > 0) { + memmove(term.line, term.line + i, row * sizeof(Line)); + memmove(term.alt, term.alt + i, row * sizeof(Line)); + } + for (i += row; i < term.row; i++) { + free(term.line[i]); + free(term.alt[i]); + } + + /* resize to new height */ + term.line = xrealloc(term.line, row * sizeof(Line)); + term.alt = xrealloc(term.alt, row * sizeof(Line)); + term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty)); + term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs)); + + for (i = 0; i < HISTSIZE; i++) { + term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph)); + for (j = mincol; j < col; j++) { + term.hist[i][j] = term.c.attr; + term.hist[i][j].u = ' '; + } + } + + /* resize each row to new width, zero-pad if needed */ + for (i = 0; i < minrow; i++) { + term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph)); + term.alt[i] = xrealloc(term.alt[i], col * sizeof(Glyph)); + } + + /* allocate any new rows */ + for (/* i = minrow */; i < row; i++) { + term.line[i] = xmalloc(col * sizeof(Glyph)); + term.alt[i] = xmalloc(col * sizeof(Glyph)); + } + if (col > term.col) { + bp = term.tabs + term.col; + + memset(bp, 0, sizeof(*term.tabs) * (col - term.col)); + while (--bp > term.tabs && !*bp) + /* nothing */ ; + for (bp += tabspaces; bp < term.tabs + col; bp += tabspaces) + *bp = 1; + } + /* update terminal size */ + term.col = col; + term.row = row; + /* reset scrolling region */ + tsetscroll(0, row-1); + /* make use of the LIMIT in tmoveto */ + tmoveto(term.c.x, term.c.y); + /* Clearing both screens (it makes dirty all lines) */ + c = term.c; + for (i = 0; i < 2; i++) { + if (mincol < col && 0 < minrow) { + tclearregion(mincol, 0, col - 1, minrow - 1); + } + if (0 < col && minrow < row) { + tclearregion(0, minrow, col - 1, row - 1); + } + tswapscreen(); + tcursor(CURSOR_LOAD); + } + term.c = c; +} + +void +resettitle(void) +{ + xsettitle(NULL); +} + +void +drawregion(int x1, int y1, int x2, int y2) +{ + int y; + + for (y = y1; y < y2; y++) { + if (!term.dirty[y]) + continue; + + term.dirty[y] = 0; + xdrawline(TLINE(y), x1, y, x2); + } +} + +void +draw(void) +{ + int cx = term.c.x, ocx = term.ocx, ocy = term.ocy; + + if (!xstartdraw()) + return; + + /* adjust cursor position */ + LIMIT(term.ocx, 0, term.col-1); + LIMIT(term.ocy, 0, term.row-1); + if (term.line[term.ocy][term.ocx].mode & ATTR_WDUMMY) + term.ocx--; + if (term.line[term.c.y][cx].mode & ATTR_WDUMMY) + cx--; + + term.dirty[term.ocy] = 1; + drawregion(0, 0, term.col, term.row); + if (term.scr == 0) + xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], + term.ocx, term.ocy, term.line[term.ocy][term.ocx]); + term.ocx = cx; + term.ocy = term.c.y; + xfinishdraw(); + if (ocx != term.ocx || ocy != term.ocy) + xximspot(term.ocx, term.ocy); +} + +void +redraw(void) +{ + tfulldirt(); + draw(); +} diff --git a/src/sxmo-st/st.h b/src/sxmo-st/st.h new file mode 100644 index 0000000..5489ac5 --- /dev/null +++ b/src/sxmo-st/st.h @@ -0,0 +1,128 @@ +/* See LICENSE for license details. */ + +#include +#include + +/* macros */ +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#define LEN(a) (sizeof(a) / sizeof(a)[0]) +#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) +#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) +#define DEFAULT(a, b) (a) = (a) ? (a) : (b) +#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) +#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ + (a).bg != (b).bg) +#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \ + (t1.tv_nsec-t2.tv_nsec)/1E6) +#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit))) + +#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) +#define IS_TRUECOL(x) (1 << 24 & (x)) + +enum glyph_attribute { + ATTR_NULL = 0, + ATTR_BOLD = 1 << 0, + ATTR_FAINT = 1 << 1, + ATTR_ITALIC = 1 << 2, + ATTR_UNDERLINE = 1 << 3, + ATTR_BLINK = 1 << 4, + ATTR_REVERSE = 1 << 5, + ATTR_INVISIBLE = 1 << 6, + ATTR_STRUCK = 1 << 7, + ATTR_WRAP = 1 << 8, + ATTR_WIDE = 1 << 9, + ATTR_WDUMMY = 1 << 10, + ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, +}; + +enum selection_mode { + SEL_IDLE = 0, + SEL_EMPTY = 1, + SEL_READY = 2 +}; + +enum selection_type { + SEL_REGULAR = 1, + SEL_RECTANGULAR = 2 +}; + +enum selection_snap { + SNAP_WORD = 1, + SNAP_LINE = 2 +}; + +typedef unsigned char uchar; +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned short ushort; + +typedef uint_least32_t Rune; + +#define Glyph Glyph_ +typedef struct { + Rune u; /* character code */ + ushort mode; /* attribute flags */ + uint32_t fg; /* foreground */ + uint32_t bg; /* background */ +} Glyph; + +typedef Glyph *Line; + +typedef union { + int i; + uint ui; + float f; + const void *v; + const char *s; +} Arg; + +void die(const char *, ...); +void redraw(void); +void draw(void); + +void kscrolldown(const Arg *); +void kscrollup(const Arg *); +void printscreen(const Arg *); +void printsel(const Arg *); +void sendbreak(const Arg *); +void toggleprinter(const Arg *); +void externalpipe(const Arg *); + +int tattrset(int); +void tnew(int, int); +void tresize(int, int); +void tsetdirtattr(int); +void ttyhangup(void); +int ttynew(char *, char *, char *, char **); +size_t ttyread(void); +void ttyresize(int, int); +void ttywrite(const char *, size_t, int); + +void resettitle(void); + +void selclear(void); +void selinit(void); +void selstart(int, int, int); +void selextend(int, int, int, int); +int selected(int, int); +char *getsel(void); + +size_t utf8encode(Rune, char *); + +void *xmalloc(size_t); +void *xrealloc(void *, size_t); +char *xstrdup(char *); + +/* config.h globals */ +extern char *utmp; +extern char *scroll; +extern char *stty_args; +extern char *vtiden; +extern wchar_t *worddelimiters; +extern int allowaltscreen; +extern int allowwindowops; +extern char *termname; +extern unsigned int tabspaces; +extern unsigned int defaultfg; +extern unsigned int defaultbg; diff --git a/src/sxmo-st/st.info b/src/sxmo-st/st.info new file mode 100644 index 0000000..8201ad6 --- /dev/null +++ b/src/sxmo-st/st.info @@ -0,0 +1,239 @@ +st-mono| simpleterm monocolor, + acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + am, + bce, + bel=^G, + blink=\E[5m, + bold=\E[1m, + cbt=\E[Z, + cvvis=\E[?25h, + civis=\E[?25l, + clear=\E[H\E[2J, + cnorm=\E[?12l\E[?25h, + colors#2, + cols#80, + cr=^M, + csr=\E[%i%p1%d;%p2%dr, + cub=\E[%p1%dD, + cub1=^H, + cud1=^J, + cud=\E[%p1%dB, + cuf1=\E[C, + cuf=\E[%p1%dC, + cup=\E[%i%p1%d;%p2%dH, + cuu1=\E[A, + cuu=\E[%p1%dA, + dch=\E[%p1%dP, + dch1=\E[P, + dim=\E[2m, + dl=\E[%p1%dM, + dl1=\E[M, + ech=\E[%p1%dX, + ed=\E[J, + el=\E[K, + el1=\E[1K, + enacs=\E)0, + flash=\E[?5h$<80/>\E[?5l, + fsl=^G, + home=\E[H, + hpa=\E[%i%p1%dG, + hs, + ht=^I, + hts=\EH, + ich=\E[%p1%d@, + il1=\E[L, + il=\E[%p1%dL, + ind=^J, + indn=\E[%p1%dS, + invis=\E[8m, + is2=\E[4l\E>\E[?1034l, + it#8, + kel=\E[1;2F, + ked=\E[1;5F, + ka1=\E[1~, + ka3=\E[5~, + kc1=\E[4~, + kc3=\E[6~, + kbs=\177, + kcbt=\E[Z, + kb2=\EOu, + kcub1=\EOD, + kcud1=\EOB, + kcuf1=\EOC, + kcuu1=\EOA, + kDC=\E[3;2~, + kent=\EOM, + kEND=\E[1;2F, + kIC=\E[2;2~, + kNXT=\E[6;2~, + kPRV=\E[5;2~, + kHOM=\E[1;2H, + kLFT=\E[1;2D, + kRIT=\E[1;2C, + kind=\E[1;2B, + kri=\E[1;2A, + kclr=\E[3;5~, + kdl1=\E[3;2~, + kdch1=\E[3~, + kich1=\E[2~, + kend=\E[4~, + kf1=\EOP, + kf2=\EOQ, + kf3=\EOR, + kf4=\EOS, + kf5=\E[15~, + kf6=\E[17~, + kf7=\E[18~, + kf8=\E[19~, + kf9=\E[20~, + kf10=\E[21~, + kf11=\E[23~, + kf12=\E[24~, + kf13=\E[1;2P, + kf14=\E[1;2Q, + kf15=\E[1;2R, + kf16=\E[1;2S, + kf17=\E[15;2~, + kf18=\E[17;2~, + kf19=\E[18;2~, + kf20=\E[19;2~, + kf21=\E[20;2~, + kf22=\E[21;2~, + kf23=\E[23;2~, + kf24=\E[24;2~, + kf25=\E[1;5P, + kf26=\E[1;5Q, + kf27=\E[1;5R, + kf28=\E[1;5S, + kf29=\E[15;5~, + kf30=\E[17;5~, + kf31=\E[18;5~, + kf32=\E[19;5~, + kf33=\E[20;5~, + kf34=\E[21;5~, + kf35=\E[23;5~, + kf36=\E[24;5~, + kf37=\E[1;6P, + kf38=\E[1;6Q, + kf39=\E[1;6R, + kf40=\E[1;6S, + kf41=\E[15;6~, + kf42=\E[17;6~, + kf43=\E[18;6~, + kf44=\E[19;6~, + kf45=\E[20;6~, + kf46=\E[21;6~, + kf47=\E[23;6~, + kf48=\E[24;6~, + kf49=\E[1;3P, + kf50=\E[1;3Q, + kf51=\E[1;3R, + kf52=\E[1;3S, + kf53=\E[15;3~, + kf54=\E[17;3~, + kf55=\E[18;3~, + kf56=\E[19;3~, + kf57=\E[20;3~, + kf58=\E[21;3~, + kf59=\E[23;3~, + kf60=\E[24;3~, + kf61=\E[1;4P, + kf62=\E[1;4Q, + kf63=\E[1;4R, + khome=\E[1~, + kil1=\E[2;5~, + krmir=\E[2;2~, + knp=\E[6~, + kmous=\E[M, + kpp=\E[5~, + lines#24, + mir, + msgr, + npc, + op=\E[39;49m, + pairs#64, + mc0=\E[i, + mc4=\E[4i, + mc5=\E[5i, + rc=\E8, + rev=\E[7m, + ri=\EM, + rin=\E[%p1%dT, + ritm=\E[23m, + rmacs=\E(B, + rmcup=\E[?1049l, + rmir=\E[4l, + rmkx=\E[?1l\E>, + rmso=\E[27m, + rmul=\E[24m, + rs1=\Ec, + rs2=\E[4l\E>\E[?1034l, + sc=\E7, + sitm=\E[3m, + sgr0=\E[0m, + smacs=\E(0, + smcup=\E[?1049h, + smir=\E[4h, + smkx=\E[?1h\E=, + smso=\E[7m, + smul=\E[4m, + tbc=\E[3g, + tsl=\E]0;, + xenl, + vpa=\E[%i%p1%dd, +# XTerm extensions + rmxx=\E[29m, + smxx=\E[9m, +# disabled rep for now: causes some issues with older ncurses versions. +# rep=%p1%c\E[%p2%{1}%-%db, +# tmux extensions, see TERMINFO EXTENSIONS in tmux(1) + Tc, + Ms=\E]52;%p1%s;%p2%s\007, + Se=\E[2 q, + Ss=\E[%p1%d q, + +st| simpleterm, + use=st-mono, + colors#8, + setab=\E[4%p1%dm, + setaf=\E[3%p1%dm, + setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, + setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, + sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, + +st-256color| simpleterm with 256 colors, + use=st, + ccc, + colors#256, + oc=\E]104\007, + pairs#32767, +# Nicked from xterm-256color + initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, + setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m, + setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m, + +st-meta| simpleterm with meta key, + use=st, + km, + rmm=\E[?1034l, + smm=\E[?1034h, + rs2=\E[4l\E>\E[?1034h, + is2=\E[4l\E>\E[?1034h, + +st-meta-256color| simpleterm with meta key and 256 colors, + use=st-256color, + km, + rmm=\E[?1034l, + smm=\E[?1034h, + rs2=\E[4l\E>\E[?1034h, + is2=\E[4l\E>\E[?1034h, + +st-bs| simpleterm with backspace as backspace, + use=st, + kbs=\010, + kdch1=\177, + +st-bs-256color| simpleterm with backspace as backspace and 256colors, + use=st-256color, + kbs=\010, + kdch1=\177, diff --git a/src/sxmo-st/win.h b/src/sxmo-st/win.h new file mode 100644 index 0000000..a6ef1b9 --- /dev/null +++ b/src/sxmo-st/win.h @@ -0,0 +1,39 @@ +/* See LICENSE for license details. */ + +enum win_mode { + MODE_VISIBLE = 1 << 0, + MODE_FOCUSED = 1 << 1, + MODE_APPKEYPAD = 1 << 2, + MODE_MOUSEBTN = 1 << 3, + MODE_MOUSEMOTION = 1 << 4, + MODE_REVERSE = 1 << 5, + MODE_KBDLOCK = 1 << 6, + MODE_HIDE = 1 << 7, + MODE_APPCURSOR = 1 << 8, + MODE_MOUSESGR = 1 << 9, + MODE_8BIT = 1 << 10, + MODE_BLINK = 1 << 11, + MODE_FBLINK = 1 << 12, + MODE_FOCUS = 1 << 13, + MODE_MOUSEX10 = 1 << 14, + MODE_MOUSEMANY = 1 << 15, + MODE_BRCKTPASTE = 1 << 16, + MODE_NUMLOCK = 1 << 17, + MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\ + |MODE_MOUSEMANY, +}; + +void xbell(void); +void xclipcopy(void); +void xdrawcursor(int, int, Glyph, int, int, Glyph); +void xdrawline(Line, int, int, int); +void xfinishdraw(void); +void xloadcols(void); +int xsetcolorname(int, const char *); +void xsettitle(char *); +int xsetcursor(int); +void xsetmode(int, unsigned int); +void xsetpointermotion(int); +void xsetsel(char *); +int xstartdraw(void); +void xximspot(int, int); diff --git a/src/sxmo-st/x.c b/src/sxmo-st/x.c new file mode 100644 index 0000000..c399523 --- /dev/null +++ b/src/sxmo-st/x.c @@ -0,0 +1,2188 @@ +/* See LICENSE for license details. */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *argv0; +#include "arg.h" +#include "st.h" +#include "win.h" +#include "hb.h" + +/* types used in config.h */ +typedef struct { + uint mod; + KeySym keysym; + void (*func)(const Arg *); + const Arg arg; +} Shortcut; + +typedef struct { + uint mod; + uint button; + void (*func)(const Arg *); + const Arg arg; + uint release; +} MouseShortcut; + +typedef struct { + KeySym k; + uint mask; + char *s; + /* three-valued logic variables: 0 indifferent, 1 on, -1 off */ + signed char appkey; /* application keypad */ + signed char appcursor; /* application cursor */ +} Key; + +/* Xresources preferences */ +enum resource_type { + STRING = 0, + INTEGER = 1, + FLOAT = 2 +}; + +typedef struct { + char *name; + enum resource_type type; + void *dst; +} ResourcePref; + +/* X modifiers */ +#define XK_ANY_MOD UINT_MAX +#define XK_NO_MOD 0 +#define XK_SWITCH_MOD (1<<13) + +/* function definitions used in config.h */ +static void clipcopy(const Arg *); +static void clippaste(const Arg *); +static void numlock(const Arg *); +static void selpaste(const Arg *); +static void zoom(const Arg *); +static void zoomabs(const Arg *); +static void zoomreset(const Arg *); +static void ttysend(const Arg *); +static void invert(const Arg *); +static void toggleselectionmode(const Arg *); + +/* config.h for applying patches and the configuration. */ +#include "config.h" + +/* XEMBED messages */ +#define XEMBED_FOCUS_IN 4 +#define XEMBED_FOCUS_OUT 5 + +/* macros */ +#define IS_SET(flag) ((win.mode & (flag)) != 0) +#define TRUERED(x) (((x) & 0xff0000) >> 8) +#define TRUEGREEN(x) (((x) & 0xff00)) +#define TRUEBLUE(x) (((x) & 0xff) << 8) + +typedef XftDraw *Draw; +typedef XftColor Color; +typedef XftGlyphFontSpec GlyphFontSpec; + +/* Purely graphic info */ +typedef struct { + int tw, th; /* tty width and height */ + int w, h; /* window width and height */ + int ch; /* char height */ + int cw; /* char width */ + int mode; /* window state/mode flags */ + int cursor; /* cursor style */ +} TermWindow; + +typedef struct { + Display *dpy; + Colormap cmap; + Window win; + Drawable buf; + GlyphFontSpec *specbuf; /* font spec buffer used for rendering */ + Atom xembed, wmdeletewin, netwmname, netwmpid, selectionmode; + struct { + XIM xim; + XIC xic; + XPoint spot; + XVaNestedList spotlist; + } ime; + Draw draw; + Visual *vis; + XSetWindowAttributes attrs; + int scr; + int isfixed; /* is fixed geometry? */ + int l, t; /* left and top offset */ + int gm; /* geometry mask */ +} XWindow; + +typedef struct { + Atom xtarget; + char *primary, *clipboard; + struct timespec tclick1; + struct timespec tclick2; +} XSelection; + +/* Font structure */ +#define Font Font_ +typedef struct { + int height; + int width; + int ascent; + int descent; + int badslant; + int badweight; + short lbearing; + short rbearing; + XftFont *match; + FcFontSet *set; + FcPattern *pattern; +} Font; + +/* Drawing Context */ +typedef struct { + Color *col; + size_t collen; + Font font, bfont, ifont, ibfont; + GC gc; +} DC; + +static inline ushort sixd_to_16bit(int); +static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int); +static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int); +static void xdrawglyph(Glyph, int, int); +static void xclear(int, int, int, int); +static int xgeommasktogravity(int); +static int ximopen(Display *); +static void ximinstantiate(Display *, XPointer, XPointer); +static void ximdestroy(XIM, XPointer, XPointer); +static int xicdestroy(XIC, XPointer, XPointer); +static void xinit(int, int); +static void cresize(int, int); +static void xresize(int, int); +static void xhints(void); +static int xloadcolor(int, const char *, Color *); +static int xloadfont(Font *, FcPattern *); +static void xloadfonts(char *, double); +static void xunloadfont(Font *); +static void xunloadfonts(void); +static void xsetenv(void); +static void xseturgency(int); +static int evcol(XEvent *); +static int evrow(XEvent *); + +static void expose(XEvent *); +static void visibility(XEvent *); +static void unmap(XEvent *); +static void kpress(XEvent *); +static void cmessage(XEvent *); +static void resize(XEvent *); +static void focus(XEvent *); +static uint buttonmask(uint); +static int mouseaction(XEvent *, uint); +static void brelease(XEvent *); +static void bpress(XEvent *); +static void bmotion(XEvent *); +static void propnotify(XEvent *); +static void selnotify(XEvent *); +static void selclear_(XEvent *); +static void selrequest(XEvent *); +static void setsel(char *, Time); +static void mousesel(XEvent *, int); +static void mousereport(XEvent *); +static char *kmap(KeySym, uint); +static int match(uint, uint); +static void updateselectionmodeatom(void); + +static void run(void); +static void usage(void); + +static void (*handler[LASTEvent])(XEvent *) = { + [KeyPress] = kpress, + [ClientMessage] = cmessage, + [ConfigureNotify] = resize, + [VisibilityNotify] = visibility, + [UnmapNotify] = unmap, + [Expose] = expose, + [FocusIn] = focus, + [FocusOut] = focus, + [MotionNotify] = bmotion, + [ButtonPress] = bpress, + [ButtonRelease] = brelease, +/* + * Uncomment if you want the selection to disappear when you select something + * different in another window. + */ + [SelectionClear] = selclear_, + [SelectionNotify] = selnotify, +/* + * PropertyNotify is only turned on when there is some INCR transfer happening + * for the selection retrieval. + */ + [PropertyNotify] = propnotify, + [SelectionRequest] = selrequest, +}; + +/* Globals */ +static DC dc; +static XWindow xw; +static XSelection xsel; +static TermWindow win; + +/* Font Ring Cache */ +enum { + FRC_NORMAL, + FRC_ITALIC, + FRC_BOLD, + FRC_ITALICBOLD +}; + +typedef struct { + XftFont *font; + int flags; + Rune unicodep; +} Fontcache; + +/* Fontcache is an array now. A new font will be appended to the array. */ +static Fontcache *frc = NULL; +static int frclen = 0; +static int frccap = 0; +static char *usedfont = NULL; +static double usedfontsize = 0; +static double defaultfontsize = 0; + +static char *opt_class = NULL; +static char **opt_cmd = NULL; +static char *opt_embed = NULL; +static char *opt_font = NULL; +static char *opt_io = NULL; +static char *opt_line = NULL; +static char *opt_name = NULL; +static char *opt_title = NULL; + +static int invertcolors = 0; +static int oldbutton = 3; /* button event on startup: 3 = release */ +static int selectionmodeenabled = 0; + +void +invert(const Arg *dummy) +{ + invertcolors = !invertcolors; + redraw(); +} + +void +toggleselectionmode(const Arg *dummy) +{ + selectionmodeenabled = !selectionmodeenabled; + selclear(); + updateselectionmodeatom(); +} + +Color +invertedcolor(Color *clr) { + XRenderColor rc; + Color inverted; + rc.red = ~clr->color.red; + rc.green = ~clr->color.green; + rc.blue = ~clr->color.blue; + rc.alpha = clr->color.alpha; + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &rc, &inverted); + return inverted; +} + +void +clipcopy(const Arg *dummy) +{ + Atom clipboard; + + free(xsel.clipboard); + xsel.clipboard = NULL; + + if (xsel.primary != NULL) { + xsel.clipboard = xstrdup(xsel.primary); + clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); + XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime); + } +} + +void +clippaste(const Arg *dummy) +{ + Atom clipboard; + + clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); + XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard, + xw.win, CurrentTime); +} + +void +selpaste(const Arg *dummy) +{ + XConvertSelection(xw.dpy, XA_PRIMARY, xsel.xtarget, XA_PRIMARY, + xw.win, CurrentTime); +} + +void +numlock(const Arg *dummy) +{ + win.mode ^= MODE_NUMLOCK; +} + +void +zoom(const Arg *arg) +{ + Arg larg; + + larg.f = usedfontsize + arg->f; + zoomabs(&larg); +} + +void +zoomabs(const Arg *arg) +{ + xunloadfonts(); + xloadfonts(usedfont, arg->f); + cresize(0, 0); + redraw(); + xhints(); +} + +void +zoomreset(const Arg *arg) +{ + Arg larg; + + if (defaultfontsize > 0) { + larg.f = defaultfontsize; + zoomabs(&larg); + } +} + +void +ttysend(const Arg *arg) +{ + ttywrite(arg->s, strlen(arg->s), 1); +} + +int +evcol(XEvent *e) +{ + int x = e->xbutton.x - borderpx; + LIMIT(x, 0, win.tw - 1); + return x / win.cw; +} + +int +evrow(XEvent *e) +{ + int y = e->xbutton.y - borderpx; + LIMIT(y, 0, win.th - 1); + return y / win.ch; +} + +void +mousesel(XEvent *e, int done) +{ + int type, seltype = SEL_REGULAR; + uint state = e->xbutton.state & ~(Button1Mask | forcemousemod); + + for (type = 1; type < LEN(selmasks); ++type) { + if (match(selmasks[type], state)) { + seltype = type; + break; + } + } + selextend(evcol(e), evrow(e), seltype, done); + if (done) + setsel(getsel(), e->xbutton.time); +} + +void +mousereport(XEvent *e) +{ + int len, x = evcol(e), y = evrow(e), + button = e->xbutton.button, state = e->xbutton.state; + char buf[40]; + static int ox, oy; + + /* from urxvt */ + if (e->xbutton.type == MotionNotify) { + if (x == ox && y == oy) + return; + if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY)) + return; + /* MOUSE_MOTION: no reporting if no button is pressed */ + if (IS_SET(MODE_MOUSEMOTION) && oldbutton == 3) + return; + + button = oldbutton + 32; + ox = x; + oy = y; + } else { + if (!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) { + button = 3; + } else { + button -= Button1; + if (button >= 3) + button += 64 - 3; + } + if (e->xbutton.type == ButtonPress) { + oldbutton = button; + ox = x; + oy = y; + } else if (e->xbutton.type == ButtonRelease) { + oldbutton = 3; + /* MODE_MOUSEX10: no button release reporting */ + if (IS_SET(MODE_MOUSEX10)) + return; + if (button == 64 || button == 65) + return; + } + } + + if (!IS_SET(MODE_MOUSEX10)) { + button += ((state & ShiftMask ) ? 4 : 0) + + ((state & Mod4Mask ) ? 8 : 0) + + ((state & ControlMask) ? 16 : 0); + } + + if (IS_SET(MODE_MOUSESGR)) { + len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c", + button, x+1, y+1, + e->xbutton.type == ButtonRelease ? 'm' : 'M'); + } else if (x < 223 && y < 223) { + len = snprintf(buf, sizeof(buf), "\033[M%c%c%c", + 32+button, 32+x+1, 32+y+1); + } else { + return; + } + + ttywrite(buf, len, 0); +} + +uint +buttonmask(uint button) +{ + return button == Button1 ? Button1Mask + : button == Button2 ? Button2Mask + : button == Button3 ? Button3Mask + : button == Button4 ? Button4Mask + : button == Button5 ? Button5Mask + : 0; +} + +int +mouseaction(XEvent *e, uint release) +{ + MouseShortcut *ms; + + /* ignore Buttonmask for Button - it's set on release */ + uint state = e->xbutton.state & ~buttonmask(e->xbutton.button); + + for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { + if (ms->release == release && + ms->button == e->xbutton.button && + (match(ms->mod, state) || /* exact or forced */ + match(ms->mod, state & ~forcemousemod))) { + ms->func(&(ms->arg)); + return 1; + } + } + + return 0; +} + +void +bpress(XEvent *e) +{ + struct timespec now; + int snap; + + if (!selectionmodeenabled) + return; + + if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) { + mousereport(e); + return; + } + + if (mouseaction(e, 0)) + return; + + if (e->xbutton.button == Button1) { + /* + * If the user clicks below predefined timeouts specific + * snapping behaviour is exposed. + */ + clock_gettime(CLOCK_MONOTONIC, &now); + if (TIMEDIFF(now, xsel.tclick2) <= tripleclicktimeout) { + snap = SNAP_LINE; + } else if (TIMEDIFF(now, xsel.tclick1) <= doubleclicktimeout) { + snap = SNAP_WORD; + } else { + snap = 0; + } + xsel.tclick2 = xsel.tclick1; + xsel.tclick1 = now; + + selstart(evcol(e), evrow(e), snap); + } +} + +void +propnotify(XEvent *e) +{ + XPropertyEvent *xpev; + Atom clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); + + xpev = &e->xproperty; + if (xpev->state == PropertyNewValue && + (xpev->atom == XA_PRIMARY || + xpev->atom == clipboard)) { + selnotify(e); + } +} + +void +selnotify(XEvent *e) +{ + ulong nitems, ofs, rem; + int format; + uchar *data, *last, *repl; + Atom type, incratom, property = None; + + incratom = XInternAtom(xw.dpy, "INCR", 0); + + ofs = 0; + if (e->type == SelectionNotify) + property = e->xselection.property; + else if (e->type == PropertyNotify) + property = e->xproperty.atom; + + if (property == None) + return; + + do { + if (XGetWindowProperty(xw.dpy, xw.win, property, ofs, + BUFSIZ/4, False, AnyPropertyType, + &type, &format, &nitems, &rem, + &data)) { + fprintf(stderr, "Clipboard allocation failed\n"); + return; + } + + if (e->type == PropertyNotify && nitems == 0 && rem == 0) { + /* + * If there is some PropertyNotify with no data, then + * this is the signal of the selection owner that all + * data has been transferred. We won't need to receive + * PropertyNotify events anymore. + */ + MODBIT(xw.attrs.event_mask, 0, PropertyChangeMask); + XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, + &xw.attrs); + } + + if (type == incratom) { + /* + * Activate the PropertyNotify events so we receive + * when the selection owner does send us the next + * chunk of data. + */ + MODBIT(xw.attrs.event_mask, 1, PropertyChangeMask); + XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, + &xw.attrs); + + /* + * Deleting the property is the transfer start signal. + */ + XDeleteProperty(xw.dpy, xw.win, (int)property); + continue; + } + + /* + * As seen in getsel: + * Line endings are inconsistent in the terminal and GUI world + * copy and pasting. When receiving some selection data, + * replace all '\n' with '\r'. + * FIXME: Fix the computer world. + */ + repl = data; + last = data + nitems * format / 8; + while ((repl = memchr(repl, '\n', last - repl))) { + *repl++ = '\r'; + } + + if (IS_SET(MODE_BRCKTPASTE) && ofs == 0) + ttywrite("\033[200~", 6, 0); + ttywrite((char *)data, nitems * format / 8, 1); + if (IS_SET(MODE_BRCKTPASTE) && rem == 0) + ttywrite("\033[201~", 6, 0); + XFree(data); + /* number of 32-bit chunks returned */ + ofs += nitems * format / 32; + } while (rem > 0); + + /* + * Deleting the property again tells the selection owner to send the + * next data chunk in the property. + */ + XDeleteProperty(xw.dpy, xw.win, (int)property); +} + +void +xclipcopy(void) +{ + clipcopy(NULL); +} + +void +selclear_(XEvent *e) +{ + selclear(); +} + +void +selrequest(XEvent *e) +{ + XSelectionRequestEvent *xsre; + XSelectionEvent xev; + Atom xa_targets, string, clipboard; + char *seltext; + + xsre = (XSelectionRequestEvent *) e; + xev.type = SelectionNotify; + xev.requestor = xsre->requestor; + xev.selection = xsre->selection; + xev.target = xsre->target; + xev.time = xsre->time; + if (xsre->property == None) + xsre->property = xsre->target; + + /* reject */ + xev.property = None; + + xa_targets = XInternAtom(xw.dpy, "TARGETS", 0); + if (xsre->target == xa_targets) { + /* respond with the supported type */ + string = xsel.xtarget; + XChangeProperty(xsre->display, xsre->requestor, xsre->property, + XA_ATOM, 32, PropModeReplace, + (uchar *) &string, 1); + xev.property = xsre->property; + } else if (xsre->target == xsel.xtarget || xsre->target == XA_STRING) { + /* + * xith XA_STRING non ascii characters may be incorrect in the + * requestor. It is not our problem, use utf8. + */ + clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); + if (xsre->selection == XA_PRIMARY) { + seltext = xsel.primary; + } else if (xsre->selection == clipboard) { + seltext = xsel.clipboard; + } else { + fprintf(stderr, + "Unhandled clipboard selection 0x%lx\n", + xsre->selection); + return; + } + if (seltext != NULL) { + XChangeProperty(xsre->display, xsre->requestor, + xsre->property, xsre->target, + 8, PropModeReplace, + (uchar *)seltext, strlen(seltext)); + xev.property = xsre->property; + } + } + + /* all done, send a notification to the listener */ + if (!XSendEvent(xsre->display, xsre->requestor, 1, 0, (XEvent *) &xev)) + fprintf(stderr, "Error sending SelectionNotify event\n"); +} + +void +setsel(char *str, Time t) +{ + if (!str) + return; + + free(xsel.primary); + xsel.primary = str; + + XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); + if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) + selclear(); +} + +void +xsetsel(char *str) +{ + setsel(str, CurrentTime); +} + +void +brelease(XEvent *e) +{ + if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) { + mousereport(e); + return; + } + + if (mouseaction(e, 1)) + return; + if (e->xbutton.button == Button1) + mousesel(e, 1); +} + +void +bmotion(XEvent *e) +{ + if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) { + mousereport(e); + return; + } + + mousesel(e, 0); +} + +void +cresize(int width, int height) +{ + int col, row; + + if (width != 0) + win.w = width; + if (height != 0) + win.h = height; + + col = (win.w - 2 * borderpx) / win.cw; + row = (win.h - 2 * borderpx) / win.ch; + col = MAX(1, col); + row = MAX(1, row); + + tresize(col, row); + xresize(col, row); + ttyresize(win.tw, win.th); +} + +void +xresize(int col, int row) +{ + win.tw = col * win.cw; + win.th = row * win.ch; + + XFreePixmap(xw.dpy, xw.buf); + xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, + DefaultDepth(xw.dpy, xw.scr)); + XftDrawChange(xw.draw, xw.buf); + xclear(0, 0, win.w, win.h); + + /* resize to new width */ + xw.specbuf = xrealloc(xw.specbuf, col * sizeof(GlyphFontSpec)); +} + +ushort +sixd_to_16bit(int x) +{ + return x == 0 ? 0 : 0x3737 + 0x2828 * x; +} + +int +xloadcolor(int i, const char *name, Color *ncolor) +{ + XRenderColor color = { .alpha = 0xffff }; + + if (!name) { + if (BETWEEN(i, 16, 255)) { /* 256 color */ + if (i < 6*6*6+16) { /* same colors as xterm */ + color.red = sixd_to_16bit( ((i-16)/36)%6 ); + color.green = sixd_to_16bit( ((i-16)/6) %6 ); + color.blue = sixd_to_16bit( ((i-16)/1) %6 ); + } else { /* greyscale */ + color.red = 0x0808 + 0x0a0a * (i - (6*6*6+16)); + color.green = color.blue = color.red; + } + return XftColorAllocValue(xw.dpy, xw.vis, + xw.cmap, &color, ncolor); + } else + name = colorname[i]; + } + + return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); +} + +void +xloadcols(void) +{ + int i; + static int loaded; + Color *cp; + + if (loaded) { + for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) + XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); + } else { + dc.collen = MAX(LEN(colorname), 256); + dc.col = xmalloc(dc.collen * sizeof(Color)); + } + + for (i = 0; i < dc.collen; i++) + if (!xloadcolor(i, NULL, &dc.col[i])) { + if (colorname[i]) + die("could not allocate color '%s'\n", colorname[i]); + else + die("could not allocate color %d\n", i); + } + loaded = 1; +} + +int +xsetcolorname(int x, const char *name) +{ + Color ncolor; + + if (!BETWEEN(x, 0, dc.collen)) + return 1; + + if (!xloadcolor(x, name, &ncolor)) + return 1; + + XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); + dc.col[x] = ncolor; + + return 0; +} + +/* + * Absolute coordinates. + */ +void +xclear(int x1, int y1, int x2, int y2) +{ + Color c; + c = dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg]; + if (invertcolors) { + c = invertedcolor(&c); + } + XftDrawRect(xw.draw, &c, x1, y1, x2-x1, y2-y1); +} + +void +xhints(void) +{ + XClassHint class = {opt_name ? opt_name : termname, + opt_class ? opt_class : termname}; + XWMHints wm = {.flags = InputHint, .input = 1}; + XSizeHints *sizeh; + + sizeh = XAllocSizeHints(); + + sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize; + sizeh->height = win.h; + sizeh->width = win.w; + sizeh->height_inc = win.ch; + sizeh->width_inc = win.cw; + sizeh->base_height = 2 * borderpx; + sizeh->base_width = 2 * borderpx; + sizeh->min_height = win.ch + 2 * borderpx; + sizeh->min_width = win.cw + 2 * borderpx; + if (xw.isfixed) { + sizeh->flags |= PMaxSize; + sizeh->min_width = sizeh->max_width = win.w; + sizeh->min_height = sizeh->max_height = win.h; + } + if (xw.gm & (XValue|YValue)) { + sizeh->flags |= USPosition | PWinGravity; + sizeh->x = xw.l; + sizeh->y = xw.t; + sizeh->win_gravity = xgeommasktogravity(xw.gm); + } + + XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm, + &class); + XFree(sizeh); +} + +int +xgeommasktogravity(int mask) +{ + switch (mask & (XNegative|YNegative)) { + case 0: + return NorthWestGravity; + case XNegative: + return NorthEastGravity; + case YNegative: + return SouthWestGravity; + } + + return SouthEastGravity; +} + +int +xloadfont(Font *f, FcPattern *pattern) +{ + FcPattern *configured; + FcPattern *match; + FcResult result; + XGlyphInfo extents; + int wantattr, haveattr; + + /* + * Manually configure instead of calling XftMatchFont + * so that we can use the configured pattern for + * "missing glyph" lookups. + */ + configured = FcPatternDuplicate(pattern); + if (!configured) + return 1; + + FcConfigSubstitute(NULL, configured, FcMatchPattern); + XftDefaultSubstitute(xw.dpy, xw.scr, configured); + + match = FcFontMatch(NULL, configured, &result); + if (!match) { + FcPatternDestroy(configured); + return 1; + } + + if (!(f->match = XftFontOpenPattern(xw.dpy, match))) { + FcPatternDestroy(configured); + FcPatternDestroy(match); + return 1; + } + + if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) == + XftResultMatch)) { + /* + * Check if xft was unable to find a font with the appropriate + * slant but gave us one anyway. Try to mitigate. + */ + if ((XftPatternGetInteger(f->match->pattern, "slant", 0, + &haveattr) != XftResultMatch) || haveattr < wantattr) { + f->badslant = 1; + fputs("font slant does not match\n", stderr); + } + } + + if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) == + XftResultMatch)) { + if ((XftPatternGetInteger(f->match->pattern, "weight", 0, + &haveattr) != XftResultMatch) || haveattr != wantattr) { + f->badweight = 1; + fputs("font weight does not match\n", stderr); + } + } + + XftTextExtentsUtf8(xw.dpy, f->match, + (const FcChar8 *) ascii_printable, + strlen(ascii_printable), &extents); + + f->set = NULL; + f->pattern = configured; + + f->ascent = f->match->ascent; + f->descent = f->match->descent; + f->lbearing = 0; + f->rbearing = f->match->max_advance_width; + + f->height = f->ascent + f->descent; + f->width = DIVCEIL(extents.xOff, strlen(ascii_printable)); + + return 0; +} + +void +xloadfonts(char *fontstr, double fontsize) +{ + FcPattern *pattern; + double fontval; + + if (fontstr[0] == '-') + pattern = XftXlfdParse(fontstr, False, False); + else + pattern = FcNameParse((FcChar8 *)fontstr); + + if (!pattern) + die("can't open font %s\n", fontstr); + + if (fontsize > 1) { + FcPatternDel(pattern, FC_PIXEL_SIZE); + FcPatternDel(pattern, FC_SIZE); + FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize); + usedfontsize = fontsize; + } else { + if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) == + FcResultMatch) { + usedfontsize = fontval; + } else if (FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) == + FcResultMatch) { + usedfontsize = -1; + } else { + /* + * Default font size is 12, if none given. This is to + * have a known usedfontsize value. + */ + FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12); + usedfontsize = 12; + } + defaultfontsize = usedfontsize; + } + + if (xloadfont(&dc.font, pattern)) + die("can't open font %s\n", fontstr); + + if (usedfontsize < 0) { + FcPatternGetDouble(dc.font.match->pattern, + FC_PIXEL_SIZE, 0, &fontval); + usedfontsize = fontval; + if (fontsize == 0) + defaultfontsize = fontval; + } + + /* Setting character width and height. */ + win.cw = ceilf(dc.font.width * cwscale); + win.ch = ceilf(dc.font.height * chscale); + + FcPatternDel(pattern, FC_SLANT); + FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); + if (xloadfont(&dc.ifont, pattern)) + die("can't open font %s\n", fontstr); + + FcPatternDel(pattern, FC_WEIGHT); + FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); + if (xloadfont(&dc.ibfont, pattern)) + die("can't open font %s\n", fontstr); + + FcPatternDel(pattern, FC_SLANT); + FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); + if (xloadfont(&dc.bfont, pattern)) + die("can't open font %s\n", fontstr); + + FcPatternDestroy(pattern); +} + +void +xunloadfont(Font *f) +{ + XftFontClose(xw.dpy, f->match); + FcPatternDestroy(f->pattern); + if (f->set) + FcFontSetDestroy(f->set); +} + +void +xunloadfonts(void) +{ + /* Clear HarfBuzz font cache. */ + hbunloadfonts(); + + /* Free the loaded fonts in the font cache. */ + while (frclen > 0) + XftFontClose(xw.dpy, frc[--frclen].font); + + xunloadfont(&dc.font); + xunloadfont(&dc.bfont); + xunloadfont(&dc.ifont); + xunloadfont(&dc.ibfont); +} + +int +ximopen(Display *dpy) +{ + XIMCallback imdestroy = { .client_data = NULL, .callback = ximdestroy }; + XICCallback icdestroy = { .client_data = NULL, .callback = xicdestroy }; + + xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL); + if (xw.ime.xim == NULL) + return 0; + + if (XSetIMValues(xw.ime.xim, XNDestroyCallback, &imdestroy, NULL)) + fprintf(stderr, "XSetIMValues: " + "Could not set XNDestroyCallback.\n"); + + xw.ime.spotlist = XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot, + NULL); + + if (xw.ime.xic == NULL) { + xw.ime.xic = XCreateIC(xw.ime.xim, XNInputStyle, + XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, xw.win, + XNDestroyCallback, &icdestroy, + NULL); + } + if (xw.ime.xic == NULL) + fprintf(stderr, "XCreateIC: Could not create input context.\n"); + + return 1; +} + +void +ximinstantiate(Display *dpy, XPointer client, XPointer call) +{ + if (ximopen(dpy)) + XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, + ximinstantiate, NULL); +} + +void +ximdestroy(XIM xim, XPointer client, XPointer call) +{ + xw.ime.xim = NULL; + XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, + ximinstantiate, NULL); + XFree(xw.ime.spotlist); +} + +int +xicdestroy(XIC xim, XPointer client, XPointer call) +{ + xw.ime.xic = NULL; + return 1; +} + +void +xinit(int cols, int rows) +{ + XGCValues gcvalues; + Cursor cursor; + Window parent; + pid_t thispid = getpid(); + XColor xmousefg, xmousebg; + + xw.scr = XDefaultScreen(xw.dpy); + xw.vis = XDefaultVisual(xw.dpy, xw.scr); + + /* font */ + if (!FcInit()) + die("could not init fontconfig.\n"); + + usedfont = (opt_font == NULL)? font : opt_font; + xloadfonts(usedfont, 0); + + /* colors */ + xw.cmap = XDefaultColormap(xw.dpy, xw.scr); + xloadcols(); + + /* adjust fixed window geometry */ + win.w = 2 * borderpx + cols * win.cw; + win.h = 2 * borderpx + rows * win.ch; + if (xw.gm & XNegative) + xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2; + if (xw.gm & YNegative) + xw.t += DisplayHeight(xw.dpy, xw.scr) - win.h - 2; + + /* Events */ + xw.attrs.background_pixel = dc.col[defaultbg].pixel; + xw.attrs.border_pixel = dc.col[defaultbg].pixel; + xw.attrs.bit_gravity = NorthWestGravity; + xw.attrs.event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask + | ExposureMask | VisibilityChangeMask | StructureNotifyMask + | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; + xw.attrs.colormap = xw.cmap; + + if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) + parent = XRootWindow(xw.dpy, xw.scr); + xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, + win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, + xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity + | CWEventMask | CWColormap, &xw.attrs); + + memset(&gcvalues, 0, sizeof(gcvalues)); + gcvalues.graphics_exposures = False; + dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, + &gcvalues); + xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, + DefaultDepth(xw.dpy, xw.scr)); + XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); + XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); + + /* font spec buffer */ + xw.specbuf = xmalloc(cols * sizeof(GlyphFontSpec)); + + /* Xft rendering context */ + xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); + + /* input methods */ + if (!ximopen(xw.dpy)) { + XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, + ximinstantiate, NULL); + } + + /* invisible 1x1 cursor for keypad-only hardware */ + { + Pixmap blank; + static const char blankdata[1] = {0}; + memset(&xmousefg, 0, sizeof(xmousefg)); + memset(&xmousebg, 0, sizeof(xmousebg)); + blank = XCreateBitmapFromData(xw.dpy, xw.win, blankdata, 1, 1); + cursor = XCreatePixmapCursor(xw.dpy, blank, blank, &xmousefg, &xmousebg, 0, 0); + XFreePixmap(xw.dpy, blank); + XDefineCursor(xw.dpy, xw.win, cursor); + } + + xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); + xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); + xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False); + XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1); + + xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False); + XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32, + PropModeReplace, (uchar *)&thispid, 1); + + xw.selectionmode = XInternAtom(xw.dpy, "_ST_SELMODE", False); + updateselectionmodeatom(); + + win.mode = MODE_NUMLOCK; + resettitle(); + xhints(); + XMapWindow(xw.dpy, xw.win); + XSync(xw.dpy, False); + + clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1); + clock_gettime(CLOCK_MONOTONIC, &xsel.tclick2); + xsel.primary = NULL; + xsel.clipboard = NULL; + xsel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0); + if (xsel.xtarget == None) + xsel.xtarget = XA_STRING; +} + +int +xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y) +{ + float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp; + ushort mode, prevmode = USHRT_MAX; + Font *font = &dc.font; + int frcflags = FRC_NORMAL; + float runewidth = win.cw; + Rune rune; + FT_UInt glyphidx; + FcResult fcres; + FcPattern *fcpattern, *fontpattern; + FcFontSet *fcsets[] = { NULL }; + FcCharSet *fccharset; + int i, f, numspecs = 0; + + for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) { + /* Fetch rune and mode for current glyph. */ + rune = glyphs[i].u; + mode = glyphs[i].mode; + + /* Skip dummy wide-character spacing. */ + if (mode == ATTR_WDUMMY) + continue; + + /* Determine font for glyph if different from previous glyph. */ + if (prevmode != mode) { + prevmode = mode; + font = &dc.font; + frcflags = FRC_NORMAL; + runewidth = win.cw * ((mode & ATTR_WIDE) ? 2.0f : 1.0f); + if ((mode & ATTR_ITALIC) && (mode & ATTR_BOLD)) { + font = &dc.ibfont; + frcflags = FRC_ITALICBOLD; + } else if (mode & ATTR_ITALIC) { + font = &dc.ifont; + frcflags = FRC_ITALIC; + } else if (mode & ATTR_BOLD) { + font = &dc.bfont; + frcflags = FRC_BOLD; + } + yp = winy + font->ascent; + } + + /* Lookup character index with default font. */ + glyphidx = XftCharIndex(xw.dpy, font->match, rune); + if (glyphidx) { + specs[numspecs].font = font->match; + specs[numspecs].glyph = glyphidx; + specs[numspecs].x = (short)xp; + specs[numspecs].y = (short)yp; + xp += runewidth; + numspecs++; + continue; + } + + /* Fallback on font cache, search the font cache for match. */ + for (f = 0; f < frclen; f++) { + glyphidx = XftCharIndex(xw.dpy, frc[f].font, rune); + /* Everything correct. */ + if (glyphidx && frc[f].flags == frcflags) + break; + /* We got a default font for a not found glyph. */ + if (!glyphidx && frc[f].flags == frcflags + && frc[f].unicodep == rune) { + break; + } + } + + /* Nothing was found. Use fontconfig to find matching font. */ + if (f >= frclen) { + if (!font->set) + font->set = FcFontSort(0, font->pattern, + 1, 0, &fcres); + fcsets[0] = font->set; + + /* + * Nothing was found in the cache. Now use + * some dozen of Fontconfig calls to get the + * font for one single character. + * + * Xft and fontconfig are design failures. + */ + fcpattern = FcPatternDuplicate(font->pattern); + fccharset = FcCharSetCreate(); + + FcCharSetAddChar(fccharset, rune); + FcPatternAddCharSet(fcpattern, FC_CHARSET, + fccharset); + FcPatternAddBool(fcpattern, FC_SCALABLE, 1); + + FcConfigSubstitute(0, fcpattern, + FcMatchPattern); + FcDefaultSubstitute(fcpattern); + + fontpattern = FcFontSetMatch(0, fcsets, 1, + fcpattern, &fcres); + + /* Allocate memory for the new cache entry. */ + if (frclen >= frccap) { + frccap += 16; + frc = xrealloc(frc, frccap * sizeof(Fontcache)); + } + + frc[frclen].font = XftFontOpenPattern(xw.dpy, + fontpattern); + if (!frc[frclen].font) + die("XftFontOpenPattern failed seeking fallback font: %s\n", + strerror(errno)); + frc[frclen].flags = frcflags; + frc[frclen].unicodep = rune; + + glyphidx = XftCharIndex(xw.dpy, frc[frclen].font, rune); + + f = frclen; + frclen++; + + FcPatternDestroy(fcpattern); + FcCharSetDestroy(fccharset); + } + + specs[numspecs].font = frc[f].font; + specs[numspecs].glyph = glyphidx; + specs[numspecs].x = (short)xp; + specs[numspecs].y = (short)yp; + xp += runewidth; + numspecs++; + } + + /* HarfBuzz font shaping for programming ligatures (Fira Code) */ + hbtransform(specs, glyphs, len, x, y); + + return numspecs; +} + +void +xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y) +{ + int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1); + int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, + width = charlen * win.cw; + Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; + XRenderColor colfg, colbg; + XRectangle r; + + /* Fallback on color display for attributes not supported by the font */ + if (base.mode & ATTR_ITALIC && base.mode & ATTR_BOLD) { + if (dc.ibfont.badslant || dc.ibfont.badweight) + base.fg = defaultattr; + } else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) || + (base.mode & ATTR_BOLD && dc.bfont.badweight)) { + base.fg = defaultattr; + } + + if (IS_TRUECOL(base.fg)) { + colfg.alpha = 0xffff; + colfg.red = TRUERED(base.fg); + colfg.green = TRUEGREEN(base.fg); + colfg.blue = TRUEBLUE(base.fg); + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &truefg); + fg = &truefg; + } else { + fg = &dc.col[base.fg]; + } + + if (IS_TRUECOL(base.bg)) { + colbg.alpha = 0xffff; + colbg.green = TRUEGREEN(base.bg); + colbg.red = TRUERED(base.bg); + colbg.blue = TRUEBLUE(base.bg); + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &truebg); + bg = &truebg; + } else { + bg = &dc.col[base.bg]; + } + + /* Change basic system colors [0-7] to bright system colors [8-15] */ + if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7)) + fg = &dc.col[base.fg + 8]; + + if (IS_SET(MODE_REVERSE)) { + if (fg == &dc.col[defaultfg]) { + fg = &dc.col[defaultbg]; + } else { + colfg.red = ~fg->color.red; + colfg.green = ~fg->color.green; + colfg.blue = ~fg->color.blue; + colfg.alpha = fg->color.alpha; + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, + &revfg); + fg = &revfg; + } + + if (bg == &dc.col[defaultbg]) { + bg = &dc.col[defaultfg]; + } else { + colbg.red = ~bg->color.red; + colbg.green = ~bg->color.green; + colbg.blue = ~bg->color.blue; + colbg.alpha = bg->color.alpha; + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, + &revbg); + bg = &revbg; + } + } + + if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) { + colfg.red = fg->color.red / 2; + colfg.green = fg->color.green / 2; + colfg.blue = fg->color.blue / 2; + colfg.alpha = fg->color.alpha; + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &revfg); + fg = &revfg; + } + + if (base.mode & ATTR_REVERSE) { + temp = fg; + fg = bg; + bg = temp; + } + + if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK) + fg = bg; + + if (base.mode & ATTR_INVISIBLE) + fg = bg; + + if (invertcolors) { + revfg = invertedcolor(fg); + revbg = invertedcolor(bg); + fg = &revfg; + bg = &revbg; + } + + /* Intelligent cleaning up of the borders. */ + if (x == 0) { + xclear(0, (y == 0)? 0 : winy, borderpx, + winy + win.ch + + ((winy + win.ch >= borderpx + win.th)? win.h : 0)); + } + if (winx + width >= borderpx + win.tw) { + xclear(winx + width, (y == 0)? 0 : winy, win.w, + ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch))); + } + if (y == 0) + xclear(winx, 0, winx + width, borderpx); + if (winy + win.ch >= borderpx + win.th) + xclear(winx, winy + win.ch, winx + width, win.h); + + /* Clean up the region we want to draw to. */ + XftDrawRect(xw.draw, bg, winx, winy, width, win.ch); + + /* Set the clip region because Xft is sometimes dirty. */ + r.x = 0; + r.y = 0; + r.height = win.ch; + r.width = width; + XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1); + + /* Render the glyphs. */ + XftDrawGlyphFontSpec(xw.draw, fg, specs, len); + + /* Render underline and strikethrough. */ + if (base.mode & ATTR_UNDERLINE) { + XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1, + width, 1); + } + + if (base.mode & ATTR_STRUCK) { + XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3, + width, 1); + } + + /* Reset clip to none. */ + XftDrawSetClip(xw.draw, 0); +} + +void +xdrawglyph(Glyph g, int x, int y) +{ + int numspecs; + XftGlyphFontSpec spec; + + numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y); + xdrawglyphfontspecs(&spec, g, numspecs, x, y); +} + +void +xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) +{ + Color drawcol; + XRenderColor colbg; + + /* remove the old cursor */ + if (selected(ox, oy)) + og.mode ^= ATTR_REVERSE; + xdrawglyph(og, ox, oy); + + if (IS_SET(MODE_HIDE)) + return; + + /* + * Select the right color for the right mode. + */ + g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE; + + if (IS_SET(MODE_REVERSE)) { + g.mode |= ATTR_REVERSE; + g.bg = defaultfg; + if (selected(cx, cy)) { + drawcol = dc.col[defaultcs]; + g.fg = defaultrcs; + } else { + drawcol = dc.col[defaultrcs]; + g.fg = defaultcs; + } + } else { + if (selected(cx, cy)) { + g.fg = defaultfg; + g.bg = defaultrcs; + } else { + g.bg = g.fg; + g.fg = defaultbg; + } + + if (IS_TRUECOL(g.bg)) { + colbg.alpha = 0xffff; + colbg.red = TRUERED(g.bg); + colbg.green = TRUEGREEN(g.bg); + colbg.blue = TRUEBLUE(g.bg); + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, + &colbg, &drawcol); + } else { + drawcol = dc.col[g.bg]; + } + } + + /* draw the new one */ + if (IS_SET(MODE_FOCUSED)) { + switch (win.cursor) { + case 7: /* st extension */ + g.u = 0x2603; /* snowman (U+2603) */ + /* FALLTHROUGH */ + case 0: /* Blinking Block */ + case 1: /* Blinking Block (Default) */ + case 2: /* Steady Block */ + xdrawglyph(g, cx, cy); + break; + case 3: /* Blinking Underline */ + case 4: /* Steady Underline */ + XftDrawRect(xw.draw, &drawcol, + borderpx + cx * win.cw, + borderpx + (cy + 1) * win.ch - \ + cursorthickness, + win.cw, cursorthickness); + break; + case 5: /* Blinking bar */ + case 6: /* Steady bar */ + XftDrawRect(xw.draw, &drawcol, + borderpx + cx * win.cw, + borderpx + cy * win.ch, + cursorthickness, win.ch); + break; + } + } else { + XftDrawRect(xw.draw, &drawcol, + borderpx + cx * win.cw, + borderpx + cy * win.ch, + win.cw - 1, 1); + XftDrawRect(xw.draw, &drawcol, + borderpx + cx * win.cw, + borderpx + cy * win.ch, + 1, win.ch - 1); + XftDrawRect(xw.draw, &drawcol, + borderpx + (cx + 1) * win.cw - 1, + borderpx + cy * win.ch, + 1, win.ch - 1); + XftDrawRect(xw.draw, &drawcol, + borderpx + cx * win.cw, + borderpx + (cy + 1) * win.ch - 1, + win.cw, 1); + } +} + +void +xsetenv(void) +{ + char buf[sizeof(long) * 8 + 1]; + + snprintf(buf, sizeof(buf), "%lu", xw.win); + setenv("WINDOWID", buf, 1); +} + +void +xsettitle(char *p) +{ + XTextProperty prop; + DEFAULT(p, opt_title); + + Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, + &prop); + XSetWMName(xw.dpy, xw.win, &prop); + XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname); + XFree(prop.value); +} + +int +xstartdraw(void) +{ + return IS_SET(MODE_VISIBLE); +} + +void +xdrawline(Line line, int x1, int y1, int x2) +{ + int i, x, ox, numspecs; + Glyph base, new; + XftGlyphFontSpec *specs = xw.specbuf; + + numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1); + i = ox = 0; + for (x = x1; x < x2 && i < numspecs; x++) { + new = line[x]; + if (new.mode == ATTR_WDUMMY) + continue; + if (selected(x, y1)) + new.mode ^= ATTR_REVERSE; + if (i > 0 && ATTRCMP(base, new)) { + xdrawglyphfontspecs(specs, base, i, ox, y1); + specs += i; + numspecs -= i; + i = 0; + } + if (i == 0) { + ox = x; + base = new; + } + i++; + } + if (i > 0) + xdrawglyphfontspecs(specs, base, i, ox, y1); +} + +void +xfinishdraw(void) +{ + XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w, + win.h, 0, 0); + XSetForeground(xw.dpy, dc.gc, + dc.col[IS_SET(MODE_REVERSE)? + defaultfg : defaultbg].pixel); +} + +void +xximspot(int x, int y) +{ + (void)x; + (void)y; +} + +void +expose(XEvent *ev) +{ + redraw(); +} + +void +visibility(XEvent *ev) +{ + XVisibilityEvent *e = &ev->xvisibility; + + MODBIT(win.mode, e->state != VisibilityFullyObscured, MODE_VISIBLE); +} + +void +unmap(XEvent *ev) +{ + win.mode &= ~MODE_VISIBLE; +} + +void +xsetpointermotion(int set) +{ + MODBIT(xw.attrs.event_mask, set, PointerMotionMask); + XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); +} + +void +xsetmode(int set, unsigned int flags) +{ + int mode = win.mode; + MODBIT(win.mode, set, flags); + if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE)) + redraw(); +} + +int +xsetcursor(int cursor) +{ + if (!BETWEEN(cursor, 0, 7)) /* 7: st extension */ + return 1; + win.cursor = cursor; + return 0; +} + +void +xseturgency(int add) +{ + XWMHints *h = XGetWMHints(xw.dpy, xw.win); + + MODBIT(h->flags, add, XUrgencyHint); + XSetWMHints(xw.dpy, xw.win, h); + XFree(h); +} + +void +xbell(void) +{ + if (!(IS_SET(MODE_FOCUSED))) + xseturgency(1); + if (bellvolume) + XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL); +} + +void +focus(XEvent *ev) +{ + XFocusChangeEvent *e = &ev->xfocus; + + if (e->mode == NotifyGrab) + return; + + if (ev->type == FocusIn) { + if (xw.ime.xic) + XSetICFocus(xw.ime.xic); + win.mode |= MODE_FOCUSED; + xseturgency(0); + if (IS_SET(MODE_FOCUS)) + ttywrite("\033[I", 3, 0); + } else { + if (xw.ime.xic) + XUnsetICFocus(xw.ime.xic); + win.mode &= ~MODE_FOCUSED; + if (IS_SET(MODE_FOCUS)) + ttywrite("\033[O", 3, 0); + } +} + +int +match(uint mask, uint state) +{ + return mask == XK_ANY_MOD || mask == (state & ~ignoremod); +} + +char* +kmap(KeySym k, uint state) +{ + Key *kp; + int i; + + /* Check for mapped keys out of X11 function keys. */ + for (i = 0; i < LEN(mappedkeys); i++) { + if (mappedkeys[i] == k) + break; + } + if (i == LEN(mappedkeys)) { + if ((k & 0xFFFF) < 0xFD00) + return NULL; + } + + for (kp = key; kp < key + LEN(key); kp++) { + if (kp->k != k) + continue; + + if (!match(kp->mask, state)) + continue; + + if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0) + continue; + if (IS_SET(MODE_NUMLOCK) && kp->appkey == 2) + continue; + + if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0) + continue; + + return kp->s; + } + + return NULL; +} + +void +kpress(XEvent *ev) +{ + XKeyEvent *e = &ev->xkey; + KeySym ksym; + char buf[64], *customkey; + int len; + Rune c; + Status status; + Shortcut *bp; + + if (IS_SET(MODE_KBDLOCK)) + return; + + ksym = NoSymbol; + if (xw.ime.xic) { + len = Xutf8LookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status); + if (status == XLookupNone) + return; + if (status == XLookupChars) { + ttywrite(buf, len, 1); + return; + } + } else { + len = XLookupString(e, buf, sizeof buf, &ksym, NULL); + } + /* 1. shortcuts */ + for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { + if (ksym == bp->keysym && match(bp->mod, e->state)) { + bp->func(&(bp->arg)); + return; + } + } + + /* 2. custom keys from config.h */ + if ((customkey = kmap(ksym, e->state))) { + ttywrite(customkey, strlen(customkey), 1); + return; + } + + /* 3. composed string from input method */ + if (len == 0) + return; + if (len == 1 && e->state & Mod1Mask) { + if (IS_SET(MODE_8BIT)) { + if (*buf < 0177) { + c = *buf | 0x80; + len = utf8encode(c, buf); + } + } else { + buf[1] = buf[0]; + buf[0] = '\033'; + len = 2; + } + } + ttywrite(buf, len, 1); +} + +void +cmessage(XEvent *e) +{ + /* + * See xembed specs + * http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html + */ + if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) { + if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) { + win.mode |= MODE_FOCUSED; + xseturgency(0); + } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) { + win.mode &= ~MODE_FOCUSED; + } + } else if (e->xclient.data.l[0] == xw.wmdeletewin) { + ttyhangup(); + exit(0); + } +} + +void +updateselectionmodeatom() { + XChangeProperty(xw.dpy, xw.win, xw.selectionmode, XA_CARDINAL, 32, + PropModeReplace, (uchar *)&selectionmodeenabled, 1); +} + +void +resize(XEvent *e) +{ + if (e->xconfigure.width == win.w && e->xconfigure.height == win.h) + return; + + cresize(e->xconfigure.width, e->xconfigure.height); +} + +void +run(void) +{ + XEvent ev; + int w = win.w, h = win.h; + fd_set rfd; + int xfd = XConnectionNumber(xw.dpy), ttyfd, xev, drawing; + struct timespec seltv, *tv, now, lastblink, trigger; + double timeout; + + /* Waiting for window mapping */ + do { + XNextEvent(xw.dpy, &ev); + /* + * This XFilterEvent call is required because of XOpenIM. It + * does filter out the key event and some client message for + * the input method too. + */ + if (XFilterEvent(&ev, None)) + continue; + if (ev.type == ConfigureNotify) { + w = ev.xconfigure.width; + h = ev.xconfigure.height; + } + } while (ev.type != MapNotify); + + ttyfd = ttynew(opt_line, shell, opt_io, opt_cmd); + cresize(w, h); + + for (timeout = -1, drawing = 0, lastblink = (struct timespec){0};;) { + FD_ZERO(&rfd); + FD_SET(ttyfd, &rfd); + FD_SET(xfd, &rfd); + + if (XPending(xw.dpy)) + timeout = 0; /* existing events might not set xfd */ + + seltv.tv_sec = timeout / 1E3; + seltv.tv_nsec = 1E6 * (timeout - 1E3 * seltv.tv_sec); + tv = timeout >= 0 ? &seltv : NULL; + + if (pselect(MAX(xfd, ttyfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) { + if (errno == EINTR) + continue; + die("select failed: %s\n", strerror(errno)); + } + clock_gettime(CLOCK_MONOTONIC, &now); + + if (FD_ISSET(ttyfd, &rfd)) + ttyread(); + + xev = 0; + while (XPending(xw.dpy)) { + xev = 1; + XNextEvent(xw.dpy, &ev); + if (XFilterEvent(&ev, None)) + continue; + if (handler[ev.type]) + (handler[ev.type])(&ev); + } + + /* + * To reduce flicker and tearing, when new content or event + * triggers drawing, we first wait a bit to ensure we got + * everything, and if nothing new arrives - we draw. + * We start with trying to wait minlatency ms. If more content + * arrives sooner, we retry with shorter and shorter periods, + * and eventually draw even without idle after maxlatency ms. + * Typically this results in low latency while interacting, + * maximum latency intervals during `cat huge.txt`, and perfect + * sync with periodic updates from animations/key-repeats/etc. + */ + if (FD_ISSET(ttyfd, &rfd) || xev) { + if (!drawing) { + trigger = now; + drawing = 1; + } + timeout = (maxlatency - TIMEDIFF(now, trigger)) \ + / maxlatency * minlatency; + if (timeout > 0) + continue; /* we have time, try to find idle */ + } + + /* idle detected or maxlatency exhausted -> draw */ + timeout = -1; + if (blinktimeout && tattrset(ATTR_BLINK)) { + timeout = blinktimeout - TIMEDIFF(now, lastblink); + if (timeout <= 0) { + if (-timeout > blinktimeout) /* start visible */ + win.mode |= MODE_BLINK; + win.mode ^= MODE_BLINK; + tsetdirtattr(ATTR_BLINK); + lastblink = now; + timeout = blinktimeout; + } + } + + draw(); + XFlush(xw.dpy); + drawing = 0; + } +} + +int +resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) +{ + char **sdst = dst; + int *idst = dst; + float *fdst = dst; + + char fullname[256]; + char fullclass[256]; + char *type; + XrmValue ret; + + snprintf(fullname, sizeof(fullname), "%s.%s", + opt_name ? opt_name : "st", name); + snprintf(fullclass, sizeof(fullclass), "%s.%s", + opt_class ? opt_class : "St", name); + fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; + + XrmGetResource(db, fullname, fullclass, &type, &ret); + if (ret.addr == NULL || strncmp("String", type, 64)) + return 1; + + switch (rtype) { + case STRING: + *sdst = ret.addr; + break; + case INTEGER: + *idst = strtoul(ret.addr, NULL, 10); + break; + case FLOAT: + *fdst = strtof(ret.addr, NULL); + break; + } + return 0; +} + +void +config_init(void) +{ + char *resm; + XrmDatabase db; + ResourcePref *p; + + XrmInitialize(); + resm = XResourceManagerString(xw.dpy); + if (!resm) + return; + + db = XrmGetStringDatabase(resm); + for (p = resources; p < resources + LEN(resources); p++) + resource_load(db, p->name, p->type, p->dst); +} + +void +usage(void) +{ + die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]" + " [-n name] [-o file]\n" + " [-T title] [-t title] [-w windowid]" + " [[-e] command [args ...]]\n" + " %s [-aiv] [-c class] [-f font] [-g geometry]" + " [-n name] [-o file]\n" + " [-T title] [-t title] [-w windowid] -l line" + " [stty_args ...]\n", argv0, argv0); +} + +int +main(int argc, char *argv[]) +{ + xw.l = xw.t = 0; + xw.isfixed = False; + xsetcursor(cursorshape); + + ARGBEGIN { + case 'a': + allowaltscreen = 0; + break; + case 'c': + opt_class = EARGF(usage()); + break; + case 'e': + if (argc > 0) + --argc, ++argv; + goto run; + case 'f': + opt_font = EARGF(usage()); + break; + case 'g': + xw.gm = XParseGeometry(EARGF(usage()), + &xw.l, &xw.t, &cols, &rows); + break; + case 'i': + xw.isfixed = 1; + break; + case 'o': + opt_io = EARGF(usage()); + break; + case 'l': + opt_line = EARGF(usage()); + break; + case 'n': + opt_name = EARGF(usage()); + break; + case 't': + case 'T': + opt_title = EARGF(usage()); + break; + case 'w': + opt_embed = EARGF(usage()); + break; + case 'v': + die("%s " VERSION "\n", argv0); + break; + default: + usage(); + } ARGEND; + +run: + if (argc > 0) /* eat all remaining arguments */ + opt_cmd = argv; + + if (!opt_title) + opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0]; + + setlocale(LC_CTYPE, ""); + XSetLocaleModifiers(""); + + if(!(xw.dpy = XOpenDisplay(NULL))) + die("Can't open display\n"); + + config_init(); + cols = MAX(cols, 1); + rows = MAX(rows, 1); + tnew(cols, rows); + xinit(cols, rows); + xsetenv(); + selinit(); + run(); + + return 0; +} diff --git a/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/01-bug-report.yml b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/01-bug-report.yml new file mode 100644 index 0000000..9a56563 --- /dev/null +++ b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/01-bug-report.yml @@ -0,0 +1,65 @@ +name: 🐞 Bug report +description: Create a report to help us improve + +labels: [bug, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to help everyone identify and fix the bug. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: dropdown + id: affected-version + attributes: + label: Select the version + options: + - 1.5.0.1 + - Git master branch + - other or don't know + default: 1 + validations: + required: true + - type: textarea + id: description + attributes: + label: Describe your issue + placeholder: When I did X then Y happened. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + placeholder: | + 1. Start ... + 2. Do this + 3. Do that + validations: + required: true + - type: textarea + id: expected + attributes: + label: What did you expect? + placeholder: I expected this to happen. + - type: textarea + id: environment + attributes: + label: Additional Information + description: | + Additional information you want to provide such as logs, system info, environment, screenshots, etc. + placeholder: | + Add any other context about the bug here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-libinput/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for reporting this issue! We will get back to you as soon as possible. diff --git a/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/02-feature-request.yml b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/02-feature-request.yml new file mode 100644 index 0000000..963c9ad --- /dev/null +++ b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/02-feature-request.yml @@ -0,0 +1,49 @@ +name: ✨ Feature request +description: Suggest a feature for this software +labels: [enhancement, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to properly describe the new software feature you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: "Describe the feature" + placeholder: A thing in X that allows to do Y. + validations: + required: true + - type: textarea + id: rationale + attributes: + label: "It should be done because" + placeholder: Doing Y is needed for Z. + validations: + required: true + - type: textarea + id: alternative + attributes: + label: "What are the alternatives?" + placeholder: We could do A or B instead. + - type: textarea + id: context + attributes: + label: Additional context + description: Additional information you want to provide such as references to related issues or protocols, the implications on existing use cases, etc. + placeholder: | + Add any other context about the feature request here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-libinput/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for your suggestion! Let's see together if it can be done. diff --git a/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/03-code-cleanup.yml b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/03-code-cleanup.yml new file mode 100644 index 0000000..e2b341a --- /dev/null +++ b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/03-code-cleanup.yml @@ -0,0 +1,49 @@ +name: 🔧 Code cleanup +description: Level up the source code +labels: [code-cleanup, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to properly describe the code cleanup you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: "Describe the cleanup" + placeholder: C in X needs to be changed into D. + validations: + required: true + - type: textarea + id: rationale + attributes: + label: "It should be done because" + placeholder: Having D is needed for E. + validations: + required: true + - type: textarea + id: alternative + attributes: + label: "What are the alternatives?" + placeholder: We could do A or B instead. + - type: textarea + id: context + attributes: + label: Additional context + description: Additional information you want to provide such as implications on existing code, how to ensure API/ABI stability, which tests are needed or to be run, related issues, etc. + placeholder: | + Add any other context about the cleanup here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-libinput/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for looking at the source code! Let's see together how it can be improved. diff --git a/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/04-doc-update.yml b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/04-doc-update.yml new file mode 100644 index 0000000..b980d08 --- /dev/null +++ b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/04-doc-update.yml @@ -0,0 +1,38 @@ +name: 🔖 Documentation update +description: Make your mark for better documentation + +labels: [documentation, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to help others understand our software. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: Describe the update + placeholder: These things need to be better documented. + validations: + required: true + - type: textarea + id: environment + attributes: + label: Additional Information + description: Additional information you want to provide such as tickets related to changes in the software, affected files, screenshots, etc. + placeholder: | + Add any other context about the update here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-libinput/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for requesting this update! We will get back to you as soon as possible. diff --git a/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/05-org-task.yml b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/05-org-task.yml new file mode 100644 index 0000000..6201c19 --- /dev/null +++ b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/05-org-task.yml @@ -0,0 +1,43 @@ +name: ✅ Organizational task +description: Create a task for project organization + +labels: [needs-triage, organization] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to get organizational things done. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: Describe the task + placeholder: These things need to be done. + validations: + required: true + - type: textarea + id: rationale + attributes: + label: "It should be done because" + placeholder: Doing Y is needed for Z. + - type: textarea + id: environment + attributes: + label: Additional Information + description: Additional information you want to provide such as the context for bigger tasks, the implicatons on existing workflows, related issues, etc. + placeholder: | + Add any other context about the task here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-input-libinput/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for adding this task! We will get back to you as soon as possible. diff --git a/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/config.yml b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..5d1b3a8 --- /dev/null +++ b/src/xf86-input-libinput/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: XLibre Community Support + url: https://github.com/orgs/X11Libre/discussions + about: Please ask and answer questions here. + - name: Mailing List + url: https://www.freelists.org/list/xlibre + about: You can join the discussions on our mailing list. diff --git a/src/xf86-input-libinput/.github/workflows/build.yml b/src/xf86-input-libinput/.github/workflows/build.yml new file mode 100644 index 0000000..d1d7355 --- /dev/null +++ b/src/xf86-input-libinput/.github/workflows/build.yml @@ -0,0 +1,50 @@ +permissions: + contents: write + +on: + push: + pull_request: + +jobs: + ubuntu: + strategy: + matrix: + xserver-version: [ master, xlibre-xserver-25.1.0, xlibre-xserver-25.0.0.18 ] + runs-on: ubuntu-latest + steps: + - uses: X11Libre/action-build-driver/target/ubuntu@v0.4.0 + with: + xserver-version: ${{ matrix.xserver-version }} + + freebsd: + strategy: + matrix: + xserver-version: [ master, xlibre-xserver-25.1.0, xlibre-xserver-25.0.0.18 ] + runs-on: ubuntu-latest + steps: + - uses: X11Libre/action-build-driver/target/freebsd@v0.4.0 + with: + xserver-version: ${{ matrix.xserver-version }} + + dragonfly: + strategy: + matrix: + # xlibre-xserver-25.0.x not compiling on dragonfly yet + xserver-version: [ master, xlibre-xserver-25.1.0 ] + runs-on: ubuntu-latest + steps: + - uses: X11Libre/action-build-driver/target/dragonfly@v0.4.0 + with: + xserver-version: ${{ matrix.xserver-version }} + + # not supported on NetBSD + + release-notes: + name: Release pushed tag + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/xlibre-') }} + needs: [ ubuntu, freebsd, dragonfly ] + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: X11Libre/action-build-driver/release@v0.4.0 diff --git a/src/xf86-input-libinput/.gitignore b/src/xf86-input-libinput/.gitignore new file mode 100644 index 0000000..752a4ba --- /dev/null +++ b/src/xf86-input-libinput/.gitignore @@ -0,0 +1,87 @@ +# +# X.Org module default exclusion patterns +# The next section if for module specific patterns +# +# Do not edit the following section +# GNU Build System (Autotools) +aclocal.m4 +autom4te.cache/ +autoscan.log +ChangeLog +compile +config.guess +config.h +config.h.in +config.log +config-ml.in +config.py +config.status +config.status.lineno +config.sub +configure +configure.scan +depcomp +.deps/ +INSTALL +install-sh +.libs/ +libtool +libtool.m4 +ltmain.sh +lt~obsolete.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 +Makefile +Makefile.in +mdate-sh +missing +mkinstalldirs +*.pc +py-compile +stamp-h? +symlink-tree +texinfo.tex +ylwrap + +# Do not edit the following section +# Edit Compile Debug Document Distribute +*~ +*.[0-9] +*.[0-9]x +*.bak +*.bin +core +*.dll +*.exe +*-ISO*.bdf +*-JIS*.bdf +*-KOI8*.bdf +*.kld +*.ko +*.ko.cmd +*.lai +*.l[oa] +*.[oa] +*.obj +*.patch +*.so +*.pcf.gz +*.pdb +*.tar.bz2 +*.tar.gz +# +# Add & Override patterns for xf86-input-libinput +# +# Edit the following section as needed +# For example, !report.pc overrides *.pc. See 'man gitignore' +# +*.log +*.trs +*.swp +*.announce +*.sig +test-driver +tags +.vimdir +test/test-bezier diff --git a/src/xf86-input-libinput/COPYING b/src/xf86-input-libinput/COPYING new file mode 100644 index 0000000..43bc59d --- /dev/null +++ b/src/xf86-input-libinput/COPYING @@ -0,0 +1,20 @@ +SPDX-License-Identifier: MIT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/src/xf86-input-libinput/Makefile.am b/src/xf86-input-libinput/Makefile.am new file mode 100644 index 0000000..cdcc414 --- /dev/null +++ b/src/xf86-input-libinput/Makefile.am @@ -0,0 +1,45 @@ +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +# During distcheck, system locations (as provided by pkg-config) may +# not be writable; provide instead relative locations. +DISTCHECK_CONFIGURE_FLAGS = --with-xorg-module-dir='$${libdir}/xorg/modules' \ + --with-sdkdir='$${includedir}/xorg' + +SUBDIRS = src include man test +MAINTAINERCLEANFILES = ChangeLog INSTALL + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = xorg-libinput.pc + +dist_xorgconf_DATA = conf/40-libinput.conf + +.PHONY: ChangeLog INSTALL + +INSTALL: + $(INSTALL_CMD) + +ChangeLog: + $(CHANGELOG_CMD) + +dist-hook: ChangeLog INSTALL + +EXTRA_DIST = README.md diff --git a/src/xf86-input-libinput/README.md b/src/xf86-input-libinput/README.md new file mode 100644 index 0000000..a671388 --- /dev/null +++ b/src/xf86-input-libinput/README.md @@ -0,0 +1,33 @@ +xf86-input-libinput - a libinput-based X driver +=============================================== + +The official repository for this driver is + + https://github.com/X11Libre/xf86-input-evdev + +This is an X driver based on libinput. It is a thin wrapper around libinput, +so while it does provide all features that libinput supports it does little +beyond. + +***WARNING: misconfiguration of an X input driver may leave you without +usable input devices in your X session. Use with caution.*** + + +Building +-------- + +To build this driver: + + autoreconf -vif + ./configure --prefix=$HOME/build + make && make install + +Note that this assumes the same prefix as used in "Building the X Window +System" above, adjust as required. If you want a system install, use a +prefix of */usr*. + +Install the default configuration file: + + cp conf/99-libinput.conf /etc/X11/xorg.conf.d/ + +This will assign this driver to *all* devices. Use with caution. diff --git a/src/xf86-input-libinput/autogen.sh b/src/xf86-input-libinput/autogen.sh new file mode 100755 index 0000000..421528e --- /dev/null +++ b/src/xf86-input-libinput/autogen.sh @@ -0,0 +1,17 @@ +#! /bin/sh + +srcdir=`dirname "$0"` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd "$srcdir" + +autoreconf -v --install || exit 1 +cd "$ORIGDIR" || exit $? + +git config --local --get format.subjectPrefix >/dev/null 2>&1 || + git config --local format.subjectPrefix "PATCH xf86-input-libinput" + +if test -z "$NOCONFIGURE"; then + exec "$srcdir"/configure "$@" +fi diff --git a/src/xf86-input-libinput/conf/40-libinput.conf b/src/xf86-input-libinput/conf/40-libinput.conf new file mode 100644 index 0000000..eb33ad0 --- /dev/null +++ b/src/xf86-input-libinput/conf/40-libinput.conf @@ -0,0 +1,52 @@ +# Match on all types of devices but joysticks +# +# If you want to configure your devices, do not copy this file. +# Instead, use a config snippet that contains something like this: +# +# Section "InputClass" +# Identifier "something or other" +# MatchDriver "libinput" +# +# MatchIsTouchpad "on" +# ... other Match directives ... +# Option "someoption" "value" +# EndSection +# +# This applies the option any libinput device also matched by the other +# directives. See the xorg.conf(5) man page for more info on +# matching devices. + +Section "InputClass" + Identifier "libinput pointer catchall" + MatchIsPointer "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput keyboard catchall" + MatchIsKeyboard "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput touchpad catchall" + MatchIsTouchpad "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput touchscreen catchall" + MatchIsTouchscreen "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection + +Section "InputClass" + Identifier "libinput tablet catchall" + MatchIsTablet "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" +EndSection diff --git a/src/xf86-input-libinput/configure.ac b/src/xf86-input-libinput/configure.ac new file mode 100644 index 0000000..ce87e51 --- /dev/null +++ b/src/xf86-input-libinput/configure.ac @@ -0,0 +1,157 @@ +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Process this file with autoconf to produce a configure script + +# Initialize Autoconf +AC_PREREQ([2.60]) +AC_INIT([xlibre-xf86-input-libinput], + [25.0.1], + [https://github.com/X11Libre/xf86-input-libinput/issues], + [xlibre-xf86-input-libinput]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_AUX_DIR(.) + +# Initialize Automake +AM_INIT_AUTOMAKE([foreign dist-xz]) + +# Initialize libtool +AC_DISABLE_STATIC +LT_INIT + +# Initialize X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.8) +XORG_DEFAULT_OPTIONS + +CFLAGS="$CFLAGS -Wno-declaration-after-statement" + +# Obtain compiler/linker options from server and required extensions +PKG_CHECK_MODULES(XORG, [xorg-server >= 25.0.0] xproto [inputproto >= 2.3.99.1]) +PKG_CHECK_MODULES(LIBINPUT, [libinput >= 1.11.0]) + +OLD_LIBS=$LIBS +OLD_CFLAGS=$CFLAGS +LIBS="$LIBS $LIBINPUT_LIBS" +CFLAGS="$CFLAGS $LIBINPUT_CFLAGS" + +AC_MSG_CHECKING([if libinput_device_config_scroll_get_button_lock is available]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[libinput_device_config_scroll_get_button_lock(NULL)]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_LIBINPUT_SCROLL_BUTTON_LOCK, [1], + [libinput_device_config_scroll_get_button_lock() is available]) + [libinput_have_scroll_button_lock=yes]], + [AC_MSG_RESULT([no]) + [libinput_have_scroll_button_lock=no]]) + +AC_MSG_CHECKING([if libinput_event_pointer_get_scroll_value_v120 is available]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[libinput_event_pointer_get_scroll_value_v120(NULL, 0)]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_LIBINPUT_AXIS_VALUE_V120, [1], + [libinput_event_pointer_get_scroll_value_v120() is available]) + [libinput_have_axis_value_v120=yes]], + [AC_MSG_RESULT([no]) + [libinput_have_axis_value_v120=no]]) + +AC_MSG_CHECKING([if libinput_config_accel_create is available]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[libinput_config_accel_create(0)]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_LIBINPUT_CUSTOM_ACCEL, [1], + [libinput_config_accel_create() is available]) + [libinput_have_custom_accel=yes]], + [AC_MSG_RESULT([no]) + [libinput_have_custom_accel=no]]) + +AC_MSG_CHECKING([if libinput_tablet_tool_config_pressure_range_set is available]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[libinput_tablet_tool_config_pressure_range_set(0)]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_LIBINPUT_PRESURE_RANGE, [1], + [libinput_tablet_tool_config_pressure_range_set() is available]) + [libinput_have_pressure_range=yes]], + [AC_MSG_RESULT([no]) + [libinput_have_pressure_range=no]]) + +AC_MSG_CHECKING([if libinput_device_config_click_set_clickfinger_button_map is available]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[libinput_device_config_click_set_clickfinger_button_map(NULL, 0)]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP, [1], + [libinput_device_config_click_set_clickfinger_button_map() is available]) + [libinput_have_clickfinger_button_map=yes]], + [AC_MSG_RESULT([no]) + [libinput_have_clickfinger_button_map=no]]) + +AC_MSG_CHECKING([if libinput_plugin_system_load is available]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[libinput_plugin_system_load_plugins(NULL, 0)]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_LIBINPUT_PLUGINS, [1], + [libinput_plugin_system_load_plugins() is available]) + [libinput_have_plugin_system=yes]], + [AC_MSG_RESULT([no]) + [libinput_have_plugin_system=no]]) + +LIBS=$OLD_LIBS +CFLAGS=$OLD_CFLAGS + +# Define a configure option for an alternate input module directory +PKG_PROG_PKG_CONFIG([0.25]) +AC_ARG_WITH(xorg-module-dir, + AS_HELP_STRING([--with-xorg-module-dir=DIR], + [Default xorg module directory]), + [moduledir="$withval"], + [moduledir=`$PKG_CONFIG --variable=moduledir xorg-server`]) +inputdir=${moduledir}/input +AC_SUBST(inputdir) + +AC_ARG_WITH(xorg-conf-dir, + AC_HELP_STRING([--with-xorg-conf-dir=DIR], + [Default xorg.conf.d directory [[default=${prefix}/share/X11/xorg.conf.d]]]), + [xorgconfdir="$withval"], + [xorgconfdir='${prefix}/share/X11/xorg.conf.d']) +AC_SUBST(xorgconfdir) + +# X Server SDK location is required to install header files +sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server` + +# Workaround overriding sdkdir to be able to create a tarball when user has no +# write permission in sdkdir. See DISTCHECK_CONFIGURE_FLAGS in Makefile.am +AC_ARG_WITH([sdkdir], [], [sdkdir="$withval"]) +AC_SUBST([sdkdir]) + +AC_CONFIG_FILES([Makefile + include/Makefile + src/Makefile + man/Makefile + test/Makefile + xorg-libinput.pc]) +AC_OUTPUT diff --git a/src/xf86-input-libinput/include/Makefile.am b/src/xf86-input-libinput/include/Makefile.am new file mode 100644 index 0000000..0d52b9b --- /dev/null +++ b/src/xf86-input-libinput/include/Makefile.am @@ -0,0 +1 @@ +sdk_HEADERS = libinput-properties.h diff --git a/src/xf86-input-libinput/include/libinput-properties.h b/src/xf86-input-libinput/include/libinput-properties.h new file mode 100644 index 0000000..2034338 --- /dev/null +++ b/src/xf86-input-libinput/include/libinput-properties.h @@ -0,0 +1,269 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef _LIBINPUT_PROPERTIES_H_ +#define _LIBINPUT_PROPERTIES_H_ + +/* Tapping enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP "libinput Tapping Enabled" + +/* Tapping default enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_TAP_DEFAULT "libinput Tapping Enabled Default" + +/* Tap drag enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG "libinput Tapping Drag Enabled" + +/* Tap drag default enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_TAP_DRAG_DEFAULT "libinput Tapping Drag Enabled Default" + +/* Tap drag lock enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK "libinput Tapping Drag Lock Enabled" + +/* Tap drag lock default enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT "libinput Tapping Drag Lock Enabled Default" + +/* Tap button order: BOOL, 2 values in order LRM, LMR, only one may be set + at any time */ +#define LIBINPUT_PROP_TAP_BUTTONMAP "libinput Tapping Button Mapping Enabled" + +/* Tap button default order: BOOL, 2 values in order LRM, LMR, read-only */ +#define LIBINPUT_PROP_TAP_BUTTONMAP_DEFAULT "libinput Tapping Button Mapping Default" + +/* Clickfinger button order: BOOL, 2 values in order LRM, LMR, only one may be set + at any time */ +#define LIBINPUT_PROP_CLICKFINGER_BUTTONMAP "libinput Clickfinger Button Mapping Enabled" + +/* Clickfinger button default order: BOOL, 2 values in order LRM, LMR, read-only */ +#define LIBINPUT_PROP_CLICKFINGER_BUTTONMAP_DEFAULT "libinput Clickfinger Button Mapping Default" + +/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows */ +#define LIBINPUT_PROP_CALIBRATION "libinput Calibration Matrix" + +/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows, read-only*/ +#define LIBINPUT_PROP_CALIBRATION_DEFAULT "libinput Calibration Matrix Default" + +/* Pointer accel speed: FLOAT, 1 value, 32 bit */ +#define LIBINPUT_PROP_ACCEL "libinput Accel Speed" + +/* Pointer accel speed: FLOAT, 1 value, 32 bit, read-only*/ +#define LIBINPUT_PROP_ACCEL_DEFAULT "libinput Accel Speed Default" + +/* Pointer accel profile: BOOL, 3 values in order adaptive, flat, custom + * only one is enabled at a time at max, read-only */ +#define LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE "libinput Accel Profiles Available" + +/* Pointer accel profile: BOOL, 3 values in order adaptive, flat, custom + only one is enabled at a time at max, read-only */ +#define LIBINPUT_PROP_ACCEL_PROFILE_ENABLED_DEFAULT "libinput Accel Profile Enabled Default" + +/* Pointer accel profile: BOOL, 3 values in order adaptive, flat, custom + only one is enabled at a time at max */ +#define LIBINPUT_PROP_ACCEL_PROFILE_ENABLED "libinput Accel Profile Enabled" + +/* Points for the custom accel profile: FLOAT, N values */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_FALLBACK "libinput Accel Custom Fallback Points" + +/* Steps for the custom accel profile: FLOAT, 1 value */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_FALLBACK "libinput Accel Custom Fallback Step" + +/* Points for the custom accel profile: FLOAT, N values */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_MOTION "libinput Accel Custom Motion Points" + +/* Steps for the custom accel profile: FLOAT, 1 value */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_MOTION "libinput Accel Custom Motion Step" + +/* Points for the custom accel profile: FLOAT, N values */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_SCROLL "libinput Accel Custom Scroll Points" + +/* Steps for the custom accel profile: FLOAT, 1 value */ +#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_SCROLL "libinput Accel Custom Scroll Step" + +/* Natural scrolling: BOOL, 1 value */ +#define LIBINPUT_PROP_NATURAL_SCROLL "libinput Natural Scrolling Enabled" + +/* Natural scrolling: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_NATURAL_SCROLL_DEFAULT "libinput Natural Scrolling Enabled Default" + +/* Send-events mode: BOOL read-only, 2 values in order disabled, + disabled-on-external-mouse */ +#define LIBINPUT_PROP_SENDEVENTS_AVAILABLE "libinput Send Events Modes Available" + +/* Send-events mode: BOOL, 2 values in order disabled, + disabled-on-external-mouse */ +#define LIBINPUT_PROP_SENDEVENTS_ENABLED "libinput Send Events Mode Enabled" + +/* Send-events mode: BOOL, 2 values in order disabled, + disabled-on-external-mouse, read-only */ +#define LIBINPUT_PROP_SENDEVENTS_ENABLED_DEFAULT "libinput Send Events Mode Enabled Default" + +/* Left-handed enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_LEFT_HANDED "libinput Left Handed Enabled" + +/* Left-handed enabled/disabled: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_LEFT_HANDED_DEFAULT "libinput Left Handed Enabled Default" + +/* Scroll method: BOOL read-only, 3 values in order 2fg, edge, button. + shows available scroll methods */ +#define LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE "libinput Scroll Methods Available" + +/* Scroll method: BOOL, 3 values in order 2fg, edge, button + only one is enabled at a time at max */ +#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED "libinput Scroll Method Enabled" + +/* Scroll method: BOOL, 3 values in order 2fg, edge, button + only one is enabled at a time at max, read-only */ +#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT "libinput Scroll Method Enabled Default" + +/* Scroll button for button scrolling: 32-bit int, 1 value */ +#define LIBINPUT_PROP_SCROLL_BUTTON "libinput Button Scrolling Button" + +/* Scroll button for button scrolling: 32-bit int, 1 value, read-only */ +#define LIBINPUT_PROP_SCROLL_BUTTON_DEFAULT "libinput Button Scrolling Button Default" + +/* Scroll button lock: BOOL, 1 value, TRUE for enabled, FALSE otherwise */ +#define LIBINPUT_PROP_SCROLL_BUTTON_LOCK "libinput Button Scrolling Button Lock Enabled" + +/* Scroll button lock: BOOL, 1 value, TRUE for enabled, FALSE otherwise, read-only*/ +#define LIBINPUT_PROP_SCROLL_BUTTON_LOCK_DEFAULT "libinput Button Scrolling Button Lock Enabled Default" + +/* Scroll pixel distance: CARD32, 1 value (with implementation-defined limits) */ +#define LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE "libinput Scrolling Pixel Distance" + +/* Scroll pixel distance: CARD32, 1 value, read-only */ +#define LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE_DEFAULT "libinput Scrolling Pixel Distance Default" + +/* Scroll factor: FLOAT, 1 value, 32 bit */ +#define LIBINPUT_PROP_SCROLL_FACTOR "libinput Scrolling Factor" + +/* Scroll factor: FLOAT, 1 value, 32 bit, read-only */ +#define LIBINPUT_PROP_SCROLL_FACTOR_DEFAULT "libinput Scrolling Factor Default" + +/* Click method: BOOL read-only, 2 values in order buttonareas, clickfinger + shows available click methods */ +#define LIBINPUT_PROP_CLICK_METHODS_AVAILABLE "libinput Click Methods Available" + +/* Click method: BOOL, 2 values in order buttonareas, clickfinger + only one enabled at a time at max */ +#define LIBINPUT_PROP_CLICK_METHOD_ENABLED "libinput Click Method Enabled" + +/* Click method: BOOL, 2 values in order buttonareas, clickfinger + only one enabled at a time at max, read-only */ +#define LIBINPUT_PROP_CLICK_METHOD_ENABLED_DEFAULT "libinput Click Method Enabled Default" + +/* Middle button emulation: BOOL, 1 value */ +#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED "libinput Middle Emulation Enabled" + +/* Middle button emulation: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT "libinput Middle Emulation Enabled Default" + +/* Disable while typing: BOOL, 1 value */ +#define LIBINPUT_PROP_DISABLE_WHILE_TYPING "libinput Disable While Typing Enabled" + +/* Disable while typing: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_DISABLE_WHILE_TYPING_DEFAULT "libinput Disable While Typing Enabled Default" + +/* Drag lock buttons, either: + CARD8, one value, the meta lock button, or + CARD8, n * 2 values, the drag lock pairs with n being the button and n+1 + the target button number */ +#define LIBINPUT_PROP_DRAG_LOCK_BUTTONS "libinput Drag Lock Buttons" + +/* Horizontal scroll events enabled: BOOL, 1 value (0 or 1). + * If disabled, horizontal scroll events are discarded */ +#define LIBINPUT_PROP_HORIZ_SCROLL_ENABLED "libinput Horizontal Scroll Enabled" + +/* Number of modes each pad mode group has available: CARD8, one for each + * pad mode group, read-only. + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUPS_AVAILABLE "libinput Pad Mode Groups Modes Available" + +/* Mode each pad mode group is currently in: CARD8, one for each pad mode + * group, read-only. + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUPS "libinput Pad Mode Groups Modes" + +/* The association of each logical button with the pad mode group: INT8, + * one for each logical button. If set to -1 the button cannot be associated + * with a mode group. read-only + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_BUTTONS "libinput Pad Mode Group Buttons" + +/* The association of each logical strip with the pad mode group: INT8, + * one for each logical strip. If set to -1 the strip cannot be associated + * with a mode group. read-only + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_STRIPS "libinput Pad Mode Group Strips" + +/* The association of each logical ring with the pad mode group: INT8, + * one for each logical ring. If set to -1 the ring cannot be associated + * with a mode group. read-only + */ +#define LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_RINGS "libinput Pad Mode Group Rings" + +/* Device rotation: FLOAT, 1 value, 32 bit */ +#define LIBINPUT_PROP_ROTATION_ANGLE "libinput Rotation Angle" + +/* Device rotation: FLOAT, 1 value, 32 bit, read-only */ +#define LIBINPUT_PROP_ROTATION_ANGLE_DEFAULT "libinput Rotation Angle Default" + +/* Tablet tool pressure curve: float, 8 values, 32 bit + * Value range is [0.0, 1.0], the values specify the x/y of the four + * control points for a cubic bezier curve. + * Default value: 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 + */ +#define LIBINPUT_PROP_TABLET_TOOL_PRESSURECURVE "libinput Tablet Tool Pressurecurve" + +/* Tablet tool pressure range: float, 2 values, 32 bit + * Value range is [0.0, 1.0] for min and max physical pressure to map to the logical range + * Default value: 0.0 1.0 + */ +#define LIBINPUT_PROP_TABLET_TOOL_PRESSURE_RANGE "libinput Tablet Tool Pressure Range" + +/* Tablet tool pressure range: float, 2 values, 32 bit, read-only */ +#define LIBINPUT_PROP_TABLET_TOOL_PRESSURE_RANGE_DEFAULT "libinput Tablet Tool Pressure Range Default" + +/* Tablet tool area ratio: CARD32, 2 values, w and h */ +#define LIBINPUT_PROP_TABLET_TOOL_AREA_RATIO "libinput Tablet Tool Area Ratio" + +/* High-resolution wheel scroll events enabled: BOOL, 1 value (0 or 1). + * If disabled, high-resolution wheel scroll events are discarded */ +#define LIBINPUT_PROP_HIRES_WHEEL_SCROLL_ENABLED "libinput High Resolution Wheel Scroll Enabled" + +/* The tablet tool unique serial number: CARD32, 1 value, constant for the + * lifetime of the device. + * + * If this property exists and is zero, the tool does not have a unique serial + * number. + */ +#define LIBINPUT_PROP_TABLET_TOOL_SERIAL "libinput Tablet Tool Serial" + +/* The tablet tool hardware ID: CARD32, 1 value, constant for the lifetime of the device. + * + * This property only exists if the device has a known tool ID. + * See libinput_tablet_tool_get_tool_id() in the libinput documentation for details. + */ +#define LIBINPUT_PROP_TABLET_TOOL_ID "libinput Tablet Tool ID" + +#endif /* _LIBINPUT_PROPERTIES_H_ */ diff --git a/src/xf86-input-libinput/man/Makefile.am b/src/xf86-input-libinput/man/Makefile.am new file mode 100644 index 0000000..a84a0e1 --- /dev/null +++ b/src/xf86-input-libinput/man/Makefile.am @@ -0,0 +1,40 @@ +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +drivermandir = $(DRIVER_MAN_DIR) + +driverman_PRE = libinput.man + +driverman_DATA = $(driverman_PRE:man=$(DRIVER_MAN_SUFFIX)) + +EXTRA_DIST = libinput.man + +CLEANFILES = $(driverman_DATA) + +SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man + +MAN_SUBSTS += \ + -e 's|\@VERSION\@|$(PACKAGE_NAME) $(PACKAGE_VERSION)|g' + +# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure +.man.$(DRIVER_MAN_SUFFIX): + $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@ diff --git a/src/xf86-input-libinput/man/libinput.man b/src/xf86-input-libinput/man/libinput.man new file mode 100644 index 0000000..8cd98b9 --- /dev/null +++ b/src/xf86-input-libinput/man/libinput.man @@ -0,0 +1,612 @@ +'\" t +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH LIBINPUT 4 2025-06-01 "@VERSION@" +.SH NAME +libinput \- libinput-based X.Org input driver +.SH SYNOPSIS +.nf +.B "Section \*qInputDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qlibinput\*q" +.BI " Option \*qDevice\*q \*q" devpath \*q +\ \ ... +.B EndSection +.fi + +.SH NOTE +This is the man page for the X input driver. +If you are looking for the library documentation, go to +.B http://wayland.freedesktop.org/libinput/doc/ + +.SH DESCRIPTION +.B libinput +is an XLibre input driver based on libinput. +It therefore supports all input devices that libinput can handle, including +most mice, keyboards, tablets and touchscreens. +.PP +It is recommended that +.B libinput +devices are configured through the +.B InputClass +directive (refer to +.BR xorg.conf (5)) +instead of manual per-device configuration. +Devices configured using the +.B InputDevice +directive in the +.BR xorg.conf (5) +file are not hot-plug capable. + +.SH CONFIGURATION DETAILS +Please refer to +.BR xorg.conf (5) +for general configuration details +and for options that can be used with all input drivers. +This section only covers configuration details specific to this driver. +.PP +The following driver +.B Options +are supported: +.TP 7 +.BI "Option \*qAccelProfile\*q \*q" string \*q +Sets the pointer acceleration profile to the given profile. +Permitted values are +.BR adaptive , +.BR flat , +.BR custom . +Not all devices support this option or all profiles. +If a profile is unsupported, the default profile for this device is used. +For a description on the profiles and their behavior, +see the libinput documentation. +.TP 7 +.BI "Option \*qAccelSpeed\*q \*q" float \*q +Sets the pointer acceleration speed within the range [-1, 1]. +This only applies to the flat or adaptive profile. +.TP 7 +.BI "Option \*qAccelPointsFallback\*q \*q" string \*q +.TQ +.BI "Option \*qAccelPointsMotion\*q \*q" string \*q +.TQ +.BI "Option \*qAccelPointsScroll\*q \*q" string \*q +Sets the points of the Fallback/Motion/Scroll acceleration functions. +The string must be a space-separated list of +floating point non-negative numbers, e.g., +"0.0 1.0 2.4 2.5". +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.BI "Option \*qAccelStepFallback\*q \*q" float \*q +.TQ +.BI "Option \*qAccelStepMotion\*q \*q" float \*q +.TQ +.BI "Option \*qAccelStepScroll\*q \*q" float \*q +Sets the step between the points of the Fallback/Motion/Scroll +acceleration functions. +When a step of 0.0 is provided, +libinput's Fallback acceleration function is used. +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.BI "Option \*qButtonMapping\*q \*q" string \*q +Sets the logical button mapping for this device, see +.BR XSetPointerMapping (3). +The string must be a space-separated list of button mappings in the order of the +logical buttons on the device, starting with button 1. +The default mapping is "1 2 3 ... 32". +A mapping of 0 deactivates the button. +Multiple buttons can have the same mapping. +Invalid mapping strings are discarded and the default mapping +is used for all buttons. +Buttons not specified in the user's mapping use the default mapping. +See section +.B BUTTON MAPPING +for more details. +.TP 7 +.BI "Option \*qCalibrationMatrix\*q \*q" string \*q +A string of 9 space-separated floating point numbers, in the order +\*qa b c d e f g h i\*q. +Sets the calibration matrix to the 3x3 matrix where the first row is (abc), +the second row is (def) and the third row is (ghi). +.TP 7 +.BI "Option \*qClickMethod\*q \*q" string \*q +Enables a click method. +Permitted values are +.BR none , +.BR buttonareas , +.BR clickfinger . +Not all devices support all methods. +If an option is unsupported, the default click method for this device is used. +.TP 7 +.BI "Option \*qDisableWhileTyping\*q \*q" bool \*q +Indicates if the touchpad should be disabled while typing on the keyboard +(this does not apply to modifier keys such as Ctrl or Alt). +.TP 7 +.BI "Option \*qDevice\*q \*q" string \*q +Specifies the device through which the device can be accessed. +This will generally be of the form \*q/dev/input/eventX\*q, +where X is some integer. +When using +.B InputClass +directives, this option is set by the server. +The mapping from device node to hardware is system-dependent. +Property: "Device Node" (read-only). +.TP 7 +.BI "Option \*qDragLockButtons\*q \*q" "L1 B1 L2 B2 ..." \*q +Sets "drag lock buttons" that simulate a button logically down even when it has +been physically released. +To logically release a locked button, +a second click of the same button is required. +.IP +If the option is a single button number, that button acts as the +"meta" locking button for the next button number. +See section +.B BUTTON DRAG LOCK +for details. +.IP +If the option is a list of button number pairs, the first number of each +number pair is the lock button, the second number the logical button number +to be locked. +See section +.B BUTTON DRAG LOCK +for details. +.IP +For both meta and button pair configuration, +the button numbers are device button numbers, i.e. the +.B ButtonMapping +applies after drag lock. +.TP 7 +.BI "Option \*qHighResolutionWheelScrolling\*q \*q" bool \*q +Disables high-resolution wheel scroll events, enabled by default. When enabled, +the driver forwards only high-resolution wheel scroll events from libinput. +When disabled, the driver forwards legacy wheel scroll events instead. +.TP 7 +.BI "Option \*qHorizontalScrolling\*q \*q" bool \*q +Enables or disables horizontal scrolling. +When disabled, +this driver will discard any horizontal scroll events from libinput. +This does not disable horizontal scroll events from libinput; +it merely discards the horizontal axis from any scroll events. +Default is enabled. +.TP 7 +.BI "Option \*qLeftHanded\*q \*q" bool \*q +Enables left-handed button orientation, i.e. swapping left and right buttons. +.TP 7 +.BI "Option \*qMiddleEmulation\*q \*q" bool \*q +Enables middle button emulation. +When enabled, pressing the left and right +buttons simultaneously produces a middle mouse button click. +A synonym +.IP +.BI "Option \*qEmulate3Buttons\*q \*q" bool \*q +.IP +is preserved for compatibility with +.B evdev +driver, with +.BI "\*qMiddleEmulation\*q +having preference if both are set. +.TP 7 +.BI "Option \*qNaturalScrolling\*q \*q" bool \*q +Enables or disables natural scrolling behavior. +.TP 7 +.BI "Option \*qRotationAngle\*q \*q" float \*q +Sets the rotation angle of the device to the given angle, in degrees clockwise. +The angle must be between 0.0 (inclusive) and 360.0 (exclusive). +.TP 7 +.BI "Option \*qScrollButton\*q \*q" int \*q +Designates a button as scroll button. +If the +.B ScrollMethod +is +.B button +and the button is logically down, x/y axis movement is converted into +scroll events. +.TP 7 +.BI "Option \*qScrollButtonLock\*q \*q" bool \*q +Enables or disables the scroll button lock. +If enabled, the +.B ScrollButton +is considered logically down after the first click and remains down until +the second click of that button. +If disabled (the default), the +.B ScrollButton +button is considered logically down while held down and up once physically +released. +.TP 7 +.BI "Option \*qScrollFactor\*q \*q" float \*q +Sets the scroll factor for scroll events. A value higher than 1.0 means faster scrolling. +Applications that don't support xi2 input will instead receive scroll button events +less or more frequently depending on the scroll factor value, instead of scrolling "smoother". +.TP 7 +.BI "Option \*qScrollMethod\*q \*q" string \*q +Enables a scroll method. Permitted values are +.BR none , +.BR twofinger , +.BR edge , +.BR button . +Not all devices support all options. +If an option is unsupported, the default scroll option for this device is used. +.TP 7 +.BI "Option \*qScrollPixelDistance\*q \*q" int \*q +Sets the movement distance, in "pixels", required to trigger one logical +wheel click. +This option only applies to the scroll methods +.BR twofinger , +.BR edge , +.BR button . +See section +.B SCROLL PIXEL DISTANCE +for more details. +.TP 7 +.BI "Option \*qSendEventsMode\*q \*q" (disabled|enabled|disabled-on-external-mouse) \*q +Sets the send events mode to disabled, enabled, +or "disable when an external mouse is connected". +.TP 7 +.BI "Option \*qTabletToolPressureCurve\*q \*q" "x0/y0 x1/y1 x2/y2 x3/y3" \*q +Set the pressure curve for a tablet stylus to the bezier formed by the four +points. +The respective x/y coordinate must be in the [0.0, 1.0] range. +For more information see section +.B TABLET TOOL PRESSURE CURVE. +.TP 7 +.BI "Option \*qTabletToolPressureRange\*q \*q" "min max" \*q +Set the pressure range for a tablet stylus to the given subset of the physical +range. +The min/max values must be in the [0.0, 1.0] range. +For example, a min of 0.3 means the tablet will send 0 pressure for anything +equal or below 30% of the physical pressure range and a max of 0.7 means +the tablet sends its maximum pressure value for any pressure equal or higher to +70% of the physical pressure range. +.TP 7 +.BI "Option \*qTabletToolAreaRatio\*q \*q" "w:h" \*q +Sets the area ratio for a tablet tool. +The area always starts at the origin (0/0) and +expands to the largest available area with the specified aspect ratio. +Events outside this area are cropped to the area. +The special value "default" is used for the default mapping +(i.e. the device-native mapping). +For more information see section +.B TABLET TOOL AREA RATIO. +.TP 7 +.BI "Option \*qTapping\*q \*q" bool \*q +Enables or disables tap-to-click behavior. +.TP 7 +.BI "Option \*qTappingButtonMap\*q \*q" (lrm|lmr) \*q +Set the button mapping for 1/2/3-finger taps to left/right/middle or +left/middle/right, respectively. +.TP 7 +.BI "Option \*qTappingDrag\*q \*q" bool \*q +Enables or disables drag during tapping behavior ("tap-and-drag"). +When enabled, a tap followed by a finger held down causes a single button down +only, all motions of that finger thus translate into dragging motion. +Tap-and-drag requires option +.B Tapping +to be enabled. +.TP 7 +.BI "Option \*qTappingDragLock\*q \*q" bool \*q +Enables or disables drag lock during tapping behavior. +When enabled, +a finger up during tap-and-drag will not immediately release the button. +If the finger is set down again within the timeout, +the dragging process continues. +.PP +For all options, the options are only parsed if the device supports that +configuration option. +For all options, the default value is the one used by libinput. +On configuration failure, the default value is applied. + +.SH SUPPORTED PROPERTIES +.B libinput +exports runtime-configurable options as properties. +If a property listed below is not available, +the matching configuration option is not available on the device. +This however does not imply that the feature is not available on the device. +The following properties are provided by the +.B libinput +driver. +.TP 7 +.B "libinput Accel Profiles Available" +3 boolean values (8 bit, 0 or 1), in order "adaptive", "flat", "custom". +Indicates which acceleration profiles are available on this device. +.TP 7 +.B "libinput Accel Profile Enabled" +3 boolean values (8 bit, 0 or 1), in order "adaptive", "flat", "custom". +Indicates which acceleration profile is currently enabled on this device. +.TP 7 +.B "libinput Accel Speed" +1 32-bit float value, defines the pointer speed. +Value range -1, 1. +This only applies to the flat or adaptive profile. +.TP 7 +.B "libinput Accel Custom Fallback Points" +.TQ +.B "libinput Accel Custom Motion Points" +.TQ +.B "libinput Accel Custom Scroll Points" +A space-separated list of 32-bit floating point non-negative numbers, e.g. +"0.0 1.0 2.4 2.5". +Sets the points of the Fallback/Motion/Scroll acceleration functions. +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.B "libinput Accel Custom Fallback Step" +.TQ +.B "libinput Accel Custom Motion Step" +.TQ +.B "libinput Accel Custom Scroll Step" +1 32-bit float value, sets the step between the points of the +Fallback/Motion/Scroll acceleration functions. +When a step of 0.0 is provided, libinput's Fallback acceleration +function is used. +This only applies to the custom profile. +See section +.B CUSTOM ACCELERATION PROFILE +.TP 7 +.B "libinput Button Scrolling Button" +1 32-bit value. Sets the button number to use for button scrolling. +This setting is independent of the scroll method, to enable button scrolling the +method must be set to button-scrolling and a valid button must be set. +.TP 7 +.B "libinput Button Scrolling Button Lock Enabled" +1 boolean value. If true, the scroll button lock is enabled. +This setting is independent of the scroll method or the scroll button, to enable +button scrolling the method must be set to button-scrolling and a valid +button must be set. +.TP 7 +.B "libinput Calibration Matrix" +9 32-bit float values, representing a 3x3 calibration matrix, order is row +1, row 2, row 3 +.TP 7 +.B "libinput Click Methods Available" +2 boolean values (8 bit, 0 or 1), in order "buttonareas", "clickfinger". +Indicates which click methods are available on this device. +.TP 7 +.B "libinput Click Methods Enabled" +2 boolean values (8 bit, 0 or 1), in order "buttonareas", "clickfinger". +Indicates which click methods are enabled on this device. +.TP 7 +.B "libinput Drag Lock Buttons" +Either one 8-bit value specifying the meta drag lock button, or a list of +button pairs. +See section +.B BUTTON DRAG LOCK +for details. +.TP 7 +.B "libinput High Resolution Wheel Scroll Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates whether high-resolution wheel scroll events are enabled or not. +.TP 7 +.B "libinput Horizontal Scroll Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates whether horizontal scrolling events are enabled or not. +.TP 7 +.B "libinput Left Handed Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates if left-handed mode is enabled or disabled. +.TP 7 +.B "libinput Middle Emulation Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates if middle emulation is enabled or disabled. +.TP 7 +.B "libinput Natural Scrolling Enabled" +1 boolean value (8 bit, 0 or 1). +1 enables natural scrolling. +.TP 7 +.B "libinput Rotation Angle" +1 32-bit float value [0.0 to 360.0). +Sets the rotation angle of the device, +clockwise of its natural neutral position. +.TP 7 +.B "libinput Scrolling Factor" +1 32-bit float value. +Sets the scroll factor for scroll events. A value higher than 1.0 means faster scrolling. +Applications that don't support xi2 input will instead receive scroll button events +less or more frequently depending on the scroll factor value, instead of scrolling "smoother". +.TP 7 +.B "libinput Scroll Methods Available" +3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button". +Indicates which scroll methods are available on this device. +.TP 7 +.B "libinput Scroll Method Enabled" +3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button". +Indicates which scroll method is currently enabled on this device. +.TP 7 +.B "libinput Scrolling Pixel Distance" +1 32-bit value (nonzero, with additional implementation-defined range checks). +Changes the movement distance required to trigger one logical wheel click. +.TP 7 +.B "libinput Send Events Modes Available" +2 boolean values (8 bit, 0 or 1), in order "disabled" and +"disabled-on-external-mouse". +Indicates which send-event modes are available on this device. +.TP 7 +.B "libinput Send Events Mode Enabled" +2 boolean values (8 bit, 0 or 1), in order "disabled" and +"disabled-on-external-mouse". +Indicates which send-event mode is currently enabled on this device. +.TP 7 +.B "libinput Tablet Tool Pressurecurve" +4 32-bit float values [0.0 to 1.0]. +See section +.B TABLET TOOL PRESSURE CURVE +.TP 7 +.B "libinput Tablet Tool Area Ratio" +2 32-bit values, corresponding to width and height. +Special value 0, 0 resets to the default ratio. +See section +.B TABLET TOOL AREA RATIO +for more information. +.TP 7 +.B "libinput Tapping Enabled" +1 boolean value (8 bit, 0 or 1). +1 enables tapping. +.TP 7. +.B "libinput Tapping Button Mapping Enabled" +2 boolean value (8 bit, 0 or 1), in order "lrm" and "lmr". +Indicates which button mapping is currently enabled on this device. +.TP 7 +.B "libinput Tapping Drag Lock Enabled" +1 boolean value (8 bit, 0 or 1). +1 enables drag lock during tapping. +.TP 7 +.B "libinput Disable While Typing Enabled" +1 boolean value (8 bit, 0 or 1). +Indicates if disable while typing is enabled or disabled. +.PP +Most properties have a +.B "libinput Default" +equivalent that indicates the default value for this setting on this device. + +.SH BUTTON MAPPING +X clients receive events with logical button numbers, +where 1, 2, 3 are usually interpreted as left, middle, right; +and logical buttons 4, 5, 6, 7 are usually interpreted +as scroll up, down, left, right. +The fourth and fifth physical buttons on a device +will thus send logical buttons 8 and 9. +The +.B ButtonMapping +option adjusts the logical button mapping, it does not affect how a physical +button is mapped to a logical button. +.PP +Traditionally, a device was set to left-handed button mode by applying a +button mapping of +.B "\*q3 2 1 ...\*q" +On systems using the +.B libinput +XLibre input driver it is recommended to use the +.B LeftHanded +option instead. +.PP +The +.B libinput +XLibre input driver does not use the button mapping after setup. +Use +.BR XSetPointerMapping (3) +to modify the button mapping at runtime. + +.SH BUTTON DRAG LOCK +Button drag lock holds a button logically down even when the button itself +has been physically released since. +Button drag lock comes in two modes. +.PP +If in "meta" mode, a meta button click activates drag lock for the next +button press of any other button. +A button click in the future will keep that button held logically down +until a subsequent click of that same button. +The meta button events themselves are discarded. +A separate meta button click is required each time a drag lock should be +activated for a button in the future. +.PP +If in "pairs" mode, each button can be assigned a target locking button. +On button click, the target lock button is held logically down until the +next click of the same button. +The button events themselves are discarded +and only the target button events are sent. +.PP +This feature is provided by this driver, not by libinput. + +.SH TABLET TOOL PRESSURE CURVE +The pressure curve affects how stylus pressure is reported. +By default, the hardware pressure is reported as-is. +By setting a pressure curve, the feel of the stylus can be adjusted +to be more like e.g. a pencil or a brush. +.PP +The pressure curve is a cubic Bezier curve, drawn within a normalized range +of 0.0 to 1.0 between the four points provided. +This normalized range is applied to the tablet's pressure input +so that the highest pressure maps to 1.0. +The points must have increasing x coordinates, if x0 is larger than 0.0 +all pressure values lower than x0 are equivalent to y0. +If x3 is less than 1.0, +all pressure values higher than x3 are equivalent to y3. +.PP +The input for a linear curve (default) is "0.0/0.0 0.0/0.0 1.0/1.0 1.0/1.0"; +a slightly depressed curve (firmer) might be +"0.0/0.0 0.05/0.0 1.0/0.95 1.0/1.0"; +a slightly raised curve (softer) might be "0.0/0.0 0.0/0.05 0.95/1.0 1.0/1.0". +.PP +This feature is provided by this driver, not by libinput. + +.SH TABLET TOOL AREA RATIO +By default, a tablet tool can access the whole sensor area and the tablet +area is mapped to the available screen area. +For external tablets like the Wacom Intuos series, +the height:width ratio of the tablet may be different to that of the monitor, +causing the skew of input data. +.PP +To avoid this skew of input data, an area ratio may be set to match the +ratio of the screen device. +For example, a ratio of 4:3 will reduce the available area of the tablet +to the largest available area with a ratio of 4:3. +Events within this area will scale to the tablet's announced axis range, +the area ratio is thus transparent to the X server. +Any events outside this area will send events equal to the maximum value of +that axis. +The area always starts at the device's origin in it's current rotation, i.e., +it takes left-handed-ness into account. +.PP +This feature is provided by this driver, not by libinput. + +.SH SCROLL PIXEL DISTANCE +The X server does not support per-pixel scrolling but it does support +smooth scrolling. +All scroll events however are based around a logical unit of scrolling +(traditionally corresponding to a wheel click). +It is thus not possible to scroll by 10 pixels, but it is possible for a +driver to scroll by 1/10th of a logical wheel click. +.PP +libinput provides scroll data in pixels. +The \fBScrollPixelDistance\fR option defines the amount of movement equivalent +to one wheel click. +For example, a value of 50 means the user has to move a finger by 50 pixels to +generate one logical click event and each pixel is 1/50th of a wheel click. + +.SH CUSTOM ACCELERATION PROFILE +The custom pointer acceleration profile gives users full control over the +acceleration behavior at different speeds. +libinput exposes an acceleration function \fIf(x)\fP +where the x-axis is the device speed in device units per millisecond +and the y-axis is the pointer speed. +.PP +The custom acceleration function is defined using n points which are spaced +uniformly along the x-axis, starting from 0 and continuing in constant steps. +Thus the points defining the custom function are: +.EX +(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1]) +.EE +When a velocity value does not lie exactly on those points, +a linear interpolation/extrapolation of the two closest points +will be calculated. +.PP +There are 3 custom acceleration functions, +which are used for different movement types: +.TS +tab(;) allbox; +l l l. +Movement type; Uses; supported by +Fallback; Catch-all default movement type; All devices +Motion; Used for pointer motion; All devices +Scroll; Used for scroll movement; Mouse, Touchpad +.TE +.PP +See libinput library documentation for more details: +https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html#the-custom-acceleration-profile + +.SH BUGS +This driver does not work with \fBOption \*qDevice\*q\fR set to an event +node in \fI/dev/input/by-id\fR and \fI/dev/input/by-path\fR. +This can be usually be worked by using \fBSection \*qInputClass\*q\fR with an +appropriate \fBMatch*\fR statement in the +.BR xorg.conf (5). + +.SH AUTHORS +Peter Hutterer +.SH "SEE ALSO" +.BR XLibre (1), +.BR xorg.conf (5), +.BR Xserver (1), +.BR X (7) diff --git a/src/xf86-input-libinput/meson.build b/src/xf86-input-libinput/meson.build new file mode 100644 index 0000000..a49f3f4 --- /dev/null +++ b/src/xf86-input-libinput/meson.build @@ -0,0 +1,154 @@ +project('xf86-input-libinput', 'c', + version: '25.0.1', + default_options: ['warning_level=2'], + meson_version: '>= 0.50.0') + +driver_version = meson.project_version().split('.') + +dir_pkgconf = get_option('prefix') / get_option('libdir') / 'pkgconfig' +dir_man4 = get_option('prefix') / get_option('mandir') / 'man4' + +cc = meson.get_compiler('c') +cflags = [ + '-Wno-unused-parameter', + '-Wno-sign-compare', # lots of work to get rid of this + '-Wmissing-prototypes', + '-Wstrict-prototypes', + '-Wlogical-op', + '-Wpointer-arith', + '-Wuninitialized', + '-Winit-self', + '-Wstrict-prototypes', + '-Wimplicit-fallthrough', + '-Wredundant-decls', + '-Wincompatible-pointer-types', + '-Wformat=2', + '-Wno-missing-field-initializers', + '-Wmissing-declarations', + + '-fvisibility=hidden', +] +add_project_arguments(cc.get_supported_arguments(cflags), language: 'c') + +pkgconfig = import('pkgconfig') +dep_xserver = dependency('xorg-server', version: '>= 1.19') +dep_xproto = dependency('xproto') +dep_inputproto = dependency('inputproto', version: '>= 2.3.99.1') +dep_libinput = dependency('libinput', version: '>= 1.11.0') + +config_h = configuration_data() +config_h.set('PACKAGE_VERSION_MAJOR', driver_version[0]) +config_h.set('PACKAGE_VERSION_MINOR', driver_version[1]) +config_h.set('PACKAGE_VERSION_PATCHLEVEL', driver_version[2]) + +if cc.has_function('libinput_device_config_scroll_get_button_lock', + dependencies: dep_libinput) + config_h.set('HAVE_LIBINPUT_SCROLL_BUTTON_LOCK', 1) +endif +if cc.has_function('libinput_event_pointer_get_scroll_value_v120', + dependencies: dep_libinput) + config_h.set('HAVE_LIBINPUT_AXIS_VALUE_V120', 1) +endif +if cc.has_function('libinput_config_accel_create', + dependencies: dep_libinput) + config_h.set('HAVE_LIBINPUT_CUSTOM_ACCEL', 1) +endif +if cc.has_function('libinput_tablet_tool_config_pressure_range_set', + dependencies: dep_libinput) + config_h.set('HAVE_LIBINPUT_PRESSURE_RANGE', 1) +endif +if cc.has_function('libinput_device_config_click_set_clickfinger_button_map', + dependencies: dep_libinput) + config_h.set('HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP', 1) +endif +if cc.has_header_symbol('libinput.h', 'LIBINPUT_LED_COMPOSE', + dependencies: dep_libinput) + config_h.set('HAVE_LIBINPUT_COMPOSE_AND_KANA', 1) +endif +if cc.has_function('libinput_plugin_system_load_plugins', dependencies: dep_libinput) + config_h.set('HAVE_LIBINPUT_PLUGINS', 1) +endif + +dir_headers = get_option('sdkdir') +if dir_headers == '' + dir_headers = dep_xserver.get_pkgconfig_variable('sdkdir') +endif + +dir_xorg_module = get_option('xorg-module-dir') +if dir_xorg_module == '' + dir_xorg_module = dep_xserver.get_pkgconfig_variable('moduledir') / 'input' +endif + +dir_xorg_conf = get_option('xorg-conf-dir') +if dir_xorg_conf == '' + dir_xorg_conf = dep_xserver.get_pkgconfig_variable('sysconfigdir') +endif + +libbezier = static_library('bezier', ['src/bezier.c', 'src/bezier.h']) +dep_libbezier = declare_dependency(link_with: libbezier) + +libdraglock = static_library('draglock', ['src/draglock.c', 'src/draglock.h']) +dep_libdraglock = declare_dependency(link_with: libdraglock) + +dep_drivers = [ + dep_xserver, + dep_xproto, + dep_inputproto, + dep_libinput, + dep_libbezier, + dep_libdraglock, +] + +driver_src = ['src/xf86libinput.c', 'src/util-strings.c'] +driver_lib = shared_module( + 'libinput_drv', + driver_src, + name_prefix: '', # we want libinput_drv.so, not liblibinput_drv.so + include_directories: include_directories('include'), + dependencies: dep_drivers, + install: true, + install_dir: dir_xorg_module, +) + +test_bezier = executable('test-bezier', + ['test/test-bezier.c'], + dependencies: dep_libbezier, + include_directories: include_directories('src'), + install: false) +test('test-bezier', test_bezier) + +test_draglock = executable('test-draglock', + ['test/test-draglock.c'], + dependencies: dep_libdraglock, + include_directories: include_directories('src'), + install: false) +test('test-draglock', test_draglock) + + +conf_pkgconf = configuration_data() +conf_pkgconf.set('PACKAGE_VERSION', meson.project_version()) +conf_pkgconf.set('sdkdir', dir_headers) + +configure_file( + input: 'xorg-libinput.pc.in', + output: 'xorg-libinput.pc', + configuration: conf_pkgconf, + install_dir: dir_pkgconf, +) + +config_man = configuration_data() +config_man.set('VERSION', '@0@ @1@'.format(meson.project_name(), meson.project_version())) + +configure_file( + input: 'man/libinput.man', + output: 'libinput.4', + configuration: config_man, + install_dir: dir_man4 +) + +install_headers('include/libinput-properties.h', install_dir: dir_headers) + +install_data('conf/40-libinput.conf', install_dir: dir_xorg_conf) + +# Now generate config.h +configure_file(output: 'config.h', configuration: config_h) diff --git a/src/xf86-input-libinput/meson_options.txt b/src/xf86-input-libinput/meson_options.txt new file mode 100644 index 0000000..6de43b9 --- /dev/null +++ b/src/xf86-input-libinput/meson_options.txt @@ -0,0 +1,15 @@ +option('sdkdir', + type: 'string', + value: '', + description: 'Directory to install header files in [default=from xorg-server pkgconf]', +) +option('xorg-module-dir', + type : 'string', + value : '', + description : 'Default xorg module directory [default=from xorg-server pkgconf]', +) +option('xorg-conf-dir', + type : 'string', + value : '', + description : 'Default xorg.conf.d directory [default=from xorg-server pkgconfig]' +) diff --git a/src/xf86-input-libinput/src/Makefile.am b/src/xf86-input-libinput/src/Makefile.am new file mode 100644 index 0000000..48d19f9 --- /dev/null +++ b/src/xf86-input-libinput/src/Makefile.am @@ -0,0 +1,45 @@ +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +# this is obnoxious: +# -module lets us name the module exactly how we want +# -avoid-version prevents gratuitous .0.0.0 version numbers on the end +# _ladir passes a dummy rpath to libtool so the thing will actually link +# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. + +AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) +AM_CPPFLAGS =-I$(top_srcdir)/include $(LIBINPUT_CFLAGS) + +libinput_drv_la_LTLIBRARIES = libinput_drv.la +libinput_drv_la_LDFLAGS = -module -avoid-version +libinput_drv_la_LIBADD = $(LIBINPUT_LIBS) libdraglock.la libbezier.la -lm +libinput_drv_ladir = @inputdir@ + +libinput_drv_la_SOURCES = \ + xf86libinput.c \ + util-macros.h \ + util-strings.h \ + util-strings.c \ + $(NULL) + +noinst_LTLIBRARIES = libdraglock.la libbezier.la +libdraglock_la_SOURCES = draglock.c draglock.h +libbezier_la_SOURCES = bezier.c bezier.h diff --git a/src/xf86-input-libinput/src/bezier.c b/src/xf86-input-libinput/src/bezier.c new file mode 100644 index 0000000..8a32607 --- /dev/null +++ b/src/xf86-input-libinput/src/bezier.c @@ -0,0 +1,176 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2016 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "config.h" + +#include +#include +#include + +#include "bezier.h" + +const struct bezier_control_point bezier_defaults[4] = { + { 0.0, 0.0 }, + { 0.0, 0.0 }, + { 1.0, 1.0 }, + { 1.0, 1.0 }, +}; + +struct point { + int x, y; +}; + +/** + * de Casteljau's algorithm. See this page here + * https://pomax.github.io/bezierinfo/#extended + * + * To play with bezier curve shapes, I used + * http://cubic-bezier.com/ + */ +static struct point +decasteljau(const struct point *controls, + size_t ncontrols, + double t) +{ + struct point new_controls[ncontrols]; + + if (ncontrols == 1) + return controls[0]; + + for (int i = 0; i < ncontrols - 1; i++) { + new_controls[i].x = (1.0 - t) * controls[i].x + t * controls[i + 1].x; + new_controls[i].y = (1.0 - t) * controls[i].y + t * controls[i + 1].y; + } + + return decasteljau(new_controls, ncontrols - 1, t); +} + +/** + * Given a Bézier curve defined by the control points, reduce the curve to + * one with ncurve_points. + */ +static void +flatten_curve(const struct point *controls, + size_t ncontrols, + struct point *curve, + size_t ncurve_points) +{ + ncurve_points--; /* make sure we end up with 100/100 as last point */ + + for (int i = 0; i <= ncurve_points; i++) { + double t = 1.0 * i/ncurve_points; + struct point p; + + p = decasteljau(controls, ncontrols, t); + curve[i] = p; + } +} + +/** + * Calculate line through a and b, set curve[x] for each x between + * [a.x, b.x]. + * + * Note: pcurve must be at least b.x size. + */ +static void +line_between(struct point a, struct point b, + struct point *curve, size_t curve_sz) +{ + double slope; + double offset; + + assert(b.x < curve_sz); + + if (a.x == b.x) { + curve[a.x].x = a.x; + curve[a.x].y = a.y; + return; + } + + slope = (double)(b.y - a.y)/(b.x - a.x); + offset = a.y - slope * a.x; + + for (int x = a.x; x <= b.x; x++) { + struct point p; + p.x = x; + p.y = slope * x + offset; + curve[x] = p; + } +} + +bool +cubic_bezier(const struct bezier_control_point controls[4], + int *bezier_out, + size_t bezier_sz) +{ + const int nsegments = 50; + const int range = bezier_sz - 1; + struct point curve[nsegments]; + struct point bezier[bezier_sz]; + struct point zero = { 0, 0 }, + max = { range, range}; + + /* Scale control points into the [0, bezier_sz) range */ + struct point ctrls[4]; + + for (int i = 0; i < 4; i++) { + if (controls[i].x < 0.0 || controls[i].x > 1.0 || + controls[i].y < 0.0 || controls[i].y > 1.0) + return false; + + ctrls[i].x = controls[i].x * range; + ctrls[i].y = controls[i].y * range; + } + + for (int i = 0; i < 3; i++) { + if (ctrls[i].x > ctrls[i+1].x) + return false; + } + + /* Reduce curve to nsegments, because this isn't a drawing program */ + flatten_curve(ctrls, 4, curve, nsegments); + + /* we now have nsegments points in curve that represent the bezier + curve (already in the [0, bezier_sz) range). Run through the + points and draw a straight line between each point and voila, we + have our curve. + + If the first control points (x0/y0) is not at x == 0 or the last + control point (x3/y3) is not at the max value, draw a line + between from 0/0 to x0/y0 and from x3/y3 to xmax/y3. + */ + + line_between(zero, curve[0], bezier, bezier_sz); + + for (int i = 0; i < nsegments - 1; i++) + line_between(curve[i], curve[i+1], bezier, bezier_sz); + + if (curve[nsegments - 1].x < max.x) + line_between(curve[nsegments - 1], max, bezier, bezier_sz); + + for (int i = 0; i < bezier_sz; i++) + bezier_out[i] = bezier[i].y; + + return true; +} diff --git a/src/xf86-input-libinput/src/bezier.h b/src/xf86-input-libinput/src/bezier.h new file mode 100644 index 0000000..d59536d --- /dev/null +++ b/src/xf86-input-libinput/src/bezier.h @@ -0,0 +1,68 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2016 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "config.h" + +#ifndef BEZIER_H +#define BEZIER_H + +#include +#include + +struct bezier_control_point { + double x, y; +}; + +extern const struct bezier_control_point bezier_defaults[4]; + +/** + * Given four control points in the range [(0.0/0.0), (1.0/1.0)] + * construct a Bézier curve. + * + * ^ + *1.0 | c2 ______ c3 + * | _/ + * | / + * |c1 / + * | / + * | / + * |/_________________> + * c0 1.0 + * + * This function requires that c[i].x <= c[i+1].x + * + * The curve is mapped into a canvas size [0, bezier_sz)². For each x + * coordinate in [0, bezier_sz), the matching y coordinate is thus + * bezier[x]. + * + * In other words, if you have a range [0,2048) input possible values, + * the output is a list of 2048 points in a [0, 2048) range. + * + * @return true on success, false otherwise + */ +bool +cubic_bezier(const struct bezier_control_point controls[4], + int *bezier, + size_t bezier_sz); +#endif diff --git a/src/xf86-input-libinput/src/draglock.c b/src/xf86-input-libinput/src/draglock.c new file mode 100644 index 0000000..423dd84 --- /dev/null +++ b/src/xf86-input-libinput/src/draglock.c @@ -0,0 +1,281 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "config.h" + +#include "draglock.h" + +#include +#include + +#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) + +static int +draglock_parse_config(struct draglock *dl, const char *config) +{ + int button = 0, target = 0; + const char *str = NULL; + char *end_str = NULL; + int pairs[DRAGLOCK_MAX_BUTTONS] = {0}; + + if (!config) + return 0; + + /* empty string disables drag lock */ + if (*config == '\0') { + dl->mode = DRAGLOCK_DISABLED; + return 0; + } + + /* check for a single-number string first, config is "" */ + button = strtol(config, &end_str, 10); + if (*end_str == '\0') { + if (button < 0 || button >= DRAGLOCK_MAX_BUTTONS) + return 1; + /* we allow for button 0 so stacked xorg.conf.d snippets can + * disable the config again */ + if (button == 0) { + dl->mode = DRAGLOCK_DISABLED; + return 0; + } + + return draglock_set_meta(dl, button); + } + + dl->mode = DRAGLOCK_DISABLED; + + /* check for a set of button pairs, config is + * " ..." */ + str = config; + while (*str != '\0') { + button = strtol(str, &end_str, 10); + if (*end_str == '\0') + return 1; + + str = end_str; + target = strtol(str, &end_str, 10); + if (end_str == str) + return 1; + if (button <= 0 || button >= DRAGLOCK_MAX_BUTTONS || target >= DRAGLOCK_MAX_BUTTONS) + return 1; + + pairs[button] = target; + str = end_str; + } + + return draglock_set_pairs(dl, pairs, ARRAY_SIZE(pairs)); +} + +int +draglock_init_from_string(struct draglock *dl, const char *config) +{ + dl->mode = DRAGLOCK_DISABLED; + + dl->meta_button = 0; + dl->meta_state = false; + memset(dl->lock_pair, 0, sizeof(dl->lock_pair)); + memset(dl->lock_state, 0, sizeof(dl->lock_state)); + + return draglock_parse_config(dl, config); +} + +enum draglock_mode +draglock_get_mode(const struct draglock *dl) +{ + return dl->mode; +} + +int +draglock_get_meta(const struct draglock *dl) +{ + if (dl->mode == DRAGLOCK_META) + return dl->meta_button; + return 0; +} + +size_t +draglock_get_pairs(const struct draglock *dl, int *array, size_t nelem) +{ + unsigned int i; + size_t last = 0; + + if (dl->mode != DRAGLOCK_PAIRS) + return 0; + + /* size 1 array with the meta button */ + if (dl->meta_button) { + *array = dl->meta_button; + return 1; + } + + /* size N array with a[0] == 0, the rest ordered by button number */ + memset(array, 0, nelem * sizeof(array[0])); + for (i = 0; i < nelem && i < ARRAY_SIZE(dl->lock_pair); i++) { + array[i] = dl->lock_pair[i]; + if (array[i] != 0 && i > last) + last = i; + } + return last; +} + +int +draglock_set_meta(struct draglock *dl, int meta_button) +{ + if (meta_button < 0 || meta_button >= DRAGLOCK_MAX_BUTTONS) + return 1; + + dl->meta_button = meta_button; + dl->mode = meta_button ? DRAGLOCK_META : DRAGLOCK_DISABLED; + + return 0; +} + +int +draglock_set_pairs(struct draglock *dl, const int *array, size_t nelem) +{ + unsigned int i; + + if (nelem == 0 || array[0] != 0) + return 1; + + for (i = 0; i < nelem; i++) { + if (array[i] < 0 || array[i] >= DRAGLOCK_MAX_BUTTONS) + return 1; + } + + dl->mode = DRAGLOCK_DISABLED; + for (i = 0; i < nelem; i++) { + dl->lock_pair[i] = array[i]; + if (dl->lock_pair[i]) + dl->mode = DRAGLOCK_PAIRS; + } + + return 0; +} + +static int +draglock_filter_meta(struct draglock *dl, int *button, int *press) +{ + int b = *button, + is_press = *press; + + if (b == dl->meta_button) { + if (is_press) + dl->meta_state = true; + *button = 0; + return 0; + } + + switch (dl->lock_state[b]) { + case DRAGLOCK_BUTTON_STATE_NONE: + if (dl->meta_state && is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_1; + dl->meta_state = false; + } + break; + case DRAGLOCK_BUTTON_STATE_DOWN_1: + if (!is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_UP_1; + b = 0; + } + break; + case DRAGLOCK_BUTTON_STATE_UP_1: + if (is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_2; + b = 0; + } + break; + case DRAGLOCK_BUTTON_STATE_DOWN_2: + if (!is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_NONE; + } + break; + } + + *button = b; + + return 0; +} + +static int +draglock_filter_pair(struct draglock *dl, int *button, int *press) +{ + int b = *button, + is_press = *press; + + if (dl->lock_pair[b] == 0) + return 0; + + switch (dl->lock_state[b]) { + case DRAGLOCK_BUTTON_STATE_NONE: + if (is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_1; + b = dl->lock_pair[b]; + } + break; + case DRAGLOCK_BUTTON_STATE_DOWN_1: + if (!is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_UP_1; + b = 0; + } + break; + case DRAGLOCK_BUTTON_STATE_UP_1: + if (is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_2; + b = 0; + } + break; + case DRAGLOCK_BUTTON_STATE_DOWN_2: + if (!is_press) { + dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_NONE; + b = dl->lock_pair[b]; + } + break; + } + + *button = b; + + return 0; +} + +int +draglock_filter_button(struct draglock *dl, int *button, int *is_press) +{ + if (*button == 0) + return 0; + + switch(dl->mode) { + case DRAGLOCK_DISABLED: + return 0; + case DRAGLOCK_META: + return draglock_filter_meta(dl, button, is_press); + case DRAGLOCK_PAIRS: + return draglock_filter_pair(dl, button, is_press); + default: + abort(); + break; + } + + return 0; +} diff --git a/src/xf86-input-libinput/src/draglock.h b/src/xf86-input-libinput/src/draglock.h new file mode 100644 index 0000000..bddf6a2 --- /dev/null +++ b/src/xf86-input-libinput/src/draglock.h @@ -0,0 +1,158 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +#include "config.h" + +#ifndef DRAGLOCK_H +#define DRAGLOCK_H 1 + +#include +#include + +/* 32 buttons are enough for everybody™ + * Note that this is the limit of physical buttons as well as the highest + * allowed target button. + */ +#define DRAGLOCK_MAX_BUTTONS 32 + +enum draglock_mode +{ + DRAGLOCK_DISABLED, + DRAGLOCK_META, + DRAGLOCK_PAIRS +}; + +enum draglock_button_state +{ + DRAGLOCK_BUTTON_STATE_NONE, + DRAGLOCK_BUTTON_STATE_DOWN_1, + DRAGLOCK_BUTTON_STATE_UP_1, + DRAGLOCK_BUTTON_STATE_DOWN_2, +}; + +struct draglock +{ + enum draglock_mode mode; + int meta_button; /* meta key to lock any button */ + bool meta_state; /* meta_button state */ + unsigned int lock_pair[DRAGLOCK_MAX_BUTTONS + 1];/* specify a meta/lock pair */ + enum draglock_button_state lock_state[DRAGLOCK_MAX_BUTTONS + 1]; /* state of any locked buttons */ +}; + +/** + * Initialize the draglock struct based on the config string. The string is + * either a single number to configure DRAGLOCK_META mode or a list of + * number pairs, with pair[0] as button and pair[1] as target lock number to + * configure DRAGLOCK_PAIRS mode. + * + * If config is NULL, the empty string, "0" or an even-numbered list of 0, + * the drag lock mode is DRAGLOCK_DISABLED. + * + * @return 0 on success or nonzero on error + */ +int +draglock_init_from_string(struct draglock *dl, const char *config); + +/** + * Get the current drag lock mode. + * + * If the mode is DRAGLOCK_META, a meta button click will cause the next + * subsequent button click to be held logically down until the release of + * the second button click of that same button. Events from the meta button + * are always discarded. + * + * If the mode is DRAGLOCK_PAIRS, any button may be configured with a + * 'target' button number. A click of that button causes the target button + * to be held logically down until the release of the second button click. + */ +enum draglock_mode +draglock_get_mode(const struct draglock *dl); + +/** + * @return the meta button number or 0 if the current mode is not + * DRAGLOCK_META. + */ +int +draglock_get_meta(const struct draglock *dl); + +/** + * Get the drag lock button mapping pairs. The array is filled with the + * button number as index and the mapped target button number as value, i.e. + * array[3] == 8 means button 3 will draglock button 8. + * + * A value of 0 indicates draglock is disabled for that button. + * + * @note Button numbers start at 1, array[0] is always 0. + * + * @param[in|out] array Caller-allocated array to hold the button mappings. + * @param[in] nelem Maximum number of elements in array + * + * @return The number of valid elements in array or 0 if the current mode is + * not DRAGLOCK_PAIRS + */ +size_t +draglock_get_pairs(const struct draglock *dl, int *array, size_t nelem); + +/** + * Set the drag lock config to the DRAGLOCK_META mode, with the given + * button as meta button. + * + * If the button is 0 the mode becomes DRAGLOCK_DISABLED. + * + * @return 0 on success, nonzero otherwise + */ +int +draglock_set_meta(struct draglock *dl, int meta_button); + +/** + * Set the drag lock config to the DRAGLOCK_PAIRS mode. The array + * must be filled with the button number as index and the mapped target + * button number as value, i.e. + * array[3] == 8 means button 3 will draglock button 8. + * + * A value of 0 indicates draglock is disabled for that button. If all + * buttons are 0, the mode becomes DRAGLOCK_DISABLED. + * + * @note Button numbers start at 1, array[0] is always 0. + * + * @return 0 on successor nonzero otherwise + */ +int +draglock_set_pairs(struct draglock *dl, const int *array, size_t nelem); + +/** + * Process the given button event through the drag lock state machine. + * If the event is to be discarded by the caller, button is set to 0. + * Otherwise, button is set to the button event to process and is_press is + * set to the button state to process. + * + * @param[in|out] button The button number to process + * @param[in|out] is_press nonzero for press, zero for release + * + * @return 0 on success or 1 on error + */ +int +draglock_filter_button(struct draglock *dl, int *button, int *is_press); + +#endif /* DRAGLOCK_H */ diff --git a/src/xf86-input-libinput/src/util-macros.h b/src/xf86-input-libinput/src/util-macros.h new file mode 100644 index 0000000..d56a8a3 --- /dev/null +++ b/src/xf86-input-libinput/src/util-macros.h @@ -0,0 +1,65 @@ +/* + * Copyright © 2008-2011 Kristian Høgsberg + * Copyright © 2011 Intel Corporation + * Copyright © 2013-2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include "config.h" + +#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) +/** + * Iterate through the array _arr, assigning the variable elem to each + * element. elem only exists within the loop. + */ +#define ARRAY_FOR_EACH(_arr, _elem) \ + for (__typeof__((_arr)[0]) *_elem = _arr; \ + _elem < (_arr) + ARRAY_LENGTH(_arr); \ + _elem++) + +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) + +#define ANSI_HIGHLIGHT "\x1B[0;1;39m" +#define ANSI_RED "\x1B[0;31m" +#define ANSI_GREEN "\x1B[0;32m" +#define ANSI_YELLOW "\x1B[0;33m" +#define ANSI_BLUE "\x1B[0;34m" +#define ANSI_MAGENTA "\x1B[0;35m" +#define ANSI_CYAN "\x1B[0;36m" +#define ANSI_BRIGHT_RED "\x1B[0;31;1m" +#define ANSI_BRIGHT_GREEN "\x1B[0;32;1m" +#define ANSI_BRIGHT_YELLOW "\x1B[0;33;1m" +#define ANSI_BRIGHT_BLUE "\x1B[0;34;1m" +#define ANSI_BRIGHT_MAGENTA "\x1B[0;35;1m" +#define ANSI_BRIGHT_CYAN "\x1B[0;36;1m" +#define ANSI_NORMAL "\x1B[0m" + +#define ANSI_UP "\x1B[%dA" +#define ANSI_DOWN "\x1B[%dB" +#define ANSI_RIGHT "\x1B[%dC" +#define ANSI_LEFT "\x1B[%dD" + +#define CASE_RETURN_STRING(a) case a: return #a + +#define _fallthrough_ __attribute__((fallthrough)) diff --git a/src/xf86-input-libinput/src/util-strings.c b/src/xf86-input-libinput/src/util-strings.c new file mode 100644 index 0000000..7ad25ae --- /dev/null +++ b/src/xf86-input-libinput/src/util-strings.c @@ -0,0 +1,246 @@ +/* + * Copyright © 2008 Kristian Høgsberg + * Copyright © 2013-2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "config.h" +#define _GNU_SOURCE + +#include "util-strings.h" + +/** + * Return the next word in a string pointed to by state before the first + * separator character. Call repeatedly to tokenize a whole string. + * + * @param state Current state + * @param len String length of the word returned + * @param separators List of separator characters + * + * @return The first word in *state, NOT null-terminated + */ +static const char * +next_word(const char **state, size_t *len, const char *separators) +{ + const char *next = *state; + size_t l; + + if (!*next) + return NULL; + + next += strspn(next, separators); + if (!*next) { + *state = next; + return NULL; + } + + l = strcspn(next, separators); + *state = next + l; + *len = l; + + return next; +} + +/** + * Return a null-terminated string array with the contents of argv + * duplicated. + * + * Use strv_free() to free the array. + * + * @return A null-terminated string array or NULL on errors + */ +char** +strv_from_argv(int argc, char **argv) +{ + char **strv = NULL; + + assert(argc >= 0); + + if (argc == 0) + return NULL; + + strv = zalloc((argc + 1) * sizeof *strv); + for (int i = 0; i < argc; i++) { + char *copy = safe_strdup(argv[i]); + if (!copy) { + strv_free(strv); + return NULL; + } + strv[i] = copy; + } + return strv; +} + +/** + * Return a null-terminated string array with the tokens in the input + * string, e.g. "one two\tthree" with a separator list of " \t" will return + * an array [ "one", "two", "three", NULL ] and num elements 3. + * + * Use strv_free() to free the array. + * + * Another example: + * result = strv_from_string("+1-2++3--4++-+5-+-", "+-", &nelem) + * result == [ "1", "2", "3", "4", "5", NULL ] and nelem == 5 + * + * @param in Input string + * @param separators List of separator characters + * @param num_elements Number of elements found in the input string + * + * @return A null-terminated string array or NULL on errors + */ +char ** +strv_from_string(const char *in, const char *separators, size_t *num_elements) +{ + assert(in != NULL); + + const char *s = in; + size_t l, nelems = 0; + while (next_word(&s, &l, separators) != NULL) + nelems++; + + if (nelems == 0) { + *num_elements = 0; + return NULL; + } + + size_t strv_len = nelems + 1; /* NULL-terminated */ + char **strv = calloc(strv_len, sizeof(*strv)); + if (!strv) + return NULL; + + size_t idx = 0; + const char *word; + s = in; + while ((word = next_word(&s, &l, separators)) != NULL) { + char *copy = strndup(word, l); + if (!copy) { + strv_free(strv); + *num_elements = 0; + return NULL; + } + + strv[idx++] = copy; + } + + *num_elements = nelems; + + return strv; +} + +/** + * Return a newly allocated string with all elements joined by the + * joiner, same as Python's string.join() basically. + * A strv of ["one", "two", "three", NULL] with a joiner of ", " results + * in "one, two, three". + * + * An empty strv ([NULL]) returns NULL, same for passing NULL as either + * argument. + * + * @param strv Input string array + * @param joiner Joiner between the elements in the final string + * + * @return A null-terminated string joining all elements + */ +char * +strv_join(char **strv, const char *joiner) +{ + char **s; + char *str; + size_t slen = 0; + size_t count = 0; + + if (!strv || !joiner) + return NULL; + + if (strv[0] == NULL) + return NULL; + + for (s = strv, count = 0; *s; s++, count++) { + slen += strlen(*s); + } + + assert(slen < 1000); + assert(strlen(joiner) < 1000); + assert(count > 0); + assert(count < 100); + + slen += (count - 1) * strlen(joiner); + + str = zalloc(slen + 1); /* trailing \0 */ + for (s = strv; *s; s++) { + strcat(str, *s); + --count; + if (count > 0) + strcat(str, joiner); + } + + return str; +} + +/** + * Return a pointer to the basename within filename. + * If the filename the empty string or a directory (i.e. the last char of + * filename is '/') NULL is returned. + */ +const char * +safe_basename(const char *filename) +{ + const char *basename; + + if (*filename == '\0') + return NULL; + + basename = strrchr(filename, '/'); + if (basename == NULL) + return filename; + + if (*(basename + 1) == '\0') + return NULL; + + return basename + 1; +} + +/** + * Similar to basename() but returns the trunk only without the (last) + * trailing suffix, so that: + * + * - foo.c returns foo + * - foo.a.b returns foo.a + * - foo returns foo + * - foo/ returns "" + * + * @return an allocated string representing the trunk name of the file + */ +char * +trunkname(const char *filename) +{ + const char *base = safe_basename(filename); + char *suffix; + + if (base == NULL) + return safe_strdup(""); + + suffix = rindex(base, '.'); + if (suffix == NULL) + return safe_strdup(base); + else + return strndup(base, suffix-base); +} diff --git a/src/xf86-input-libinput/src/util-strings.h b/src/xf86-input-libinput/src/util-strings.h new file mode 100644 index 0000000..cc8ba84 --- /dev/null +++ b/src/xf86-input-libinput/src/util-strings.h @@ -0,0 +1,395 @@ +/* + * Copyright © 2008 Kristian Høgsberg + * Copyright © 2013-2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_LOCALE_H +#include +#endif +#ifdef HAVE_XLOCALE_H +#include +#endif + +#include "util-macros.h" + +static inline bool +streq(const char *str1, const char *str2) +{ + /* one NULL, one not NULL is always false */ + if (str1 && str2) + return strcmp(str1, str2) == 0; + return str1 == str2; +} + +static inline bool +strneq(const char *str1, const char *str2, int n) +{ + /* one NULL, one not NULL is always false */ + if (str1 && str2) + return strncmp(str1, str2, n) == 0; + return str1 == str2; +} + +static inline void * +zalloc(size_t size) +{ + void *p; + + /* We never need to alloc anything more than 1,5 MB so we can assume + * if we ever get above that something's going wrong */ + if (size > 1536 * 1024) + assert(!"bug: internal malloc size limit exceeded"); + + p = calloc(1, size); + if (!p) + abort(); + + return p; +} + +/** + * strdup guaranteed to succeed. If the input string is NULL, the output + * string is NULL. If the input string is a string pointer, we strdup or + * abort on failure. + */ +static inline char* +safe_strdup(const char *str) +{ + char *s; + + if (!str) + return NULL; + + s = strdup(str); + if (!s) + abort(); + return s; +} + +static inline bool +safe_atoi_base(const char *str, int *val, int base) +{ + char *endptr; + long v; + + assert(base == 10 || base == 16 || base == 8); + + errno = 0; + v = strtol(str, &endptr, base); + if (errno > 0) + return false; + if (str == endptr) + return false; + if (*str != '\0' && *endptr != '\0') + return false; + + if (v > INT_MAX || v < INT_MIN) + return false; + + *val = v; + return true; +} + +static inline bool +safe_atoi(const char *str, int *val) +{ + return safe_atoi_base(str, val, 10); +} + +static inline bool +safe_atou_base(const char *str, unsigned int *val, int base) +{ + char *endptr; + unsigned long v; + + assert(base == 10 || base == 16 || base == 8); + + errno = 0; + v = strtoul(str, &endptr, base); + if (errno > 0) + return false; + if (str == endptr) + return false; + if (*str != '\0' && *endptr != '\0') + return false; + + if ((long)v < 0) + return false; + + *val = v; + return true; +} + +static inline bool +safe_atou(const char *str, unsigned int *val) +{ + return safe_atou_base(str, val, 10); +} + +static inline bool +safe_atod(const char *str, double *val) +{ + char *endptr; + double v; +#ifdef HAVE_LOCALE_H + locale_t c_locale; +#endif + size_t slen = strlen(str); + + /* We don't have a use-case where we want to accept hex for a double + * or any of the other values strtod can parse */ + for (size_t i = 0; i < slen; i++) { + char c = str[i]; + + if (isdigit(c)) + continue; + switch(c) { + case '+': + case '-': + case '.': + break; + default: + return false; + } + } + +#ifdef HAVE_LOCALE_H + /* Create a "C" locale to force strtod to use '.' as separator */ + c_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + if (c_locale == (locale_t)0) + return false; + + errno = 0; + v = strtod_l(str, &endptr, c_locale); + freelocale(c_locale); +#else + /* No locale support in provided libc, assume it already uses '.' */ + errno = 0; + v = strtod(str, &endptr); +#endif + if (errno > 0) + return false; + if (str == endptr) + return false; + if (*str != '\0' && *endptr != '\0') + return false; + if (v != 0.0 && !isnormal(v)) + return false; + + *val = v; + return true; +} + +char **strv_from_argv(int argc, char **argv); +char **strv_from_string(const char *in, const char *separator, size_t *num_elements); +char *strv_join(char **strv, const char *joiner); + +static inline void +strv_free(char **strv) { + char **s = strv; + + if (!strv) + return; + + while (*s != NULL) { + free(*s); + *s = (char*)0x1; /* detect use-after-free */ + s++; + } + + free (strv); +} + +/** + * parse a string containing a list of doubles into a double array. + * + * @param in string to parse + * @param separator string used to separate double in list e.g. "," + * @param result double array + * @param length length of double array + * @return true when parsed successfully otherwise false + */ +static inline double * +double_array_from_string(const char *in, + const char *separator, + size_t *length) +{ + double *result = NULL; + *length = 0; + + size_t nelem; + char **strv = strv_from_string(in, separator, &nelem); + if(!strv) + return result; + + double *numv = calloc(nelem, sizeof(double)); + if (!numv) + goto out; + + for (size_t idx = 0; idx < nelem; idx++) { + double val; + if (!safe_atod(strv[idx], &val)) + goto out; + + numv[idx] = val; + } + + result = numv; + numv = NULL; + *length = nelem; + +out: + strv_free(strv); + free(numv); + return result; +} + +struct key_value_str{ + char *key; + char *value; +}; + +struct key_value_double { + double key; + double value; +}; + +static inline ssize_t +kv_double_from_string(const char *string, + const char *pair_separator, + const char *kv_separator, + struct key_value_double **result_out) + +{ + struct key_value_double *result = NULL; + + if (!pair_separator || pair_separator[0] == '\0' || + !kv_separator || kv_separator[0] == '\0') + return -1; + + size_t npairs; + char **pairs = strv_from_string(string, pair_separator, &npairs); + if (!pairs || npairs == 0) + goto error; + + result = zalloc(npairs * sizeof *result); + + for (size_t idx = 0; idx < npairs; idx++) { + char *pair = pairs[idx]; + size_t nelem; + char **kv = strv_from_string(pair, kv_separator, &nelem); + double k, v; + + if (!kv || nelem != 2 || + !safe_atod(kv[0], &k) || + !safe_atod(kv[1], &v)) { + strv_free(kv); + goto error; + } + + result[idx].key = k; + result[idx].value = v; + + strv_free(kv); + } + + strv_free(pairs); + + *result_out = result; + + return npairs; + +error: + strv_free(pairs); + free(result); + return -1; +} + +/** + * Strip any of the characters in what from the beginning and end of the + * input string. + * + * @return a newly allocated string with none of "what" at the beginning or + * end of string + */ +static inline char * +strstrip(const char *input, const char *what) +{ + char *str, *last; + + str = safe_strdup(&input[strspn(input, what)]); + + last = str; + + for (char *c = str; *c != '\0'; c++) { + if (!strchr(what, *c)) + last = c + 1; + } + + *last = '\0'; + + return str; +} + +/** + * Return true if str ends in suffix, false otherwise. If the suffix is the + * empty string, strendswith() always returns false. + */ +static inline bool +strendswith(const char *str, const char *suffix) +{ + size_t slen = strlen(str); + size_t suffixlen = strlen(suffix); + size_t offset; + + if (slen == 0 || suffixlen == 0 || suffixlen > slen) + return false; + + offset = slen - suffixlen; + return strneq(&str[offset], suffix, suffixlen); +} + +static inline bool +strstartswith(const char *str, const char *prefix) +{ + size_t prefixlen = strlen(prefix); + + return prefixlen > 0 ? strneq(str, prefix, strlen(prefix)) : false; +} + +const char * +safe_basename(const char *filename); + +char * +trunkname(const char *filename); diff --git a/src/xf86-input-libinput/src/xf86libinput.c b/src/xf86-input-libinput/src/xf86libinput.c new file mode 100644 index 0000000..8d3691c --- /dev/null +++ b/src/xf86-input-libinput/src/xf86libinput.c @@ -0,0 +1,6837 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2013-2017 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "config.h" +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "bezier.h" +#include "draglock.h" +#include "libinput-properties.h" +#include "util-strings.h" + +#define TOUCHPAD_NUM_AXES 4 /* x, y, hscroll, vscroll */ +#define TABLET_NUM_BUTTONS 7 /* we need scroll buttons */ +#define TOUCH_MAX_SLOTS 15 +#define XORG_KEYCODE_OFFSET 8 +#define SCROLL_INCREMENT 15 +#define SCROLL_FACTOR_MIN 0.0001 +#define SCROLL_FACTOR_MAX 1000.0 +#define TOUCHPAD_SCROLL_DIST_MIN 10 /* in libinput pixels */ +#define TOUCHPAD_SCROLL_DIST_MAX 50 /* in libinput pixels */ + +#if HAVE_LIBINPUT_CUSTOM_ACCEL +#define CUSTOM_ACCEL_NPOINTS_MIN 2 +#define CUSTOM_ACCEL_NPOINTS_MAX 64 +#define CUSTOM_ACCEL_POINT_MIN 0 +#define CUSTOM_ACCEL_POINT_MAX 10000 +#define CUSTOM_ACCEL_STEP_MIN 0 +#define CUSTOM_ACCEL_STEP_MAX 10000 +#endif + +#define streq(a, b) (strcmp(a, b) == 0) +#define strneq(a, b, n) (strncmp(a, b, n) == 0) + +/* + libinput does not provide axis information for absolute devices, instead + it scales into the screen dimensions provided. So we set up the axes with + a fixed range, let libinput scale into that range and then the server + do the scaling it usually does. + */ +#define TOUCH_AXIS_MAX 0xffff +#define TABLET_AXIS_MAX 0xffffff +#define TABLET_PRESSURE_AXIS_MAX 2047 +#define TABLET_TILT_AXIS_MAX 64 +#define TABLET_STRIP_AXIS_MAX 4096 +#define TABLET_RING_AXIS_MAX 71 + +enum capabilities { + CAP_KEYBOARD = 0x1, + CAP_POINTER = 0x2, + CAP_TOUCH = 0x4, + CAP_TABLET = 0x8, + CAP_TABLET_TOOL = 0x10, + CAP_TABLET_PAD = 0x20, + CAP_GESTURE = 0x40, +}; + +struct xf86libinput_driver { + struct libinput *libinput; + int device_enabled_count; + void *registered_InputInfoPtr; +}; + +static struct xf86libinput_driver driver_context; + +struct xf86libinput_device { + int refcount; + int enabled_count; + uint32_t id; + struct libinput_device *device; + struct xorg_list device_list; + int server_fd; + + struct xorg_list unclaimed_tablet_tool_list; +}; + +struct xf86libinput_tablet_tool_queued_event { + struct xorg_list node; + struct libinput_event_tablet_tool *event; +}; + +struct xf86libinput_tablet_tool_event_queue { + bool need_to_queue; + struct xorg_list event_list; +}; + +struct xf86libinput_tablet_tool { + struct xorg_list node; + struct libinput_tablet_tool *tool; +}; + +#if HAVE_LIBINPUT_CUSTOM_ACCEL +struct accel_points { + double step; + double points[CUSTOM_ACCEL_NPOINTS_MAX]; + size_t npoints; +}; +#endif + +struct xf86libinput_pressure_range { + float min, max; +}; + +struct xf86libinput { + InputInfoPtr pInfo; + char *path; + uint32_t capabilities; + + struct { + struct scroll_axis { + int dist; + double fraction; + } v, h; + } scroll; + + struct { + double x; + double y; + double x_remainder; + double y_remainder; + } scale; + + BOOL has_abs; + + ValuatorMask *valuators; + ValuatorMask *valuators_unaccelerated; + + struct options { + BOOL tapping; + BOOL tap_drag; + BOOL tap_drag_lock; + enum libinput_config_tap_button_map tap_button_map; + BOOL natural_scrolling; + BOOL left_handed; + BOOL middle_emulation; + BOOL disable_while_typing; + CARD32 sendevents; + CARD32 scroll_button; /* xorg button number */ + BOOL scroll_buttonlock; + uint32_t scroll_pixel_distance; + float scroll_factor; + float speed; + float matrix[9]; + enum libinput_config_scroll_method scroll_method; + enum libinput_config_click_method click_method; +#if HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP + enum libinput_config_clickfinger_button_map clickfinger_button_map; +#endif + enum libinput_config_accel_profile accel_profile; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + struct accel_points accel_points_fallback; + struct accel_points accel_points_motion; + struct accel_points accel_points_scroll; +#endif + unsigned char btnmap[MAX_BUTTONS + 1]; + + BOOL horiz_scrolling_enabled; + BOOL hires_scrolling_enabled; + + float rotation_angle; + struct bezier_control_point pressurecurve[4]; + struct xf86libinput_pressure_range pressure_range; + struct ratio { + int x, y; + } area; + } options; + + struct draglock draglock; + + struct xf86libinput_device *shared_device; + struct xorg_list shared_device_link; + + struct libinput_tablet_tool *tablet_tool; + + bool allow_mode_group_updates; + + /* Pre-calculated pressure curve. + In the 0...TABLET_AXIS_MAX range */ + struct { + int *values; + size_t sz; + } pressurecurve; + + struct scale_factor { + double x, y; + } area_scale_factor; +}; + +enum event_handling { + EVENT_QUEUED, + EVENT_HANDLED, +}; + +static void +xf86libinput_create_subdevice(InputInfoPtr pInfo, + uint32_t capabilities, + XF86OptionPtr extra_opts); +static inline void +update_mode_prop(InputInfoPtr pInfo, + struct libinput_event_tablet_pad *event); + +static enum event_handling +xf86libinput_handle_event(struct libinput_event *event); + +static void +xf86libinput_post_tablet_motion(InputInfoPtr pInfo, + struct libinput_event_tablet_tool *event); + +static inline int +use_server_fd(const InputInfoPtr pInfo) { + return pInfo->fd > -1 && (pInfo->flags & XI86_SERVER_FD); +} + +static inline unsigned int +btn_linux2xorg(unsigned int b) +{ + unsigned int button; + + switch(b) { + case 0: button = 0; break; + case BTN_LEFT: button = 1; break; + case BTN_MIDDLE: button = 2; break; + case BTN_RIGHT: button = 3; break; + /* tablet button range */ + case BTN_STYLUS: button = 2; break; + case BTN_STYLUS2: button = 3; break; + case BTN_STYLUS3: button = 8; break; + default: + button = 8 + b - BTN_SIDE; + break; + } + + return button; +} +static inline unsigned int +btn_xorg2linux(unsigned int b) +{ + unsigned int button; + + switch(b) { + case 0: button = 0; break; + case 1: button = BTN_LEFT; break; + case 2: button = BTN_MIDDLE; break; + case 3: button = BTN_RIGHT; break; + default: + button = b - 8 + BTN_SIDE; + break; + } + + return button; +} + +static BOOL +xf86libinput_is_subdevice(InputInfoPtr pInfo) +{ + char *source; + BOOL is_subdevice; + + source = xf86CheckStrOption(pInfo->options, "_source", ""); + is_subdevice = streq(source, "_driver/libinput"); + free(source); + + return is_subdevice; +} + +static inline InputInfoPtr +xf86libinput_get_parent(InputInfoPtr pInfo) +{ + InputInfoPtr parent; + int parent_id; + + parent_id = xf86CheckIntOption(pInfo->options, "_libinput/shared-device", -1); + if (parent_id == -1) + return NULL; + + nt_list_for_each_entry(parent, xf86FirstLocalDevice(), next) { + int id = xf86CheckIntOption(parent->options, + "_libinput/shared-device", + -1); + if (id == parent_id && !xf86libinput_is_subdevice(parent)) + return parent; + } + + return NULL; +} + +static inline struct xf86libinput_device* +xf86libinput_shared_create(struct libinput_device *device) +{ + static uint32_t next_shared_device_id; + struct xf86libinput_device *shared_device; + + shared_device = calloc(1, sizeof(*shared_device)); + if (!shared_device) + return NULL; + + shared_device->device = device; + shared_device->refcount = 1; + shared_device->id = ++next_shared_device_id; + xorg_list_init(&shared_device->device_list); + xorg_list_init(&shared_device->unclaimed_tablet_tool_list); + + return shared_device; +} + +static inline struct xf86libinput_device* +xf86libinput_shared_ref(struct xf86libinput_device *shared_device) +{ + shared_device->refcount++; + + return shared_device; +} + +static inline struct xf86libinput_device* +xf86libinput_shared_unref(struct xf86libinput_device *shared_device) +{ + shared_device->refcount--; + + if (shared_device->refcount > 0) + return shared_device; + + free(shared_device); + + return NULL; +} + +static inline struct libinput_device * +xf86libinput_shared_enable(InputInfoPtr pInfo, + struct xf86libinput_device *shared_device, + const char *path) +{ + struct libinput_device *device; + struct libinput *libinput = driver_context.libinput; + + /* With systemd-logind the server requests the fd from logind, sets + * pInfo->fd and sets the "fd" option to the fd number. + * + * If we have a second device that uses the same path, the server + * checks all pInfo->major/minor for a match and returns the matched + * device's pInfo->fd. In this driver, this fd is the epollfd, not + * the actual device. This causes troubles when removing the + * device. + * + * What we need to do here is: after enabling the device the first + * time extract the real fd and store it in the shared device + * struct. The second device replaces the pInfo->options "fd" with + * the real fd we're using. + * + * When the device is unplugged, the server now correctly finds two + * devices on the real fd and releases them in order. + */ + shared_device->enabled_count++; + if (shared_device->enabled_count > 1) { + if (pInfo->flags & XI86_SERVER_FD) { + pInfo->options = xf86ReplaceIntOption(pInfo->options, + "fd", + shared_device->server_fd); + } + + return shared_device->device; + } + + device = libinput_path_add_device(libinput, path); + if (!device) + return NULL; + + libinput_device_set_user_data(device, shared_device); + shared_device->device = libinput_device_ref(device); + + if (pInfo->flags & XI86_SERVER_FD) + shared_device->server_fd = xf86CheckIntOption(pInfo->options, + "fd", + -1); + return device; +} + +static inline void +xf86libinput_shared_disable(struct xf86libinput_device *shared_device) +{ + struct libinput_device *device = shared_device->device; + + shared_device->enabled_count--; + + if (shared_device->enabled_count > 0) + return; + + if (!device) + return; + + libinput_device_set_user_data(device, NULL); + libinput_path_remove_device(device); + libinput_device_unref(device); + shared_device->device = NULL; +} + +static inline bool +xf86libinput_shared_is_enabled(struct xf86libinput_device *shared_device) +{ + return shared_device->enabled_count > 0; +} + +static inline bool +xf86libinput_set_pressurecurve(struct xf86libinput *driver_data, + const struct bezier_control_point controls[4]) +{ + if (memcmp(controls, bezier_defaults, sizeof(bezier_defaults)) == 0) { + free(driver_data->pressurecurve.values); + driver_data->pressurecurve.values = NULL; + return true; + } + + if (!driver_data->pressurecurve.values) { + int *vals = calloc(TABLET_PRESSURE_AXIS_MAX + 1, sizeof(int)); + if (!vals) + return false; + + driver_data->pressurecurve.values = vals; + driver_data->pressurecurve.sz = TABLET_PRESSURE_AXIS_MAX + 1; + } + + return cubic_bezier(controls, + driver_data->pressurecurve.values, + driver_data->pressurecurve.sz); +} + +static inline bool +xf86libinput_set_pressure_range(struct xf86libinput *driver_data, + const struct xf86libinput_pressure_range *rangeopt) +{ +#if HAVE_LIBINPUT_PRESSURE_RANGE + struct libinput_tablet_tool *tool = driver_data->tablet_tool; + + if (!tool) + return FALSE; + + return libinput_tablet_tool_config_pressure_range_is_available(tool) && + libinput_tablet_tool_config_pressure_range_set(tool, + rangeopt->min, + rangeopt->max) == LIBINPUT_CONFIG_STATUS_SUCCESS; +#else + return FALSE; +#endif +} + +static inline void +xf86libinput_set_area_ratio(struct xf86libinput *driver_data, + const struct ratio *ratio) +{ + double f; + double w, h; + + if (libinput_device_get_size(driver_data->shared_device->device, &w, &h) != 0) + return; + + driver_data->options.area = *ratio; + + if (ratio->y == 0) { + driver_data->area_scale_factor.x = 1.0; + driver_data->area_scale_factor.y = 1.0; + return; + } + + f = 1.0 * (ratio->x * h)/(ratio->y * w); + + if (f <= 1.0) { + driver_data->area_scale_factor.x = 1.0/f; + driver_data->area_scale_factor.y = 1.0; + } else { + driver_data->area_scale_factor.x = 1.0; + driver_data->area_scale_factor.y = f; + } +} + +/** + * returns true if the device has one or more of the given capabilities or + * if the device isn't a subdevice + */ +static inline bool +subdevice_has_capabilities(DeviceIntPtr dev, uint32_t capabilities) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + + if (!xf86libinput_is_subdevice(pInfo)) + return true; + + return !!(driver_data->capabilities & capabilities); +} + +static int +LibinputSetProperty(DeviceIntPtr dev, Atom atom, + XIPropertyValuePtr val, + BOOL checkonly); + +static void +LibinputInitProperty(DeviceIntPtr dev); + +static void +LibinputApplyConfigSendEvents(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (libinput_device_config_send_events_get_modes(device) != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED && + libinput_device_config_send_events_set_mode(device, + driver_data->options.sendevents) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set SendEventsMode %u\n", + driver_data->options.sendevents); +} + +static void +LibinputApplyConfigNaturalScroll(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_scroll_has_natural_scroll(device) && + libinput_device_config_scroll_set_natural_scroll_enabled(device, + driver_data->options.natural_scrolling) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set NaturalScrolling to %d\n", + driver_data->options.natural_scrolling); +} + +#if HAVE_LIBINPUT_CUSTOM_ACCEL +static bool +LibinputApplyConfigAccelCustom(struct xf86libinput *driver_data, + struct libinput_device *device) +{ + bool success = false; + struct libinput_config_accel *accel; + enum libinput_config_status status; + + accel = libinput_config_accel_create(LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM); + if (!accel) + goto out; + + /* If the step is 0, the user has not set a custom function, + thus we don't set the points */ + if (driver_data->options.accel_points_fallback.step > 0 && + driver_data->options.accel_points_fallback.npoints >= 2) { + status = libinput_config_accel_set_points(accel, + LIBINPUT_ACCEL_TYPE_FALLBACK, + driver_data->options.accel_points_fallback.step, + driver_data->options.accel_points_fallback.npoints, + driver_data->options.accel_points_fallback.points); + if (status != LIBINPUT_CONFIG_STATUS_SUCCESS) + goto out; + } + + if (driver_data->options.accel_points_motion.step > 0 && + driver_data->options.accel_points_motion.npoints >= 2) { + status = libinput_config_accel_set_points(accel, + LIBINPUT_ACCEL_TYPE_MOTION, + driver_data->options.accel_points_motion.step, + driver_data->options.accel_points_motion.npoints, + driver_data->options.accel_points_motion.points); + if (status != LIBINPUT_CONFIG_STATUS_SUCCESS) + goto out; + } + + if (driver_data->options.accel_points_scroll.step > 0 && + driver_data->options.accel_points_scroll.npoints >= 2) { + status = libinput_config_accel_set_points(accel, + LIBINPUT_ACCEL_TYPE_SCROLL, + driver_data->options.accel_points_scroll.step, + driver_data->options.accel_points_scroll.npoints, + driver_data->options.accel_points_scroll.points); + if (status != LIBINPUT_CONFIG_STATUS_SUCCESS) + goto out; + } + + status = libinput_device_config_accel_apply(device, accel); + success = status == LIBINPUT_CONFIG_STATUS_SUCCESS; +out: + libinput_config_accel_destroy(accel); + return success; +} +#endif + +static void +LibinputApplyConfigAccel(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + bool success = false; + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_accel_is_available(device) && + libinput_device_config_accel_set_speed(device, + driver_data->options.speed) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set speed %.2f\n", + driver_data->options.speed); + + if (!libinput_device_config_accel_get_profiles(device) || + driver_data->options.accel_profile == LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) + return; + + switch (driver_data->options.accel_profile) { + case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT: + case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE: + success = libinput_device_config_accel_set_profile(device, driver_data->options.accel_profile) == + LIBINPUT_CONFIG_STATUS_SUCCESS; + break; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + case LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM: + success = LibinputApplyConfigAccelCustom(driver_data, device); + break; +#endif + default: + success = false; + break; + } + + if (!success) { + const char *profile; + + switch (driver_data->options.accel_profile) { + case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE: + profile = "adaptive"; + break; + case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT: + profile = "flat"; + break; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + case LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM: + profile = "custom"; + break; +#endif + default: + profile = "unknown"; + break; + } + xf86IDrvMsg(pInfo, X_ERROR, "Failed to set profile %s\n", profile); + } +} + +static inline void +LibinputApplyConfigTap(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_tap_get_finger_count(device) > 0 && + libinput_device_config_tap_set_enabled(device, + driver_data->options.tapping) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping to %d\n", + driver_data->options.tapping); + + if (libinput_device_config_tap_get_finger_count(device) > 0 && + libinput_device_config_tap_set_button_map(device, + driver_data->options.tap_button_map) != LIBINPUT_CONFIG_STATUS_SUCCESS) { + const char *map; + + switch(driver_data->options.tap_button_map) { + case LIBINPUT_CONFIG_TAP_MAP_LRM: map = "lrm"; break; + case LIBINPUT_CONFIG_TAP_MAP_LMR: map = "lmr"; break; + default: map = "unknown"; break; + } + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping ButtonMap to %s\n", + map); + } + + if (libinput_device_config_tap_get_finger_count(device) > 0 && + libinput_device_config_tap_set_drag_lock_enabled(device, + driver_data->options.tap_drag_lock) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping DragLock to %d\n", + driver_data->options.tap_drag_lock); + + if (libinput_device_config_tap_get_finger_count(device) > 0 && + libinput_device_config_tap_set_drag_enabled(device, + driver_data->options.tap_drag) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag to %d\n", + driver_data->options.tap_drag); +} + +static void +LibinputApplyConfigCalibration(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_TOUCH|CAP_TABLET)) + return; + + if (libinput_device_config_calibration_has_matrix(device) && + libinput_device_config_calibration_set_matrix(device, + driver_data->options.matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to apply matrix: " + "%.2f %.2f %.2f %2.f %.2f %.2f %.2f %.2f %.2f\n", + driver_data->options.matrix[0], driver_data->options.matrix[1], + driver_data->options.matrix[2], driver_data->options.matrix[3], + driver_data->options.matrix[4], driver_data->options.matrix[5], + driver_data->options.matrix[6], driver_data->options.matrix[7], + driver_data->options.matrix[8]); +} + +static void +LibinputApplyConfigLeftHanded(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TABLET|CAP_TABLET_TOOL)) + return; + + if (libinput_device_config_left_handed_is_available(device) && + libinput_device_config_left_handed_set(device, + driver_data->options.left_handed) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set LeftHanded to %d\n", + driver_data->options.left_handed); +} + +static void +LibinputApplyConfigScrollMethod(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_scroll_set_method(device, + driver_data->options.scroll_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) { + const char *method; + + switch(driver_data->options.scroll_method) { + case LIBINPUT_CONFIG_SCROLL_NO_SCROLL: method = "none"; break; + case LIBINPUT_CONFIG_SCROLL_2FG: method = "twofinger"; break; + case LIBINPUT_CONFIG_SCROLL_EDGE: method = "edge"; break; + case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN: method = "button"; break; + default: + method = "unknown"; break; + } + + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set scroll to %s\n", + method); + } + + if (libinput_device_config_scroll_get_methods(device) & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) { + unsigned int scroll_button; +#if HAVE_LIBINPUT_SCROLL_BUTTON_LOCK + enum libinput_config_scroll_button_lock_state buttonlock; + + buttonlock = driver_data->options.scroll_buttonlock ? + LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED : + LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED; + + if (libinput_device_config_scroll_set_button_lock(device, buttonlock) + != LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to %s ScrollButtonLock\n", + buttonlock ? "enable" : "disable"); + } +#endif + + scroll_button = btn_xorg2linux(driver_data->options.scroll_button); + if (libinput_device_config_scroll_set_button(device, scroll_button) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set ScrollButton to %u\n", + driver_data->options.scroll_button); + + } +} + +static void +LibinputApplyConfigClickMethod(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; +#if HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP + uint32_t click_methods = libinput_device_config_click_get_methods(device); +#endif + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_click_set_method(device, + driver_data->options.click_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) { + const char *method; + + switch (driver_data->options.click_method) { + case LIBINPUT_CONFIG_CLICK_METHOD_NONE: method = "none"; break; + case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS: method = "buttonareas"; break; + case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER: method = "clickfinger"; break; + default: + method = "unknown"; break; + } + + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set click method to %s\n", + method); + } + +#if HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP + if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER && + libinput_device_config_click_set_clickfinger_button_map(device, + driver_data->options.clickfinger_button_map) != LIBINPUT_CONFIG_STATUS_SUCCESS) { + const char *map; + + switch (driver_data->options.clickfinger_button_map) { + case LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM: map = "LRM"; break; + case LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR: map = "LMR"; break; + default: + map = "unknown"; break; + } + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set clickfinger button map to %s\n", + map); + } +#endif +} + +static void +LibinputApplyConfigMiddleEmulation(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_middle_emulation_is_available(device) && + libinput_device_config_middle_emulation_set_enabled(device, + driver_data->options.middle_emulation) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set MiddleEmulation to %d\n", + driver_data->options.middle_emulation); +} + +static void +LibinputApplyConfigDisableWhileTyping(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_dwt_is_available(device) && + libinput_device_config_dwt_set_enabled(device, + driver_data->options.disable_while_typing) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set DisableWhileTyping to %d\n", + driver_data->options.disable_while_typing); +} + +static void +LibinputApplyConfigRotation(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_rotation_is_available(device) && + libinput_device_config_rotation_set_angle(device, driver_data->options.rotation_angle) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set RotationAngle to %.2f\n", + driver_data->options.rotation_angle); +} + +static void +LibinputApplyConfigPressureRange(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ +#if HAVE_LIBINPUT_PRESSURE_RANGE + InputInfoPtr pInfo = dev->public.devicePrivate; + struct libinput_tablet_tool *tool = driver_data->tablet_tool; + struct xf86libinput_pressure_range *rangeopt = &driver_data->options.pressure_range; + + if (!subdevice_has_capabilities(dev, CAP_TABLET_TOOL)) + return; + + if (tool && libinput_tablet_tool_config_pressure_range_is_available(tool) && + libinput_tablet_tool_config_pressure_range_set(tool, rangeopt->min, rangeopt->max) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set PressureRange to %.2f..%.2f\n", + rangeopt->min, rangeopt->max); +#endif +} + +static inline void +LibinputApplyConfig(DeviceIntPtr dev) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + + LibinputApplyConfigSendEvents(dev, driver_data, device); + LibinputApplyConfigNaturalScroll(dev, driver_data, device); + LibinputApplyConfigAccel(dev, driver_data, device); + LibinputApplyConfigTap(dev, driver_data, device); + LibinputApplyConfigCalibration(dev, driver_data, device); + LibinputApplyConfigLeftHanded(dev, driver_data, device); + LibinputApplyConfigScrollMethod(dev, driver_data, device); + LibinputApplyConfigClickMethod(dev, driver_data, device); + LibinputApplyConfigMiddleEmulation(dev, driver_data, device); + LibinputApplyConfigDisableWhileTyping(dev, driver_data, device); + LibinputApplyConfigRotation(dev, driver_data, device); + LibinputApplyConfigPressureRange(dev, driver_data, device); +} + +static int +xf86libinput_on(DeviceIntPtr dev) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device = driver_data->shared_device; + struct libinput *libinput = driver_context.libinput; + struct libinput_device *device; + + device = xf86libinput_shared_enable(pInfo, + shared_device, + driver_data->path); + if (!device) + return !Success; + + /* if we use server fds, overwrite the fd with the one from + libinput nonetheless, otherwise the server won't call ReadInput + for our device. This must be swapped back to the real fd in + DEVICE_OFF so systemd-logind closes the right fd */ + pInfo->fd = libinput_get_fd(libinput); + + if (driver_context.device_enabled_count == 0) { + xf86AddEnabledDevice(pInfo); + driver_context.registered_InputInfoPtr = pInfo; + } + + driver_context.device_enabled_count++; + dev->public.on = TRUE; + + LibinputApplyConfig(dev); + + return Success; +} + +static int +xf86libinput_off(DeviceIntPtr dev) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device = driver_data->shared_device; + + if (--driver_context.device_enabled_count == 0) { + xf86RemoveEnabledDevice(pInfo); + } + + if (use_server_fd(pInfo)) { + pInfo->fd = xf86SetIntOption(pInfo->options, "fd", -1); + } else { + pInfo->fd = -1; + } + + dev->public.on = FALSE; + + xf86libinput_shared_disable(shared_device); + + return Success; +} + +static void +xf86libinput_ptr_ctl(DeviceIntPtr dev, PtrCtrl *ctl) +{ +} + +static void +init_button_map(unsigned char *btnmap, size_t size) +{ + int i; + + memset(btnmap, 0, size); + for (i = 0; i < size; i++) + btnmap[i] = i; +} + +static void +init_button_labels(Atom *labels, size_t size) +{ + assert(size > 10); + + memset(labels, 0, size * sizeof(Atom)); + labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); + labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_SIDE); + labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_EXTRA); + labels[9] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_FORWARD); + labels[10] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_BACK); +} + +static void +init_axis_labels(Atom *labels, size_t size) +{ + memset(labels, 0, size * sizeof(Atom)); + labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL); + labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL); +} + +static int +xf86libinput_init_pointer(InputInfoPtr pInfo) +{ + DeviceIntPtr dev= pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + int min, max, res; + int nbuttons = 7; + int i; + + Atom btnlabels[MAX_BUTTONS]; + Atom axislabels[TOUCHPAD_NUM_AXES]; + + for (i = BTN_JOYSTICK - 1; i >= BTN_SIDE; i--) { + if (libinput_device_pointer_has_button(device, i)) { + nbuttons += i - BTN_SIDE + 1; + break; + } + } + + init_button_labels(btnlabels, ARRAY_SIZE(btnlabels)); + init_axis_labels(axislabels, ARRAY_SIZE(axislabels)); + + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, + nbuttons, + btnlabels, + xf86libinput_ptr_ctl, + GetMotionHistorySize(), + TOUCHPAD_NUM_AXES, + axislabels); + min = -1; + max = -1; + res = 0; + + xf86InitValuatorAxisStruct(dev, 0, + XIGetKnownProperty(AXIS_LABEL_PROP_REL_X), + min, max, res * 1000, 0, res * 1000, Relative); + xf86InitValuatorAxisStruct(dev, 1, + XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y), + min, max, res * 1000, 0, res * 1000, Relative); + + SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0); + SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0); + + return Success; +} + +static int +xf86libinput_init_pointer_absolute(InputInfoPtr pInfo) +{ + DeviceIntPtr dev= pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + int min, max, res; + int nbuttons = 7; + int i; + + Atom btnlabels[MAX_BUTTONS]; + Atom axislabels[TOUCHPAD_NUM_AXES]; + + for (i = BTN_BACK; i >= BTN_SIDE; i--) { + if (libinput_device_pointer_has_button(device, i)) { + nbuttons += i - BTN_SIDE + 1; + break; + } + } + + init_button_labels(btnlabels, ARRAY_SIZE(btnlabels)); + init_axis_labels(axislabels, ARRAY_SIZE(axislabels)); + + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, + nbuttons, + btnlabels, + xf86libinput_ptr_ctl, + GetMotionHistorySize(), + TOUCHPAD_NUM_AXES, + axislabels); + min = 0; + max = TOUCH_AXIS_MAX; + res = 0; + + xf86InitValuatorAxisStruct(dev, 0, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X), + min, max, res * 1000, 0, res * 1000, Absolute); + xf86InitValuatorAxisStruct(dev, 1, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y), + min, max, res * 1000, 0, res * 1000, Absolute); + + SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0); + SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0); + + driver_data->has_abs = TRUE; + + return Success; +} + +static void +xf86libinput_kbd_ctrl(DeviceIntPtr device, KeybdCtrl *ctrl) +{ +#define CAPSFLAG 1 +#define NUMFLAG 2 +#define SCROLLFLAG 4 +#define COMPOSEFLAG 8 +#define KANAFLAG 16 + static struct { int xbit, code; } bits[] = { + { CAPSFLAG, LIBINPUT_LED_CAPS_LOCK }, + { NUMFLAG, LIBINPUT_LED_NUM_LOCK }, + { SCROLLFLAG, LIBINPUT_LED_SCROLL_LOCK }, +#ifdef HAVE_LIBINPUT_COMPOSE_AND_KANA + { COMPOSEFLAG, LIBINPUT_LED_COMPOSE }, + { KANAFLAG, LIBINPUT_LED_KANA }, +#endif + { 0, 0 }, + }; + int i = 0; + enum libinput_led leds = 0; + InputInfoPtr pInfo = device->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *ldevice = driver_data->shared_device->device; + + if (!device->enabled) + return; + + while (bits[i].xbit) { + if (ctrl->leds & bits[i].xbit) + leds |= bits[i].code; + i++; + } + + libinput_device_led_update(ldevice, leds); +} + +static void +xf86libinput_init_keyboard(InputInfoPtr pInfo) +{ + DeviceIntPtr dev= pInfo->dev; + XkbRMLVOSet rmlvo = {0}; + XkbRMLVOSet defaults = {0}; + + XkbGetRulesDflts(&defaults); + + rmlvo.rules = xf86SetStrOption(pInfo->options, + "xkb_rules", + defaults.rules); + rmlvo.model = xf86SetStrOption(pInfo->options, + "xkb_model", + defaults.model); + rmlvo.layout = xf86SetStrOption(pInfo->options, + "xkb_layout", + defaults.layout); + rmlvo.variant = xf86SetStrOption(pInfo->options, + "xkb_variant", + defaults.variant); + rmlvo.options = xf86SetStrOption(pInfo->options, + "xkb_options", + defaults.options); + + InitKeyboardDeviceStruct(dev, &rmlvo, NULL, + xf86libinput_kbd_ctrl); + XkbFreeRMLVOSet(&rmlvo, FALSE); + XkbFreeRMLVOSet(&defaults, FALSE); +} + +static void +xf86libinput_init_touch(InputInfoPtr pInfo) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + int min, max, res; + Atom btnlabels[MAX_BUTTONS]; + Atom axislabels[TOUCHPAD_NUM_AXES]; + int nbuttons = 7; + int ntouches = TOUCH_MAX_SLOTS; + + init_button_labels(btnlabels, ARRAY_SIZE(btnlabels)); + init_axis_labels(axislabels, ARRAY_SIZE(axislabels)); + + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, + nbuttons, + btnlabels, + xf86libinput_ptr_ctl, + GetMotionHistorySize(), + TOUCHPAD_NUM_AXES, + axislabels); + min = 0; + max = TOUCH_AXIS_MAX; + res = 0; + + xf86InitValuatorAxisStruct(dev, 0, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_X), + min, max, res * 1000, 0, res * 1000, Absolute); + xf86InitValuatorAxisStruct(dev, 1, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y), + min, max, res * 1000, 0, res * 1000, Absolute); + + ntouches = libinput_device_touch_get_touch_count(device); + if (ntouches == 0) /* unknown - mtdev */ + ntouches = TOUCH_MAX_SLOTS; + InitTouchClassDeviceStruct(dev, ntouches, XIDirectTouch, 2); +} + +static void +xf86libinput_init_gesture(InputInfoPtr pInfo) +{ + DeviceIntPtr dev = pInfo->dev; + int ntouches = TOUCH_MAX_SLOTS; + InitGestureClassDeviceStruct(dev, ntouches); +} + +static int +xf86libinput_init_tablet_pen_or_eraser(InputInfoPtr pInfo, + struct libinput_tablet_tool *tool) +{ + DeviceIntPtr dev = pInfo->dev; + int min, max, res; + int axis; + + min = 0; + max = TABLET_PRESSURE_AXIS_MAX; + res = 0; + axis = 2; + if (libinput_tablet_tool_has_pressure(tool)) + xf86InitValuatorAxisStruct(dev, axis++, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE), + min, max, res * 1000, 0, res * 1000, Absolute); + max = TABLET_TILT_AXIS_MAX; + min = -TABLET_TILT_AXIS_MAX; + if (libinput_tablet_tool_has_tilt(tool)) { + xf86InitValuatorAxisStruct(dev, axis++, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X), + min, max, res * 1000, 0, res * 1000, Absolute); + xf86InitValuatorAxisStruct(dev, axis++, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y), + min, max, res * 1000, 0, res * 1000, Absolute); + } + + min = -TABLET_AXIS_MAX; + max = TABLET_AXIS_MAX; + if (libinput_tablet_tool_has_rotation(tool)) + xf86InitValuatorAxisStruct(dev, axis++, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ), + min, max, res * 1000, 0, res * 1000, Absolute); + return axis; +} + +static void +xf86libinput_init_tablet_airbrush(InputInfoPtr pInfo, + struct libinput_tablet_tool *tool) +{ + DeviceIntPtr dev = pInfo->dev; + int min, max, res; + int axis; + + /* first axes are shared */ + axis = xf86libinput_init_tablet_pen_or_eraser(pInfo, tool); + if (axis < 5) { + xf86IDrvMsg(pInfo, X_ERROR, "Airbrush tool has missing pressure or tilt axes\n"); + return; + } + + if (!libinput_tablet_tool_has_slider(tool)) { + xf86IDrvMsg(pInfo, X_ERROR, "Airbrush tool is missing the slider axis\n"); + return; + } + + min = -TABLET_AXIS_MAX; + max = TABLET_AXIS_MAX; + res = 0; + + xf86InitValuatorAxisStruct(dev, axis, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_THROTTLE), + min, max, res * 1000, 0, res * 1000, Absolute); +} + +static void +xf86libinput_init_tablet_mouse(InputInfoPtr pInfo, + struct libinput_tablet_tool *tool) +{ + DeviceIntPtr dev = pInfo->dev; + int min, max, res; + int axis; + + if (!libinput_tablet_tool_has_rotation(tool)) { + xf86IDrvMsg(pInfo, X_ERROR, "Mouse tool is missing the rotation axis\n"); + return; + } + + min = 0; + max = TABLET_AXIS_MAX; + res = 0; + + /* The mouse/lens tool don't have pressure, but for backwards-compat + with the xorg wacom driver we initialize the the axis anyway */ + axis = 2; + xf86InitValuatorAxisStruct(dev, axis, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE), + min, max, res * 1000, 0, res * 1000, Absolute); + + axis = 3; + min = -TABLET_AXIS_MAX; + max = TABLET_AXIS_MAX; + xf86InitValuatorAxisStruct(dev, axis, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ), + min, max, res * 1000, 0, res * 1000, Absolute); + return; +} + +static void +xf86libinput_init_tablet(InputInfoPtr pInfo) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_tablet_tool *tool; + int min, max, res; + Atom btnlabels[TABLET_NUM_BUTTONS] = {0}; + Atom axislabels[TOUCHPAD_NUM_AXES] = {0}; + int nbuttons = TABLET_NUM_BUTTONS; + int naxes = 2; + + if (driver_data->tablet_tool == NULL) { + xf86IDrvMsg(pInfo, X_WARNING, "BUG: tablet_tool is NULL\n"); + return; + } + + tool = driver_data->tablet_tool; + + if (libinput_tablet_tool_has_pressure(tool)) + naxes++; + if (libinput_tablet_tool_has_tilt(tool)) + naxes += 2; + if (libinput_tablet_tool_has_slider(tool)) + naxes++; + if (libinput_tablet_tool_has_rotation(tool)) + naxes++; + + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, + nbuttons, + btnlabels, + xf86libinput_ptr_ctl, + GetMotionHistorySize(), + naxes, + axislabels); + + min = 0; + max = TABLET_AXIS_MAX; + res = 0; + xf86InitValuatorAxisStruct(dev, 0, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X), + min, max, res * 1000, 0, res * 1000, Absolute); + xf86InitValuatorAxisStruct(dev, 1, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y), + min, max, res * 1000, 0, res * 1000, Absolute); + + switch (libinput_tablet_tool_get_type(tool)) { + case LIBINPUT_TABLET_TOOL_TYPE_PEN: + case LIBINPUT_TABLET_TOOL_TYPE_ERASER: + xf86libinput_init_tablet_pen_or_eraser(pInfo, tool); + break; + case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH: + xf86libinput_init_tablet_airbrush(pInfo, tool); + break; + case LIBINPUT_TABLET_TOOL_TYPE_MOUSE: + case LIBINPUT_TABLET_TOOL_TYPE_LENS: + xf86libinput_init_tablet_mouse(pInfo, tool); + break; + default: + xf86IDrvMsg(pInfo, X_ERROR, "Tool type not supported yet\n"); + break; + } + + InitProximityClassDeviceStruct(dev); +} + +static void +xf86libinput_init_tablet_pad(InputInfoPtr pInfo) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + int min, max, res; + Atom btnlabels[MAX_BUTTONS] = {0}; + Atom axislabels[TOUCHPAD_NUM_AXES] = {0}; + int nbuttons; + int naxes = 7; + + nbuttons = libinput_device_tablet_pad_get_num_buttons(device) + 4; + + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, + nbuttons, + btnlabels, + xf86libinput_ptr_ctl, + GetMotionHistorySize(), + naxes, + axislabels); + + /* For compat with xf86-input-wacom we init x, y, pressure, followed + * by strip x, strip y, ring, ring2*/ + min = 0; + max = TABLET_AXIS_MAX; + res = 0; + xf86InitValuatorAxisStruct(dev, 0, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X), + min, max, res * 1000, 0, res * 1000, Absolute); + xf86InitValuatorAxisStruct(dev, 1, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y), + min, max, res * 1000, 0, res * 1000, Absolute); + xf86InitValuatorAxisStruct(dev, 2, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE), + min, max, res * 1000, 0, res * 1000, Absolute); + + /* strip x */ + max = TABLET_STRIP_AXIS_MAX; + xf86InitValuatorAxisStruct(dev, 3, + None, + min, max, res * 1000, 0, res * 1000, Absolute); + /* strip y */ + xf86InitValuatorAxisStruct(dev, 4, + None, + min, max, res * 1000, 0, res * 1000, Absolute); + /* first ring */ + max = TABLET_RING_AXIS_MAX; + xf86InitValuatorAxisStruct(dev, 5, + XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL), + min, max, res * 1000, 0, res * 1000, Absolute); + /* second ring */ + xf86InitValuatorAxisStruct(dev, 6, + None, + min, max, res * 1000, 0, res * 1000, Absolute); +} + +static int +xf86libinput_init(DeviceIntPtr dev) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device = driver_data->shared_device; + struct libinput_device *device = shared_device->device; + + if (device == NULL) { + xf86IDrvMsg(pInfo, X_WARNING, "BUG: xf86libinput_init() device is NULL\n"); + return !Success; + } + + dev->public.on = FALSE; + + if (driver_data->capabilities & CAP_KEYBOARD) + xf86libinput_init_keyboard(pInfo); + if (driver_data->capabilities & CAP_POINTER) { + if (libinput_device_config_calibration_has_matrix(device) && + !libinput_device_config_accel_is_available(device)) + xf86libinput_init_pointer_absolute(pInfo); + else + xf86libinput_init_pointer(pInfo); + } + if (driver_data->capabilities & CAP_TOUCH) + xf86libinput_init_touch(pInfo); + if (driver_data->capabilities & CAP_GESTURE) + xf86libinput_init_gesture(pInfo); + if (driver_data->capabilities & CAP_TABLET_TOOL) + xf86libinput_init_tablet(pInfo); + if (driver_data->capabilities & CAP_TABLET_PAD) + xf86libinput_init_tablet_pad(pInfo); + + LibinputApplyConfig(dev); + LibinputInitProperty(dev); + XIRegisterPropertyHandler(dev, LibinputSetProperty, NULL, NULL); + + /* If we have a device but it's not yet enabled it's the + * already-removed device from PreInit. Drop the ref to clean up, + * we'll get a new libinput_device during DEVICE_ON when we re-add + * it. */ + if (!xf86libinput_shared_is_enabled(shared_device)) { + libinput_device_unref(device); + shared_device->device = NULL; + } + + return 0; +} + +static bool +is_libinput_device(InputInfoPtr pInfo) +{ + char *driver; + BOOL rc; + + driver = xf86CheckStrOption(pInfo->options, "driver", ""); + rc = streq(driver, "libinput"); + free(driver); + + return rc; +} + +static void +swap_registered_device(InputInfoPtr pInfo) +{ + InputInfoPtr next; + + if (pInfo != driver_context.registered_InputInfoPtr) + return; + + next = xf86FirstLocalDevice(); + while (next && (next == pInfo || !is_libinput_device(next))) + next = next->next; + + input_lock(); + xf86RemoveEnabledDevice(pInfo); + if (next) + xf86AddEnabledDevice(next); + driver_context.registered_InputInfoPtr = next; + input_unlock(); +} + +static void +xf86libinput_destroy(DeviceIntPtr dev) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device = driver_data->shared_device; + + /* If the device being destroyed is the one we used for + * xf86AddEnabledDevice(), we need to swap it out for one that is + * still live. xf86AddEnabledDevice() buffers some data and once the + * deletes pInfo (when DEVICE_OFF completes) the thread will keep + * calling that struct's read_input because we never removed it. + * Avoid this by removing ours and substituting one that's still + * valid, the fd is the same anyway (libinput's epollfd). + */ + if (driver_context.device_enabled_count > 0) + swap_registered_device(pInfo); + + xorg_list_del(&driver_data->shared_device_link); + + if (driver_data->tablet_tool) + libinput_tablet_tool_unref(driver_data->tablet_tool); + + xf86libinput_shared_unref(shared_device); +} + +static int +xf86libinput_device_control(DeviceIntPtr dev, int mode) +{ + int rc = BadValue; + + switch(mode) { + case DEVICE_INIT: + rc = xf86libinput_init(dev); + break; + case DEVICE_ON: + rc = xf86libinput_on(dev); + break; + case DEVICE_OFF: + rc = xf86libinput_off(dev); + break; + case DEVICE_CLOSE: + xf86libinput_destroy(dev); + rc = Success; + break; + } + + return rc; +} + +static void +xf86libinput_handle_motion(InputInfoPtr pInfo, struct libinput_event_pointer *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + ValuatorMask *mask = driver_data->valuators; + double x, y; + + if ((driver_data->capabilities & CAP_POINTER) == 0) + return; + + x = libinput_event_pointer_get_dx(event); + y = libinput_event_pointer_get_dy(event); + + valuator_mask_zero(mask); + + { + double ux, uy; + + ux = libinput_event_pointer_get_dx_unaccelerated(event); + uy = libinput_event_pointer_get_dy_unaccelerated(event); + + valuator_mask_set_unaccelerated(mask, 0, x, ux); + valuator_mask_set_unaccelerated(mask, 1, y, uy); + } + xf86PostMotionEventM(dev, Relative, mask); +} + +static void +xf86libinput_handle_absmotion(InputInfoPtr pInfo, struct libinput_event_pointer *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + ValuatorMask *mask = driver_data->valuators; + double x, y; + + if (!driver_data->has_abs) { + xf86IDrvMsg(pInfo, X_ERROR, + "Discarding absolute event from relative device. " + "Please file a bug\n"); + return; + } + + if ((driver_data->capabilities & CAP_POINTER) == 0) + return; + + x = libinput_event_pointer_get_absolute_x_transformed(event, TOUCH_AXIS_MAX + 1); + y = libinput_event_pointer_get_absolute_y_transformed(event, TOUCH_AXIS_MAX + 1); + + valuator_mask_zero(mask); + valuator_mask_set_double(mask, 0, x); + valuator_mask_set_double(mask, 1, y); + + xf86PostMotionEventM(dev, Absolute, mask); +} + +static void +xf86libinput_handle_button(InputInfoPtr pInfo, struct libinput_event_pointer *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + int button; + int is_press; + + if ((driver_data->capabilities & CAP_POINTER) == 0) + return; + + button = btn_linux2xorg(libinput_event_pointer_get_button(event)); + is_press = (libinput_event_pointer_get_button_state(event) == LIBINPUT_BUTTON_STATE_PRESSED); + + if (draglock_get_mode(&driver_data->draglock) != DRAGLOCK_DISABLED) + draglock_filter_button(&driver_data->draglock, &button, &is_press); + + if (button && button < 256) + xf86PostButtonEvent(dev, Relative, button, is_press, 0, 0); +} + +static void +xf86libinput_handle_key(InputInfoPtr pInfo, struct libinput_event_keyboard *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + int is_press; + int key = libinput_event_keyboard_get_key(event); + + if ((driver_data->capabilities & CAP_KEYBOARD) == 0) + return; + + /* keycodes > 256 that have a historical mapping in xkeyboard-config + * plus Nokia MSM8909 keypad evdev keycodes > 247 mapped into X11 8-bit range */ + switch (key) { + case KEY_TOUCHPAD_TOGGLE: key = KEY_F21; break; + case KEY_TOUCHPAD_ON: key = KEY_F22; break; + case KEY_TOUCHPAD_OFF: key = KEY_F23; break; + case KEY_MICMUTE: key = KEY_F20; break; + case 696: /* KEY_KBD_LCD_MENU1 (Left Softkey) */ key = KEY_COMPOSE; break; + case 697: /* KEY_KBD_LCD_MENU2 (Right Softkey) */ key = KEY_BACK; break; + case 445: /* KEY_PICKUP_PHONE (Call button) */ key = KEY_PHONE; break; + case 352: /* KEY_OK (Center D-pad OK) */ key = KEY_ENTER; break; + case 522: /* KEY_NUMERIC_STAR (*) */ key = KEY_KPASTERISK; break; + case 523: /* KEY_NUMERIC_POUND (#) */ key = KEY_KPSLASH; break; + } + + key += XORG_KEYCODE_OFFSET; + + is_press = (libinput_event_keyboard_get_key_state(event) == LIBINPUT_KEY_STATE_PRESSED); + xf86PostKeyboardEvent(dev, key, is_press); +} + +/* + * The scroll fraction is the value we divide the scroll dist with to + * accommodate for wheels with a small click angle. On these devices, + * multiple clicks of small angle accumulate to the XI 2.1 scroll distance. + * This gives us smooth scrolling on those wheels for small movements, the + * legacy button events are generated whenever the full distance is reached. + * e.g. a 2 degree click angle requires 8 clicks before a legacy event is + * sent, but each of those clicks will send XI2.1 smooth scroll data for + * compatible clients. + * + * Starting with kernel v5.0 we should get REL_WHEEL_HI_RES from those + * devices for the fine-grained scrolling and REL_WHEEL for the normal one, + * so the use-case above shouldn't matter anymore. + */ +static inline double +guess_wheel_scroll_value(struct xf86libinput *driver_data, + struct libinput_event_pointer *event, + enum libinput_pointer_axis axis) +{ + struct scroll_axis *s; + double f; + double angle; + int discrete; + + switch (axis) { + case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL: + s = &driver_data->scroll.h; + break; + case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: + s = &driver_data->scroll.v; + break; + default: + return 0.0; + } + + angle = libinput_event_pointer_get_axis_value(event, axis); + discrete = libinput_event_pointer_get_axis_value_discrete(event, axis); + + /* We only need to guess the fraction on the first set of + * scroll events until a discrete value arrives. Once known, we + * re-use the fraction until the device goes away. + */ + if (s->fraction != 0.0) + goto out; + + /* if we get a discrete of 0, assume REL_WHEEL_HI_RES exists and + * normal scroll events are sent correctly, so skip all the + * guesswork. + */ + if (discrete == 0) { + s->fraction = 1.0; + goto out; + } + + /* Calculate the angle per single scroll event */ + angle /= discrete; + + /* We only do magic for click angles smaller than 10 degrees */ + if (angle >= 10) { + s->fraction = 1.0; + goto out; + } + + /* Figure out something that gets close to 15 degrees (the general + * wheel default) with a number of clicks. This formula gives us + * between 12 and and 20 degrees for the range of 1-10. See + * https://bugs.freedesktop.org/attachment.cgi?id=128256 for a + * graph. + */ + f = round(15.0/angle); + + s->fraction = f; + +out: + return s->dist/s->fraction * discrete; +} + +#if HAVE_LIBINPUT_AXIS_VALUE_V120 +static inline double +get_wheel_120_value(struct xf86libinput *driver_data, + struct libinput_event_pointer *event, + enum libinput_pointer_axis axis) +{ + struct scroll_axis *s; + double angle; + + switch (axis) { + case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL: + s = &driver_data->scroll.h; + break; + case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: + s = &driver_data->scroll.v; + break; + default: + return 0.0; + } + + angle = libinput_event_pointer_get_scroll_value_v120(event, axis); + return s->dist * angle/120; +} +#endif + +static inline double +get_wheel_scroll_value(struct xf86libinput *driver_data, + struct libinput_event_pointer *event, + enum libinput_pointer_axis axis) +{ +#if HAVE_LIBINPUT_AXIS_VALUE_V120 + if (driver_data->options.hires_scrolling_enabled) + return get_wheel_120_value(driver_data, event, axis); +#endif + return guess_wheel_scroll_value(driver_data, event, axis); +} + +static inline double +get_finger_or_continuous_scroll_value(struct xf86libinput *driver_data, + struct libinput_event_pointer *event, + enum libinput_pointer_axis axis) +{ +#if HAVE_LIBINPUT_AXIS_VALUE_V120 + if (driver_data->options.hires_scrolling_enabled) + return libinput_event_pointer_get_scroll_value(event, axis); +#endif + return libinput_event_pointer_get_axis_value(event, axis); +} + +static inline bool +calculate_axis_value(struct xf86libinput *driver_data, + enum libinput_pointer_axis axis, + struct libinput_event_pointer *event, + enum libinput_pointer_axis_source source, + double *value_out) +{ + double value; + + if (!libinput_event_pointer_has_axis(event, axis)) + return false; + + /* Event may be LIBINPUT_POINTER_AXIS or + * LIBINPUT_EVENT_POINTER_SCROLL_{WHEEL|FINGER|CONTINUOUS}, depending + * on the libinput version. + * + * libinput guarantees the axis source is set for the second set of + * events too but we can switch to the event type once we ditch + * libinput < 1.19 support. + */ + if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) { + value = get_wheel_scroll_value(driver_data, event, axis); + } else { + double dist = driver_data->options.scroll_pixel_distance; + assert(dist != 0.0); + + value = get_finger_or_continuous_scroll_value(driver_data, + event, + axis); + + /* We need to scale this value into our scroll increment range + * because that one is constant for the lifetime of the + * device. The user may change the ScrollPixelDistance + * though, so where we have a dist of 10 but an increment of + * 15, we need to scale from 0..10 into 0..15. + * + * We now switched to vdist of 120, so make this + * proportionate - 120/15 is 8. + */ + value = value/dist * SCROLL_INCREMENT * 8; + } + + value *= driver_data->options.scroll_factor; + *value_out = value; + + return true; +} + +static void +xf86libinput_handle_axis(InputInfoPtr pInfo, + struct libinput_event *e, + enum libinput_pointer_axis_source source) +{ + struct libinput_event_pointer *event; + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + ValuatorMask *mask = driver_data->valuators; + double value; + + if ((driver_data->capabilities & CAP_POINTER) == 0) + return; + + valuator_mask_zero(mask); + + event = libinput_event_get_pointer_event(e); + if (calculate_axis_value(driver_data, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, + event, + source, + &value)) + valuator_mask_set_double(mask, 3, value); + + if (!driver_data->options.horiz_scrolling_enabled) + goto out; + + if (calculate_axis_value(driver_data, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, + event, + source, + &value)) + valuator_mask_set_double(mask, 2, value); + + if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL && + !valuator_mask_isset(mask, 2) && + !valuator_mask_isset(mask, 3)) + return; + +out: + xf86PostMotionEventM(dev, Relative, mask); +} + +static void +xf86libinput_handle_touch(InputInfoPtr pInfo, + struct libinput_event_touch *event, + enum libinput_event_type event_type) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + int type; + int slot; + ValuatorMask *m = driver_data->valuators; + double val; + + /* libinput doesn't give us hw touch ids which X expects, so + emulate them here */ + static unsigned int next_touchid; + static unsigned int touchids[TOUCH_MAX_SLOTS] = {0}; + + if ((driver_data->capabilities & CAP_TOUCH) == 0) + return; + + slot = libinput_event_touch_get_seat_slot(event); + + switch (event_type) { + case LIBINPUT_EVENT_TOUCH_DOWN: + type = XI_TouchBegin; + touchids[slot] = next_touchid++; + break; + case LIBINPUT_EVENT_TOUCH_UP: + case LIBINPUT_EVENT_TOUCH_CANCEL: + type = XI_TouchEnd; + break; + case LIBINPUT_EVENT_TOUCH_MOTION: + type = XI_TouchUpdate; + break; + default: + return; + } + + valuator_mask_zero(m); + + if (type != XI_TouchEnd) { + val = libinput_event_touch_get_x_transformed(event, TOUCH_AXIS_MAX); + valuator_mask_set_double(m, 0, val); + + val = libinput_event_touch_get_y_transformed(event, TOUCH_AXIS_MAX); + valuator_mask_set_double(m, 1, val); + } + + xf86PostTouchEvent(dev, touchids[slot], type, 0, m); +} + +static void +xf86libinput_handle_gesture_swipe(InputInfoPtr pInfo, + struct libinput_event_gesture *event, + enum libinput_event_type event_type) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + int type; + uint32_t flags = 0; + + if ((driver_data->capabilities & CAP_GESTURE) == 0) + return; + + switch (event_type) { + case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: + type = XI_GestureSwipeBegin; + break; + case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE: + type = XI_GestureSwipeUpdate; + break; + case LIBINPUT_EVENT_GESTURE_SWIPE_END: + type = XI_GestureSwipeEnd; + if (libinput_event_gesture_get_cancelled(event)) + flags |= XIGestureSwipeEventCancelled; + break; + default: + return; + } + + xf86PostGestureSwipeEvent(dev, type, + libinput_event_gesture_get_finger_count(event), + flags, + libinput_event_gesture_get_dx(event), + libinput_event_gesture_get_dy(event), + libinput_event_gesture_get_dx_unaccelerated(event), + libinput_event_gesture_get_dy_unaccelerated(event)); +} + +static void +xf86libinput_handle_gesture_pinch(InputInfoPtr pInfo, + struct libinput_event_gesture *event, + enum libinput_event_type event_type) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + int type; + uint32_t flags = 0; + + if ((driver_data->capabilities & CAP_GESTURE) == 0) + return; + + switch (event_type) { + case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN: + type = XI_GesturePinchBegin; + break; + case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: + type = XI_GesturePinchUpdate; + break; + case LIBINPUT_EVENT_GESTURE_PINCH_END: + type = XI_GesturePinchEnd; + if (libinput_event_gesture_get_cancelled(event)) + flags |= XIGesturePinchEventCancelled; + break; + default: + return; + } + + xf86PostGesturePinchEvent(dev, type, + libinput_event_gesture_get_finger_count(event), + flags, + libinput_event_gesture_get_dx(event), + libinput_event_gesture_get_dy(event), + libinput_event_gesture_get_dx_unaccelerated(event), + libinput_event_gesture_get_dy_unaccelerated(event), + libinput_event_gesture_get_scale(event), + libinput_event_gesture_get_angle_delta(event)); +} + +static InputInfoPtr +xf86libinput_pick_device(struct xf86libinput_device *shared_device, + struct libinput_event *event) +{ + struct xf86libinput *driver_data; + uint32_t needed_cap; + enum libinput_event_type type = libinput_event_get_type(event); + + if (shared_device == NULL) + return NULL; + + switch(type) { + case LIBINPUT_EVENT_KEYBOARD_KEY: + needed_cap = CAP_KEYBOARD; + break; + case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: + needed_cap = CAP_TABLET; + break; + case LIBINPUT_EVENT_TABLET_TOOL_BUTTON: + case LIBINPUT_EVENT_TABLET_TOOL_AXIS: + case LIBINPUT_EVENT_TABLET_TOOL_TIP: + needed_cap = CAP_TABLET_TOOL; + break; + default: + needed_cap = ~CAP_KEYBOARD; + break; + } + + xorg_list_for_each_entry(driver_data, + &shared_device->device_list, + shared_device_link) { + if (driver_data->capabilities & needed_cap) { + struct libinput_tablet_tool *tool; + + if (needed_cap != CAP_TABLET_TOOL) + return driver_data->pInfo; + + tool = libinput_event_tablet_tool_get_tool( + libinput_event_get_tablet_tool_event(event)); + if (libinput_tablet_tool_get_serial(driver_data->tablet_tool) == + libinput_tablet_tool_get_serial(tool) && + libinput_tablet_tool_get_tool_id(driver_data->tablet_tool) == + libinput_tablet_tool_get_tool_id(tool) && + libinput_tablet_tool_get_type(driver_data->tablet_tool) == + libinput_tablet_tool_get_type(tool)) + return driver_data->pInfo; + } + } + + return NULL; +} + +static void +xf86libinput_tool_destroy_queued_event(struct xf86libinput_tablet_tool_queued_event *qe) +{ + struct libinput_event *e; + + e = libinput_event_tablet_tool_get_base_event(qe->event); + libinput_event_destroy(e); + xorg_list_del(&qe->node); + free(qe); +} + +static void +xf86libinput_tool_replay_events(struct xf86libinput_tablet_tool_event_queue *queue) +{ + struct xf86libinput_tablet_tool_queued_event *qe, *tmp; + + xorg_list_for_each_entry_safe(qe, tmp, &queue->event_list, node) { + struct libinput_event *e; + + e = libinput_event_tablet_tool_get_base_event(qe->event); + xf86libinput_handle_event(e); + xf86libinput_tool_destroy_queued_event(qe); + } +} + +static bool +xf86libinput_tool_queue_event(struct libinput_event_tablet_tool *event) +{ + struct libinput_event *e; + struct libinput_tablet_tool *tool; + struct xf86libinput_tablet_tool_event_queue *queue; + struct xf86libinput_tablet_tool_queued_event *qe; + + tool = libinput_event_tablet_tool_get_tool(event); + if (!tool) + return true; + + queue = libinput_tablet_tool_get_user_data(tool); + if (!queue) + return false; + + if (!queue->need_to_queue) { + if (!xorg_list_is_empty(&queue->event_list)) { + libinput_tablet_tool_set_user_data(tool, NULL); + xf86libinput_tool_replay_events(queue); + free(queue); + } + + return false; + } + + /* We got the prox out while still queuing, just ditch the whole + * series of events and the event queue with it. */ + if (libinput_event_tablet_tool_get_proximity_state(event) == + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) { + struct xf86libinput_tablet_tool_queued_event *tmp; + + xorg_list_for_each_entry_safe(qe, tmp, &queue->event_list, node) + xf86libinput_tool_destroy_queued_event(qe); + + libinput_tablet_tool_set_user_data(tool, NULL); + free(queue); + + /* we destroy the event here but return true + * to make sure the event looks like it got queued and the + * caller doesn't destroy it for us + */ + e = libinput_event_tablet_tool_get_base_event(event); + libinput_event_destroy(e); + return true; + } + + qe = calloc(1, sizeof(*qe)); + if (!qe) { + e = libinput_event_tablet_tool_get_base_event(event); + libinput_event_destroy(e); + return true; + } + + qe->event = event; + xorg_list_append(&qe->node, &queue->event_list); + + return true; +} + +static enum event_handling +xf86libinput_handle_tablet_tip(InputInfoPtr pInfo, + struct libinput_event_tablet_tool *event) +{ + DeviceIntPtr pDev = pInfo->dev; + enum libinput_tablet_tool_tip_state state; + const BOOL is_absolute = TRUE; + + if (xf86libinput_tool_queue_event(event)) + return EVENT_QUEUED; + + xf86libinput_post_tablet_motion(pDev->public.devicePrivate, event); + + state = libinput_event_tablet_tool_get_tip_state(event); + + xf86PostButtonEventP(pInfo->dev, + is_absolute, 1, + state == LIBINPUT_TABLET_TOOL_TIP_DOWN ? 1 : 0, + 0, 0, NULL); + + return EVENT_HANDLED; +} + +static enum event_handling +xf86libinput_handle_tablet_button(InputInfoPtr pInfo, + struct libinput_event_tablet_tool *event) +{ + enum libinput_button_state state; + uint32_t button, b; + + if (xf86libinput_tool_queue_event(event)) + return EVENT_QUEUED; + + button = libinput_event_tablet_tool_get_button(event); + state = libinput_event_tablet_tool_get_button_state(event); + + b = btn_linux2xorg(button); + + xf86PostButtonEventP(pInfo->dev, + TRUE, + b, + state == LIBINPUT_BUTTON_STATE_PRESSED ? 1 : 0, + 0, 0, NULL); + + return EVENT_HANDLED; +} + +static void +xf86libinput_apply_area(InputInfoPtr pInfo, double *x, double *y) +{ + struct xf86libinput *driver_data = pInfo->private; + const struct scale_factor *f = &driver_data->area_scale_factor; + double sx, sy; + + if (driver_data->options.area.x == 0) + return; + + /* In left-handed mode, libinput already gives us transformed + * coordinates, so we can clip the same way. */ + + sx = min(*x * f->x, TABLET_AXIS_MAX); + sy = min(*y * f->y, TABLET_AXIS_MAX); + + *x = sx; + *y = sy; +} + +static void +xf86libinput_post_tablet_motion(InputInfoPtr pInfo, + struct libinput_event_tablet_tool *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + ValuatorMask *mask = driver_data->valuators; + struct libinput_tablet_tool *tool; + double value; + double x, y; + + x = libinput_event_tablet_tool_get_x_transformed(event, + TABLET_AXIS_MAX); + y = libinput_event_tablet_tool_get_y_transformed(event, + TABLET_AXIS_MAX); + xf86libinput_apply_area(pInfo, &x, &y); + valuator_mask_set_double(mask, 0, x); + valuator_mask_set_double(mask, 1, y); + + tool = libinput_event_tablet_tool_get_tool(event); + + if (libinput_tablet_tool_has_pressure(tool)) { + value = TABLET_PRESSURE_AXIS_MAX * libinput_event_tablet_tool_get_pressure(event); + if (driver_data->pressurecurve.values) + value = driver_data->pressurecurve.values[(int)value]; + valuator_mask_set_double(mask, 2, value); + } + + if (libinput_tablet_tool_has_tilt(tool)) { + value = libinput_event_tablet_tool_get_tilt_x(event); + valuator_mask_set_double(mask, 3, value); + + value = libinput_event_tablet_tool_get_tilt_y(event); + valuator_mask_set_double(mask, 4, value); + } + + if (libinput_tablet_tool_has_slider(tool)) { + value = libinput_event_tablet_tool_get_slider_position(event); + value *= TABLET_AXIS_MAX; + valuator_mask_set_double(mask, 5, value); + } + + if (libinput_tablet_tool_has_rotation(tool)) { + int valuator; + + value = libinput_event_tablet_tool_get_rotation(event); + value *= TABLET_AXIS_MAX; + + switch (libinput_tablet_tool_get_type(tool)) { + case LIBINPUT_TABLET_TOOL_TYPE_PEN: + case LIBINPUT_TABLET_TOOL_TYPE_ERASER: + valuator = 5; + break; + case LIBINPUT_TABLET_TOOL_TYPE_MOUSE: + case LIBINPUT_TABLET_TOOL_TYPE_LENS: + valuator = 3; + break; + default: + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid rotation axis on tool\n"); + return; + } + + valuator_mask_set_double(mask, valuator, value); + } + + xf86PostMotionEventM(dev, Absolute, mask); +} + +static enum event_handling +xf86libinput_handle_tablet_axis(InputInfoPtr pInfo, + struct libinput_event_tablet_tool *event) +{ + if (xf86libinput_tool_queue_event(event)) + return EVENT_QUEUED; + + xf86libinput_post_tablet_motion(pInfo, event); + + return EVENT_HANDLED; +} + +static inline const char * +tool_type_to_str(enum libinput_tablet_tool_type type) +{ + const char *str; + + switch (type) { + case LIBINPUT_TABLET_TOOL_TYPE_PEN: str = "Pen"; break; + case LIBINPUT_TABLET_TOOL_TYPE_BRUSH: str = "Brush"; break; + case LIBINPUT_TABLET_TOOL_TYPE_PENCIL: str = "Pencil"; break; + case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH: str = "Airbrush"; break; + case LIBINPUT_TABLET_TOOL_TYPE_ERASER: str = "Eraser"; break; + case LIBINPUT_TABLET_TOOL_TYPE_MOUSE: str = "Mouse"; break; + case LIBINPUT_TABLET_TOOL_TYPE_LENS: str = "Lens"; break; + default: + str = "unknown tool"; + break; + } + + return str; +} + +static inline void +xf86libinput_create_tool_subdevice(InputInfoPtr pInfo, + struct libinput_event_tablet_tool *event) +{ + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device = driver_data->shared_device; + struct xf86libinput_tablet_tool *t; + struct xf86libinput_tablet_tool_event_queue *queue; + struct libinput_tablet_tool *tool; + enum libinput_tablet_tool_type tool_type; + uint64_t serial, tool_id; + XF86OptionPtr options = NULL; + char name[64]; + + t = calloc(1, sizeof *t); + if (!t) + return; + + queue = calloc(1, sizeof(*queue)); + if (!queue) { + free(t); + return; + } + queue->need_to_queue = true; + xorg_list_init(&queue->event_list); + + tool = libinput_event_tablet_tool_get_tool(event); + serial = libinput_tablet_tool_get_serial(tool); + tool_id = libinput_tablet_tool_get_tool_id(tool); + tool_type = libinput_tablet_tool_get_type(tool); + + t->tool = libinput_tablet_tool_ref(tool); + xorg_list_append(&t->node, &shared_device->unclaimed_tablet_tool_list); + + options = xf86ReplaceIntOption(options, "_libinput/tablet-tool-serial", serial); + options = xf86ReplaceIntOption(options, "_libinput/tablet-tool-id", tool_id); + options = xf86ReplaceIntOption(options, "_libinput/tablet-tool-type", tool_type); + /* Convert the name to " (serial number)" */ + if (snprintf(name, + sizeof(name), + "%s %s (%#x)", + pInfo->name, + tool_type_to_str(libinput_tablet_tool_get_type(tool)), + (uint32_t)serial) > strlen(pInfo->name)) + options = xf86ReplaceStrOption(options, "Name", name); + + libinput_tablet_tool_set_user_data(tool, queue); + xf86libinput_tool_queue_event(event); + + xf86libinput_create_subdevice(pInfo, CAP_TABLET_TOOL, options); +} + +static inline DeviceIntPtr +xf86libinput_find_device_for_tool(InputInfoPtr pInfo, + struct libinput_tablet_tool *tool) +{ + struct xf86libinput *dev; + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device = driver_data->shared_device; + uint64_t serial = libinput_tablet_tool_get_serial(tool); + uint64_t tool_id = libinput_tablet_tool_get_tool_id(tool); + enum libinput_tablet_tool_type tool_type = libinput_tablet_tool_get_type(tool); + + xorg_list_for_each_entry(dev, + &shared_device->device_list, + shared_device_link) { + if (dev->tablet_tool && + libinput_tablet_tool_get_serial(dev->tablet_tool) == serial && + libinput_tablet_tool_get_tool_id(dev->tablet_tool) == tool_id && + libinput_tablet_tool_get_type(dev->tablet_tool) == tool_type) { + return dev->pInfo->dev; + } + } + + return NULL; +} + +static enum event_handling +xf86libinput_handle_tablet_proximity(InputInfoPtr pInfo, + struct libinput_event_tablet_tool *event) +{ + struct xf86libinput *driver_data = pInfo->private; + struct libinput_tablet_tool *tool; + DeviceIntPtr pDev; + ValuatorMask *mask = driver_data->valuators; + double x, y; + BOOL in_prox; + + tool = libinput_event_tablet_tool_get_tool(event); + pDev = xf86libinput_find_device_for_tool(pInfo, tool); + + in_prox = libinput_event_tablet_tool_get_proximity_state(event) == + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN; + + if (pDev == NULL && in_prox) { + xf86libinput_create_tool_subdevice(pInfo, event); + return EVENT_QUEUED; + } + + if (xf86libinput_tool_queue_event(event)) + return EVENT_QUEUED; + + if (pDev == NULL) { + xf86IDrvMsg(pInfo, X_WARNING, "BUG: xf86libinput_handle_tablet_proximity() pDev is NULL\n"); + return EVENT_HANDLED; + } + + x = libinput_event_tablet_tool_get_x_transformed(event, TABLET_AXIS_MAX); + y = libinput_event_tablet_tool_get_y_transformed(event, TABLET_AXIS_MAX); + valuator_mask_set_double(mask, 0, x); + valuator_mask_set_double(mask, 1, y); + + xf86PostProximityEventM(pDev, in_prox, mask); + + /* We have to send an extra motion event after proximity to make + * sure the client got the updated x/y coordinates, especially if + * they don't handle proximity events (XI2). + */ + if (in_prox) + xf86libinput_post_tablet_motion(pDev->public.devicePrivate, event); + + return EVENT_HANDLED; +} + +static void +xf86libinput_handle_tablet_pad_button(InputInfoPtr pInfo, + struct libinput_event_tablet_pad *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_tablet_pad_mode_group *group; + int button, b; + int is_press; + + if ((driver_data->capabilities & CAP_TABLET_PAD) == 0) + return; + + b = libinput_event_tablet_pad_get_button_number(event); + button = 1 + b; + if (button > 3) + button += 4; /* offset by scroll buttons */ + is_press = (libinput_event_tablet_pad_get_button_state(event) == LIBINPUT_BUTTON_STATE_PRESSED); + + xf86PostButtonEvent(dev, Relative, button, is_press, 0, 0); + + group = libinput_event_tablet_pad_get_mode_group(event); + if (libinput_tablet_pad_mode_group_button_is_toggle(group, b)) + update_mode_prop(pInfo, event); +} + +static void +xf86libinput_handle_tablet_pad_strip(InputInfoPtr pInfo, + struct libinput_event_tablet_pad *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + ValuatorMask *mask = driver_data->valuators; + double value; + int axis = 3; + int v; + + if ((driver_data->capabilities & CAP_TABLET_PAD) == 0) + return; + + /* this isn't compatible with the wacom driver which just forwards + * the values and lets the clients handle them with log2. */ + axis += libinput_event_tablet_pad_get_strip_number(event); + value = libinput_event_tablet_pad_get_strip_position(event); + v = TABLET_STRIP_AXIS_MAX * value; + + valuator_mask_zero(mask); + valuator_mask_set(mask, axis, v); + + xf86PostMotionEventM(dev, Absolute, mask); +} + +static void +xf86libinput_handle_tablet_pad_ring(InputInfoPtr pInfo, + struct libinput_event_tablet_pad *event) +{ + DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; + ValuatorMask *mask = driver_data->valuators; + double value; + int axis = 5; + int v; + + if ((driver_data->capabilities & CAP_TABLET_PAD) == 0) + return; + + axis += libinput_event_tablet_pad_get_ring_number(event); + value = libinput_event_tablet_pad_get_ring_position(event)/360.0; + v = TABLET_RING_AXIS_MAX * value; + + valuator_mask_zero(mask); + valuator_mask_set(mask, axis, v); + + xf86PostMotionEventM(dev, Absolute, mask); +} + +static enum event_handling +xf86libinput_handle_event(struct libinput_event *event) +{ + struct libinput_device *device; + enum libinput_event_type type; + InputInfoPtr pInfo; + struct xf86libinput *driver_data; + enum event_handling event_handling = EVENT_HANDLED; + + type = libinput_event_get_type(event); + device = libinput_event_get_device(event); + pInfo = xf86libinput_pick_device(libinput_device_get_user_data(device), + event); + + if (!pInfo || !pInfo->dev->public.on) + goto out; + + driver_data = pInfo->private; + + switch (type) { + case LIBINPUT_EVENT_NONE: + case LIBINPUT_EVENT_DEVICE_ADDED: + case LIBINPUT_EVENT_DEVICE_REMOVED: + break; + case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: + xf86libinput_handle_absmotion(pInfo, + libinput_event_get_pointer_event(event)); + break; + + case LIBINPUT_EVENT_POINTER_MOTION: + xf86libinput_handle_motion(pInfo, + libinput_event_get_pointer_event(event)); + break; + case LIBINPUT_EVENT_POINTER_BUTTON: + xf86libinput_handle_button(pInfo, + libinput_event_get_pointer_event(event)); + break; + case LIBINPUT_EVENT_KEYBOARD_KEY: + xf86libinput_handle_key(pInfo, + libinput_event_get_keyboard_event(event)); + break; + case LIBINPUT_EVENT_POINTER_AXIS: +#if HAVE_LIBINPUT_AXIS_VALUE_V120 + /* ignore POINTER_AXIS where we have libinput 1.19 and + higher and high-resolution scroll is enabled */ + if (driver_data->options.hires_scrolling_enabled) + break; +#endif + + xf86libinput_handle_axis(pInfo, + event, + libinput_event_pointer_get_axis_source( + libinput_event_get_pointer_event(event) + )); + break; +#if HAVE_LIBINPUT_AXIS_VALUE_V120 + case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL: + if (driver_data->options.hires_scrolling_enabled) { + xf86libinput_handle_axis(pInfo, + event, + LIBINPUT_POINTER_AXIS_SOURCE_WHEEL); + } + break; + case LIBINPUT_EVENT_POINTER_SCROLL_FINGER: + if (driver_data->options.hires_scrolling_enabled) { + xf86libinput_handle_axis(pInfo, + event, + LIBINPUT_POINTER_AXIS_SOURCE_FINGER); + } + break; + case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS: + if (driver_data->options.hires_scrolling_enabled) { + xf86libinput_handle_axis(pInfo, + event, + LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS); + } + break; +#endif + case LIBINPUT_EVENT_TOUCH_FRAME: + break; + case LIBINPUT_EVENT_TOUCH_UP: + case LIBINPUT_EVENT_TOUCH_DOWN: + case LIBINPUT_EVENT_TOUCH_MOTION: + case LIBINPUT_EVENT_TOUCH_CANCEL: + xf86libinput_handle_touch(pInfo, + libinput_event_get_touch_event(event), + libinput_event_get_type(event)); + break; + case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: + case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE: + case LIBINPUT_EVENT_GESTURE_SWIPE_END: + xf86libinput_handle_gesture_swipe(pInfo, + libinput_event_get_gesture_event(event), + type); + break; + case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN: + case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: + case LIBINPUT_EVENT_GESTURE_PINCH_END: + xf86libinput_handle_gesture_pinch(pInfo, + libinput_event_get_gesture_event(event), + type); + break; + case LIBINPUT_EVENT_TABLET_TOOL_AXIS: + event_handling = xf86libinput_handle_tablet_axis(pInfo, + libinput_event_get_tablet_tool_event(event)); + break; + case LIBINPUT_EVENT_TABLET_TOOL_BUTTON: + event_handling = xf86libinput_handle_tablet_button(pInfo, + libinput_event_get_tablet_tool_event(event)); + break; + case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: + event_handling = xf86libinput_handle_tablet_proximity(pInfo, + libinput_event_get_tablet_tool_event(event)); + break; + case LIBINPUT_EVENT_TABLET_TOOL_TIP: + event_handling = xf86libinput_handle_tablet_tip(pInfo, + libinput_event_get_tablet_tool_event(event)); + break; + case LIBINPUT_EVENT_TABLET_PAD_BUTTON: + xf86libinput_handle_tablet_pad_button(pInfo, + libinput_event_get_tablet_pad_event(event)); + break; + case LIBINPUT_EVENT_TABLET_PAD_RING: + xf86libinput_handle_tablet_pad_ring(pInfo, + libinput_event_get_tablet_pad_event(event)); + break; + case LIBINPUT_EVENT_TABLET_PAD_STRIP: + xf86libinput_handle_tablet_pad_strip(pInfo, + libinput_event_get_tablet_pad_event(event)); + break; + case LIBINPUT_EVENT_SWITCH_TOGGLE: + break; + + /* new libinput events we don't handle yet */ +#ifdef LIBINPUT_EVENT_GESTURE_HOLD_BEGIN + case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN: + break; +#endif +#ifdef LIBINPUT_EVENT_GESTURE_HOLD_END + case LIBINPUT_EVENT_GESTURE_HOLD_END: + break; +#endif +#ifdef LIBINPUT_EVENT_TABLET_PAD_KEY + case LIBINPUT_EVENT_TABLET_PAD_KEY: + break; +#endif + } + +out: + return event_handling; +} + +static void +xf86libinput_read_input(InputInfoPtr pInfo) +{ + struct libinput *libinput = driver_context.libinput; + int rc; + struct libinput_event *event; + + rc = libinput_dispatch(libinput); + if (rc == -EAGAIN) + return; + + if (rc < 0) { + xf86IDrvMsg(pInfo, X_ERROR, + "Error reading events: %s\n", + strerror(-rc)); + return; + } + + while ((event = libinput_get_event(libinput))) { + if (xf86libinput_handle_event(event) == EVENT_HANDLED) + libinput_event_destroy(event); + } +} + +/* + libinput provides a userdata for the context, but not per path device. so + the open_restricted call has the libinput context, but no reference to + the pInfo->fd that we actually need to return. + The server stores the fd in the options though, so we just get it from + there. If a device is added twice with two different fds this may give us + the wrong fd but why are you doing that anyway. + */ +static int +open_restricted(const char *path, int flags, void *data) +{ + InputInfoPtr pInfo; + int fd = -1; + + /* Special handling for sysfs files (used for pad LEDs) */ + if (strneq(path, "/sys/", 5)) { + fd = open(path, flags); + return fd < 0 ? -errno : fd; + } + + nt_list_for_each_entry(pInfo, xf86FirstLocalDevice(), next) { + char *device = xf86CheckStrOption(pInfo->options, "Device", NULL); + + if (device != NULL && streq(path, device)) { + free(device); + break; + } + free(device); + } + + if (pInfo == NULL) { + xf86Msg(X_ERROR, "Failed to look up path '%s'\n", path); + return -ENODEV; + } + + fd = xf86OpenSerial(pInfo->options); + if (fd < 0) + return -errno; + + xf86FlushInput(fd); + + return fd; +} + +static void +close_restricted(int fd, void *data) +{ + InputInfoPtr pInfo; + int server_fd = -1; + BOOL found = FALSE; + + nt_list_for_each_entry(pInfo, xf86FirstLocalDevice(), next) { + server_fd = xf86CheckIntOption(pInfo->options, "fd", -1); + + if (server_fd == fd) { + found = TRUE; + break; + } + } + + if (!found) + xf86CloseSerial(fd); +} + +const struct libinput_interface interface = { + .open_restricted = open_restricted, + .close_restricted = close_restricted, +}; + +_X_ATTRIBUTE_PRINTF(3, 0) +static void +xf86libinput_log_handler(struct libinput *libinput, + enum libinput_log_priority priority, + const char *format, + va_list args) +{ + MessageType type; + int verbosity; + + switch(priority) { + case LIBINPUT_LOG_PRIORITY_DEBUG: + type = X_DEBUG; + verbosity = 10; + break; + case LIBINPUT_LOG_PRIORITY_ERROR: + type = X_ERROR; + verbosity = -1; + break; + case LIBINPUT_LOG_PRIORITY_INFO: + type = X_INFO; + verbosity = 3; + break; + default: + return; + } + + /* log messages in libinput are per-context, not per device, so we + can't use xf86IDrvMsg here, and the server has no xf86VMsg or + similar */ + LogVMessageVerb(type, verbosity, format, args); +} + +static inline BOOL +xf86libinput_parse_tap_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL tap; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + tap = xf86SetBoolOption(pInfo->options, + "Tapping", + libinput_device_config_tap_get_enabled(device)); + + if (libinput_device_config_tap_set_enabled(device, tap) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping to %d\n", + tap); + tap = libinput_device_config_tap_get_enabled(device); + } + + return tap; +} + +static inline BOOL +xf86libinput_parse_tap_drag_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL drag; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + drag = xf86SetBoolOption(pInfo->options, + "TappingDrag", + libinput_device_config_tap_get_drag_enabled(device)); + + if (libinput_device_config_tap_set_drag_enabled(device, drag) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag Lock to %d\n", + drag); + drag = libinput_device_config_tap_get_drag_enabled(device); + } + + return drag; +} + +static inline BOOL +xf86libinput_parse_tap_drag_lock_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL drag_lock; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + drag_lock = xf86SetBoolOption(pInfo->options, + "TappingDragLock", + libinput_device_config_tap_get_drag_lock_enabled(device)); + + if (libinput_device_config_tap_set_drag_lock_enabled(device, drag_lock) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag Lock to %d\n", + drag_lock); + drag_lock = libinput_device_config_tap_get_drag_lock_enabled(device); + } + + return drag_lock; +} + +static inline enum libinput_config_tap_button_map +xf86libinput_parse_tap_buttonmap_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + enum libinput_config_tap_button_map map; + char *str; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + map = libinput_device_config_tap_get_button_map(device); + str = xf86SetStrOption(pInfo->options, + "TappingButtonMap", + NULL); + if (str) { + if (streq(str, "lmr")) + map = LIBINPUT_CONFIG_TAP_MAP_LMR; + else if (streq(str, "lrm")) + map = LIBINPUT_CONFIG_TAP_MAP_LRM; + else + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid TapButtonMap: %s\n", + str); + free(str); + } + + if (libinput_device_config_tap_set_button_map(device, map) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Button Map to %d\n", + map); + map = libinput_device_config_tap_get_button_map(device); + } + + return map; +} + +#if HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP +static inline enum libinput_config_clickfinger_button_map +xf86libinput_parse_clickfinger_map_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + uint32_t click_methods = libinput_device_config_click_get_methods(device); + enum libinput_config_clickfinger_button_map map; + char *str; + + map = libinput_device_config_click_get_clickfinger_button_map(device); + if ((click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) == 0) + return map; + + str = xf86SetStrOption(pInfo->options, + "ClickfingerButtonMap", + NULL); + if (str) { + if (streq(str, "lmr")) + map = LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR; + else if (streq(str, "lrm")) + map = LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM; + else + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid ClickfingerButtonMap: %s\n", + str); + free(str); + } + + if (libinput_device_config_click_set_clickfinger_button_map(device, map) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Clickfinger Button Map to %d\n", + map); + map = libinput_device_config_click_get_clickfinger_button_map(device); + } + + return map; +} +#endif + +static inline double +xf86libinput_parse_accel_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + double speed; + + if (!libinput_device_config_accel_is_available(device)) + return 0.0; + + speed = xf86SetRealOption(pInfo->options, + "AccelSpeed", + libinput_device_config_accel_get_speed(device)); + if (libinput_device_config_accel_set_speed(device, speed) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid speed %.2f, using 0 instead\n", + speed); + speed = libinput_device_config_accel_get_speed(device); + } + + return speed; +} + +static inline enum libinput_config_accel_profile +xf86libinput_parse_accel_profile_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + enum libinput_config_accel_profile profile; + char *str; + + if (libinput_device_config_accel_get_profiles(device) == + LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) + return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; + + str = xf86SetStrOption(pInfo->options, "AccelProfile", NULL); + if (!str) + profile = libinput_device_config_accel_get_profile(device); + else if (strcasecmp(str, "adaptive") == 0) + profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; + else if (strcasecmp(str, "flat") == 0) + profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + else if (strcasecmp(str, "custom") == 0) + profile = LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM; +#endif + else { + xf86IDrvMsg(pInfo, X_ERROR, + "Unknown accel profile '%s'. Using default.\n", + str); + profile = libinput_device_config_accel_get_profile(device); + } + + free(str); + + return profile; +} + +#if HAVE_LIBINPUT_CUSTOM_ACCEL +static inline struct accel_points +xf86libinput_parse_accel_points_option(InputInfoPtr pInfo, struct libinput_device *device, const char *name) +{ + struct accel_points accel_points = {0}; + char *str = NULL; + double *points = NULL; + size_t npoints = 0; + + if ((libinput_device_config_accel_get_profiles(device) & LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM) == 0) + goto out; + + str = xf86SetStrOption(pInfo->options, name, NULL); + if (!str) + goto out; + + points = double_array_from_string(str, " ", &npoints); + if (!points) { + xf86IDrvMsg(pInfo, X_ERROR, "Failed to parse AccelPoints, ignoring points.\n"); + goto out; + } + + if (npoints < CUSTOM_ACCEL_NPOINTS_MIN) { + xf86IDrvMsg(pInfo, X_ERROR, "At least %d AccelPoints are required, ignoring points.\n", + CUSTOM_ACCEL_NPOINTS_MIN); + goto out; + } + + if (npoints > CUSTOM_ACCEL_NPOINTS_MAX) { + xf86IDrvMsg(pInfo, X_WARNING, "Excessive number of AccelPoints, clipping to first %d points.\n", + CUSTOM_ACCEL_NPOINTS_MAX); + npoints = CUSTOM_ACCEL_NPOINTS_MAX; + } + + for (size_t idx = 0; idx < npoints; idx++) { + if (points[idx] < CUSTOM_ACCEL_POINT_MIN || points[idx] > CUSTOM_ACCEL_POINT_MAX) { + xf86IDrvMsg(pInfo, X_ERROR, "AccelPoints are not in the allowed range between %d and %d, ignoring points.\n", + CUSTOM_ACCEL_POINT_MIN, + CUSTOM_ACCEL_POINT_MAX); + goto out; + } + } + + memcpy(accel_points.points, points, npoints * sizeof(*points)); + accel_points.npoints = npoints; + +out: + free(str); + free(points); + return accel_points; +} + +static inline struct accel_points +xf86libinput_parse_accel_points_fallback_option(InputInfoPtr pInfo, struct libinput_device *device) +{ + return xf86libinput_parse_accel_points_option(pInfo, device, "AccelPointsFallback"); +} + +static inline struct accel_points +xf86libinput_parse_accel_points_motion_option(InputInfoPtr pInfo, struct libinput_device *device) +{ + return xf86libinput_parse_accel_points_option(pInfo, device, "AccelPointsMotion"); +} + +static inline struct accel_points +xf86libinput_parse_accel_points_scroll_option(InputInfoPtr pInfo, struct libinput_device *device) +{ + return xf86libinput_parse_accel_points_option(pInfo, device, "AccelPointsScroll"); +} + + +static inline double +xf86libinput_parse_accel_step_option(InputInfoPtr pInfo, struct libinput_device *device, const char *name) +{ + double step = 0.0; + double parsed_step; + + if ((libinput_device_config_accel_get_profiles(device) & LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM) == 0) + return step; + + parsed_step = xf86SetRealOption(pInfo->options, name, 0.0); + + if (parsed_step < CUSTOM_ACCEL_STEP_MIN || parsed_step > CUSTOM_ACCEL_STEP_MAX) { + xf86IDrvMsg(pInfo, X_ERROR, "Invalid step value, ignoring step.\n"); + return step; + } + + if (parsed_step == 0) + xf86IDrvMsg(pInfo, X_INFO, "Step value 0 was provided, libinput Fallback acceleration function is used.\n"); + + step = parsed_step; + return step; +} + +static inline double +xf86libinput_parse_accel_step_fallback_option(InputInfoPtr pInfo, struct libinput_device *device) +{ + return xf86libinput_parse_accel_step_option(pInfo, device, "AccelStepFallback"); +} + +static inline double +xf86libinput_parse_accel_step_motion_option(InputInfoPtr pInfo, struct libinput_device *device) +{ + return xf86libinput_parse_accel_step_option(pInfo, device, "AccelStepMotion"); +} + +static inline double +xf86libinput_parse_accel_step_scroll_option(InputInfoPtr pInfo, struct libinput_device *device) +{ + return xf86libinput_parse_accel_step_option(pInfo, device, "AccelStepScroll"); +} +#endif + +static inline BOOL +xf86libinput_parse_natscroll_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL natural_scroll; + + if (!libinput_device_config_scroll_has_natural_scroll(device)) + return FALSE; + + natural_scroll = xf86SetBoolOption(pInfo->options, + "NaturalScrolling", + libinput_device_config_scroll_get_natural_scroll_enabled(device)); + if (libinput_device_config_scroll_set_natural_scroll_enabled(device, + natural_scroll) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set NaturalScrolling to %d\n", + natural_scroll); + + natural_scroll = libinput_device_config_scroll_get_natural_scroll_enabled(device); + } + + return natural_scroll; +} + +static inline enum libinput_config_send_events_mode +xf86libinput_parse_sendevents_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + char *modestr; + enum libinput_config_send_events_mode mode; + + if (libinput_device_config_send_events_get_modes(device) == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED) + return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; + + mode = libinput_device_config_send_events_get_mode(device); + modestr = xf86SetStrOption(pInfo->options, + "SendEventsMode", + NULL); + if (modestr) { + if (streq(modestr, "enabled")) + mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; + else if (streq(modestr, "disabled")) + mode = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; + else if (streq(modestr, "disabled-on-external-mouse")) + mode = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; + else + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid SendeventsMode: %s\n", + modestr); + free(modestr); + } + + if (libinput_device_config_send_events_set_mode(device, mode) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set SendEventsMode %u\n", mode); + mode = libinput_device_config_send_events_get_mode(device); + } + + return mode; +} + +static inline void +xf86libinput_parse_calibration_option(InputInfoPtr pInfo, + struct libinput_device *device, + float matrix_out[9]) +{ + char *str; + float matrix[9] = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; + int num_calibration; + + memcpy(matrix_out, matrix, sizeof(matrix)); + + if (!libinput_device_config_calibration_has_matrix(device)) + return; + + libinput_device_config_calibration_get_matrix(device, matrix); + memcpy(matrix_out, matrix, sizeof(matrix)); + + str = xf86SetStrOption(pInfo->options, + "CalibrationMatrix", + NULL); + if (!str) + return; + + num_calibration = sscanf(str, "%f %f %f %f %f %f %f %f %f ", + &matrix[0], &matrix[1], + &matrix[2], &matrix[3], + &matrix[4], &matrix[5], + &matrix[6], &matrix[7], + &matrix[8]); + if (num_calibration != 9) { + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid matrix: %s, using default\n", str); + } else if (libinput_device_config_calibration_set_matrix(device, + matrix) == + LIBINPUT_CONFIG_STATUS_SUCCESS) { + memcpy(matrix_out, matrix, sizeof(matrix)); + } else + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to apply matrix: %s, using default\n", str); + free(str); +} + +static inline BOOL +xf86libinput_parse_lefthanded_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL left_handed; + + if (!libinput_device_config_left_handed_is_available(device)) + return FALSE; + + left_handed = xf86SetBoolOption(pInfo->options, + "LeftHanded", + libinput_device_config_left_handed_get(device)); + if (libinput_device_config_left_handed_set(device, + left_handed) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set LeftHanded to %d\n", + left_handed); + left_handed = libinput_device_config_left_handed_get(device); + } + + return left_handed; +} + +static inline enum libinput_config_scroll_method +xf86libinput_parse_scroll_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + uint32_t scroll_methods; + enum libinput_config_scroll_method m; + char *method; + + scroll_methods = libinput_device_config_scroll_get_methods(device); + if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL) + return LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + + method = xf86SetStrOption(pInfo->options, "ScrollMethod", NULL); + if (!method) + m = libinput_device_config_scroll_get_method(device); + else if (strncasecmp(method, "twofinger", 9) == 0) + m = LIBINPUT_CONFIG_SCROLL_2FG; + else if (strncasecmp(method, "edge", 4) == 0) + m = LIBINPUT_CONFIG_SCROLL_EDGE; + else if (strncasecmp(method, "button", 6) == 0) + m = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; + else if (strncasecmp(method, "none", 4) == 0) + m = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + else { + xf86IDrvMsg(pInfo, X_ERROR, + "Unknown scroll method '%s'. Using default.\n", + method); + m = libinput_device_config_scroll_get_method(device); + } + + free(method); + return m; +} + +static inline unsigned int +xf86libinput_parse_scrollbutton_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + unsigned int b; + CARD32 scroll_button; + + if ((libinput_device_config_scroll_get_methods(device) & + LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0) + return 0; + + b = btn_linux2xorg(libinput_device_config_scroll_get_button(device)); + scroll_button = xf86SetIntOption(pInfo->options, + "ScrollButton", + b); + + b = btn_xorg2linux(scroll_button); + + if (libinput_device_config_scroll_set_button(device, + b) != LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set ScrollButton to %u\n", + scroll_button); + scroll_button = btn_linux2xorg(libinput_device_config_scroll_get_button(device)); + } + return scroll_button; +} + +static inline BOOL +xf86libinput_parse_scrollbuttonlock_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + bool dflt; + BOOL buttonlock = FALSE; + + if ((libinput_device_config_scroll_get_methods(device) & + LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0) + return 0; + +#if HAVE_LIBINPUT_SCROLL_BUTTON_LOCK + dflt = libinput_device_config_scroll_get_default_button_lock(device); + buttonlock = xf86SetBoolOption(pInfo->options, "ScrollButtonLock", dflt); + + if (libinput_device_config_scroll_set_button_lock(device, buttonlock) + != LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to %s ScrollButtonLock\n", + buttonlock ? "enable" : "disable"); + buttonlock = libinput_device_config_scroll_get_button_lock(device); + } +#endif + return buttonlock; +} + +static inline bool +xf86libinput_want_scroll_distance_option(struct libinput_device *device) +{ + uint32_t methods = + LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN | + LIBINPUT_CONFIG_SCROLL_2FG | + LIBINPUT_CONFIG_SCROLL_EDGE; + + if ((libinput_device_config_scroll_get_methods(device) & methods) == 0) + return false; + + return true; +} + +static inline uint32_t +xf86libinput_parse_scroll_pixel_distance_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + uint32_t dflt = SCROLL_INCREMENT; + uint32_t dist; + + if (!xf86libinput_want_scroll_distance_option(device)) + return dflt; + + dist = xf86SetIntOption(pInfo->options, "ScrollPixelDistance", dflt); + if (dist < TOUCHPAD_SCROLL_DIST_MIN || dist > TOUCHPAD_SCROLL_DIST_MAX) { + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid ScrollPixelDistance %d\n", dist); + dist = dflt; + } + return dist; +} + +static inline double +xf86libinput_parse_scroll_factor_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + const double scroll_factor_default = 1.0; + double scroll_factor = xf86SetRealOption(pInfo->options, "ScrollFactor", scroll_factor_default); + if (scroll_factor < SCROLL_FACTOR_MIN || scroll_factor > SCROLL_FACTOR_MAX) { + xf86IDrvMsg(pInfo, X_ERROR, "Invalid ScrollFactor %f, expected to be between %f and %f\n", + scroll_factor, SCROLL_FACTOR_MIN, SCROLL_FACTOR_MAX); + scroll_factor = scroll_factor_default; + } + return scroll_factor; +} + +static inline unsigned int +xf86libinput_parse_clickmethod_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + uint32_t click_methods = libinput_device_config_click_get_methods(device); + enum libinput_config_click_method m; + char *method; + + if (click_methods == LIBINPUT_CONFIG_CLICK_METHOD_NONE) + return LIBINPUT_CONFIG_CLICK_METHOD_NONE; + + method = xf86SetStrOption(pInfo->options, "ClickMethod", NULL); + + if (!method) + m = libinput_device_config_click_get_method(device); + else if (strncasecmp(method, "buttonareas", 11) == 0) + m = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; + else if (strncasecmp(method, "clickfinger", 11) == 0) + m = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; + else if (strncasecmp(method, "none", 4) == 0) + m = LIBINPUT_CONFIG_CLICK_METHOD_NONE; + else { + xf86IDrvMsg(pInfo, X_ERROR, + "Unknown click method '%s'. Using default.\n", + method); + m = libinput_device_config_click_get_method(device); + } + free(method); + + return m; +} + +static inline BOOL +xf86libinput_parse_middleemulation_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + int enabled; + + if (!libinput_device_config_middle_emulation_is_available(device)) + return FALSE; + + enabled = xf86SetBoolOption(pInfo->options, + "MiddleEmulation", + -1); /* returns -1 if the option has not been set */ + if (enabled == -1) + enabled = xf86SetBoolOption(pInfo->options, + "Emulate3Buttons", + libinput_device_config_middle_emulation_get_default_enabled(device)); + if (libinput_device_config_middle_emulation_set_enabled(device, enabled) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set MiddleEmulation to %d\n", + enabled); + enabled = libinput_device_config_middle_emulation_get_enabled(device); + } + + return enabled; +} + +static inline BOOL +xf86libinput_parse_disablewhiletyping_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL enabled; + + if (!libinput_device_config_dwt_is_available(device)) + return FALSE; + + enabled = xf86SetBoolOption(pInfo->options, + "DisableWhileTyping", + libinput_device_config_dwt_get_default_enabled(device)); + if (libinput_device_config_dwt_set_enabled(device, enabled) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set DisableWhileTyping to %d\n", + enabled); + enabled = libinput_device_config_dwt_get_enabled(device); + } + + return enabled; +} + +static void +xf86libinput_parse_buttonmap_option(InputInfoPtr pInfo, + unsigned char *btnmap, + size_t size) +{ + const int MAXBUTTONS = 32; + char *mapping, *map, *s = NULL; + int idx = 1; + + init_button_map(btnmap, size); + + mapping = xf86SetStrOption(pInfo->options, "ButtonMapping", NULL); + if (!mapping) + return; + + map = mapping; + do + { + unsigned long int btn = strtoul(map, &s, 10); + + if (s == map || btn > MAXBUTTONS) + { + xf86IDrvMsg(pInfo, X_ERROR, + "... Invalid button mapping. Using defaults\n"); + init_button_map(btnmap, size); + break; + } + + btnmap[idx++] = btn; + map = s; + } while (s && *s != '\0' && idx < MAXBUTTONS); + + free(mapping); +} + +static inline void +xf86libinput_parse_draglock_option(InputInfoPtr pInfo, + struct xf86libinput *driver_data) +{ + char *str; + + str = xf86SetStrOption(pInfo->options, "DragLockButtons", NULL); + if (draglock_init_from_string(&driver_data->draglock, str) != 0) + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid DragLockButtons option: \"%s\"\n", + str); + free(str); +} + +static inline BOOL +xf86libinput_parse_horiz_scroll_option(InputInfoPtr pInfo) +{ + return xf86SetBoolOption(pInfo->options, "HorizontalScrolling", TRUE); +} + +static inline BOOL +xf86libinput_parse_hirescroll_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + return xf86SetBoolOption(pInfo->options, + "HighResolutionWheelScrolling", + TRUE); +} + +static inline double +xf86libinput_parse_rotation_angle_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + double angle; + + if (!libinput_device_config_rotation_is_available(device)) + return 0.0; + + angle = xf86SetRealOption(pInfo->options, + "RotationAngle", + libinput_device_config_rotation_get_default_angle(device)); + if (libinput_device_config_rotation_set_angle(device, angle) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid angle %.2f, using 0.0 instead\n", + angle); + angle = libinput_device_config_rotation_get_angle(device); + } + + return angle; +} + +static void +xf86libinput_parse_pressurecurve_option(InputInfoPtr pInfo, + struct xf86libinput *driver_data, + struct bezier_control_point pcurve[4]) +{ + struct bezier_control_point controls[4] = { + { 0.0, 0.0 }, + { 0.0, 0.0 }, + { 1.0, 1.0 }, + { 1.0, 1.0 }, + }; + float points[8]; + char *str; + int rc = 0; + int test_bezier[64]; + struct libinput_tablet_tool *tool = driver_data->tablet_tool; + + if ((driver_data->capabilities & CAP_TABLET_TOOL) == 0) + return; + + if (!tool || !libinput_tablet_tool_has_pressure(tool)) + return; + + str = xf86SetStrOption(pInfo->options, + "TabletToolPressureCurve", + NULL); + if (!str) + goto out; + + rc = sscanf(str, "%f/%f %f/%f %f/%f %f/%f", + &points[0], &points[1], &points[2], &points[3], + &points[4], &points[5], &points[6], &points[7]); + if (rc != 8) + goto out; + + for (int i = 0; i < 4; i++) { + if (points[i] < 0.0 || points[i] > 1.0) + goto out; + } + + controls[0].x = points[0]; + controls[0].y = points[1]; + controls[1].x = points[2]; + controls[1].y = points[3]; + controls[2].x = points[4]; + controls[2].y = points[5]; + controls[3].x = points[6]; + controls[3].y = points[7]; + + if (!cubic_bezier(controls, test_bezier, ARRAY_SIZE(test_bezier))) { + memcpy(controls, bezier_defaults, sizeof(controls)); + goto out; + } + + rc = 0; +out: + if (rc != 0) + xf86IDrvMsg(pInfo, X_ERROR, "Invalid pressure curve: %s\n", str); + free(str); + memcpy(pcurve, controls, sizeof(controls)); + xf86libinput_set_pressurecurve(driver_data, controls); +} + +static void +xf86libinput_parse_pressure_range_option(InputInfoPtr pInfo, + struct xf86libinput *driver_data, + struct xf86libinput_pressure_range *rangeopt) +{ +#if HAVE_LIBINPUT_PRESSURE_RANGE + struct libinput_tablet_tool *tool = driver_data->tablet_tool; + float min, max; + char *str; + int rc; + + rangeopt->min = 0.0; + rangeopt->max = 1.0; + + if ((driver_data->capabilities & CAP_TABLET_TOOL) == 0) + return; + + if (!tool || !libinput_tablet_tool_config_pressure_range_is_available(tool)) + return; + + str = xf86SetStrOption(pInfo->options, + "TabletToolPressureRange", + NULL); + if (!str) + return; + + rc = sscanf(str, "%f %f", &min, &max); + if (rc != 2) + goto out; + + if (min < 0.0 || max > 1.0 || min >= max) + goto out; + + rangeopt->min = min; + rangeopt->max = max; +out: + free(str); +#endif +} + +static inline bool +want_area_handling(struct xf86libinput *driver_data) +{ + struct libinput_device *device = driver_data->shared_device->device; + + if ((driver_data->capabilities & CAP_TABLET_TOOL) == 0) + return false; + + /* If we have a calibration matrix, it's a built-in tablet and we + * don't need to set the area ratio on those */ + return !libinput_device_config_calibration_has_matrix(device); +} + +static void +xf86libinput_parse_tablet_area_option(InputInfoPtr pInfo, + struct xf86libinput *driver_data, + struct ratio *area_out) +{ + char *str; + int rc; + struct ratio area; + + if (!want_area_handling(driver_data)) + return; + + str = xf86SetStrOption(pInfo->options, + "TabletToolAreaRatio", + NULL); + if (!str || streq(str, "default")) + goto out; + + rc = sscanf(str, "%d:%d", &area.x, &area.y); + if (rc != 2 || area.x <= 0 || area.y <= 0) { + xf86IDrvMsg(pInfo, X_ERROR, "Invalid tablet tool area ratio: %s\n", str); + } else { + *area_out = area; + } + +out: + free(str); +} + +static void +xf86libinput_parse_options(InputInfoPtr pInfo, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + struct options *options = &driver_data->options; + + /* libinput options */ + options->tapping = xf86libinput_parse_tap_option(pInfo, device); + options->tap_drag = xf86libinput_parse_tap_drag_option(pInfo, device); + options->tap_drag_lock = xf86libinput_parse_tap_drag_lock_option(pInfo, device); + options->tap_button_map = xf86libinput_parse_tap_buttonmap_option(pInfo, device); + options->speed = xf86libinput_parse_accel_option(pInfo, device); + options->accel_profile = xf86libinput_parse_accel_profile_option(pInfo, device); +#if HAVE_LIBINPUT_CUSTOM_ACCEL + options->accel_points_fallback = xf86libinput_parse_accel_points_fallback_option(pInfo, device); + options->accel_points_fallback.step = xf86libinput_parse_accel_step_fallback_option(pInfo, device); + options->accel_points_motion = xf86libinput_parse_accel_points_motion_option(pInfo, device); + options->accel_points_motion.step = xf86libinput_parse_accel_step_motion_option(pInfo, device); + options->accel_points_scroll = xf86libinput_parse_accel_points_scroll_option(pInfo, device); + options->accel_points_scroll.step = xf86libinput_parse_accel_step_scroll_option(pInfo, device); +#endif + options->natural_scrolling = xf86libinput_parse_natscroll_option(pInfo, device); + options->sendevents = xf86libinput_parse_sendevents_option(pInfo, device); + options->left_handed = xf86libinput_parse_lefthanded_option(pInfo, device); + options->scroll_method = xf86libinput_parse_scroll_option(pInfo, device); + options->scroll_button = xf86libinput_parse_scrollbutton_option(pInfo, device); + options->scroll_buttonlock = xf86libinput_parse_scrollbuttonlock_option(pInfo, device); + options->scroll_pixel_distance = xf86libinput_parse_scroll_pixel_distance_option(pInfo, device); + options->scroll_factor = xf86libinput_parse_scroll_factor_option(pInfo, device); + options->click_method = xf86libinput_parse_clickmethod_option(pInfo, device); +#if HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP + options->clickfinger_button_map = xf86libinput_parse_clickfinger_map_option(pInfo, device); +#endif + options->middle_emulation = xf86libinput_parse_middleemulation_option(pInfo, device); + options->disable_while_typing = xf86libinput_parse_disablewhiletyping_option(pInfo, device); + options->rotation_angle = xf86libinput_parse_rotation_angle_option(pInfo, device); + xf86libinput_parse_calibration_option(pInfo, device, driver_data->options.matrix); + + /* non-libinput options */ + xf86libinput_parse_buttonmap_option(pInfo, + options->btnmap, + sizeof(options->btnmap)); + if (driver_data->capabilities & CAP_POINTER) { + xf86libinput_parse_draglock_option(pInfo, driver_data); + options->horiz_scrolling_enabled = xf86libinput_parse_horiz_scroll_option(pInfo); + options->hires_scrolling_enabled = xf86libinput_parse_hirescroll_option(pInfo, device); + } + + xf86libinput_parse_pressurecurve_option(pInfo, + driver_data, + options->pressurecurve); + xf86libinput_parse_pressure_range_option(pInfo, driver_data, &options->pressure_range); + xf86libinput_parse_tablet_area_option(pInfo, + driver_data, + &options->area); +} + +static const char* +xf86libinput_get_type_name(struct libinput_device *device, + struct xf86libinput *driver_data) +{ + const char *type_name; + + /* now pick an actual type */ + if (libinput_device_config_tap_get_finger_count(device) > 0) + type_name = XI_TOUCHPAD; + else if (driver_data->capabilities & CAP_TOUCH) + type_name = XI_TOUCHSCREEN; + else if (driver_data->capabilities & CAP_POINTER) + type_name = XI_MOUSE; + else if (driver_data->capabilities & CAP_TABLET) + type_name = XI_TABLET; + else if (driver_data->capabilities & CAP_TABLET_PAD) + type_name = "PAD"; + else if (driver_data->capabilities & CAP_TABLET_TOOL){ + switch (libinput_tablet_tool_get_type(driver_data->tablet_tool)) { + case LIBINPUT_TABLET_TOOL_TYPE_PEN: + case LIBINPUT_TABLET_TOOL_TYPE_BRUSH: + case LIBINPUT_TABLET_TOOL_TYPE_PENCIL: + case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH: + type_name = "STYLUS"; + break; + case LIBINPUT_TABLET_TOOL_TYPE_ERASER: + type_name = "ERASER"; + break; + case LIBINPUT_TABLET_TOOL_TYPE_MOUSE: + case LIBINPUT_TABLET_TOOL_TYPE_LENS: + type_name = "CURSOR"; + break; + default: + type_name = XI_TABLET; + break; + } + } else + type_name = XI_KEYBOARD; + + return type_name; +} + +static void +xf86libinput_init_driver_context(void) +{ + if (!driver_context.libinput) { + driver_context.libinput = libinput_path_create_context(&interface, &driver_context); + libinput_log_set_handler(driver_context.libinput, + xf86libinput_log_handler); + /* we want all msgs, let the server filter */ + libinput_log_set_priority(driver_context.libinput, + LIBINPUT_LOG_PRIORITY_DEBUG); +#if HAVE_LIBINPUT_PLUGINS + libinput_plugin_system_append_default_paths(driver_context.libinput); + libinput_plugin_system_load_plugins(driver_context.libinput, LIBINPUT_PLUGIN_SYSTEM_FLAG_NONE); +#endif + } else { + libinput_ref(driver_context.libinput); + } +} + +struct xf86libinput_hotplug_info { + InputAttributes *attrs; + InputOption *input_options; +}; + +static DeviceIntPtr +xf86libinput_hotplug_device(struct xf86libinput_hotplug_info *hotplug) +{ + DeviceIntPtr dev; + + input_lock(); + if (NewInputDeviceRequest(hotplug->input_options, + hotplug->attrs, + &dev) != Success) + dev = NULL; + input_unlock(); + + input_option_free_list(&hotplug->input_options); + FreeInputAttributes(hotplug->attrs); + free(hotplug); + + return dev; +} + +static Bool +xf86libinput_hotplug_device_cb(ClientPtr client, pointer closure) +{ + struct xf86libinput_hotplug_info *hotplug = closure; + + xf86libinput_hotplug_device(hotplug); + + return TRUE; +} + +static void +xf86libinput_create_subdevice(InputInfoPtr pInfo, + uint32_t capabilities, + XF86OptionPtr extra_options) +{ + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device; + struct xf86libinput_hotplug_info *hotplug; + InputOption *iopts = NULL; + XF86OptionPtr options, o; + + shared_device = driver_data->shared_device; + pInfo->options = xf86ReplaceIntOption(pInfo->options, + "_libinput/shared-device", + shared_device->id); + + options = xf86OptionListDuplicate(pInfo->options); + options = xf86ReplaceStrOption(options, "_source", "_driver/libinput"); + options = xf86OptionListMerge(options, extra_options); + + if (capabilities & CAP_KEYBOARD) + options = xf86ReplaceBoolOption(options, "_libinput/cap-keyboard", 1); + if (capabilities & CAP_POINTER) + options = xf86ReplaceBoolOption(options, "_libinput/cap-pointer", 1); + if (capabilities & CAP_TOUCH) + options = xf86ReplaceBoolOption(options, "_libinput/cap-touch", 1); + if (capabilities & CAP_GESTURE) + options = xf86ReplaceBoolOption(options, "_libinput/cap-gesture", 1); + if (capabilities & CAP_TABLET_TOOL) + options = xf86ReplaceBoolOption(options, "_libinput/cap-tablet-tool", 1); + if (capabilities & CAP_TABLET_PAD) + options = xf86ReplaceBoolOption(options, "_libinput/cap-tablet-pad", 1); + + /* need convert from one option list to the other. woohoo. */ + o = options; + while (o) { + iopts = input_option_new(iopts, + xf86OptionName(o), + xf86OptionValue(o)); + o = xf86NextOption(o); + } + xf86OptionListFree(options); + + hotplug = calloc(1, sizeof(*hotplug)); + if (!hotplug) + return; + + hotplug->input_options = iopts; + hotplug->attrs = DuplicateInputAttributes(pInfo->attrs); + + xf86IDrvMsg(pInfo, X_INFO, "needs a virtual subdevice\n"); + + QueueWorkProc(xf86libinput_hotplug_device_cb, serverClient, hotplug); +} + +static inline uint32_t +caps_from_options(InputInfoPtr pInfo) +{ + uint32_t capabilities = 0; + + if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-keyboard", 0)) + capabilities |= CAP_KEYBOARD; + if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-pointer", 0)) + capabilities |= CAP_POINTER; + if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-touch", 0)) + capabilities |= CAP_TOUCH; + if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-gesture", 0)) + capabilities |= CAP_GESTURE; + if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-tablet-tool", 0)) + capabilities |= CAP_TABLET_TOOL; + + return capabilities; +} + +static inline Bool +claim_tablet_tool(InputInfoPtr pInfo) +{ + struct xf86libinput *driver_data = pInfo->private; + struct xf86libinput_device *shared_device = driver_data->shared_device; + struct xf86libinput_tablet_tool_event_queue *queue; + struct xf86libinput_tablet_tool *t; + enum libinput_tablet_tool_type tool_type; + uint64_t serial, tool_id; + + serial = (uint32_t)xf86CheckIntOption(pInfo->options, "_libinput/tablet-tool-serial", 0); + tool_id = (uint32_t)xf86CheckIntOption(pInfo->options, "_libinput/tablet-tool-id", 0); + tool_type = (uint32_t)xf86CheckIntOption(pInfo->options, "_libinput/tablet-tool-type", 0); + + xorg_list_for_each_entry(t, + &shared_device->unclaimed_tablet_tool_list, + node) { + if (libinput_tablet_tool_get_serial(t->tool) == serial && + libinput_tablet_tool_get_tool_id(t->tool) == tool_id && + libinput_tablet_tool_get_type(t->tool) == tool_type) { + driver_data->tablet_tool = t->tool; + queue = libinput_tablet_tool_get_user_data(t->tool); + if (queue) + queue->need_to_queue = false; + xorg_list_del(&t->node); + free(t); + return TRUE; + } + } + + return FALSE; +} + +static int +xf86libinput_pre_init(InputDriverPtr drv, + InputInfoPtr pInfo, + int flags) +{ + struct xf86libinput *driver_data = NULL; + struct xf86libinput_device *shared_device = NULL; + struct libinput *libinput = NULL; + struct libinput_device *device = NULL; + char *path = NULL; + bool is_subdevice; + + pInfo->type_name = 0; + pInfo->device_control = xf86libinput_device_control; + pInfo->read_input = xf86libinput_read_input; + pInfo->control_proc = NULL; + pInfo->switch_mode = NULL; + + driver_data = calloc(1, sizeof(*driver_data)); + if (!driver_data) + goto fail; + + driver_data->valuators = valuator_mask_new(6); + if (!driver_data->valuators) + goto fail; + + driver_data->valuators_unaccelerated = valuator_mask_new(2); + if (!driver_data->valuators_unaccelerated) + goto fail; + + path = xf86SetStrOption(pInfo->options, "Device", NULL); + if (!path) + goto fail; + + xf86libinput_init_driver_context(); + libinput = driver_context.libinput; + + if (libinput == NULL) { + xf86IDrvMsg(pInfo, X_ERROR, "Creating a device for %s failed\n", path); + goto fail; + } + + is_subdevice = xf86libinput_is_subdevice(pInfo); + if (is_subdevice) { + InputInfoPtr parent; + struct xf86libinput *parent_driver_data; + + parent = xf86libinput_get_parent(pInfo); + if (!parent) { + xf86IDrvMsg(pInfo, X_ERROR, "Failed to find parent device\n"); + goto fail; + } + + parent_driver_data = parent->private; + if (!parent_driver_data) /* parent already removed again */ + goto fail; + + xf86IDrvMsg(pInfo, X_INFO, "is a virtual subdevice\n"); + shared_device = xf86libinput_shared_ref(parent_driver_data->shared_device); + device = shared_device->device; + if (!device) + xf86IDrvMsg(pInfo, X_ERROR, "Parent device not available\n"); + } + + if (!device) { + device = libinput_path_add_device(libinput, path); + if (!device) { + xf86IDrvMsg(pInfo, X_ERROR, "Failed to create a device for %s\n", path); + goto fail; + } + + /* We ref the device above, then remove it. It gets + re-added with the same path in DEVICE_ON, we hope + it doesn't change until then */ + libinput_device_ref(device); + libinput_path_remove_device(device); + + shared_device = xf86libinput_shared_create(device); + if (!shared_device) { + libinput_device_unref(device); + goto fail; + } + } + + pInfo->private = driver_data; + driver_data->pInfo = pInfo; + driver_data->path = path; + driver_data->shared_device = shared_device; + xorg_list_append(&driver_data->shared_device_link, + &shared_device->device_list); + + /* Scroll dist value matters for source finger/continuous. For those + * devices libinput provides pixel-like data, changing this will + * affect touchpad scroll speed. For wheels it doesn't matter as + * we're using the discrete value only. + */ + driver_data->scroll.v.dist = 120; + driver_data->scroll.h.dist = 120; + + if (!is_subdevice) { + if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) + driver_data->capabilities |= CAP_POINTER; + if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) + driver_data->capabilities |= CAP_KEYBOARD; + if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) + driver_data->capabilities |= CAP_TOUCH; + if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_GESTURE)) + driver_data->capabilities |= CAP_GESTURE; + if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) + driver_data->capabilities |= CAP_TABLET; + if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_PAD)) + driver_data->capabilities |= CAP_TABLET_PAD; + } else { + + driver_data->capabilities = caps_from_options(pInfo); + + if (driver_data->capabilities & CAP_TABLET_TOOL) + claim_tablet_tool(pInfo); + } + + /* Disable acceleration in the server, libinput does it for us */ + pInfo->options = xf86ReplaceIntOption(pInfo->options, "AccelerationProfile", -1); + pInfo->options = xf86ReplaceStrOption(pInfo->options, "AccelerationScheme", "none"); + + xf86libinput_parse_options(pInfo, driver_data, device); + + /* Device is both keyboard and pointer. Drop the keyboard cap from + * this device, create a separate device instead */ + if (!is_subdevice && + driver_data->capabilities & CAP_KEYBOARD && + driver_data->capabilities & (CAP_POINTER|CAP_TOUCH|CAP_GESTURE)) { + driver_data->capabilities &= ~CAP_KEYBOARD; + xf86libinput_create_subdevice(pInfo, + CAP_KEYBOARD, + NULL); + } + + pInfo->type_name = xf86libinput_get_type_name(device, driver_data); + + return Success; +fail: + if (driver_data) { + if (driver_data->valuators) + valuator_mask_free(&driver_data->valuators); + if (driver_data->valuators_unaccelerated) + valuator_mask_free(&driver_data->valuators_unaccelerated); + } + free(path); + if (shared_device) + xf86libinput_shared_unref(shared_device); + free(driver_data); + if (libinput) + driver_context.libinput = libinput_unref(libinput); + return BadValue; +} + +static void +xf86libinput_uninit(InputDriverPtr drv, + InputInfoPtr pInfo, + int flags) +{ + struct xf86libinput *driver_data = pInfo->private; + if (driver_data) { + driver_context.libinput = libinput_unref(driver_context.libinput); + valuator_mask_free(&driver_data->valuators); + valuator_mask_free(&driver_data->valuators_unaccelerated); + free(driver_data->path); + free(driver_data); + pInfo->private = NULL; + } + xf86DeleteInput(pInfo, flags); +} + +InputDriverRec xf86libinput_driver = { + .driverVersion = 1, + .driverName = "libinput", + .PreInit = xf86libinput_pre_init, + .UnInit = xf86libinput_uninit, + .module = NULL, + .default_options= NULL, + .capabilities = XI86_DRV_CAP_SERVER_FD +}; + +static XF86ModuleVersionInfo xf86libinput_version_info = { + "libinput", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + {0, 0, 0, 0} +}; + +static pointer +xf86libinput_setup_proc(pointer module, pointer options, int *errmaj, int *errmin) +{ + xf86AddInputDriver(&xf86libinput_driver, module, 0); + return module; +} + +_X_EXPORT XF86ModuleData libinputModuleData = { + .vers = &xf86libinput_version_info, + .setup = &xf86libinput_setup_proc, + .teardown = NULL +}; + +/* Property support */ + +/* libinput-specific properties */ +static Atom prop_tap; +static Atom prop_tap_default; +static Atom prop_tap_drag; +static Atom prop_tap_drag_default; +static Atom prop_tap_drag_lock; +static Atom prop_tap_drag_lock_default; +static Atom prop_tap_buttonmap; +static Atom prop_tap_buttonmap_default; +static Atom prop_calibration; +static Atom prop_calibration_default; +static Atom prop_accel; +static Atom prop_accel_default; +static Atom prop_accel_profile_enabled; +#if HAVE_LIBINPUT_CUSTOM_ACCEL +static Atom prop_accel_points_fallback; +static Atom prop_accel_step_fallback; +static Atom prop_accel_points_motion; +static Atom prop_accel_step_motion; +static Atom prop_accel_points_scroll; +static Atom prop_accel_step_scroll; +#endif +static Atom prop_accel_profile_default; +static Atom prop_accel_profiles_available; +static Atom prop_natural_scroll; +static Atom prop_natural_scroll_default; +static Atom prop_sendevents_available; +static Atom prop_sendevents_enabled; +static Atom prop_sendevents_default; +static Atom prop_left_handed; +static Atom prop_left_handed_default; +static Atom prop_scroll_methods_available; +static Atom prop_scroll_method_enabled; +static Atom prop_scroll_method_default; +static Atom prop_scroll_button; +static Atom prop_scroll_button_default; +static Atom prop_scroll_buttonlock; +static Atom prop_scroll_buttonlock_default; +static Atom prop_scroll_pixel_distance; +static Atom prop_scroll_pixel_distance_default; +static Atom prop_scroll_factor; +static Atom prop_scroll_factor_default; +static Atom prop_click_methods_available; +static Atom prop_click_method_enabled; +static Atom prop_click_method_default; +static Atom prop_clickfinger_buttonmap; +static Atom prop_clickfinger_buttonmap_default; +static Atom prop_middle_emulation; +static Atom prop_middle_emulation_default; +static Atom prop_disable_while_typing; +static Atom prop_disable_while_typing_default; +static Atom prop_mode_groups_available; +static Atom prop_mode_groups; +static Atom prop_mode_groups_buttons; +static Atom prop_mode_groups_rings; +static Atom prop_mode_groups_strips; +static Atom prop_rotation_angle; +static Atom prop_rotation_angle_default; +static Atom prop_pressure_range; +static Atom prop_pressure_range_default; + +/* driver properties */ +static Atom prop_draglock; +static Atom prop_horiz_scroll; +static Atom prop_pressurecurve; +static Atom prop_area_ratio; +static Atom prop_serial; +static Atom prop_tool_id; +static Atom prop_hires_scroll; + +/* general properties */ +static Atom prop_float; +static Atom prop_device; +static Atom prop_product_id; + +struct mode_prop_state { + int deviceid; + InputInfoPtr pInfo; + + struct libinput_tablet_pad_mode_group *group; + unsigned int mode; + unsigned int idx; +}; + +static Bool +update_mode_prop_cb(ClientPtr client, pointer closure) +{ + struct mode_prop_state *state = closure; + InputInfoPtr pInfo = state->pInfo, tmp; + struct xf86libinput *driver_data = pInfo->private; + BOOL found = FALSE; + XIPropertyValuePtr val; + int rc; + unsigned char groups[4] = {0}; + struct libinput_tablet_pad_mode_group *group = state->group; + unsigned int mode = state->mode; + unsigned int idx = state->idx; + + if (idx >= ARRAY_SIZE(groups)) + goto out; + + /* The device may have gotten removed before the WorkProc was + * scheduled. X reuses deviceids, but if the pointer value and + * device ID are what we had before, we're good */ + nt_list_for_each_entry(tmp, xf86FirstLocalDevice(), next) { + if (tmp->dev->id == state->deviceid && tmp == pInfo) { + found = TRUE; + break; + } + } + if (!found) + goto out; + + rc = XIGetDeviceProperty(pInfo->dev, + prop_mode_groups, + &val); + if (rc != Success || + val->format != 8 || + val->size <= 0) + goto out; + + memcpy(groups, (unsigned char*)val->data, val->size); + + if (groups[idx] == mode) + goto out; + + groups[idx] = mode; + + driver_data->allow_mode_group_updates = true; + XIChangeDeviceProperty(pInfo->dev, + prop_mode_groups, + XA_INTEGER, 8, + PropModeReplace, + val->size, + groups, + TRUE); + driver_data->allow_mode_group_updates = false; + +out: + libinput_tablet_pad_mode_group_unref(group); + free(state); + return TRUE; +} + +static inline void +update_mode_prop(InputInfoPtr pInfo, + struct libinput_event_tablet_pad *event) +{ + struct libinput_tablet_pad_mode_group *group; + struct mode_prop_state *state; + + state = calloc(1, sizeof(*state)); + if (!state) + return; + + state->deviceid = pInfo->dev->id; + state->pInfo = pInfo; + + group = libinput_event_tablet_pad_get_mode_group(event); + + state->group = libinput_tablet_pad_mode_group_ref(group); + state->mode = libinput_event_tablet_pad_get_mode(event); + state->idx = libinput_tablet_pad_mode_group_get_index(group); + + /* Schedule a WorkProc so we don't update from within the input + thread */ + QueueWorkProc(update_mode_prop_cb, serverClient, state); +} + +static inline BOOL +xf86libinput_check_device(DeviceIntPtr dev, + Atom atom) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + + if (device == NULL) { + if (dev->public.on) + xf86IDrvMsg(pInfo, X_WARNING, "BUG: xf86libinput_check_device() device is on\n"); + xf86IDrvMsg(pInfo, X_INFO, + "SetProperty on %u called but device is disabled.\n" + "This driver cannot change properties on a disabled device\n", + atom); + return FALSE; + } + + return TRUE; +} + +static inline int +LibinputSetPropertyTap(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + if (checkonly) { + if (*data != 0 && *data != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return BadMatch; + } else { + driver_data->options.tapping = *data; + } + + return Success; +} + +static inline int +LibinputSetPropertyTapDrag(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + if (checkonly) { + if (*data != 0 && *data != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return BadMatch; + } else { + driver_data->options.tap_drag = *data; + } + + return Success; +} + +static inline int +LibinputSetPropertyTapDragLock(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + if (checkonly) { + if (*data != 0 && *data != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return BadMatch; + } else { + driver_data->options.tap_drag_lock = *data; + } + + return Success; +} + +static inline int +LibinputSetPropertyTapButtonmap(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + BOOL* data; + enum libinput_config_tap_button_map map; + + if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (checkonly) { + if ((data[0] && data[1]) || (!data[0] && !data[1])) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } + + if (data[0]) + map = LIBINPUT_CONFIG_TAP_MAP_LRM; + else if (data[1]) + map = LIBINPUT_CONFIG_TAP_MAP_LMR; + else + return BadValue; + + if (!checkonly) + driver_data->options.tap_button_map = map; + + return Success; +} + +static inline int +LibinputSetPropertyCalibration(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + float* data; + + if (val->format != 32 || val->size != 9 || val->type != prop_float) + return BadMatch; + + data = (float*)val->data; + + if (checkonly) { + if (data[6] != 0.0 || + data[7] != 0.0 || + data[8] != 1.0) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (!libinput_device_config_calibration_has_matrix(device)) + return BadMatch; + } else { + memcpy(driver_data->options.matrix, + data, + sizeof(driver_data->options.matrix)); + } + + return Success; +} + +static inline int +LibinputSetPropertyAccel(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + float* data; + + if (val->format != 32 || val->size != 1 || val->type != prop_float) + return BadMatch; + + data = (float*)val->data; + + if (checkonly) { + if (*data < -1.0 || *data > 1.0) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (libinput_device_config_accel_is_available(device) == 0) + return BadMatch; + } else { + driver_data->options.speed = *data; + } + + return Success; +} + +static inline int +LibinputSetPropertyAccelProfile(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + uint32_t profiles = 0; + + if (val->format != 8 || val->size < 2 || val->size > 3 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (data[0]) + profiles |= LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; + if (data[1]) + profiles |= LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + if (val->size > 2 && data[2]) + profiles |= LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM; +#endif + + if (checkonly) { + uint32_t supported; + + if (__builtin_popcount(profiles) > 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + supported = libinput_device_config_accel_get_profiles(device); + if (profiles && (profiles & supported) == 0) + return BadValue; + } else { + driver_data->options.accel_profile = profiles; + } + + return Success; +} + +#if HAVE_LIBINPUT_CUSTOM_ACCEL +static inline int +LibinputSetPropertyAccelPoints(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + float* data; + struct accel_points *accel_points = NULL; + + if (val->format != 32 || val->type != prop_float || + val->size < CUSTOM_ACCEL_NPOINTS_MIN || val->size > CUSTOM_ACCEL_NPOINTS_MAX) + return BadMatch; + + data = (float*)val->data; + + if (checkonly) { + uint32_t profiles; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + profiles = libinput_device_config_accel_get_profiles(device); + if ((profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM) == 0) + return BadValue; + + for (size_t idx = 0; idx < val->size; idx++) { + if (data[idx] < CUSTOM_ACCEL_POINT_MIN || data[idx] > CUSTOM_ACCEL_POINT_MAX) + return BadValue; + } + } else { + if (atom == prop_accel_points_fallback) + accel_points = &driver_data->options.accel_points_fallback; + else if (atom == prop_accel_points_motion) + accel_points = &driver_data->options.accel_points_motion; + else if (atom == prop_accel_points_scroll) + accel_points = &driver_data->options.accel_points_scroll; + else + return BadValue; + + for (size_t idx = 0; idx < val->size; idx++) + accel_points->points[idx] = data[idx]; + accel_points->npoints = val->size; + } + + return Success; +} + +static inline int +LibinputSetPropertyAccelStep(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + float* data; + + if (val->format != 32 || val->type != prop_float || val->size != 1) + return BadMatch; + + data = (float*)val->data; + + if (checkonly) { + uint32_t profiles; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + profiles = libinput_device_config_accel_get_profiles(device); + if ((profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM) == 0) + return BadValue; + + if (*data < CUSTOM_ACCEL_STEP_MIN || *data > CUSTOM_ACCEL_STEP_MAX) + return BadValue; + } else { + if (atom == prop_accel_step_fallback) + driver_data->options.accel_points_fallback.step = *data; + else if (atom == prop_accel_step_motion) + driver_data->options.accel_points_motion.step = *data; + else if (atom == prop_accel_step_scroll) + driver_data->options.accel_points_scroll.step = *data; + } + + return Success; +} +#endif + +static inline int +LibinputSetPropertyNaturalScroll(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (checkonly) { + if (*data != 0 && *data != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (libinput_device_config_scroll_has_natural_scroll(device) == 0) + return BadMatch; + } else { + driver_data->options.natural_scrolling = *data; + } + + return Success; +} + +static inline int +LibinputSetPropertySendEvents(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + uint32_t modes = 0; + + if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (data[0]) + modes |= LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; + if (data[1]) + modes |= LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; + + if (checkonly) { + uint32_t supported; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + supported = libinput_device_config_send_events_get_modes(device); + if ((modes | supported) != supported) + return BadValue; + + } else { + driver_data->options.sendevents = modes; + } + + return Success; +} + +static inline int +LibinputSetPropertyLeftHanded(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (checkonly) { + int supported; + int left_handed = *data; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + supported = libinput_device_config_left_handed_is_available(device); + if (!supported && left_handed) + return BadValue; + } else { + struct xf86libinput *other; + + driver_data->options.left_handed = *data; + + xorg_list_for_each_entry(other, + &driver_data->shared_device->device_list, + shared_device_link) { + DeviceIntPtr other_device = other->pInfo->dev; + + if (other->options.left_handed == *data) + continue; + + XIChangeDeviceProperty(other_device, + atom, + val->type, + val->format, + PropModeReplace, + val->size, + val->data, + TRUE); + } + + } + + return Success; +} + +static inline int +LibinputSetPropertyScrollMethods(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + uint32_t modes = 0; + + if (val->format != 8 || val->size != 3 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (data[0]) + modes |= LIBINPUT_CONFIG_SCROLL_2FG; + if (data[1]) + modes |= LIBINPUT_CONFIG_SCROLL_EDGE; + if (data[2]) + modes |= LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; + + if (checkonly) { + uint32_t supported; + + if (__builtin_popcount(modes) > 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + supported = libinput_device_config_scroll_get_methods(device); + if (modes && (modes & supported) == 0) + return BadValue; + } else { + driver_data->options.scroll_method = modes; + } + + return Success; +} + +static inline int +LibinputSetPropertyScrollButton(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + CARD32* data; + + if (val->format != 32 || val->size != 1 || val->type != XA_CARDINAL) + return BadMatch; + + data = (CARD32*)val->data; + + if (checkonly) { + uint32_t button = *data; + uint32_t supported; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + supported = libinput_device_pointer_has_button(device, + btn_xorg2linux(button)); + if (button && !supported) + return BadValue; + } else { + driver_data->options.scroll_button = *data; + } + + return Success; +} + +static inline int +LibinputSetPropertyScrollButtonLock(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + BOOL enabled; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + enabled = *(BOOL*)val->data; + if (checkonly) { + if (enabled != 0 && enabled != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } else { + driver_data->options.scroll_buttonlock = enabled; + } + + return Success; +} + +static inline int +LibinputSetPropertyClickMethod(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + uint32_t modes = 0; + + if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (data[0]) + modes |= LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; + if (data[1]) + modes |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; + + if (checkonly) { + uint32_t supported; + + if (__builtin_popcount(modes) > 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + supported = libinput_device_config_click_get_methods(device); + if (modes && (modes & supported) == 0) + return BadValue; + } else { + driver_data->options.click_method = modes; + } + + return Success; +} + +static inline int +LibinputSetPropertyClickfingerButtonmap(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ +#if HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + BOOL* data; + enum libinput_config_clickfinger_button_map map; + + if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + + if (checkonly) { + if ((data[0] && data[1]) || (!data[0] && !data[1])) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } + + if (data[0]) + map = LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM; + else if (data[1]) + map = LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR; + else + return BadValue; + + if (!checkonly) + driver_data->options.clickfinger_button_map = map; + +#endif + return Success; +} + + +static inline int +LibinputSetPropertyMiddleEmulation(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + if (checkonly) { + if (*data != 0 && *data != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (!libinput_device_config_middle_emulation_is_available(device)) + return BadMatch; + } else { + driver_data->options.middle_emulation = *data; + } + + return Success; +} + +static inline int +LibinputSetPropertyDisableWhileTyping(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + if (checkonly) { + if (*data != 0 && *data != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (!libinput_device_config_dwt_is_available(device)) + return BadMatch; + } else { + driver_data->options.disable_while_typing = *data; + } + + return Success; +} + +static inline int +prop_draglock_set_meta(struct xf86libinput *driver_data, + const BYTE *values, + int len, + BOOL checkonly) +{ + struct draglock *dl, + dummy; /* for checkonly */ + int meta; + + if (len > 1) + return BadImplementation; /* should not happen */ + + dl = (checkonly) ? &dummy : &driver_data->draglock; + meta = len > 0 ? values[0] : 0; + + return draglock_set_meta(dl, meta) == 0 ? Success: BadValue; +} + +static inline int +prop_draglock_set_pairs(struct xf86libinput *driver_data, + const BYTE* pairs, + int len, + BOOL checkonly) +{ + struct draglock *dl, + dummy; /* for checkonly */ + int data[MAX_BUTTONS + 1] = {0}; + int i; + int highest = 0; + const unsigned int max = MAX_BUTTONS; + + if (len >= ARRAY_SIZE(data)) + return BadMatch; + + if (len < 2 || len % 2) + return BadImplementation; /* should not happen */ + + dl = (checkonly) ? &dummy : &driver_data->draglock; + + for (i = 0; i < len; i += 2) { + if (pairs[i] > max) + return BadValue; + + data[pairs[i]] = pairs[i+1]; + highest = max(highest, pairs[i]); + } + + return draglock_set_pairs(dl, data, highest + 1) == 0 ? Success : BadValue; +} + +static inline int +LibinputSetPropertyDragLockButtons(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + + if (val->format != 8 || val->type != XA_INTEGER) + return BadMatch; + + /* either a single value, or pairs of values */ + if (val->size > 1 && val->size % 2) + return BadMatch; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (val->size <= 1) + return prop_draglock_set_meta(driver_data, + (BYTE*)val->data, + val->size, checkonly); + else + return prop_draglock_set_pairs(driver_data, + (BYTE*)val->data, + val->size, checkonly); +} + +static inline int +LibinputSetPropertyHorizScroll(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + BOOL enabled; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + enabled = *(BOOL*)val->data; + if (checkonly) { + if (enabled != 0 && enabled != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } else { + driver_data->options.horiz_scrolling_enabled = enabled; + } + + return Success; +} + +static inline int +LibinputSetPropertyScrollPixelDistance(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + uint32_t dist; + + if (val->format != 32 || val->size != 1 || val->type != XA_CARDINAL) + return BadMatch; + + dist = *(BOOL*)val->data; + if (checkonly) { + if (dist < TOUCHPAD_SCROLL_DIST_MIN || + dist > TOUCHPAD_SCROLL_DIST_MAX) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } else { + driver_data->options.scroll_pixel_distance = dist; + } + + return Success; +} + +static inline int +LibinputSetPropertyScrollFactor(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + float *scroll_factor; + + if (val->format != 32 || val->size != 1 || val->type != prop_float) + return BadMatch; + + scroll_factor = (float*)val->data; + + if (checkonly) { + if (*scroll_factor < SCROLL_FACTOR_MIN || *scroll_factor > SCROLL_FACTOR_MAX) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } else { + driver_data->options.scroll_factor = *scroll_factor; + } + + return Success; +} + +static inline int +LibinputSetPropertyRotationAngle(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + float *angle; + + if (val->format != 32 || val->size != 1 || val->type != prop_float) + return BadMatch; + + angle = (float*)val->data; + + if (checkonly) { + if (*angle < 0.0 || *angle >= 360.0) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (libinput_device_config_rotation_is_available(device) == 0) + return BadMatch; + } else { + driver_data->options.rotation_angle = *angle; + } + + return Success; +} + +static inline int +LibinputSetPropertyPressureCurve(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + float *vals; + struct bezier_control_point controls[4]; + + if (val->format != 32 || val->size != 8 || val->type != prop_float) + return BadMatch; + + vals = val->data; + controls[0].x = vals[0]; + controls[0].y = vals[1]; + controls[1].x = vals[2]; + controls[1].y = vals[3]; + controls[2].x = vals[4]; + controls[2].y = vals[5]; + controls[3].x = vals[6]; + controls[3].y = vals[7]; + + if (checkonly) { + int test_bezier[64]; + + for (int i = 0; i < val->size; i++) { + if (vals[i] < 0.0 || vals[i] > 1.0) + return BadValue; + } + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (!cubic_bezier(controls, test_bezier, ARRAY_SIZE(test_bezier))) + return BadValue; + } else { + xf86libinput_set_pressurecurve(driver_data, controls); + memcpy(driver_data->options.pressurecurve, controls, + sizeof(controls)); + } + + return Success; +} + +static inline int +LibinputSetPropertyPressureRange(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + float *vals; + struct xf86libinput_pressure_range rangeopt = { 0.0, 1.0 }; + + if (val->format != 32 || val->size != 2 || val->type != prop_float) + return BadMatch; + + vals = val->data; + rangeopt.min = vals[0]; + rangeopt.max = vals[1]; + + if (checkonly) { + if (rangeopt.min < 0.0 || rangeopt.max > 1.0 || rangeopt.min >= rangeopt.max) + return BadValue; + + /* Disallow reducing the range to less than 20% of the range, mostly + * to avoid footguns */ + if (rangeopt.max - rangeopt.min < 0.2) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } else { + driver_data->options.pressure_range = rangeopt; + } + + return Success; +} + +static inline int +LibinputSetPropertyAreaRatio(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + uint32_t *vals; + struct ratio area = { 0, 0 }; + + if (val->format != 32 || val->size != 2 || val->type != XA_CARDINAL) + return BadMatch; + + vals = val->data; + area.x = vals[0]; + area.y = vals[1]; + + if (checkonly) { + if (area.x < 0 || area.y < 0) + return BadValue; + + if ((area.x != 0 && area.y == 0) || + (area.x == 0 && area.y != 0)) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } else { + struct xf86libinput *other; + + xf86libinput_set_area_ratio(driver_data, &area); + + xorg_list_for_each_entry(other, + &driver_data->shared_device->device_list, + shared_device_link) { + DeviceIntPtr other_device = other->pInfo->dev; + + if (other->options.area.x == area.x && + other->options.area.y == area.y) + continue; + + XIChangeDeviceProperty(other_device, + atom, + val->type, + val->format, + PropModeReplace, + val->size, + val->data, + TRUE); + } + } + + return Success; +} + +static inline int +LibinputSetPropertyHighResolutionScroll(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + BOOL enabled; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + enabled = *(BOOL*)val->data; + if (checkonly) { + if (enabled != 0 && enabled != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + } else { + driver_data->options.hires_scrolling_enabled = enabled; + } + + return Success; +} + +static int +LibinputSetProperty(DeviceIntPtr dev, Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + int rc; + + if (atom == prop_tap) + rc = LibinputSetPropertyTap(dev, atom, val, checkonly); + else if (atom == prop_tap_drag) + rc = LibinputSetPropertyTapDrag(dev, atom, val, checkonly); + else if (atom == prop_tap_drag_lock) + rc = LibinputSetPropertyTapDragLock(dev, atom, val, checkonly); + else if (atom == prop_tap_buttonmap) + rc = LibinputSetPropertyTapButtonmap(dev, atom, val, checkonly); + else if (atom == prop_calibration) + rc = LibinputSetPropertyCalibration(dev, atom, val, + checkonly); + else if (atom == prop_accel) + rc = LibinputSetPropertyAccel(dev, atom, val, checkonly); + else if (atom == prop_accel_profile_enabled) + rc = LibinputSetPropertyAccelProfile(dev, atom, val, checkonly); +#if HAVE_LIBINPUT_CUSTOM_ACCEL + else if (atom == prop_accel_points_fallback || + atom == prop_accel_points_motion || + atom == prop_accel_points_scroll) + rc = LibinputSetPropertyAccelPoints(dev, atom, val, checkonly); + else if (atom == prop_accel_step_fallback || + atom == prop_accel_step_motion || + atom == prop_accel_step_scroll) + rc = LibinputSetPropertyAccelStep(dev, atom, val, checkonly); +#endif + else if (atom == prop_natural_scroll) + rc = LibinputSetPropertyNaturalScroll(dev, atom, val, checkonly); + else if (atom == prop_sendevents_enabled) + rc = LibinputSetPropertySendEvents(dev, atom, val, checkonly); + else if (atom == prop_left_handed) + rc = LibinputSetPropertyLeftHanded(dev, atom, val, checkonly); + else if (atom == prop_scroll_method_enabled) + rc = LibinputSetPropertyScrollMethods(dev, atom, val, checkonly); + else if (atom == prop_scroll_button) + rc = LibinputSetPropertyScrollButton(dev, atom, val, checkonly); + else if (atom == prop_scroll_buttonlock) + rc = LibinputSetPropertyScrollButtonLock(dev, atom, val, checkonly); + else if (atom == prop_click_method_enabled) + rc = LibinputSetPropertyClickMethod(dev, atom, val, checkonly); + else if (atom == prop_clickfinger_buttonmap) + rc = LibinputSetPropertyClickfingerButtonmap(dev, atom, val, checkonly); + else if (atom == prop_middle_emulation) + rc = LibinputSetPropertyMiddleEmulation(dev, atom, val, checkonly); + else if (atom == prop_disable_while_typing) + rc = LibinputSetPropertyDisableWhileTyping(dev, atom, val, checkonly); + else if (atom == prop_draglock) + rc = LibinputSetPropertyDragLockButtons(dev, atom, val, checkonly); + else if (atom == prop_horiz_scroll) + rc = LibinputSetPropertyHorizScroll(dev, atom, val, checkonly); + else if (atom == prop_scroll_pixel_distance) + rc = LibinputSetPropertyScrollPixelDistance(dev, atom, val, checkonly); + else if (atom == prop_scroll_factor) + rc = LibinputSetPropertyScrollFactor(dev, atom, val, checkonly); + else if (atom == prop_mode_groups) { + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + + if (driver_data->allow_mode_group_updates) + return Success; + else + return BadAccess; + } + else if (atom == prop_rotation_angle) + rc = LibinputSetPropertyRotationAngle(dev, atom, val, checkonly); + else if (atom == prop_pressurecurve) + rc = LibinputSetPropertyPressureCurve(dev, atom, val, checkonly); + else if (atom == prop_pressure_range) + rc = LibinputSetPropertyPressureRange(dev, atom, val, checkonly); + else if (atom == prop_area_ratio) + rc = LibinputSetPropertyAreaRatio(dev, atom, val, checkonly); + else if (atom == prop_hires_scroll) + rc = LibinputSetPropertyHighResolutionScroll(dev, atom, val, checkonly); + else if (atom == prop_accel_default || + atom == prop_accel_profile_default || + atom == prop_calibration_default || + atom == prop_click_method_default || + atom == prop_click_methods_available || + atom == prop_clickfinger_buttonmap_default || + atom == prop_disable_while_typing_default || + atom == prop_left_handed_default || + atom == prop_middle_emulation_default || + atom == prop_mode_groups_available || + atom == prop_mode_groups_buttons || + atom == prop_mode_groups_rings || + atom == prop_mode_groups_strips || + atom == prop_natural_scroll_default || + atom == prop_product_id || + atom == prop_pressure_range_default || + atom == prop_rotation_angle_default || + atom == prop_scroll_button_default || + atom == prop_scroll_buttonlock_default || + atom == prop_scroll_method_default || + atom == prop_scroll_methods_available || + atom == prop_scroll_pixel_distance_default || + atom == prop_scroll_factor_default || + atom == prop_sendevents_available || + atom == prop_sendevents_default || + atom == prop_serial || + atom == prop_tap_buttonmap_default || + atom == prop_tap_default || + atom == prop_tap_drag_default || + atom == prop_tap_drag_lock_default || + atom == prop_tool_id || + atom == prop_device) + return BadAccess; /* read-only */ + else + return Success; + + if (!checkonly && rc == Success) + LibinputApplyConfig(dev); + + return rc; +} + +static Atom +LibinputMakeProperty(DeviceIntPtr dev, + const char *prop_name, + Atom type, + int format, + int len, + void *data) +{ + int rc; + Atom prop = MakeAtom(prop_name, strlen(prop_name), TRUE); + + rc = XIChangeDeviceProperty(dev, prop, type, format, + PropModeReplace, + len, data, FALSE); + if (rc != Success) + return None; + + XISetDevicePropertyDeletable(dev, prop, FALSE); + + return prop; +} + +static void +LibinputInitTapProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + // By default tapping property config is true + BOOL tap = driver_data->options.tapping ? driver_data->options.tapping : TRUE; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return; + + prop_tap = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP, + XA_INTEGER, + 8, + 1, + &tap); + if (!prop_tap) + return; + + tap = libinput_device_config_tap_get_default_enabled(device); + prop_tap_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DEFAULT, + XA_INTEGER, 8, + 1, &tap); +} + +static void +LibinputInitTapDragProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL drag = driver_data->options.tap_drag; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return; + + prop_tap_drag = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG, + XA_INTEGER, 8, + 1, &drag); + if (!prop_tap_drag) + return; + + drag = libinput_device_config_tap_get_default_drag_enabled(device); + prop_tap_drag_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG_DEFAULT, + XA_INTEGER, 8, + 1, &drag); +} + +static void +LibinputInitTapDragLockProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL drag_lock = driver_data->options.tap_drag_lock; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return; + + prop_tap_drag_lock = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG_LOCK, + XA_INTEGER, 8, + 1, &drag_lock); + if (!prop_tap_drag_lock) + return; + + drag_lock = libinput_device_config_tap_get_default_drag_lock_enabled(device); + prop_tap_drag_lock_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT, + XA_INTEGER, 8, + 1, &drag_lock); +} + +static void +LibinputInitTapButtonmapProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + enum libinput_config_tap_button_map map; + BOOL data[2] = {0}; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + map = driver_data->options.tap_button_map; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return; + + switch (map) { + case LIBINPUT_CONFIG_TAP_MAP_LRM: + data[0] = 1; + break; + case LIBINPUT_CONFIG_TAP_MAP_LMR: + data[1] = 1; + break; + default: + break; + } + + prop_tap_buttonmap = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_BUTTONMAP, + XA_INTEGER, 8, + 2, data); + if (!prop_tap_buttonmap) + return; + + map = libinput_device_config_tap_get_default_button_map(device); + memset(data, 0, sizeof(data)); + + switch (map) { + case LIBINPUT_CONFIG_TAP_MAP_LRM: + data[0] = 1; + break; + case LIBINPUT_CONFIG_TAP_MAP_LMR: + data[1] = 1; + break; + default: + break; + } + + prop_tap_buttonmap_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_BUTTONMAP_DEFAULT, + XA_INTEGER, 8, + 2, data); +} + +static void +LibinputInitCalibrationProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + float calibration[9]; + + if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TOUCH|CAP_TABLET)) + return; + + if (!libinput_device_config_calibration_has_matrix(device)) + return; + + /* We use a 9-element matrix just to be closer to the X server's + transformation matrix which also has the full matrix */ + + libinput_device_config_calibration_get_matrix(device, calibration); + calibration[6] = 0.0; + calibration[7] = 0.0; + calibration[8] = 1.0; + + prop_calibration = LibinputMakeProperty(dev, + LIBINPUT_PROP_CALIBRATION, + prop_float, 32, + 9, calibration); + if (!prop_calibration) + return; + + libinput_device_config_calibration_get_default_matrix(device, + calibration); + + prop_calibration_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_CALIBRATION_DEFAULT, + prop_float, 32, + 9, calibration); +} + +static void +LibinputInitAccelProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + float speed = driver_data->options.speed; + uint32_t profile_mask; + enum libinput_config_accel_profile profile; + BOOL profiles[3] = {FALSE}; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + float custom_points_fallback[CUSTOM_ACCEL_NPOINTS_MAX] = {0}; + float custom_points_motion[CUSTOM_ACCEL_NPOINTS_MAX] = {0}; + float custom_points_scroll[CUSTOM_ACCEL_NPOINTS_MAX] = {0}; + size_t custom_npoints_fallback = driver_data->options.accel_points_fallback.npoints; + size_t custom_npoints_motion = driver_data->options.accel_points_motion.npoints; + size_t custom_npoints_scroll = driver_data->options.accel_points_scroll.npoints; + float custom_step_fallback = driver_data->options.accel_points_fallback.step; + float custom_step_motion = driver_data->options.accel_points_motion.step; + float custom_step_scroll = driver_data->options.accel_points_scroll.step; + + for (size_t idx = 0; idx < CUSTOM_ACCEL_NPOINTS_MAX; idx++) { + custom_points_fallback[idx] = driver_data->options.accel_points_fallback.points[idx]; + custom_points_motion[idx] = driver_data->options.accel_points_motion.points[idx]; + custom_points_scroll[idx] = driver_data->options.accel_points_scroll.points[idx]; + } +#endif + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (!libinput_device_config_accel_is_available(device) || + driver_data->capabilities & CAP_TABLET) + return; + + prop_accel = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL, + prop_float, 32, + 1, &speed); + if (!prop_accel) + return; + + speed = libinput_device_config_accel_get_default_speed(device); + prop_accel_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_DEFAULT, + prop_float, 32, + 1, &speed); + + profile_mask = libinput_device_config_accel_get_profiles(device); + if (profile_mask == LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) + return; + + if (profile_mask & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE) + profiles[0] = TRUE; + if (profile_mask & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT) + profiles[1] = TRUE; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + if (profile_mask & LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM) + profiles[2] = TRUE; +#endif + + prop_accel_profiles_available = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE, + XA_INTEGER, 8, + ARRAY_SIZE(profiles), + profiles); + if (!prop_accel_profiles_available) + return; + + memset(profiles, 0, sizeof(profiles)); + + profile = libinput_device_config_accel_get_profile(device); + switch(profile) { + case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE: + profiles[0] = TRUE; + break; + case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT: + profiles[1] = TRUE; + break; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + case LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM: + profiles[2] = TRUE; + break; +#endif + default: + break; + } + + prop_accel_profile_enabled = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_PROFILE_ENABLED, + XA_INTEGER, 8, + ARRAY_SIZE(profiles), + profiles); + if (!prop_accel_profile_enabled) + return; + + memset(profiles, 0, sizeof(profiles)); + + profile = libinput_device_config_accel_get_default_profile(device); + switch(profile) { + case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE: + profiles[0] = TRUE; + break; + case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT: + profiles[1] = TRUE; + break; +#if HAVE_LIBINPUT_CUSTOM_ACCEL + case LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM: + profiles[2] = TRUE; + break; +#endif + default: + break; + } + + prop_accel_profile_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_PROFILE_ENABLED_DEFAULT, + XA_INTEGER, 8, + ARRAY_SIZE(profiles), + profiles); + if (!prop_accel_profile_default) + return; + +#if HAVE_LIBINPUT_CUSTOM_ACCEL + prop_accel_points_fallback = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_FALLBACK, + prop_float, 32, + custom_npoints_fallback, + custom_points_fallback); + prop_accel_step_fallback = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_CUSTOM_STEP_FALLBACK, + prop_float, 32, 1, + &custom_step_fallback); + prop_accel_points_motion = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_MOTION, + prop_float, 32, + custom_npoints_motion, + custom_points_motion); + prop_accel_step_motion = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_CUSTOM_STEP_MOTION, + prop_float, 32, 1, + &custom_step_motion); + prop_accel_points_scroll = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_SCROLL, + prop_float, 32, + custom_npoints_scroll, + custom_points_scroll); + prop_accel_step_scroll = LibinputMakeProperty(dev, + LIBINPUT_PROP_ACCEL_CUSTOM_STEP_SCROLL, + prop_float, 32, 1, + &custom_step_scroll); +#endif +} + +static void +LibinputInitNaturalScrollProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL natural_scroll = driver_data->options.natural_scrolling; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (!libinput_device_config_scroll_has_natural_scroll(device)) + return; + + prop_natural_scroll = LibinputMakeProperty(dev, + LIBINPUT_PROP_NATURAL_SCROLL, + XA_INTEGER, 8, + 1, &natural_scroll); + if (!prop_natural_scroll) + return; + + natural_scroll = libinput_device_config_scroll_get_default_natural_scroll_enabled(device); + prop_natural_scroll_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_NATURAL_SCROLL_DEFAULT, + XA_INTEGER, 8, + 1, &natural_scroll); +} + +static void +LibinputInitSendEventsProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + uint32_t sendevent_modes; + uint32_t sendevents; + BOOL modes[2] = {FALSE}; + + sendevent_modes = libinput_device_config_send_events_get_modes(device); + if (sendevent_modes == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED) + return; + + if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED) + modes[0] = TRUE; + if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE) + modes[1] = TRUE; + + prop_sendevents_available = LibinputMakeProperty(dev, + LIBINPUT_PROP_SENDEVENTS_AVAILABLE, + XA_INTEGER, 8, + 2, modes); + if (!prop_sendevents_available) + return; + + memset(modes, 0, sizeof(modes)); + sendevents = driver_data->options.sendevents; + + switch(sendevents) { + case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED: + modes[0] = TRUE; + break; + case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE: + modes[1] = TRUE; + break; + } + + prop_sendevents_enabled = LibinputMakeProperty(dev, + LIBINPUT_PROP_SENDEVENTS_ENABLED, + XA_INTEGER, 8, + 2, modes); + + if (!prop_sendevents_enabled) + return; + + memset(modes, 0, sizeof(modes)); + sendevent_modes = libinput_device_config_send_events_get_default_mode(device); + if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED) + modes[0] = TRUE; + if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE) + modes[1] = TRUE; + + prop_sendevents_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_SENDEVENTS_ENABLED_DEFAULT, + XA_INTEGER, 8, + 2, modes); +} + +static void +LibinputInitLeftHandedProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL left_handed = driver_data->options.left_handed; + + if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TABLET|CAP_TABLET_TOOL)) + return; + + if (!libinput_device_config_left_handed_is_available(device) || + driver_data->capabilities & CAP_TABLET) + return; + + prop_left_handed = LibinputMakeProperty(dev, + LIBINPUT_PROP_LEFT_HANDED, + XA_INTEGER, 8, + 1, &left_handed); + if (!prop_left_handed) + return; + + left_handed = libinput_device_config_left_handed_get_default(device); + prop_left_handed_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_LEFT_HANDED_DEFAULT, + XA_INTEGER, 8, + 1, &left_handed); +} + +static void +LibinputInitScrollMethodsProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + uint32_t scroll_methods; + enum libinput_config_scroll_method method; + BOOL methods[3] = {FALSE}; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + scroll_methods = libinput_device_config_scroll_get_methods(device); + if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL) + return; + + if (scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) + methods[0] = TRUE; + if (scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE) + methods[1] = TRUE; + if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) + methods[2] = TRUE; + + prop_scroll_methods_available = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE, + XA_INTEGER, 8, + ARRAY_SIZE(methods), + methods); + if (!prop_scroll_methods_available) + return; + + memset(methods, 0, sizeof(methods)); + + method = libinput_device_config_scroll_get_method(device); + switch(method) { + case LIBINPUT_CONFIG_SCROLL_2FG: + methods[0] = TRUE; + break; + case LIBINPUT_CONFIG_SCROLL_EDGE: + methods[1] = TRUE; + break; + case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN: + methods[2] = TRUE; + break; + default: + break; + } + + prop_scroll_method_enabled = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_METHOD_ENABLED, + XA_INTEGER, 8, + ARRAY_SIZE(methods), + methods); + if (!prop_scroll_method_enabled) + return; + + scroll_methods = libinput_device_config_scroll_get_default_method(device); + if (scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) + methods[0] = TRUE; + if (scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE) + methods[1] = TRUE; + if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) + methods[2] = TRUE; + + prop_scroll_method_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT, + XA_INTEGER, 8, + ARRAY_SIZE(methods), + methods); + /* Scroll button and scroll button lock */ + if (libinput_device_config_scroll_get_methods(device) & + LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) { + CARD32 scroll_button = driver_data->options.scroll_button; + BOOL lock_enabled = driver_data->options.scroll_buttonlock; + + prop_scroll_button = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_BUTTON, + XA_CARDINAL, 32, + 1, &scroll_button); + if (!prop_scroll_button) + return; + +#if HAVE_LIBINPUT_SCROLL_BUTTON_LOCK + scroll_button = libinput_device_config_scroll_get_default_button(device); + scroll_button = btn_linux2xorg(scroll_button); + prop_scroll_button_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_BUTTON_DEFAULT, + XA_CARDINAL, 32, + 1, &scroll_button); + prop_scroll_buttonlock = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_BUTTON_LOCK, + XA_INTEGER, 8, + 1, &lock_enabled); + if (!prop_scroll_buttonlock) + return; + + lock_enabled = libinput_device_config_scroll_get_default_button_lock(device); + prop_scroll_buttonlock_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_BUTTON_LOCK_DEFAULT, + XA_INTEGER, 8, + 1, &lock_enabled); +#endif + } +} + +static void +LibinputInitScrollPixelDistanceProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + CARD32 dist = driver_data->options.scroll_pixel_distance; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (!xf86libinput_want_scroll_distance_option(device)) + return; + + prop_scroll_pixel_distance = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE, + XA_CARDINAL, 32, + 1, &dist); + if (!prop_scroll_pixel_distance) + return; + + prop_scroll_pixel_distance_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE_DEFAULT, + XA_CARDINAL, 32, + 1, &dist); +} + +static void +LibinputInitScrollFactorProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + float scroll_factor = driver_data->options.scroll_factor; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + prop_scroll_factor = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_FACTOR, + prop_float, 32, + 1, &scroll_factor); + if (!prop_scroll_factor) + return; + + prop_scroll_factor_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_SCROLL_FACTOR_DEFAULT, + prop_float, 32, + 1, &scroll_factor); + + if (!prop_scroll_factor_default) + return; +} + +static void +LibinputInitClickMethodsProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + uint32_t click_methods; + enum libinput_config_click_method method; + BOOL methods[2] = {FALSE}; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + click_methods = libinput_device_config_click_get_methods(device); + if (click_methods == LIBINPUT_CONFIG_CLICK_METHOD_NONE) + return; + + if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) + methods[0] = TRUE; + if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) + methods[1] = TRUE; + + prop_click_methods_available = LibinputMakeProperty(dev, + LIBINPUT_PROP_CLICK_METHODS_AVAILABLE, + XA_INTEGER, 8, + ARRAY_SIZE(methods), + methods); + if (!prop_click_methods_available) + return; + + memset(methods, 0, sizeof(methods)); + + method = libinput_device_config_click_get_method(device); + switch(method) { + case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS: + methods[0] = TRUE; + break; + case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER: + methods[1] = TRUE; + break; + default: + break; + } + + prop_click_method_enabled = LibinputMakeProperty(dev, + LIBINPUT_PROP_CLICK_METHOD_ENABLED, + XA_INTEGER, 8, + ARRAY_SIZE(methods), + methods); + + if (!prop_click_method_enabled) + return; + + memset(methods, 0, sizeof(methods)); + + method = libinput_device_config_click_get_default_method(device); + switch(method) { + case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS: + methods[0] = TRUE; + break; + case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER: + methods[1] = TRUE; + break; + default: + break; + } + + prop_click_method_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_CLICK_METHOD_ENABLED_DEFAULT, + XA_INTEGER, 8, + ARRAY_SIZE(methods), + methods); +} + +static void +LibinputInitClickfingerButtonmapProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ +#if HAVE_LIBINPUT_CLICKFINGER_BUTTON_MAP + enum libinput_config_clickfinger_button_map map; + BOOL data[2] = {0}; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + uint32_t click_methods = libinput_device_config_click_get_methods(device); + if ((click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) == 0) + return; + + map = driver_data->options.clickfinger_button_map; + + switch (map) { + case LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM: + data[0] = 1; + break; + case LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR: + data[1] = 1; + break; + default: + break; + } + + prop_clickfinger_buttonmap = LibinputMakeProperty(dev, + LIBINPUT_PROP_CLICKFINGER_BUTTONMAP, + XA_INTEGER, 8, + 2, data); + if (!prop_clickfinger_buttonmap) + return; + + map = libinput_device_config_click_get_default_clickfinger_button_map(device); + memset(data, 0, sizeof(data)); + + switch (map) { + case LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM: + data[0] = 1; + break; + case LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR: + data[1] = 1; + break; + default: + break; + } + + prop_clickfinger_buttonmap_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_CLICKFINGER_BUTTONMAP_DEFAULT, + XA_INTEGER, 8, + 2, data); +#endif +} + +static void +LibinputInitMiddleEmulationProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL middle = driver_data->options.middle_emulation; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (!libinput_device_config_middle_emulation_is_available(device)) + return; + + prop_middle_emulation = LibinputMakeProperty(dev, + LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED, + XA_INTEGER, + 8, + 1, + &middle); + if (!prop_middle_emulation) + return; + + middle = libinput_device_config_middle_emulation_get_default_enabled(device); + prop_middle_emulation_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT, + XA_INTEGER, 8, + 1, &middle); +} + +static void +LibinputInitDisableWhileTypingProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL dwt = driver_data->options.disable_while_typing; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (!libinput_device_config_dwt_is_available(device)) + return; + + prop_disable_while_typing = LibinputMakeProperty(dev, + LIBINPUT_PROP_DISABLE_WHILE_TYPING, + XA_INTEGER, + 8, + 1, + &dwt); + if (!prop_disable_while_typing) + return; + + dwt = libinput_device_config_dwt_get_default_enabled(device); + prop_disable_while_typing_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_DISABLE_WHILE_TYPING_DEFAULT, + XA_INTEGER, 8, + 1, &dwt); +} + +static void +LibinputInitModeGroupProperties(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + struct libinput_tablet_pad_mode_group *group; + int ngroups, nmodes, mode; + int nbuttons, nstrips, nrings; + unsigned char groups[4] = {0}, + current[4] = {0}, + associations[MAX_BUTTONS] = {0}; + int g, b, r, s; + + if (!subdevice_has_capabilities(dev, CAP_TABLET_PAD)) + return; + + if (!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_PAD)) + return; + + ngroups = libinput_device_tablet_pad_get_num_mode_groups(device); + if (ngroups <= 0) + return; + + group = libinput_device_tablet_pad_get_mode_group(device, 0); + nmodes = libinput_tablet_pad_mode_group_get_num_modes(group); + if (ngroups == 1 && nmodes == 1) + return; + + ngroups = min(ngroups, ARRAY_SIZE(groups)); + for (g = 0; g < ngroups; g++) { + group = libinput_device_tablet_pad_get_mode_group(device, g); + nmodes = libinput_tablet_pad_mode_group_get_num_modes(group); + mode = libinput_tablet_pad_mode_group_get_mode(group); + + groups[g] = nmodes; + current[g] = mode; + } + + prop_mode_groups_available = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_PAD_MODE_GROUPS_AVAILABLE, + XA_INTEGER, + 8, + ngroups, + groups); + if (!prop_mode_groups_available) + return; + + prop_mode_groups = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_PAD_MODE_GROUPS, + XA_INTEGER, + 8, + ngroups, + current); + if (!prop_mode_groups) + return; + + for (b = 0; b < ARRAY_SIZE(associations); b++) + associations[b] = -1; + + nbuttons = libinput_device_tablet_pad_get_num_buttons(device); + for (b = 0; b < nbuttons; b++) { + /* logical buttons exclude scroll wheel buttons */ + int lb = b <= 3 ? b : b + 4; + associations[lb] = -1; + for (g = 0; g < ngroups; g++) { + group = libinput_device_tablet_pad_get_mode_group(device, g); + if (libinput_tablet_pad_mode_group_has_button(group, b)) { + associations[lb] = g; + break; + } + } + } + + prop_mode_groups_buttons = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_BUTTONS, + XA_INTEGER, + 8, + nbuttons, + associations); + if (!prop_mode_groups_buttons) + return; + + nrings = libinput_device_tablet_pad_get_num_rings(device); + if (nrings) { + for (r = 0; r < nrings; r++) { + associations[r] = -1; + for (g = 0; g < ngroups; g++) { + group = libinput_device_tablet_pad_get_mode_group(device, g); + if (libinput_tablet_pad_mode_group_has_ring(group, r)) { + associations[r] = g; + break; + } + } + } + + prop_mode_groups_rings = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_RINGS, + XA_INTEGER, + 8, + nrings, + associations); + if (!prop_mode_groups_rings) + return; + } + + nstrips = libinput_device_tablet_pad_get_num_strips(device); + if (nstrips) { + for (s = 0; s < nstrips; s++) { + associations[s] = -1; + for (g = 0; g < ngroups; g++) { + group = libinput_device_tablet_pad_get_mode_group(device, g); + if (libinput_tablet_pad_mode_group_has_strip(group, s)) { + associations[s] = g; + break; + } + } + } + + prop_mode_groups_strips = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_PAD_MODE_GROUP_STRIPS, + XA_INTEGER, + 8, + nstrips, + associations); + if (!prop_mode_groups_strips) + return; + } +} + +static void +LibinputInitDragLockProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data) +{ + size_t sz; + int dl_values[MAX_BUTTONS + 1]; + + if ((driver_data->capabilities & CAP_POINTER) == 0) + return; + + switch (draglock_get_mode(&driver_data->draglock)) { + case DRAGLOCK_DISABLED: + sz = 0; /* will be an empty property */ + break; + case DRAGLOCK_META: + dl_values[0] = draglock_get_meta(&driver_data->draglock); + sz = 1; + break; + case DRAGLOCK_PAIRS: + sz = draglock_get_pairs(&driver_data->draglock, + dl_values, ARRAY_SIZE(dl_values)); + break; + default: + xf86IDrvMsg(dev->public.devicePrivate, + X_ERROR, + "Invalid drag lock mode\n"); + return; + } + + prop_draglock = LibinputMakeProperty(dev, + LIBINPUT_PROP_DRAG_LOCK_BUTTONS, + XA_INTEGER, 8, + sz, dl_values); +} + +static void +LibinputInitHorizScrollProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data) +{ + BOOL enabled = driver_data->options.horiz_scrolling_enabled; + + if ((driver_data->capabilities & CAP_POINTER) == 0) + return; + + prop_horiz_scroll = LibinputMakeProperty(dev, + LIBINPUT_PROP_HORIZ_SCROLL_ENABLED, + XA_INTEGER, 8, + 1, &enabled); +} + +static void +LibinputInitRotationAngleProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + float angle = driver_data->options.rotation_angle; + + if (!libinput_device_config_rotation_is_available(device)) + return; + + prop_rotation_angle = LibinputMakeProperty(dev, + LIBINPUT_PROP_ROTATION_ANGLE, + prop_float, 32, + 1, &angle); + if (!prop_rotation_angle) + return; + + angle = libinput_device_config_rotation_get_default_angle(device); + prop_rotation_angle_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_ROTATION_ANGLE_DEFAULT, + prop_float, 32, + 1, &angle); + + if (!prop_rotation_angle_default) + return; +} + +static void +LibinputInitPressureCurveProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data) +{ + const struct bezier_control_point *curve = driver_data->options.pressurecurve; + struct libinput_tablet_tool *tool = driver_data->tablet_tool; + float data[8]; + + if ((driver_data->capabilities & CAP_TABLET_TOOL) == 0) + return; + + if (!tool || !libinput_tablet_tool_has_pressure(tool)) + return; + + data[0] = curve[0].x; + data[1] = curve[0].y; + data[2] = curve[1].x; + data[3] = curve[1].y; + data[4] = curve[2].x; + data[5] = curve[2].y; + data[6] = curve[3].x; + data[7] = curve[3].y; + + prop_pressurecurve = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_TOOL_PRESSURECURVE, + prop_float, 32, + 8, data); +} + +static void +LibinputInitPressureRangeProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data) +{ +#if HAVE_LIBINPUT_PRESSURE_RANGE + struct libinput_tablet_tool *tool = driver_data->tablet_tool; + const struct xf86libinput_pressure_range *rangeopt = &driver_data->options.pressure_range; + float data[2] = { + rangeopt->min, + rangeopt->max, + }; + + if ((driver_data->capabilities & CAP_TABLET_TOOL) == 0) + return; + + + if (!tool || !libinput_tablet_tool_config_pressure_range_is_available(tool)) + return; + + prop_pressure_range = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_TOOL_PRESSURE_RANGE, + prop_float, 32, + 2, &data); + if (!prop_pressure_range) + return; + + data[0] = libinput_tablet_tool_config_pressure_range_get_default_minimum(tool); + data[1] = libinput_tablet_tool_config_pressure_range_get_default_maximum(tool); + prop_pressure_range_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_TOOL_PRESSURE_RANGE_DEFAULT, + prop_float, 32, + 2, &data); + + if (!prop_pressure_range_default) + return; +#endif +} + +static void +LibinputInitTabletAreaRatioProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data) +{ + const struct ratio *ratio = &driver_data->options.area; + uint32_t data[2]; + + if (!want_area_handling(driver_data)) + return; + + data[0] = ratio->x; + data[1] = ratio->y; + + prop_area_ratio = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_TOOL_AREA_RATIO, + XA_CARDINAL, 32, + 2, data); +} + +static void +LibinputInitTabletSerialProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data) +{ + struct libinput_tablet_tool *tool = driver_data->tablet_tool; + uint32_t serial, tool_id; + + if ((driver_data->capabilities & CAP_TABLET_TOOL) == 0) + return; + + if (!tool) + return; + + /* Serial prop is always created to indicate when we don't have a serial */ + serial = libinput_tablet_tool_get_serial(tool); + prop_serial = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_TOOL_SERIAL, + XA_CARDINAL, 32, + 1, &serial); + + /* The tool ID prop is only created if we have a known tool id */ + tool_id = libinput_tablet_tool_get_tool_id(tool); + if (tool_id) { + prop_tool_id = LibinputMakeProperty(dev, + LIBINPUT_PROP_TABLET_TOOL_ID, + XA_CARDINAL, 32, + 1, &tool_id); + } +} + +static void +LibinputInitHighResolutionScrollProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL enabled = driver_data->options.hires_scrolling_enabled; + + if ((driver_data->capabilities & CAP_POINTER) == 0) + return; + + prop_hires_scroll = LibinputMakeProperty(dev, + LIBINPUT_PROP_HIRES_WHEEL_SCROLL_ENABLED, + XA_INTEGER, 8, + 1, &enabled); +} + +static void +LibinputInitProperty(DeviceIntPtr dev) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + const char *device_node; + CARD32 product[2]; + int rc; + + prop_float = XIGetKnownProperty("FLOAT"); + + LibinputInitTapProperty(dev, driver_data, device); + LibinputInitTapDragProperty(dev, driver_data, device); + LibinputInitTapDragLockProperty(dev, driver_data, device); + LibinputInitTapButtonmapProperty(dev, driver_data, device); + LibinputInitNaturalScrollProperty(dev, driver_data, device); + LibinputInitDisableWhileTypingProperty(dev, driver_data, device); + LibinputInitScrollMethodsProperty(dev, driver_data, device); + LibinputInitScrollFactorProperty(dev, driver_data, device); + LibinputInitClickMethodsProperty(dev, driver_data, device); + LibinputInitClickfingerButtonmapProperty(dev, driver_data, device); + LibinputInitMiddleEmulationProperty(dev, driver_data, device); + LibinputInitRotationAngleProperty(dev, driver_data, device); + LibinputInitAccelProperty(dev, driver_data, device); + LibinputInitCalibrationProperty(dev, driver_data, device); + LibinputInitLeftHandedProperty(dev, driver_data, device); + LibinputInitModeGroupProperties(dev, driver_data, device); + LibinputInitSendEventsProperty(dev, driver_data, device); + + /* Device node property, read-only */ + device_node = driver_data->path; + prop_device = MakeAtom(XI_PROP_DEVICE_NODE, + strlen(XI_PROP_DEVICE_NODE), + TRUE); + rc = XIChangeDeviceProperty(dev, prop_device, XA_STRING, 8, + PropModeReplace, + strlen(device_node), device_node, + FALSE); + if (rc != Success) + return; + + XISetDevicePropertyDeletable(dev, prop_device, FALSE); + + prop_product_id = MakeAtom(XI_PROP_PRODUCT_ID, + strlen(XI_PROP_PRODUCT_ID), + TRUE); + product[0] = libinput_device_get_id_vendor(device); + product[1] = libinput_device_get_id_product(device); + rc = XIChangeDeviceProperty(dev, prop_product_id, XA_INTEGER, 32, + PropModeReplace, 2, product, FALSE); + if (rc != Success) + return; + + XISetDevicePropertyDeletable(dev, prop_product_id, FALSE); + + LibinputInitDragLockProperty(dev, driver_data); + LibinputInitHorizScrollProperty(dev, driver_data); + LibinputInitScrollPixelDistanceProperty(dev, driver_data, device); + LibinputInitPressureCurveProperty(dev, driver_data); + LibinputInitPressureRangeProperty(dev, driver_data); + LibinputInitTabletAreaRatioProperty(dev, driver_data); + LibinputInitTabletSerialProperty(dev, driver_data); + LibinputInitHighResolutionScrollProperty(dev, driver_data, device); +} diff --git a/src/xf86-input-libinput/test/.gitignore b/src/xf86-input-libinput/test/.gitignore new file mode 100644 index 0000000..48a46e3 --- /dev/null +++ b/src/xf86-input-libinput/test/.gitignore @@ -0,0 +1 @@ +test-draglock diff --git a/src/xf86-input-libinput/test/Makefile.am b/src/xf86-input-libinput/test/Makefile.am new file mode 100644 index 0000000..4c9c5f6 --- /dev/null +++ b/src/xf86-input-libinput/test/Makefile.am @@ -0,0 +1,16 @@ +AM_CPPFLAGS = $(XORG_CFLAGS) \ + $(CWARNFLAGS) \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src + +tests = test-draglock test-bezier + +noinst_PROGRAMS = $(tests) + +test_draglock_SOURCES = test-draglock.c +test_draglock_LDADD = ../src/libdraglock.la + +test_bezier_SOURCES = test-bezier.c +test_bezier_LDADD = ../src/libbezier.la -lm + +TESTS = $(tests) diff --git a/src/xf86-input-libinput/test/test-bezier.c b/src/xf86-input-libinput/test/test-bezier.c new file mode 100644 index 0000000..5596bc5 --- /dev/null +++ b/src/xf86-input-libinput/test/test-bezier.c @@ -0,0 +1,208 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2016 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "bezier.h" + +#include +#include +#include + +static inline void +print_curve(int *bezier, size_t size) +{ + /* look at it with gnuplot, "plot 'output-file.txt'" */ + for (int i = 0; i < size; i++) + printf("%d %d\n", i, bezier[i]); +} + +static void +test_linear(void) +{ + const int size = 2048; + int bezier[size]; + + struct bezier_control_point controls[] = { + { 0.0, 0.0 }, + { 0.0, 0.0 }, + { 1.0, 1.0 }, + { 1.0, 1.0 } + }; + + cubic_bezier(controls, bezier, size); + + assert(bezier[0] == 0); + assert(bezier[size - 1] == size - 1); + + for (int x = 1; x < size; x++) + assert(bezier[x] == x); +} + +/* Center point pulled down towards X axis */ +static void +test_flattened(void) +{ + const int size = 2048; + int bezier[size]; + + struct bezier_control_point controls[] = { + { 0.0, 0.0 }, + { 0.1, 0.0 }, + { 1.0, 0.9 }, + { 1.0, 1.0 } + }; + + cubic_bezier(controls, bezier, size); + + assert(bezier[0] == 0); + assert(bezier[size - 1] == size - 1); + + for (int x = 1; x < size - 1; x++) { + assert(bezier[x] < x); + } +} + +/* Center point pulled up from X axis */ +static void +test_raised(void) +{ + const int size = 2048; + int bezier[size]; + + struct bezier_control_point controls[] = { + { 0.0, 0.0 }, + { 0.1, 0.4 }, + { 0.4, 1.0 }, + { 1.0, 1.0 } + }; + + cubic_bezier(controls, bezier, size); + + assert(bezier[0] == 0); + assert(bezier[size - 1] == size - 1); + + for (int x = 1; x < size; x++) + assert(bezier[x] >= x); + + for (int x = 10; x < size - 10; x++) + assert(bezier[x] > x); +} + +static void +test_windy(void) +{ + const int size = 2048; + int bezier[size]; + + struct bezier_control_point controls[] = { + { 0.0, 0.0 }, + { 0.0, 0.3 }, + { 1.0, 0.7 }, + { 1.0, 1.0 } + }; + + cubic_bezier(controls, bezier, size); + + assert(bezier[0] == 0); + assert(bezier[size - 1] == size - 1); + + for (int x = 1; x < size/2 - 20; x++) + assert(bezier[x] > x); + + for (int x = size/2 + 20; x < size - 1; x++) + assert(bezier[x] < x); +} + +static void +test_nonzero_x_linear(void) +{ + const int size = 2048; + int bezier[size]; + int x; + + struct bezier_control_point controls[] = { + { 0.2, 0.0 }, + { 0.2, 0.0 }, + { 0.8, 1.0 }, + { 0.8, 1.0 } + }; + + cubic_bezier(controls, bezier, size); + + x = 0; + do { + assert(bezier[x] == 0); + } while (++x < size * 0.2 - 1); + + /* ppc64le, ppc64, aarch64 have different math results at -O2, + resulting in one extra zero at the beginning of the array. + some other numbers are different too but within the error + margin (#99992) */ + if (bezier[x] == 0) + x++; + + do { + assert(bezier[x] > bezier[x-1]); + } while (++x < size * 0.8 - 1); + + do { + assert(bezier[x] == size - 1); + } while (++x < size); +} + +static void +test_nonzero_y_linear(void) +{ + const int size = 2048; + int bezier[size]; + + struct bezier_control_point controls[] = { + { 0.0, 0.2 }, + { 0.0, 0.2 }, + { 1.0, 0.8 }, + { 1.0, 0.8 } + }; + + cubic_bezier(controls, bezier, size); + + assert(bezier[0] == (int)(size * 0.2)); + + for (int x = 1; x < size; x++) { + assert(bezier[x - 1] <= bezier[x]); + assert(bezier[x] >= (int)(size * 0.2)); + } +} + +int +main(int argc, char **argv) +{ + test_linear(); + test_flattened(); + test_raised(); + test_windy(); + test_nonzero_x_linear(); + test_nonzero_y_linear(); + + return 0; +} diff --git a/src/xf86-input-libinput/test/test-draglock.c b/src/xf86-input-libinput/test/test-draglock.c new file mode 100644 index 0000000..d2a7bc2 --- /dev/null +++ b/src/xf86-input-libinput/test/test-draglock.c @@ -0,0 +1,548 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2013-2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "draglock.h" + +#include +#include + +static void +test_config_empty(void) +{ + struct draglock dl; + int rc; + + rc = draglock_init_from_string(&dl, NULL); + assert(dl.mode == DRAGLOCK_DISABLED); + assert(rc == 0); +} + +static void +test_config_invalid(void) +{ + struct draglock dl; + int rc; + + /* no trailing space */ + rc = draglock_init_from_string(&dl, "1 "); + assert(rc != 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_init_from_string(&dl, "256"); + assert(rc != 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_init_from_string(&dl, "-1"); + assert(rc != 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_init_from_string(&dl, "1 2 3"); + assert(rc != 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_init_from_string(&dl, "0 2"); + assert(rc != 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_init_from_string(&dl, "0 0"); + assert(rc != 0); + assert(dl.mode == DRAGLOCK_DISABLED); +} + +static void +test_config_disable(void) +{ + struct draglock dl; + int rc; + + rc = draglock_init_from_string(&dl, ""); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_init_from_string(&dl, "0"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_DISABLED); +} + +static void +test_config_meta_button(void) +{ + struct draglock dl; + int rc; + + rc = draglock_init_from_string(&dl, "1"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_META); + assert(dl.meta_button == 1); + + rc = draglock_init_from_string(&dl, "2"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_META); + assert(dl.meta_button == 2); + + rc = draglock_init_from_string(&dl, "10"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_META); + assert(dl.meta_button == 10); +} + +static void +test_config_button_pairs(void) +{ + struct draglock dl; + int rc; + + rc = draglock_init_from_string(&dl, "1 1"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_PAIRS); + + rc = draglock_init_from_string(&dl, "1 2 3 4 5 6 7 8"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_PAIRS); + + rc = draglock_init_from_string(&dl, "1 2 3 4 5 0 7 8"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_PAIRS); + + /* all disabled */ + rc = draglock_init_from_string(&dl, "1 0 3 0 5 0 7 0"); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_DISABLED); +} + +static void +test_config_get(void) +{ + struct draglock dl; + int rc; + const int sz = 32; + int map[sz]; + + draglock_init_from_string(&dl, ""); + rc = draglock_get_meta(&dl); + assert(rc == 0); + rc = draglock_get_pairs(&dl, map, sz); + assert(rc == 0); + + draglock_init_from_string(&dl, "8"); + rc = draglock_get_meta(&dl); + assert(rc == 8); + rc = draglock_get_pairs(&dl, map, sz); + assert(rc == 0); + + draglock_init_from_string(&dl, "1 2 3 4 5 6"); + rc = draglock_get_meta(&dl); + assert(rc == 0); + rc = draglock_get_pairs(&dl, map, sz); + assert(rc == 5); + assert(map[0] == 0); + assert(map[1] == 2); + assert(map[2] == 0); + assert(map[3] == 4); + assert(map[4] == 0); + assert(map[5] == 6); +} + +static void +test_set_meta(void) +{ + struct draglock dl; + int rc; + + draglock_init_from_string(&dl, ""); + + rc = draglock_set_meta(&dl, 0); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_set_meta(&dl, 1); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_META); + + rc = draglock_set_meta(&dl, -1); + assert(rc == 1); + rc = draglock_set_meta(&dl, 32); + assert(rc == 1); +} + +static void +test_set_pairs(void) +{ + struct draglock dl; + int rc; + const int sz = 32; + int map[sz]; + + draglock_init_from_string(&dl, ""); + memset(map, 0, sizeof(map)); + + rc = draglock_set_pairs(&dl, map, sz); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + rc = draglock_set_pairs(&dl, map, 1); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_DISABLED); + + map[0] = 1; + rc = draglock_set_pairs(&dl, map, 1); + assert(rc == 1); + + map[0] = 0; + map[1] = 2; + rc = draglock_set_pairs(&dl, map, sz); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_PAIRS); + + map[0] = 0; + map[1] = 0; + map[10] = 8; + rc = draglock_set_pairs(&dl, map, sz); + assert(rc == 0); + assert(dl.mode == DRAGLOCK_PAIRS); +} + +static void +test_filter_meta_passthrough(void) +{ + struct draglock dl; + int rc; + int button, press; + int i; + + rc = draglock_init_from_string(&dl, "10"); + assert(rc == 0); + + for (i = 0; i < 10; i++) { + button = i; + press = 1; + + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + assert(press == 1); + + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + assert(press == 1); + } +} + +static void +test_filter_meta_click_meta_only(void) +{ + struct draglock dl; + int rc; + int button, press; + + rc = draglock_init_from_string(&dl, "10"); + assert(rc == 0); + + button = 10; + press = 1; + + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + button = 10; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); +} + +static void +test_filter_meta(void) +{ + struct draglock dl; + int rc; + int button, press; + int i; + + rc = draglock_init_from_string(&dl, "10"); + assert(rc == 0); + + for (i = 1; i < 10; i++) { + /* meta down */ + button = 10; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* meta up */ + button = 10; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button down -> passthrough */ + button = i; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + + /* button up -> eaten */ + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button down -> eaten */ + button = i; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button up -> passthrough */ + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + assert(press == 0); + } +} + +static void +test_filter_meta_extra_click(void) +{ + struct draglock dl; + int rc; + int button, press; + int i; + + rc = draglock_init_from_string(&dl, "10"); + assert(rc == 0); + + for (i = 1; i < 10; i++) { + /* meta down */ + button = 10; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* meta up */ + button = 10; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button down -> passthrough */ + button = i; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + + /* button up -> eaten */ + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* meta down */ + button = 10; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* meta up */ + button = 10; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button down -> eaten */ + button = i; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button up -> passthrough */ + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + assert(press == 0); + } +} + +static void +test_filter_meta_interleaved(void) +{ + struct draglock dl; + int rc; + int button, press; + int i; + + rc = draglock_init_from_string(&dl, "10"); + assert(rc == 0); + + for (i = 1; i < 10; i++) { + /* meta down */ + button = 10; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* meta up */ + button = 10; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button down -> passthrough */ + button = i; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + + /* button up -> eaten */ + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + } + + for (i = 0; i < 10; i++) { + /* button down -> eaten */ + button = i; + press = 1; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == 0); + + /* button up -> passthrough */ + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + assert(button == i); + assert(press == 0); + } +} + +static void +test_filter_pairs(void) +{ + struct draglock dl; + int rc; + int button, press; + int i; + + rc = draglock_init_from_string(&dl, "1 11 2 0 3 13 4 0 5 15 6 0 7 17 8 0 9 19"); + assert(rc == 0); + + for (i = 1; i < 10; i++) { + button = i; + press = 1; + + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + if (i % 2) + assert(button == i + 10); + else + assert(button == i); + assert(press == 1); + + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + if (i % 2) { + assert(button == 0); + } else { + assert(button == i); + assert(press == 0); + } + } + + for (i = 1; i < 10; i++) { + button = i; + press = 1; + + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + if (i % 2) { + assert(button == 0); + } else { + assert(button == i); + assert(press == 1); + } + + button = i; + press = 0; + rc = draglock_filter_button(&dl, &button, &press); + assert(rc == 0); + if (i % 2) + assert(button == i + 10); + else + assert(button == i); + assert(press == 0); + } +} + +int +main(int argc, char **argv) +{ + test_config_empty(); + test_config_invalid(); + test_config_disable(); + test_config_meta_button(); + test_config_button_pairs(); + + test_config_get(); + test_set_meta(); + test_set_pairs(); + + test_filter_meta_passthrough(); + test_filter_meta_click_meta_only(); + test_filter_meta(); + test_filter_meta_extra_click(); + test_filter_meta_interleaved(); + + test_filter_pairs(); + + return 0; +} diff --git a/src/xf86-input-libinput/xorg-libinput.pc.in b/src/xf86-input-libinput/xorg-libinput.pc.in new file mode 100644 index 0000000..ff98189 --- /dev/null +++ b/src/xf86-input-libinput/xorg-libinput.pc.in @@ -0,0 +1,6 @@ +sdkdir=@sdkdir@ + +Name: xorg-libinput +Description: X.Org libinput input driver. +Version: @PACKAGE_VERSION@ +Cflags: -I${sdkdir} diff --git a/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/01-bug-report.yml b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/01-bug-report.yml new file mode 100644 index 0000000..dc12de7 --- /dev/null +++ b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/01-bug-report.yml @@ -0,0 +1,65 @@ +name: 🐞 Bug report +description: Create a report to help us improve + +labels: [bug, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to help everyone identify and fix the bug. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: dropdown + id: affected-version + attributes: + label: Select the version + options: + - 0.5.1.1 + - Git master branch + - other or don't know + default: 1 + validations: + required: true + - type: textarea + id: description + attributes: + label: Describe your issue + placeholder: When I did X then Y happened. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + placeholder: | + 1. Start ... + 2. Do this + 3. Do that + validations: + required: true + - type: textarea + id: expected + attributes: + label: What did you expect? + placeholder: I expected this to happen. + - type: textarea + id: environment + attributes: + label: Additional Information + description: | + Additional information you want to provide such as logs, system info, environment, screenshots, etc. + placeholder: | + Add any other context about the bug here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-video-fbdev/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for reporting this issue! We will get back to you as soon as possible. diff --git a/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/02-feature-request.yml b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/02-feature-request.yml new file mode 100644 index 0000000..fed7d15 --- /dev/null +++ b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/02-feature-request.yml @@ -0,0 +1,49 @@ +name: ✨ Feature request +description: Suggest a feature for this software +labels: [enhancement, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to properly describe the new software feature you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: "Describe the feature" + placeholder: A thing in X that allows to do Y. + validations: + required: true + - type: textarea + id: rationale + attributes: + label: "It should be done because" + placeholder: Doing Y is needed for Z. + validations: + required: true + - type: textarea + id: alternative + attributes: + label: "What are the alternatives?" + placeholder: We could do A or B instead. + - type: textarea + id: context + attributes: + label: Additional context + description: Additional information you want to provide such as references to related issues or protocols, the implications on existing use cases, etc. + placeholder: | + Add any other context about the feature request here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-video-fbdev/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for your suggestion! Let's see together if it can be done. diff --git a/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/03-code-cleanup.yml b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/03-code-cleanup.yml new file mode 100644 index 0000000..63513fa --- /dev/null +++ b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/03-code-cleanup.yml @@ -0,0 +1,49 @@ +name: 🔧 Code cleanup +description: Level up the source code +labels: [code-cleanup, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to properly describe the code cleanup you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: "Describe the cleanup" + placeholder: C in X needs to be changed into D. + validations: + required: true + - type: textarea + id: rationale + attributes: + label: "It should be done because" + placeholder: Having D is needed for E. + validations: + required: true + - type: textarea + id: alternative + attributes: + label: "What are the alternatives?" + placeholder: We could do A or B instead. + - type: textarea + id: context + attributes: + label: Additional context + description: Additional information you want to provide such as implications on existing code, how to ensure API/ABI stability, which tests are needed or to be run, related issues, etc. + placeholder: | + Add any other context about the cleanup here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-video-fbdev/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for looking at the source code! Let's see together how it can be improved. diff --git a/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/04-doc-update.yml b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/04-doc-update.yml new file mode 100644 index 0000000..18c619e --- /dev/null +++ b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/04-doc-update.yml @@ -0,0 +1,38 @@ +name: 🔖 Documentation update +description: Make your mark for better documentation + +labels: [documentation, needs-triage] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to help others understand our software. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: Describe the update + placeholder: These things need to be better documented. + validations: + required: true + - type: textarea + id: environment + attributes: + label: Additional Information + description: Additional information you want to provide such as tickets related to changes in the software, affected files, screenshots, etc. + placeholder: | + Add any other context about the update here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-video-fbdev/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for requesting this update! We will get back to you as soon as possible. diff --git a/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/05-org-task.yml b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/05-org-task.yml new file mode 100644 index 0000000..e70d1b8 --- /dev/null +++ b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/05-org-task.yml @@ -0,0 +1,43 @@ +name: ✅ Organizational task +description: Create a task for project organization + +labels: [needs-triage, organization] + +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to get organizational things done. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions). + - type: textarea + id: description + attributes: + label: Describe the task + placeholder: These things need to be done. + validations: + required: true + - type: textarea + id: rationale + attributes: + label: "It should be done because" + placeholder: Doing Y is needed for Z. + - type: textarea + id: environment + attributes: + label: Additional Information + description: Additional information you want to provide such as the context for bigger tasks, the implicatons on existing workflows, related issues, etc. + placeholder: | + Add any other context about the task here. + - type: checkboxes + id: checks + attributes: + label: Extra fields + options: + - label: I have checked the existing [issues](https://github.com/X11Libre/xf86-video-fbdev/issues) + required: true + - label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md) + required: true + - label: I'd like to work on this issue + - type: markdown + attributes: + value: | + Thanks for adding this task! We will get back to you as soon as possible. diff --git a/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/config.yml b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..5d1b3a8 --- /dev/null +++ b/src/xf86-video-fbdev/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: XLibre Community Support + url: https://github.com/orgs/X11Libre/discussions + about: Please ask and answer questions here. + - name: Mailing List + url: https://www.freelists.org/list/xlibre + about: You can join the discussions on our mailing list. diff --git a/src/xf86-video-fbdev/.github/workflows/build.yml b/src/xf86-video-fbdev/.github/workflows/build.yml new file mode 100644 index 0000000..25307e7 --- /dev/null +++ b/src/xf86-video-fbdev/.github/workflows/build.yml @@ -0,0 +1,58 @@ +permissions: + contents: write + +on: + push: + pull_request: + +jobs: + ubuntu: + strategy: + matrix: + xserver-version: [ master, xlibre-xserver-25.1.0, xlibre-xserver-25.0.0.18 ] + runs-on: ubuntu-latest + steps: + - uses: X11Libre/action-build-driver/target/ubuntu@v0.4.0 + with: + xserver-version: ${{ matrix.xserver-version }} + + freebsd: + strategy: + matrix: + xserver-version: [ master, xlibre-xserver-25.1.0, xlibre-xserver-25.0.0.18 ] + runs-on: ubuntu-latest + steps: + - uses: X11Libre/action-build-driver/target/freebsd@v0.4.0 + with: + xserver-version: ${{ matrix.xserver-version }} + + dragonfly: + strategy: + matrix: + # xlibre-xserver-25.0.x not compiling on dragonfly yet + xserver-version: [ master, xlibre-xserver-25.1.0 ] + runs-on: ubuntu-latest + steps: + - uses: X11Libre/action-build-driver/target/dragonfly@v0.4.0 + with: + xserver-version: ${{ matrix.xserver-version }} + + netbsd: + strategy: + matrix: + xserver-version: [ master, xlibre-xserver-25.1.0 ] + runs-on: ubuntu-latest + steps: + - uses: X11Libre/action-build-driver/target/netbsd@v0.4.0 + with: + xserver-version: ${{ matrix.xserver-version }} + + release-notes: + name: Release pushed tag + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/xlibre-') }} + needs: [ ubuntu, freebsd, dragonfly, netbsd ] + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: X11Libre/action-build-driver/release@v0.4.0 diff --git a/src/xf86-video-fbdev/.gitignore b/src/xf86-video-fbdev/.gitignore new file mode 100644 index 0000000..61135d2 --- /dev/null +++ b/src/xf86-video-fbdev/.gitignore @@ -0,0 +1,78 @@ +# +# X.Org module default exclusion patterns +# The next section if for module specific patterns +# +# Do not edit the following section +# GNU Build System (Autotools) +aclocal.m4 +autom4te.cache/ +autoscan.log +ChangeLog +compile +config.guess +config.h +config.h.in +config.log +config-ml.in +config.py +config.status +config.status.lineno +config.sub +configure +configure.scan +depcomp +.deps/ +INSTALL +install-sh +.libs/ +libtool +libtool.m4 +ltmain.sh +lt~obsolete.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 +Makefile +Makefile.in +mdate-sh +missing +mkinstalldirs +*.pc +py-compile +stamp-h? +symlink-tree +texinfo.tex +ylwrap + +# Do not edit the following section +# Edit Compile Debug Document Distribute +*~ +*.[0-9] +*.[0-9]x +*.bak +*.bin +core +*.dll +*.exe +*-ISO*.bdf +*-JIS*.bdf +*-KOI8*.bdf +*.kld +*.ko +*.ko.cmd +*.lai +*.l[oa] +*.[oa] +*.obj +*.patch +*.so +*.pcf.gz +*.pdb +*.tar.bz2 +*.tar.gz +# +# Add & Override patterns for xf86-video-fbdev +# +# Edit the following section as needed +# For example, !report.pc overrides *.pc. See 'man gitignore' +# diff --git a/src/xf86-video-fbdev/COPYING b/src/xf86-video-fbdev/COPYING new file mode 100644 index 0000000..c513618 --- /dev/null +++ b/src/xf86-video-fbdev/COPYING @@ -0,0 +1,23 @@ +Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is fur- +nished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- +NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the XFree86 Project shall not +be used in advertising or otherwise to promote the sale, use or other deal- +ings in this Software without prior written authorization from the XFree86 +Project. diff --git a/src/xf86-video-fbdev/Makefile.am b/src/xf86-video-fbdev/Makefile.am new file mode 100644 index 0000000..bc45146 --- /dev/null +++ b/src/xf86-video-fbdev/Makefile.am @@ -0,0 +1,38 @@ +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# During distcheck, system locations (as provided by pkg-config) may +# not be writable; provide instead relative locations. +DISTCHECK_CONFIGURE_FLAGS = --with-xorg-module-dir='$${libdir}/xorg/modules' + +SUBDIRS = src man +MAINTAINERCLEANFILES = ChangeLog INSTALL + +.PHONY: ChangeLog INSTALL + +INSTALL: + $(INSTALL_CMD) + +ChangeLog: + $(CHANGELOG_CMD) + +dist-hook: ChangeLog INSTALL + +EXTRA_DIST = README.md diff --git a/src/xf86-video-fbdev/README.md b/src/xf86-video-fbdev/README.md new file mode 100644 index 0000000..d725310 --- /dev/null +++ b/src/xf86-video-fbdev/README.md @@ -0,0 +1,8 @@ +xf86-video-fbdev - video driver for framebuffer device +------------------------------------------------------ + +The primary development code repository can be found at: + + https://github.com/X11Libre/xf86-video-fbdev + +Please submit bug reports and requests to merge patches there. diff --git a/src/xf86-video-fbdev/autogen.sh b/src/xf86-video-fbdev/autogen.sh new file mode 100755 index 0000000..9a13326 --- /dev/null +++ b/src/xf86-video-fbdev/autogen.sh @@ -0,0 +1,17 @@ +#! /bin/sh + +srcdir=`dirname "$0"` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd "$srcdir" + +autoreconf -v --install || exit 1 +cd "$ORIGDIR" || exit $? + +git config --local --get format.subjectPrefix >/dev/null 2>&1 || + git config --local format.subjectPrefix "PATCH xf86-video-fbdev" + +if test -z "$NOCONFIGURE"; then + exec "$srcdir"/configure "$@" +fi diff --git a/src/xf86-video-fbdev/configure.ac b/src/xf86-video-fbdev/configure.ac new file mode 100644 index 0000000..c922282 --- /dev/null +++ b/src/xf86-video-fbdev/configure.ac @@ -0,0 +1,64 @@ +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Process this file with autoconf to produce a configure script + +# Initialize Autoconf +AC_PREREQ([2.60]) +AC_INIT([xlibre-xf86-video-fbdev], + [25.0.0], + [https://github.com/X11Libre/xf86-video-fbdev/issues], + [xlibrexf86-video-fbdev]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_AUX_DIR(.) + +# Initialize Automake +AM_INIT_AUTOMAKE([foreign dist-xz]) + +# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.8) +XORG_DEFAULT_OPTIONS + +# Initialize libtool +LT_INIT([disable-static]) + +AH_TOP([#include "xorg-server.h"]) + +# Define a configure option for an alternate module directory +PKG_PROG_PKG_CONFIG([0.25]) + +xlibre_video_drivers_dir=`$PKG_CONFIG --variable=video_drivers_dir xlibre-server` +AC_SUBST(xlibre_video_drivers_dir) + +# Store the list of server defined optional extensions in REQUIRED_MODULES +XORG_DRIVER_CHECK_EXT(RANDR, randrproto) +XORG_DRIVER_CHECK_EXT(RENDER, renderproto) +XORG_DRIVER_CHECK_EXT(XV, videoproto) + +# Obtain compiler/linker options for the driver dependencies +PKG_CHECK_MODULES(XORG, [xorg-server >= 25.0.0 xproto fontsproto $REQUIRED_MODULES]) +PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) +XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" + +AC_CONFIG_FILES([Makefile src/Makefile man/Makefile]) +AC_OUTPUT diff --git a/src/xf86-video-fbdev/man/Makefile.am b/src/xf86-video-fbdev/man/Makefile.am new file mode 100644 index 0000000..a542592 --- /dev/null +++ b/src/xf86-video-fbdev/man/Makefile.am @@ -0,0 +1,42 @@ +# $Id$ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +drivermandir = $(DRIVER_MAN_DIR) + +driverman_PRE = fbdev.man + +driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@) + +EXTRA_DIST = fbdev.man + +CLEANFILES = $(driverman_DATA) + + +# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure + + +SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man + +.man.$(DRIVER_MAN_SUFFIX): + $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@ diff --git a/src/xf86-video-fbdev/man/fbdev.man b/src/xf86-video-fbdev/man/fbdev.man new file mode 100644 index 0000000..ee3f55c --- /dev/null +++ b/src/xf86-video-fbdev/man/fbdev.man @@ -0,0 +1,77 @@ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH FBDEV __drivermansuffix__ __vendorversion__ +.SH NAME +fbdev \- video driver for framebuffer device +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qfbdev\*q" +.BI " BusID \*qpci:" bus : dev : func \*q +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B fbdev +is an +.B __xservername__ +driver for framebuffer devices. +This is a non-accelerated driver, +the following framebuffer depths are supported: 8, 15, 16, 24. +All visual types are supported for depth 8, +and TrueColor visual is supported for the other depths. +Multi-head configurations are supported. +.SH SUPPORTED HARDWARE +The +.B fbdev +driver supports all hardware where a framebuffer driver is available. +fbdev uses the os-specific submodule +.BR fbdevhw (__drivermansuffix__) +to talk to the kernel device driver. +Currently a fbdevhw module is available for Linux. +.SH CONFIGURATION DETAILS +Please refer to +.BR __xconfigfile__ (__filemansuffix__) +for general configuration details. +This section only covers configuration details specific to this driver. +.PP +For this driver it is not required to specify modes +in the screen section of the config file. +The +.B fbdev +driver can pick up the currently used video mode from the framebuffer +driver and will use it if there are no video modes configured. +.PP +For PCI boards you might have to add a BusID line to the Device section. +See above for a sample line. +.PP +The following driver +.B Options +are supported: +.TP +.BI "Option \*qfbdev\*q \*q" string \*q +The framebuffer device to use. +Default: /dev/fb0. +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Enable or disable use of the shadow framebuffer layer. +Mandatory for 24bpp framebuffers on newer servers. +Default: on. +.TP +.BI "Option \*qRotate\*q \*q" string \*q +Enable rotation of the display. +The supported values are "CW" (clockwise, 90 degrees), +"UD" (upside down, 180 degrees) +and "CCW" (counter clockwise, 270 degrees). +Implies use of the shadow framebuffer layer. +Disabled for 24bpp framebuffers. +Default: off. +.SH "SEE ALSO" +.BR __xservername__ (__appmansuffix__), +.BR __xconfigfile__ (__filemansuffix__), +.BR Xserver (__appmansuffix__), +.BR X (__miscmansuffix__), +.BR fbdevhw (__drivermansuffix__) +.SH AUTHORS +Authors include: Gerd Knorr, Michel D\(:anzer, Geert Uytterhoeven diff --git a/src/xf86-video-fbdev/src/Makefile.am b/src/xf86-video-fbdev/src/Makefile.am new file mode 100644 index 0000000..ff72407 --- /dev/null +++ b/src/xf86-video-fbdev/src/Makefile.am @@ -0,0 +1,32 @@ +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# this is obnoxious: +# -module lets us name the module exactly how we want +# -avoid-version prevents gratuitous .0.0.0 version numbers on the end +# _ladir passes a dummy rpath to libtool so the thing will actually link +# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. +AM_CFLAGS = $(BASE_CFLAGS) $(XORG_CFLAGS) +fbdev_drv_la_LTLIBRARIES = fbdev_drv.la +fbdev_drv_la_LDFLAGS = -module -avoid-version +fbdev_drv_ladir = @xlibre_video_drivers_dir@ + +fbdev_drv_la_SOURCES = \ + fbdev.c diff --git a/src/xf86-video-fbdev/src/fbdev.c b/src/xf86-video-fbdev/src/fbdev.c new file mode 100644 index 0000000..6e3b9e7 --- /dev/null +++ b/src/xf86-video-fbdev/src/fbdev.c @@ -0,0 +1,1200 @@ +/* + * Authors: Alan Hourihane, + * Michel Dänzer, + */ +#include "config.h" + +#include + +/* all driver need this */ +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "mipointer.h" +#include "micmap.h" +#include "colormapst.h" +#include "xf86cmap.h" +#include "shadow.h" +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +/* for visuals */ +#include "fb.h" + +#include "fbdevhw.h" + +#ifdef XV +#include "xf86xv.h" +#endif + +#include + +/* for xf86{Depth,FbBpp}. i am a terrible person, and i am sorry. */ +#include "xf86Priv.h" + +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 23 +#define HAVE_SHADOW_3224 +#endif + +static Bool debug = 0; + +#define TRACE_ENTER(str) \ + do { if (debug) ErrorF("fbdev: " str " %d\n",pScrn->scrnIndex); } while (0) +#define TRACE_EXIT(str) \ + do { if (debug) ErrorF("fbdev: " str " done\n"); } while (0) +#define TRACE(str) \ + do { if (debug) ErrorF("fbdev trace: " str "\n"); } while (0) + +/* -------------------------------------------------------------------- */ +/* prototypes */ + +static const OptionInfoRec * FBDevAvailableOptions(int chipid, int busid); +static void FBDevIdentify(int flags); +static Bool FBDevProbe(DriverPtr drv, int flags); +static Bool FBDevPciProbe(DriverPtr drv, int entity_num, + struct pci_device *dev, intptr_t match_data); +static Bool FBDevPreInit(ScrnInfoPtr pScrn, int flags); +static Bool FBDevScreenInit(ScreenPtr pScreen, int argc, char **argv); +static Bool FBDevCloseScreen(ScreenPtr pScreen); +static void * FBDevWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, + CARD32 *size, void *closure); +static void FBDevPointerMoved(ScrnInfoPtr pScrn, int x, int y); +static Bool FBDevDGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen); +static Bool FBDevDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, + void *ptr); + + +enum { FBDEV_ROTATE_NONE=0, FBDEV_ROTATE_CW=270, FBDEV_ROTATE_UD=180, FBDEV_ROTATE_CCW=90 }; + + +/* -------------------------------------------------------------------- */ + +#define FBDEV_VERSION 4000 +#define FBDEV_NAME "FBDEV" +#define FBDEV_DRIVER_NAME "fbdev" + +static const struct pci_id_match fbdev_device_match[] = { + { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + 0x00030000, 0x00ffffff, 0 + }, + + { 0, 0, 0 }, +}; + +_X_EXPORT DriverRec FBDEV = { + FBDEV_VERSION, + FBDEV_DRIVER_NAME, +#if 0 + "driver for linux framebuffer devices", +#endif + FBDevIdentify, + FBDevProbe, + FBDevAvailableOptions, + NULL, + 0, + FBDevDriverFunc, + fbdev_device_match, + FBDevPciProbe +}; + +/* Supported "chipsets" */ +static SymTabRec FBDevChipsets[] = { + { 0, "fbdev" }, + {-1, NULL } +}; + +/* Supported options */ +typedef enum { + OPTION_SHADOW_FB, + OPTION_ROTATE, + OPTION_FBDEV, + OPTION_DEBUG +} FBDevOpts; + +static const OptionInfoRec FBDevOptions[] = { + { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE }, + { OPTION_FBDEV, "fbdev", OPTV_STRING, {0}, FALSE }, + { OPTION_DEBUG, "debug", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +/* -------------------------------------------------------------------- */ + +MODULESETUPPROTO(FBDevSetup); + +static XF86ModuleVersionInfo FBDevVersRec = +{ + "fbdev", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData fbdevModuleData = { &FBDevVersRec, FBDevSetup, NULL }; + +void* +FBDevSetup(void *module, void *opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) { + setupDone = TRUE; + xf86AddDriver(&FBDEV, module, HaveDriverFuncs); + return (void*)1; + } else { + if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +/* -------------------------------------------------------------------- */ +/* our private data, and two functions to allocate/free this */ + +typedef struct { + unsigned char* fbstart; + unsigned char* fbmem; + int fboff; + int lineLength; + int rotate; + Bool shadowFB; + Bool shadow24; + void *shadow; + CloseScreenProcPtr CloseScreen; + CreateScreenResourcesProcPtr CreateScreenResources; + void (*PointerMoved)(ScrnInfoPtr pScrn, int x, int y); + EntityInfoPtr pEnt; +#ifdef XFreeXDGA + /* DGA info */ + DGAModePtr pDGAMode; + int nDGAMode; +#endif + OptionInfoPtr Options; +} FBDevRec, *FBDevPtr; + +#define FBDEVPTR(p) ((FBDevPtr)((p)->driverPrivate)) + +static Bool +FBDevGetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate != NULL) + return TRUE; + + pScrn->driverPrivate = XNFcallocarray(sizeof(FBDevRec), 1); + return TRUE; +} + +static void +FBDevFreeRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate == NULL) + return; + free(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +/* -------------------------------------------------------------------- */ + +static const OptionInfoRec * +FBDevAvailableOptions(int chipid, int busid) +{ + return FBDevOptions; +} + +static void +FBDevIdentify(int flags) +{ + xf86PrintChipsets(FBDEV_NAME, "driver for framebuffer", FBDevChipsets); +} + +static Bool +fbdevSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + return fbdevHWSwitchMode(pScrn, mode); +} + +static void +fbdevAdjustFrame(ScrnInfoPtr pScrn, int x, int y) +{ + fbdevHWAdjustFrame(pScrn, x, y); +} + +static Bool +fbdevEnterVT(ScrnInfoPtr pScrn) +{ + return fbdevHWEnterVT(pScrn); +} + +static void +fbdevLeaveVT(ScrnInfoPtr pScrn) +{ + fbdevHWLeaveVT(pScrn); +} + +static ModeStatus +fbdevValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool verbose, int flags) +{ + return fbdevHWValidMode(pScrn, mode, verbose, flags); +} + +static Bool FBDevPciProbe(DriverPtr drv, int entity_num, + struct pci_device *dev, intptr_t match_data) +{ + ScrnInfoPtr pScrn = NULL; + + if (!xf86LoadDrvSubModule(drv, "fbdevhw")) + return FALSE; + + pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL, NULL, + NULL, NULL, NULL, NULL); + if (pScrn) { + char *device; + GDevPtr devSection = xf86GetDevFromEntity(pScrn->entityList[0], + pScrn->entityInstanceList[0]); + + device = xf86FindOptionValue(devSection->options, "fbdev"); + if (fbdevHWProbe(dev, device, NULL)) { + pScrn->driverVersion = FBDEV_VERSION; + pScrn->driverName = FBDEV_DRIVER_NAME; + pScrn->name = FBDEV_NAME; + pScrn->Probe = FBDevProbe; + pScrn->PreInit = FBDevPreInit; + pScrn->ScreenInit = FBDevScreenInit; + pScrn->SwitchMode = fbdevSwitchMode; + pScrn->AdjustFrame = fbdevAdjustFrame; + pScrn->EnterVT = fbdevEnterVT; + pScrn->LeaveVT = fbdevLeaveVT; + pScrn->ValidMode = fbdevValidMode; + + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "claimed PCI slot %d@%d:%d:%d\n", + dev->bus, dev->domain, dev->dev, dev->func); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "using %s\n", device ? device : "default device"); + } + else { + pScrn = NULL; + } + } + + return (pScrn != NULL); +} + +static Bool +FBDevProbe(DriverPtr drv, int flags) +{ + int i; + ScrnInfoPtr pScrn; + GDevPtr *devSections; + int numDevSections; + char *dev; + Bool foundScreen = FALSE; + + TRACE("probe start"); + + /* For now, just bail out for PROBE_DETECT. */ + if (flags & PROBE_DETECT) + return FALSE; + + if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0) + return FALSE; + + if (!xf86LoadDrvSubModule(drv, "fbdevhw")) + return FALSE; + + for (i = 0; i < numDevSections; i++) { + Bool isPci = FALSE; + + dev = xf86FindOptionValue(devSections[i]->options,"fbdev"); + if (devSections[i]->busID) { + } + if (fbdevHWProbe(NULL,dev,NULL)) { + pScrn = NULL; + if (isPci) { + } else { + int entity; + + entity = xf86ClaimFbSlot(drv, 0, + devSections[i], TRUE); + pScrn = xf86ConfigFbEntity(pScrn,0,entity, + NULL,NULL,NULL,NULL); + + } + if (pScrn) { + foundScreen = TRUE; + + pScrn->driverVersion = FBDEV_VERSION; + pScrn->driverName = FBDEV_DRIVER_NAME; + pScrn->name = FBDEV_NAME; + pScrn->Probe = FBDevProbe; + pScrn->PreInit = FBDevPreInit; + pScrn->ScreenInit = FBDevScreenInit; + pScrn->SwitchMode = fbdevSwitchMode; + pScrn->AdjustFrame = fbdevAdjustFrame; + pScrn->EnterVT = fbdevEnterVT; + pScrn->LeaveVT = fbdevLeaveVT; + pScrn->ValidMode = fbdevValidMode; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "using %s\n", dev ? dev : "default device"); + } + } + } + free(devSections); + TRACE("probe done"); + return foundScreen; +} + +static Bool +FBDevPreInit(ScrnInfoPtr pScrn, int flags) +{ + FBDevPtr fPtr; + int default_depth, fbbpp; + const char *s; + int type; + void *pci_dev = NULL; + + if (flags & PROBE_DETECT) return FALSE; + + TRACE_ENTER("PreInit"); + + /* Check the number of entities, and fail if it isn't one. */ + if (pScrn->numEntities != 1) + return FALSE; + + pScrn->monitor = pScrn->confScreen->monitor; + + FBDevGetRec(pScrn); + fPtr = FBDEVPTR(pScrn); + + fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + + if (fPtr->pEnt->location.type == BUS_PCI) + pci_dev = fPtr->pEnt->location.id.pci; + /* open device */ + if (!fbdevHWInit(pScrn, pci_dev, + xf86FindOptionValue(fPtr->pEnt->device->options, + "fbdev"))) + return FALSE; + default_depth = fbdevHWGetDepth(pScrn,&fbbpp); + + if (default_depth == 8) do { + /* trust the command line */ + if (xf86FbBpp > 0 || xf86Depth > 0) + break; + + /* trust the config file's Screen stanza */ + if (pScrn->confScreen->defaultfbbpp > 0 || + pScrn->confScreen->defaultdepth > 0) + break; + + /* trust our Device stanza in the config file */ + if (xf86FindOption(fPtr->pEnt->device->options, "DefaultDepth") || + xf86FindOption(fPtr->pEnt->device->options, "DefaultFbBpp")) + break; + + /* otherwise, lol no */ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Console is 8bpp, defaulting to 32bpp\n"); + default_depth = 24; + fbbpp = 32; + } while (0); + + fPtr->shadow24 = FALSE; +#ifdef HAVE_SHADOW_3224 + /* okay but 24bpp is awful */ + if (fbbpp == 24) { + fPtr->shadow24 = TRUE; + fbbpp = 32; + } +#endif + + if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp, + Support24bppFb | Support32bppFb | SupportConvert32to24 | SupportConvert24to32)) + return FALSE; + xf86PrintDepthBpp(pScrn); + + /* color weight */ + if (pScrn->depth > 8) { + rgb zeros = { 0, 0, 0 }; + if (!xf86SetWeight(pScrn, zeros, zeros)) + return FALSE; + } + + /* visual init */ + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; + + /* We don't currently support DirectColor at > 8bpp */ + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "requested default visual" + " (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + + { + Gamma zeros = {0.0, 0.0, 0.0}; + + if (!xf86SetGamma(pScrn,zeros)) { + return FALSE; + } + } + + pScrn->progClock = TRUE; + pScrn->rgbBits = 8; + pScrn->chipset = "fbdev"; + pScrn->videoRam = fbdevHWGetVidmem(pScrn); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "hardware: %s (video memory:" + " %dkB)\n", fbdevHWGetName(pScrn), pScrn->videoRam/1024); + + /* handle options */ + xf86CollectOptions(pScrn, NULL); + if (!(fPtr->Options = malloc(sizeof(FBDevOptions)))) + return FALSE; + memcpy(fPtr->Options, FBDevOptions, sizeof(FBDevOptions)); + xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, fPtr->Options); + + /* use shadow framebuffer by default */ + fPtr->shadowFB = xf86ReturnOptValBool(fPtr->Options, OPTION_SHADOW_FB, TRUE); + if (!fPtr->shadowFB && fPtr->shadow24) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "24bpp requires shadow framebuffer, forcing\n"); + fPtr->shadowFB = TRUE; + } + + debug = xf86ReturnOptValBool(fPtr->Options, OPTION_DEBUG, FALSE); + + /* rotation */ + fPtr->rotate = FBDEV_ROTATE_NONE; + s = xf86GetOptValString(fPtr->Options, OPTION_ROTATE); + if (s && !fPtr->shadow24) + { + if(!xf86NameCmp(s, "CW")) + { + fPtr->shadowFB = TRUE; + fPtr->rotate = FBDEV_ROTATE_CW; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "rotating screen clockwise\n"); + } + else if(!xf86NameCmp(s, "CCW")) + { + fPtr->shadowFB = TRUE; + fPtr->rotate = FBDEV_ROTATE_CCW; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "rotating screen counter-clockwise\n"); + } + else if(!xf86NameCmp(s, "UD")) + { + fPtr->shadowFB = TRUE; + fPtr->rotate = FBDEV_ROTATE_UD; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "rotating screen upside-down\n"); + } + else + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "\"%s\" is not a valid value for Option \"Rotate\"\n", s); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "valid options are \"CW\", \"CCW\" and \"UD\"\n"); + } + } + + /* select video modes */ + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "checking modes against framebuffer device...\n"); + fbdevHWSetVideoModes(pScrn); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "checking modes against monitor...\n"); + { + DisplayModePtr mode, first = mode = pScrn->modes; + + if (mode != NULL) do { + mode->status = xf86CheckModeForMonitor(mode, pScrn->monitor); + mode = mode->next; + } while (mode != NULL && mode != first); + + xf86PruneDriverModes(pScrn); + } + + if (NULL == pScrn->modes) + fbdevHWUseBuildinMode(pScrn); + pScrn->currentMode = pScrn->modes; + + /* First approximation, may be refined in ScreenInit */ + pScrn->displayWidth = pScrn->virtualX; + + xf86PrintModes(pScrn); + + /* Set display resolution */ + xf86SetDpi(pScrn, 0, 0); + + /* Load bpp-specific modules */ + switch ((type = fbdevHWGetType(pScrn))) + { + case FBDEVHW_PACKED_PIXELS: + switch (pScrn->bitsPerPixel) + { + case 8: + case 16: + case 24: + case 32: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "unsupported number of bits per pixel: %d", + pScrn->bitsPerPixel); + return FALSE; + } + break; + case FBDEVHW_INTERLEAVED_PLANES: + /* Not supported yet, don't know what to do with this */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "interleaved planes are not yet supported by the " + "fbdev driver\n"); + return FALSE; + case FBDEVHW_TEXT: + /* This should never happen ... + * we should check for this much much earlier ... */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "text mode is not supported by the fbdev driver\n"); + return FALSE; + case FBDEVHW_VGA_PLANES: + /* Not supported yet */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "EGA/VGA planes are not yet supported by the fbdev " + "driver\n"); + return FALSE; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "unrecognised fbdev hardware type (%d)\n", type); + return FALSE; + } + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + FBDevFreeRec(pScrn); + return FALSE; + } + + /* Load shadow if needed */ + if (fPtr->shadowFB) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "using shadow" + " framebuffer\n"); + if (!xf86LoadSubModule(pScrn, "shadow")) { + FBDevFreeRec(pScrn); + return FALSE; + } + } + + TRACE_EXIT("PreInit"); + return TRUE; +} + +static void +fbdevUpdate32to24(ScreenPtr pScreen, shadowBufPtr pBuf) +{ +#ifdef HAVE_SHADOW_3224 + shadowUpdate32to24(pScreen, pBuf); +#endif +} + +static void +fbdevUpdateRotatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) +{ + shadowUpdateRotatePacked(pScreen, pBuf); +} + +static void +fbdevUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) +{ + shadowUpdatePacked(pScreen, pBuf); +} + +static Bool +FBDevCreateScreenResources(ScreenPtr pScreen) +{ + PixmapPtr pPixmap; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + FBDevPtr fPtr = FBDEVPTR(pScrn); + Bool ret; + void (*update)(ScreenPtr, shadowBufPtr); + + pScreen->CreateScreenResources = fPtr->CreateScreenResources; + ret = pScreen->CreateScreenResources(pScreen); + pScreen->CreateScreenResources = FBDevCreateScreenResources; + + if (!ret) + return FALSE; + + pPixmap = pScreen->GetScreenPixmap(pScreen); + + if (fPtr->shadow24) + update = fbdevUpdate32to24; + else if (fPtr->rotate) + update = fbdevUpdateRotatePacked; + else + update = fbdevUpdatePacked; + + if (!shadowAdd(pScreen, pPixmap, update, FBDevWindowLinear, fPtr->rotate, + NULL)) { + return FALSE; + } + + return TRUE; +} + +static Bool +FBDevShadowInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + FBDevPtr fPtr = FBDEVPTR(pScrn); + + if (!shadowSetup(pScreen)) { + return FALSE; + } + + fPtr->CreateScreenResources = pScreen->CreateScreenResources; + pScreen->CreateScreenResources = FBDevCreateScreenResources; + + return TRUE; +} + +static void +fbdevLoadPalette(ScrnInfoPtr pScrn, int num, int *i, LOCO *col, VisualPtr pVis) +{ + fbdevHWLoadPalette(pScrn, num, i, col, pVis); +} + +static void +fbdevDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ + fbdevHWDPMSSet(pScrn, mode, flags); +} + +static Bool +fbdevSaveScreen(ScreenPtr pScreen, int mode) +{ + return fbdevHWSaveScreen(pScreen, mode); +} + +static Bool +FBDevScreenInit(ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + FBDevPtr fPtr = FBDEVPTR(pScrn); + VisualPtr visual; + int init_picture = 0; + int ret, flags; + int type; + + TRACE_ENTER("FBDevScreenInit"); + +#if DEBUG + ErrorF("\tbitsPerPixel=%d, depth=%d, defaultVisual=%s\n" + "\tmask: %x,%x,%x, offset: %d,%d,%d\n", + pScrn->bitsPerPixel, + pScrn->depth, + xf86GetVisualName(pScrn->defaultVisual), + pScrn->mask.red,pScrn->mask.green,pScrn->mask.blue, + pScrn->offset.red,pScrn->offset.green,pScrn->offset.blue); +#endif + + if (NULL == (fPtr->fbmem = fbdevHWMapVidmem(pScrn))) { + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"mapping of video memory" + " failed\n"); + return FALSE; + } + fPtr->fboff = fbdevHWLinearOffset(pScrn); + + fbdevHWSave(pScrn); + + if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) { + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"mode initialization failed\n"); + return FALSE; + } + fbdevHWSaveScreen(pScreen, SCREEN_SAVER_ON); + fbdevHWAdjustFrame(pScrn, 0, 0); + + /* mi layer */ + miClearVisualTypes(); + if (pScrn->bitsPerPixel > 8) { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, TrueColor)) { + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"visual type setup failed" + " for %d bits per pixel [1]\n", + pScrn->bitsPerPixel); + return FALSE; + } + } else { + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) { + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"visual type setup failed" + " for %d bits per pixel [2]\n", + pScrn->bitsPerPixel); + return FALSE; + } + } + if (!miSetPixmapDepths()) { + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"pixmap depth setup failed\n"); + return FALSE; + } + + if(fPtr->rotate==FBDEV_ROTATE_CW || fPtr->rotate==FBDEV_ROTATE_CCW) + { + int tmp = pScrn->virtualX; + pScrn->virtualX = pScrn->displayWidth = pScrn->virtualY; + pScrn->virtualY = tmp; + } else if (!fPtr->shadowFB) { + /* FIXME: this doesn't work for all cases, e.g. when each scanline + has a padding which is independent from the depth (controlfb) */ + pScrn->displayWidth = fbdevHWGetLineLength(pScrn) / + (pScrn->bitsPerPixel / 8); + + if (pScrn->displayWidth != pScrn->virtualX) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Pitch updated to %d after ModeInit\n", + pScrn->displayWidth); + } + } + + if(fPtr->rotate && !fPtr->PointerMoved) { + fPtr->PointerMoved = pScrn->PointerMoved; + pScrn->PointerMoved = FBDevPointerMoved; + } + + fPtr->fbstart = fPtr->fbmem + fPtr->fboff; + + if (fPtr->shadowFB) { + fPtr->shadow = calloc(1, pScrn->displayWidth * pScrn->virtualY * + ((pScrn->bitsPerPixel + 7) / 8)); + + if (!fPtr->shadow) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to allocate shadow framebuffer\n"); + return FALSE; + } + } + + switch ((type = fbdevHWGetType(pScrn))) + { + case FBDEVHW_PACKED_PIXELS: + switch (pScrn->bitsPerPixel) { + case 8: + case 16: + case 24: + case 32: + ret = fbScreenInit(pScreen, fPtr->shadowFB ? fPtr->shadow + : fPtr->fbstart, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, + pScrn->yDpi, pScrn->displayWidth, + pScrn->bitsPerPixel); + init_picture = 1; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: invalid number of bits per" + " pixel (%d) encountered in" + " FBDevScreenInit()\n", pScrn->bitsPerPixel); + ret = FALSE; + break; + } + break; + case FBDEVHW_INTERLEAVED_PLANES: + /* This should never happen ... + * we should check for this much much earlier ... */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: interleaved planes are not yet " + "supported by the fbdev driver\n"); + ret = FALSE; + break; + case FBDEVHW_TEXT: + /* This should never happen ... + * we should check for this much much earlier ... */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: text mode is not supported by the " + "fbdev driver\n"); + ret = FALSE; + break; + case FBDEVHW_VGA_PLANES: + /* Not supported yet */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: EGA/VGA Planes are not yet " + "supported by the fbdev driver\n"); + ret = FALSE; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: unrecognised hardware type (%d) " + "encountered in FBDevScreenInit()\n", type); + ret = FALSE; + break; + } + if (!ret) + return FALSE; + + if (pScrn->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + /* must be after RGB ordering fixed */ + if (init_picture && !fbPictureInit(pScreen, NULL, 0)) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Render extension initialisation failed\n"); + + if (fPtr->shadowFB && !FBDevShadowInit(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "shadow framebuffer initialization failed\n"); + return FALSE; + } + + if (!fPtr->rotate) + FBDevDGAInit(pScrn, pScreen); + else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "display rotated; disabling DGA\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "using driver rotation; disabling " + "XRandR\n"); +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 24 + xf86DisableRandR(); +#endif + if (pScrn->bitsPerPixel == 24) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "rotation might be broken at 24 " + "bits per pixel\n"); + } + + xf86SetBlackWhitePixels(pScreen); + xf86SetBackingStore(pScreen); + + /* software cursor */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* colormap */ + switch ((type = fbdevHWGetType(pScrn))) + { + /* XXX It would be simpler to use miCreateDefColormap() in all cases. */ + case FBDEVHW_PACKED_PIXELS: + if (!miCreateDefColormap(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: miCreateDefColormap failed " + "in FBDevScreenInit()\n"); + return FALSE; + } + break; + case FBDEVHW_INTERLEAVED_PLANES: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: interleaved planes are not yet " + "supported by the fbdev driver\n"); + return FALSE; + case FBDEVHW_TEXT: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: text mode is not supported by " + "the fbdev driver\n"); + return FALSE; + case FBDEVHW_VGA_PLANES: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: EGA/VGA planes are not yet " + "supported by the fbdev driver\n"); + return FALSE; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "internal error: unrecognised fbdev hardware type " + "(%d) encountered in FBDevScreenInit()\n", type); + return FALSE; + } + flags = CMAP_PALETTED_TRUECOLOR; + if(!xf86HandleColormaps(pScreen, 256, 8, fbdevLoadPalette, NULL, flags)) + return FALSE; + + xf86DPMSInit(pScreen, fbdevDPMSSet, 0); + + pScreen->SaveScreen = fbdevSaveScreen; + + /* Wrap the current CloseScreen function */ + fPtr->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = FBDevCloseScreen; + +#ifdef XV + { + XF86VideoAdaptorPtr *ptr; + + int n = xf86XVListGenericAdaptors(pScrn,&ptr); + if (n) { + xf86XVScreenInit(pScreen,ptr,n); + } + } +#endif + + TRACE_EXIT("FBDevScreenInit"); + + return TRUE; +} + +static Bool +FBDevCloseScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + FBDevPtr fPtr = FBDEVPTR(pScrn); + + fbdevHWRestore(pScrn); + fbdevHWUnmapVidmem(pScrn); + if (fPtr->shadow) { + shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen)); + free(fPtr->shadow); + fPtr->shadow = NULL; + } +#ifdef XFreeXDGA + if (fPtr->pDGAMode) { + free(fPtr->pDGAMode); + fPtr->pDGAMode = NULL; + fPtr->nDGAMode = 0; + } +#endif + pScrn->vtSema = FALSE; + + pScreen->CreateScreenResources = fPtr->CreateScreenResources; + pScreen->CloseScreen = fPtr->CloseScreen; + return (*pScreen->CloseScreen)(pScreen); +} + + + +/*********************************************************************** + * Shadow stuff + ***********************************************************************/ + +static void * +FBDevWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, + CARD32 *size, void *closure) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + FBDevPtr fPtr = FBDEVPTR(pScrn); + + if (!pScrn->vtSema) + return NULL; + + if (fPtr->lineLength) + *size = fPtr->lineLength; + else + *size = fPtr->lineLength = fbdevHWGetLineLength(pScrn); + + return ((CARD8 *)fPtr->fbstart + row * fPtr->lineLength + offset); +} + +static void +FBDevPointerMoved(ScrnInfoPtr pScrn, int x, int y) +{ + FBDevPtr fPtr = FBDEVPTR(pScrn); + int newX, newY; + + switch (fPtr->rotate) + { + case FBDEV_ROTATE_CW: + /* 90 degrees CW rotation. */ + newX = pScrn->pScreen->height - y - 1; + newY = x; + break; + + case FBDEV_ROTATE_CCW: + /* 90 degrees CCW rotation. */ + newX = y; + newY = pScrn->pScreen->width - x - 1; + break; + + case FBDEV_ROTATE_UD: + /* 180 degrees UD rotation. */ + newX = pScrn->pScreen->width - x - 1; + newY = pScrn->pScreen->height - y - 1; + break; + + default: + /* No rotation. */ + newX = x; + newY = y; + break; + } + + /* Pass adjusted pointer coordinates to wrapped PointerMoved function. */ + (*fPtr->PointerMoved)(pScrn, newX, newY); +} + + +/*********************************************************************** + * DGA stuff + ***********************************************************************/ +#ifdef XFreeXDGA +static Bool FBDevDGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName, + unsigned char **ApertureBase, + int *ApertureSize, int *ApertureOffset, + int *flags); +static Bool FBDevDGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode); +static void FBDevDGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags); + +static Bool +FBDevDGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName, + unsigned char **ApertureBase, int *ApertureSize, + int *ApertureOffset, int *flags) +{ + *DeviceName = NULL; /* No special device */ + *ApertureBase = (unsigned char *)(pScrn->memPhysBase); + *ApertureSize = pScrn->videoRam; + *ApertureOffset = pScrn->fbOffset; + *flags = 0; + + return TRUE; +} + +static Bool +FBDevDGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode) +{ + DisplayModePtr pMode; + int frameX0, frameY0; + + if (pDGAMode) { + pMode = pDGAMode->mode; + frameX0 = frameY0 = 0; + } + else { + if (!(pMode = pScrn->currentMode)) + return TRUE; + + frameX0 = pScrn->frameX0; + frameY0 = pScrn->frameY0; + } + + if (!(*pScrn->SwitchMode)(pScrn, pMode)) + return FALSE; + (*pScrn->AdjustFrame)(pScrn, frameX0, frameY0); + + return TRUE; +} + +static void +FBDevDGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) +{ + (*pScrn->AdjustFrame)(pScrn, x, y); +} + +static int +FBDevDGAGetViewport(ScrnInfoPtr pScrn) +{ + return (0); +} + +static DGAFunctionRec FBDevDGAFunctions = +{ + FBDevDGAOpenFramebuffer, + NULL, /* CloseFramebuffer */ + FBDevDGASetMode, + FBDevDGASetViewport, + FBDevDGAGetViewport, + NULL, /* Sync */ + NULL, /* FillRect */ + NULL, /* BlitRect */ + NULL, /* BlitTransRect */ +}; + +static void +FBDevDGAAddModes(ScrnInfoPtr pScrn) +{ + FBDevPtr fPtr = FBDEVPTR(pScrn); + DisplayModePtr pMode = pScrn->modes; + DGAModePtr pDGAMode; + + do { + pDGAMode = realloc(fPtr->pDGAMode, + (fPtr->nDGAMode + 1) * sizeof(DGAModeRec)); + if (!pDGAMode) + break; + + fPtr->pDGAMode = pDGAMode; + pDGAMode += fPtr->nDGAMode; + (void)memset(pDGAMode, 0, sizeof(DGAModeRec)); + + ++fPtr->nDGAMode; + pDGAMode->mode = pMode; + pDGAMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + pDGAMode->byteOrder = pScrn->imageByteOrder; + pDGAMode->depth = pScrn->depth; + pDGAMode->bitsPerPixel = pScrn->bitsPerPixel; + pDGAMode->red_mask = pScrn->mask.red; + pDGAMode->green_mask = pScrn->mask.green; + pDGAMode->blue_mask = pScrn->mask.blue; + pDGAMode->visualClass = pScrn->bitsPerPixel > 8 ? + TrueColor : PseudoColor; + pDGAMode->xViewportStep = 1; + pDGAMode->yViewportStep = 1; + pDGAMode->viewportWidth = pMode->HDisplay; + pDGAMode->viewportHeight = pMode->VDisplay; + + if (fPtr->lineLength) + pDGAMode->bytesPerScanline = fPtr->lineLength; + else + pDGAMode->bytesPerScanline = fPtr->lineLength = fbdevHWGetLineLength(pScrn); + + pDGAMode->imageWidth = pMode->HDisplay; + pDGAMode->imageHeight = pMode->VDisplay; + pDGAMode->pixmapWidth = pDGAMode->imageWidth; + pDGAMode->pixmapHeight = pDGAMode->imageHeight; + pDGAMode->maxViewportX = pScrn->virtualX - + pDGAMode->viewportWidth; + pDGAMode->maxViewportY = pScrn->virtualY - + pDGAMode->viewportHeight; + + pDGAMode->address = fPtr->fbstart; + + pMode = pMode->next; + } while (pMode != pScrn->modes); +} +#endif + +static Bool +FBDevDGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen) +{ +#ifdef XFreeXDGA + FBDevPtr fPtr = FBDEVPTR(pScrn); + + if (pScrn->depth < 8) + return FALSE; + + if (!fPtr->nDGAMode) + FBDevDGAAddModes(pScrn); + + return (DGAInit(pScreen, &FBDevDGAFunctions, + fPtr->pDGAMode, fPtr->nDGAMode)); +#else + return TRUE; +#endif +} + +static Bool +FBDevDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, void *ptr) +{ + xorgHWFlags *flag; + + switch (op) { + case GET_REQUIRED_HW_INTERFACES: + flag = (CARD32*)ptr; + (*flag) = 0; + return TRUE; + default: + return FALSE; + } +}