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

« back to all changes in this revision

Viewing changes to src/constraints.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-01 12:43:53 UTC
  • mto: (2.2.1 sid) (1.4.2)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20070501124353-qjwng2k8l9i1afqo
Tags: upstream-2.19.5
ImportĀ upstreamĀ versionĀ 2.19.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
  else if (flags & META_IS_RESIZE_ACTION)
351
351
    info->action_type = ACTION_RESIZE;
352
352
  else if (flags & META_IS_MOVE_ACTION)
353
 
    info->action_type = ACTION_MOVE_AND_RESIZE;
 
353
    info->action_type = ACTION_MOVE;
354
354
  else
355
355
    g_error ("BAD, BAD developer!  No treat for you!  (Fix your calls to "
356
356
             "meta_window_move_resize_internal()).\n");
365
365
   * and (b) ignored it for aspect ratio windows -- at least in those
366
366
   * cases where both directions do actually change size.
367
367
   */
368
 
  info->fixed_directions = 0;
 
368
  info->fixed_directions = FIXED_DIRECTION_NONE;
369
369
  /* If x directions don't change but either y direction does */
370
370
  if ( orig->x == new->x && orig->x + orig->width  == new->x + new->width   &&
371
371
      (orig->y != new->y || orig->y + orig->height != new->y + new->height))
385
385
   * aren't explicit user interaction, though, so just clear it out.
386
386
   */
387
387
  if (!info->is_user_action)
388
 
    info->fixed_directions = 0;
 
388
    info->fixed_directions = FIXED_DIRECTION_NONE;
389
389
 
390
390
  xinerama_info =
391
391
    meta_screen_get_xinerama_for_rect (window->screen, &info->current);
441
441
                "Freakin' Invalid Stupid",
442
442
              (info->is_user_action) ? "true" : "false",
443
443
              meta_gravity_to_string (info->resize_gravity),
444
 
              (info->fixed_directions == 0) ? "None" :
 
444
              (info->fixed_directions == FIXED_DIRECTION_NONE) ? "None" :
445
445
                (info->fixed_directions == FIXED_DIRECTION_X) ? "X fixed" :
446
446
                (info->fixed_directions == FIXED_DIRECTION_Y) ? "Y fixed" :
447
447
                "Freakin' Invalid Stupid",
500
500
      /* Since we just barely placed the window, there's no reason to
501
501
       * consider any of the directions fixed.
502
502
       */
503
 
      info->fixed_directions = 0;
 
503
      info->fixed_directions = FIXED_DIRECTION_NONE;
504
504
    }
505
505
 
506
506
  if (window->placed || did_placement)
691
691
                        ConstraintPriority  priority,
692
692
                        gboolean            check_only)
693
693
{
694
 
  MetaRectangle min_size, max_size, work_area;
 
694
  MetaRectangle target_size;
 
695
  MetaRectangle min_size, max_size;
695
696
  gboolean hminbad, vminbad;
696
697
  gboolean horiz_equal, vert_equal;
697
698
  gboolean constraint_already_satisfied;
703
704
  if (!window->maximized_horizontally && !window->maximized_vertically)
704
705
    return TRUE;
705
706
 
706
 
  work_area = info->work_area_xinerama;
707
 
  unextend_by_frame (&work_area, info->fgeom);
 
707
  /* Calculate target_size = maximized size of (window + frame) */
 
708
  if (window->maximized_horizontally && window->maximized_vertically)
 
709
    target_size = info->work_area_xinerama;
 
710
  else
 
711
    {
 
712
      /* Amount of maximization possible in a single direction depends
 
713
       * on which struts could occlude the window given its current
 
714
       * position.  For example, a vertical partial strut on the right
 
715
       * is only relevant for a horizontally maximized window when the
 
716
       * window is at a vertical position where it could be occluded
 
717
       * by that partial strut.
 
718
       */
 
719
      MetaDirection  direction;
 
720
      GSList        *active_workspace_struts;
 
721
 
 
722
      if (window->maximized_horizontally)
 
723
        direction = META_DIRECTION_HORIZONTAL;
 
724
      else
 
725
        direction = META_DIRECTION_VERTICAL;
 
726
      active_workspace_struts = window->screen->active_workspace->all_struts;
 
727
 
 
728
      target_size = info->current;
 
729
      extend_by_frame (&target_size, info->fgeom);
 
730
      meta_rectangle_expand_to_avoiding_struts (&target_size,
 
731
                                                &info->entire_xinerama,
 
732
                                                direction,
 
733
                                                active_workspace_struts);
 
734
   }
 
735
  /* Now make target_size = maximized size of client window */
 
736
  unextend_by_frame (&target_size, info->fgeom);
 
737
 
 
738
  /* Check min size constraints; max size constraints are ignored for maximized
 
739
   * windows, as per bug 327543.
 
740
   */
708
741
  get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size);
709
 
 
710
 
  hminbad = work_area.width < min_size.width && window->maximized_horizontally;
711
 
  vminbad = work_area.height < min_size.height && window->maximized_vertically;
 
742
  hminbad = target_size.width < min_size.width && window->maximized_horizontally;
 
743
  vminbad = target_size.height < min_size.height && window->maximized_vertically;
712
744
  if (hminbad || vminbad)
713
745
    return TRUE;
714
746
 
715
747
  /* Determine whether constraint is already satisfied; exit if it is */
716
 
  horiz_equal = work_area.x      == info->current.x &&
717
 
                work_area.width  == info->current.width;
718
 
  vert_equal  = work_area.y      == info->current.y &&
719
 
                work_area.height == info->current.height;
 
748
  horiz_equal = target_size.x      == info->current.x &&
 
749
                target_size.width  == info->current.width;
 
750
  vert_equal  = target_size.y      == info->current.y &&
 
751
                target_size.height == info->current.height;
720
752
  constraint_already_satisfied =
721
753
    (horiz_equal || !window->maximized_horizontally) &&
722
754
    (vert_equal  || !window->maximized_vertically);
726
758
  /*** Enforce constraint ***/
727
759
  if (window->maximized_horizontally)
728
760
    {
729
 
      info->current.x      = work_area.x;
730
 
      info->current.width  = work_area.width;
 
761
      info->current.x      = target_size.x;
 
762
      info->current.width  = target_size.width;
731
763
    }
732
764
  if (window->maximized_vertically)
733
765
    {
734
 
      info->current.y      = work_area.y;
735
 
      info->current.height = work_area.height;
 
766
      info->current.y      = target_size.y;
 
767
      info->current.height = target_size.height;
736
768
    }
737
769
  return TRUE;
738
770
}
777
809
                           gboolean            check_only)
778
810
{
779
811
  int bh, hi, bw, wi, extra_height, extra_width;
 
812
  int new_width, new_height;
780
813
  gboolean constraint_already_satisfied;
781
814
 
782
815
  if (priority > PRIORITY_SIZE_HINTS_INCREMENTS)
794
827
  wi = window->size_hints.width_inc;
795
828
  extra_height = (info->current.height - bh) % hi;
796
829
  extra_width  = (info->current.width  - bw) % wi;
 
830
  /* ignore size increments for maximized windows */
797
831
  if (window->maximized_horizontally)
798
832
    extra_width *= 0;
799
833
  if (window->maximized_vertically)
800
834
    extra_height *= 0;
 
835
  /* constraint is satisfied iff there is no extra height or width */
801
836
  constraint_already_satisfied = 
802
837
    (extra_height == 0 && extra_width == 0);
803
838
 
805
840
    return constraint_already_satisfied;
806
841
 
807
842
  /*** Enforce constraint ***/
808
 
  /* Shrink to base + N * inc */
 
843
  new_width  = info->current.width  - extra_width;
 
844
  new_height = info->current.height - extra_height;
 
845
 
 
846
  /* Adjusting down instead of up (as done in the above two lines) may
 
847
   * violate minimum size constraints; fix the adjustment if this
 
848
   * happens.
 
849
   */
 
850
  if (new_width  < window->size_hints.min_width)
 
851
    new_width  += ((window->size_hints.min_width  - new_width)/wi  + 1)*wi;
 
852
  if (new_height < window->size_hints.min_height)
 
853
    new_height += ((window->size_hints.min_height - new_height)/hi + 1)*hi;
 
854
 
 
855
  /* Resize to the new size */
809
856
  meta_rectangle_resize_with_gravity (&info->orig,
810
857
                                      &info->current, 
811
858
                                      info->resize_gravity,
812
 
                                      info->current.width - extra_width,
813
 
                                      info->current.height - extra_height);
 
859
                                      new_width,
 
860
                                      new_height);
814
861
  return TRUE;
815
862
}
816
863
 
994
1041
  gboolean exit_early = FALSE, constraint_satisfied;
995
1042
  MetaRectangle how_far_it_can_be_smushed, min_size, max_size;
996
1043
 
 
1044
#ifdef WITH_VERBOSE_MODE
997
1045
  /* First, log some debugging information */
998
1046
  char spanning_region[1 + 28 * g_list_length (region_spanning_rectangles)];
999
 
  (void) spanning_region;  /* Avoid stupid & incorrect compiler warnings... */
 
1047
 
1000
1048
  meta_topic (META_DEBUG_GEOMETRY,
1001
1049
              "screen/xinerama constraint; region_spanning_rectangles: %s\n",
1002
1050
              meta_rectangle_region_to_string (region_spanning_rectangles, ", ", 
1003
1051
                                               spanning_region));
 
1052
#endif
1004
1053
 
1005
1054
  /* Determine whether constraint applies; exit if it doesn't */
1006
1055
  how_far_it_can_be_smushed = info->current;