~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to resize.c

  • Committer: Matthew Fuller
  • Date: 2016-09-20 20:22:19 UTC
  • mfrom: (523.1.26 cleanups)
  • Revision ID: fullermd@over-yonder.net-20160920202219-ykdjyr1whmip1e5u
Cleanup organization of some window handling code.

Especially move various window-handling bits ouf of menus.c and util.c,
where they have no business being.  Create win_ops and win_util files for
much of it, as well as moving some to other existing locations they
better fit.  Do a little light commenting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
#include <stdlib.h>
74
74
 
75
75
#include "parse.h"
 
76
#include "events.h"
76
77
#include "util.h"
77
78
#include "otp.h"
78
79
#include "resize.h"
81
82
#include "decorations.h"
82
83
#include "screen.h"
83
84
#include "drawing.h"
 
85
#include "win_ops.h"
 
86
#include "win_utils.h"
84
87
#include "workspace_manager.h"
85
88
#include "iconmgr.h"
86
89
 
1277
1280
                }
1278
1281
        }
1279
1282
}
 
1283
 
 
1284
 
 
1285
/***********************************************************************
 
1286
 *
 
1287
 *  Procedure:
 
1288
 *      resizeFromCenter -
 
1289
 *
 
1290
 ***********************************************************************
 
1291
 */
 
1292
void
 
1293
resizeFromCenter(Window w, TwmWindow *tmp_win)
 
1294
{
 
1295
        int lastx, lasty, bw2;
 
1296
 
 
1297
        bw2 = tmp_win->frame_bw * 2;
 
1298
        AddingW = tmp_win->attr.width + bw2 + 2 * tmp_win->frame_bw3D;
 
1299
        AddingH = tmp_win->attr.height + tmp_win->title_height + bw2 + 2 *
 
1300
                  tmp_win->frame_bw3D;
 
1301
 
 
1302
        XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY,
 
1303
                     &DragWidth, &DragHeight,
 
1304
                     &JunkBW, &JunkDepth);
 
1305
 
 
1306
        XWarpPointer(dpy, None, w,
 
1307
                     0, 0, 0, 0, DragWidth / 2, DragHeight / 2);
 
1308
        XQueryPointer(dpy, Scr->Root, &JunkRoot,
 
1309
                      &JunkChild, &JunkX, &JunkY,
 
1310
                      &AddingX, &AddingY, &JunkMask);
 
1311
 
 
1312
        lastx = -10000;
 
1313
        lasty = -10000;
 
1314
 
 
1315
        MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight);
 
1316
        while(1) {
 
1317
                XMaskEvent(dpy,
 
1318
                           ButtonPressMask | PointerMotionMask | ExposureMask, &Event);
 
1319
 
 
1320
                if(Event.type == MotionNotify) {
 
1321
                        /* discard any extra motion events before a release */
 
1322
                        while(XCheckMaskEvent(dpy,
 
1323
                                              ButtonMotionMask | ButtonPressMask, &Event))
 
1324
                                if(Event.type == ButtonPress) {
 
1325
                                        break;
 
1326
                                }
 
1327
                }
 
1328
 
 
1329
                if(Event.type == ButtonPress) {
 
1330
                        MenuEndResize(tmp_win);
 
1331
                        // Next line should be unneeded, done by MenuEndResize() ?
 
1332
                        XMoveResizeWindow(dpy, w, AddingX, AddingY, AddingW, AddingH);
 
1333
                        break;
 
1334
                }
 
1335
 
 
1336
                if(Event.type != MotionNotify) {
 
1337
                        DispatchEvent2();
 
1338
                        if(Cancel) {
 
1339
                                // ...
 
1340
                                MenuEndResize(tmp_win);
 
1341
                                return;
 
1342
                        }
 
1343
                        continue;
 
1344
                }
 
1345
 
 
1346
                /*
 
1347
                 * XXX - if we are going to do a loop, we ought to consider
 
1348
                 * using multiple GXxor lines so that we don't need to
 
1349
                 * grab the server.
 
1350
                 */
 
1351
                XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
 
1352
                              &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
 
1353
 
 
1354
                if(lastx != AddingX || lasty != AddingY) {
 
1355
                        MenuDoResize(AddingX, AddingY, tmp_win);
 
1356
 
 
1357
                        lastx = AddingX;
 
1358
                        lasty = AddingY;
 
1359
                }
 
1360
 
 
1361
        }
 
1362
}