aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-02-04 06:53:14 (GMT)
committerfluxgen <fluxgen>2002-02-04 06:53:14 (GMT)
commit7b175210c8389d1a0715dfe6f04c2049f9c6a7b8 (patch)
tree0334f64654adf73110409f08a67869749f483475 /src
parentae9d3d84c99ab00b3054dab5b035065acac567b4 (diff)
downloadfluxbox_pavel-7b175210c8389d1a0715dfe6f04c2049f9c6a7b8.zip
fluxbox_pavel-7b175210c8389d1a0715dfe6f04c2049f9c6a7b8.tar.bz2
_WIN_WORKSPACE atom and some indent
Diffstat (limited to 'src')
-rw-r--r--src/Window.cc163
1 files changed, 85 insertions, 78 deletions
diff --git a/src/Window.cc b/src/Window.cc
index c2f66e1..67d772c 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.23 2002/01/27 13:13:33 fluxgen Exp $ 25// $Id: Window.cc,v 1.24 2002/02/04 06:53:14 fluxgen Exp $
26 26
27// stupid macros needed to access some functions in version 2 of the GNU C 27// stupid macros needed to access some functions in version 2 of the GNU C
28// library 28// library
@@ -77,18 +77,18 @@ windowmenu(0),
77tab(0) 77tab(0)
78{ 78{
79 79
80#ifdef DEBUG 80 #ifdef DEBUG
81 fprintf(stderr, 81 fprintf(stderr,
82 I18n::instance()-> 82 I18n::instance()->
83 getMessage( 83 getMessage(
84# ifdef NLS 84 #ifdef NLS
85 WindowSet, WindowCreating, 85 WindowSet, WindowCreating,
86# else // !NLS 86 #else // !NLS
87 0, 0, 87 0, 0,
88# endif // NLS 88 #endif // NLS
89 "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"), 89 "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"),
90 w); 90 w);
91#endif // DEBUG 91 #endif // DEBUG
92 92
93 Fluxbox *fluxbox = Fluxbox::instance(); 93 Fluxbox *fluxbox = Fluxbox::instance();
94 display = fluxbox->getXDisplay(); 94 display = fluxbox->getXDisplay();
@@ -116,24 +116,24 @@ tab(0)
116 switch (dir[i]) { 116 switch (dir[i]) {
117 case Fluxbox::SHADE: 117 case Fluxbox::SHADE:
118 decorations.shade = true; 118 decorations.shade = true;
119 break; 119 break;
120 case Fluxbox::MAXIMIZE: 120 case Fluxbox::MAXIMIZE:
121 decorations.maximize = true; 121 decorations.maximize = true;
122 break; 122 break;
123 case Fluxbox::MINIMIZE: 123 case Fluxbox::MINIMIZE:
124 decorations.iconify = true; 124 decorations.iconify = true;
125 break; 125 break;
126 case Fluxbox::STICK: 126 case Fluxbox::STICK:
127 decorations.sticky = true; 127 decorations.sticky = true;
128 break; 128 break;
129 case Fluxbox::CLOSE: 129 case Fluxbox::CLOSE:
130 decorations.close = true; 130 decorations.close = true;
131 break; 131 break;
132 case Fluxbox::MENU: 132 case Fluxbox::MENU:
133 decorations.menu = true; 133 decorations.menu = true;
134 break; 134 break;
135 default: 135 default:
136 break; 136 break;
137 } 137 }
138 } 138 }
139 //next right 139 //next right
@@ -161,8 +161,7 @@ tab(0)
161 // fetch client size and placement 161 // fetch client size and placement
162 XWindowAttributes wattrib; 162 XWindowAttributes wattrib;
163 if ((! XGetWindowAttributes(display, client.window, &wattrib)) || 163 if ((! XGetWindowAttributes(display, client.window, &wattrib)) ||
164 (! wattrib.screen) || wattrib.override_redirect) { 164 (! wattrib.screen) || wattrib.override_redirect) {
165 //fluxbox->ungrab();
166 throw FluxboxWindow::XGETWINDOWATTRIB; 165 throw FluxboxWindow::XGETWINDOWATTRIB;
167 } 166 }
168 167
@@ -197,12 +196,12 @@ tab(0)
197 getWMHints(); 196 getWMHints();
198 getWMNormalHints(); 197 getWMNormalHints();
199 198
200#ifdef SLIT 199 #ifdef SLIT
201 if (client.initial_state == WithdrawnState) { 200 if (client.initial_state == WithdrawnState) {
202 screen->getSlit()->addClient(client.window); 201 screen->getSlit()->addClient(client.window);
203 throw NOERROR; 202 throw NOERROR;
204 } 203 }
205#endif // SLIT 204 #endif // SLIT
206 205
207 managed = true; 206 managed = true;
208 fluxbox->saveWindowSearch(client.window, this); 207 fluxbox->saveWindowSearch(client.window, this);
@@ -392,27 +391,28 @@ tab(0)
392 } 391 }
393 392
394 setFocusFlag(false); 393 setFocusFlag(false);
395 394 /*
396 #ifdef DEBUG 395 #ifdef DEBUG
397 fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); 396 fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this);
398 #endif 397 #endif
399 398 */
400 //TODO move this 399 //TODO move this
401 #ifdef GNOME 400 #ifdef GNOME
402 int val = workspace_number; 401 int val = workspace_number;
403 XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom(), XA_CARDINAL, 32, 402 XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom(),
404 PropModeReplace, (unsigned char *)&val, 1); 403 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1);
405 #endif 404 #endif
406 405
407} 406}
408 407
409 408
410FluxboxWindow::~FluxboxWindow(void) { 409FluxboxWindow::~FluxboxWindow(void) {
410 #ifdef GNOME
411 XDeleteProperty (display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom());
412 #endif
413
411 Fluxbox *fluxbox = Fluxbox::instance(); 414 Fluxbox *fluxbox = Fluxbox::instance();
412 415
413 //TODO: Move this to Workspace::removeWindow
414 if (client.transient_for)
415 fluxbox->setFocusedWindow(client.transient_for);
416 416
417 if (moving || resizing) { 417 if (moving || resizing) {
418 screen->hideGeometry(); 418 screen->hideGeometry();
@@ -448,6 +448,9 @@ FluxboxWindow::~FluxboxWindow(void) {
448 if (client.blackbox_hint) 448 if (client.blackbox_hint)
449 XFree(client.blackbox_hint); 449 XFree(client.blackbox_hint);
450 450
451 //TODO: Move this to Workspace::removeWindow
452 if (client.transient_for)
453 fluxbox->setFocusedWindow(client.transient_for);
451 454
452 if (client.window_group) 455 if (client.window_group)
453 fluxbox->removeGroupSearch(client.window_group); 456 fluxbox->removeGroupSearch(client.window_group);
@@ -576,30 +579,29 @@ Window FluxboxWindow::createToplevelWindow(int x, int y, unsigned int width,
576{ 579{
577 XSetWindowAttributes attrib_create; 580 XSetWindowAttributes attrib_create;
578 unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWColormap | 581 unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWColormap |
579 CWOverrideRedirect | CWEventMask; 582 CWOverrideRedirect | CWEventMask;
580 583
581 attrib_create.background_pixmap = None; 584 attrib_create.background_pixmap = None;
582 attrib_create.colormap = screen->getColormap(); 585 attrib_create.colormap = screen->getColormap();
583 attrib_create.override_redirect = True; 586 attrib_create.override_redirect = True;
584 attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask | 587 attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
585 ButtonMotionMask | EnterWindowMask; 588 ButtonMotionMask | EnterWindowMask;
586 589
587 return (XCreateWindow(display, screen->getRootWindow(), x, y, width, height, 590 return (XCreateWindow(display, screen->getRootWindow(), x, y, width, height,
588 borderwidth, screen->getDepth(), InputOutput, 591 borderwidth, screen->getDepth(), InputOutput,
589 screen->getVisual(), create_mask, 592 screen->getVisual(), create_mask,
590 &attrib_create)); 593 &attrib_create));
591} 594}
592 595
593 596
594Window FluxboxWindow::createChildWindow(Window parent, Cursor cursor) { 597Window FluxboxWindow::createChildWindow(Window parent, Cursor cursor) {
595 XSetWindowAttributes attrib_create; 598 XSetWindowAttributes attrib_create;
596 unsigned long create_mask = CWBackPixmap | CWBorderPixel | 599 unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWEventMask;
597 CWEventMask;
598 600
599 attrib_create.background_pixmap = None; 601 attrib_create.background_pixmap = None;
600 attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask | 602 attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
601 ButtonMotionMask | ExposureMask | 603 ButtonMotionMask | ExposureMask |
602 EnterWindowMask | LeaveWindowMask; 604 EnterWindowMask | LeaveWindowMask;
603 605
604 if (cursor) { 606 if (cursor) {
605 create_mask |= CWCursor; 607 create_mask |= CWCursor;
@@ -607,8 +609,8 @@ Window FluxboxWindow::createChildWindow(Window parent, Cursor cursor) {
607 } 609 }
608 610
609 return (XCreateWindow(display, parent, 0, 0, 1, 1, 0, 611 return (XCreateWindow(display, parent, 0, 0, 1, 1, 0,
610 screen->getDepth(), InputOutput, screen->getVisual(), 612 screen->getDepth(), InputOutput, screen->getVisual(),
611 create_mask, &attrib_create)); 613 create_mask, &attrib_create));
612} 614}
613 615
614 616
@@ -626,13 +628,13 @@ void FluxboxWindow::associateClientWindow(void) {
626 628
627 XFlush(display); 629 XFlush(display);
628 630
629 attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | 631 attrib_set.event_mask =
630 FocusChangeMask; 632 PropertyChangeMask | StructureNotifyMask | FocusChangeMask;
631 attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask | 633 attrib_set.do_not_propagate_mask =
632 ButtonMotionMask; 634 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask;
633 635
634 XChangeWindowAttributes(display, client.window, CWEventMask|CWDontPropagate, 636 XChangeWindowAttributes(display, client.window, CWEventMask|CWDontPropagate,
635 &attrib_set); 637 &attrib_set);
636 638
637#ifdef SHAPE 639#ifdef SHAPE
638 if (Fluxbox::instance()->hasShapeExtensions()) { 640 if (Fluxbox::instance()->hasShapeExtensions()) {
@@ -642,13 +644,13 @@ void FluxboxWindow::associateClientWindow(void) {
642 unsigned int ufoo; 644 unsigned int ufoo;
643 645
644 XShapeQueryExtents(display, client.window, &frame.shaped, &foo, &foo, 646 XShapeQueryExtents(display, client.window, &frame.shaped, &foo, &foo,
645 &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo); 647 &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo);
646 648
647 if (frame.shaped) { 649 if (frame.shaped) {
648 XShapeCombineShape(display, frame.window, ShapeBounding, 650 XShapeCombineShape(display, frame.window, ShapeBounding,
649 frame.mwm_border_w, frame.y_border + 651 frame.mwm_border_w, frame.y_border +
650 frame.mwm_border_w, client.window, 652 frame.mwm_border_w, client.window,
651 ShapeBounding, ShapeSet); 653 ShapeBounding, ShapeSet);
652 654
653 int num = 1; 655 int num = 1;
654 XRectangle xrect[2]; 656 XRectangle xrect[2];
@@ -665,22 +667,23 @@ void FluxboxWindow::associateClientWindow(void) {
665 } 667 }
666 668
667 XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0, 669 XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0,
668 xrect, num, ShapeUnion, Unsorted); 670 xrect, num, ShapeUnion, Unsorted);
669 } 671 }
670 } 672 }
671#endif // SHAPE 673#endif // SHAPE
672 //create the buttons 674 //create the buttons
673 if (decorations.iconify) 675 if (decorations.iconify)
674 createButton(Fluxbox::MINIMIZE, FluxboxWindow::iconifyPressed_cb, FluxboxWindow::iconifyButton_cb, FluxboxWindow::iconifyDraw_cb); 676 createButton(Fluxbox::MINIMIZE, FluxboxWindow::iconifyPressed_cb,
677 FluxboxWindow::iconifyButton_cb, FluxboxWindow::iconifyDraw_cb);
675 if (decorations.maximize) 678 if (decorations.maximize)
676 createButton(Fluxbox::MAXIMIZE, FluxboxWindow::maximizePressed_cb, FluxboxWindow::maximizeButton_cb, 679 createButton(Fluxbox::MAXIMIZE, FluxboxWindow::maximizePressed_cb,
677 FluxboxWindow::maximizeDraw_cb); 680 FluxboxWindow::maximizeButton_cb, FluxboxWindow::maximizeDraw_cb);
678 if (decorations.close) 681 if (decorations.close)
679 createButton(Fluxbox::CLOSE, FluxboxWindow::closePressed_cb, 682 createButton(Fluxbox::CLOSE, FluxboxWindow::closePressed_cb,
680 FluxboxWindow::closeButton_cb, FluxboxWindow::closeDraw_cb); 683 FluxboxWindow::closeButton_cb, FluxboxWindow::closeDraw_cb);
681 if (decorations.sticky) 684 if (decorations.sticky)
682 createButton(Fluxbox::STICK, FluxboxWindow::stickyPressed_cb, 685 createButton(Fluxbox::STICK, FluxboxWindow::stickyPressed_cb,
683 FluxboxWindow::stickyButton_cb, FluxboxWindow::stickyDraw_cb); 686 FluxboxWindow::stickyButton_cb, FluxboxWindow::stickyDraw_cb);
684 687
685 if (decorations.menu)//TODO 688 if (decorations.menu)//TODO
686 createButton(Fluxbox::MENU, 0, 0, 0); 689 createButton(Fluxbox::MENU, 0, 0, 0);
@@ -758,7 +761,7 @@ void FluxboxWindow::decorate(void) {
758 if (tmp) image_ctrl->removeImage(tmp); 761 if (tmp) image_ctrl->removeImage(tmp);
759 762
760 XSetWindowBorder(display, frame.title, 763 XSetWindowBorder(display, frame.title,
761 screen->getBorderColor()->getPixel()); 764 screen->getBorderColor()->getPixel());
762 765
763 decorateLabel(); 766 decorateLabel();
764 767
@@ -821,7 +824,7 @@ void FluxboxWindow::decorate(void) {
821 } 824 }
822 825
823 XSetWindowBorder(display, frame.window, 826 XSetWindowBorder(display, frame.window,
824 screen->getBorderColor()->getPixel()); 827 screen->getBorderColor()->getPixel());
825} 828}
826 829
827 830
@@ -860,10 +863,10 @@ void FluxboxWindow::createButton(int type, ButtonEventProc pressed, ButtonEventP
860} 863}
861 864
862Window FluxboxWindow::findTitleButton(int type) { 865Window FluxboxWindow::findTitleButton(int type) {
863 for (unsigned int i=0; i<buttonlist.size(); i++) 866 for (unsigned int i=0; i<buttonlist.size(); i++) {
864 if (buttonlist[i].type == type) 867 if (buttonlist[i].type == type)
865 return buttonlist[i].win; 868 return buttonlist[i].win;
866 869 }
867 return 0; 870 return 0;
868} 871}
869void FluxboxWindow::stickyButton_cb(FluxboxWindow *t, XButtonEvent *be) { 872void FluxboxWindow::stickyButton_cb(FluxboxWindow *t, XButtonEvent *be) {
@@ -914,26 +917,25 @@ void FluxboxWindow::stickyDraw_cb(FluxboxWindow *t, Window w, bool pressed) {
914 t->drawButtonBase(w, pressed); 917 t->drawButtonBase(w, pressed);
915 if (t->stuck) { 918 if (t->stuck) {
916 XFillRectangle(t->display, w, 919 XFillRectangle(t->display, w,
917 ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : 920 ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc :
918 t->screen->getWindowStyle()->b_pic_unfocus_gc), 921 t->screen->getWindowStyle()->b_pic_unfocus_gc),
919 t->frame.button_w/2-t->frame.button_w/4, t->frame.button_h/2-t->frame.button_h/4, 922 t->frame.button_w/2-t->frame.button_w/4, t->frame.button_h/2-t->frame.button_h/4,
920 t->frame.button_w/2, t->frame.button_h/2); 923 t->frame.button_w/2, t->frame.button_h/2);
921 } else { 924 } else {
922 XFillRectangle(t->display, w, 925 XFillRectangle(t->display, w,
923 ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : 926 ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc :
924 t->screen->getWindowStyle()->b_pic_unfocus_gc), 927 t->screen->getWindowStyle()->b_pic_unfocus_gc),
925 t->frame.button_w/2, t->frame.button_h/2, 928 t->frame.button_w/2, t->frame.button_h/2,
926 t->frame.button_w/5, t->frame.button_h/5); 929 t->frame.button_w/5, t->frame.button_h/5);
927 } 930 }
928} 931}
929 932
930void FluxboxWindow::iconifyDraw_cb(FluxboxWindow *t, Window w, bool pressed) { 933void FluxboxWindow::iconifyDraw_cb(FluxboxWindow *t, Window w, bool pressed) {
931 t->drawButtonBase(w, pressed); 934 t->drawButtonBase(w, pressed);
932 XDrawRectangle(t->display, w, 935 XDrawRectangle(t->display, w,
933 ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : 936 ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc :
934 t->screen->getWindowStyle()->b_pic_unfocus_gc), 937 t->screen->getWindowStyle()->b_pic_unfocus_gc),
935 2, t->frame.button_h - 5, t->frame.button_w - 5, 2); 938 2, t->frame.button_h - 5, t->frame.button_w - 5, 2);
936
937} 939}
938 940
939void FluxboxWindow::maximizeDraw_cb(FluxboxWindow *t, Window w, bool pressed) { 941void FluxboxWindow::maximizeDraw_cb(FluxboxWindow *t, Window w, bool pressed) {
@@ -1065,7 +1067,7 @@ void FluxboxWindow::positionButtons(bool redecorate_label) {
1065 //Draw the label 1067 //Draw the label
1066 frame.label_w = lw - by; 1068 frame.label_w = lw - by;
1067 XMoveResizeWindow(display, frame.label, lx, frame.bevel_w, 1069 XMoveResizeWindow(display, frame.label, lx, frame.bevel_w,
1068 frame.label_w, frame.label_h); 1070 frame.label_w, frame.label_h);
1069 if (redecorate_label) 1071 if (redecorate_label)
1070 decorateLabel(); 1072 decorateLabel();
1071 if (tab) { 1073 if (tab) {
@@ -1537,6 +1539,10 @@ void FluxboxWindow::getBlackboxHints(void) {
1537 1539
1538void FluxboxWindow::configure(int dx, int dy, 1540void FluxboxWindow::configure(int dx, int dy,
1539 unsigned int dw, unsigned int dh) { 1541 unsigned int dw, unsigned int dh) {
1542 //we don't want negative size
1543 if (dw <0 || dh<0)
1544 return;
1545
1540 bool send_event = (frame.x != dx || frame.y != dy); 1546 bool send_event = (frame.x != dx || frame.y != dy);
1541 1547
1542 if ((dw != frame.width) || (dh != frame.height)) { 1548 if ((dw != frame.width) || (dh != frame.height)) {
@@ -1598,7 +1604,7 @@ void FluxboxWindow::configure(int dx, int dy,
1598 if (send_event && ! moving) { 1604 if (send_event && ! moving) {
1599 client.x = dx + frame.mwm_border_w + screen->getBorderWidth(); 1605 client.x = dx + frame.mwm_border_w + screen->getBorderWidth();
1600 client.y = dy + frame.y_border + frame.mwm_border_w + 1606 client.y = dy + frame.y_border + frame.mwm_border_w +
1601 screen->getBorderWidth(); 1607 screen->getBorderWidth();
1602 1608
1603 XEvent event; 1609 XEvent event;
1604 event.type = ConfigureNotify; 1610 event.type = ConfigureNotify;
@@ -2079,7 +2085,8 @@ void FluxboxWindow::stick(void) {
2079 blackbox_attrib.attrib |= BaseDisplay::ATTRIB_OMNIPRESENT; 2085 blackbox_attrib.attrib |= BaseDisplay::ATTRIB_OMNIPRESENT;
2080 2086
2081 } 2087 }
2082 2088 //find a STICK button in window
2089 redrawAllButtons();
2083 setState(current_state); 2090 setState(current_state);
2084} 2091}
2085 2092
@@ -2530,17 +2537,17 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) {
2530 2537
2531void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) { 2538void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
2532 if (ue->window == client.window) { 2539 if (ue->window == client.window) {
2533#ifdef DEBUG 2540 #ifdef DEBUG
2534 fprintf(stderr, 2541 fprintf(stderr,
2535 I18n::instance()->getMessage( 2542 I18n::instance()->getMessage(
2536#ifdef NLS 2543 #ifdef NLS
2537 WindowSet, WindowUnmapNotify, 2544 WindowSet, WindowUnmapNotify,
2538#else // !NLS 2545 #else // !NLS
2539 0, 0, 2546 0, 0,
2540#endif // NLS 2547 #endif // NLS
2541 "FluxboxWindow::unmapNotifyEvent() for 0x%lx\n"), 2548 "FluxboxWindow::unmapNotifyEvent() for 0x%lx\n"),
2542 client.window); 2549 client.window);
2543#endif // DEBUG 2550 #endif // DEBUG
2544 2551
2545 Fluxbox *fluxbox = Fluxbox::instance(); 2552 Fluxbox *fluxbox = Fluxbox::instance();
2546 BaseDisplay::GrabGuard gg(*fluxbox); 2553 BaseDisplay::GrabGuard gg(*fluxbox);
@@ -3099,7 +3106,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
3099 3106
3100 resizing = true; 3107 resizing = true;
3101 3108
3102 fluxbox->grab(); 3109// fluxbox->grab();
3103 3110
3104 int gx, gy; 3111 int gx, gy;
3105 frame.grab_x = me->x - screen->getBorderWidth(); 3112 frame.grab_x = me->x - screen->getBorderWidth();