From: Dana Jansens Date: Thu, 31 Oct 2002 06:30:23 +0000 (+0000) Subject: no more menus, at last. woop X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=60b016b7fc54a01c19a3ab9a6d127b0509c38f11;p=chaz%2Fopenbox no more menus, at last. woop --- diff --git a/src/Basemenu.cc b/src/Basemenu.cc deleted file mode 100644 index 3c096eff..00000000 --- a/src/Basemenu.cc +++ /dev/null @@ -1,1034 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -// Basemenu.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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" -#endif // HAVE_CONFIG_H - -extern "C" { -#ifdef HAVE_STDIO_H -# include -#endif // HAVE_STDIO_H - -#ifdef HAVE_STDLIB_H -# include -#endif // HAVE_STDLIB_H - -#ifdef HAVE_STRING_H -# include -#endif // HAVE_STRING_H -} - -#include -#include -using namespace std; - -#include "i18n.hh" -#include "blackbox.hh" -#include "Basemenu.hh" -#include "Font.hh" -#include "GCCache.hh" -#include "Image.hh" -#include "Screen.hh" -#include "Util.hh" - - -static Basemenu *shown = (Basemenu *) 0; - -Basemenu::Basemenu(BScreen *scrn) { - screen = scrn; - blackbox = screen->getBlackbox(); - image_ctrl = screen->getImageControl(); - display = blackbox->getXDisplay(); - parent = (Basemenu *) 0; - alignment = AlignDontCare; - - title_vis = - movable = - hide_tree = True; - - shifted = - internal_menu = - moving = - torn = - visible = False; - - menu.x = - menu.y = - menu.x_shift = - menu.y_shift = - menu.x_move = - menu.y_move = 0; - - which_sub = - which_press = - which_sbl = -1; - - menu.sublevels = - menu.persub = - menu.minsub = 0; - - menu.frame_pixmap = - menu.title_pixmap = - menu.hilite_pixmap = None; - - menu.bevel_w = screen->getBevelWidth(); - - const MenuStyle* const style = screen->getMenuStyle(); - menu.width = menu.title_h = menu.item_w = menu.frame_h = - style->t_font->height() + (menu.bevel_w * 2); - - menu.item_h = style->f_font->height() + menu.bevel_w; - - menu.height = menu.title_h + screen->getBorderWidth() + menu.frame_h; - - unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - XSetWindowAttributes attrib; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - screen->getBorderColor()->pixel(); - attrib.colormap = screen->getColormap(); - attrib.override_redirect = True; - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask; - - menu.window = - XCreateWindow(display, screen->getRootWindow(), - menu.x, menu.y, menu.width, menu.height, - screen->getBorderWidth(), screen->getDepth(), - InputOutput, screen->getVisual(), attrib_mask, &attrib); - blackbox->saveMenuSearch(menu.window, this); - - attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | CWEventMask; - attrib.background_pixel = screen->getBorderColor()->pixel(); - attrib.event_mask |= EnterWindowMask | LeaveWindowMask; - - menu.title = - XCreateWindow(display, menu.window, 0, 0, menu.width, menu.height, 0, - screen->getDepth(), InputOutput, screen->getVisual(), - attrib_mask, &attrib); - blackbox->saveMenuSearch(menu.title, this); - - attrib.event_mask |= PointerMotionMask; - menu.frame = XCreateWindow(display, menu.window, 0, - menu.title_h + screen->getBorderWidth(), - menu.width, menu.frame_h, 0, - screen->getDepth(), InputOutput, - screen->getVisual(), attrib_mask, &attrib); - blackbox->saveMenuSearch(menu.frame, this); - - // even though this is the end of the constructor the menu is still not - // completely created. items must be inserted and it must be update()'d -} - - -Basemenu::~Basemenu(void) { - XUnmapWindow(display, menu.window); - - if (shown && shown->getWindowID() == getWindowID()) - shown = (Basemenu *) 0; - - MenuItems::const_iterator it = menuitems.begin(), - end = menuitems.end(); - for (; it != end; ++it) { - if (! internal_menu) { - Basemenu *tmp = (*it)->submenu(); - if (tmp) { - if (! tmp->internal_menu) - delete tmp; - else - tmp->internal_hide(); - } - } - } - - std::for_each(menuitems.begin(), menuitems.end(), PointerAssassin()); - - if (menu.title_pixmap) - image_ctrl->removeImage(menu.title_pixmap); - - if (menu.frame_pixmap) - image_ctrl->removeImage(menu.frame_pixmap); - - if (menu.hilite_pixmap) - image_ctrl->removeImage(menu.hilite_pixmap); - - blackbox->removeMenuSearch(menu.title); - XDestroyWindow(display, menu.title); - - blackbox->removeMenuSearch(menu.frame); - XDestroyWindow(display, menu.frame); - - blackbox->removeMenuSearch(menu.window); - XDestroyWindow(display, menu.window); -} - - -BasemenuItem *Basemenu::find(int index) { - if (index < 0 || index >= static_cast(menuitems.size())) - return (BasemenuItem*) 0; - - return menuitems[index]; -} - - -int Basemenu::insert(BasemenuItem *item, int pos) { - if (pos < 0) { - menuitems.push_back(item); - } else { - assert(pos <= static_cast(menuitems.size())); - menuitems.insert((menuitems.begin() + pos), item); - } - return menuitems.size(); -} - - -int Basemenu::insert(const string& label, int function, - const string& exec, int pos) { - BasemenuItem *item = new BasemenuItem(label, function, exec); - return insert(item, pos); -} - - -int Basemenu::insert(const string& label, Basemenu *submenu, int pos) { - BasemenuItem *item = new BasemenuItem(label, submenu); - submenu->parent = this; - - return insert(item, pos); -} - - -int Basemenu::remove(int index) { - BasemenuItem *item = find(index); - if (! item) return -1; - - if (! internal_menu) { - Basemenu *tmp = item->submenu(); - if (tmp) { - if (! tmp->internal_menu) - delete tmp; - else - tmp->internal_hide(); - } - } - - delete item; - - if (which_sub == index) - which_sub = -1; - else if (which_sub > index) - which_sub--; - - menuitems.erase(menuitems.begin() + index); - - return menuitems.size(); -} - - -void Basemenu::update(void) { - const MenuStyle* const style = screen->getMenuStyle(); - menu.item_h = (style->f_font->height() < 9 ? 9 : style->f_font->height()) + - menu.bevel_w; // 9 for the menu pixmaps (checkmarks) - menu.title_h = style->t_font->height() + menu.bevel_w * 2; - - if (title_vis) { - menu.item_w = screen->getMenuStyle()->t_font->measureString(menu.label) + - menu.bevel_w * 2; - } else { - menu.item_w = 1; - } - - unsigned int ii = 0; - MenuItems::iterator it = menuitems.begin(), end = menuitems.end(); - for (; it != end; ++it) { - ii = screen->getMenuStyle()->f_font->measureString((*it)->l) + - (menu.bevel_w * 2) + (menu.item_h * 2); - - menu.item_w = ((menu.item_w < ii) ? ii : menu.item_w); - } - - if (! menuitems.empty()) { - menu.sublevels = 1; - - const unsigned int menu_size = menuitems.size(); - while (((menu.item_h * (menu_size + 1) / menu.sublevels) - + menu.title_h + screen->getBorderWidth()) > - screen->getHeight()) - menu.sublevels++; - - if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub; - - menu.persub = menu_size / menu.sublevels; - if (menu_size % menu.sublevels) menu.persub++; - } else { - menu.sublevels = 0; - menu.persub = 0; - } - - menu.width = (menu.sublevels * (menu.item_w)); - if (! menu.width) menu.width = menu.item_w; - - menu.frame_h = (menu.item_h * menu.persub); - menu.height = ((title_vis) ? menu.title_h + screen->getBorderWidth() : 0) + - menu.frame_h; - if (! menu.frame_h) menu.frame_h = 1; - if (menu.height < 1) menu.height = 1; - - Pixmap tmp; - BTexture *texture; - if (title_vis) { - tmp = menu.title_pixmap; - texture = &(screen->getMenuStyle()->title); - if (texture->texture() == (BTexture::Flat | BTexture::Solid)) { - menu.title_pixmap = None; - XSetWindowBackground(display, menu.title, - texture->color().pixel()); - } else { - menu.title_pixmap = - image_ctrl->renderImage(menu.width, menu.title_h, *texture); - XSetWindowBackgroundPixmap(display, menu.title, menu.title_pixmap); - } - if (tmp) image_ctrl->removeImage(tmp); - XClearWindow(display, menu.title); - } - - tmp = menu.frame_pixmap; - texture = &(screen->getMenuStyle()->frame); - if (texture->texture() == (BTexture::Flat | BTexture::Solid)) { - menu.frame_pixmap = None; - XSetWindowBackground(display, menu.frame, - texture->color().pixel()); - } else { - menu.frame_pixmap = - image_ctrl->renderImage(menu.width, menu.frame_h, *texture); - XSetWindowBackgroundPixmap(display, menu.frame, menu.frame_pixmap); - } - if (tmp) image_ctrl->removeImage(tmp); - - tmp = menu.hilite_pixmap; - texture = &(screen->getMenuStyle()->hilite); - if (texture->texture() == (BTexture::Flat | BTexture::Solid)) { - menu.hilite_pixmap = None; - } else { - menu.hilite_pixmap = - image_ctrl->renderImage(menu.item_w, menu.item_h, *texture); - } - if (tmp) image_ctrl->removeImage(tmp); - - XResizeWindow(display, menu.window, menu.width, menu.height); - - if (title_vis) - XResizeWindow(display, menu.title, menu.width, menu.title_h); - - XMoveResizeWindow(display, menu.frame, 0, - ((title_vis) ? menu.title_h + - screen->getBorderWidth() : 0), menu.width, - menu.frame_h); - - XClearWindow(display, menu.window); - XClearWindow(display, menu.title); - XClearWindow(display, menu.frame); - - if (title_vis && visible) redrawTitle(); - - const int menu_size = menuitems.size(); - for (int i = 0; visible && i < menu_size; i++) { - if (i == which_sub) { - drawItem(i, True, 0); - drawSubmenu(i); - } else { - drawItem(i, False, 0); - } - } - - if (parent && visible) - parent->drawSubmenu(parent->which_sub); - - XMapSubwindows(display, menu.window); -} - - -void Basemenu::show(void) { - XMapSubwindows(display, menu.window); - XMapWindow(display, menu.window); - visible = True; - - if (! parent) { - if (shown && (! shown->torn)) - shown->hide(); - - shown = this; - } -} - - -void Basemenu::hide(void) { - if (! torn && hide_tree && parent && parent->isVisible()) { - Basemenu *p = parent; - - while (p->isVisible() && ! p->torn && p->parent) p = p->parent; - p->internal_hide(); - } else { - internal_hide(); - } -} - - -void Basemenu::internal_hide(void) { - BasemenuItem *tmp = find(which_sub); - if (tmp) - tmp->submenu()->internal_hide(); - - if (parent && ! torn) { - parent->drawItem(parent->which_sub, False, True); - - parent->which_sub = -1; - } else if (shown && shown->menu.window == menu.window) { - shown = (Basemenu *) 0; - } - - torn = visible = False; - which_sub = which_press = which_sub = -1; - - XUnmapWindow(display, menu.window); -} - - -void Basemenu::move(int x, int y) { - menu.x = x; - menu.y = y; - XMoveWindow(display, menu.window, x, y); - if (which_sub != -1) - drawSubmenu(which_sub); -} - - -void Basemenu::redrawTitle(void) { - const char *text = (! menu.label.empty()) ? getLabel() : - i18n(BasemenuSet, BasemenuBlackboxMenu, "Blackbox Menu"); - int dx = menu.bevel_w; - unsigned int l; - const MenuStyle* const style = screen->getMenuStyle(); - - l = style->t_font->measureString(text) + menu.bevel_w * 2; - - switch (screen->getMenuStyle()->t_justify) { - case RightJustify: - dx += menu.width - l; - break; - - case CenterJustify: - dx += (menu.width - l) / 2; - break; - - case LeftJustify: - default: - break; - } - - XClearWindow(display, menu.title); - style->t_font->drawString(menu.title, dx, menu.bevel_w, - style->t_text, text); -} - - -void Basemenu::drawSubmenu(int index) { - BasemenuItem *item = find(which_sub); - if (item && item->submenu() && ! item->submenu()->isTorn() && - which_sub != index) - item->submenu()->internal_hide(); - - item = find(index); - if (! item) - return; - - Basemenu *submenu = item->submenu(); - - if (submenu && visible && ! submenu->isTorn() && item->isEnabled()) { - if (submenu->parent != this) submenu->parent = this; - const int sbl = index / menu.persub, i = index - (sbl * menu.persub); - int x = menu.x + ((menu.item_w * (sbl + 1)) + screen->getBorderWidth()), y; - - if (alignment == AlignTop) { - y = (((shifted) ? menu.y_shift : menu.y) + - ((title_vis) ? menu.title_h + screen->getBorderWidth() : 0) - - ((submenu->title_vis) ? - submenu->menu.title_h + screen->getBorderWidth() : 0)); - } else { - y = (((shifted) ? menu.y_shift : menu.y) + - (menu.item_h * i) + - ((title_vis) ? menu.title_h + screen->getBorderWidth() : 0) - - ((submenu->title_vis) ? - submenu->menu.title_h + screen->getBorderWidth() : 0)); - } - - if (alignment == AlignBottom && - (y + submenu->menu.height) > ((shifted) ? menu.y_shift : - menu.y) + menu.height) - y = (((shifted) ? menu.y_shift : menu.y) + - menu.height - submenu->menu.height); - - if ((x + submenu->getWidth()) > screen->getWidth()) - x = ((shifted) ? menu.x_shift : menu.x) - - submenu->getWidth() - screen->getBorderWidth(); - - if (x < 0) x = 0; - - if ((y + submenu->getHeight()) > screen->getHeight()) - y = screen->getHeight() - submenu->getHeight() - - (screen->getBorderWidth() * 2); - if (y < 0) y = 0; - - submenu->move(x, y); - if (! moving) drawItem(index, True); - - if (! submenu->isVisible()) - submenu->show(); - submenu->moving = moving; - which_sub = index; - } else { - which_sub = -1; - } -} - - -bool Basemenu::hasSubmenu(int index) { - BasemenuItem *item = find(index); - if (item && item->submenu()) - return True; - return False; -} - - -void Basemenu::drawItem(int index, bool highlight, bool clear, - int x, int y, unsigned int w, unsigned int h) { - BasemenuItem *item = find(index); - if (! item) return; - - bool dotext = True, dohilite = True, dosel = True, dooppsel = True; - const char *text = item->label(); - const int sbl = index / menu.persub, i = index - (sbl * menu.persub); - const unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4; - int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h); - int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0; - int text_x = 0, text_y = 0, sel_x = 0, oppsel_x = 0, sel_y = 0; - unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, - text_h = 0; - - if (text) { - text_w = screen->getMenuStyle()->f_font->measureString(text); - text_y = item_y + menu.bevel_w / 2; - - switch(screen->getMenuStyle()->f_justify) { - case LeftJustify: - text_x = item_x + menu.bevel_w + menu.item_h + 1; - break; - - case RightJustify: - text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w); - break; - - case CenterJustify: - text_x = item_x + ((menu.item_w + 1 - text_w) / 2); - break; - } - - text_h = menu.item_h - menu.bevel_w; - } - - const MenuStyle* const style = screen->getMenuStyle(); - const BPen hipen(style->hilite.color()); - // match the text color - const BPen pen((highlight ? style->h_text : - (item->isEnabled() ? style->f_text : - style->d_text))); - - - sel_x = item_x; - if (screen->getMenuStyle()->bullet_pos == Right) - sel_x += (menu.item_w - menu.item_h - menu.bevel_w); - sel_x += quarter_w; - oppsel_x = sel_x; - if (screen->getMenuStyle()->bullet_pos == Right) - oppsel_x -= (menu.item_w - menu.item_h - menu.bevel_w); - else - oppsel_x += (menu.item_w - menu.item_h - menu.bevel_w); - sel_y = item_y + quarter_w; - - if (clear) { - XClearArea(display, menu.frame, item_x, item_y, menu.item_w, menu.item_h, - False); - } else if (! (x == y && y == -1 && w == h && h == 0)) { - // calculate the which part of the hilite to redraw - if (! (max(item_x, x) <= min(item_x + menu.item_w, x + w) && - max(item_y, y) <= min(item_y + menu.item_h, y + h))) { - dohilite = False; - } else { - hilite_x = max(item_x, x); - hilite_y = max(item_y, y); - hilite_w = min(item_x + menu.item_w, x + w) - hilite_x; - hilite_h = min(item_y + menu.item_h, y + h) - hilite_y; - hoff_x = hilite_x % menu.item_w; - hoff_y = hilite_y % menu.item_h; - } - - // check if we need to redraw the text - const int text_ry = item_y + (menu.bevel_w / 2); - if (! (max(text_x, x) <= min(text_x + text_w, x + w) && - max(text_ry, y) <= min(text_ry + text_h, y + h))) - dotext = False; - - // check if we need to redraw the select pixmap/menu bullet - if (! (max(sel_x, x) <= min(sel_x + half_w, x + w) && - max(sel_y, y) <= min(sel_y + half_w, y + h))) - dosel = False; - - // check if we need to redraw the select pixmap/menu bullet - // on the opposite side of the menu - if (! (max(oppsel_x, x) <= min(oppsel_x + half_w, x + w) && - max(sel_y, y) <= min(sel_y + half_w, y + h))) - dooppsel = False; - } - -#ifdef XFT - if (dotext) - XClearArea(display, menu.frame, text_x, text_y , text_w, text_h, False); -#endif // XFT - - if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) { - if (menu.hilite_pixmap) - XCopyArea(display, menu.hilite_pixmap, menu.frame, - hipen.gc(), hoff_x, hoff_y, - hilite_w, hilite_h, hilite_x, hilite_y); - else - XFillRectangle(display, menu.frame, hipen.gc(), - hilite_x, hilite_y, hilite_w, hilite_h); - } - - if (dooppsel && item->isSelected()) { -#ifdef BITMAPBUTTONS - if ( style->tick_image.mask != None) { - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), - oppsel_x, item_y + menu.item_h/2 - style->tick_image.h/2); - XSetClipMask(blackbox->getXDisplay(), pen.gc(), - style->tick_image.mask); - - XFillRectangle(blackbox->getXDisplay(), menu.frame, pen.gc(), - oppsel_x, item_y + menu.item_h/2 - style->tick_image.h/2, - style->tick_image.w, - style->tick_image.h); - - XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); - - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), - 0, 0); - } else { -#endif // BITMAPBUTTONS - XPoint pts[6]; - - pts[0].x = oppsel_x + 0; - pts[0].y = sel_y + 2; - - pts[1].x = 0; - pts[1].y = 3; - - pts[2].x = 2; - pts[2].y = 3; - - pts[3].x = 5; - pts[3].y = -5; - - - pts[4].x = 0; - pts[4].y = -3; - - pts[5].x = -5; - pts[5].y = 5; - - XFillPolygon(display, menu.frame, pen.gc(), pts, 6, Nonconvex, - CoordModePrevious); -#ifdef BITMAPBUTTONS - } -#endif // BITMAPBUTTONS - } - - if (dotext && text) { - style->f_font->drawString(menu.frame, text_x, text_y, - (highlight ? style->h_text : - (item->isEnabled() ? style->f_text : - style->d_text)), - text); - } - - if (dosel && item->submenu()) { -#ifdef BITMAPBUTTONS - if ( style->bullet_image.mask != None) { - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), - sel_x, item_y + menu.item_h/2 - style->bullet_image.h/2); - XSetClipMask(blackbox->getXDisplay(), pen.gc(), - style->bullet_image.mask); - - XFillRectangle(blackbox->getXDisplay(), menu.frame, pen.gc(), - sel_x, item_y + menu.item_h/2 - style->bullet_image.h/2, - style->bullet_image.w, style->bullet_image.h); - - XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); - - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), - 0, 0); - } else { -#endif // BITMAPBUTTONS - const int bullet_size = 3; - - switch (screen->getMenuStyle()->bullet) { - case Square: - XDrawRectangle(display, menu.frame, pen.gc(), sel_x, sel_y, - bullet_size * 2, bullet_size * 2); - break; - - case Triangle: - XPoint tri[3]; - - if (screen->getMenuStyle()->bullet_pos == Right) { - tri[0].x = sel_x + quarter_w - bullet_size; - tri[0].y = sel_y + quarter_w - bullet_size; - tri[1].x = 2 * bullet_size; - tri[1].y = bullet_size; - tri[2].x = -(2 * bullet_size); - tri[2].y = bullet_size; - } else { - tri[0].x = sel_x + quarter_w - bullet_size; - tri[0].y = item_y + half_w; - tri[1].x = 2 * bullet_size; - tri[1].y = bullet_size; - tri[2].x = 0; - tri[2].y = -(2 * bullet_size); - } - - XFillPolygon(display, menu.frame, pen.gc(), tri, 3, Convex, - CoordModePrevious); - break; - - case Diamond: - XPoint dia[4]; - - dia[0].x = sel_x + quarter_w - bullet_size; - dia[0].y = item_y + half_w; - dia[1].x = bullet_size; - dia[1].y = -bullet_size; - dia[2].x = bullet_size; - dia[2].y = bullet_size; - dia[3].x = -bullet_size; - dia[3].y = bullet_size; - - XFillPolygon(display, menu.frame, pen.gc(), dia, 4, Convex, - CoordModePrevious); - break; - } -#ifdef BITMAPBUTTONS - } -#endif // BITMAPBUTTONS - } -} - - -void Basemenu::setLabel(const string& label) { - menu.label = label; -} - - -void Basemenu::setItemSelected(int index, bool sel) { - assert(index >= 0); - BasemenuItem *item = find(index); - if (! item) return; - - item->setSelected(sel); - if (visible) drawItem(index, (index == which_sub), True); -} - - -bool Basemenu::isItemSelected(int index) { - assert(index >= 0); - BasemenuItem *item = find(index); - if (! item) return False; - - return item->isSelected(); -} - - -void Basemenu::setItemEnabled(int index, bool enable) { - assert(index >= 0); - BasemenuItem *item = find(index); - if (! item) return; - - item->setEnabled(enable); - if (visible) drawItem(index, (index == which_sub), True); -} - - -bool Basemenu::isItemEnabled(int index) { - assert(index >= 0); - BasemenuItem *item = find(index); - if (! item) return False; - - return item->isEnabled(); -} - - -void Basemenu::buttonPressEvent(XButtonEvent *be) { - if (be->window == menu.frame) { - const int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h), - w = (sbl * menu.persub) + i; - - BasemenuItem *item = find(w); - if (item) { - which_press = i; - which_sbl = sbl; - - - if (item->submenu()) - drawSubmenu(w); - else - drawItem(w, (item->isEnabled()), True); - } - } else { - menu.x_move = be->x_root - menu.x; - menu.y_move = be->y_root - menu.y; - } -} - - -void Basemenu::buttonReleaseEvent(XButtonEvent *re) { - if (re->window == menu.title) { - if (moving) { - moving = False; - - if (which_sub != -1) - drawSubmenu(which_sub); - } - - if (re->x >= 0 && re->x <= static_cast(menu.width) && - re->y >= 0 && re->y <= static_cast(menu.title_h)) - if (re->button == 3) - hide(); - } else if (re->window == menu.frame && - re->x >= 0 && re->x < static_cast(menu.width) && - re->y >= 0 && re->y < static_cast(menu.frame_h)) { - if (re->button == 3) { - hide(); - } else { - const int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h), - ix = sbl * menu.item_w, iy = i * menu.item_h, - w = (sbl * menu.persub) + i, - p = (which_sbl * menu.persub) + which_press; - - if (w >= 0 && w < static_cast(menuitems.size())) { - drawItem(p, (p == which_sub), True); - - if (p == w && isItemEnabled(w)) { - if (re->x > ix && re->x < static_cast(ix + menu.item_w) && - re->y > iy && re->y < static_cast(iy + menu.item_h)) { - itemSelected(re->button, w); - } - } - } else { - drawItem(p, False, True); - } - } - } -} - - -void Basemenu::motionNotifyEvent(XMotionEvent *me) { - if (me->window == menu.title && (me->state & Button1Mask)) { - if (movable) { - if (! moving) { - if (parent && ! torn) { - parent->drawItem(parent->which_sub, False, True); - parent->which_sub = -1; - } - - moving = torn = True; - - if (which_sub != -1) - drawSubmenu(which_sub); - } else { - menu.x = me->x_root - menu.x_move, - menu.y = me->y_root - menu.y_move; - - XMoveWindow(display, menu.window, menu.x, menu.y); - - if (which_sub != -1) - drawSubmenu(which_sub); - } - } - } else if (me->window == menu.frame && - me->x >= 0 && me->x < static_cast(menu.width) && - me->y >= 0 && me->y < static_cast(menu.frame_h)) { - const int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h), - w = (sbl * menu.persub) + i; - - if ((i != which_press || sbl != which_sbl) && - (w >= 0 && w < static_cast(menuitems.size()))) { - if (which_press != -1 && which_sbl != -1) { - const int p = (which_sbl * menu.persub) + which_press; - BasemenuItem *item = find(p); - if (! item) return; - - drawItem(p, False, True); - if (item->submenu() && - item->submenu()->isVisible() && - ! item->submenu()->isTorn()) { - item->submenu()->internal_hide(); - which_sub = -1; - } - } - - which_press = i; - which_sbl = sbl; - - BasemenuItem *itmp = find(w); - if (! itmp) return; - - if (itmp->submenu()) - drawSubmenu(w); - else - drawItem(w, (itmp->isEnabled()), True); - } - } -} - - -void Basemenu::exposeEvent(XExposeEvent *ee) { - if (ee->window == menu.title) { - redrawTitle(); - } else if (ee->window == menu.frame) { - // this is a complicated algorithm... lets do it step by step... - // first... we see in which sub level the expose starts... and how many - // items down in that sublevel - - const int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h), - // next... figure out how many sublevels over the redraw spans - sbl_d = ((ee->x + ee->width) / menu.item_w); - // then we see how many items down to redraw - int id_d = ((ee->y + ee->height) / menu.item_h); - - if (id_d > menu.persub) id_d = menu.persub; - - // draw the sublevels and the number of items the exposure spans - MenuItems::iterator it, - end = menuitems.end(); - for (int i = sbl; i <= sbl_d; i++) { - // set the iterator to the first item in the sublevel needing redrawing - it = menuitems.begin() + (id + (i * menu.persub)); - for (int ii = id; ii <= id_d && it != end; ++it, ii++) { - const int index = ii + (i * menu.persub); - // redraw the item - drawItem(index, (which_sub == index), False, - ee->x, ee->y, ee->width, ee->height); - } - } - } -} - - -void Basemenu::enterNotifyEvent(XCrossingEvent *ce) { - if (ce->window == menu.frame) { - menu.x_shift = menu.x, menu.y_shift = menu.y; - if (menu.x + menu.width > screen->getWidth()) { - menu.x_shift = screen->getWidth() - menu.width - - screen->getBorderWidth(); - shifted = True; - } else if (menu.x < 0) { - menu.x_shift = -screen->getBorderWidth(); - shifted = True; - } - - if (menu.y + menu.height > screen->getHeight()) { - menu.y_shift = screen->getHeight() - menu.height - - screen->getBorderWidth(); - shifted = True; - } else if (menu.y + static_cast(menu.title_h) < 0) { - menu.y_shift = -screen->getBorderWidth(); - shifted = True; - } - - if (shifted) - XMoveWindow(display, menu.window, menu.x_shift, menu.y_shift); - - if (which_sub != -1) { - BasemenuItem *tmp = find(which_sub); - if (tmp->submenu()->isVisible()) { - const int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h), - w = (sbl * menu.persub) + i; - - if (w != which_sub && ! tmp->submenu()->isTorn()) { - tmp->submenu()->internal_hide(); - - drawItem(which_sub, False, True); - which_sub = -1; - } - } - } - } -} - - -void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) { - if (ce->window == menu.frame) { - if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) { - const int p = (which_sbl * menu.persub) + which_press; - - drawItem(p, (p == which_sub), True); - - which_sbl = which_press = -1; - } - - if (shifted) { - XMoveWindow(display, menu.window, menu.x, menu.y); - shifted = False; - - if (which_sub != -1) drawSubmenu(which_sub); - } - } -} - - -void Basemenu::reconfigure(void) { - XSetWindowBackground(display, menu.window, - screen->getBorderColor()->pixel()); - XSetWindowBorder(display, menu.window, - screen->getBorderColor()->pixel()); - XSetWindowBorderWidth(display, menu.window, screen->getBorderWidth()); - - menu.bevel_w = screen->getBevelWidth(); - update(); -} - - -void Basemenu::changeItemLabel(unsigned int index, const string& label) { - BasemenuItem *item = find(index); - if (item) - item->newLabel(label); -} diff --git a/src/Basemenu.hh b/src/Basemenu.hh deleted file mode 100644 index 09c26028..00000000 --- a/src/Basemenu.hh +++ /dev/null @@ -1,178 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Basemenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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. - -#ifndef __Basemenu_hh -#define __Basemenu_hh - -extern "C" { -#include -} - -#include -#include - -class Blackbox; -class BImageControl; -class BScreen; -class BasemenuItem; - - -class Basemenu { -private: - typedef std::vector MenuItems; - MenuItems menuitems; - Blackbox *blackbox; - Basemenu *parent; - BImageControl *image_ctrl; - BScreen *screen; - - bool moving, visible, movable, torn, internal_menu, title_vis, shifted, - hide_tree; - Display *display; - int which_sub, which_press, which_sbl, alignment; - - struct _menu { - Pixmap frame_pixmap, title_pixmap, hilite_pixmap; - Window window, frame, title; - - std::string label; - int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub; - unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w, - bevel_h; - } menu; - - Basemenu(const Basemenu&); - Basemenu& operator=(const Basemenu&); - -protected: - inline void setTitleVisibility(bool b) { title_vis = b; } - inline void setMovable(bool b) { movable = b; } - inline void setHideTree(bool h) { hide_tree = h; } - inline void setMinimumSublevels(int m) { menu.minsub = m; } - - virtual void itemSelected(int button, unsigned int index) = 0; - virtual void drawItem(int index, bool highlight = False, bool clear = False, - int x = -1, int y = -1, - unsigned int w = 0, unsigned int h = 0); - virtual void redrawTitle(void); - virtual void internal_hide(void); - - -public: - Basemenu(BScreen *scrn); - virtual ~Basemenu(void); - - inline bool isTorn(void) const { return torn; } - inline bool isVisible(void) const { return visible; } - - inline BScreen *getScreen(void) { return screen; } - - inline Window getWindowID(void) const { return menu.window; } - - inline const char *getLabel(void) const { return menu.label.c_str(); } - - int insert(BasemenuItem *item, int pos); - int insert(const std::string& label, int function = 0, - const std::string& exec = "", int pos = -1); - int insert(const std::string &label, Basemenu *submenu, int pos = -1); - int remove(int index); - - void changeItemLabel(unsigned int index, const std::string& label); - - inline int getX(void) const { return menu.x; } - inline int getY(void) const { return menu.y; } - inline unsigned int getCount(void) { return menuitems.size(); } - inline int getCurrentSubmenu(void) const { return which_sub; } - BasemenuItem *find(int index); - - inline unsigned int getWidth(void) const { return menu.width; } - inline unsigned int getHeight(void) const { return menu.height; } - inline unsigned int getTitleHeight(void) const - { return menu.title_h; } - - inline void setInternalMenu(void) { internal_menu = True; } - inline void setAlignment(int a) { alignment = a; } - inline void setTorn(void) { torn = True; } - inline void removeParent(void) - { if (internal_menu) parent = (Basemenu *) 0; } - - bool hasSubmenu(int index); - bool isItemSelected(int index); - bool isItemEnabled(int index); - - void buttonPressEvent(XButtonEvent *be); - void buttonReleaseEvent(XButtonEvent *be); - void motionNotifyEvent(XMotionEvent *me); - void enterNotifyEvent(XCrossingEvent *ce); - void leaveNotifyEvent(XCrossingEvent *ce); - void exposeEvent(XExposeEvent *ee); - void reconfigure(void); - void setLabel(const std::string& label); - void move(int x, int y); - void update(void); - void setItemSelected(int index, bool sel); - void setItemEnabled(int index, bool enable); - - virtual void drawSubmenu(int index); - virtual void show(void); - virtual void hide(void); - - enum { AlignDontCare = 1, AlignTop, AlignBottom }; - enum { Right = 1, Left }; - enum { Empty = 0, Square, Triangle, Diamond }; -}; - - -class BasemenuItem { -private: - Basemenu *sub; - std::string l, e; - int f, enabled, selected; - - friend class Basemenu; - -protected: - -public: - BasemenuItem(const std::string& lp, int fp = 0, const std::string& ep = ""): - sub(0), l(lp), e(ep), f(fp), enabled(1), selected(0) {} - - BasemenuItem(const std::string& lp, Basemenu *mp): sub(mp), l(lp), - f(0), enabled(1), - selected(0) {} - - inline const char *exec(void) const { return e.c_str(); } - inline const char *label(void) const { return l.c_str(); } - inline int function(void) const { return f; } - inline Basemenu *submenu(void) { return sub; } - - inline void newLabel(const std::string& label) { l = label; } - - inline int isEnabled(void) const { return enabled; } - inline void setEnabled(int e) { enabled = e; } - inline int isSelected(void) const { return selected; } - inline void setSelected(int s) { selected = s; } -}; - - -#endif // __Basemenu_hh diff --git a/src/Clientmenu.cc b/src/Clientmenu.cc deleted file mode 100644 index 07f70439..00000000 --- a/src/Clientmenu.cc +++ /dev/null @@ -1,59 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Clientmenu.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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" -#endif // HAVE_CONFIG_H - -#include "blackbox.hh" -#include "Clientmenu.hh" -#include "Screen.hh" -#include "Window.hh" -#include "Workspace.hh" -#include "Workspacemenu.hh" - - -Clientmenu::Clientmenu(Workspace *ws) : Basemenu(ws->getScreen()) { - wkspc = ws; - - setInternalMenu(); -} - - -void Clientmenu::itemSelected(int button, unsigned int index) { - if (button > 2) return; - - BlackboxWindow *win = wkspc->getWindow(index); - if (win) { - if (button == 1) { - if (! wkspc->isCurrent()) wkspc->setCurrent(); - } else if (button == 2) { - if (! wkspc->isCurrent()) win->deiconify(True, False); - } - wkspc->raiseWindow(win); - win->setInputFocus(); - } - - Workspacemenu* wkspcmenu = wkspc->getScreen()->getWorkspacemenu(); - if (! (wkspcmenu->isTorn() || isTorn())) hide(); -} diff --git a/src/Clientmenu.hh b/src/Clientmenu.hh deleted file mode 100644 index 70cc2aa0..00000000 --- a/src/Clientmenu.hh +++ /dev/null @@ -1,47 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Clientmenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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. - -#ifndef __Clientmenu_hh -#define __Clientmenu_hh - -#include "Basemenu.hh" -class Workspace; -class BScreen; - -class Clientmenu : public Basemenu { -private: - Workspace *wkspc; - - Clientmenu(const Clientmenu&); - Clientmenu& operator=(const Clientmenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - -public: - Clientmenu(Workspace *ws); -}; - - -#endif // __Clientmenu_hh - diff --git a/src/Configmenu.cc b/src/Configmenu.cc deleted file mode 100644 index fbb2c66a..00000000 --- a/src/Configmenu.cc +++ /dev/null @@ -1,615 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -// Configmenu.cc for Blackbox - An X11 Window Manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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" -#endif // HAVE_CONFIG_H - -#include "i18n.hh" -#include "Configmenu.hh" -#include "Image.hh" -#include "Toolbar.hh" -#include "Window.hh" -#include "Screen.hh" - -Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) { - setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions, "Config Options")); - setInternalMenu(); - - focusmenu = new Focusmenu(this); - placementmenu = new Placementmenu(this); - windowsnapmenu = new WindowToWindowSnapmenu(this); - edgesnapmenu = new WindowToEdgeSnapmenu(this); -#ifdef XINERAMA - xineramamenu = new Xineramamenu(this); -#endif // XINERAMA -#ifdef XFT - xftmenu = new Xftmenu(this); -#endif // XFT - - insert(i18n(ConfigmenuSet, ConfigmenuFocusModel, - "Focus Model"), focusmenu); - insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement, - "Window Placement"), placementmenu); - insert(i18n(ConfigmenuSet, ConfigmenuWindowToWindowSnap, - "Window-To-Window Snapping"), windowsnapmenu); - insert(i18n(ConfigmenuSet, ConfigmenuWindowToEdgeSnap, - "Window-To-Edge Snapping"), edgesnapmenu); -#ifdef XINERAMA - insert(i18n(ConfigmenuSet, ConfigmenuXineramaSupport, - "XineramaSupport"), xineramamenu); -#endif // XINERAMA -#ifdef XFT - insert(i18n(ConfigmenuSet, ConfigmenuXftOptions, - "Xft Font Options"), xftmenu); -#endif // XINERAMA - insert(i18n(ConfigmenuSet, ConfigmenuImageDithering, - "Image Dithering"), 1); - insert(i18n(ConfigmenuSet, ConfigmenuOpaqueMove, - "Opaque Window Moving"), 2); - insert(i18n(ConfigmenuSet, ConfigmenuWorkspaceWarping, - "Workspace Warping"), 3); - insert(i18n(ConfigmenuSet, ConfigmenuFullMax, - "Full Maximization"), 4); - insert(i18n(ConfigmenuSet, ConfigmenuFocusNew, - "Focus New Windows"), 5); - insert(i18n(ConfigmenuSet, ConfigmenuFocusLast, - "Focus Last Window on Workspace"), 6); - insert(i18n(ConfigmenuSet, ConfigmenuDisableBindings, - "Disable Mouse with Scroll Lock"), 7); - insert(i18n(ConfigmenuSet, ConfigmenuHideToolbar, - "Hide Toolbar"), 8); - update(); - setValues(); -} - - -void Configmenu::setValues(void) { - int index = 4; -#ifdef XINERAMA - ++index; -#endif // XINERAMA -#ifdef XFT - ++index; -#endif // XFT - setItemSelected(index++, getScreen()->doImageDither()); - setItemSelected(index++, getScreen()->doOpaqueMove()); - setItemSelected(index++, getScreen()->doWorkspaceWarping()); - setItemSelected(index++, getScreen()->doFullMax()); - setItemSelected(index++, getScreen()->doFocusNew()); - setItemSelected(index++, getScreen()->doFocusLast()); - setItemSelected(index++, getScreen()->allowScrollLock()); - setItemSelected(index++, getScreen()->doHideToolbar()); -} - - -Configmenu::~Configmenu(void) { - delete focusmenu; - delete placementmenu; - delete windowsnapmenu; - delete edgesnapmenu; -#ifdef XINERAMA - delete xineramamenu; -#endif // XINERAMA -#ifdef XFT - delete xftmenu; -#endif // XFT -} - - -void Configmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - switch(item->function()) { - case 1: // dither - getScreen()->saveImageDither(! getScreen()->doImageDither()); - setItemSelected(index, getScreen()->doImageDither()); - break; - - case 2: // opaque move - getScreen()->saveOpaqueMove(! getScreen()->doOpaqueMove()); - setItemSelected(index, getScreen()->doOpaqueMove()); - break; - - case 3: // workspace wrapping - getScreen()->saveWorkspaceWarping(! getScreen()->doWorkspaceWarping()); - setItemSelected(index, getScreen()->doWorkspaceWarping()); - break; - - case 4: // full maximization - getScreen()->saveFullMax(! getScreen()->doFullMax()); - setItemSelected(index, getScreen()->doFullMax()); - break; - - case 5: // focus new windows - getScreen()->saveFocusNew(! getScreen()->doFocusNew()); - setItemSelected(index, getScreen()->doFocusNew()); - break; - - case 6: // focus last window on workspace - getScreen()->saveFocusLast(! getScreen()->doFocusLast()); - setItemSelected(index, getScreen()->doFocusLast()); - break; - - case 7: // disable mouse bindings with Scroll Lock - getScreen()->saveAllowScrollLock(! getScreen()->allowScrollLock()); - setItemSelected(index, getScreen()->allowScrollLock()); - getScreen()->reconfigure(); - break; - - case 8: // hide toolbar - getScreen()->saveHideToolbar(! getScreen()->doHideToolbar()); - setItemSelected(index, getScreen()->doHideToolbar()); - break; - } -} - - -void Configmenu::reconfigure(void) { - setValues(); - focusmenu->reconfigure(); - placementmenu->reconfigure(); - windowsnapmenu->reconfigure(); - edgesnapmenu->reconfigure(); -#ifdef XINERAMA - xineramamenu->reconfigure(); -#endif // XINERAMA -#ifdef XFT - xftmenu->reconfigure(); -#endif // XFT - - Basemenu::reconfigure(); -} - - -Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->getScreen()) { - setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel, "Focus Model")); - setInternalMenu(); - - insert(i18n(ConfigmenuSet, ConfigmenuClickToFocus, "Click To Focus"), 1); - insert(i18n(ConfigmenuSet, ConfigmenuSloppyFocus, "Sloppy Focus"), 2); - insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise, "Auto Raise"), 3); - insert(i18n(ConfigmenuSet, ConfigmenuClickRaise, "Click Raise"), 4); - update(); - setValues(); -} - - -void Configmenu::Focusmenu::setValues(void) { - setItemSelected(0, ! getScreen()->isSloppyFocus()); - setItemSelected(1, getScreen()->isSloppyFocus()); - setItemEnabled(2, getScreen()->isSloppyFocus()); - setItemSelected(2, getScreen()->doAutoRaise()); - setItemEnabled(3, getScreen()->isSloppyFocus()); - setItemSelected(3, getScreen()->doClickRaise()); -} - - -void Configmenu::Focusmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - switch (item->function()) { - case 1: // click to focus - getScreen()->toggleFocusModel(BScreen::ClickToFocus); - break; - - case 2: // sloppy focus - getScreen()->toggleFocusModel(BScreen::SloppyFocus); - break; - - case 3: // auto raise with sloppy focus - getScreen()->saveAutoRaise(! getScreen()->doAutoRaise()); - break; - - case 4: // click raise with sloppy focus - getScreen()->saveClickRaise(! getScreen()->doClickRaise()); - // make sure the appropriate mouse buttons are grabbed on the windows - getScreen()->toggleFocusModel(BScreen::SloppyFocus); - break; - } - setValues(); -} - - -Configmenu::Placementmenu::Placementmenu(Configmenu *cm): - Basemenu(cm->getScreen()) { - setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement, "Window Placement")); - setInternalMenu(); - - insert(i18n(ConfigmenuSet, ConfigmenuSmartRows, "Smart Placement (Rows)"), - BScreen::RowSmartPlacement); - insert(i18n(ConfigmenuSet, ConfigmenuSmartCols, "Smart Placement (Columns)"), - BScreen::ColSmartPlacement); - insert(i18n(ConfigmenuSet, ConfigmenuCascade, "Cascade Placement"), - BScreen::CascadePlacement); - insert(i18n(ConfigmenuSet, ConfigmenuUnderMouse, "Under Mouse Placement"), - BScreen::UnderMousePlacement); - insert(i18n(ConfigmenuSet, ConfigmenuClickMouse, "Click Mouse Placement"), - BScreen::ClickMousePlacement); - insert(i18n(ConfigmenuSet, ConfigmenuLeftRight, "Left to Right"), - BScreen::LeftRight); - insert(i18n(ConfigmenuSet, ConfigmenuRightLeft, "Right to Left"), - BScreen::RightLeft); - insert(i18n(ConfigmenuSet, ConfigmenuTopBottom, "Top to Bottom"), - BScreen::TopBottom); - insert(i18n(ConfigmenuSet, ConfigmenuBottomTop, "Bottom to Top"), - BScreen::BottomTop); - insert(i18n(ConfigmenuSet, ConfigmenuIgnoreShaded, "Ignore Shaded Windows"), - BScreen::IgnoreShaded); - insert(i18n(ConfigmenuSet, ConfigmenuIgnoreMax, - "Ignore Full-Maximized Windows"), - BScreen::IgnoreMaximized); - update(); - setValues(); -} - - -void Configmenu::Placementmenu::setValues(void) { - int placement = getScreen()->getPlacementPolicy(); - - setItemSelected(0, placement == BScreen::RowSmartPlacement); - setItemSelected(1, placement == BScreen::ColSmartPlacement); - setItemSelected(2, placement == BScreen::CascadePlacement); - setItemSelected(3, placement == BScreen::UnderMousePlacement); - setItemSelected(4, placement == BScreen::ClickMousePlacement); - - bool rl = (getScreen()->getRowPlacementDirection() == BScreen::LeftRight), - tb = (getScreen()->getColPlacementDirection() == BScreen::TopBottom), - e = (placement == BScreen::RowSmartPlacement || - placement == BScreen::ColSmartPlacement); - - setItemSelected(5, rl); - setItemSelected(6, ! rl); - setItemEnabled(5, e); - setItemEnabled(6, e); - - setItemSelected(7, tb); - setItemSelected(8, ! tb); - setItemEnabled(7, e); - setItemEnabled(8, e); - - setItemSelected(9, getScreen()->getPlaceIgnoreShaded()); - setItemSelected(10, getScreen()->getPlaceIgnoreMaximized()); - setItemEnabled(9, e); - setItemEnabled(10, e); -} - - -void Configmenu::Placementmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - switch (item->function()) { - case BScreen::RowSmartPlacement: - getScreen()->savePlacementPolicy(item->function()); - break; - - case BScreen::ColSmartPlacement: - getScreen()->savePlacementPolicy(item->function()); - break; - - case BScreen::CascadePlacement: - getScreen()->savePlacementPolicy(item->function()); - break; - - case BScreen::UnderMousePlacement: - getScreen()->savePlacementPolicy(item->function()); - break; - - case BScreen::ClickMousePlacement: - getScreen()->savePlacementPolicy(item->function()); - break; - - case BScreen::LeftRight: - getScreen()->saveRowPlacementDirection(BScreen::LeftRight); - break; - - case BScreen::RightLeft: - getScreen()->saveRowPlacementDirection(BScreen::RightLeft); - break; - - case BScreen::TopBottom: - getScreen()->saveColPlacementDirection(BScreen::TopBottom); - break; - - case BScreen::BottomTop: - getScreen()->saveColPlacementDirection(BScreen::BottomTop); - break; - - case BScreen::IgnoreShaded: - getScreen()->savePlaceIgnoreShaded(! getScreen()->getPlaceIgnoreShaded()); - break; - - case BScreen::IgnoreMaximized: - getScreen()-> - savePlaceIgnoreMaximized(! getScreen()->getPlaceIgnoreMaximized()); - break; - } - setValues(); -} - - -Configmenu::WindowToWindowSnapmenu::WindowToWindowSnapmenu(Configmenu *cm) : - Basemenu(cm->getScreen()) { - setLabel(i18n(ConfigmenuSet, ConfigmenuWindowToWindowSnap, - "Window-To-Window Snapping")); - setInternalMenu(); - - insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnapNo, "No Snapping"), 1); - insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnap, "Edge Snapping"), 2); - insert(i18n(ConfigmenuSet, ConfigmenuWindowDoResistance, - "Edge Resistance"), 3); - insert(i18n(ConfigmenuSet, ConfigmenuWindowCornerSnap, - "Window Corner Snapping"), 4); - update(); - setValues(); -} - - -void Configmenu::WindowToWindowSnapmenu::setValues(void) { - setItemSelected(0, (getScreen()->getWindowToWindowSnap() == - BScreen::WindowNoSnap)); - setItemSelected(1, (getScreen()->getWindowToWindowSnap() == - BScreen::WindowSnap)); - setItemSelected(2, (getScreen()->getWindowToWindowSnap() == - BScreen::WindowResistance)); - - setItemEnabled(3, getScreen()->getWindowToWindowSnap()); - setItemSelected(3, getScreen()->getWindowCornerSnap()); -} - - -void Configmenu::WindowToWindowSnapmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Configmenu::WindowToWindowSnapmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - switch (item->function()) { - case 1: // none - getScreen()->saveWindowToWindowSnap(BScreen::WindowNoSnap); - break; - - case 2: // edge snapping - getScreen()->saveWindowToWindowSnap(BScreen::WindowSnap); - break; - - case 3: // edge resistance - getScreen()->saveWindowToWindowSnap(BScreen::WindowResistance); - break; - - case 4: // window corner snapping - getScreen()->saveWindowCornerSnap(! getScreen()->getWindowCornerSnap()); - break; - - } - setValues(); -} - - -Configmenu::WindowToEdgeSnapmenu::WindowToEdgeSnapmenu(Configmenu *cm) : - Basemenu(cm->getScreen()) { - setLabel(i18n(ConfigmenuSet, ConfigmenuWindowToEdgeSnap, - "Window-To-Edge Snapping")); - setInternalMenu(); - - insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnapNo, "No Snapping"), 1); - insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnap, "Edge Snapping"), 2); - insert(i18n(ConfigmenuSet, ConfigmenuWindowDoResistance, - "Edge Resistance"), 3); - update(); - setValues(); -} - - -void Configmenu::WindowToEdgeSnapmenu::setValues(void) { - setItemSelected(0, (getScreen()->getWindowToEdgeSnap() == - BScreen::WindowNoSnap)); - setItemSelected(1, (getScreen()->getWindowToEdgeSnap() == - BScreen::WindowSnap)); - setItemSelected(2, (getScreen()->getWindowToEdgeSnap() == - BScreen::WindowResistance)); -} - - -void Configmenu::WindowToEdgeSnapmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Configmenu::WindowToEdgeSnapmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - switch (item->function()) { - case 1: // none - getScreen()->saveWindowToEdgeSnap(BScreen::WindowNoSnap); - break; - - case 2: // edge snapping - getScreen()->saveWindowToEdgeSnap(BScreen::WindowSnap); - break; - - case 3: // edge resistance - getScreen()->saveWindowToEdgeSnap(BScreen::WindowResistance); - break; - } - setValues(); -} - - -#ifdef XINERAMA -Configmenu::Xineramamenu::Xineramamenu(Configmenu *cm): - Basemenu(cm->getScreen()) { - setLabel(i18n(ConfigmenuSet, ConfigmenuXineramaSupport, "Xinerama Support")); - setInternalMenu(); - - insert(i18n(ConfigmenuSet, ConfigmenuXineramaPlacement, "Window Placement"), - 1); - insert(i18n(ConfigmenuSet, ConfigmenuXineramaMaximizing, "Window Maximizing"), - 2); - insert(i18n(ConfigmenuSet, ConfigmenuXineramaSnapping, "Window Snapping"), - 3); - - update(); - setValues(); -} - - -void Configmenu::Xineramamenu::setValues(void) { - setItemSelected(0, getScreen()->getBlackbox()->doXineramaPlacement()); - setItemSelected(1, getScreen()->getBlackbox()->doXineramaMaximizing()); - setItemSelected(2, getScreen()->getBlackbox()->doXineramaSnapping()); -} - - -void Configmenu::Xineramamenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Configmenu::Xineramamenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - Blackbox *bb = getScreen()->getBlackbox(); - - switch (item->function()) { - case 1: // window placement - bb->saveXineramaPlacement(! bb->doXineramaPlacement()); - setItemSelected(0, bb->doXineramaPlacement()); - break; - - case 2: // window maximizing - bb->saveXineramaMaximizing(! bb->doXineramaMaximizing()); - setItemSelected(1, bb->doXineramaMaximizing()); - break; - - case 3: // window snapping - bb->saveXineramaSnapping(! bb->doXineramaSnapping()); - setItemSelected(2, bb->doXineramaSnapping()); - break; - } -} -#endif // XINERAMA - -#ifdef XFT -Configmenu::Xftmenu::Xftmenu(Configmenu *cm): - Basemenu(cm->getScreen()) { - setLabel(i18n(ConfigmenuSet, ConfigmenuXftOptions, "Xft Font Options")); - setInternalMenu(); - - insert(i18n(ConfigmenuSet, ConfigmenuXftAA, "Anti-Alias Text"), 1); - insert(i18n(ConfigmenuSet, ConfigmenuXftShadow, "Drop Shadows Under Text"), - 2); - - update(); - setValues(); -} - - -void Configmenu::Xftmenu::setValues(void) { - setItemSelected(0, getScreen()->doAAFonts()); - setItemEnabled(1, getScreen()->doAAFonts()); - setItemSelected(1, getScreen()->doShadowFonts()); -} - - -void Configmenu::Xftmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Configmenu::Xftmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - switch (item->function()) { - case 1: // anti-alias text - getScreen()->saveAAFonts(! getScreen()->doAAFonts()); - break; - - case 2: // drop shadows - getScreen()->saveShadowFonts(! getScreen()->doShadowFonts()); - break; - } - - setValues(); -} -#endif // XFT diff --git a/src/Configmenu.hh b/src/Configmenu.hh deleted file mode 100644 index 081e397f..00000000 --- a/src/Configmenu.hh +++ /dev/null @@ -1,163 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Configmenu.hh for Blackbox - An X11 Window Manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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. - -#ifndef __Configmenu_hh -#define __Configmenu_hh - -#include "Basemenu.hh" - -// forward declaration -class Blackbox; -class BScreen; -class Configmenu; - -class Configmenu : public Basemenu { -private: - class Focusmenu : public Basemenu { - private: - Focusmenu(const Focusmenu&); - Focusmenu& operator=(const Focusmenu&); - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - Focusmenu(Configmenu *cm); - virtual void reconfigure(void); - }; - - class Placementmenu : public Basemenu { - private: - Placementmenu(const Placementmenu&); - Placementmenu& operator=(const Placementmenu&); - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - Placementmenu(Configmenu *cm); - virtual void reconfigure(void); - }; - - class WindowToWindowSnapmenu : public Basemenu { - private: - WindowToWindowSnapmenu(const WindowToWindowSnapmenu&); - WindowToWindowSnapmenu& operator=(const WindowToWindowSnapmenu&); - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - WindowToWindowSnapmenu(Configmenu *cm); - virtual void reconfigure(void); - }; - - class WindowToEdgeSnapmenu : public Basemenu { - private: - WindowToEdgeSnapmenu(const WindowToEdgeSnapmenu&); - WindowToEdgeSnapmenu& operator=(const WindowToEdgeSnapmenu&); - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - WindowToEdgeSnapmenu(Configmenu *cm); - virtual void reconfigure(void); - }; - -#ifdef XINERAMA - class Xineramamenu : public Basemenu { - private: - Xineramamenu(const Xineramamenu&); - Xineramamenu& operator=(const Xineramamenu&); - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - Xineramamenu(Configmenu *cm); - virtual void reconfigure(void); - }; -#endif // XINERAMA - -#ifdef XFT - class Xftmenu : public Basemenu { - private: - Xftmenu(const Xftmenu&); - Xftmenu& operator=(const Xftmenu&); - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - Xftmenu(Configmenu *cm); - virtual void reconfigure(void); - }; -#endif // XFT - - Focusmenu *focusmenu; - Placementmenu *placementmenu; - WindowToWindowSnapmenu *windowsnapmenu; - WindowToEdgeSnapmenu *edgesnapmenu; -#ifdef XINERAMA - Xineramamenu *xineramamenu; -#endif // XINERAMA -#ifdef XFT - Xftmenu *xftmenu; -#endif // XFT - -// friend class Focusmenu; -// friend class Placementmenu; - - Configmenu(const Configmenu&); - Configmenu& operator=(const Configmenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - -public: - Configmenu(BScreen *scr); - virtual ~Configmenu(void); - - inline Basemenu *getFocusmenu(void) { return focusmenu; } - inline Basemenu *getPlacementmenu(void) { return placementmenu; } - inline Basemenu *getWindowSnapmenu(void) { return windowsnapmenu; } - inline Basemenu *getEdgeSnapmenu(void) { return edgesnapmenu; } -#ifdef XINERAMA - inline Basemenu *getXineramamenu(void) { return xineramamenu; } -#endif // XINERAMA -#ifdef XFT - inline Basemenu *getXftmenu(void) { return xftmenu; } -#endif // XFT - - virtual void reconfigure(void); -}; - -#endif // __Configmenu_hh diff --git a/src/Iconmenu.cc b/src/Iconmenu.cc deleted file mode 100644 index dba587a2..00000000 --- a/src/Iconmenu.cc +++ /dev/null @@ -1,57 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Icon.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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" -#endif // HAVE_CONFIG_H - -#include "i18n.hh" -#include "Iconmenu.hh" -#include "Screen.hh" -#include "Window.hh" - - -Iconmenu::Iconmenu(BScreen *scrn) : Basemenu(scrn) { - setInternalMenu(); - - setLabel(i18n(IconSet, IconIcons, "Icons")); - update(); -} - - -void Iconmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - if (index < getScreen()->getIconCount()) { - BlackboxWindow *win = getScreen()->getIcon(index); - - if (win) { - win->deiconify(); - win->setInputFocus(); - } - } - - if (! (getScreen()->getWorkspacemenu()->isTorn() || isTorn())) - hide(); -} diff --git a/src/Iconmenu.hh b/src/Iconmenu.hh deleted file mode 100644 index 1747e79a..00000000 --- a/src/Iconmenu.hh +++ /dev/null @@ -1,46 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Icon.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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. - -#ifndef __Icon_hh -#define __Icon_hh - -#include "Basemenu.hh" - -// forward declaration -class Iconmenu; -class BScreen; - -class Iconmenu : public Basemenu { -private: - Iconmenu(const Iconmenu&); - Iconmenu& operator=(const Iconmenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - -public: - Iconmenu(BScreen *scrn); -}; - - -#endif // __Icon_hh diff --git a/src/Rootmenu.cc b/src/Rootmenu.cc deleted file mode 100644 index 3395b4f7..00000000 --- a/src/Rootmenu.cc +++ /dev/null @@ -1,96 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Rootmenu.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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" -#endif // HAVE_CONFIG_H - -extern "C" { -#ifdef HAVE_STDIO_H -# include -#endif // HAVE_STDIO_H - -#ifdef HAVE_STDLIB_H -# include -#endif // HAVE_STDLIB_H - -#ifdef HAVE_STRING_H -# include -#endif // HAVE_STRING_H - -#ifdef HAVE_SYS_PARAM_H -# include -#endif // HAVE_SYS_PARAM_H -} - -#include "blackbox.hh" -#include "Rootmenu.hh" -#include "Screen.hh" -#include "Util.hh" - - -Rootmenu::Rootmenu(BScreen *scrn) : Basemenu(scrn) { } - - -void Rootmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - if (! item->function()) - return; - - if (! (getScreen()->getRootmenu()->isTorn() || isTorn()) && - item->function() != BScreen::Reconfigure && - item->function() != BScreen::SetStyle) - hide(); - - switch (item->function()) { - case BScreen::Execute: - if (item->exec()) - bexec(item->exec(), getScreen()->displayString()); - break; - - case BScreen::Restart: - getScreen()->getBlackbox()->restart(); - break; - - case BScreen::RestartOther: - if (item->exec()) - getScreen()->getBlackbox()->restart(item->exec()); - break; - - case BScreen::Exit: - getScreen()->getBlackbox()->shutdown(); - break; - - case BScreen::SetStyle: - if (item->exec()) - getScreen()->getBlackbox()->saveStyleFilename(item->exec()); - - case BScreen::Reconfigure: - getScreen()->getBlackbox()->reconfigure(); - return; - } -} diff --git a/src/Rootmenu.hh b/src/Rootmenu.hh deleted file mode 100644 index e436397d..00000000 --- a/src/Rootmenu.hh +++ /dev/null @@ -1,47 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Rootmenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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. - -#ifndef __Rootmenu_hh -#define __Rootmenu_hh - -// forward declarations -class BScreen; - -#include "Basemenu.hh" - - -class Rootmenu : public Basemenu { -private: - Rootmenu(const Rootmenu&); - Rootmenu& operator=(const Rootmenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - -public: - Rootmenu(BScreen *scrn); -}; - - -#endif // __Rootmenu_hh - diff --git a/src/Windowmenu.cc b/src/Windowmenu.cc deleted file mode 100644 index c49a6f91..00000000 --- a/src/Windowmenu.cc +++ /dev/null @@ -1,208 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Windowmenu.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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" -#endif // HAVE_CONFIG_H - -extern "C" { -#ifdef HAVE_STRING_H -# include -#endif // HAVE_STRING_H -} - -#include "i18n.hh" -#include "blackbox.hh" -#include "Screen.hh" -#include "Window.hh" -#include "Windowmenu.hh" -#include "Workspace.hh" - - -Windowmenu::Windowmenu(BlackboxWindow *win) : Basemenu(win->getScreen()) { - window = win; - - setTitleVisibility(False); - setMovable(False); - setInternalMenu(); - - sendToMenu = new SendtoWorkspacemenu(this); - insert(i18n(WindowmenuSet, WindowmenuSendTo, "Send To ..."), - sendToMenu); - insert(i18n(WindowmenuSet, WindowmenuShade, "Shade"), - BScreen::WindowShade); - insert(i18n(WindowmenuSet, WindowmenuIconify, "Iconify"), - BScreen::WindowIconify); - insert(i18n(WindowmenuSet, WindowmenuMaximize, "Maximize"), - BScreen::WindowMaximize); - insert(i18n(WindowmenuSet, WindowmenuRaise,"Raise"), - BScreen::WindowRaise); - insert(i18n(WindowmenuSet, WindowmenuLower, "Lower"), - BScreen::WindowLower); - insert(i18n(WindowmenuSet, WindowmenuStick, "Stick"), - BScreen::WindowStick); - insert(i18n(WindowmenuSet, WindowmenuKillClient, "Kill Client"), - BScreen::WindowKill); - insert(i18n(WindowmenuSet, WindowmenuClose, "Close"), - BScreen::WindowClose); - - update(); - - setItemEnabled(1, window->hasTitlebar()); - setItemEnabled(2, window->isIconifiable()); - setItemEnabled(3, window->isMaximizable()); - setItemEnabled(8, window->isClosable()); -} - - -Windowmenu::~Windowmenu(void) { - delete sendToMenu; -} - - -void Windowmenu::show(void) { - if (isItemEnabled(1)) setItemSelected(1, window->isShaded()); - if (isItemEnabled(3)) setItemSelected(3, window->isMaximized()); - if (isItemEnabled(6)) setItemSelected(6, window->isStuck()); - - Basemenu::show(); -} - - -void Windowmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - - hide(); - switch (item->function()) { - case BScreen::WindowShade: - window->shade(); - break; - - case BScreen::WindowIconify: - window->iconify(); - break; - - case BScreen::WindowMaximize: - window->maximize(1); // full maximize - break; - - case BScreen::WindowClose: - window->close(); - break; - - case BScreen::WindowRaise: { - Workspace *wkspc = - getScreen()->getWorkspace(window->getWorkspaceNumber()); - wkspc->raiseWindow(window); - } - break; - - case BScreen::WindowLower: { - Workspace *wkspc = - getScreen()->getWorkspace(window->getWorkspaceNumber()); - wkspc->lowerWindow(window); - } - break; - - case BScreen::WindowStick: - window->stick(); - break; - - case BScreen::WindowKill: - XKillClient(getScreen()->getBaseDisplay()->getXDisplay(), - window->getClientWindow()); - break; - } -} - - -void Windowmenu::reconfigure(void) { - setItemEnabled(1, window->hasTitlebar()); - setItemEnabled(2, window->isIconifiable()); - setItemEnabled(3, window->isMaximizable()); - setItemEnabled(8, window->isClosable()); - - sendToMenu->reconfigure(); - - Basemenu::reconfigure(); -} - - -Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu *w) - : Basemenu(w->getScreen()) { - - window = w->window; - - setTitleVisibility(False); - setMovable(False); - setInternalMenu(); - update(); -} - - -void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, - unsigned int index) { - if (button > 2) return; - - if (index <= getScreen()->getWorkspaceCount()) { - if (index == getScreen()->getCurrentWorkspaceID()) return; - if (window->isStuck()) window->stick(); - - if (button == 1) window->withdraw(); - getScreen()->reassociateWindow(window, index, True); - if (button == 2) getScreen()->changeWorkspaceID(index); - } - hide(); -} - - -void Windowmenu::SendtoWorkspacemenu::update(void) { - unsigned int i, r = getCount(), - workspace_count = getScreen()->getWorkspaceCount(); - while (r > workspace_count) { - remove(0); - r = getCount(); - } - - for (i = 0; i < workspace_count; ++i) { - if (r < workspace_count) { - insert(getScreen()->getWorkspace(i)->getName()); - ++r; - } else { - changeItemLabel(i, getScreen()->getWorkspace(i)->getName()); - setItemEnabled(i, i != getScreen()->getCurrentWorkspaceID()); - } - } - - Basemenu::update(); -} - - -void Windowmenu::SendtoWorkspacemenu::show(void) { - update(); - - Basemenu::show(); -} diff --git a/src/Windowmenu.hh b/src/Windowmenu.hh deleted file mode 100644 index 26c51457..00000000 --- a/src/Windowmenu.hh +++ /dev/null @@ -1,79 +0,0 @@ -// Windowmenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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. - -#ifndef __Windowmenu_hh -#define __Windowmenu_hh - -#include "Basemenu.hh" - -// forward declaration -class Windowmenu; -class SendtoWorkspaceMenu; - -class BlackboxWindow; - -class Windowmenu : public Basemenu { -private: - BlackboxWindow *window; - - class SendtoWorkspacemenu : public Basemenu { - private: - BlackboxWindow *window; - SendtoWorkspacemenu(const SendtoWorkspacemenu&); - SendtoWorkspacemenu& operator=(const SendtoWorkspacemenu&); - - protected: - virtual void itemSelected(int button, unsigned int index); - - public: - SendtoWorkspacemenu(Windowmenu *w); - - void update(void); - - virtual void show(void); - }; - - SendtoWorkspacemenu *sendToMenu; - - friend class SendtoWorkspacemenu; - - Windowmenu(const Windowmenu&); - Windowmenu& operator=(const Windowmenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - - -public: - Windowmenu(BlackboxWindow *win); - virtual ~Windowmenu(void); - - inline Basemenu *getSendToMenu(void) { return (Basemenu *) sendToMenu; } - - void reconfigure(void); - void setClosable(void); - - virtual void show(void); -}; - - -#endif // __Windowmenu_hh diff --git a/src/Workspacemenu.cc b/src/Workspacemenu.cc deleted file mode 100644 index 2ba73e23..00000000 --- a/src/Workspacemenu.cc +++ /dev/null @@ -1,88 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Workspacemenu.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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" -#endif // HAVE_CONFIG_H - -#include "i18n.hh" -#include "blackbox.hh" -#include "Clientmenu.hh" -#include "Screen.hh" -#include "Toolbar.hh" -#include "Workspacemenu.hh" -#include "Workspace.hh" - - -Workspacemenu::Workspacemenu(BScreen *scrn) : Basemenu(scrn) { - setInternalMenu(); - - setLabel(i18n(WorkspacemenuSet, WorkspacemenuWorkspacesTitle, "Workspaces")); - insert(i18n(WorkspacemenuSet, WorkspacemenuNewWorkspace, "New Workspace")); - insert(i18n(WorkspacemenuSet, WorkspacemenuRemoveLast, "Remove Last")); -} - - -void Workspacemenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - if (index == 0) { - getScreen()->addWorkspace(); - } else if (index == 1) { - getScreen()->removeLastWorkspace(); - } else { - // subtract 2 because the workspace menu has 2 extra items at the top before - // the list of the workspace names - index -= 2; - const Workspace* const wkspc = getScreen()->getCurrentWorkspace(); - if (wkspc->getID() != index && index < getScreen()->getWorkspaceCount()) - getScreen()->changeWorkspaceID(index); - } - if (! (getScreen()->getWorkspacemenu()->isTorn() || isTorn())) - hide(); -} - - -void Workspacemenu::changeWorkspaceLabel(unsigned int index, - const std::string& label) { - // add 2 because the workspace menu has 2 extra items at the top before the - // list of the workspace names - changeItemLabel(index + 2, label); -} - - -void Workspacemenu::insertWorkspace(Workspace *wkspc) { - assert(wkspc); - // add 2 because the workspace menu has 2 extra items at the top before the - // list of the workspace names - insert(wkspc->getName(), wkspc->getMenu(), wkspc->getID() + 2); -} - - -void Workspacemenu::removeWorkspace(Workspace *wkspc) { - assert(wkspc); - // add 2 because the workspace menu has 2 extra items at the top before the - // list of the workspace names - remove(wkspc->getID() + 2); -} diff --git a/src/Workspacemenu.hh b/src/Workspacemenu.hh deleted file mode 100644 index 15269844..00000000 --- a/src/Workspacemenu.hh +++ /dev/null @@ -1,52 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// WorkspaceMenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// 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. - -#ifndef __Workspacemenu_hh -#define __Workspacemenu_hh - -#include "Basemenu.hh" - -// forward declaration -class Workspacemenu; -class Toolbar; -class Workspace; - -class Workspacemenu : public Basemenu { -private: - Workspacemenu(const Workspacemenu&); - Workspacemenu& operator=(const Workspacemenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - -public: - Workspacemenu(BScreen *scrn); - - void changeWorkspaceLabel(unsigned int index, const std::string& label); - void insertWorkspace(Workspace *wkspc); - void removeWorkspace(Workspace *wkspc); -}; - - -#endif // __Workspacemenu_hh -