~muktupavels/metacity/adwaita-icon-theme-lp-1414613

« back to all changes in this revision

Viewing changes to src/display.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-13 23:03:47 UTC
  • mto: (2.2.1 sid) (1.4.2)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051213230347-8dnaprp18n18dz1y
Tags: upstream-2.13.5
ImportĀ upstreamĀ versionĀ 2.13.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Copyright (C) 2001 Havoc Pennington
5
5
 * Copyright (C) 2002, 2003, 2004 Red Hat, Inc.
6
6
 * Copyright (C) 2003, 2004 Rob Adams
 
7
 * Copyright (C) 2004, 2005 Elijah Newren
7
8
 * 
8
9
 * This program is free software; you can redistribute it and/or
9
10
 * modify it under the terms of the GNU General Public License as
518
519
  display->grab_screen = NULL;
519
520
  display->grab_resize_popup = NULL;
520
521
 
 
522
  display->grab_edge_resistance_data = NULL;
 
523
 
521
524
#ifdef HAVE_XSYNC
522
525
  {
523
526
    int major, minor;
1335
1338
 
1336
1339
  if (window)
1337
1340
    {
 
1341
      /* FIXME!!!!  This function is _wrong_ except for the resize-only
 
1342
       * case.  Even then, it sucks to special case the code instead of
 
1343
       * factoring out common functionality with the configure reqest
 
1344
       * handling, especially since the EWMH says this message should be
 
1345
       * treated identically to a configure request with the exception of
 
1346
       * having a special gravity specified.
 
1347
       */
1338
1348
      meta_window_get_gravity_position (window, &x, &y);
1339
1349
      width = window->rect.width;
1340
1350
      height = window->rect.height;
1357
1367
        {
1358
1368
          if (gravity)
1359
1369
            meta_window_resize_with_gravity (window,
1360
 
                                             TRUE,
 
1370
                                             FALSE,
1361
1371
                                             width,
1362
1372
                                             height,
1363
1373
                                             gravity);
1364
1374
          else
1365
1375
            meta_window_resize (window,
1366
 
                                TRUE,
 
1376
                                FALSE,
1367
1377
                                width,
1368
1378
                                height);
1369
1379
        }
1370
1380
      else
1371
1381
        {
1372
1382
          meta_window_move_resize (window,
1373
 
                                   TRUE,
 
1383
                                   FALSE,
1374
1384
                                   x,
1375
1385
                                   y,
1376
1386
                                   width,
1390
1400
 
1391
1401
  if (window)
1392
1402
    {
1393
 
      /*
1394
 
       * The EWMH includes a sibling for the restack request, but we
1395
 
       * don't currently support these types of raises.
 
1403
      /* FIXME: The EWMH includes a sibling for the restack request, but we
 
1404
       * (stupidly) don't currently support these types of raises.
1396
1405
       *
 
1406
       * Also, unconditionally following these is REALLY stupid--we should
 
1407
       * combine this code with the stuff in
 
1408
       * meta_window_configure_request() which is smart about whether to
 
1409
       * follow the request or do something else (though not smart enough
 
1410
       * and is also too stupid to handle the sibling stuff).
1397
1411
       */
1398
1412
      switch (event->xclient.data.l[2])
1399
1413
        {
1669
1683
            {
1670
1684
              if (window->has_resize_func)
1671
1685
                {
1672
 
                  gboolean north;
1673
 
                  gboolean west;
 
1686
                  gboolean north, south;
 
1687
                  gboolean west, east;
1674
1688
                  int root_x, root_y;
1675
1689
                  MetaGrabOp op;
1676
1690
 
1677
1691
                  meta_window_get_position (window, &root_x, &root_y);
1678
1692
 
1679
 
                  west = event->xbutton.x_root < (root_x + window->rect.width / 2);
1680
 
                  north = event->xbutton.y_root < (root_y + window->rect.height / 2);
 
1693
                  west = event->xbutton.x_root <  (root_x + 1 * window->rect.width  / 3);
 
1694
                  east = event->xbutton.x_root >  (root_x + 2 * window->rect.width  / 3);
 
1695
                  north = event->xbutton.y_root < (root_y + 1 * window->rect.height / 3);
 
1696
                  south = event->xbutton.y_root > (root_y + 2 * window->rect.height / 3);
1681
1697
 
1682
 
                  if (west && north)
 
1698
                  if (north && west)
1683
1699
                    op = META_GRAB_OP_RESIZING_NW;
1684
 
                  else if (west)
 
1700
                  else if (north && east)
 
1701
                    op = META_GRAB_OP_RESIZING_NE;
 
1702
                  else if (south && west)
1685
1703
                    op = META_GRAB_OP_RESIZING_SW;
 
1704
                  else if (south && east)
 
1705
                    op = META_GRAB_OP_RESIZING_SE;
1686
1706
                  else if (north)
1687
 
                    op = META_GRAB_OP_RESIZING_NE;
1688
 
                  else
1689
 
                    op = META_GRAB_OP_RESIZING_SE;
 
1707
                    op = META_GRAB_OP_RESIZING_N;
 
1708
                  else if (west)
 
1709
                    op = META_GRAB_OP_RESIZING_W;
 
1710
                  else if (east)
 
1711
                    op = META_GRAB_OP_RESIZING_E;
 
1712
                  else if (south)
 
1713
                    op = META_GRAB_OP_RESIZING_S;
 
1714
                  else /* Middle region is no-op to avoid user triggering wrong action */
 
1715
                    op = META_GRAB_OP_NONE;
1690
1716
                  
1691
 
                  meta_display_begin_grab_op (display,
1692
 
                                              window->screen,
1693
 
                                              window,
1694
 
                                              op,
1695
 
                                              TRUE,
1696
 
                                              event->xbutton.serial,
1697
 
                                              event->xbutton.button,
1698
 
                                              0,
1699
 
                                              event->xbutton.time,
1700
 
                                              event->xbutton.x_root,
1701
 
                                              event->xbutton.y_root);
 
1717
                  if (op != META_GRAB_OP_NONE)
 
1718
                    meta_display_begin_grab_op (display,
 
1719
                                                window->screen,
 
1720
                                                window,
 
1721
                                                op,
 
1722
                                                TRUE,
 
1723
                                                event->xbutton.serial,
 
1724
                                                event->xbutton.button,
 
1725
                                                0,
 
1726
                                                event->xbutton.time,
 
1727
                                                event->xbutton.x_root,
 
1728
                                                event->xbutton.y_root);
1702
1729
                }
1703
1730
            }
1704
1731
          else if (event->xbutton.button == 3)
3243
3270
  display->grab_old_window_stacking = NULL;
3244
3271
#ifdef HAVE_XSYNC
3245
3272
  display->grab_sync_request_alarm = None;
 
3273
  display->grab_last_user_action_was_snap = FALSE;
3246
3274
#endif
3247
3275
  display->grab_was_cancelled = FALSE;
3248
3276
  
3334
3362
  g_assert (display->grab_window != NULL || display->grab_screen != NULL);
3335
3363
  g_assert (display->grab_op != META_GRAB_OP_NONE);
3336
3364
 
 
3365
  /* If this is a move or resize, cache the window edges for
 
3366
   * resistance/snapping
 
3367
   */
 
3368
  if (meta_grab_op_is_resizing (display->grab_op) || 
 
3369
      meta_grab_op_is_moving (display->grab_op))
 
3370
    {
 
3371
      meta_topic (META_DEBUG_WINDOW_OPS,
 
3372
                  "Computing edges to resist-movement or snap-to for %s.\n",
 
3373
                  window->desc);
 
3374
      meta_display_compute_resistance_and_snapping_edges (display);
 
3375
    }
 
3376
 
3337
3377
  /* Save the old stacking */
3338
3378
  if (GRAB_OP_IS_WINDOW_SWITCH (display->grab_op))
3339
3379
    {
3407
3447
      display->ungrab_should_not_cause_focus_window = display->grab_xwindow;
3408
3448
    }
3409
3449
  
 
3450
  /* If this was a move or resize clear out the edge cache */
 
3451
  if (meta_grab_op_is_resizing (display->grab_op) || 
 
3452
      meta_grab_op_is_moving (display->grab_op))
 
3453
    {
 
3454
      meta_topic (META_DEBUG_WINDOW_OPS,
 
3455
                  "Clearing out the edges for resistance/snapping");
 
3456
      meta_display_cleanup_edges (display);
 
3457
    }
 
3458
 
3410
3459
  if (display->grab_old_window_stacking != NULL)
3411
3460
    {
3412
3461
      meta_topic (META_DEBUG_WINDOW_OPS,
4275
4324
  return gravity;
4276
4325
}
4277
4326
 
4278
 
gboolean
4279
 
meta_rectangle_intersect (MetaRectangle *src1,
4280
 
                          MetaRectangle *src2,
4281
 
                          MetaRectangle *dest)
4282
 
{
4283
 
  int dest_x, dest_y;
4284
 
  int dest_w, dest_h;
4285
 
  int return_val;
4286
 
 
4287
 
  g_return_val_if_fail (src1 != NULL, FALSE);
4288
 
  g_return_val_if_fail (src2 != NULL, FALSE);
4289
 
  g_return_val_if_fail (dest != NULL, FALSE);
4290
 
 
4291
 
  return_val = FALSE;
4292
 
 
4293
 
  dest_x = MAX (src1->x, src2->x);
4294
 
  dest_y = MAX (src1->y, src2->y);
4295
 
  dest_w = MIN (src1->x + src1->width, src2->x + src2->width) - dest_x;
4296
 
  dest_h = MIN (src1->y + src1->height, src2->y + src2->height) - dest_y;
4297
 
  
4298
 
  if (dest_w > 0 && dest_h > 0)
4299
 
    {
4300
 
      dest->x = dest_x;
4301
 
      dest->y = dest_y;
4302
 
      dest->width = dest_w;
4303
 
      dest->height = dest_h;
4304
 
      return_val = TRUE;
4305
 
    }
4306
 
  else
4307
 
    {
4308
 
      dest->width = 0;
4309
 
      dest->height = 0;
4310
 
    }
4311
 
 
4312
 
  return return_val;
4313
 
}
4314
 
 
4315
 
gboolean
4316
 
meta_rectangle_equal (const MetaRectangle *src1,
4317
 
                      const MetaRectangle *src2)
4318
 
{
4319
 
  return ((src1->x == src2->x) &&
4320
 
          (src1->y == src2->y) &&
4321
 
          (src1->width == src2->width) &&
4322
 
          (src1->height == src2->height));
4323
 
}
4324
 
 
4325
4327
static MetaScreen*
4326
4328
find_screen_for_selection (MetaDisplay *display,
4327
4329
                           Window       owner,