1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Workspace.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
25 # include "../config.h"
26 #endif // HAVE_CONFIG_H
30 #include <X11/Xatom.h>
34 #endif // HAVE_STDIO_H
38 #endif // HAVE_STRING_H
49 #include "blackbox.hh"
50 #include "Clientmenu.hh"
57 #include "Workspace.hh"
58 #include "Windowmenu.hh"
62 Workspace::Workspace(BScreen
*scrn
, unsigned int i
) {
64 xatom
= screen
->getBlackbox()->getXAtom();
66 cascade_x
= cascade_y
= 0;
73 clientmenu
= new Clientmenu(this);
75 lastfocus
= (BlackboxWindow
*) 0;
81 void Workspace::addWindow(BlackboxWindow
*w
, bool place
, bool sticky
) {
84 if (place
) placeWindow(w
);
86 stackingList
.push_front(w
);
88 // if the window is sticky, then it needs to be added on all other
90 if (! sticky
&& w
->isStuck()) {
91 for (unsigned int i
= 0; i
< screen
->getWorkspaceCount(); ++i
)
93 screen
->getWorkspace(i
)->addWindow(w
, place
, True
);
99 w
->setWindowNumber(windowList
.size());
102 windowList
.push_back(w
);
104 clientmenu
->insert(w
->getTitle());
105 clientmenu
->update();
108 screen
->updateNetizenWindowAdd(w
->getClientWindow(), id
);
110 if (screen
->doFocusNew() || (w
->isTransient() && w
->getTransientFor() &&
111 w
->getTransientFor()->isFocused())) {
112 if (id
== screen
->getCurrentWorkspaceID())
116 not on the focused workspace, so the window is not going to get focus
117 but if the user wants new windows focused, then it should get focus
118 when this workspace does become focused.
125 if (! w
->isDesktop())
132 void Workspace::removeWindow(BlackboxWindow
*w
, bool sticky
) {
135 stackingList
.remove(w
);
137 // pass focus to the next appropriate window
138 if ((w
->isFocused() || w
== lastfocus
) &&
139 ! screen
->getBlackbox()->doShutdown()) {
143 // if the window is sticky, then it needs to be removed on all other
145 if (! sticky
&& w
->isStuck()) {
146 for (unsigned int i
= 0; i
< screen
->getWorkspaceCount(); ++i
)
148 screen
->getWorkspace(i
)->removeWindow(w
, True
);
151 if (! w
->isNormal()) return;
153 BlackboxWindowList::iterator it
, end
= windowList
.end();
155 for (i
= 0, it
= windowList
.begin(); it
!= end
; ++it
, ++i
)
160 windowList
.erase(it
);
161 clientmenu
->remove(i
);
162 clientmenu
->update();
165 screen
->updateNetizenWindowDel(w
->getClientWindow());
167 BlackboxWindowList::iterator it
= windowList
.begin();
168 const BlackboxWindowList::iterator end
= windowList
.end();
170 for (; it
!= end
; ++it
, ++i
)
171 (*it
)->setWindowNumber(i
);
175 cascade_x
= cascade_y
= 0;
183 void Workspace::focusFallback(const BlackboxWindow
*old_window
) {
184 BlackboxWindow
*newfocus
= 0;
186 if (id
== screen
->getCurrentWorkspaceID()) {
187 // The window is on the visible workspace.
189 // if it's a transient, then try to focus its parent
190 if (old_window
&& old_window
->isTransient()) {
191 newfocus
= old_window
->getTransientFor();
194 newfocus
->isIconic() || // do not focus icons
195 newfocus
->getWorkspaceNumber() != id
|| // or other workspaces
196 ! newfocus
->setInputFocus())
201 BlackboxWindowList::iterator it
= stackingList
.begin(),
202 end
= stackingList
.end();
203 for (; it
!= end
; ++it
) {
204 BlackboxWindow
*tmp
= *it
;
205 if (tmp
&& tmp
->isNormal() && tmp
->setInputFocus()) {
206 // we found our new focus target
213 screen
->getBlackbox()->setFocusedWindow(newfocus
);
215 // The window is not on the visible workspace.
217 if (old_window
&& lastfocus
== old_window
) {
218 // The window was the last-focus target, so we need to replace it.
219 BlackboxWindow
*win
= (BlackboxWindow
*) 0;
220 if (! stackingList
.empty())
221 win
= stackingList
.front();
222 setLastFocusedWindow(win
);
228 void Workspace::setFocused(const BlackboxWindow
*w
, bool focused
) {
229 BlackboxWindowList::iterator it
, end
= windowList
.end();
231 for (i
= 0, it
= windowList
.begin(); it
!= end
; ++it
, ++i
)
236 clientmenu
->setItemSelected(i
, focused
);
240 void Workspace::showAll(void) {
241 BlackboxWindowList::iterator it
= stackingList
.begin();
242 const BlackboxWindowList::iterator end
= stackingList
.end();
243 for (; it
!= end
; ++it
) {
244 BlackboxWindow
*bw
= *it
;
250 void Workspace::hideAll(void) {
251 // withdraw in reverse order to minimize the number of Expose events
252 BlackboxWindowList::reverse_iterator it
= stackingList
.rbegin();
253 const BlackboxWindowList::reverse_iterator end
= stackingList
.rend();
255 BlackboxWindow
*bw
= *it
;
256 ++it
; // withdraw removes the current item from the list so we need the next
257 // iterator before that happens
263 void Workspace::removeAll(void) {
264 while (! windowList
.empty())
265 windowList
.front()->iconify();
270 * returns the number of transients for win, plus the number of transients
271 * associated with each transient of win
273 static int countTransients(const BlackboxWindow
* const win
) {
274 int ret
= win
->getTransients().size();
276 BlackboxWindowList::const_iterator it
, end
= win
->getTransients().end();
277 for (it
= win
->getTransients().begin(); it
!= end
; ++it
) {
278 ret
+= countTransients(*it
);
286 * puts the transients of win into the stack. windows are stacked above
287 * the window before it in the stackvector being iterated, meaning
288 * stack[0] is on bottom, stack[1] is above stack[0], stack[2] is above
291 void Workspace::raiseTransients(const BlackboxWindow
* const win
,
292 StackVector::iterator
&stack
) {
293 if (win
->getTransients().size() == 0) return; // nothing to do
295 // put win's transients in the stack
296 BlackboxWindowList::const_iterator it
, end
= win
->getTransients().end();
297 for (it
= win
->getTransients().begin(); it
!= end
; ++it
) {
298 *stack
++ = (*it
)->getFrameWindow();
299 screen
->updateNetizenWindowRaise((*it
)->getClientWindow());
301 if (! (*it
)->isIconic()) {
302 Workspace
*wkspc
= screen
->getWorkspace((*it
)->getWorkspaceNumber());
303 wkspc
->stackingList
.remove((*it
));
304 wkspc
->stackingList
.push_front((*it
));
308 // put transients of win's transients in the stack
309 for (it
= win
->getTransients().begin(); it
!= end
; ++it
) {
310 raiseTransients(*it
, stack
);
315 void Workspace::lowerTransients(const BlackboxWindow
* const win
,
316 StackVector::iterator
&stack
) {
317 if (win
->getTransients().size() == 0) return; // nothing to do
319 // put transients of win's transients in the stack
320 BlackboxWindowList::const_reverse_iterator it
,
321 end
= win
->getTransients().rend();
322 for (it
= win
->getTransients().rbegin(); it
!= end
; ++it
) {
323 lowerTransients(*it
, stack
);
326 // put win's transients in the stack
327 for (it
= win
->getTransients().rbegin(); it
!= end
; ++it
) {
328 *stack
++ = (*it
)->getFrameWindow();
329 screen
->updateNetizenWindowLower((*it
)->getClientWindow());
331 if (! (*it
)->isIconic()) {
332 Workspace
*wkspc
= screen
->getWorkspace((*it
)->getWorkspaceNumber());
333 wkspc
->stackingList
.remove((*it
));
334 wkspc
->stackingList
.push_back((*it
));
340 void Workspace::raiseWindow(BlackboxWindow
*w
) {
341 BlackboxWindow
*win
= w
;
343 if (win
->isDesktop()) return;
345 // walk up the transient_for's to the window that is not a transient
346 while (win
->isTransient() && ! win
->isDesktop()) {
347 if (! win
->getTransientFor()) break;
348 win
= win
->getTransientFor();
351 // get the total window count (win and all transients)
352 unsigned int i
= 1 + countTransients(win
);
354 // stack the window with all transients above
355 StackVector
stack_vector(i
);
356 StackVector::iterator stack
= stack_vector
.begin();
358 *(stack
++) = win
->getFrameWindow();
359 screen
->updateNetizenWindowRaise(win
->getClientWindow());
360 if (! (win
->isIconic() || win
->isDesktop())) {
361 Workspace
*wkspc
= screen
->getWorkspace(win
->getWorkspaceNumber());
362 wkspc
->stackingList
.remove(win
);
363 wkspc
->stackingList
.push_front(win
);
366 raiseTransients(win
, stack
);
368 screen
->raiseWindows(&stack_vector
[0], stack_vector
.size());
372 void Workspace::lowerWindow(BlackboxWindow
*w
) {
373 BlackboxWindow
*win
= w
;
375 // walk up the transient_for's to the window that is not a transient
376 while (win
->isTransient() && ! win
->isDesktop()) {
377 if (! win
->getTransientFor()) break;
378 win
= win
->getTransientFor();
381 // get the total window count (win and all transients)
382 unsigned int i
= 1 + countTransients(win
);
384 // stack the window with all transients above
385 StackVector
stack_vector(i
);
386 StackVector::iterator stack
= stack_vector
.begin();
388 lowerTransients(win
, stack
);
390 *(stack
++) = win
->getFrameWindow();
391 screen
->updateNetizenWindowLower(win
->getClientWindow());
392 if (! (win
->isIconic() || win
->isDesktop())) {
393 Workspace
*wkspc
= screen
->getWorkspace(win
->getWorkspaceNumber());
394 wkspc
->stackingList
.remove(win
);
395 wkspc
->stackingList
.push_back(win
);
398 screen
->lowerWindows(&stack_vector
[0], stack_vector
.size());
402 void Workspace::reconfigure(void) {
403 clientmenu
->reconfigure();
404 std::for_each(windowList
.begin(), windowList
.end(),
405 std::mem_fun(&BlackboxWindow::reconfigure
));
409 BlackboxWindow
*Workspace::getWindow(unsigned int index
) {
410 if (index
< windowList
.size()) {
411 BlackboxWindowList::iterator it
= windowList
.begin();
412 for(; index
> 0; --index
, ++it
); /* increment to index */
420 Workspace::getNextWindowInList(BlackboxWindow
*w
) {
421 BlackboxWindowList::iterator it
= std::find(windowList
.begin(),
424 assert(it
!= windowList
.end()); // window must be in list
426 if (it
== windowList
.end())
427 return windowList
.front(); // if we walked off the end, wrap around
433 BlackboxWindow
* Workspace::getPrevWindowInList(BlackboxWindow
*w
) {
434 BlackboxWindowList::iterator it
= std::find(windowList
.begin(),
437 assert(it
!= windowList
.end()); // window must be in list
438 if (it
== windowList
.begin())
439 return windowList
.back(); // if we walked of the front, wrap around
445 BlackboxWindow
* Workspace::getTopWindowOnStack(void) const {
446 return stackingList
.front();
450 void Workspace::sendWindowList(Netizen
&n
) {
451 BlackboxWindowList::iterator it
= windowList
.begin(),
452 end
= windowList
.end();
453 for(; it
!= end
; ++it
)
454 n
.sendWindowAdd((*it
)->getClientWindow(), getID());
458 unsigned int Workspace::getCount(void) const {
459 return windowList
.size();
463 void Workspace::appendStackOrder(BlackboxWindowList
&stack_order
) const {
464 BlackboxWindowList::const_reverse_iterator it
= stackingList
.rbegin();
465 const BlackboxWindowList::const_reverse_iterator end
= stackingList
.rend();
466 for (; it
!= end
; ++it
)
467 if ((*it
)->isNormal())
468 stack_order
.push_back(*it
);
472 bool Workspace::isCurrent(void) const {
473 return (id
== screen
->getCurrentWorkspaceID());
477 bool Workspace::isLastWindow(const BlackboxWindow
* const w
) const {
478 return (w
== windowList
.back());
482 void Workspace::setCurrent(void) {
483 screen
->changeWorkspaceID(id
);
487 void Workspace::readName(void) {
488 XAtom::StringVect namesList
;
489 unsigned long numnames
= id
+ 1;
491 // attempt to get from the _NET_WM_DESKTOP_NAMES property
492 if (xatom
->getValue(screen
->getRootWindow(), XAtom::net_desktop_names
,
493 XAtom::utf8
, numnames
, namesList
) &&
494 namesList
.size() > id
) {
495 name
= namesList
[id
];
497 clientmenu
->setLabel(name
);
498 clientmenu
->update();
501 Use a default name. This doesn't actually change the class. That will
502 happen after the setName changes the root property, and that change
503 makes its way back to this function.
505 string tmp
=i18n(WorkspaceSet
, WorkspaceDefaultNameFormat
,
507 assert(tmp
.length() < 32);
508 char default_name
[32];
509 sprintf(default_name
, tmp
.c_str(), id
+ 1);
511 setName(default_name
); // save this into the _NET_WM_DESKTOP_NAMES property
516 void Workspace::setName(const string
& new_name
) {
517 // set the _NET_WM_DESKTOP_NAMES property with the new name
518 XAtom::StringVect namesList
;
519 unsigned long numnames
= (unsigned) -1;
520 if (xatom
->getValue(screen
->getRootWindow(), XAtom::net_desktop_names
,
521 XAtom::utf8
, numnames
, namesList
) &&
522 namesList
.size() > id
)
523 namesList
[id
] = new_name
;
525 namesList
.push_back(new_name
);
527 xatom
->setValue(screen
->getRootWindow(), XAtom::net_desktop_names
,
528 XAtom::utf8
, namesList
);
533 * Calculate free space available for window placement.
535 typedef std::vector
<Rect
> rectList
;
537 static rectList
calcSpace(const Rect
&win
, const rectList
&spaces
) {
540 rectList::const_iterator siter
, end
= spaces
.end();
541 for (siter
= spaces
.begin(); siter
!= end
; ++siter
) {
542 const Rect
&curr
= *siter
;
544 if(! win
.intersects(curr
)) {
545 result
.push_back(curr
);
549 /* Use an intersection of win and curr to determine the space around
550 * curr that we can use.
552 * NOTE: the spaces calculated can overlap.
557 extra
.setCoords(curr
.left(), curr
.top(),
558 isect
.left() - 1, curr
.bottom());
559 if (extra
.valid()) result
.push_back(extra
);
562 extra
.setCoords(curr
.left(), curr
.top(),
563 curr
.right(), isect
.top() - 1);
564 if (extra
.valid()) result
.push_back(extra
);
567 extra
.setCoords(isect
.right() + 1, curr
.top(),
568 curr
.right(), curr
.bottom());
569 if (extra
.valid()) result
.push_back(extra
);
572 extra
.setCoords(curr
.left(), isect
.bottom() + 1,
573 curr
.right(), curr
.bottom());
574 if (extra
.valid()) result
.push_back(extra
);
580 static bool rowRLBT(const Rect
&first
, const Rect
&second
) {
581 if (first
.bottom() == second
.bottom())
582 return first
.right() > second
.right();
583 return first
.bottom() > second
.bottom();
586 static bool rowRLTB(const Rect
&first
, const Rect
&second
) {
587 if (first
.y() == second
.y())
588 return first
.right() > second
.right();
589 return first
.y() < second
.y();
592 static bool rowLRBT(const Rect
&first
, const Rect
&second
) {
593 if (first
.bottom() == second
.bottom())
594 return first
.x() < second
.x();
595 return first
.bottom() > second
.bottom();
598 static bool rowLRTB(const Rect
&first
, const Rect
&second
) {
599 if (first
.y() == second
.y())
600 return first
.x() < second
.x();
601 return first
.y() < second
.y();
604 static bool colLRTB(const Rect
&first
, const Rect
&second
) {
605 if (first
.x() == second
.x())
606 return first
.y() < second
.y();
607 return first
.x() < second
.x();
610 static bool colLRBT(const Rect
&first
, const Rect
&second
) {
611 if (first
.x() == second
.x())
612 return first
.bottom() > second
.bottom();
613 return first
.x() < second
.x();
616 static bool colRLTB(const Rect
&first
, const Rect
&second
) {
617 if (first
.right() == second
.right())
618 return first
.y() < second
.y();
619 return first
.right() > second
.right();
622 static bool colRLBT(const Rect
&first
, const Rect
&second
) {
623 if (first
.right() == second
.right())
624 return first
.bottom() > second
.bottom();
625 return first
.right() > second
.right();
629 bool Workspace::smartPlacement(Rect
& win
) {
632 //initially the entire screen is free
634 if (screen
->isXineramaActive() &&
635 screen
->getBlackbox()->doXineramaPlacement()) {
636 RectList availableAreas
= screen
->allAvailableAreas();
637 RectList::iterator it
, end
= availableAreas
.end();
639 for (it
= availableAreas
.begin(); it
!= end
; ++it
)
640 spaces
.push_back(*it
);
643 spaces
.push_back(screen
->availableArea());
646 BlackboxWindowList::const_iterator wit
= windowList
.begin(),
647 end
= windowList
.end();
649 for (; wit
!= end
; ++wit
) {
650 const BlackboxWindow
* const curr
= *wit
;
652 // watch for shaded windows and full-maxed windows
653 if (curr
->isShaded()) {
654 if (screen
->getPlaceIgnoreShaded()) continue;
655 } else if (curr
->isMaximizedFull()) {
656 if (screen
->getPlaceIgnoreMaximized()) continue;
659 tmp
.setRect(curr
->frameRect().x(), curr
->frameRect().y(),
660 curr
->frameRect().width() + screen
->getBorderWidth(),
661 curr
->frameRect().height() + screen
->getBorderWidth());
663 spaces
= calcSpace(tmp
, spaces
);
666 if (screen
->getPlacementPolicy() == BScreen::RowSmartPlacement
) {
667 if(screen
->getRowPlacementDirection() == BScreen::LeftRight
) {
668 if(screen
->getColPlacementDirection() == BScreen::TopBottom
)
669 std::sort(spaces
.begin(), spaces
.end(), rowLRTB
);
671 std::sort(spaces
.begin(), spaces
.end(), rowLRBT
);
673 if(screen
->getColPlacementDirection() == BScreen::TopBottom
)
674 std::sort(spaces
.begin(), spaces
.end(), rowRLTB
);
676 std::sort(spaces
.begin(), spaces
.end(), rowRLBT
);
679 if(screen
->getColPlacementDirection() == BScreen::TopBottom
) {
680 if(screen
->getRowPlacementDirection() == BScreen::LeftRight
)
681 std::sort(spaces
.begin(), spaces
.end(), colLRTB
);
683 std::sort(spaces
.begin(), spaces
.end(), colRLTB
);
685 if(screen
->getRowPlacementDirection() == BScreen::LeftRight
)
686 std::sort(spaces
.begin(), spaces
.end(), colLRBT
);
688 std::sort(spaces
.begin(), spaces
.end(), colRLBT
);
692 rectList::const_iterator sit
= spaces
.begin(), spaces_end
= spaces
.end();
693 for(; sit
!= spaces_end
; ++sit
) {
694 if (sit
->width() >= win
.width() && sit
->height() >= win
.height())
698 if (sit
== spaces_end
)
701 //set new position based on the empty space found
702 const Rect
& where
= *sit
;
706 // adjust the location() based on left/right and top/bottom placement
707 if (screen
->getPlacementPolicy() == BScreen::RowSmartPlacement
) {
708 if (screen
->getRowPlacementDirection() == BScreen::RightLeft
)
709 win
.setX(where
.right() - win
.width());
710 if (screen
->getColPlacementDirection() == BScreen::BottomTop
)
711 win
.setY(where
.bottom() - win
.height());
713 if (screen
->getColPlacementDirection() == BScreen::BottomTop
)
714 win
.setY(win
.y() + where
.height() - win
.height());
715 if (screen
->getRowPlacementDirection() == BScreen::RightLeft
)
716 win
.setX(win
.x() + where
.width() - win
.width());
722 bool Workspace::underMousePlacement(Rect
&win
) {
726 XQueryPointer(screen
->getBlackbox()->getXDisplay(), screen
->getRootWindow(),
727 &r
, &c
, &rx
, &ry
, &x
, &y
, &m
);
731 if (screen
->isXineramaActive() &&
732 screen
->getBlackbox()->doXineramaPlacement()) {
733 RectList availableAreas
= screen
->allAvailableAreas();
734 RectList::iterator it
, end
= availableAreas
.end();
736 for (it
= availableAreas
.begin(); it
!= end
; ++it
)
737 if (it
->contains(rx
, ry
)) break;
738 assert(it
!= end
); // the mouse isn't inside an area?
742 area
= screen
->availableArea();
744 x
= rx
- win
.width() / 2;
745 y
= ry
- win
.height() / 2;
751 if (x
+ win
.width() > area
.x() + area
.width())
752 x
= area
.x() + area
.width() - win
.width();
753 if (y
+ win
.height() > area
.y() + area
.height())
754 y
= area
.y() + area
.height() - win
.height();
763 bool Workspace::cascadePlacement(Rect
&win
, const int offset
) {
767 if (screen
->isXineramaActive() &&
768 screen
->getBlackbox()->doXineramaPlacement()) {
769 area
= screen
->allAvailableAreas()[cascade_region
];
772 area
= screen
->availableArea();
774 if ((static_cast<signed>(cascade_x
+ win
.width()) > area
.right() + 1) ||
775 (static_cast<signed>(cascade_y
+ win
.height()) > area
.bottom() + 1)) {
776 cascade_x
= cascade_y
= 0;
778 if (screen
->isXineramaActive() &&
779 screen
->getBlackbox()->doXineramaPlacement()) {
780 // go to the next xinerama region, and use its area
781 if (++cascade_region
>= screen
->allAvailableAreas().size())
783 area
= screen
->allAvailableAreas()[cascade_region
];
788 if (cascade_x
== 0) {
789 cascade_x
= area
.x() + offset
;
790 cascade_y
= area
.y() + offset
;
793 win
.setPos(cascade_x
, cascade_y
);
802 void Workspace::placeWindow(BlackboxWindow
*win
) {
803 Rect
new_win(0, 0, win
->frameRect().width(), win
->frameRect().height());
806 switch (screen
->getPlacementPolicy()) {
807 case BScreen::RowSmartPlacement
:
808 case BScreen::ColSmartPlacement
:
809 placed
= smartPlacement(new_win
);
811 case BScreen::UnderMousePlacement
:
812 case BScreen::ClickMousePlacement
:
813 placed
= underMousePlacement(new_win
);
815 break; // handled below
819 cascadePlacement(new_win
, (win
->getTitleHeight() +
820 screen
->getBorderWidth() * 2));
822 if (new_win
.right() > screen
->availableArea().right())
823 new_win
.setX(screen
->availableArea().left());
824 if (new_win
.bottom() > screen
->availableArea().bottom())
825 new_win
.setY(screen
->availableArea().top());
827 win
->configure(new_win
.x(), new_win
.y(), new_win
.width(), new_win
.height());