mirror of https://github.com/i3/i3lock.git
adding option to enable tiling of images
parent
0b1d84bb7a
commit
1cddfc4a98
|
@ -13,7 +13,7 @@ MANDIR = $(DESTDIR)$(PREFIX)/share/man
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I. -I/usr/include -I${X11INC}
|
INCS = -I. -I/usr/include -I${X11INC}
|
||||||
LIBS = -L${X11LIB} -lX11 -lpam -lXext -lXpm
|
LIBS = -L${X11LIB} -lX11 -lpam -lXext -lXpm -lm
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -DVERSION=\"${VERSION}\"
|
CPPFLAGS = -DVERSION=\"${VERSION}\"
|
||||||
|
|
6
i3lock.1
6
i3lock.1
|
@ -23,6 +23,7 @@ i3lock \- slightly improved version of slock
|
||||||
.IR image.xpm \|]
|
.IR image.xpm \|]
|
||||||
.RB [\|\-c
|
.RB [\|\-c
|
||||||
.IR color \|]
|
.IR color \|]
|
||||||
|
.RB [\|\-t\|]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B i3lock
|
.B i3lock
|
||||||
|
@ -77,6 +78,11 @@ XPM by using convert(1) from ImageMagick or GIMP for example.
|
||||||
.B \-c, \-\-color
|
.B \-c, \-\-color
|
||||||
Turns the screen into the given color instead of white. Color must be given in 6-byte format: rrggbb (i.e. ff0000 is red)
|
Turns the screen into the given color instead of white. Color must be given in 6-byte format: rrggbb (i.e. ff0000 is red)
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-t, \-\-tiling
|
||||||
|
If an image is specified (via -i) it will display the image tiled all over the screen (if it is a multi-monitor setup, the image is visible on all screens)
|
||||||
|
>>>>>>> adding option to enable tiling of images:i3lock.1
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
Michael Stapelberg <michael+i3lock at stapelberg dot de>
|
Michael Stapelberg <michael+i3lock at stapelberg dot de>
|
||||||
|
|
||||||
|
|
55
i3lock.c
55
i3lock.c
|
@ -22,6 +22,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
@ -36,6 +37,31 @@
|
||||||
|
|
||||||
static char passwd[256];
|
static char passwd[256];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* displays an xpm image tiled over the whole screen
|
||||||
|
* (the image will be visible on all screens
|
||||||
|
* when using a multi monitor setup)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void tiling_image(XpmImage *image,
|
||||||
|
int disp_height, int disp_width,
|
||||||
|
Display *dpy,
|
||||||
|
Pixmap pix,
|
||||||
|
Window w,
|
||||||
|
GC gc) {
|
||||||
|
int rows = (int)ceil(disp_height / (float)image->height),
|
||||||
|
cols = (int)ceil(disp_width / (float)image->width);
|
||||||
|
|
||||||
|
int x = 0,
|
||||||
|
y = 0;
|
||||||
|
|
||||||
|
for(y = 0; y < rows; y++) {
|
||||||
|
for(x = 0; x < cols; x++) {
|
||||||
|
XCopyArea(dpy, pix, w, gc, 0, 0, image->width, image->height, image->width * x, image->height * y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void die(const char *errstr, ...) {
|
static void die(const char *errstr, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
@ -151,6 +177,7 @@ int main(int argc, char *argv[]) {
|
||||||
bool beep = false;
|
bool beep = false;
|
||||||
bool dpms = false;
|
bool dpms = false;
|
||||||
bool xpm_image = false;
|
bool xpm_image = false;
|
||||||
|
bool tiling = false;
|
||||||
char xpm_image_path[256];
|
char xpm_image_path[256];
|
||||||
char color[7] = "ffffff"; // white
|
char color[7] = "ffffff"; // white
|
||||||
Cursor invisible;
|
Cursor invisible;
|
||||||
|
@ -174,10 +201,11 @@ int main(int argc, char *argv[]) {
|
||||||
{"dpms", no_argument, NULL, 'd'},
|
{"dpms", no_argument, NULL, 'd'},
|
||||||
{"image", required_argument, NULL, 'i'},
|
{"image", required_argument, NULL, 'i'},
|
||||||
{"color", required_argument, NULL, 'c'},
|
{"color", required_argument, NULL, 'c'},
|
||||||
|
{"tiling", no_argument, NULL, 't'},
|
||||||
{NULL, no_argument, NULL, 0}
|
{NULL, no_argument, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "vnbdi:c:", long_options, &optind)) != -1) {
|
while ((opt = getopt_long(argc, argv, "vnbdi:c:t", long_options, &optind)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'v':
|
case 'v':
|
||||||
die("i3lock-"VERSION", © 2009 Michael Stapelberg\n"
|
die("i3lock-"VERSION", © 2009 Michael Stapelberg\n"
|
||||||
|
@ -207,8 +235,11 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 't':
|
||||||
|
tiling = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color]\n");
|
die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color] [-t]\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,19 +272,31 @@ int main(int argc, char *argv[]) {
|
||||||
XDefineCursor(dpy, w, invisible);
|
XDefineCursor(dpy, w, invisible);
|
||||||
XMapRaised(dpy, w);
|
XMapRaised(dpy, w);
|
||||||
|
|
||||||
if(xpm_image && file_exists(xpm_image_path))
|
if (xpm_image && file_exists(xpm_image_path)) {
|
||||||
{
|
|
||||||
GC gc = XDefaultGC(dpy, 0);
|
GC gc = XDefaultGC(dpy, 0);
|
||||||
int depth = DefaultDepth(dpy, screen);
|
int depth = DefaultDepth(dpy, screen);
|
||||||
int disp_width = DisplayWidth(dpy, screen);
|
int disp_width = DisplayWidth(dpy, screen);
|
||||||
int disp_height = DisplayHeight(dpy, screen);
|
int disp_height = DisplayHeight(dpy, screen);
|
||||||
Pixmap pix = XCreatePixmap(dpy, w, disp_width, disp_height, depth);
|
Pixmap pix = XCreatePixmap(dpy, w, disp_width, disp_height, depth);
|
||||||
int err = XpmReadFileToPixmap(dpy, w, xpm_image_path, &pix, 0, 0);
|
XpmImage xpm_image;
|
||||||
|
XpmInfo xpm_info;
|
||||||
|
|
||||||
|
int err = XpmReadFileToXpmImage(xpm_image_path, &xpm_image, &xpm_info);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
print_xpm_error(err);
|
print_xpm_error(err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
|
|
||||||
|
err = XpmCreatePixmapFromXpmImage(dpy, w, &xpm_image, &pix, 0, 0);
|
||||||
|
if (err != 0) {
|
||||||
|
print_xpm_error(err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tiling)
|
||||||
|
tiling_image(&xpm_image, disp_height, disp_width, dpy, pix, w, gc);
|
||||||
|
else
|
||||||
|
XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(len = 1000; len; len--) {
|
for(len = 1000; len; len--) {
|
||||||
|
|
Loading…
Reference in New Issue