1
/* $XTermId: misc.c,v 1.370 2007/07/22 20:34:04 tom Exp $ */
1
/* $XTermId: misc.c,v 1.383 2008/04/14 00:05:43 tom Exp $ */
5
* Copyright 1999-2006,2007 by Thomas E. Dickey
5
* Copyright 1999-2007,2008 by Thomas E. Dickey
7
7
* All Rights Reserved
109
110
#define OUR_EVENT(event,Type) \
110
111
(event.type == Type && \
111
(event.xcrossing.window == XtWindow(XtParent(term)) || \
112
(event.xcrossing.window == XtWindow(XtParent(xw)) || \
113
114
event.xcrossing.window == XtWindow(XtParent(tekWidget)))))
115
116
#define OUR_EVENT(event,Type) \
116
117
(event.type == Type && \
117
(event.xcrossing.window == XtWindow(XtParent(term))))
118
(event.xcrossing.window == XtWindow(XtParent(xw))))
121
static Cursor make_hidden_cursor(XtermWidget);
120
123
#if OPT_EXEC_XTERM
121
124
/* Like readlink(2), but returns a malloc()ed buffer, or NULL on
122
125
error; adapted from libc docs */
131
buf = realloc(buf, size);
134
buf = TypeRealloc(char, size, buf);
132
135
memset(buf, 0, size);
134
137
n = readlink(filename, buf, size);
188
191
TRACE(("unselectwindow(%d) flag=%d\n", screen->select, flag));
193
if (screen->hide_pointer) {
194
screen->hide_pointer = False;
195
xtermDisplayCursor(term);
190
198
if (!screen->always_highlight) {
192
200
if (TEK4014_ACTIVE(term)) {
288
xtermDisplayCursor(XtermWidget xw)
290
TScreen *screen = TScreenOf(xw);
293
if (screen->hide_pointer) {
294
TRACE(("Display hidden_cursor\n"));
295
XDefineCursor(screen->display, VWindow(screen), screen->hidden_cursor);
297
TRACE(("Display pointer_cursor\n"));
298
recolor_cursor(screen,
299
screen->pointer_cursor,
300
T_COLOR(screen, MOUSE_FG),
301
T_COLOR(screen, MOUSE_BG));
302
XDefineCursor(screen->display, VWindow(screen), screen->pointer_cursor);
308
xtermShowPointer(XtermWidget xw, Bool enable)
310
static int tried = -1;
311
TScreen *screen = TScreenOf(xw);
314
if (TEK4014_SHOWN(xw))
319
* Whether we actually hide the pointer depends on the pointer-mode and
323
switch (screen->pointer_mode) {
328
if (screen->send_mouse_pos != MOUSE_OFF)
337
if (screen->hide_pointer) {
338
screen->hide_pointer = False;
339
xtermDisplayCursor(xw);
340
switch (screen->send_mouse_pos) {
341
case ANY_EVENT_MOUSE:
344
MotionOff(screen, xw);
348
} else if (!(screen->hide_pointer) && (tried <= 0)) {
349
if (screen->hidden_cursor == 0) {
350
screen->hidden_cursor = make_hidden_cursor(xw);
352
if (screen->hidden_cursor == 0) {
356
screen->hide_pointer = True;
357
xtermDisplayCursor(xw);
358
MotionOn(screen, xw);
282
366
XtermWidget xw = term;
348
432
((event.xany.type != KeyPress) &&
349
433
(event.xany.type != KeyRelease) &&
350
434
(event.xany.type != ButtonPress) &&
351
(event.xany.type != ButtonRelease)))
435
(event.xany.type != ButtonRelease))) {
438
* If the event is interesting (and not a keyboard event), turn the
439
* mouse pointer back on.
441
if (screen->hide_pointer) {
442
switch (event.xany.type) {
453
xtermShowPointer(xw, True);
352
458
XtDispatchEvent(&event);
353
460
} while ((input_mask = XtAppPending(app_con)) & XtIMXEvent);
464
make_hidden_cursor(XtermWidget xw)
466
TScreen *screen = TScreenOf(xw);
468
Display *dpy = screen->display;
474
* Prefer nil2 (which is normally available) to "fixed" (which is supposed
475
* to be "always" available), since it's a smaller glyph in case the
476
* server insists on drawing _somethng_.
478
TRACE(("Ask for nil2 font\n"));
479
if ((fn = XLoadQueryFont(dpy, "nil2")) == 0) {
480
TRACE(("...Ask for fixed font\n"));
481
fn = XLoadQueryFont(dpy, "fixed");
485
/* a space character seems to work as a cursor (dots are not needed) */
486
c = XCreateGlyphCursor(dpy, fn->fid, fn->fid, 'X', ' ', &dummy, &dummy);
491
TRACE(("XCreateGlyphCursor ->%#lx\n", c));
357
496
make_colored_cursor(unsigned cursorindex, /* index into font */
358
497
unsigned long fg, /* pixel value */
456
* Try to find the actual program which is running in the child process.
595
* Try to find the actual program which is running in the child process.
457
596
* This works for Linux. If we cannot find the program, fall back to the
458
597
* xterm program (which is usually adequate). Give up if we are given only
459
598
* a relative path to xterm, since that would not always match $PATH.
599
if (event->type == FocusIn) {
738
if (screen->quiet_grab
739
&& (event->mode == NotifyGrab || event->mode == NotifyUngrab)) {
741
} else if (event->type == FocusIn) {
600
742
setXUrgency(screen, False);
1604
1748
for (i = 0; i < cmap_size; i++) {
1605
1749
if (!tried[bestInx]) {
1607
* Look for the best match based on luminance.
1751
* Look for the best match based on luminance.
1608
1752
* Measure this by the least-squares difference of
1609
1753
* the weighted R/G/B components from the color map
1610
1754
* versus the requested color. Use the Y (luma)
2718
2862
unparseputn(xw, NUM_ANSI_COLORS);
2867
* First ensure that we handle the extended cursor- and
2868
* editing-keypad keys.
2870
if ((code <= XK_Fn(MAX_FKEY))
2871
|| xtermcapString(xw, CodeToXkey(code), 0) == 0)
2722
2874
XKeyEvent event;
2723
2875
event.state = state;
2772
2924
#if OPT_WIDE_CHARS
2773
2925
static Char *converted; /* NO_LEAKS */
2927
static char empty[1];
2776
char *original = (value != 0) ? value : "";
2930
char *original = (value != 0) ? value : empty;
2777
2931
char *name = original;
2778
2932
TScreen *screen = TScreenOf(term);
2779
2933
Widget w = CURRENT_EMU();
2854
3008
Display *dpy = XtDisplay(term);
2857
char *propname = (!strcmp(attribute, XtNtitle)
2859
: "_NET_WM_ICON_NAME");
3011
const char *propname = (!strcmp(attribute, XtNtitle)
3013
: "_NET_WM_ICON_NAME");
2860
3014
if ((my_atom = XInternAtom(dpy, propname, False)) != None) {
2861
3015
if (screen->utf8_title) { /* FIXME - redundant? */
2862
3016
TRACE(("...updating %s\n", propname));