2013-11-04 101 views

回答

2

xlib沒有內置的動畫或閃爍的概念。您必須運行計時器並定期繪製並擦除光標。

1

我使用類似於: 這是我的項目摘錄http://open.source.sveena.com 您必須完成缺少的部分。

// call this periodically 
void FlipCaret() 
{ 
     if(!s_caretgc)return; 
     if(s_hidecaret)return; 
     XACCESSLOCK; 
     if(!s_caretgc)return; 
     XFillRectangle(s_caretdisplay, s_caretwindow, s_caretgc, s_caretx, s_carety, s_caretcx, s_caretcy); 
     XFlush(s_caretdisplay); 
     s_caretvisible = s_caretvisible ? 0 : 1; 
} 

// to create and destroy caret 
static void  s_DestroyCaret() 
{ 
     if(!s_caretgc)return; 
     XACCESSLOCK; 
     if(s_caretgc){ 
       if(s_caretvisible){ 
         FlipCaret(); 
       } 
       XFreeGC(s_caretdisplay, s_caretgc); 
       XFlush(s_caretdisplay); 
       s_caretgc = 0; 
     } 
} 

static void  s_CreateCaret(MWND* mwnd, Window w) 
{ 
     s_DestroyCaret(); 
     XACCESSLOCK; 
     s_caretdisplay = mwnd->m_Display; 
     s_caretmwnd = mwnd; 
     s_caretwindow = w; 
     s_caretx = mwnd->Caretx; 
     s_carety = mwnd->Carety; 
     s_caretcx = mwnd->CaretCx; 
     s_caretcy = mwnd->CaretCy; 
     if(s_caretcx<5)s_caretcx = 5; 
     if(s_caretcx>20)s_caretcx = 20; 
     if(s_caretcy<16)s_caretcy = 16; 
     if(s_caretcy>100)s_caretcy = 100; 
     XGCValues gcval; 
     gcval.function = GXinvert; 
     gcval.fill_style = FillSolid; 
     if(IsValidXWindow(w, "XCreateGC")) 
     s_caretgc = XCreateGC(s_caretdisplay,w,GCFunction|GCFillStyle,&gcval); 
     XFlush(s_caretdisplay); 
} 
相關問題