* lock all screens when X runs in multiscreen mode and display whatever the

-bg defines

--HG--
extra : convert_revision : svn%3Aeebe1cee-a9af-4fe4-bd26-ad572b19c5ab/trunk%4040
This commit is contained in:
mathias 2006-05-05 00:41:21 +00:00
parent 569a19488c
commit 83cf2e7a88
16 changed files with 508 additions and 353 deletions

View file

@ -1,4 +1,6 @@
Version 1.0
2006-05-05:
* lock all screens if in X is running in multiscreen mode
2005-12-25:
* added -auth sha256
* added -auth sha384

4
README
View file

@ -1,7 +1,7 @@
alock - README
==============
Mathias Gumz <akira@fluxbox.org>
v1.0, 25 December 2005
v1.0, 05 May 2006
About
-----
@ -68,7 +68,7 @@ from 'xtrlock' left.
Author / Contributors
---------------------
* 2005 Mathias Gumz aka akira <akira@fluxbox.org> (code)
* 2005 - 2006 Mathias Gumz aka akira <akira@fluxbox.org> (code)
* 1993 - 1994 Ian Jackson (xtrlock)
* 2005 Tenner (alock-logo)

View file

@ -1,7 +1,7 @@
ALOCK(1)
========
Mathias Gumz <akira@fluxbox.org>
v1.0, 25 December 2005
v1.0, 05 May 2006
NAME
----
@ -108,6 +108,6 @@ Other Lockers ::
COPYING
-------
Copyright (C) 2005 Mathias Gumz. Free use of this software is
Copyright (C) 2005 - 2006 Mathias Gumz. Free use of this software is
granted under the terms of the MIT. See LICENSE provided in the
distribution.

View file

@ -2,7 +2,7 @@
#define alock_height 100
#define alock_x_hot 23
#define alock_y_hot 46
static unsigned char alock_bits[] = {
static char alock_bits[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,

View file

@ -131,10 +131,21 @@ void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) {
}
xinfo->display = dpy;
xinfo->window = 0;
xinfo->nr_screens = ScreenCount(dpy);
xinfo->root = DefaultRootWindow(dpy);
xinfo->colormap = DefaultColormap(dpy, DefaultScreen(dpy));
xinfo->window = (Window*)calloc(xinfo->nr_screens, sizeof(Window));
xinfo->root = (Window*)calloc(xinfo->nr_screens, sizeof(Window));
xinfo->colormap = (Colormap*)calloc(xinfo->nr_screens, sizeof(Colormap));
xinfo->cursor = (Cursor*)calloc(xinfo->nr_screens, sizeof(Cursor));
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
xinfo->window[scr] = 0;
xinfo->root[scr] = RootWindow(dpy, scr);
xinfo->colormap[scr] = DefaultColormap(dpy, scr);
}
}
}
int event_loop(struct aOpts* opts, struct aXInfo* xinfo) {
@ -358,24 +369,33 @@ int main(int argc, char **argv) {
exit(1);
}
XSelectInput(xinfo.display, xinfo.window, KeyPressMask|KeyReleaseMask);
XMapWindow(xinfo.display, xinfo.window);
XRaiseWindow(xinfo.display, xinfo.window);
{
int scr;
for (scr = 0; scr < xinfo.nr_screens; scr++) {
XSelectInput(xinfo.display, xinfo.window[scr], KeyPressMask|KeyReleaseMask);
XMapWindow(xinfo.display, xinfo.window[scr]);
XRaiseWindow(xinfo.display, xinfo.window[scr]);
}
}
/* try to grab 2 times, another process (windowmanager) may have grabbed
* the keyboard already */
if ((XGrabKeyboard(xinfo.display, xinfo.window, True, GrabModeAsync, GrabModeAsync,
CurrentTime)) != GrabSuccess) {
if ((XGrabKeyboard(xinfo.display, xinfo.window[0], True, GrabModeAsync, GrabModeAsync,
CurrentTime)) != GrabSuccess) {
sleep(1);
if ((XGrabKeyboard(xinfo.display, xinfo.window, True, GrabModeAsync, GrabModeAsync,
if ((XGrabKeyboard(xinfo.display, xinfo.window[0], True, GrabModeAsync, GrabModeAsync,
CurrentTime)) != GrabSuccess) {
printf("alock: couldnt grab the keyboard.\n");
exit(1);
}
}
if (XGrabPointer(xinfo.display, xinfo.window, False, (KeyPressMask|KeyReleaseMask) & 0,
GrabModeAsync, GrabModeAsync, None, xinfo.cursor, CurrentTime) != GrabSuccess) {
/* TODO: think about it: do we really need NR_SCREEN cursors ? we grab the
* pointer on :*.0 anyway ... */
if (XGrabPointer(xinfo.display, xinfo.window[0], False, (KeyPressMask|KeyReleaseMask) & 0,
GrabModeAsync, GrabModeAsync, None, xinfo.cursor[0], CurrentTime) != GrabSuccess) {
XUngrabKeyboard(xinfo.display, CurrentTime);
printf("alock: couldnt grab the pointer.\n");
exit(1);

View file

@ -33,12 +33,15 @@
struct aXInfo {
Display* display;
Window root;
Colormap colormap;
Display* display;
Window window;
Cursor cursor;
int nr_screens;
Window* root;
Colormap* colormap;
Window* window;
Cursor* cursor;
};
struct aAuth {
@ -71,8 +74,10 @@ struct aOpts {
\*------------------------------------------------------------------*/
void alock_string2lower(char* string);
int alock_native_byte_order();
int alock_alloc_color(const struct aXInfo* xinfo, const char* color_name,
const char* fallback_name, XColor* result);
int alock_alloc_color(const struct aXInfo* xinfo, const int scr,
const char* color_name,
const char* fallback_name,
XColor* result);
int alock_check_xrender(const struct aXInfo* xinfo);
int alock_shade_pixmap(const struct aXInfo* xinfo,
const Pixmap src_pm,

View file

@ -39,16 +39,18 @@ void alock_string2lower(char* string) {
/* ---------------------------------------------------------------- *\
\* ---------------------------------------------------------------- */
int alock_alloc_color(const struct aXInfo* xinfo, const char* color_name,
int alock_alloc_color(const struct aXInfo* xinfo, const int scr, const char* color_name,
const char* fallback_name, XColor* result) {
static XColor tmp;
if (!xinfo || !color_name || !fallback_name || !result)
if (!xinfo ||
!xinfo->colormap || xinfo->nr_screens < scr || scr < 0 ||
!color_name || !fallback_name || !result)
return 0;
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_name, &tmp, result)) == 0)
if ((XAllocNamedColor(xinfo->display, xinfo->colormap, fallback_name, &tmp, result)) == 0)
if((XAllocNamedColor(xinfo->display, xinfo->colormap[scr], color_name, &tmp, result)) == 0)
if ((XAllocNamedColor(xinfo->display, xinfo->colormap[scr], fallback_name, &tmp, result)) == 0)
return 0;
return 1;
}

View file

@ -31,8 +31,8 @@
/* ---------------------------------------------------------------- *\
\* ---------------------------------------------------------------- */
static Window window = 0;
static XColor color;
static Window* window = NULL;
static XColor* color = NULL;
static int alock_bg_blank_init(const char* args, struct aXInfo* xinfo) {
@ -60,38 +60,60 @@ static int alock_bg_blank_init(const char* args, struct aXInfo* xinfo) {
free(arguments);
}
alock_alloc_color(xinfo, color_name, "black", &color);
{
color = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
window = (Window*)calloc(xinfo->nr_screens, sizeof(Window));
}
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
alock_alloc_color(xinfo, scr, color_name, "black", &color[scr]);
XGetWindowAttributes(xinfo->display, xinfo->root[scr], &xgwa);
xswa.override_redirect = True;
xswa.colormap = xinfo->colormap[scr];
xswa.background_pixel = color[scr].pixel;
xsmask |= CWOverrideRedirect;
xsmask |= CWBackPixel;
xsmask |= CWColormap;
window[scr] = XCreateWindow(xinfo->display, xinfo->root[scr],
0, 0, xgwa.width, xgwa.height,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOutput, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
if (window[scr])
xinfo->window[scr] = window[scr];
}
}
free(color_name);
XGetWindowAttributes(xinfo->display, xinfo->root, &xgwa);
xswa.override_redirect = True;
xswa.colormap = xinfo->colormap;
xswa.background_pixel = color.pixel;
xsmask |= CWOverrideRedirect;
xsmask |= CWBackPixel;
xsmask |= CWColormap;
window = XCreateWindow(xinfo->display, xinfo->root,
0, 0, xgwa.width, xgwa.height,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOutput, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
if (window)
xinfo->window = window;
return window;
return 1;
}
static int alock_bg_blank_deinit(struct aXInfo* xinfo) {
if (!xinfo || !window)
if (!xinfo)
return 0;
XDestroyWindow(xinfo->display, window);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
if (window[scr])
XDestroyWindow(xinfo->display, window[scr]);
}
free(window);
free(color);
}
return 1;
}

View file

@ -39,9 +39,9 @@ enum {
ALOCK_TILED = 4
};
static Window window = 0;
static Pixmap pixmap = 0;
static XColor color;
static Window* window = NULL;
static Pixmap* pixmap = NULL;
static XColor* color = NULL;
static int alock_bg_image_init(const char* args, struct aXInfo* xinfo) {
@ -103,134 +103,149 @@ static int alock_bg_image_init(const char* args, struct aXInfo* xinfo) {
shade = 0;
}
alock_alloc_color(xinfo, color_name, "black", &color);
free(color_name);
XGetWindowAttributes(xinfo->display, xinfo->root, &xgwa);
{ /* get image and set it as the background pixmap for the window */
Imlib_Context context = NULL;
Imlib_Image image = NULL;
context = imlib_context_new();
imlib_context_push(context);
imlib_context_set_display(xinfo->display);
imlib_context_set_visual(DefaultVisual(xinfo->display,
DefaultScreen(xinfo->display)));
imlib_context_set_colormap(xinfo->colormap);
image = imlib_load_image_without_cache(filename);
if (image) {
char do_shade = shade > 0 && shade < 100;
int w;
int h;
pixmap = XCreatePixmap(xinfo->display, xinfo->root,
xgwa.width, xgwa.height,
DefaultDepth(xinfo->display, DefaultScreen(xinfo->display)));
imlib_context_set_drawable(pixmap);
imlib_context_set_image(image);
w = imlib_image_get_width();
h = imlib_image_get_height();
if (do_shade || options & ALOCK_CENTER) {
GC gc;
XGCValues gcval;
gcval.foreground = color.pixel;
gc = XCreateGC(xinfo->display, xinfo->root, GCForeground, &gcval);
XFillRectangle(xinfo->display, pixmap, gc, 0, 0, xgwa.width, xgwa.height);
XFreeGC(xinfo->display, gc);
}
if (do_shade) {
GC gc;
XGCValues gcval;
Pixmap tmp_pixmap = XCreatePixmap(xinfo->display, xinfo->root, w, h,
DefaultDepth(xinfo->display, DefaultScreen(xinfo->display)));
Pixmap shaded_pixmap = XCreatePixmap(xinfo->display, xinfo->root, w, h,
DefaultDepth(xinfo->display, DefaultScreen(xinfo->display)));
gcval.foreground = color.pixel;
gc = XCreateGC(xinfo->display, xinfo->root, GCForeground, &gcval);
XFillRectangle(xinfo->display, shaded_pixmap, gc, 0, 0, w, h);
imlib_context_set_drawable(tmp_pixmap);
imlib_render_image_on_drawable(0, 0);
alock_shade_pixmap(xinfo, tmp_pixmap, shaded_pixmap, shade, 0, 0, 0, 0, w, h);
imlib_free_image_and_decache();
imlib_context_set_drawable(shaded_pixmap);
image = imlib_create_image_from_drawable(None, 0, 0, w, h, 0);
XFreePixmap(xinfo->display, shaded_pixmap);
XFreePixmap(xinfo->display, tmp_pixmap);
imlib_context_set_drawable(pixmap);
imlib_context_set_image(image);
}
if (options & ALOCK_CENTER) {
imlib_render_image_on_drawable((xgwa.width - w)/2, (xgwa.height - h)/2);
} else if (options & ALOCK_TILED) {
Pixmap tile;
GC gc;
XGCValues gcval;
tile = XCreatePixmap(xinfo->display, xinfo->root,
w, h, DefaultDepth(xinfo->display, DefaultScreen(xinfo->display)));
imlib_render_image_on_drawable(0, 0);
gcval.fill_style = FillTiled;
gcval.tile = tile;
gc = XCreateGC(xinfo->display, tile, GCFillStyle|GCTile, &gcval);
XFillRectangle(xinfo->display, pixmap, gc, 0, 0, xgwa.width, xgwa.height);
XFreeGC(xinfo->display, gc);
XFreePixmap(xinfo->display, tile);
} else {/* fallback is ALOCK_SCALE */
imlib_render_image_on_drawable_at_size(0, 0, xgwa.width, xgwa.height);
}
imlib_free_image_and_decache();
} else {
printf("alock: error, couldnt load [%s].\n", filename);
if (filename)
free(filename);
XDestroyWindow(xinfo->display, window);
return 0;
}
imlib_context_pop();
imlib_context_free(context);
{
pixmap = (Pixmap*)calloc(xinfo->nr_screens, sizeof(Pixmap));
window = (Window*)calloc(xinfo->nr_screens, sizeof(Window));
color = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
}
xswa.override_redirect = True;
xswa.colormap = xinfo->colormap;
xswa.background_pixmap = pixmap;
{
int scr;
for (scr = 0; xinfo->nr_screens; scr++) {
xsmask |= CWOverrideRedirect;
xsmask |= CWColormap;
xsmask |= CWBackPixmap;
alock_alloc_color(xinfo, scr, color_name, "black", &color[scr]);
window = XCreateWindow(xinfo->display, xinfo->root,
0, 0, xgwa.width, xgwa.height,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOutput, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
XGetWindowAttributes(xinfo->display, xinfo->root[scr], &xgwa);
XMapWindow(xinfo->display, window);
{ /* get image and set it as the background pixmap for the window */
Imlib_Context context = NULL;
Imlib_Image image = NULL;
if (window)
xinfo->window = window;
context = imlib_context_new();
imlib_context_push(context);
imlib_context_set_display(xinfo->display);
imlib_context_set_visual(DefaultVisual(xinfo->display,
DefaultScreen(xinfo->display)));
imlib_context_set_colormap(xinfo->colormap[scr]);
image = imlib_load_image_without_cache(filename);
if (image) {
char do_shade = shade > 0 && shade < 100;
int w;
int h;
pixmap[scr] = XCreatePixmap(xinfo->display, xinfo->root[scr],
xgwa.width, xgwa.height,
DefaultDepth(xinfo->display, scr));
imlib_context_set_drawable(pixmap[scr]);
imlib_context_set_image(image);
w = imlib_image_get_width();
h = imlib_image_get_height();
if (do_shade || options & ALOCK_CENTER) {
GC gc;
XGCValues gcval;
gcval.foreground = color[scr].pixel;
gc = XCreateGC(xinfo->display, xinfo->root[scr], GCForeground, &gcval);
XFillRectangle(xinfo->display, pixmap[scr], gc, 0, 0, xgwa.width, xgwa.height);
XFreeGC(xinfo->display, gc);
}
if (do_shade) {
GC gc;
XGCValues gcval;
Pixmap tmp_pixmap = XCreatePixmap(xinfo->display, xinfo->root[scr], w, h,
DefaultDepth(xinfo->display, scr));
Pixmap shaded_pixmap = XCreatePixmap(xinfo->display, xinfo->root[scr], w, h,
DefaultDepth(xinfo->display, scr));
gcval.foreground = color[scr].pixel;
gc = XCreateGC(xinfo->display, xinfo->root[scr], GCForeground, &gcval);
XFillRectangle(xinfo->display, shaded_pixmap, gc, 0, 0, w, h);
imlib_context_set_drawable(tmp_pixmap);
imlib_render_image_on_drawable(0, 0);
alock_shade_pixmap(xinfo, tmp_pixmap, shaded_pixmap, shade, 0, 0, 0, 0, w, h);
imlib_free_image_and_decache();
imlib_context_set_drawable(shaded_pixmap);
image = imlib_create_image_from_drawable(None, 0, 0, w, h, 0);
XFreePixmap(xinfo->display, shaded_pixmap);
XFreePixmap(xinfo->display, tmp_pixmap);
imlib_context_set_drawable(pixmap[scr]);
imlib_context_set_image(image);
}
if (options & ALOCK_CENTER) {
imlib_render_image_on_drawable((xgwa.width - w)/2, (xgwa.height - h)/2);
} else if (options & ALOCK_TILED) {
Pixmap tile;
GC gc;
XGCValues gcval;
tile = XCreatePixmap(xinfo->display, xinfo->root[scr],
w, h, DefaultDepth(xinfo->display, scr));
imlib_render_image_on_drawable(0, 0);
gcval.fill_style = FillTiled;
gcval.tile = tile;
gc = XCreateGC(xinfo->display, tile, GCFillStyle|GCTile, &gcval);
XFillRectangle(xinfo->display, pixmap[scr], gc, 0, 0, xgwa.width, xgwa.height);
XFreeGC(xinfo->display, gc);
XFreePixmap(xinfo->display, tile);
} else {/* fallback is ALOCK_SCALE */
imlib_render_image_on_drawable_at_size(0, 0, xgwa.width, xgwa.height);
}
imlib_free_image_and_decache();
} else {
printf("alock: error, couldnt load [%s].\n", filename);
if (filename)
free(filename);
XDestroyWindow(xinfo->display, window[scr]);
return 0;
}
imlib_context_pop();
imlib_context_free(context);
}
xswa.override_redirect = True;
xswa.colormap = xinfo->colormap[scr];
xswa.background_pixmap = pixmap[scr];
xsmask |= CWOverrideRedirect;
xsmask |= CWColormap;
xsmask |= CWBackPixmap;
window[scr] = XCreateWindow(xinfo->display, xinfo->root[scr],
0, 0, xgwa.width, xgwa.height,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOutput, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
XMapWindow(xinfo->display, window[scr]);
if (window[scr])
xinfo->window[scr] = window[scr];
}
free(color_name);
}
if (filename)
free(filename);
@ -242,8 +257,16 @@ static int alock_bg_image_init(const char* args, struct aXInfo* xinfo) {
static int alock_bg_image_deinit(struct aXInfo* xinfo) {
if (!xinfo || !window)
return 0;
XDestroyWindow(xinfo->display, window);
XFreePixmap(xinfo->display, pixmap);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
XDestroyWindow(xinfo->display, window[scr]);
XFreePixmap(xinfo->display, pixmap[scr]);
}
free(color);
free(pixmap);
free(window);
}
return 1;
}

View file

@ -21,11 +21,12 @@
includes
\* ---------------------------------------------------------------- */
#include <X11/Xlib.h>
#include <stdlib.h>
#include "alock.h"
/* ---------------------------------------------------------------- *\
\* ---------------------------------------------------------------- */
static Window window = 0;
static Window* window = NULL;
static int alock_bg_none_init(const char* args, struct aXInfo* xinfo) {
@ -35,27 +36,38 @@ static int alock_bg_none_init(const char* args, struct aXInfo* xinfo) {
if (!xinfo)
return 0;
window = (Window*)calloc(xinfo->nr_screens, sizeof(Window));
xswa.override_redirect = True;
xsmask |= CWOverrideRedirect;
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
window[scr] = XCreateWindow(xinfo->display, xinfo->root[scr],
0, 0, 1, 1,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOnly, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
window = XCreateWindow(xinfo->display, xinfo->root,
0, 0, 1, 1,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOnly, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
if (window[scr])
xinfo->window[scr] = window[scr];
}
}
if (window)
xinfo->window = window;
return window;
return 1;
}
static int alock_bg_none_deinit(struct aXInfo* xinfo) {
if (!xinfo || !window)
return 0;
XDestroyWindow(xinfo->display, window);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
XDestroyWindow(xinfo->display, window[scr]);
}
}
return 1;
}

View file

@ -32,8 +32,8 @@
/* ---------------------------------------------------------------- *\
\* ---------------------------------------------------------------- */
static Window window = 0;
static XColor color;
static Window* window = NULL;
static XColor* color = NULL;
static int alock_bg_shade_init(const char* args, struct aXInfo* xinfo) {
@ -83,79 +83,95 @@ static int alock_bg_shade_init(const char* args, struct aXInfo* xinfo) {
return 0;
}
/* get a color from color_name */
alock_alloc_color(xinfo, color_name, "black", &color);
free(color_name);
{ /* get dimension of the screen */
XWindowAttributes xgwa;
XGetWindowAttributes(xinfo->display, xinfo->root, &xgwa);
width = xgwa.width;
height = xgwa.height;
{
window = (Window*)calloc(xinfo->nr_screens, sizeof(Window));
color = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
}
{ /* xrender stuff */
Display* dpy = xinfo->display;
Window root = xinfo->root;
int scrnr = DefaultScreen(dpy);
int depth = DefaultDepth(dpy, scrnr);
GC gc = DefaultGC(dpy, scrnr);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
{ /* grab whats on the screen */
XImage* image = XGetImage(dpy, root, 0, 0, width, height, AllPlanes, ZPixmap);
src_pm = XCreatePixmap(dpy, root, width, height, depth);
XPutImage(dpy, src_pm, gc, image, 0, 0, 0, 0, width, height);
XDestroyImage(image);
/* get a color from color_name */
alock_alloc_color(xinfo, scr, color_name, "black", &color[scr]);
{ /* get dimension of the screen */
XWindowAttributes xgwa;
XGetWindowAttributes(xinfo->display, xinfo->root[scr], &xgwa);
width = xgwa.width;
height = xgwa.height;
}
{ /* xrender stuff */
Display* dpy = xinfo->display;
Window root = xinfo->root[scr];
int depth = DefaultDepth(dpy, scr);
GC gc = DefaultGC(dpy, scr);
{ /* grab whats on the screen */
XImage* image = XGetImage(dpy, root, 0, 0, width, height, AllPlanes, ZPixmap);
src_pm = XCreatePixmap(dpy, root, width, height, depth);
XPutImage(dpy, src_pm, gc, image, 0, 0, 0, 0, width, height);
XDestroyImage(image);
}
dst_pm = XCreatePixmap(dpy, root, width, height, depth);
{ /* tint the dst*/
GC tintgc;
XGCValues tintval;
tintval.foreground = color[scr].pixel;
tintgc = XCreateGC(dpy, dst_pm, GCForeground, &tintval);
XFillRectangle(dpy, dst_pm, tintgc, 0, 0, width, height);
XFreeGC(dpy, tintgc);
}
alock_shade_pixmap(xinfo, src_pm, dst_pm, shade, 0, 0, 0, 0, width, height);
}
{ /* create final window */
XSetWindowAttributes xswa;
long xsmask = 0;
xswa.override_redirect = True;
xswa.colormap = xinfo->colormap[scr];
xswa.background_pixmap = dst_pm;
xsmask |= CWOverrideRedirect;
xsmask |= CWBackPixmap;
xsmask |= CWColormap;
window[scr] = XCreateWindow(xinfo->display, xinfo->root[scr],
0, 0, width, height,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOutput, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
XFreePixmap(xinfo->display, src_pm);
XFreePixmap(xinfo->display, dst_pm);
}
if (window[scr])
xinfo->window[scr] = window[scr];
}
dst_pm = XCreatePixmap(dpy, root, width, height, depth);
{ /* tint the dst*/
GC tintgc;
XGCValues tintval;
tintval.foreground = color.pixel;
tintgc = XCreateGC(dpy, dst_pm, GCForeground, &tintval);
XFillRectangle(dpy, dst_pm, tintgc, 0, 0, width, height);
XFreeGC(dpy, tintgc);
}
alock_shade_pixmap(xinfo, src_pm, dst_pm, shade, 0, 0, 0, 0, width, height);
free(color_name);
}
{ /* create final window */
XSetWindowAttributes xswa;
long xsmask = 0;
xswa.override_redirect = True;
xswa.colormap = xinfo->colormap;
xswa.background_pixmap = dst_pm;
xsmask |= CWOverrideRedirect;
xsmask |= CWBackPixmap;
xsmask |= CWColormap;
window = XCreateWindow(xinfo->display, xinfo->root,
0, 0, width, height,
0, /* borderwidth */
CopyFromParent, /* depth */
InputOutput, /* class */
CopyFromParent, /* visual */
xsmask, &xswa);
XFreePixmap(xinfo->display, src_pm);
XFreePixmap(xinfo->display, dst_pm);
}
if (window)
xinfo->window = window;
return window;
return 1;
}
static int alock_bg_shade_deinit(struct aXInfo* xinfo) {
if (!xinfo || !window)
return 0;
XDestroyWindow(xinfo->display, window);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
XDestroyWindow(xinfo->display, window[scr]);
}
free(window);
free(color);
}
return 1;
}

View file

@ -123,9 +123,9 @@ static const struct CursorFontName cursor_names[] = {
\*------------------------------------------------------------------*/
static Cursor cursor = 0;
static XColor color_fg;
static XColor color_bg;
static Cursor* cursor = NULL;
static XColor* color_fg = NULL;
static XColor* color_bg = NULL;
static int alock_cursor_glyph_init(const char* args, struct aXInfo* xinfo) {
@ -179,19 +179,31 @@ static int alock_cursor_glyph_init(const char* args, struct aXInfo* xinfo) {
free(arguments);
}
alock_alloc_color(xinfo, color_bg_name, "black", &color_bg);
alock_alloc_color(xinfo, color_fg_name, "white", &color_fg);
{
cursor = (Cursor*)calloc(xinfo->nr_screens, sizeof(Cursor));
color_fg = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
color_bg = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
}
free(color_fg_name);
free(color_bg_name);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
/* create cursor from X11/cursorfont.h */
if ((cursor = XCreateFontCursor(xinfo->display, shape))) {
XRecolorCursor(xinfo->display, cursor, &color_fg, &color_bg);
xinfo->cursor = cursor;
} else {
printf("alock: error, couldnt create fontcursor [%d].\n", shape);
return 0;
alock_alloc_color(xinfo, scr, color_bg_name, "black", &color_bg[scr]);
alock_alloc_color(xinfo, scr, color_fg_name, "white", &color_fg[scr]);
/* create cursor from X11/cursorfont.h */
if ((cursor[scr] = XCreateFontCursor(xinfo->display, shape))) {
XRecolorCursor(xinfo->display, cursor[scr], &color_fg[scr], &color_bg[scr]);
xinfo->cursor[scr] = cursor[scr];
} else {
printf("alock: error, couldnt create fontcursor [%d].\n", shape);
return 0;
}
}
free(color_fg_name);
free(color_bg_name);
}
return 1;
@ -202,7 +214,16 @@ static int alock_cursor_glyph_deinit(struct aXInfo* xinfo) {
if (!xinfo || !cursor)
return 0;
XFreeCursor(xinfo->display, cursor);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
XFreeCursor(xinfo->display, cursor[scr]);
}
free(cursor);
free(color_bg);
free(color_fg);
}
return 1;
}

View file

@ -90,7 +90,7 @@ static int alock_cursor_image_init(const char* args, struct aXInfo* xinfo) {
imlib_context_push(ctx);
imlib_context_set_display(xinfo->display);
imlib_context_set_visual(DefaultVisual(xinfo->display, DefaultScreen(xinfo->display)));
imlib_context_set_colormap(xinfo->colormap);
imlib_context_set_colormap(xinfo->colormap[0]);
img = imlib_load_image_without_cache(filename);
if (img) {
@ -120,7 +120,7 @@ static int alock_cursor_image_init(const char* args, struct aXInfo* xinfo) {
XInitImage(&ximage);
cursor_pm = XCreatePixmap(xinfo->display, xinfo->root, w, h, 32);
cursor_pm = XCreatePixmap(xinfo->display, xinfo->root[0], w, h, 32);
gc = XCreateGC(xinfo->display, cursor_pm, 0, 0);
XPutImage(xinfo->display, cursor_pm, gc, &ximage, 0, 0, 0, 0, w, h);
XFreeGC(xinfo->display, gc);
@ -140,7 +140,7 @@ static int alock_cursor_image_init(const char* args, struct aXInfo* xinfo) {
h = img->height;
cursor_pm = XCreatePixmap(xinfo->display,
xinfo->root,
xinfo->root[0],
w, h,
img->depth);
gc = XCreateGC(xinfo->display, cursor_pm, 0, NULL);
@ -179,7 +179,12 @@ static int alock_cursor_image_init(const char* args, struct aXInfo* xinfo) {
free(filename);
xinfo->cursor = cursor;
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
xinfo->cursor[scr] = cursor;
}
}
return cursor;
}

View file

@ -29,7 +29,11 @@
\* ---------------------------------------------------------------- */
static int alock_cursor_none_init(const char* args, struct aXInfo* xinfo) {
xinfo->cursor = None;
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
xinfo->cursor[scr] = None;
}
return 1;
}

View file

@ -82,9 +82,9 @@ static struct ThemeCursor cursors[] = {
/*------------------------------------------------------------------*\
\*------------------------------------------------------------------*/
static Cursor cursor = 0;
static XColor color_fg;
static XColor color_bg;
static Cursor* cursor = NULL;
static XColor* color_fg = NULL;
static XColor* color_bg = NULL;
static int alock_cursor_theme_init(const char* args, struct aXInfo* xinfo) {
char* color_bg_name = strdup("steelblue3");
@ -139,34 +139,52 @@ static int alock_cursor_theme_init(const char* args, struct aXInfo* xinfo) {
free(arguments);
}
alock_alloc_color(xinfo, color_fg_name, "white", &color_fg);
alock_alloc_color(xinfo, color_bg_name, "blank", &color_bg);
{
int scr;
for (scr = 0; xinfo->nr_screens; scr++) {
alock_alloc_color(xinfo, scr, color_fg_name, "white", &color_fg[scr]);
alock_alloc_color(xinfo, scr, color_bg_name, "blank", &color_bg[scr]);
}
free(color_fg_name);
free(color_bg_name);
cursor = (Cursor*)calloc(xinfo->nr_screens, sizeof(Cursor));
color_bg = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
color_fg = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));
pixmap_cursor = XCreateBitmapFromData(xinfo->display, xinfo->root,
free(color_fg_name);
free(color_bg_name);
for (scr = 0; xinfo->nr_screens; scr++) {
pixmap_cursor = XCreateBitmapFromData(xinfo->display, xinfo->root[scr],
theme->bits, theme->width, theme->height);
pixmap_cursor_mask = XCreateBitmapFromData(xinfo->display, xinfo->root,
theme->mask, theme->width, theme->height);
pixmap_cursor_mask = XCreateBitmapFromData(xinfo->display, xinfo->root[scr],
theme->mask, theme->width, theme->height);
cursor = XCreatePixmapCursor(xinfo->display,
cursor[scr] = XCreatePixmapCursor(xinfo->display,
pixmap_cursor, pixmap_cursor_mask,
&color_fg, &color_bg,
&color_fg[scr], &color_bg[scr],
theme->x_hot, theme->y_hot);
if (cursor) {
xinfo->cursor = cursor;
return 1;
} else
return 0;
if (cursor)
xinfo->cursor = cursor;
}
}
return 1;
}
static int alock_cursor_theme_deinit(struct aXInfo* xinfo) {
if (!xinfo || !cursor)
return 0;
XFreeCursor(xinfo->display, cursor);
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
XFreeCursor(xinfo->display, cursor[scr]);
}
free(cursor);
free(color_bg);
free(color_fg);
}
return 1;
}

View file

@ -52,7 +52,12 @@ static int alock_cursor_xcursor_init(const char* args, struct aXInfo* xinfo) {
return 0;
}
xinfo->cursor = cursor;
{
int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) {
xinfo->cursor[scr] = cursor;
}
}
return 1;
}