~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to menus.c

  • Committer: Richard Levitte
  • Author(s): Claude Lecommandeur
  • Date: 2003-02-02 17:06:24 UTC
  • Revision ID: richard@levitte.org-20030202170624-ufdh8dgunc7nfrg7
Tags: ctwm-3.4
CTWM version 3.4

Monotone-Parent: c700ef3475b277d9b00913b22b99fdfe49782d14
Monotone-Revision: 1be23fb8d6d29219f3dc9717e362a5814b7eb554

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
#include <unixio.h>
80
80
#include <file.h>
81
81
#include <decw$include/Xos.h>
 
82
#include <decw$include/Xatom.h>
82
83
#else
83
84
#include <X11/Xos.h>
 
85
#include <X11/Xatom.h>
84
86
#endif
85
87
#include "twm.h"
86
88
#include "gc.h"
91
93
#include "parse.h"
92
94
#include "gram.h"
93
95
#include "screen.h"
 
96
#include "icons.h"
94
97
#ifdef VMS
95
98
#include <X11Xmu/CharSet.h>
96
99
#include <decw$bitmaps/menu12.xbm>
98
101
#include <lib$routines.h>
99
102
#else
100
103
#include <X11/Xmu/CharSet.h>
101
 
#include <X11/bitmaps/menu12>
102
104
#endif
103
105
#include "version.h"
104
106
 
1230
1232
    mr->pmenu = NULL;
1231
1233
 
1232
1234
    if (Scr->Monochrome == MONOCHROME || !Scr->InterpolateMenuColors)
1233
 
        return;
 
1235
        return 0;
1234
1236
 
1235
1237
    start = mr->first;
1236
1238
    while (TRUE)
1332
1334
    TwmWindow **WindowNames;
1333
1335
    TwmWindow *tmp_win2,*tmp_win3;
1334
1336
    int i;
1335
 
    int (*compar)() = 
1336
 
      (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
1337
 
    static char **actions = NULL;
 
1337
    int xl, yt;
 
1338
    int (*compar)() = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
 
1339
    Bool clipped;
1338
1340
 
1339
1341
    if (!menu) return False;
1340
1342
 
1454
1456
    /*
1455
1457
    * clip to screen
1456
1458
    */
 
1459
    clipped = FALSE;
1457
1460
    if (x + menu->width > Scr->MyDisplayWidth) {
1458
1461
        x = Scr->MyDisplayWidth - menu->width;
1459
 
    }
1460
 
    if (x < 0) x = 0;
 
1462
        clipped = TRUE;
 
1463
    }
 
1464
    if (x < 0) {
 
1465
        x = 0;
 
1466
        clipped = TRUE;
 
1467
    }
1461
1468
    if (y + menu->height > Scr->MyDisplayHeight) {
1462
1469
        y = Scr->MyDisplayHeight - menu->height;
1463
 
    }
1464
 
    if (y < 0) y = 0;
 
1470
        clipped = TRUE;
 
1471
    }
 
1472
    if (y < 0) {
 
1473
        y = 0;
 
1474
        clipped = TRUE;
 
1475
    }
1465
1476
    MenuOrigins[MenuDepth].x = x;
1466
1477
    MenuOrigins[MenuDepth].y = y;
1467
1478
    MenuDepth++;
1468
1479
 
1469
1480
    XMoveWindow(dpy, menu->w, x, y);
1470
1481
    if (Scr->Shadow) {
1471
 
        XMoveWindow (dpy, menu->shadow, x + SHADOWWIDTH, y + SHADOWWIDTH);
1472
 
    }
1473
 
    if (Scr->Shadow) {
 
1482
        XMoveWindow  (dpy, menu->shadow, x + SHADOWWIDTH, y + SHADOWWIDTH);
1474
1483
        XRaiseWindow (dpy, menu->shadow);
1475
1484
    }
1476
1485
    XMapRaised(dpy, menu->w);
1477
 
    if (Scr->Shadow) {
1478
 
        XMapWindow (dpy, menu->shadow);
 
1486
    if (clipped && center) {
 
1487
        xl = x + (menu->width      / 2);
 
1488
        yt = y + (Scr->EntryHeight / 2);
 
1489
        XWarpPointer (dpy, Scr->Root, Scr->Root, x, y, menu->width, menu->height, xl, yt);
1479
1490
    }
 
1491
    if (Scr->Shadow) XMapWindow (dpy, menu->shadow);
1480
1492
    XSync(dpy, 0);
1481
 
 
1482
1493
    return True;
1483
1494
}
1484
1495
 
1607
1618
{
1608
1619
  int lastx, lasty, width, height, bw2;
1609
1620
  int namelen;
1610
 
  int stat;
1611
 
  Window junk;
1612
1621
 
1613
1622
  namelen = strlen (tmp_win->name);
1614
1623
  bw2 = tmp_win->frame_bw * 2;
1802
1811
#else
1803
1812
#ifdef X11R6
1804
1813
        if (smcConn) SmcCloseConnection (smcConn, 0, NULL);
 
1814
#endif /* X11R6 */
1805
1815
        execvp(*Argv, Argv);
1806
 
#endif /* X11R6 */
1807
1816
#endif /* VMS */
1808
1817
        fprintf (stderr, "%s:  unable to restart:  %s\n", ProgramName, *Argv);
1809
1818
        break;
1817
1826
        MoveIconManager(func);
1818
1827
        break;
1819
1828
 
 
1829
    case F_FORWMAPICONMGR:
 
1830
    case F_BACKMAPICONMGR:
 
1831
        MoveMappedIconManager(func);
 
1832
        break;
 
1833
 
1820
1834
    case F_NEXTICONMGR:
1821
1835
    case F_PREVICONMGR:
1822
1836
        JumpIconManager(func);
1851
1865
    case F_SHOWWORKMGR:
1852
1866
        if (! Scr->workSpaceManagerActive) break;
1853
1867
        DeIconify (Scr->workSpaceMgr.workspaceWindow.twm_win);
1854
 
        RaiseWindow(dpy, Scr->workSpaceMgr.workspaceWindow.twm_win);
 
1868
        RaiseWindow(Scr->workSpaceMgr.workspaceWindow.twm_win);
1855
1869
        break;
1856
1870
 
1857
1871
    case F_HIDEWORKMGR:
2329
2343
                    ((CurrentDragX != origDragX ||
2330
2344
                      CurrentDragY != origDragY)))
2331
2345
                  tmp_win->icon_moved = TRUE;
2332
 
                if (!Scr->OpaqueMove && menuFromFrameOrWindowOrTitlebar)
2333
 
                  XMoveWindow(dpy, DragWindow, 
2334
 
                              Event.xbutton.x_root - DragWidth / 2,
2335
 
                              Event.xbutton.y_root - DragHeight / 2);
 
2346
                if (!Scr->OpaqueMove && menuFromFrameOrWindowOrTitlebar) {
 
2347
                    int xl = Event.xbutton.x_root - (DragWidth  / 2),
 
2348
                        yt = Event.xbutton.y_root - (DragHeight / 2);
 
2349
                    if (!moving_icon &&
 
2350
                       (MoveFunction == F_MOVEPACK || MoveFunction == F_MOVEPUSH))
 
2351
                        TryToPack (tmp_win, &xl, &yt);
 
2352
                        XMoveWindow(dpy, DragWindow, xl, yt);
 
2353
                }
2336
2354
                if (menuFromFrameOrWindowOrTitlebar) DragWindow = None;
2337
2355
                break;
2338
2356
            }
3150
3168
    char oldDisplay[256];
3151
3169
    char *doisplay;
3152
3170
    int restorevar = 0;
3153
 
    SigProc     sig;
3154
3171
 
3155
3172
    oldDisplay[0] = '\0';
3156
3173
    doisplay=getenv("DISPLAY");
3175
3192
        restorevar = 1;
3176
3193
    }
3177
3194
#ifdef USE_SIGNALS
 
3195
  {
 
3196
    SigProc     sig;
 
3197
 
3178
3198
    sig = signal (SIGALRM, SIG_IGN);
3179
3199
    (void) system (s);
3180
3200
    signal (SIGALRM, sig);
 
3201
  }
3181
3202
#else  /* USE_SIGNALS */
3182
3203
    (void) system (s);
3183
3204
#endif  /* USE_SIGNALS */
3385
3406
    if (tmp_win->icon && tmp_win->icon->w) {
3386
3407
        XUnmapWindow(dpy, tmp_win->icon->w);
3387
3408
        IconDown (tmp_win);
 
3409
        if (Scr->SchrinkIconTitles) tmp_win->icon->title_schrinked = True;
3388
3410
    }
3389
3411
    if (tmp_win->list)
3390
3412
      for (wl = tmp_win->list; wl != NULL; wl = wl->nextv)
3454
3476
    WList *wl;
3455
3477
    Window leader;
3456
3478
    Window blanket;
3457
 
    int i;
3458
3479
 
3459
3480
    iconify = (!tmp_win->iconify_by_unmapping);
3460
3481
    t = (TwmWindow*) 0;
3593
3614
TwmWindow *tmp_win;
3594
3615
{
3595
3616
    long fy, savey;
3596
 
    int nstep = 10;
3597
 
    int i, offset;
3598
 
    XEvent ev;
 
3617
    int offset;
3599
3618
    int    south;
3600
3619
    int grav = ((tmp_win->hints.flags & PWinGravity) 
3601
3620
                      ? tmp_win->hints.win_gravity : NorthWestGravity);
3650
3669
    Window junk;
3651
3670
    int px, py, dummy;
3652
3671
    unsigned udummy;
 
3672
    unsigned char       *prop;
 
3673
    unsigned long       nitems, bytesafter;
 
3674
    Atom                actual_type;
 
3675
    int                 actual_format;
3653
3676
 
3654
3677
    n = 0;
3655
3678
    (void) sprintf(Info[n++], "Twm version:  %s", Version);
3682
3705
                x, y);
3683
3706
        (void) sprintf(Info[n++], "Border width     = %d", bw);
3684
3707
        (void) sprintf(Info[n++], "Depth            = %d", depth);
 
3708
 
 
3709
        if (XGetWindowProperty (dpy, t->w, _XA_WM_CLIENT_MACHINE, 0L, 64, False,
 
3710
                                XA_STRING, &actual_type, &actual_format, &nitems,
 
3711
                                &bytesafter, &prop) == Success) {
 
3712
            if (nitems && prop) {
 
3713
                (void) sprintf(Info[n++], "Client machine   = %s", (char*)prop);
 
3714
                XFree ((char *) prop);
 
3715
            }
 
3716
        }
 
3717
        
3685
3718
    }
3686
3719
 
3687
3720
    Info[n++][0] = '\0';
4193
4226
int     width, height;
4194
4227
{
4195
4228
    int         srect;
4196
 
    int         i, j, x, y, usec, nrects;
 
4229
    int         i, j, usec, nrects;
4197
4230
    Pixmap      mask;
4198
4231
    GC          gc;
4199
4232
    XGCValues   gcv;
4428
4461
    return (ret);
4429
4462
}
4430
4463
 
 
4464
WarpCursorToDefaultEntry (menu)
 
4465
MenuRoot *menu;
 
4466
{
 
4467
    MenuItem    *item;
 
4468
    Window       root;
 
4469
    int          i, x, y, xl, yt;
 
4470
    unsigned int w, h, bw, d;
 
4471
 
 
4472
    for (i = 0, item = menu->first; item != menu->last; item = item->next) {
 
4473
        if (item == menu->defaultitem) break;
 
4474
        i++;
 
4475
     }
 
4476
     if (!XGetGeometry (dpy, menu->w, &root, &x, &y, &w, &h, &bw, &d)) return 0;
 
4477
     xl = x + (menu->width / 2);
 
4478
     yt = y + (i + 0.5) * Scr->EntryHeight;
 
4479
        
 
4480
     XWarpPointer (dpy, Scr->Root, Scr->Root,
 
4481
                   Event.xbutton.x_root, Event.xbutton.y_root,
 
4482
                   menu->width, menu->height, xl, yt);
 
4483
}