updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / slim-plus / slim-xinerama.patch
blobef9ee7680184602943899d9deef03d2ec1f46e8f
1 diff --git a/INSTALL b/INSTALL
2 index 3a9562c..3db35c8 100644
3 --- a/INSTALL
4 +++ b/INSTALL
5 @@ -2,6 +2,7 @@ INSTALL file for SLiM
7 0. Prerequisites:
8 - X.org or XFree86
9 + - libXinerama
10 - libxmu
11 - libpng
12 - libjpeg
13 diff --git a/Makefile b/Makefile
14 index f7d3d2d..919b954 100644
15 --- a/Makefile
16 +++ b/Makefile
17 @@ -7,7 +7,7 @@ CXX=/usr/bin/g++
18 CC=/usr/bin/gcc
19 CFLAGS=-Wall -I. -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/libpng12 -I/usr/include
20 CXXFLAGS=$(CFLAGS)
21 -LDFLAGS=-lXft -lX11 -lfreetype -lXrender -lfontconfig -lpng12 -lz -lm -lcrypt -lXmu -lpng -ljpeg
22 +LDFLAGS=-lXft -lX11 -lXinerama -lfreetype -lXrender -lfontconfig -lpng12 -lz -lm -lcrypt -lXmu -lpng -ljpeg
23 CUSTOM=-DHAVE_SHADOW
24 ifdef USE_PAM
25 LDFLAGS+= -lpam
26 diff --git a/Makefile.freebsd b/Makefile.freebsd
27 index 3ff326e..10436cf 100644
28 --- a/Makefile.freebsd
29 +++ b/Makefile.freebsd
30 @@ -6,7 +6,7 @@
31 CXX=/usr/bin/g++
32 CC=/usr/bin/gcc
33 CFLAGS=-I. -I/usr/local/include/freetype2 -I/usr/local/include/freetype2/config -I/usr/local/include/libpng -I/usr/local/include -I/usr/include
34 -LDFLAGS= -L/usr/local/lib -lXft -lX11 -lfreetype -lXrender -lfontconfig -lpng -lz -lm -lcrypt -lXmu -lpng -ljpeg
35 +LDFLAGS= -L/usr/local/lib -lXft -lX11 -lXinerama -lfreetype -lXrender -lfontconfig -lpng -lz -lm -lcrypt -lXmu -lpng -ljpeg
36 CUSTOM=-DNEEDS_BASENAME
37 .ifdef(USE_PAM)
38 LDFLAGS+= -lpam
39 diff --git a/Makefile.openbsd b/Makefile.openbsd
40 index b1829f8..08d1c04 100644
41 --- a/Makefile.openbsd
42 +++ b/Makefile.openbsd
43 @@ -6,7 +6,7 @@
44 CXX=/usr/bin/g++
45 CC=/usr/bin/gcc
46 CFLAGS=-I. -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 -I/usr/X11R6/include/freetype2/config -I/usr/local/include/libpng -I/usr/local/include -I/usr/include
47 -LDFLAGS=-L/usr/X11R6/lib -L/usr/local/lib -lXft -lX11 -lfreetype -lXrender -lfontconfig -lpng -lz -lm -lXmu -lpng -ljpeg
48 +LDFLAGS=-L/usr/X11R6/lib -L/usr/local/lib -lXft -lX11 -lXinerama -lfreetype -lXrender -lfontconfig -lpng -lz -lm -lXmu -lpng -ljpeg
49 CUSTOM=-DNEEDS_BASENAME
50 PREFIX=/usr
51 CFGDIR=/etc
52 diff --git a/README b/README
53 index e30fbf1..fad5cf2 100644
54 --- a/README
55 +++ b/README
56 @@ -15,6 +15,7 @@ INTRODUCTION
57 - XFT / freetype support
58 - Double or single (GDM-style) inputbox support
59 - Automake-based build procedure
60 + - Xinerama support
62 INSTALLATION
63 see the INSTALL file
64 @@ -40,8 +41,9 @@ USAGE
65 is to take a screenshot if the 'import' program is available.
67 CONFIGURATION
68 - /usr/etc/slim.conf is the main configuration file.
69 - Options are explained in the file itself
70 + /etc/slim.conf is the main configuration file, or use the -f
71 + option.
72 + Options are explained in the file itself.
74 THEMES
75 See THEMES
76 diff --git a/app.cpp b/app.cpp
77 index fd5dece..5776de9 100644
78 --- a/app.cpp
79 +++ b/app.cpp
80 @@ -321,8 +321,30 @@ void App::Run() {
81 blankScreen();
84 + int screenCount;
85 + XineramaScreenInfo *screens = XineramaQueryScreens(Dpy, &screenCount);
86 + if (screens != NULL) {
87 + bool ok;
88 + int screen = Cfg::string2int(cfg->getOption("xinerama_screen").c_str(), &ok);
89 + if (!ok || screen >= screenCount)
90 + screen = 0;
91 + screenInfo = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo));
92 + if (screenInfo == NULL) {
93 + fprintf(stderr, "Can't allocate memory for Xinerama screeninfo.\n");
94 + exit(ERR_EXIT);
95 + }
96 + memcpy(screenInfo, &screens[screen], sizeof(XineramaScreenInfo));
97 + XFree(screens);
98 + }
100 HideCursor();
102 + if (!testing && XineramaIsActive(Dpy)) {
103 + Root = XCreateSimpleWindow(Dpy, Root, ScreenLeft(), ScreenTop(), ScreenWidth(), ScreenHeight(), 0, 0, 0);
104 + XMapWindow(Dpy, Root);
105 + XFlush(Dpy);
108 // Create panel
109 LoginPanel = new Panel(Dpy, Scr, Root, cfg, themedir);
110 bool firstloop = true; // 1st time panel is shown (for automatic username)
111 @@ -714,8 +736,8 @@ void App::Console() {
112 int posy = 40;
113 int fontx = 9;
114 int fonty = 15;
115 - int width = (XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)) - (posx * 2)) / fontx;
116 - int height = (XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)) - (posy * 2)) / fonty;
117 + int width = (ScreenWidth() - (posx * 2)) / fontx;
118 + int height = (ScreenHeight() - (posy * 2)) / fonty;
120 // Execute console
121 const char* cmd = cfg->getOption("console_cmd").c_str();
122 @@ -748,6 +770,8 @@ void App::Exit() {
123 RemoveLock();
125 delete cfg;
126 + if (screenInfo != NULL)
127 + free(screenInfo);
128 exit(OK_EXIT);
131 @@ -1017,13 +1041,45 @@ void App::blankScreen()
132 GC gc = XCreateGC(Dpy, Root, 0, 0);
133 XSetForeground(Dpy, gc, BlackPixel(Dpy, Scr));
134 XFillRectangle(Dpy, Root, gc, 0, 0,
135 - XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
136 - XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
137 + XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), // intentional
138 + XHeightOfScreen(ScreenOfDisplay(Dpy, Scr))); // intentional
139 XFlush(Dpy);
140 XFreeGC(Dpy, gc);
144 +int App::ScreenLeft()
146 + if (screenInfo == NULL)
147 + return 0;
148 + else
149 + return screenInfo->x_org;
152 +int App::ScreenTop()
154 + if (screenInfo == NULL)
155 + return 0;
156 + else
157 + return screenInfo->y_org;
160 +int App::ScreenWidth()
162 + if (screenInfo == NULL)
163 + return XWidthOfScreen(ScreenOfDisplay(Dpy, Scr));
164 + else
165 + return screenInfo->width;
168 +int App::ScreenHeight()
170 + if (screenInfo == NULL)
171 + return XHeightOfScreen(ScreenOfDisplay(Dpy, Scr));
172 + else
173 + return screenInfo->height;
176 void App::setBackground(const string& themedir) {
177 string filename;
178 filename = themedir + "/background.png";
179 @@ -1037,18 +1093,18 @@ void App::setBackground(const string& themedir) {
180 if (loaded) {
181 string bgstyle = cfg->getOption("background_style");
182 if (bgstyle == "stretch") {
183 - image->Resize(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
184 + image->Resize(ScreenWidth(), ScreenHeight());
185 } else if (bgstyle == "tile") {
186 - image->Tile(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
187 + image->Tile(ScreenWidth(), ScreenHeight());
188 } else if (bgstyle == "center") {
189 string hexvalue = cfg->getOption("background_color");
190 hexvalue = hexvalue.substr(1,6);
191 - image->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
192 + image->Center(ScreenWidth(), ScreenHeight(),
193 hexvalue.c_str());
194 } else { // plain color or error
195 string hexvalue = cfg->getOption("background_color");
196 hexvalue = hexvalue.substr(1,6);
197 - image->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
198 + image->Center(ScreenWidth(), ScreenHeight(),
199 hexvalue.c_str());
201 Pixmap p = image->createPixmap(Dpy, Scr, Root);
202 diff --git a/app.h b/app.h
203 index 8127f13..faa1bf7 100644
204 --- a/app.h
205 +++ b/app.h
206 @@ -13,6 +13,7 @@
207 #define _APP_H_
209 #include <X11/Xlib.h>
210 +#include <X11/extensions/Xinerama.h>
211 #include <signal.h>
212 #include <unistd.h>
213 #include <sys/wait.h>
214 @@ -40,6 +41,8 @@ public:
215 void GetLock();
216 void RemoveLock();
218 + friend class Panel;
220 private:
221 void Login();
222 void Reboot();
223 @@ -69,10 +72,16 @@ private:
224 int ServerTimeout(int timeout, char *string);
225 int WaitForServer();
227 + int ScreenLeft();
228 + int ScreenTop();
229 + int ScreenWidth();
230 + int ScreenHeight();
232 // Private data
233 Window Root;
234 Display* Dpy;
235 int Scr;
236 + XineramaScreenInfo* screenInfo;
237 Panel* LoginPanel;
238 int ServerPID;
239 const char* DisplayName;
240 diff --git a/cfg.cpp b/cfg.cpp
241 index f53ddae..cf2127c 100644
242 --- a/cfg.cpp
243 +++ b/cfg.cpp
244 @@ -56,6 +56,7 @@ Cfg::Cfg()
245 options.insert(option("sessions","wmaker,blackbox,icewm"));
246 options.insert(option("sessiondir",""));
247 options.insert(option("hidecursor","false"));
248 + options.insert(option("xinerama_screen", "0"));
250 // Theme stuff
251 options.insert(option("input_panel_x","50%"));
252 diff --git a/panel.cpp b/panel.cpp
253 index 032574d..c0ac774 100644
254 --- a/panel.cpp
255 +++ b/panel.cpp
256 @@ -11,9 +11,12 @@
258 #include <sstream>
259 #include "panel.h"
260 +#include "app.h"
262 using namespace std;
264 +extern App* LoginApp;
266 Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
267 const string& themedir) {
268 // Set display
269 @@ -105,28 +108,27 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
274 if (bgstyle == "stretch") {
275 - bg->Resize(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
276 + bg->Resize(LoginApp->ScreenWidth(), LoginApp->ScreenHeight());
277 } else if (bgstyle == "tile") {
278 - bg->Tile(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
279 + bg->Tile(LoginApp->ScreenWidth(), LoginApp->ScreenHeight());
280 } else if (bgstyle == "center") {
281 string hexvalue = cfg->getOption("background_color");
282 hexvalue = hexvalue.substr(1,6);
283 - bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
284 - XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
285 + bg->Center(LoginApp->ScreenWidth(), LoginApp->ScreenHeight(),
286 hexvalue.c_str());
287 } else { // plain color or error
288 string hexvalue = cfg->getOption("background_color");
289 hexvalue = hexvalue.substr(1,6);
290 - bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
291 - XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
292 + bg->Center(LoginApp->ScreenWidth(), LoginApp->ScreenHeight(),
293 hexvalue.c_str());
296 string cfgX = cfg->getOption("input_panel_x");
297 string cfgY = cfg->getOption("input_panel_y");
298 - X = Cfg::absolutepos(cfgX, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), image->Width());
299 - Y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), image->Height());
300 + X = Cfg::absolutepos(cfgX, LoginApp->ScreenWidth(), image->Width());
301 + Y = Cfg::absolutepos(cfgY, LoginApp->ScreenHeight(), image->Height());
303 // Merge image into background
304 image->Merge(bg, X, Y);
305 @@ -210,8 +212,8 @@ void Panel::Message(const string& text) {
306 int shadowYOffset =
307 Cfg::string2int(cfg->getOption("msg_shadow_yoffset").c_str());
309 - int msg_x = Cfg::absolutepos(cfgX, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
310 - int msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
311 + int msg_x = Cfg::absolutepos(cfgX, LoginApp->ScreenWidth(), extents.width);
312 + int msg_y = Cfg::absolutepos(cfgY, LoginApp->ScreenHeight(), extents.height);
314 SlimDrawString8 (draw, &msgcolor, msgfont, msg_x, msg_y,
315 text,
316 @@ -585,8 +587,8 @@ void Panel::ShowSession() {
317 currsession.length(), &extents);
318 msg_x = cfg->getOption("session_x");
319 msg_y = cfg->getOption("session_y");
320 - int x = Cfg::absolutepos(msg_x, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
321 - int y = Cfg::absolutepos(msg_y, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
322 + int x = Cfg::absolutepos(msg_x, LoginApp->ScreenWidth(), extents.width);
323 + int y = Cfg::absolutepos(msg_y, LoginApp->ScreenHeight(), extents.height);
324 int shadowXOffset =
325 Cfg::string2int(cfg->getOption("session_shadow_xoffset").c_str());
326 int shadowYOffset =
327 diff --git a/slim.conf b/slim.conf
328 index 3542751..e72eca2 100644
329 --- a/slim.conf
330 +++ b/slim.conf
331 @@ -16,6 +16,8 @@ xauth_path /usr/bin/xauth
332 # Xauth file for server
333 authfile /var/run/slim.auth
335 +# Xinerama screen to show login panel on (zero-based)
336 +#xinerama_screen 0
338 # Activate numlock when slim starts. Valid values: on|off
339 # numlock on