480
462
cx = frameX (c) + (frameWidth (c) / 2);
481
463
cy = frameY (c) + (frameHeight (c) / 2);
483
/* Translate coodinates to center on physical screen */
485
diff_x = abs (c->size->x - ((c->screen_info->width - c->width) / 2));
486
diff_y = abs (c->size->y - ((c->screen_info->height - c->height) / 2));
488
if (((n_monitors > 1) && (diff_x < 25) && (diff_y < 25)) ||
489
((frameX (c) == 0) && (frameY (c) == 0) && (c->type & (WINDOW_TYPE_DIALOG))))
464
screen_info = c->screen_info;
467
if ((c->size->x == 0) && (c->size->y == 0) && (c->type & (WINDOW_TYPE_DIALOG)))
469
/* Dialogs that place temselves in (0,0) will be centered */
472
else if (n_monitors > 1)
474
/* First, check if the window is centered on the whole screen */
475
diff_x = abs (c->size->x - ((c->screen_info->width - c->size->width) / 2));
476
diff_y = abs (c->size->y - ((c->screen_info->height - c->size->height) / 2));
479
centered = ((diff_x < 25) && (diff_y < 25));
481
while ((!centered) && (monitor_nbr < n_monitors))
483
gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
484
diff_x = abs (c->size->x - ((rect.width - c->size->width) / 2));
485
diff_y = abs (c->size->y - ((rect.height - c->size->height) / 2));
486
centered = ((diff_x < 25) && (diff_y < 25));
491
492
/* We consider that the windows is centered on screen,
492
493
* Thus, will move it so its center on the current
502
503
clientAutoMaximize (Client * c, int full_w, int full_h)
504
505
if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN) ||
505
FLAG_TEST (c->xfwm_flags, XFWM_FLAG_LEGACY_FULLSCREEN))
506
FLAG_TEST (c->xfwm_flags, XFWM_FLAG_LEGACY_FULLSCREEN) ||
507
!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER))
507
/* Fullscree nwindows should not be maximized */
510
* Fullscreen or undecorated windows should not be
511
* automatically maximized...
511
516
if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ) &&
512
517
(frameWidth (c) > full_w))
519
TRACE ("The application \"%s\" has requested a window width "
520
"(%u) larger than the actual width available in the workspace (%u), "
521
"the window will be maximized horizontally.", c->name, frameWidth (c), full_w);
514
522
FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ);
517
525
if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT) &&
518
526
(frameHeight (c) > full_h))
528
TRACE ("The application \"%s\" has requested a window height "
529
"(%u) larger than the actual height available in the workspace (%u), "
530
"the window will be maximized vertically.", c->name, frameHeight (c), full_h);
520
531
FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT);
609
625
c->y = MAX (full_y + frameTop(c) + (full_h - frameHeight(c)) / 2, full_y + frameTop(c));
629
mousePlacement (Client * c, int full_x, int full_y, int full_w, int full_h, int mx, int my)
631
g_return_if_fail (c != NULL);
632
TRACE ("entering centerPlacement");
634
c->x = mx + frameLeft(c) - frameWidth(c) / 2;
635
c->y = my + frameTop(c) - frameHeight(c) / 2;
637
c->x = MIN (c->x, full_x + full_w - frameWidth(c) + frameLeft(c));
638
c->y = MIN (c->y, full_y + full_h - frameHeight(c) + frameTop(c));
640
c->x = MAX (c->x, full_x + frameLeft(c));
641
c->y = MAX (c->y, full_y + frameTop(c));
613
645
clientInitPosition (Client * c)
624
655
g_return_if_fail (c != NULL);
625
656
TRACE ("entering clientInitPosition");
627
clientGravitate (c, APPLY);
629
658
screen_info = c->screen_info;
632
661
position = (c->size->flags & (PPosition | USPosition));
634
663
n_monitors = gdk_screen_get_n_monitors (c->screen_info->gscr);
664
if ((n_monitors > 1) || (screen_info->params->placement_mode == PLACE_MOUSE))
638
666
getMouseXY (screen_info, screen_info->xroot, &msx, &msy);
639
monitor_nbr = find_monitor_at_point (screen_info->gscr, msx, msy);
641
gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
667
myScreenFindMonitorAtPoint (screen_info, msx, msy, &rect);
671
gdk_screen_get_monitor_geometry (screen_info->gscr, 0, &rect);
643
673
if (position || (c->type & (WINDOW_TYPE_DONT_PLACE | WINDOW_TYPE_DIALOG)) || clientIsTransient (c))
645
675
if (!position && clientIsTransient (c) && (c2 = clientGetTransient (c)))
702
741
clientAutoMaximize (c, full_w, full_h);
747
clientFill (Client * c, int fill_type)
749
ScreenInfo *screen_info;
750
DisplayInfo *display_info;
751
Client *east_neighbour;
752
Client *west_neighbour;
753
Client *north_neighbour;
754
Client *south_neighbour;
759
int i, cx, cy, full_x, full_y, full_w, full_h;
760
int tmp_x, tmp_y, tmp_w, tmp_h;
762
g_return_if_fail (c != NULL);
764
if (!CLIENT_CAN_FILL_WINDOW (c))
769
screen_info = c->screen_info;
770
display_info = screen_info->display_info;
772
east_neighbour = NULL;
773
west_neighbour = NULL;
774
north_neighbour = NULL;
775
south_neighbour = NULL;
777
for (c2 = screen_info->clients, i = 0; i < screen_info->client_count; c2 = c2->next, i++)
780
/* Filter out all windows which are not visible, or not on the same layer
781
* as well as the client window itself
783
if ((c != c2) && FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE) && (c2->win_layer == c->win_layer))
785
/* Fill horizontally */
786
if (fill_type & CLIENT_FILL_HORIZ)
789
* check if the neigbour client (c2) is located
790
* east or west of our client.
792
if (segment_overlap (frameY(c), frameY(c) + frameHeight(c), frameY(c2), frameY(c2) + frameHeight(c2)))
794
if ((frameX(c2) + frameWidth(c2)) < frameX(c))
798
/* Check if c2 is closer to the client
799
* then the east neighbour already found
801
if ((frameX(east_neighbour) + frameWidth(east_neighbour)) < (frameX(c2) + frameWidth(c2)))
811
if ((frameX(c) + frameWidth(c)) < frameX(c2))
813
/* Check if c2 is closer to the client
814
* then the west neighbour already found
818
if (frameX(c2) < frameX(west_neighbour))
831
/* Fill vertically */
832
if (fill_type & CLIENT_FILL_VERT)
834
/* check if the neigbour client (c2) is located
835
* north or south of our client.
837
if (segment_overlap (frameX(c), frameX(c) + frameWidth(c), frameX(c2), frameX(c2) + frameWidth(c2)))
839
if ((frameY(c2) + frameHeight(c2)) < frameY(c))
843
/* Check if c2 is closer to the client
844
* then the north neighbour already found
846
if ((frameY(north_neighbour) + frameHeight(north_neighbour)) < (frameY(c2) + frameHeight(c2)))
848
north_neighbour = c2;
853
north_neighbour = c2;
856
if ((frameY(c) + frameHeight(c)) < frameY(c2))
860
/* Check if c2 is closer to the client
861
* then the south neighbour already found
863
if (frameY(c2) < frameY(south_neighbour))
865
south_neighbour = c2;
870
south_neighbour = c2;
878
/* Compute the largest size available, based on struts, margins and Xinerama layout */
881
tmp_h = frameHeight (c);
882
tmp_w = frameWidth (c);
884
cx = tmp_x + (tmp_w / 2);
885
cy = tmp_y + (tmp_h / 2);
887
myScreenFindMonitorAtPoint (screen_info, cx, cy, &rect);
889
full_x = MAX (screen_info->params->xfwm_margins[STRUTS_LEFT], rect.x);
890
full_y = MAX (screen_info->params->xfwm_margins[STRUTS_TOP], rect.y);
891
full_w = MIN (screen_info->width - screen_info->params->xfwm_margins[STRUTS_RIGHT],
892
rect.x + rect.width) - full_x;
893
full_h = MIN (screen_info->height - screen_info->params->xfwm_margins[STRUTS_BOTTOM],
894
rect.y + rect.height) - full_y;
896
if ((fill_type & CLIENT_FILL) == CLIENT_FILL)
898
mask = CWX | CWY | CWHeight | CWWidth;
899
/* Adjust size to the largest size available, not covering struts */
900
clientMaxSpace (screen_info, &full_x, &full_y, &full_w, &full_h);
902
else if (fill_type & CLIENT_FILL_VERT)
904
mask = CWY | CWHeight;
905
/* Adjust size to the tallest size available, for the current horizontal position/width */
906
clientMaxSpace (screen_info, &tmp_x, &full_y, &tmp_w, &full_h);
908
else if (fill_type & CLIENT_FILL_HORIZ)
910
mask = CWX | CWWidth;
911
/* Adjust size to the widest size available, for the current vertical position/height */
912
clientMaxSpace (screen_info, &full_x, &tmp_y, &full_w, &tmp_h);
915
/* If there are neighbours, resize to their borders.
916
* If not, resize to the largest size available that you just have computed.
922
wc.x += MAX (frameX(east_neighbour) + frameWidth(east_neighbour), full_x);
929
wc.width = full_x - frameRight(c) - wc.x;
932
wc.width += MIN (frameX(west_neighbour), full_w);
942
wc.y += MAX (frameY(north_neighbour) + frameHeight(north_neighbour), full_y);
949
wc.height = full_y - frameBottom(c) - wc.y;
952
wc.height += MIN (frameY(south_neighbour), full_h);
959
TRACE ("Fill size request: (%d,%d) %dx%d", wc.x, wc.y, wc.width, wc.height);
960
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MANAGED))
962
clientConfigure(c, &wc, mask, NO_CFG_FLAG);