all repos — fluxbox @ fbe722de6da27d80c69551bdeffa271764094c6f

custom fork of the fluxbox windowmanager

update
fluxgen fluxgen
commit

fbe722de6da27d80c69551bdeffa271764094c6f

parent

9582e35ab89e14397bf1aeaea1d98a10d4064c60

2 files changed, 65 insertions(+), 59 deletions(-)

jump to
M src/tests/Makefilesrc/tests/Makefile

@@ -4,13 +4,12 @@ LIBS=

XFLAGS= -I/usr/X11R6/include XLIBS= -L/usr/X11R6/lib -lX11 -lXft COMPILEFILE=$(CXX) -c $(CXXFLAGS) -FONT_OBJ = ../BaseDisplay.o ../FbTk/Font.o ../FbTk/XFontImp.o ../FbTk/XftFontImp.o ../FbTk/XmbFontImp.o \ - ../FbTk/Timer.o ../StringUtil.o ../i18n.o +FONT_OBJ = ../FbTk/libFbTk.a -all: testLayers testStringUtil testKeys testResource testSignal +all: testLayers testStringUtil testKeys testResource testSignal glxtest .cc.o: - $(CXX) -c $(CXXFLAGS) $< -o $@ + $(CXX) -c $(CXXFLAGS) $< ../FbTk/XftFontImp.o: ../FbTk/XftFontImp.hh ../FbTk/XftFontImp.cc

@@ -20,8 +19,11 @@ ../FbTk/XFontImp.o: ../FbTk/XFontImp.hh ../FbTk/XFontImp.cc

../FbTk/Font.o: ../FbTk/XFontImp.hh ../FbTk/XftFontImp.hh ../FbTk/XmbFontImp.hh ../FbTk/Font.hh ../FbTk/Font.cc +glxtest: ../FbTk/App.hh glxtest.cc + ${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest + StringUtil.o: ../StringUtil.cc ../StringUtil.hh - $(CXX) -c $(CXXFLAGS) ../StringUtil.cc -o StringUtil.o + $(CXX) -c $(CXXFLAGS) ../StringUtil.cc Keys.o: ../Keys.cc ../Keys.hh $(CXX) -c $(CXXFLAGS) $(XFLAGS) ../Keys.cc -o Keys.o

@@ -32,8 +34,8 @@

../FbTk/SignalHandler.o: ${COMPILEFILE} ../FbTk/SignalHandler.cc -o ../FbTk/SignalHandler.o -testStringUtil: StringUtiltest.o StringUtil.o - $(CXX) $(LIBS) StringUtiltest.o StringUtil.o -o testStringUtil +testStringUtil: StringUtiltest.o ../FbTk/StringUtil.o + $(CXX) $(LIBS) StringUtiltest.o ../FbTk/StringUtil.o -o testStringUtil testKeys: Keys.o testKeys.o StringUtil.o $(CXX) $(LIBS) $(XLIBS) StringUtil.o Keys.o testKeys.o -o testKeys
M src/tests/testFont.ccsrc/tests/testFont.cc

@@ -19,92 +19,91 @@ // 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. -// $Id: testFont.cc,v 1.5 2002/12/01 13:42:15 rathnor Exp $ +// $Id: testFont.cc,v 1.6 2003/09/11 16:51:03 fluxgen Exp $ +#include "App.hh" +#include "FbWindow.hh" #include "Font.hh" -#include "BaseDisplay.hh" +#include "EventHandler.hh" +#include "EventManager.hh" +#include "GContext.hh" +#include "Color.hh" -#include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/keysym.h> -#include <X11/Xft/Xft.h> + #include <string> #include <iostream> using namespace std; -class App:public BaseDisplay { +class App:public FbTk::App, public FbTk::EventHandler { public: - App(const char *displayname):BaseDisplay("app", displayname) { + App(const char *displayname): + FbTk::App(displayname), + m_win(DefaultScreen(display()), + 0, 0, 640, 480, KeyPressMask | ExposureMask) { - // using screen 0 - m_win = XCreateSimpleWindow(getXDisplay(), - DefaultRootWindow(getXDisplay()), - 0, 0, - 640, 480, - 1, - 0, - 0xFFFF); - XSelectInput(getXDisplay(), m_win, KeyPressMask|ExposureMask); - XMapWindow(getXDisplay(), m_win); + m_win.show(); + m_win.setBackgroundColor(FbTk::Color("white", m_win.screenNumber())); + FbTk::EventManager::instance()->add(*this, m_win); } ~App() { - XDestroyWindow(getXDisplay(), m_win); } - - void handleEvent(XEvent * const ev) { - switch (ev->type) { - case KeyPress: - KeySym ks; - char keychar[1]; - XLookupString(&ev->xkey, keychar, 1, &ks, 0); - if (ks == XK_Escape) - shutdown(); - else { // toggle antialias - m_font.setAntialias(!m_font.isAntialias()); - cerr<<boolalpha; - cerr<<"antialias: "<<m_font.isAntialias()<<endl; - redraw(); - } - break; - case Expose: + void keyPressEvent(XKeyEvent &ke) { + KeySym ks; + char keychar[1]; + XLookupString(&ke, keychar, 1, &ks, 0); + if (ks == XK_Escape) + end(); + else { // toggle antialias + m_font.setAntialias(!m_font.isAntialias()); + cerr<<boolalpha; + cerr<<"antialias: "<<m_font.isAntialias()<<endl; redraw(); - break; } } + + void exposeEvent(XExposeEvent &event) { + redraw(); + } + void redraw() { size_t text_w = m_font.textWidth(m_text.c_str(), m_text.size()); size_t text_h = m_font.height(); int x = 640/2 - text_w/2; int y = 480/2 - text_h/2; - XClearWindow(getXDisplay(), m_win); - GC wingc = DefaultGC(getXDisplay(), 0); - - XDrawLine(getXDisplay(), m_win, wingc, - x, y + m_font.descent(), x + text_w, y + m_font.descent()); - XSetForeground(getXDisplay(), wingc, 0xFF00FF); // don't care what color it is - XDrawLine(getXDisplay(), m_win, wingc, - x, y - text_h , x + text_w, y - text_h ); - XSetForeground(getXDisplay(), wingc, 0xFF0000); // don't care what color it is - XDrawLine(getXDisplay(), m_win, wingc, - x, y, x + text_w, y); - - XSetForeground(getXDisplay(), wingc, 0); - m_font.drawText(m_win, 0, wingc, + m_win.clear(); + FbTk::GContext wingc(m_win.drawable()); + + m_win.drawLine(wingc.gc(), + x, y + m_font.descent(), + x + text_w, y + m_font.descent()); + m_win.drawLine(wingc.gc(), + x, y - text_h, + x + text_w, y - text_h); + wingc.setForeground(FbTk::Color("red", m_win.screenNumber())); + m_win.drawLine(wingc.gc(), + x, y, x + text_w, y); + wingc.setForeground(FbTk::Color("black", m_win.screenNumber())); + m_font.drawText(m_win.drawable(), + 0, wingc.gc(), m_text.c_str(), m_text.size(), x, y); } - Window win() const { return m_win; } + FbTk::Font &font() { return m_font; } void setText(const std::string& text) { m_text = text; } + private: - Window m_win; + FbTk::FbWindow m_win; FbTk::Font m_font; string m_text; }; int main(int argc, char **argv) { bool antialias = false; + bool rotate = false; string fontname("fixed"); string displayname(""); string text("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-_¯åäöÅÄÖ^~+=`\"!#¤%&/()=¡@£$½¥{[]}¶½§±");

@@ -117,7 +116,9 @@ } else if (strcmp("-display", argv[a]) == 0 && a + 1 < argc) {

displayname = argv[++a]; } else if (strcmp("-text", argv[a]) == 0 && a + 1 < argc) { text = argv[++a]; - } + } else if (strcmp("-rotate", argv[a]) == 0) + rotate = true; + } App app(displayname.c_str());

@@ -126,6 +127,9 @@ if (!app.font().load(fontname.c_str()))

cerr<<"Failed to load: "<<fontname<<endl; app.setText(text); + if (rotate) + app.font().rotate(90); + app.redraw(); app.eventLoop();