@@ -36,20 +36,20 @@ struct Rect get_screen_dimensions()
3636void Draw_begin ()
3737{
3838 if (current_state .conf -> active ){
39- // get current window size
40- XGetWindowAttributes (d ,w ,& attr );
41- rect .right = attr .width ;
42- rect .bottom = attr .height ;
43- buffer = XCreatePixmap (d ,w ,rect .right ,rect .bottom , 24 );
44-
45- Draw_Rect (& rect , (struct Color ){0 ,0 ,0 });
46- XSetForeground (d , gc , 0 );
39+ // get current window size
40+ XGetWindowAttributes (d ,w ,& attr );
41+ rect .right = attr .width ;
42+ rect .bottom = attr .height ;
43+ buffer = XCreatePixmap (d ,w ,rect .right ,rect .bottom , 24 );
44+
45+ Draw_Rect (& rect , (struct Color ){0 ,0 ,0 });
46+ XSetForeground (d , gc , 0 );
4747 }
4848}
4949
5050void Draw_Rect (struct Rect * rect , struct Color col )
5151{
52- if (current_state . conf -> active ){
52+ if (buffer ){
5353 XGCValues v ;
5454 v .foreground = RGB (col .r , col .g , col .b );
5555 GC color = XCreateGC (d ,buffer ,GCForeground ,& v );
@@ -72,6 +72,7 @@ void Draw_end()
7272{
7373 XCopyArea (d , buffer , w , gc , 0 ,0 , rect .right , rect .bottom , 0 , 0 );
7474 XFreePixmap (d , buffer );
75+ buffer = 0 ;
7576
7677}
7778
@@ -85,7 +86,7 @@ static void* GUI_thread_proc(void *unused){
8586
8687 XMapWindow (d ,w );
8788
88- current_state .conf -> active = 1 ;
89+ current_state .conf -> active = 1 ;
8990
9091 while (current_state .conf -> active ){
9192 // while(XNextEvent(d, &e)){
0 commit comments