@ -76,7 +76,7 @@ char *argv0;
# define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
# define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg)
# define IS_SET(flag) ((term.mode & (flag)) != 0)
# define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_ usec-t2.tv_usec)/ 1000 )
# define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_ nsec-t2.tv_nsec)/ 10E6 )
# define CEIL(x) (((x) != (int) (x)) ? (x) + 1 : (x))
# define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
@ -294,8 +294,8 @@ typedef struct {
char * clip ;
Atom xtarget ;
bool alt ;
struct time val tclick1 ;
struct time val tclick2 ;
struct time spec tclick1 ;
struct time spec tclick2 ;
} Selection ;
typedef union {
@ -860,7 +860,7 @@ mousereport(XEvent *e) {
void
bpress ( XEvent * e ) {
struct time val now ;
struct time spec now ;
Mousekey * mk ;
if ( IS_SET ( MODE_MOUSE ) & & ! ( e - > xbutton . state & forceselmod ) ) {
@ -877,7 +877,7 @@ bpress(XEvent *e) {
}
if ( e - > xbutton . button = = Button1 ) {
gettimeofday ( & now , NULL ) ;
clock_ gettime( CLOCK_MONOTONIC , & now ) ;
/* Clear previous selection, logically and visually. */
selclear ( NULL ) ;
@ -3709,7 +3709,8 @@ run(void) {
int w = xw . w , h = xw . h ;
fd_set rfd ;
int xfd = XConnectionNumber ( xw . dpy ) , xev , blinkset = 0 , dodraw = 0 ;
struct timeval drawtimeout , * tv = NULL , now , last , lastblink ;
struct timespec drawtimeout , * tv = NULL , now , last , lastblink ;
long deltatime ;
/* Waiting for window mapping */
while ( 1 ) {
@ -3725,17 +3726,15 @@ run(void) {
ttynew ( ) ;
cresize ( w , h ) ;
gettimeofday ( & last , NULL ) ;
clock_ gettime( CLOCK_MONOTONIC , & last ) ;
lastblink = last ;
for ( xev = actionfps ; ; ) {
long deltatime ;
FD_ZERO ( & rfd ) ;
FD_SET ( cmdfd , & rfd ) ;
FD_SET ( xfd , & rfd ) ;
if ( select( MAX ( xfd , cmdfd ) + 1 , & rfd , NULL , NULL , tv ) < 0 ) {
if ( p select( MAX ( xfd , cmdfd ) + 1 , & rfd , NULL , NULL , tv , NULL ) < 0 ) {
if ( errno = = EINTR )
continue ;
die ( " select failed: %s \n " , strerror ( errno ) ) ;
@ -3752,9 +3751,9 @@ run(void) {
if ( FD_ISSET ( xfd , & rfd ) )
xev = actionfps ;
gettimeofday ( & now , NULL ) ;
clock_ gettime( CLOCK_MONOTONIC , & now ) ;
drawtimeout . tv_sec = 0 ;
drawtimeout . tv_ usec = ( 1000 / xfps ) * 1000 ;
drawtimeout . tv_ nsec = ( 1000 / xfps ) * 10E6 ;
tv = & drawtimeout ;
dodraw = 0 ;
@ -3789,9 +3788,9 @@ run(void) {
if ( blinkset ) {
if ( TIMEDIFF ( now , lastblink ) \
> blinktimeout ) {
drawtimeout . tv_ usec = 1 ;
drawtimeout . tv_ nsec = 1000 ;
} else {
drawtimeout . tv_ usec = ( 1000 * \
drawtimeout . tv_ nsec = ( 10E6 * \
( blinktimeout - \
TIMEDIFF ( now ,
lastblink ) ) ) ;