// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-// Window.cc for Blackbox - an X11 Window manager
-// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
-// Copyright (c) 1997 - 2000, 2002 Brad Hughes <bhughes at trolltech.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
#ifdef HAVE_CONFIG_H
# include "../config.h"
}
#include "blackbox.hh"
-#include "clientmenu.hh"
#include "font.hh"
#include "gccache.hh"
-#include "iconmenu.hh"
#include "image.hh"
#include "screen.hh"
-#include "toolbar.hh"
#include "util.hh"
#include "window.hh"
-#include "windowmenu.hh"
#include "workspace.hh"
-#include "slit.hh"
using std::string;
using std::abs;
current_state = NormalState;
- windowmenu = 0;
-
/*
set the initial size and location of client window (relative to the
_root window_). This position is the reference point used with the
if (flags.maximized && (functions & Func_Maximize))
remaximize();
-
- // create this last so it only needs to be configured once
- windowmenu = new Windowmenu(this);
}
delete timer;
- delete windowmenu;
-
if (client.window_group) {
BWindowGroup *group = blackbox->searchGroup(client.window_group);
if (group) group->removeWindow(this);
ungrabButtons();
grabButtons();
-
- if (windowmenu) {
- windowmenu->move(windowmenu->getX(), frame.rect.y() + frame.title_h);
- windowmenu->reconfigure();
- }
}
return;
}
// fall back to an internal default
- client.title = i18n(WindowSet, WindowUnnamed, "Unnamed");
+ client.title = "Unnamed";
xatom->setValue(client.window, XAtom::net_wm_visible_name, XAtom::utf8,
client.title);
functions |= Func_Close;
} else if (proto[i] == xatom->getAtom(XAtom::wm_take_focus))
flags.send_focus_message = True;
- else if (proto[i] == xatom->getAtom(XAtom::blackbox_structure_messages))
- screen->addNetizen(new Netizen(screen, client.window));
}
XFree(proto);
XSendEvent(blackbox->getXDisplay(), client.window, False,
StructureNotifyMask, &event);
- screen->updateNetizenConfigNotify(&event);
XFlush(blackbox->getXDisplay());
}
}
if (flags.moving)
endMove();
- if (windowmenu) windowmenu->hide();
-
/*
* we don't want this XUnmapWindow call to generate an UnmapNotify event, so
* we need to clear the event mask on client.window for a split second.
XSelectInput(blackbox->getXDisplay(), client.window, event_mask);
XUngrabServer(blackbox->getXDisplay());
-
- if (windowmenu) windowmenu->hide();
}
if (flags.moving)
endMove();
- // handle case where menu is open then the max button is used instead
- if (windowmenu && windowmenu->isVisible()) windowmenu->hide();
-
if (flags.maximized) {
flags.maximized = 0;
if (flags.focused)
blackbox->setFocusedWindow(this);
-
- if (! flags.iconic) {
- // iconic windows arent in a workspace menu!
- if (flags.stuck)
- screen->getCurrentWorkspace()->setFocused(this, isFocused());
- else
- screen->getWorkspace(blackbox_attrib.workspace)->
- setFocused(this, flags.focused);
- }
}
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
screen->getWindowStyle()->b_pic_unfocus);
-#ifdef BITMAPBUTTONS
PixmapMask pm = screen->getWindowStyle()->icon_button;
if (screen->getWindowStyle()->icon_button.mask != None) {
XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0);
} else {
-#endif // BITMAPBUTTONS
XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(),
2, (frame.button_w - 5), (frame.button_w - 5), 2);
-#ifdef BITMAPBUTTONS
}
-#endif // BITMAPBUTTONS
}
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
screen->getWindowStyle()->b_pic_unfocus);
-#ifdef BITMAPBUTTONS
PixmapMask pm = screen->getWindowStyle()->max_button;
if (pm.mask != None) {
XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
} else {
-#endif // BITMAPBUTTONS
XDrawRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
2, 2, (frame.button_w - 5), (frame.button_w - 5));
XDrawLine(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
2, 3, (frame.button_w - 3), 3);
-#ifdef BITMAPBUTTONS
}
-#endif // BITMAPBUTTONS
}
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
screen->getWindowStyle()->b_pic_unfocus);
-#ifdef BITMAPBUTTONS
PixmapMask pm = screen->getWindowStyle()->close_button;
if (pm.mask != None) {
XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
} else {
-#endif // BITMAPBUTTONS
XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(),
2, 2, (frame.button_w - 3), (frame.button_w - 3));
XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(),
2, (frame.button_w - 3), (frame.button_w - 3), 2);
-#ifdef BITMAPBUTTONS
}
-#endif // BITMAPBUTTONS
}
void BlackboxWindow::redrawStickyButton(bool pressed) const {
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
screen->getWindowStyle()->b_pic_unfocus);
-#ifdef BITMAPBUTTONS
PixmapMask pm = screen->getWindowStyle()->stick_button;
if (pm.mask != None) {
XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
} else {
-#endif // BITMAPBUTTONS
XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(),
frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 );
-#ifdef BITMAPBUTTONS
}
-#endif
}
void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) {
positionButtons(True);
XMapSubwindows(blackbox->getXDisplay(), frame.title);
}
- if (windowmenu) windowmenu->reconfigure();
}
} else if (pe->atom == xatom->getAtom(XAtom::net_wm_strut)) {
updateStrut();
} else if (frame.stick_button == be->window) {
redrawStickyButton(True);
} else if (frame.plate == be->window) {
- if (windowmenu && windowmenu->isVisible()) windowmenu->hide();
-
screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this);
XAllowEvents(blackbox->getXDisplay(), ReplayPointer, be->time);
}
}
- if (windowmenu && windowmenu->isVisible()) windowmenu->hide();
-
screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this);
}
} else if (be->button == 2 && (be->window != frame.iconify_button) &&
(be->window != frame.close_button) &&
(be->window != frame.stick_button)) {
screen->getWorkspace(blackbox_attrib.workspace)->lowerWindow(this);
- } else if (windowmenu && be->button == 3 &&
- (frame.title == be->window || frame.label == be->window ||
- frame.handle == be->window || frame.window == be->window)) {
- if (windowmenu->isVisible()) {
- windowmenu->hide();
- } else {
- int mx = be->x_root - windowmenu->getWidth() / 2,
- my = be->y_root - windowmenu->getHeight() / 2;
-
- // snap the window menu into a corner/side if necessary
- int left_edge, right_edge, top_edge, bottom_edge;
-
- /*
- the " + (frame.border_w * 2) - 1" bits are to get the proper width
- and height of the menu, as the sizes returned by it do not include
- the borders.
- */
- left_edge = frame.rect.x();
- right_edge = frame.rect.right() -
- (windowmenu->getWidth() + (frame.border_w * 2) - 1);
- top_edge = client.rect.top() - (frame.border_w + frame.mwm_border_w);
- bottom_edge = client.rect.bottom() -
- (windowmenu->getHeight() + (frame.border_w * 2) - 1) +
- (frame.border_w + frame.mwm_border_w);
-
- if (mx < left_edge)
- mx = left_edge;
- else if (mx > right_edge)
- mx = right_edge;
- if (my < top_edge)
- my = top_edge;
- else if (my > bottom_edge)
- my = bottom_edge;
-
- if (my + windowmenu->getHeight() > screen->getHeight())
- my = screen->getHeight() - windowmenu->getHeight() -
- (screen->getBorderWidth() * 2);
-
- windowmenu->move(mx, my);
- windowmenu->show();
- XRaiseWindow(blackbox->getXDisplay(), windowmenu->getWindowID());
- XRaiseWindow(blackbox->getXDisplay(),
- windowmenu->getSendToMenu()->getWindowID());
- }
// mouse wheel up
} else if (be->button == 4) {
if ((be->window == frame.label ||
GrabModeAsync, GrabModeAsync,
None, blackbox->getMoveCursor(), CurrentTime);
- if (windowmenu && windowmenu->isVisible())
- windowmenu->hide();
-
flags.moving = True;
blackbox->setChangingWindow(this);
if (*st_it != this) // don't snap to ourself
rectlist.push_back( (*st_it)->frameRect() );
- // add the toolbar and the slit to the rect list.
- // (only if they are not hidden)
- Toolbar *tbar = screen->getToolbar();
- Slit *slit = screen->getSlit();
- Rect tbar_rect, slit_rect;
- unsigned int bwidth = screen->getBorderWidth() * 2;
-
- if (! (screen->doHideToolbar() || tbar->isHidden())) {
- tbar_rect.setRect(tbar->getX(), tbar->getY(), tbar->getWidth() + bwidth,
- tbar->getHeight() + bwidth);
- rectlist.push_back(tbar_rect);
- }
-
- if (! slit->isHidden()) {
- slit_rect.setRect(slit->getX(), slit->getY(), slit->getWidth() + bwidth,
- slit->getHeight() + bwidth);
- rectlist.push_back(slit_rect);
- }
-
RectList::const_iterator it, end = rectlist.end();
for (it = rectlist.begin(); it != end; ++it) {
bool snapped = False;