@ -51,6 +51,7 @@ typedef struct {
/* function definitions used in config.h */
/* function definitions used in config.h */
static void clipcopy ( const Arg * ) ;
static void clipcopy ( const Arg * ) ;
static void clippaste ( const Arg * ) ;
static void clippaste ( const Arg * ) ;
static void numlock ( const Arg * ) ;
static void selpaste ( const Arg * ) ;
static void selpaste ( const Arg * ) ;
static void zoom ( const Arg * ) ;
static void zoom ( const Arg * ) ;
static void zoomabs ( const Arg * ) ;
static void zoomabs ( const Arg * ) ;
@ -64,6 +65,7 @@ static void zoomreset(const Arg *);
# define XEMBED_FOCUS_OUT 5
# define XEMBED_FOCUS_OUT 5
/* macros */
/* macros */
# define IS_SET(flag) ((win.mode & (flag)) != 0)
# define TRUERED(x) (((x) & 0xff0000) >> 8)
# define TRUERED(x) (((x) & 0xff0000) >> 8)
# define TRUEGREEN(x) (((x) & 0xff00))
# define TRUEGREEN(x) (((x) & 0xff00))
# define TRUEBLUE(x) (((x) & 0xff) << 8)
# define TRUEBLUE(x) (((x) & 0xff) << 8)
@ -196,11 +198,6 @@ static XWindow xw;
static XSelection xsel ;
static XSelection xsel ;
static TermWindow win ;
static TermWindow win ;
enum window_state {
WIN_VISIBLE = 1 ,
WIN_FOCUSED = 2
} ;
/* Font Ring Cache */
/* Font Ring Cache */
enum {
enum {
FRC_NORMAL ,
FRC_NORMAL ,
@ -263,6 +260,12 @@ selpaste(const Arg *dummy)
xw . win , CurrentTime ) ;
xw . win , CurrentTime ) ;
}
}
void
numlock ( const Arg * dummy )
{
win . mode ^ = MODE_NUMLOCK ;
}
void
void
zoom ( const Arg * arg )
zoom ( const Arg * arg )
{
{
@ -1090,6 +1093,7 @@ xinit(void)
XChangeProperty ( xw . dpy , xw . win , xw . netwmpid , XA_CARDINAL , 32 ,
XChangeProperty ( xw . dpy , xw . win , xw . netwmpid , XA_CARDINAL , 32 ,
PropModeReplace , ( uchar * ) & thispid , 1 ) ;
PropModeReplace , ( uchar * ) & thispid , 1 ) ;
win . mode = MODE_NUMLOCK ;
resettitle ( ) ;
resettitle ( ) ;
XMapWindow ( xw . dpy , xw . win ) ;
XMapWindow ( xw . dpy , xw . win ) ;
xhints ( ) ;
xhints ( ) ;
@ -1319,14 +1323,13 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
fg = & revfg ;
fg = & revfg ;
}
}
if ( base . mode & ATTR_REVERSE ) {
if ( base . mode & ATTR_REVERSE ) {
temp = fg ;
temp = fg ;
fg = bg ;
fg = bg ;
bg = temp ;
bg = temp ;
}
}
if ( base . mode & ATTR_BLINK & & term . mode & MODE_BLINK )
if ( base . mode & ATTR_BLINK & & win . mode & MODE_BLINK )
fg = bg ;
fg = bg ;
if ( base . mode & ATTR_INVISIBLE )
if ( base . mode & ATTR_INVISIBLE )
@ -1440,7 +1443,7 @@ xdrawcursor(void)
return ;
return ;
/* draw the new one */
/* draw the new one */
if ( win . state & WIN_FOCUSED ) {
if ( IS_SET ( MODE_FOCUSED ) ) {
switch ( win . cursor ) {
switch ( win . cursor ) {
case 7 : /* st extension: snowman */
case 7 : /* st extension: snowman */
utf8decode ( " ☃ " , & g . u , UTF_SIZ ) ;
utf8decode ( " ☃ " , & g . u , UTF_SIZ ) ;
@ -1527,7 +1530,7 @@ drawregion(int x1, int y1, int x2, int y2)
Glyph base , new ;
Glyph base , new ;
XftGlyphFontSpec * specs ;
XftGlyphFontSpec * specs ;
if ( ! ( win . state & WIN_VISIBLE ) )
if ( ! ( IS_SET ( MODE_VISIBLE ) ) )
return ;
return ;
for ( y = y1 ; y < y2 ; y + + ) {
for ( y = y1 ; y < y2 ; y + + ) {
@ -1575,13 +1578,13 @@ visibility(XEvent *ev)
{
{
XVisibilityEvent * e = & ev - > xvisibility ;
XVisibilityEvent * e = & ev - > xvisibility ;
MODBIT ( win . stat e, e - > state ! = VisibilityFullyObscured , WIN _VISIBLE) ;
MODBIT ( win . mod e, e - > state ! = VisibilityFullyObscured , MODE _VISIBLE) ;
}
}
void
void
unmap ( XEvent * ev )
unmap ( XEvent * ev )
{
{
win . stat e & = ~ WIN _VISIBLE;
win . mod e & = ~ MODE _VISIBLE;
}
}
void
void
@ -1591,6 +1594,15 @@ xsetpointermotion(int set)
XChangeWindowAttributes ( xw . dpy , xw . win , CWEventMask , & xw . attrs ) ;
XChangeWindowAttributes ( xw . dpy , xw . win , CWEventMask , & xw . attrs ) ;
}
}
void
xsetmode ( int set , unsigned int flags )
{
int mode = win . mode ;
MODBIT ( win . mode , set , flags ) ;
if ( ( win . mode & MODE_REVERSE ) ! = ( mode & MODE_REVERSE ) )
redraw ( ) ;
}
int
int
xsetcursor ( int cursor )
xsetcursor ( int cursor )
{
{
@ -1614,7 +1626,7 @@ xseturgency(int add)
void
void
xbell ( void )
xbell ( void )
{
{
if ( ! ( win . state & WIN_FOCUSED ) )
if ( ! ( IS_SET ( MODE_FOCUSED ) ) )
xseturgency ( 1 ) ;
xseturgency ( 1 ) ;
if ( bellvolume )
if ( bellvolume )
XkbBell ( xw . dpy , xw . win , bellvolume , ( Atom ) NULL ) ;
XkbBell ( xw . dpy , xw . win , bellvolume , ( Atom ) NULL ) ;
@ -1630,13 +1642,13 @@ focus(XEvent *ev)
if ( ev - > type = = FocusIn ) {
if ( ev - > type = = FocusIn ) {
XSetICFocus ( xw . xic ) ;
XSetICFocus ( xw . xic ) ;
win . state | = WIN _FOCUSED;
win . mode | = MODE _FOCUSED;
xseturgency ( 0 ) ;
xseturgency ( 0 ) ;
if ( IS_SET ( MODE_FOCUS ) )
if ( IS_SET ( MODE_FOCUS ) )
ttywrite ( " \033 [I " , 3 , 0 ) ;
ttywrite ( " \033 [I " , 3 , 0 ) ;
} else {
} else {
XUnsetICFocus ( xw . xic ) ;
XUnsetICFocus ( xw . xic ) ;
win . stat e & = ~ WIN _FOCUSED;
win . mod e & = ~ MODE _FOCUSED;
if ( IS_SET ( MODE_FOCUS ) )
if ( IS_SET ( MODE_FOCUS ) )
ttywrite ( " \033 [O " , 3 , 0 ) ;
ttywrite ( " \033 [O " , 3 , 0 ) ;
}
}
@ -1673,7 +1685,7 @@ kmap(KeySym k, uint state)
if ( IS_SET ( MODE_APPKEYPAD ) ? kp - > appkey < 0 : kp - > appkey > 0 )
if ( IS_SET ( MODE_APPKEYPAD ) ? kp - > appkey < 0 : kp - > appkey > 0 )
continue ;
continue ;
if ( term . numlock & & kp - > appkey = = 2 )
if ( IS_SET ( MODE_NUMLOCK ) & & kp - > appkey = = 2 )
continue ;
continue ;
if ( IS_SET ( MODE_APPCURSOR ) ? kp - > appcursor < 0 : kp - > appcursor > 0 )
if ( IS_SET ( MODE_APPCURSOR ) ? kp - > appcursor < 0 : kp - > appcursor > 0 )
@ -1742,10 +1754,10 @@ cmessage(XEvent *e)
*/
*/
if ( e - > xclient . message_type = = xw . xembed & & e - > xclient . format = = 32 ) {
if ( e - > xclient . message_type = = xw . xembed & & e - > xclient . format = = 32 ) {
if ( e - > xclient . data . l [ 1 ] = = XEMBED_FOCUS_IN ) {
if ( e - > xclient . data . l [ 1 ] = = XEMBED_FOCUS_IN ) {
win . state | = WIN _FOCUSED;
win . mode | = MODE _FOCUSED;
xseturgency ( 0 ) ;
xseturgency ( 0 ) ;
} else if ( e - > xclient . data . l [ 1 ] = = XEMBED_FOCUS_OUT ) {
} else if ( e - > xclient . data . l [ 1 ] = = XEMBED_FOCUS_OUT ) {
win . stat e & = ~ WIN _FOCUSED;
win . mod e & = ~ MODE _FOCUSED;
}
}
} else if ( e - > xclient . data . l [ 0 ] = = xw . wmdeletewin ) {
} else if ( e - > xclient . data . l [ 0 ] = = xw . wmdeletewin ) {
/* Send SIGHUP to shell */
/* Send SIGHUP to shell */
@ -1810,7 +1822,7 @@ run(void)
if ( blinktimeout ) {
if ( blinktimeout ) {
blinkset = tattrset ( ATTR_BLINK ) ;
blinkset = tattrset ( ATTR_BLINK ) ;
if ( ! blinkset )
if ( ! blinkset )
MODBIT ( term . mode , 0 , MODE_BLINK ) ;
MODBIT ( win . mode , 0 , MODE_BLINK ) ;
}
}
}
}
@ -1825,7 +1837,7 @@ run(void)
dodraw = 0 ;
dodraw = 0 ;
if ( blinktimeout & & TIMEDIFF ( now , lastblink ) > blinktimeout ) {
if ( blinktimeout & & TIMEDIFF ( now , lastblink ) > blinktimeout ) {
tsetdirtattr ( ATTR_BLINK ) ;
tsetdirtattr ( ATTR_BLINK ) ;
term . mode ^ = MODE_BLINK ;
win . mode ^ = MODE_BLINK ;
lastblink = now ;
lastblink = now ;
dodraw = 1 ;
dodraw = 1 ;
}
}