~ubuntu-branches/ubuntu/precise/xterm/precise-updates

« back to all changes in this revision

Viewing changes to misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2011-02-10 18:48:37 UTC
  • mto: (1.4.11 upstream) (11.1.24 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: james.westby@ubuntu.com-20110210184837-zr6xtudedxk969gp
ImportĀ upstreamĀ versionĀ 268

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: misc.c,v 1.510 2010/10/11 08:33:33 tom Exp $ */
 
1
/* $XTermId: misc.c,v 1.517 2011/02/09 10:14:20 tom Exp $ */
2
2
 
3
3
/*
4
 
 * Copyright 1999-2009,2010 by Thomas E. Dickey
 
4
 * Copyright 1999-2010,2011 by Thomas E. Dickey
5
5
 *
6
6
 *                         All Rights Reserved
7
7
 *
250
250
#endif
251
251
 
252
252
static void
253
 
setXUrgency(TScreen * screen, Bool enable)
 
253
setXUrgency(XtermWidget xw, Bool enable)
254
254
{
 
255
    TScreen *screen = TScreenOf(xw);
 
256
 
255
257
    if (screen->bellIsUrgent) {
256
 
        XWMHints *h = XGetWMHints(screen->display, VShellWindow);
 
258
        XWMHints *h = XGetWMHints(screen->display, VShellWindow(xw));
257
259
        if (h != 0) {
258
 
            if (enable) {
 
260
            if (enable && !(screen->select & FOCUS)) {
259
261
                h->flags |= XUrgencyHint;
260
262
            } else {
261
263
                h->flags &= ~XUrgencyHint;
262
264
            }
263
 
            XSetWMHints(screen->display, VShellWindow, h);
 
265
            XSetWMHints(screen->display, VShellWindow(xw), h);
264
266
        }
265
267
    }
266
268
}
739
741
 
740
742
    if (screen->quiet_grab
741
743
        && (event->mode == NotifyGrab || event->mode == NotifyUngrab)) {
742
 
        ;
 
744
        /* EMPTY */ ;
743
745
    } else if (event->type == FocusIn) {
744
 
        setXUrgency(screen, False);
 
746
        setXUrgency(xw, False);
745
747
 
746
748
        /*
747
749
         * NotifyNonlinear only happens (on FocusIn) if the pointer was not in
856
858
 
857
859
#if defined(HAVE_XKB_BELL_EXT)
858
860
    if (tony != None) {
859
 
        XkbBell(screen->display, VShellWindow, percent, tony);
 
861
        XkbBell(screen->display, VShellWindow(xw), percent, tony);
860
862
    } else
861
863
#endif
862
864
        XBell(screen->display, percent);
874
876
        return;
875
877
    }
876
878
 
877
 
    setXUrgency(screen, True);
 
879
    setXUrgency(xw, True);
878
880
 
879
881
    /* has enough time gone by that we are allowed to ring
880
882
       the bell again? */
901
903
    }
902
904
 
903
905
    if (screen->poponbell)
904
 
        XRaiseWindow(screen->display, VShellWindow);
 
906
        XRaiseWindow(screen->display, VShellWindow(xw));
905
907
 
906
908
    if (screen->bellSuppressTime) {
907
909
        /* now we change a property and wait for the notify event to come
972
974
}
973
975
 
974
976
Window
975
 
WMFrameWindow(XtermWidget termw)
 
977
WMFrameWindow(XtermWidget xw)
976
978
{
977
979
    Window win_root, win_current, *children;
978
980
    Window win_parent = 0;
979
981
    unsigned int nchildren;
980
982
 
981
 
    win_current = XtWindow(termw);
 
983
    win_current = XtWindow(xw);
982
984
 
983
985
    /* find the parent which is child of root */
984
986
    do {
985
987
        if (win_parent)
986
988
            win_current = win_parent;
987
 
        XQueryTree(TScreenOf(termw)->display,
 
989
        XQueryTree(TScreenOf(xw)->display,
988
990
                   win_current,
989
991
                   &win_root,
990
992
                   &win_parent,
1196
1198
 
1197
1199
    if ((xw = getXtermWidget(w)) != 0) {
1198
1200
        TScreen *screen = TScreenOf(xw);
1199
 
        XMapWindow(screen->display, VShellWindow);
 
1201
        XMapWindow(screen->display, VShellWindow(xw));
1200
1202
    }
1201
1203
}
1202
1204
 
1212
1214
    if ((xw = getXtermWidget(w)) != 0) {
1213
1215
        TScreen *screen = TScreenOf(xw);
1214
1216
        XIconifyWindow(screen->display,
1215
 
                       VShellWindow,
 
1217
                       VShellWindow(xw),
1216
1218
                       DefaultScreen(screen->display));
1217
1219
    }
1218
1220
}
1219
1221
 
1220
1222
int
1221
 
QueryMaximize(XtermWidget termw, unsigned *width, unsigned *height)
 
1223
QueryMaximize(XtermWidget xw, unsigned *width, unsigned *height)
1222
1224
{
1223
 
    TScreen *screen = TScreenOf(termw);
 
1225
    TScreen *screen = TScreenOf(xw);
1224
1226
    XSizeHints hints;
1225
1227
    long supp = 0;
1226
1228
    Window root_win;
1230
1232
    unsigned root_depth;
1231
1233
 
1232
1234
    if (XGetGeometry(screen->display,
1233
 
                     RootWindowOfScreen(XtScreen(termw)),
 
1235
                     RootWindowOfScreen(XtScreen(xw)),
1234
1236
                     &root_win,
1235
1237
                     &root_x,
1236
1238
                     &root_y,
1250
1252
 
1251
1253
        hints.flags = PMaxSize;
1252
1254
        if (XGetWMNormalHints(screen->display,
1253
 
                              VShellWindow,
 
1255
                              VShellWindow(xw),
1254
1256
                              &hints,
1255
1257
                              &supp)
1256
1258
            && (hints.flags & PMaxSize) != 0) {
1270
1272
}
1271
1273
 
1272
1274
void
1273
 
RequestMaximize(XtermWidget termw, int maximize)
 
1275
RequestMaximize(XtermWidget xw, int maximize)
1274
1276
{
1275
 
    TScreen *screen = TScreenOf(termw);
 
1277
    TScreen *screen = TScreenOf(xw);
1276
1278
    XWindowAttributes wm_attrs, vshell_attrs;
1277
1279
    unsigned root_width, root_height;
1278
1280
 
1280
1282
 
1281
1283
    if (maximize) {
1282
1284
 
1283
 
        if (QueryMaximize(termw, &root_width, &root_height)) {
 
1285
        if (QueryMaximize(xw, &root_width, &root_height)) {
1284
1286
 
1285
1287
            if (XGetWindowAttributes(screen->display,
1286
 
                                     WMFrameWindow(termw),
 
1288
                                     WMFrameWindow(xw),
1287
1289
                                     &wm_attrs)) {
1288
1290
 
1289
1291
                if (XGetWindowAttributes(screen->display,
1290
 
                                         VShellWindow,
 
1292
                                         VShellWindow(xw),
1291
1293
                                         &vshell_attrs)) {
1292
1294
 
1293
1295
                    if (screen->restore_data != True
1313
1315
                        (unsigned) ((wm_attrs.height - vshell_attrs.height)
1314
1316
                                    + (wm_attrs.border_width * 2));
1315
1317
 
1316
 
                    XMoveResizeWindow(screen->display, VShellWindow,
 
1318
                    XMoveResizeWindow(screen->display, VShellWindow(xw),
1317
1319
                                      0 + wm_attrs.border_width,        /* x */
1318
1320
                                      0 + wm_attrs.border_width,        /* y */
1319
1321
                                      root_width,
1331
1333
            screen->restore_data = False;
1332
1334
 
1333
1335
            XMoveResizeWindow(screen->display,
1334
 
                              VShellWindow,
 
1336
                              VShellWindow(xw),
1335
1337
                              screen->restore_x,
1336
1338
                              screen->restore_y,
1337
1339
                              screen->restore_width,
1991
1993
                res->value = TScreenOf(xw)->Tcolors[TEXT_FG].value;
1992
1994
                res->mode = -True;
1993
1995
                fprintf(stderr,
1994
 
                        "%s: Cannot allocate color %s\n",
 
1996
                        "%s: Cannot allocate color \"%s\"\n",
1995
1997
                        xterm_name,
1996
1998
                        NonNull(res->resource));
1997
1999
            }
2309
2311
{
2310
2312
    int i;
2311
2313
    if (pOldColors == NULL) {
2312
 
        pOldColors = (ScrnColors *) XtMalloc((Cardinal) sizeof(ScrnColors));
 
2314
        pOldColors = TypeXtMalloc(ScrnColors);
2313
2315
        if (pOldColors == NULL) {
2314
2316
            fprintf(stderr, "allocation failure in GetOldColors\n");
2315
2317
            return (False);
2673
2675
                }
2674
2676
#if OPT_RENDERFONT
2675
2677
                if (UsingRenderFont(xw)) {
2676
 
                    ;           /* there is only one font entry to load */
 
2678
                    /* EMPTY */
 
2679
                    /* there is only one font entry to load */
 
2680
                    ;
2677
2681
                } else
2678
2682
#endif
2679
2683
                {
3172
3176
            if (++nparam < NPARAM)
3173
3177
                params->a_nparam = nparam;
3174
3178
        } else if (ch < 32) {
3175
 
            ;
 
3179
            /* EMPTY */ ;
3176
3180
        } else {
3177
3181
            /* should be 0x30 to 0x7e */
3178
3182
            params->a_final = ch;
3826
3830
                    if (IsSetUtf8Title(xw)) {
3827
3831
                        TRACE(("...updating %s\n", propname));
3828
3832
                        TRACE(("...value is %s\n", value));
3829
 
                        XChangeProperty(dpy, VShellWindow, my_atom,
 
3833
                        XChangeProperty(dpy, VShellWindow(xw), my_atom,
3830
3834
                                        XA_UTF8_STRING(dpy), 8,
3831
3835
                                        PropModeReplace,
3832
3836
                                        (Char *) value,
3833
3837
                                        (int) strlen(value));
3834
3838
                    } else {
3835
3839
                        TRACE(("...deleting %s\n", propname));
3836
 
                        XDeleteProperty(dpy, VShellWindow, my_atom);
 
3840
                        XDeleteProperty(dpy, VShellWindow(xw), my_atom);
3837
3841
                    }
3838
3842
                }
3839
3843
            }
4316
4320
void
4317
4321
set_vt_visibility(Bool on)
4318
4322
{
4319
 
    TScreen *screen = TScreenOf(term);
 
4323
    XtermWidget xw = term;
 
4324
    TScreen *screen = TScreenOf(xw);
4320
4325
 
4321
4326
    TRACE(("set_vt_visibility(%d)\n", on));
4322
4327
    if (on) {
4323
 
        if (!screen->Vshow && term) {
4324
 
            VTInit(term);
4325
 
            XtMapWidget(XtParent(term));
 
4328
        if (!screen->Vshow && xw) {
 
4329
            VTInit(xw);
 
4330
            XtMapWidget(XtParent(xw));
4326
4331
#if OPT_TOOLBAR
4327
4332
            /* we need both of these during initialization */
4328
 
            XtMapWidget(SHELL_OF(term));
 
4333
            XtMapWidget(SHELL_OF(xw));
4329
4334
            ShowToolbar(resource.toolBar);
4330
4335
#endif
4331
4336
            screen->Vshow = True;
4333
4338
    }
4334
4339
#if OPT_TEK4014
4335
4340
    else {
4336
 
        if (screen->Vshow && term) {
4337
 
            withdraw_window(XtDisplay(term),
4338
 
                            VShellWindow,
4339
 
                            XScreenNumberOfScreen(XtScreen(term)));
 
4341
        if (screen->Vshow && xw) {
 
4342
            withdraw_window(XtDisplay(xw),
 
4343
                            VShellWindow(xw),
 
4344
                            XScreenNumberOfScreen(XtScreen(xw)));
4340
4345
            screen->Vshow = False;
4341
4346
        }
4342
4347
    }
4547
4552
#if OPT_TRACE
4548
4553
        for (j = 0; j < opt_count; j++) {
4549
4554
            if (!strncmp(opt_array[j].opt, "-/+", 3)) {
 
4555
                char temp[80];
4550
4556
                const char *name = opt_array[j].opt + 3;
4551
4557
                for (k = 0; k < numDescs; ++k) {
4552
4558
                    const char *value = res_array[k].value;
4557
4563
                    } else {
4558
4564
                        code = 0;
4559
4565
                    }
4560
 
                    if (x_strindex(opt_array[j].desc, "inhibit") != 0)
 
4566
                    strcpy(temp, opt_array[j].desc);
 
4567
                    if (x_strindex(temp, "inhibit") != 0)
4561
4568
                        code = -code;
4562
4569
                    if (code != 0
4563
4570
                        && res_array[k].value != 0