254
260
case 0 : iswinbox = 0; break;
255
261
case 1 : iswinbox = 0; break;
256
case 2 : iswinbox = 1; iconm = 0; break;
257
default : iswinbox = 0; iconm = 1; break;
262
case 2 : iswinbox = 1; iconm = 0; break;
263
case 3 : iswman = 1; iconm = 0; break;
264
default : iswinbox = 0; iswman = 0; iconm = 1; break;
260
267
tmp_win->zoomed = ZOOM_NONE;
261
268
tmp_win->iconmgr = iconm;
262
269
tmp_win->iconmgrp = iconp;
270
tmp_win->wspmgr = iswman;
263
271
tmp_win->iswinbox = iswinbox;
264
273
tmp_win->cmaps.number_cwins = 0;
265
274
tmp_win->savegeometry.width = -1;
267
276
XSelectInput(dpy, tmp_win->w, PropertyChangeMask);
268
277
XGetWindowAttributes(dpy, tmp_win->w, &tmp_win->attr);
269
278
#ifndef NO_LOCALE
270
tmp_win->name = GetWMPropertyString(tmp_win->w, XA_WM_NAME);
279
tmp_win->name = (char*) GetWMPropertyString(tmp_win->w, XA_WM_NAME);
271
280
#else /* NO_LOCALE */
272
281
XFetchName(dpy, tmp_win->w, &tmp_win->name);
273
282
#endif /* NO_LOCALE */
587
607
if (LookInList (Scr->WindowGeometries, tmp_win->full_name, &tmp_win->class)) {
590
610
geom = LookInList (Scr->WindowGeometries, tmp_win->full_name, &tmp_win->class);
591
mask= XParseGeometry (geom, &tmp_win->attr.x, &tmp_win->attr.y,
592
(unsigned int*) &tmp_win->attr.width,
593
(unsigned int*) &tmp_win->attr.height);
611
mask_ = XParseGeometry (geom, &tmp_win->attr.x, &tmp_win->attr.y,
612
(unsigned int*) &tmp_win->attr.width,
613
(unsigned int*) &tmp_win->attr.height);
595
if (mask & XNegative) tmp_win->attr.x += Scr->MyDisplayWidth - tmp_win->attr.width;
596
if (mask & YNegative) tmp_win->attr.y += Scr->MyDisplayHeight - tmp_win->attr.height;
615
if (mask_ & XNegative) tmp_win->attr.x += Scr->rootw - tmp_win->attr.width;
616
if (mask_ & YNegative) tmp_win->attr.y += Scr->rooth - tmp_win->attr.height;
597
617
ask_user = False;
620
if (XFindContext (dpy, w, VirtScreenContext, (XPointer *)&vs) == XCSUCCESS)
624
vroot = tmp_win->vs->window;
627
if (winbox) vroot = winbox->window;
600
630
* do any prompting for position
608
638
if ((Scr->RandomPlacement == RP_ALL) ||
609
639
((Scr->RandomPlacement == RP_UNMAPPED) &&
610
640
((tmp_win->wmhints && (tmp_win->wmhints->initial_state == IconicState)) ||
611
(! OCCUPY (tmp_win, Scr->workSpaceMgr.activeWSPC))))) { /* just stick it somewhere */
612
if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth)
614
if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight)
641
(! visible (tmp_win))))) { /* just stick it somewhere */
645
"DEBUG[RandomPlacement]: win: %dx%d+%d+%d, screen: %dx%d, title height: %d, random: +%d+%d\n",
646
tmp_win->attr.width, tmp_win->attr.height,
647
tmp_win->attr.x, tmp_win->attr.y,
648
Scr->rootw, Scr->rooth,
649
tmp_win->title_height,
653
/* If the right edge of the window would fall outside of the
654
screen, start over by placing the left edge of the window
655
50 pixels inside the left edge of the screen.*/
656
if ((PlaceX + tmp_win->attr.width) > Scr->rootw)
659
/* If the bottom edge of the window would fall outside of the
660
screen, start over by placing the top edge of the window
661
50 pixels inside the top edge of the screen. Because we
662
add the title height further down, we need to count with
664
if ((PlaceY + tmp_win->attr.height
665
+ tmp_win->title_height) > Scr->rooth)
668
/* Assign the current random placement to the new window, as
669
a preliminary measure. Add the title height so things will
617
671
tmp_win->attr.x = PlaceX;
618
tmp_win->attr.y = PlaceY;
672
tmp_win->attr.y = PlaceY + tmp_win->title_height;
674
/* If the window is not supposed to move off the screen, check
675
that it's still within the screen, and if not, attempt to
676
correct the situation. */
677
if (Scr->DontMoveOff) {
682
"DEBUG[DontMoveOff]: win: %dx%d+%d+%d, screen: %dx%d, bw2: %d, bw3D: %d\n",
683
tmp_win->attr.width, tmp_win->attr.height,
684
tmp_win->attr.x, tmp_win->attr.y,
685
Scr->rootw, Scr->rooth,
686
bw2, tmp_win->frame_bw3D);
689
/* If the right edge of the window is outside the right edge
690
of the screen, we need to move the window left. Note that
691
this can only happen with windows that are less than 50
692
pixels less wide than the screen. */
693
if ((tmp_win->attr.x + tmp_win->attr.width) > Scr->rootw) {
694
available = Scr->rootw - tmp_win->attr.width
695
- 2 * (bw2 + tmp_win->frame_bw3D);
698
fprintf(stderr, "DEBUG[DontMoveOff]: availableX: %d\n",
702
/* If the window is wider than the screen or exactly the width
703
of the screen, the availability is exactly 0. The result
704
will be to have the window placed as much to the left as
706
if (available <= 0) available = 0;
708
/* Place the window exactly between the left and right edge of
709
the screen when possible. If available was originally less
710
than zero, it means the window's left edge will be against
711
the screen's left edge, and the window's right edge will be
712
outside the screen. */
713
tmp_win->attr.x = available / 2;
716
/* If the bottom edge of the window is outside the bottom edge
717
of the screen, we need to move the window up. Note that
718
this can only happen with windows that are less than 50
719
pixels less tall than the screen. Don't forget to count
720
with the title height and the frame widths. */
721
if ((tmp_win->attr.y + tmp_win->attr.height) > Scr->rooth) {
722
available = Scr->rooth - tmp_win->attr.height
723
- tmp_win->title_height - 2 * (bw2 + tmp_win->frame_bw3D);
726
fprintf(stderr, "DEBUG[DontMoveOff]: availableY: %d\n",
730
/* If the window is taller than the screen or exactly the
731
height of the screen, the availability is exactly 0.
732
The result will be to have the window placed as much to
733
the top as possible. */
734
if (available <= 0) available = 0;
736
/* Place the window exactly between the top and bottom edge of
737
the screen when possible. If available was originally less
738
than zero, it means the window's top edge will be against
739
the screen's top edge, and the window's bottom edge will be
740
outside the screen. Again, don't forget to add the title
742
tmp_win->attr.y = available / 2 + tmp_win->title_height;
747
"DEBUG[DontMoveOff]: win: %dx%d+%d+%d, screen: %dx%d\n",
748
tmp_win->attr.width, tmp_win->attr.height,
749
tmp_win->attr.x, tmp_win->attr.y,
750
Scr->rootw, Scr->rooth);
754
/* We know that if the window's left edge has moved compared to
755
PlaceX, it will have moved to the left. If it was moved less
756
than 15 pixel either way, change the next "random position"
757
30 pixels down and right. */
758
if (PlaceX - tmp_win->attr.x < 15
759
|| PlaceY - tmp_win->attr.y < 15) {
622
764
random_placed = True;
623
765
} else { /* else prompt */
713
855
SIZE_VINDENT + Scr->SizeFont.font->ascent,
714
856
tmp_win->name, namelen);
718
XTranslateCoordinates (dpy, Scr->Root, winbox->window,
719
AddingX, AddingY, &AddingX, &AddingY, &JunkChild);
720
ConstrainedToWinBox (tmp_win, AddingX, AddingY, &AddingX, &AddingY);
859
if (winbox) ConstrainedToWinBox (tmp_win, AddingX, AddingY, &AddingX, &AddingY);
723
861
AddingW = tmp_win->attr.width + bw2 + 2 * tmp_win->frame_bw3D;
724
862
AddingH = tmp_win->attr.height + tmp_win->title_height +
725
863
bw2 + 2 * tmp_win->frame_bw3D;
726
MoveOutline(winbox ? winbox->window : Scr->Root,
727
AddingX, AddingY, AddingW, AddingH,
728
tmp_win->frame_bw, tmp_win->title_height + tmp_win->frame_bw3D);
864
MoveOutline(vroot,AddingX, AddingY, AddingW, AddingH,
865
tmp_win->frame_bw, tmp_win->title_height + tmp_win->frame_bw3D);
731
868
XmbDrawImageString (dpy, Scr->SizeWindow, Scr->SizeFont.font_set,
797
XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
928
XQueryPointer(dpy, vroot, &JunkRoot, &JunkChild,
798
929
&JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
801
XTranslateCoordinates (dpy, Scr->Root, winbox->window,
802
AddingX, AddingY, &AddingX, &AddingY, &JunkChild);
804
931
TryToGrid (tmp_win, &AddingX, &AddingY);
805
932
if (Scr->PackNewWindows) TryToPack (tmp_win, &AddingX, &AddingY);
806
933
if (Scr->DontMoveOff)
808
935
ConstrainByBorders (tmp_win, &AddingX, AddingW, &AddingY, AddingH);
810
MoveOutline(winbox ? winbox->window : Scr->Root,
811
AddingX, AddingY, AddingW, AddingH,
937
MoveOutline(vroot, AddingX, AddingY, AddingW, AddingH,
812
938
tmp_win->frame_bw, tmp_win->title_height + tmp_win->frame_bw3D);
814
940
DisplayPosition (tmp_win, AddingX, AddingY);
852
978
#undef HALF_AVE_CURSOR_SIZE
853
979
dx += (tmp_win->frame_bw + 1);
854
980
dy += (bw2 + tmp_win->title_height + 1);
855
if (AddingX + dx >= Scr->MyDisplayWidth - Scr->BorderRight)
856
dx = Scr->MyDisplayWidth - Scr->BorderRight - AddingX - 1;
857
if (AddingY + dy >= Scr->MyDisplayHeight - Scr->BorderBottom)
858
dy = Scr->MyDisplayHeight - Scr->BorderBottom - AddingY - 1;
981
if (AddingX + dx >= Scr->rootw - Scr->BorderRight)
982
dx = Scr->rootw - Scr->BorderRight - AddingX - 1;
983
if (AddingY + dy >= Scr->rooth - Scr->BorderBottom)
984
dy = Scr->rooth - Scr->BorderBottom - AddingY - 1;
859
985
if (dx > 0 && dy > 0)
860
986
XWarpPointer (dpy, None, None, 0, 0, 0, 0, dx, dy);
862
XWarpPointer (dpy, None, Scr->Root, 0, 0, 0, 0,
988
XWarpPointer (dpy, None, vroot, 0, 0, 0, 0,
863
989
AddingX + AddingW/2, AddingY + AddingH/2);
865
991
AddStartResize(tmp_win, AddingX, AddingY, AddingW, AddingH);
896
1021
* using multiple GXxor lines so that we don't need to
897
1022
* grab the server.
899
XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
900
&JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
902
XTranslateCoordinates (dpy, Scr->Root, winbox->window,
903
AddingX, AddingY, &AddingX, &AddingY, &JunkChild);
1024
XQueryPointer(dpy, vroot, &JunkRoot, &JunkChild,
1025
&JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
906
1027
if (lastx != AddingX || lasty != AddingY)
979
1095
tmp_win->title_width = tmp_win->attr.width;
1098
tmp_win->icon_name = (char*) GetWMPropertyString(tmp_win->w, XA_WM_ICON_NAME);
1099
#else /* NO_LOCALE */
1100
if (XGetWindowProperty (dpy, tmp_win->w, XA_WM_ICON_NAME, 0L, 200L, False,
1101
XA_STRING, &actual_type, &actual_format, &nitems,
1102
&bytesafter,(unsigned char **)&tmp_win->icon_name))
1103
tmp_win->icon_name = tmp_win->name;
1104
#endif /* NO_LOCALE */
1106
if (tmp_win->icon_name == NULL) tmp_win->icon_name = tmp_win->name;
1108
if (strstr (tmp_win->icon_name, " - Mozilla")) {
1109
char *moz = strstr (tmp_win->icon_name, " - Mozilla");
982
XmbTextExtents(Scr->TitleBarFont.font_set, tmp_win->name, namelen,
983
&ink_rect, &logical_rect);
1115
XmbTextExtents (Scr->TitleBarFont.font_set, tmp_win->name, namelen, &ink_rect, &logical_rect);
985
1116
tmp_win->name_width = logical_rect.width;
987
tmp_win->name_width = XTextWidth(Scr->TitleBarFont.font, tmp_win->name,
1118
tmp_win->name_width = XTextWidth (Scr->TitleBarFont.font, tmp_win->name, namelen);
992
tmp_win->icon_name = GetWMPropertyString(tmp_win->w, XA_WM_ICON_NAME);
993
#else /* NO_LOCALE */
994
if (XGetWindowProperty (dpy, tmp_win->w, XA_WM_ICON_NAME, 0L, 200L, False,
995
XA_STRING, &actual_type, &actual_format, &nitems,
996
&bytesafter,(unsigned char **)&tmp_win->icon_name))
997
tmp_win->icon_name = tmp_win->name;
998
#endif /* NO_LOCALE */
1000
if (tmp_win->icon_name == NULL)
1001
tmp_win->icon_name = tmp_win->name;
1003
else if ((strlen (tmp_win->icon_name) > 11) &&
1004
(strncmp (tmp_win->icon_name, "Netscape: ", 10) == 0)) {
1007
tmp = strdup (tmp_win->icon_name + 10);
1008
XFree ((char*) tmp_win->icon_name);
1009
tmp_win->icon_name = tmp;
1013
1121
if (tmp_win->old_bw) XSetWindowBorderWidth (dpy, tmp_win->w, 0);
1015
1123
tmp_win->squeezed = FALSE;
1144
1258
if (tmp_win->highlight)
1146
1260
if (Scr->use3Dtitles && (Scr->Monochrome != COLOR))
1147
tmp_win->gray = XCreatePixmapFromBitmapData(dpy, Scr->Root,
1261
tmp_win->gray = XCreatePixmapFromBitmapData(dpy, vroot,
1148
1262
(char*)black_bits, gray_width, gray_height,
1149
1263
tmp_win->border_tile.fore, tmp_win->border_tile.back,
1152
tmp_win->gray = XCreatePixmapFromBitmapData(dpy, Scr->Root,
1266
tmp_win->gray = XCreatePixmapFromBitmapData(dpy, vroot,
1153
1267
(char*)gray_bits, gray_width, gray_height,
1154
1268
tmp_win->border_tile.fore, tmp_win->border_tile.back,