~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to menus.c

propagate from branch 'free.lp.se:X.ctwm.3_7-RELEASE' (head 479e2e1f03c6b1be1be02e75cb0c780ce23da929)
            to branch 'free.lp.se:X.ctwm' (head fbb6e8ec6313bb07d471a4a8930240b2b00a4bad)

Monotone-Parent: 6c66b72205d2a8b0f002eabc9a97670572cab313
Monotone-Parent: 79e8e89361d54f5ecedb8ebd4affdada9952fb75
Monotone-Revision: 38c0416a7908eaa1558b28b1594624872d1e0e22

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
#include "windowbox.h"
102
102
#include "workmgr.h"
103
103
#include "cursor.h"
 
104
#ifdef SOUNDS
 
105
#  include "sound.h"
 
106
#endif
104
107
#ifdef VMS
105
108
#  include <X11Xmu/CharSet.h>
106
109
#  include <decw$bitmaps/menu12.xbm>
130
133
#endif
131
134
#define ABS(x) ((x)<0?-(x):(x))
132
135
 
133
 
#ifdef SOUNDS
134
 
extern int toggle_sound();
135
 
extern int reread_sounds();
136
 
#endif
137
 
 
138
136
extern XEvent Event;
139
137
 
140
138
int RootFunction = 0;
2231
2229
 
2232
2230
    case F_INITSIZE: {
2233
2231
        int grav, x, y;
2234
 
        unsigned int w, h, sw, sh;
 
2232
        unsigned int width, height, swidth, sheight;
2235
2233
 
2236
2234
        if (DeferExecution (context, func, Scr->SelectCursor)) return TRUE;
2237
2235
        grav = ((tmp_win->hints.flags & PWinGravity) 
2239
2237
 
2240
2238
        if (!(tmp_win->hints.flags & USSize) && !(tmp_win->hints.flags & PSize)) break;
2241
2239
 
2242
 
        w  = tmp_win->hints.width  + 2 * tmp_win->frame_bw3D;
2243
 
        h  = tmp_win->hints.height + 2 * tmp_win->frame_bw3D + tmp_win->title_height;
2244
 
        ConstrainSize (tmp_win, &w, &h);
 
2240
        width  = tmp_win->hints.width  + 2 * tmp_win->frame_bw3D;
 
2241
        height  = tmp_win->hints.height + 2 * tmp_win->frame_bw3D + tmp_win->title_height;
 
2242
        ConstrainSize (tmp_win, &width, &height);
2245
2243
 
2246
2244
        x  = tmp_win->frame_x;
2247
2245
        y  = tmp_win->frame_y;
2248
 
        sw = tmp_win->frame_width;
2249
 
        sh = tmp_win->frame_height;
 
2246
        swidth = tmp_win->frame_width;
 
2247
        sheight = tmp_win->frame_height;
2250
2248
        switch (grav) {
2251
2249
            case ForgetGravity :
2252
2250
            case StaticGravity :
2258
2256
 
2259
2257
            case NorthEastGravity :
2260
2258
            case EastGravity :
2261
 
                x += sw - w;
 
2259
                x += swidth - width;
2262
2260
                break;
2263
2261
 
2264
2262
            case SouthWestGravity :
2265
2263
            case SouthGravity :
2266
 
                y += sh - h;
 
2264
                y += sheight - height;
2267
2265
                break;
2268
2266
 
2269
2267
            case SouthEastGravity :
2270
 
                x += sw - w;
2271
 
                y += sh - h;
 
2268
                x += swidth - width;
 
2269
                y += sheight - height;
2272
2270
                break;
2273
2271
        }
2274
 
        SetupWindow (tmp_win, x, y, w, h, -1);
 
2272
        SetupWindow (tmp_win, x, y, width, height, -1);
2275
2273
        break;
2276
2274
    }
2277
2275
 
2278
2276
    case F_MOVERESIZE: {
2279
2277
        int x, y, mask;
2280
 
        unsigned int w, h;
 
2278
        unsigned int width, height;
2281
2279
        int px = 20, py = 30;
2282
2280
 
2283
2281
        if (DeferExecution (context, func, Scr->SelectCursor)) return TRUE;
2284
 
        mask = XParseGeometry (action, &x, &y, &w, &h);
2285
 
        if (!(mask &  WidthValue)) w = tmp_win->frame_width;
2286
 
        else w += 2 * tmp_win->frame_bw3D;
2287
 
        if (!(mask & HeightValue)) h = tmp_win->frame_height;
2288
 
        else h += 2 * tmp_win->frame_bw3D + tmp_win->title_height;
2289
 
        ConstrainSize (tmp_win, &w, &h);
 
2282
        mask = XParseGeometry (action, &x, &y, &width, &height);
 
2283
        if (!(mask &  WidthValue)) width = tmp_win->frame_width;
 
2284
        else width += 2 * tmp_win->frame_bw3D;
 
2285
        if (!(mask & HeightValue)) height = tmp_win->frame_height;
 
2286
        else height += 2 * tmp_win->frame_bw3D + tmp_win->title_height;
 
2287
        ConstrainSize (tmp_win, &width, &height);
2290
2288
        if (mask & XValue) {
2291
 
            if (mask & XNegative) x += Scr->rootw  - w;
 
2289
            if (mask & XNegative) x += Scr->rootw  - width;
2292
2290
        } else x = tmp_win->frame_x;
2293
2291
        if (mask & YValue) {
2294
 
            if (mask & YNegative) y += Scr->rooth - h;
 
2292
            if (mask & YNegative) y += Scr->rooth - height;
2295
2293
        } else y = tmp_win->frame_y;
2296
2294
 
2297
2295
        {
2300
2298
            Window       junkW;
2301
2299
            XQueryPointer (dpy, Scr->Root, &junkW, &junkW, &junkX, &junkY, &px, &py, &junkK);
2302
2300
        }
2303
 
        px -= tmp_win->frame_x; if (px > w) px = w / 2;
2304
 
        py -= tmp_win->frame_y; if (py > h) px = h / 2;
2305
 
        SetupWindow (tmp_win, x, y, w, h, -1);
 
2301
        px -= tmp_win->frame_x; if (px > width) px = width / 2;
 
2302
        py -= tmp_win->frame_y; if (py > height) px = height / 2;
 
2303
        SetupWindow (tmp_win, x, y, width, height, -1);
2306
2304
        XWarpPointer (dpy, Scr->Root, Scr->Root, 0, 0, 0, 0, x + px, y + py);
2307
2305
        break;
2308
2306
    }
2855
2853
 
2856
2854
                if (ConstMoveDir != MOVE_NONE)
2857
2855
                {
2858
 
                    int xl, yt, w, h;
 
2856
                    int xl, yt, width, height;
2859
2857
 
2860
2858
                    xl = ConstMoveX;
2861
2859
                    yt = ConstMoveY;
2862
 
                    w = DragWidth + 2 * JunkBW;
2863
 
                    h = DragHeight + 2 * JunkBW;
 
2860
                    width = DragWidth + 2 * JunkBW;
 
2861
                    height = DragHeight + 2 * JunkBW;
2864
2862
 
2865
2863
                    if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
2866
2864
                        TryToGrid (tmp_win, &xl, &yt);
2873
2871
 
2874
2872
                    if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
2875
2873
                    {
2876
 
                        ConstrainByBorders (tmp_win, &xl, w, &yt, h);
 
2874
                        ConstrainByBorders (tmp_win, &xl, width, &yt, height);
2877
2875
                    }
2878
2876
                    CurrentDragX = xl;
2879
2877
                    CurrentDragY = yt;
2887
2885
                        WMapSetupWindow (tmp_win, xl, yt, -1, -1);
2888
2886
                    }
2889
2887
                    else
2890
 
                        MoveOutline(eventp->xmotion.root, xl, yt, w, h,
 
2888
                        MoveOutline(eventp->xmotion.root, xl, yt, width, height,
2891
2889
                            tmp_win->frame_bw, 
2892
2890
                            moving_icon ? 0 : tmp_win->title_height + tmp_win->frame_bw3D);
2893
2891
                }
2894
2892
            }
2895
2893
            else if (DragWindow != None)
2896
2894
            {
2897
 
                int xl, yt, w, h;
 
2895
                int xl, yt, width, height;
2898
2896
                if (!menuFromFrameOrWindowOrTitlebar) {
2899
2897
                  xl = eventp->xmotion.x_root - DragX - JunkBW;
2900
2898
                  yt = eventp->xmotion.y_root - DragY - JunkBW;
2903
2901
                  xl = eventp->xmotion.x_root - (DragWidth / 2);
2904
2902
                  yt = eventp->xmotion.y_root - (DragHeight / 2);
2905
2903
                }                 
2906
 
                w = DragWidth + 2 * JunkBW;
2907
 
                h = DragHeight + 2 * JunkBW;
 
2904
                width = DragWidth + 2 * JunkBW;
 
2905
                height = DragHeight + 2 * JunkBW;
2908
2906
 
2909
2907
                if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
2910
2908
                    TryToGrid (tmp_win, &xl, &yt);
2917
2915
 
2918
2916
                if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
2919
2917
                {
2920
 
                    ConstrainByBorders (tmp_win, &xl, w, &yt, h);
 
2918
                    ConstrainByBorders (tmp_win, &xl, width, &yt, height);
2921
2919
                }
2922
2920
 
2923
2921
                CurrentDragX = xl;
2932
2930
                  if (! moving_icon) WMapSetupWindow (tmp_win, xl, yt, -1, -1);
2933
2931
                }
2934
2932
                else
2935
 
                    MoveOutline(eventp->xmotion.root, xl, yt, w, h,
 
2933
                    MoveOutline(eventp->xmotion.root, xl, yt, width, height,
2936
2934
                        tmp_win->frame_bw,
2937
2935
                        moving_icon ? 0 : tmp_win->title_height + tmp_win->frame_bw3D);
2938
2936
            }
3233
3231
 
3234
3232
    case F_WARPTO:
3235
3233
        {
3236
 
            register TwmWindow *t;
 
3234
            register TwmWindow *tw;
3237
3235
            int len;
3238
3236
 
3239
3237
            len = strlen(action);
3244
3242
                        printf ("curren iconmgr entry: %s", tmp_win->iconmgr->Current);
3245
3243
                }
3246
3244
#endif /* #ifdef WARPTO_FROM_ICONMGR */
3247
 
            for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
3248
 
                if (!strncmp(action, t->full_name, len)) break;
3249
 
                if (match (action, t->full_name)) break;
 
3245
            for (tw = Scr->TwmRoot.next; tw != NULL; tw = tw->next) {
 
3246
                if (!strncmp(action, tw->full_name, len)) break;
 
3247
                if (match (action, tw->full_name)) break;
3250
3248
            }
3251
 
            if (!t) {
3252
 
                for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
3253
 
                    if (!strncmp(action, t->class.res_name, len)) break;
3254
 
                    if (match (action, t->class.res_name)) break;
 
3249
            if (!tw) {
 
3250
                for (tw = Scr->TwmRoot.next; tw != NULL; tw = tw->next) {
 
3251
                    if (!strncmp(action, tw->class.res_name, len)) break;
 
3252
                    if (match (action, tw->class.res_name)) break;
3255
3253
                }
3256
 
                if (!t) {
3257
 
                    for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
3258
 
                        if (!strncmp(action, t->class.res_class, len)) break;
3259
 
                        if (match (action, t->class.res_class)) break;
 
3254
                if (!tw) {
 
3255
                    for (tw = Scr->TwmRoot.next; tw != NULL; tw = tw->next) {
 
3256
                        if (!strncmp(action, tw->class.res_class, len)) break;
 
3257
                        if (match (action, tw->class.res_class)) break;
3260
3258
                    }
3261
3259
                }
3262
3260
            }
3263
3261
 
3264
 
            if (t) {
3265
 
                if (Scr->WarpUnmapped || t->mapped) {
3266
 
                    if (!t->mapped) DeIconify (t);
3267
 
                    if (!Scr->NoRaiseWarp) RaiseWindow (t);
3268
 
                    WarpToWindow (t);
 
3262
            if (tw) {
 
3263
                if (Scr->WarpUnmapped || tw->mapped) {
 
3264
                    if (!tw->mapped) DeIconify (tw);
 
3265
                    if (!Scr->NoRaiseWarp) RaiseWindow (tw);
 
3266
                    WarpToWindow (tw);
3269
3267
                }
3270
3268
            } else {
3271
3269
                XBell (dpy, 0);
3275
3273
 
3276
3274
    case F_WARPTOICONMGR:
3277
3275
        {
3278
 
            TwmWindow *t;
 
3276
            TwmWindow *tw;
3279
3277
            int len;
3280
3278
            Window raisewin = None, iconwin = None;
3281
3279
 
3289
3287
                    iconwin = Scr->iconmgr->active->w;
3290
3288
                }
3291
3289
            } else {
3292
 
                for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
3293
 
                    if (strncmp (action, t->icon_name, len) == 0) {
3294
 
                        if (t->list && t->list->iconmgr->twm_win->mapped) {
3295
 
                            raisewin = t->list->iconmgr->twm_win->frame;
3296
 
                            iconwin = t->list->icon;
 
3290
                for (tw = Scr->TwmRoot.next; tw != NULL; tw = tw->next) {
 
3291
                    if (strncmp (action, tw->icon_name, len) == 0) {
 
3292
                        if (tw->list && tw->list->iconmgr->twm_win->mapped) {
 
3293
                            raisewin = tw->list->iconmgr->twm_win->frame;
 
3294
                            iconwin = tw->list->icon;
3297
3295
                            break;
3298
3296
                        }
3299
3297
                    }
3966
3964
    XWindowAttributes winattrs;
3967
3965
    unsigned long eventMask;
3968
3966
    WList *wl;
3969
 
    Window leader;
3970
 
    Window blanket;
 
3967
    Window leader = (Window)-1;
 
3968
    Window blanket = (Window)-1;
3971
3969
 
3972
3970
    iconify = (!tmp_win->iconify_by_unmapping);
3973
3971
    t = (TwmWindow*) 0;
4883
4881
 
4884
4882
void SweepWindow (TwmWindow *tmp_win, Window    blanket)
4885
4883
{
4886
 
  float step;
 
4884
  float step = 0.0;
4887
4885
  int i, nsteps = 20;
4888
4886
  int dir = 0, dist = tmp_win->frame_x, dist1;
4889
4887
 
5080
5078
 
5081
5079
void jump (TwmWindow *tmp_win, int  direction, char *action)
5082
5080
{
5083
 
    int                 fx, fy, px, py, step, stat, cons;
 
5081
    int                 fx, fy, px, py, step, status, cons;
5084
5082
    int                 fwidth, fheight;
5085
5083
    int                 junkX, junkY;
5086
5084
    unsigned int        junkK;
5087
5085
    Window              junkW;
5088
5086
 
5089
5087
    if (! action) return;
5090
 
    stat = sscanf (action, "%d", &step);
5091
 
    if (stat != 1) return;
 
5088
    status = sscanf (action, "%d", &step);
 
5089
    if (status != 1) return;
5092
5090
    if (step < 1) return;
5093
5091
 
5094
5092
    fx = tmp_win->frame_x;