1 static void xevtcbexpose (XEvent
*ev
) {
2 XExposeEvent
*e
= &ev
->xexpose
;
4 if (xw
.state
&K8T_WIN_REDRAW
) {
5 if (!e
->count
&& curterm
!= NULL
) {
6 xw
.state
&= ~K8T_WIN_REDRAW
;
7 if (!updateTabBar
) updateTabBar
= -1;
9 k8t_tmFullDirty(curterm
);
10 k8t_drawTerm(curterm
, 1);
11 k8t_drawCopy(curterm
, 0, 0, curterm
->col
, curterm
->row
);
12 //if (!updateTabBar) updateTabBar = -1;
15 } else if (curterm
!= NULL
) {
16 int taby
= (opt_tabposition
==1 ? 0 : xw
.h
-xw
.tabheight
);
17 int termy
= (opt_tabposition
==1 ? xw
.tabheight
: 0);
18 int x0
= e
->x
/xw
.cw
, y0
= (e
->y
-termy
)/xw
.ch
;
19 int x1
= (e
->x
+e
->width
)/xw
.cw
, y1
= (e
->y
-termy
+e
->height
)/xw
.ch
;
21 //fprintf(stderr, "x=%d; y=%d; w=%d; h=%d\n", e->x, e->y, e->width, e->height);
22 //fprintf(stderr, "taby=%d; tabh=%d\n", taby, xw.tabheight);
23 //fprintf(stderr, "x0=%d; y0=%d; x1=%d; y1=%d\n", x0, y0, x1, y1);
25 if (e
->y
<= taby
+xw
.tabheight
&& e
->y
+e
->height
>= taby
) {
26 //fprintf(stderr, "tabbar!\n");
27 if (!updateTabBar
) updateTabBar
= -1;
29 //XCopyArea(xw.dpy, K8T_DATA(curterm)->picbuf, xw.win, dc.gc, e->x, e->y, e->width, e->height, e->x, e->y+(opt_tabposition==1?xw.height:0)));
30 //k8t_drawCopy(curterm, 0, 0, curterm->col, curterm->row);
31 //k8t_drawClear(curterm, x0, y0, x1-x0+1, y1-y0+1);
32 K8T_LIMIT(x0
, 0, curterm
->col
-1);
33 K8T_LIMIT(x1
, 0, curterm
->col
-1);
34 K8T_LIMIT(y0
, 0, curterm
->row
-1);
35 K8T_LIMIT(y1
, 0, curterm
->row
-1);
36 //fprintf(stderr, "*:x0=%d; y0=%d; x1=%d; y1=%d\n", x0, y0, x1, y1);
37 k8t_drawCopy(curterm
, x0
, y0
, x1
-x0
+1, y1
-y0
+1);
38 //xclearunused(); //FIXME: optimize this
40 if (!updateTabBar
) updateTabBar
= -1;
47 static void xevtcbvisibility (XEvent
*ev
) {
48 XVisibilityEvent
*e
= &ev
->xvisibility
;
50 if (e
->state
== VisibilityFullyObscured
) xw
.state
&= ~K8T_WIN_VISIBLE
;
51 else if ((xw
.state
&K8T_WIN_VISIBLE
) == 0) xw
.state
|= K8T_WIN_VISIBLE
|K8T_WIN_REDRAW
; /* need a full redraw for next Expose, not just a buf copy */
55 static void xevtcbunmap (XEvent
*ev
) {
56 xw
.state
&= ~K8T_WIN_VISIBLE
;
60 static void xseturgency (int add
) {
61 XWMHints
*h
= XGetWMHints(xw
.dpy
, xw
.win
);
63 h
->flags
= add
? (h
->flags
|XUrgencyHint
) : (h
->flags
&~XUrgencyHint
);
64 XSetWMHints(xw
.dpy
, xw
.win
, h
);
69 static void xevtcbfocus (XEvent
*ev
) {
70 if (ev
->type
== FocusIn
) {
71 xw
.state
|= K8T_WIN_FOCUSED
;
73 k8t_tmSendFocusEvent(curterm
, 1);
75 xw
.state
&= ~K8T_WIN_FOCUSED
;
76 k8t_tmSendFocusEvent(curterm
, 0);
78 //k8t_drawTerm(curterm, 1);
80 if (!updateTabBar) updateTabBar = -1;
83 k8t_drawCursor(curterm
, 1);
84 //k8t_tmWantRedraw(curterm, 0);
85 //k8t_drawCopy(curterm, 0, 0, curterm->col, curterm->row);
89 static void xevtcbresise (XEvent
*e
) {
92 //if (e->xconfigure.width == 65535 || e->xconfigure.width == -1) e->xconfigure.width = xw.w;
93 if (e
->xconfigure
.height
== 65535 || e
->xconfigure
.height
== -1) e
->xconfigure
.height
= xw
.h
;
94 //if ((short int)e->xconfigure.height < xw.ch) return;
96 if (e
->xconfigure
.width
== xw
.w
&& e
->xconfigure
.height
== xw
.h
) return;
97 xw
.w
= e
->xconfigure
.width
;
98 xw
.h
= e
->xconfigure
.height
;
100 row
= (xw
.h
-xw
.tabheight
)/xw
.ch
;
101 //fprintf(stderr, "neww=%d; newh=%d; ch=%d; th=%d; col=%d; row=%d; ocol=%d; orow=%d\n", xw.w, xw.h, xw.ch, xw.tabheight, col, row, curterm->col, curterm->row);
102 if (curterm
!= NULL
&& col
== curterm
->col
&& row
== curterm
->row
) return;
104 for (int f
= 0; f
< term_count
; ++f
) {
105 K8Term
*t
= term_array
[f
];
106 /*int trs =*/ k8t_tmResize(t
, col
, row
);
110 //if (trs && t == curterm) k8t_drawTerm(t, 1);
113 termCreateXPixmap(curterm
);
114 XFreePixmap(xw
.dpy
, xw
.pictab
);
115 xw
.pictab
= XCreatePixmap(xw
.dpy
, xw
.win
, xw
.w
, (xw
.tabheight
> 0 ? xw
.tabheight
: 1), XDefaultDepth(xw
.dpy
, xw
.scr
));
117 xw
.state
|= K8T_WIN_REDRAW
;
119 //k8t_drawTerm(curterm, 1);