Skip to content

Commit ab63925

Browse files
committed
replace Xinerama with Xrandr
Xrandr is supposedly the better replacement [0] for Xinerama. on my system, no packages (other than scrot) use Xinerama while there's a bunch using Xrandr, so it's likely a more common dependency too which means it's more likely to be installed on the user's system already. [0]: https://wiki.archlinux.org/title/Multihead#Xinerama
1 parent 0011db1 commit ab63925

File tree

6 files changed

+18
-28
lines changed

6 files changed

+18
-28
lines changed

.cirrus.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ task:
5353
install_script:
5454
- apk add build-base autoconf autoconf-archive automake gzip pkgconfig $CC
5555
xorg-server-dev libxcomposite-dev libxext-dev libxfixes-dev
56-
libxinerama-dev imlib2-dev
56+
libxrandr-dev imlib2-dev
5757
<< : *common_script
5858

5959
task:
@@ -77,7 +77,7 @@ task:
7777
- apt-get update
7878
- apt-get install -y autoconf autoconf-archive make pkg-config $CC
7979
libx11-dev libxcomposite-dev libxext-dev libxfixes-dev
80-
libxinerama-dev libimlib2-dev
80+
libxrandr-dev libimlib2-dev
8181
<< : *common_script
8282

8383
task:
@@ -92,7 +92,7 @@ task:
9292
- CC: gcc
9393
install_script:
9494
- pkg install -y autoconf autoconf-archive automake pkgconf gcc libX11
95-
libXcomposite libXext libXfixes libXinerama imlib2
95+
libXcomposite libXext libXfixes libXrandr imlib2
9696
<< : *common_script
9797

9898
task:
@@ -108,7 +108,7 @@ task:
108108
install_script:
109109
- brew update
110110
- brew install autoconf autoconf-archive automake make pkg-config gcc libx11
111-
libxcomposite libxext libxfixes libxinerama imlib2
111+
libxcomposite libxext libxfixes libxrandr imlib2
112112
<< : *common_script
113113

114114
task:
@@ -118,7 +118,7 @@ task:
118118
install_script:
119119
- apk add build-base pkgconfig
120120
xorg-server-dev libxcomposite-dev libxext-dev
121-
libxfixes-dev libxinerama-dev imlib2-dev
121+
libxfixes-dev libxrandr-dev imlib2-dev
122122
matrix:
123123
- name: alpine-latest-bare-build
124124
test_script:

.github/workflows/full-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
run: |
1919
sudo apt update && sudo apt upgrade
2020
sudo apt install tcc libimlib2-dev libxcomposite-dev libxfixes-dev \
21-
autoconf-archive libbsd-dev libxinerama-dev cppcheck
21+
autoconf-archive libbsd-dev libxrandr-dev cppcheck
2222
- name: distcheck
2323
run: |
2424
./autogen.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ scrot requires a few projects and libraries:
6666
- libXcomposite [(can be found in X.Org)](https://gitlab.freedesktop.org/xorg/lib/libxcomposite)
6767
- libXext [(can be found in X.Org)](https://gitlab.freedesktop.org/xorg/lib/libxext)
6868
- libXfixes [(can be found in X.Org)](https://gitlab.freedesktop.org/xorg/lib/libxfixes)
69-
- libXinerama [(can be found in X.Org)](https://gitlab.freedesktop.org/xorg/lib/libxinerama)
69+
- libXrandr [(can be found in X.Org)](https://gitlab.freedesktop.org/xorg/lib/libxrandr)
7070

7171
The [deps.pc](./deps.pc) file documents minimum version requirement for some of
7272
the libraries.

deps.pc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Name: scrot's mandatory dependencies
22
Description: ditto
33
Version: infinite
44
Cflags: -D_XOPEN_SOURCE=700L
5-
Requires: x11 imlib2 >= 1.11.0 xcomposite >= 0.2.0 xext xfixes >= 5.0.1 xinerama >= 1.1.3
5+
Requires: x11 imlib2 >= 1.11.0 xcomposite >= 0.2.0 xext xfixes >= 5.0.1 xrandr >= 1.5

man/scrot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ OPTIONS
4747
(vertical/horizontal). Default: h
4848
-l, --line STYLE STYLE indicates the style of the line when the -s
4949
option is used; see SELECTION STYLE.
50-
-M, --monitor NUM Capture Xinerama monitor number NUM.
50+
-M, --monitor NUM Capture Xrandr monitor number NUM.
5151
-m, --multidisp For multiple heads, screenshot all of them in order.
5252
-o, --overwrite By default scrot does not overwrite the output
5353
FILE, use this option to enable it.

src/scrot.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6161
#include <X11/Xutil.h>
6262
#include <X11/extensions/Xcomposite.h>
6363
#include <X11/extensions/Xfixes.h>
64-
#include <X11/extensions/Xinerama.h>
64+
#include <X11/extensions/Xrandr.h>
6565

6666
#include "options.h"
6767
#include "scrot.h"
@@ -949,27 +949,17 @@ static Imlib_Image scrotGrabShotMulti(void)
949949

950950
static Imlib_Image scrotGrabShotMonitor(void)
951951
{
952-
int eventBase, errBase;
952+
int numMonitors;
953+
XRRMonitorInfo *monitors = XRRGetMonitors(disp, root, True, &numMonitors);
954+
if (!monitors)
955+
errx(EXIT_FAILURE, "XRRGetMonitors() failed");
953956

954-
if (!XineramaQueryExtension(disp, &eventBase, &errBase))
955-
errx(EXIT_FAILURE, "Xinerama extension not found");
956-
957-
int numScreens = 0;
958-
XineramaScreenInfo *screens = XineramaQueryScreens(disp, &numScreens);
959-
960-
if (!screens && !numScreens)
961-
errx(EXIT_FAILURE, "Xinerama not active");
962-
963-
if (!numScreens)
964-
errx(EXIT_FAILURE, "Xinerama active but did not find any output device");
965-
966-
if (opt.monitor >= numScreens)
957+
if (opt.monitor >= numMonitors)
967958
errx(EXIT_FAILURE, "monitor %d not found", opt.monitor);
968959

969-
scrotAssert(screens); /* silence clang-tidy */
970-
XineramaScreenInfo *mon = &screens[opt.monitor];
971-
int x = mon->x_org, y = mon->y_org, w = mon->width, h = mon->height;
972-
XFree(screens);
960+
XRRMonitorInfo *m = monitors + opt.monitor;
961+
int x = m->x, y = m->y, h = m->height, w = m->width;
962+
XRRFreeMonitors(monitors);
973963

974964
scrotNiceClip(&x, &y, &w, &h);
975965
return scrotGrabRectAndPointer(x, y, w, h, false);

0 commit comments

Comments
 (0)