slock

Kris's build of slock (slock-flexipatch)
git clone git clone https://git.krisyotam.com/krisyotam/slock.git
Log | Files | Refs | README | LICENSE

keypress_feedback.c (870B)


      1 static void
      2 draw_key_feedback(Display *dpy, struct lock **locks, int screen)
      3 {
      4 	XGCValues gr_values;
      5 
      6 	Window win = locks[screen]->win;
      7 	Window root_win;
      8 
      9 	gr_values.foreground = locks[screen]->colors[BLOCKS];
     10 	GC gc = XCreateGC(dpy, win, GCForeground, &gr_values);
     11 
     12 	int width = blocks_width, height = blocks_height;
     13 	if (blocks_height == 0 || blocks_width == 0) {
     14 		int _x, _y;
     15 		unsigned int screen_width, screen_height, _b, _d;
     16 		XGetGeometry(dpy, win, &root_win, &_x, &_y, &screen_width, &screen_height, &_b, &_d);
     17 		width = blocks_width ? blocks_width : screen_width;
     18 		height = blocks_height ? blocks_height : screen_height;
     19 	}
     20 
     21 	unsigned int block_width = width / blocks_count;
     22 	unsigned int position = rand() % blocks_count;
     23 
     24 	XClearWindow(dpy, win);
     25 	XFillRectangle(dpy, win, gc, blocks_x + position*block_width, blocks_y, width, height);
     26 
     27 	XFreeGC(dpy, gc);
     28 }