diff -Nru clxclient-3.9.0/button.cc clxclient-3.9.2/button.cc --- clxclient-3.9.0/button.cc 2013-06-28 14:45:08.000000000 +0000 +++ clxclient-3.9.2/button.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,309 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -X_button::X_button (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, int yp, - int cbid) : - X_window (parent, xp, yp, style->size.x, style->size.y, style->color.shadow.bgnd), - _style (style), - _callb (callb), - _xs (style->size.x), - _ys (style->size.y), - _cbid (cbid), - _down (0), - _stat (0) -{ - x_add_events (ExposureMask); - if (_callb) x_add_events (ButtonPressMask | ButtonReleaseMask | Button1MotionMask | LeaveWindowMask); -} - - -X_button::~X_button (void) -{ -} - - -void X_button::handle_event (XEvent *E) -{ - switch (E->type) - { - case Expose: - expose ((XExposeEvent *) E); - break; - - case ButtonPress: - bpress ((XButtonEvent *) E); - break; - - case ButtonRelease: - brelease ((XButtonEvent *) E); - break; - - case MotionNotify: - _callb->handle_callb (X_callback::BUTTON | MOVE, this, E); - break; - - case LeaveNotify: - release (); - break; - } -} - - -void X_button::bpress (XButtonEvent *E) -{ - _down = 1; - redraw (); - _callb->handle_callb (X_callback::BUTTON | PRESS, this, (XEvent *) E); -} - - -void X_button::brelease (XButtonEvent *E) -{ - _down = 0; - redraw (); - _callb->handle_callb (X_callback::BUTTON | RELSE, this, (XEvent *) E); -} - - -void X_button::expose (XExposeEvent *E) -{ - if (E->count == 0) redraw (); -} - - -void X_button::release (void) -{ - if (_style->type & X_button_style::HOLDPTR) return; - XUngrabPointer (dpy (), CurrentTime); - _down = 0; - redraw (); -} - - -void X_button::set_stat (int stat) -{ - if (_stat != stat) - { - _stat = stat; - redraw (); - } -} - - -void X_button::redraw (void) -{ - GC gc = disp ()->dgc (); - - XSetFunction (dpy (), gc, GXcopy); - XSetLineAttributes (dpy (), gc, 0, LineSolid, CapButt, JoinBevel); - switch (_style->type & 3) - { - case X_button_style::RAISED: - XSetForeground (dpy (), gc, _down ? _style->color.shadow.dark : _style->color.shadow.lite); - XDrawLine (dpy (), win (), gc, 0, 0, 0, _ys - 2); - XDrawLine (dpy (), win (), gc, 0, 0, _xs - 2, 0); - XSetForeground (dpy (), gc, _down ? _style->color.shadow.lite : _style->color.shadow.dark); - XDrawLine (dpy (), win (), gc, _xs - 1, 1, _xs - 1, _ys); - XDrawLine (dpy (), win (), gc, 1, _ys - 1, _xs, _ys - 1); - XSetForeground (dpy (), gc, _style->color.shadow.bgnd); - XDrawPoint (dpy (), win (), gc, 0, _ys - 1); - XDrawPoint (dpy (), win (), gc, _xs - 1, 0); - break; - } -} - - - -X_tbutton::X_tbutton (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - const char *text1, - const char *text2, - int cbid) : - X_button (parent, callb, style, xp, yp, cbid), - _bg (0), - _fg (0), - _len1 (0), - _len2 (0) -{ - set_text (text1, text2); -} - - -X_tbutton::~X_tbutton (void) -{ -} - - -void X_tbutton::set_text (const char *text1, const char *text2) -{ - _len1 = 0; - _len2 = 0; - if (text1) while (((*(unsigned char *) text1) >= ' ') && (_len1 < MAXLEN - 1)) _text1 [_len1++] = *text1++; - if (text2) while (((*(unsigned char *) text2) >= ' ') && (_len2 < MAXLEN - 1)) _text2 [_len2++] = *text2++; - _text1 [_len1] = 0; - _text2 [_len2] = 0; -} - - -void X_tbutton::redraw (void) -{ - int a, d, u, x, y; - GC G = dgc (); - XftDraw *D = xft (); - XftColor *C; - XftFont *F = _style->font; - XGlyphInfo K; - unsigned long b; - - XftDrawChange (D, win ()); - XSetFunction (dpy (), G, GXcopy); - b = (_stat > 3) ? _bg : _style->color.bg [_stat]; - XSetForeground (dpy (), G, b); - XFillRectangle (dpy (), win (), G, 0, 0, _xs, _ys); - - a = F->ascent; - d = F->descent; - u = a + d - _ys / 2; - if (u < 0) u = 0; - - C = (_stat > 3) ? _fg : _style->color.fg [_stat]; - if (_len1) - { - y = (_len2) ? _ys / 2 - d + u : (_ys + a - d) / 2; - if (_style->type & X_button_style::ALEFT) x = 6; - else - { - XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) _text1, _len1, &K); - if (_style->type & X_button_style::ARIGHT) x = _xs - K.width - 6; - else x = (_xs - K.width) / 2; - } - XftDrawStringUtf8 (D, C, F, x, y, (const FcChar8 *) _text1, _len1); - } - if (_len2) - { - y = (_len1) ? _ys / 2 + a - u : (_ys + a - d) / 2; - if (_style->type & X_button_style::ALEFT) x = 6; - else - { - XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) _text2, _len2, &K); - if (_style->type & X_button_style::ARIGHT) x = _xs - K.width - 6; - else x = (_xs - K.width) / 2; - } - XftDrawStringUtf8 (D, C, F, x, y, (const FcChar8 *) _text2, _len2); - } - if ((_style->type & 3) == X_button_style::BORDER) - { - XSetLineAttributes (dpy (), G, 1, LineSolid, CapButt, JoinBevel); - XSetForeground (dpy (), G, C->pixel); - XDrawRectangle (dpy (), win (), G, 0, 0, _xs - 1, _ys - 1); - } - else X_button::redraw (); -} - - - -X_ibutton::X_ibutton (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - XImage *image, - int cbid) : - X_button (parent, callb, style, xp, yp, cbid), - _bg (0), - _fg (0), - _image (image) -{ -} - - -X_ibutton::~X_ibutton (void) -{ -} - - -void X_ibutton::redraw (void) -{ - int x, y; - unsigned long b, f; - - b = (_stat > 3) ? _bg : _style->color.bg [_stat]; - f = (_stat > 3) ? _fg : _style->color.fg [_stat]->pixel; - XSetState (dpy (), dgc (), f, b, GXcopy, ~0); - XSetWindowBackground (dpy (), win (), b); - XClearWindow (dpy (), win ()); - if (_image) - { - x = (_xs - _image->width) / 2; - y = (_ys - _image->height) / 2; - XPutImage (dpy (), win (), dgc (), _image, 0, 0, x, y, _xs, _ys); - } - if ((_style->type & 3) == X_button_style::BORDER) - { - XSetLineAttributes (dpy (), dgc (), 1, LineSolid, CapButt, JoinBevel); - XSetForeground (dpy (), dgc (), f); - XDrawRectangle (dpy (), win (), dgc (), 0, 0, _xs - 1, _ys - 1); - } - else X_button::redraw (); -} - - - -X_pbutton::X_pbutton (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, int yp, - Pixmap map0, - Pixmap map1, - int cbid) : - X_button (parent, callb, style, xp, yp, cbid), - _map0 (map0), - _map1 (map1) -{ - if (_map0) XSetWindowBackgroundPixmap (dpy (), win (), _map0); -} - - -X_pbutton::~X_pbutton (void) -{ -} - - -void X_pbutton::set_stat (bool stat) -{ - if (_stat != stat) - { - if (_map1) XSetWindowBackgroundPixmap (dpy (), win (), stat ? _map1 : _map0); - _stat = stat; - XClearWindow (dpy (), win ()); - X_button::redraw (); - } -} - diff -Nru clxclient-3.9.0/clxclient.h clxclient-3.9.2/clxclient.h --- clxclient-3.9.0/clxclient.h 2013-06-28 14:45:20.000000000 +0000 +++ clxclient-3.9.2/clxclient.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1289 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#ifndef __CLXCLIENT_H -#define __CLXCLIENT_H - - -#include -#include -#include -#include -#include -#include -#include - - -// ------------------------------------------------------------------------------------------- - -const char *clxclient_version (void); - -// ------------------------------------------------------------------------------------------- - - -class X_display -{ -public: - - X_display (const char *dispname); - ~X_display (void); - - unsigned long blackpixel (void) const { return BlackPixel (_dpy, _dsn); } - unsigned long whitepixel (void) const { return WhitePixel (_dpy, _dsn); } - - Display *dpy (void) const { return _dpy; } - int dsn (void) const { return _dsn; } - Colormap dcm (void) const { return _dcm; } - GC dgc (void) const { return _dgc; } - Visual *dvi (void) const { return _dvi; } - XftDraw *xft (void) const { return _xft; } - XIM xim (void) const { return _xim; } - - int depth (void) const { return DefaultDepth (_dpy, _dsn); } - int xsize (void) const { return WidthOfScreen (ScreenOfDisplay (_dpy, _dsn)); } - int ysize (void) const { return HeightOfScreen (ScreenOfDisplay (_dpy, _dsn)); } - int gray (void) const { return 0; } - - unsigned long alloc_color (const char *name, unsigned long d); - unsigned long alloc_color (float r, float g, float b); - XftColor *alloc_xftcolor (const char *name, XftColor *D); - XftColor *alloc_xftcolor (float r, float g, float b, float a); - void free_xftcolor (XftColor *C); - - XFontStruct *alloc_font (const char *name); - XftFont *alloc_xftfont (const char *name); - void free_xftfont (XftFont *F); - - enum { IMG_LT, IMG_RT, IMG_UP, IMG_DN, IMG_PL, IMG_MI, IMG_SQ, IMG_PT, N_IMG1515 }; - - void nofocus (void) { XSetInputFocus (_dpy, PointerRoot, PointerRoot, CurrentTime); } - - XImage *image1515 (unsigned int i); - -private: - - friend class X_rootwin; - friend class X_window; - friend class X_handler; - - Display *_dpy; - int _dsn; - Colormap _dcm; - GC _dgc; - Visual *_dvi; - XftDraw *_xft; - XIM _xim; - - static unsigned char _imgdef1515 [N_IMG1515 * 30]; - XImage *_imgptr1515 [N_IMG1515]; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_hints -{ -public: - - X_hints (void) { _sh.flags = 0; _mh.flags = 0; _ch.res_name = 0; _ch.res_class = 0; } - - void position (int x, int y); - void size (int x, int y); - void minsize (int x, int y); - void maxsize (int x, int y); - void sizeinc (int x, int y); - void input (int input); - void state (int state); - void group (Window group); - void rname (const char *rname) { _ch.res_name = (char *) rname; } - void rclas (const char *rclas) { _ch.res_class = (char *) rclas; } - - friend class X_window; - -private: - - XSizeHints _sh; - XWMHints _mh; - XClassHint _ch; - -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_window -{ -public: - - X_window (X_window *pwin, int xpos, int ypos, int xsize, int ysize, - unsigned long bgcol, unsigned long bdcol = 0, int bdpix = 0); - - virtual ~X_window (void); - - X_display* disp (void) const { return _disp; } - - Display *dpy (void) const { return _disp->_dpy; } - int dsn (void) const { return _disp->_dsn; } - Colormap dcm (void) const { return _disp->_dcm; } - GC dgc (void) const { return _disp->_dgc; } - Visual *dvi (void) const { return _disp->_dvi; } - XftDraw *xft (void) const { return _disp->_xft; } - XIM xim (void) const { return _disp->_xim; } - Window win (void) const { return _wind; } - - virtual void handle_event (XEvent *E) {} - - int x_map (void) const { return XMapWindow (_disp->_dpy, _wind); } - int x_mapraised (void) const { return XMapRaised (_disp->_dpy, _wind); } - int x_unmap (void) const { return XUnmapWindow (_disp->_dpy, _wind); } - int x_clear (void) const { return XClearWindow (_disp->_dpy, _wind); } - int x_raise (void) const { return XRaiseWindow (_disp->_dpy, _wind); } - int x_move (int xp, int yp) const; - int x_resize (int xs, int ys) const; - int x_moveresize (int xp, int yp, int xs, int ys) const; - int x_set_attrib (unsigned long mask, XSetWindowAttributes *attr) const; - int x_set_win_gravity (int gravity) const; - int x_set_bit_gravity (int gravity) const; - int x_add_events (unsigned long events); - int x_rem_events (unsigned long events); - int x_set_title (const char *title); - int x_set_background (unsigned long color); - void x_apply (X_hints *hints); - - X_window *pwin (void) { return _pwin; } - - friend class X_rootwin; - -private: - - X_window (X_display *disp); - X_window (const X_window&); - X_window& operator=(const X_window&); - X_window *find (Window w); - - unsigned long _ebits; - X_display *_disp; - X_window *_pwin; - X_window *_next; - X_window *_list; - Window _wind; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_subwin : public X_window -{ -public: - - X_subwin (X_window *pwin, int xpos, int ypos, int xsize, int ysize, - unsigned long bgcol, unsigned long bdcol = 0, int bdpix = 0) : - X_window (pwin, xpos, ypos, xsize, ysize, bgcol, bdcol, bdpix) - {} - - virtual void handle_event (XEvent *E) { pwin ()->handle_event (E); } -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_rootwin : public X_window -{ -public: - - X_rootwin (X_display *disp); - virtual ~X_rootwin (void); - - void handle_event (void); - void handle_event (XEvent *E); - bool check_done (void) const { return _list == 0; } - -private: - - Window _window; - X_window *_object; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_resman -{ -public: - - enum { NDEFOPT = 13 }; - - X_resman (void); - ~X_resman (void); - X_resman (const X_resman&); - X_resman& operator=(const X_resman&); - - void init (int *argc, char *argv [], char *name, XrmOptionDescRec *opt, int nopt); - - const char *get (const char *res, const char *def) const; - int getb (const char *res, int def) const; - void geometry (const char *res, int xd, int yd, int bd, - int &xp, int &yp, int &xs, int &ys); - - const char *rname (void) { return _rname; } - const char *rclas (void) { return _rclas; } - -private: - - char _rname [64]; - char _rclas [64]; - char *_home; - XrmDatabase _xrmdata; - - static XrmOptionDescRec defopt [X_resman::NDEFOPT]; -}; - - - -// ------------------------------------------------------------------------------------------- - - -extern "C" int x_handler_error (Display *dpy, XErrorEvent *err); - - -class X_handler : public H_thread -{ -public: - - X_handler (X_display *disp, Edest *dest, int ipid); - ~X_handler (void); - - void thr_main (void); - void next_event (void) { put_event (ITC_ip1q::N_MQ, 1); } - -private: - - int _conn; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_callback -{ -public: - - virtual ~X_callback (void) {} - - enum - { - BUTTON = 0x010000, - TEXTIP = 0x010100, - ENUMIP = 0x010200, - ROTARY = 0x010300, - SLIDER = 0x010400, - SCROLL = 0x010500, - MENU = 0x010600, - MCLIST = 0x010700 - }; - - virtual void handle_callb (int /*type*/, X_window */*W*/, XEvent */*E*/) = 0; - static int cb_class (int k) { return k & 0xFFFFFF00; } - static int cb_event (int k) { return k & 0x000000FF; } -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_draw -{ -public: - - X_draw (Display *dpy, Drawable drw, GC gct, XftDraw *xft); - ~X_draw (void) {} - - void setfont (XFontStruct *font) { _xft_font = 0; _x11_font = font; XSetFont (_dpy, _gct, font->fid); } - void setfont (XftFont *font) { _x11_font = 0; _xft_font = font; } - void setcolor (unsigned long c) { _xft_color = 0; XSetForeground (_dpy, _gct, c); } - void setcolor (XftColor *c) { _xft_color = c; XSetForeground (_dpy, _gct, c->pixel); } - void setfunc (int f) { XSetFunction (_dpy, _gct, f); } - void setline (int d, int f = LineSolid, int c = CapButt, int j = JoinBevel) { XSetLineAttributes (_dpy, _gct, d, f, c, j); } - void setdash (char *v, int n, int i = 0) { XSetDashes (_dpy, _gct, i, v, n); } - void move (int x, int y) { _xx = x; _yy = y; } - void rmove (int x, int y) { _xx += x; _yy += y; } - void draw (int x, int y) { XDrawLine (_dpy, _drw, _gct, _xx, _yy, x, y); _xx = x; _yy = y; } - void rdraw (int x, int y) { XDrawLine (_dpy, _drw, _gct, _xx, _yy, _xx + x, _yy + y); _xx += x; _yy += y; } - void drawline (int x0, int y0, int x1, int y1) { XDrawLine (_dpy, _drw, _gct, x0, y0, x1, y1); } - void drawrect (int x0, int y0, int x1, int y1) { XDrawRectangle (_dpy, _drw, _gct, x0, y0, x1 - x0, y1 - y0); } - void fillrect (int x0, int y0, int x1, int y1) { XFillRectangle (_dpy, _drw, _gct, x0, y0, x1 - x0, y1 - y0); } - void drawrect (int dx, int dy) { XDrawRectangle (_dpy, _drw, _gct, _xx, _yy, dx, dy); } - void fillrect (int dx, int dy) { XFillRectangle (_dpy, _drw, _gct, _xx, _yy, dx, dy); } - void drawarc (int dx, int dy, int a1, int a2) { XDrawArc (_dpy, _drw, _gct, _xx, _yy, dx, dy, a1, a2); } - void fillarc (int dx, int dy, int a1, int a2) { XFillArc (_dpy, _drw, _gct, _xx, _yy, dx, dy, a1, a2); } - void movepix (int dx, int dy, int xs, int ys); - void setclip (int x0, int y0, int x1, int y1); - void noclip (void) { XSetClipMask (_dpy, _gct, None); } - void drawpoints (int n, XPoint *P); - void drawlines (int n, XPoint *P); - void drawsegments (int n, XSegment *S); - void putimage (XImage *I) { XPutImage (_dpy, _drw, _gct, I, 0, 0, _xx, _yy, I->width, I->height); } - void clearwin (void) { XClearWindow (_dpy, _drw); } - - int textwidth (const char *str); - int textascent (void) { return _xft_font ? _xft_font->ascent : (_x11_font ? _x11_font->ascent : 0); } - int textdescent (void) { return _xft_font ? _xft_font->descent : (_x11_font ? _x11_font->descent : 0); } - void drawstring (const char *str, int xal); - -private: - - Display *_dpy; - Drawable _drw; - GC _gct; - XftDraw *_xft_draw; - XftColor *_xft_color; - XftFont *_xft_font; - XFontStruct *_x11_font; - int _xx; - int _yy; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_linked -{ -private: - - X_linked (X_linked *back, X_linked *forw) : - _back (back), - _forw (forw) - { - if (back) back->_forw = this; - if (forw) forw->_back = this; - } - - virtual ~X_linked (void) - { - if (_back) _back->_forw = _forw; - if (_forw) _forw->_back = _back; - } - - virtual void select (void) = 0; - - friend class X_textip; - friend class X_enumip; - - X_linked *_back; - X_linked *_forw; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_button_style -{ -public: - - enum { PLAIN = 0, BORDER = 1, RAISED = 2, ALEFT = 4, ARIGHT = 8, HOLDPTR = 16 }; - - XftFont *font; - struct - { - unsigned long bg [4]; - XftColor *fg [4]; - struct - { - unsigned long bgnd; - unsigned long lite; - unsigned long dark; - } shadow; - } color; - struct - { - int x; - int y; - } size; - int type; -}; - - -class X_button : public X_window -{ -public: - - enum { MOVE, PRESS, RELSE }; - - int cbid (void) const { return _cbid; } - int stat (void) const { return _stat; } - void set_cbid (int cbid) { _cbid = cbid; } - void release (void); - virtual void set_stat (int stat); - virtual void redraw (void); - -protected: - - X_button (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - int cbid); - - ~X_button (void); - - void handle_event (XEvent *E); - void expose (XExposeEvent *E); - void bpress (XButtonEvent *E); - void brelease (XButtonEvent *E); - - const X_button_style *_style; - X_callback *_callb; - int _xs; - int _ys; - int _cbid; - int _down; - int _stat; -}; - - -class X_tbutton : public X_button -{ -public: - - enum { MAXLEN = 24 }; - - X_tbutton (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - const char *text1 = 0, - const char *text2 = 0, - int cbid = 0); - - ~X_tbutton (void); - - virtual void redraw (void); - - void set_col (unsigned long bg, XftColor *fg) { _bg = bg, _fg = fg; } - void set_text (const char *txt1, const char *txt2); - const char *text1 (void) const { return _text1; } - const char *text2 (void) const { return _text2; } - -private: - - unsigned long _bg; - XftColor *_fg; - int _len1; - int _len2; - char _text1 [MAXLEN]; - char _text2 [MAXLEN]; -}; - - -class X_ibutton : public X_button -{ -public: - - enum { MAXLEN = 24 }; - - X_ibutton (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - XImage *image, - int cbid = 0); - - ~X_ibutton (void); - - virtual void redraw (void); - - void set_col (unsigned long bg, unsigned long fg) { _bg = bg, _fg = fg; } - void set_image (XImage *image) { _image = image; } - const XImage *image (void) const { return _image; } - -private: - - unsigned long _bg; - unsigned long _fg; - XImage *_image; -}; - - -class X_pbutton : public X_button -{ -public: - - X_pbutton (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - Pixmap map0, - Pixmap map1, - int cbid = 0); - - ~X_pbutton (void); - - virtual void set_stat (bool stat); - - const Pixmap map0 (void) const { return _map0; } - const Pixmap map1 (void) const { return _map1; } - -private: - - Pixmap _map0; - Pixmap _map1; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_scroll : public X_window, public X_callback -{ -public: - - enum { ENDGAP = 1, PLUSMIN = 2, MIDGAP = 4, ARROWS = 8 }; - enum { MOVE, STOP, C1LU, C3LU, C1RD, C3RD, B1LU, B3LU, B1RD, B3RD, B1PL, B3PL, B1MI, B3MI }; - - void redraw (void); - - X_scroll (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - int xs, - int ys, - int opts); - - ~X_scroll (void); - - float offs (void) const { return _offs; } - float frac (void) const { return _frac; } - void geom (float offs, float frac, int size = 0); - void move (float drel); - -private: - - void handle_event (XEvent *E); - void bpress (XButtonEvent *E); - void brelease (XButtonEvent *E); - void bmotion (XMotionEvent *E); - void expose (XExposeEvent *E); - - virtual void handle_callb (int type, X_window *W, XEvent *E); - - const X_button_style *_style; - X_callback *_callb; - int _xs; - int _ys; - int _km; - int _k0; - int _dk; - int _dw; - int _zz; - float _offs; - float _frac; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_textln_style -{ - -public: - - XftFont *font; - struct - { - struct - { - unsigned long bgnd; - XftColor *text; - } normal; - struct - { - unsigned long bgnd; - XftColor *text; - unsigned long line; - } focus; - struct - { - unsigned long bgnd; - unsigned long lite; - unsigned long dark; - } shadow; - } color; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_textln : public X_window -{ -public: - - X_textln (X_window *parent, - X_textln_style *style, - int xp, - int yp, - int xs, - int ys, - const char *text, - int xal); - - ~X_textln (void); - - int base (void) const { return _y0; }; - -private: - - void handle_event (XEvent *xe); - void expose (XExposeEvent *e); - - X_textln_style *_style; - const char *_text; - int _len; - int _x0; - int _y0; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_textip : public X_window, public X_linked -{ -public: - - enum { KEY, BUT, MODIF }; - - X_textip (X_window *parent, - X_callback *callb, - X_textln_style *style, - int xp, - int yp, - int xs, - int ys, - int max, - X_linked *back = 0, - X_linked *forw = 0); - - ~X_textip (void); - - void set_text (const char *txt); - void set_color (unsigned long bg, XftColor *fg); - void set_align (int xal); - void enable (void); - void clear_modified (void) { _flags |= CLEAR; } - void callb_modified (void) { if (_callb) _flags |= CALLB; } - - const char *text (void) { _txt [_i1] = 0; return (char *) _txt; } - int base (void) const { return _y0; }; - int key (void) const { return _key; } - X_linked *forw (void) const { return _forw; } - X_linked *back (void) const { return _back; } - -private: - - enum { FOCUS = 1, CLEAR = 2, CALLB = 4, RIGHT = 8, CENTER = 16 }; - - int test_utf8 (int k, const unsigned char *t); - void insert (int k, const unsigned char *t); - void go_sol (void); - void go_lt (void); - void del_rt (void); - void go_eol (void); - void go_rt (void); - void del_eol (void); - void del_all (void); - void del_lt (void); - void spkey (XKeyEvent *e); - void cbkey (int k, XKeyEvent *e); - - void handle_event (XEvent *xe); - void expose (XExposeEvent *e); - void bpress (XButtonEvent *e); - void keypress (XKeyEvent *e); - void paste (XSelectionEvent *e); - void setfocus (XFocusChangeEvent *e); - void remfocus (XFocusChangeEvent *e); - void update (bool f); - void redraw (void); - void xorcursor (void); - void checkclear (void); - void checkcallb (void); - void select (void); - int findindex (int x); - int textwidth (int i, int n); - - X_callback *_callb; - X_textln_style *_style; - unsigned long _bg; - XftColor *_fg; - int _flags; - int _xs; - int _ys; - unsigned char *_txt; - int _max; - int _key; - int _ic; - int _i1; - int _xc; - int _x0; - int _x1; - int _y0; - - static XIC _xic; - static unsigned char _utf8mark [6]; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_enip_item -{ -public: - int _code; - const char *_text; -}; - - -class X_enumip : public X_window, public X_linked -{ -public: - - enum { KEY, BUT }; - - X_enumip (X_window *parent, - X_callback *callb, - X_textln_style *style, - int xp, - int yp, - int xs, - int ys, - X_enip_item *list, - X_linked *back = 0, - X_linked *forw = 0); - - ~X_enumip (void); - - void set_ind (int ind); - int base (void) const { return _y0; }; - int key (void) const { return _key; } - int ind (void) const { return _ind; } - - virtual void handle_event (XEvent *xe); - -private: - - void spkey (XKeyEvent *e); - void cbkey (int k); - - void expose (XExposeEvent *e); - void bpress (XButtonEvent *e); - void keypress (XKeyEvent *e); - void setfocus (XFocusChangeEvent *e); - void remfocus (XFocusChangeEvent *e); - void redraw (void); - int textwidth (int i, int n); - - virtual void select (void); - - X_callback *_callb; - X_textln_style *_style; - X_enip_item *_list; - unsigned long _bg; - XftColor *_fg; - char *_txt; - int _ind; - int _max; - int _len; - int _foc; - int _key; - int _xs; - int _ys; - int _x0; - int _y0; - - static XIC _xic; - static unsigned char _utf8mark [6]; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_menuwin_style -{ -public: - - enum { PLAIN = 0, BORDER = 1, RAISED = 2, PDOWN = 256 }; - - XftFont *font; - int step; - int type; - struct - { - XftColor *bg; - XftColor *fg [4]; - XftColor *mm; - struct - { - unsigned long bgnd; - unsigned long lite; - unsigned long dark; - } shadow; - } color; -}; - - -class X_menuwin_item -{ -public: - - enum { COLMASK = 3, TITLE = 0x010000, SPACE = 0x020000, LAST = 0x040000, MARK = 0x080000, MASKED = 0x100000 }; - - const char *_text; - int _bits; - X_menuwin_item *_link; -}; - - - -class X_menuwin : public X_window -{ -public: - - enum { OPEN, SEL, CAN }; - enum { MAXITEM = 32, DL = 6, DR = 6 }; - - X_menuwin (X_window *parent, - X_callback *callb, - X_menuwin_style *style, - int xp, - int yp, - X_menuwin_item *items); - - ~X_menuwin (void); - - void show (void); - void hide (void); - void set_mask (unsigned m); - void clr_mask (unsigned m); - int xs (void) { return _xs; } - int ys (void) { return _ys; } - int selection (void) { return _isel; } - - -private: - - void handle_event (XEvent *E); - void expose (XExposeEvent *E); - void enter (XEnterWindowEvent *E); - void leave (XLeaveWindowEvent *E); - void motion (XPointerMovedEvent *E); - void bpress (XButtonEvent *E); - void brelse (XButtonEvent *E); - void redraw (bool clear); - void drawit (int k, bool inv); - void select (int k); - int findit (int x, int y); - - const X_menuwin_style *_style; - X_callback *_callb; - X_menuwin_item *_items; - int _xs; - int _ys; - int _nit; - int _isel; - int _open; - int _ypos [MAXITEM]; - int _tlen [MAXITEM]; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_scale_style -{ - -public: - - enum { SEGMAX = 20 }; - - int marg; - int nseg; - int pix [SEGMAX + 1]; - float val [SEGMAX + 1]; - const char *text [SEGMAX + 1]; - XftFont *font; - unsigned long bg; - XftColor *fg; - - void set_tick (int i, int p, float v, const char *t) { pix [i] = p; val [i] = v; text [i] = t; } - void set_text (int i, const char *t) { text [i] = t; } - int pixlen (void) const { return pix [0] + pix [nseg] + 1; } - int length (void) const { return 2 * marg + pixlen (); } - int limit (int i); - int calcpix (float x); - float calcval (int p); -}; - - -class X_hscale : public X_window -{ -public: - - X_hscale (X_window *parent, - X_scale_style *style, - int xp, - int yp, - int h, - int d = 0); - -private: - - void handle_event (XEvent *xe); - void expose (XExposeEvent *e); - - X_scale_style *_style; - int _h; - int _d; -}; - - -class X_vscale : public X_window -{ -public: - - X_vscale (X_window *parent, - X_scale_style *style, - int xp, - int yp, - int w, - int d = 0); - -private: - - void handle_event (XEvent *xe); - void expose (XExposeEvent *e); - - X_scale_style *_style; - int _w; - int _d; -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_meter_style -{ -public: - - unsigned long bg; - struct - { - unsigned long c0; - unsigned long c1; - unsigned long mk; - } off; - struct - { - unsigned long c0; - unsigned long c1; - unsigned long mk; - } act; -}; - - -class X_meter : public X_window -{ -public: - - X_meter (X_window *parent, X_meter_style *style, X_scale_style *scale, int xp, int yp, int xs, int ys); - - void handle_event (XEvent *xe); - void set_val (float v); - void set_ref (float v); - - friend class X_hmeter; - friend class X_vmeter; - -private: - - void expose (XExposeEvent *e); - void plotsect (int i0, int i1, int imin, int imax, int cl, int cr); - void plotmarks (int a, int b, unsigned long c); - - virtual void psect (GC g, int a, int b) = 0; - virtual void pmark (GC g, int a) = 0; - - X_meter_style *_style; - X_scale_style *_scale; - - int _x; - int _y; - int _d; - int _i; - int _s; - int _d0; - int _d1; - int _d2; -}; - - -class X_hmeter : public X_meter -{ -public: - - X_hmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, int xp, int yp, int h); - -private: - - virtual void psect (GC g, int a, int b); - virtual void pmark (GC g, int a); -}; - - -class X_vmeter : public X_meter -{ -public: - - X_vmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, int xp, int yp, int w); - -private: - - virtual void psect (GC g, int a, int b); - virtual void pmark (GC g, int a); -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_slider_style -{ -public: - - unsigned long bg; - unsigned long lite; - unsigned long dark; - unsigned long knob; - unsigned long mark; - int w; - int h; -}; - - -class X_slider : public X_window -{ -public: - - enum { MOVE, STOP }; - - X_slider (X_window *parent, - X_callback *callb, - X_slider_style *style, - X_scale_style *scale, - int xp, int yp, - int xs, int ys, - int cbid = 0); - - virtual void set_val (float v) = 0; - virtual void set_color (unsigned long knob, unsigned long mark) = 0; - float get_val (void) { return _scale->calcval (_i); } - int cbid (void) const { return _cbid; } - - friend class X_hslider; - friend class X_vslider; - -private: - - void brelease (XButtonEvent *E); - - X_callback *_callb; - X_slider_style *_style; - X_scale_style *_scale; - - int _x; - int _y; - int _i; - int _d; - int _cbid; - unsigned long _knob; - unsigned long _mark; -}; - - -class X_hslider : public X_slider -{ -public: - - X_hslider (X_window *parent, - X_callback *callb, - X_slider_style *style, - X_scale_style *scale, - int xp, int yp, - int h, - int cbid); - - virtual void handle_event (XEvent *E); - virtual void set_color (unsigned long knob, unsigned long mark); - virtual void set_val (float v); - -private: - - bool domove (int i); - void plines (void); - void plknob (int i); - void erase (int i); -}; - - -class X_vslider : public X_slider -{ -public: - - X_vslider (X_window *parent, - X_callback *callb, - X_slider_style *style, - X_scale_style *scale, - int xp, int yp, - int w, - int cbid); - - virtual void handle_event (XEvent *E); - virtual void set_color (unsigned long knob, unsigned long mark); - virtual void set_val (float v); - -private: - - bool domove (int i); - void plines (void); - void plknob (int i); - void erase (int i); -}; - - -// ------------------------------------------------------------------------------------------- - - -class X_mclist_style -{ -public: - - unsigned long bg; - XftColor *fg [4]; - XftFont *font; - int dy; -}; - - -class X_mclist : public X_window -{ -public: - - enum { OPEN, SEL, CAN }; - - X_mclist (X_window *parent, - X_callback *callb, - X_mclist_style *style, - int xp, - int yp, - int xs, - int ys, - int max_item, - int max_char); - - ~X_mclist (void); - - void reset (void) { _n_item = _n_char = 0; _sel = -1; } - int item (const char *txt, int col, int len = 0); - void sort (void); - void show (void); - void move (int offs); - void resize (int xs, int ys); - void forw (void); - void back (void); - - int xs (void) const { return _xs; } - int ys (void) const { return _ys; } - int span (void) const { return _span; } - int offs (void) const { return _offs; } - const char *ptr (void) const { return _ptr [_sel]; } - int col (void) const { return _col [_sel]; } - int len (void) const { return _len [_sel]; } - -private: - - void handle_event (XEvent *xE); - void expose (XExposeEvent *E); - void bpress (XButtonEvent *E); - void update (int xx, int yy, int ww, int hh); - int find (int x, int y); - void enter (XEnterWindowEvent * E); - void leave (XLeaveWindowEvent * E); - void motion (XPointerMovedEvent * E); - void hilite (int ind); - void drawhl (int ind); - - X_mclist_style *_style; - X_callback *_callb; - int _max_item; - int _max_char; - int _n_item; - int _n_char; - int _xs; - int _ys; - int _offs; - int _span; - int _nrow; - int _nclm; - int _sel; - char *_buff; - char **_ptr; - short *_len; - short *_ext; - short *_col; - int *_ind; - int *_dxc; -}; - - -// ------------------------------------------------------------------------------------------- - - -#endif - diff -Nru clxclient-3.9.0/debian/changelog clxclient-3.9.2/debian/changelog --- clxclient-3.9.0/debian/changelog 2018-12-16 12:08:37.000000000 +0000 +++ clxclient-3.9.2/debian/changelog 2020-02-23 17:22:56.000000000 +0000 @@ -1,3 +1,27 @@ +clxclient (3.9.2-1) unstable; urgency=medium + + [ Ondřej Nový ] + * Use debhelper-compat instead of debian/compat + + [ Dennis Braun ] + * New upstream release + * d/control: + + Bump Standards-Version to 4.5.0 + + Bump dh-compt to 12 + + Add libfreetype6-dev to B-D + + Add me as uploader + + Use https protocol for homepage + + Set RRR: no + * d/copyright: + + http > https + + Update copyright year + + Add myself to the d/ section + * Update patchset + * Update d/rules + * d/watch: Use https protocol + + -- Dennis Braun Sun, 23 Feb 2020 18:22:56 +0100 + clxclient (3.9.0-5) unstable; urgency=medium * Team upload. diff -Nru clxclient-3.9.0/debian/compat clxclient-3.9.2/debian/compat --- clxclient-3.9.0/debian/compat 2018-12-16 12:04:12.000000000 +0000 +++ clxclient-3.9.2/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru clxclient-3.9.0/debian/control clxclient-3.9.2/debian/control --- clxclient-3.9.0/debian/control 2018-12-16 12:04:17.000000000 +0000 +++ clxclient-3.9.2/debian/control 2020-02-23 17:21:56.000000000 +0000 @@ -3,20 +3,23 @@ Priority: optional Maintainer: Debian Multimedia Maintainers Uploaders: + Dennis Braun , Free Ekanayaka , Alessio Treglia , Jaromír Mikeš Build-Depends: - debhelper (>= 11), + debhelper-compat (= 12), libasound2-dev, libclthreads-dev, + libfreetype6-dev, libx11-dev, libxft-dev, pkg-config -Standards-Version: 4.2.1 +Standards-Version: 4.5.0 Vcs-Git: https://salsa.debian.org/multimedia-team/clxclient.git Vcs-Browser: https://salsa.debian.org/multimedia-team/clxclient -Homepage: http://kokkinizita.linuxaudio.org/linuxaudio/ +Homepage: https://kokkinizita.linuxaudio.org/linuxaudio/ +Rules-Requires-Root: no Package: libclxclient-dev Section: libdevel diff -Nru clxclient-3.9.0/debian/copyright clxclient-3.9.2/debian/copyright --- clxclient-3.9.0/debian/copyright 2018-12-16 11:41:21.000000000 +0000 +++ clxclient-3.9.2/debian/copyright 2020-02-23 17:21:56.000000000 +0000 @@ -1,17 +1,17 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: clxclient -Upstream-Contact: Fons Adriaensen -Source: http://kokkinizita.linuxaudio.org/linuxaudio/downloads/index.html -Copyright: 2003-2013 Fons Adriaensen +Upstream-Contact: Fons Adriaensen +Source: https://kokkinizita.linuxaudio.org/linuxaudio/downloads/index.html Files: * -Copyright: 2003-2013 Fons Adriaensen +Copyright: 2003-2018 Fons Adriaensen License: LGPL-2+ Files: debian/* Copyright: - 2010-2013 Alessio Treglia + 2020, Dennis Braun 2010-2017 Jaromír Mikeš + 2010-2013 Alessio Treglia 2007-2009 Free Ekanayaka License: LGPL-2+ @@ -30,4 +30,4 @@ Public License can be found in `/usr/share/common-licenses/LGPL-2' . You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . + along with this program. If not, see . diff -Nru clxclient-3.9.0/debian/patches/0004-Use-pkg-config-to-handle-xft-and-x11.patch clxclient-3.9.2/debian/patches/0004-Use-pkg-config-to-handle-xft-and-x11.patch --- clxclient-3.9.0/debian/patches/0004-Use-pkg-config-to-handle-xft-and-x11.patch 2018-12-16 12:00:39.000000000 +0000 +++ clxclient-3.9.2/debian/patches/0004-Use-pkg-config-to-handle-xft-and-x11.patch 2020-02-23 17:21:56.000000000 +0000 @@ -2,31 +2,21 @@ Date: Sun, 16 Dec 2018 13:00:05 +0100 Subject: Use pkg-config to handle xft and x11 ---- - Makefile | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/Makefile b/Makefile -index 1a911c2..704ccee 100644 ---- a/Makefile -+++ b/Makefile -@@ -31,15 +31,16 @@ MINVERS = 9.0 +--- a/source/Makefile ++++ b/source/Makefile +@@ -24,13 +24,14 @@ + PREFIX ?= /usr/local + INCDIR ?= $(PREFIX)/include + LIBDIR ?= $(PREFIX)/lib$(SUFFIX) ++PKG_CONF ?= pkgconf + + MAJVERS = 3 + MINVERS = 9.2 VERSION = $(MAJVERS).$(MINVERS) --CPPFLAGS += -Wall -I. -I/usr/X11R6/include `freetype-config --cflags` -fpic -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O2 --LDFLAGS += -L/usr/X11R6/$(LIBDIR) -Wl,--as-needed `freetype-config --libs` -+PKG_CONFIG ?= pkg-config -+CPPFLAGS += -pthread -Wall -I. `$(PKG_CONFIG) xft x11 --cflags` -fpic -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O2 -+LDFLAGS += -pthread -Wl,--as-needed +-CPPFLAGS += $(shell pkgconf --cflags freetype2) ++CPPFLAGS += $(shell $(PKG_CONF) --cflags freetype2) + CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS $(PCONFCFL) + CXXFLAGS += -Wall -O2 -fPIC LDLIBS += - - - CLXCLIENT_SO = libclxclient.so - CLXCLIENT_MAJ = $(CLXCLIENT_SO).$(MAJVERS) - CLXCLIENT_MIN = $(CLXCLIENT_MAJ).$(MINVERS) --CLXCLIENT_DEP = -lpthread -lXft -lX11 -lclthreads -+CLXCLIENT_DEP = `$(PKG_CONFIG) xft x11 --libs` -lclthreads - CLXCLIENT_O = xdisplay.o xresman.o xhandler.o xwindow.o xdraw.o \ - button.o textip.o enumip.o menuwin.o scale.o slider.o scroll.o mclist.o meter.o - CLXCLIENT_H = clxclient.h diff -Nru clxclient-3.9.0/debian/patches/0005-Fix_header.patch clxclient-3.9.2/debian/patches/0005-Fix_header.patch --- clxclient-3.9.0/debian/patches/0005-Fix_header.patch 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/debian/patches/0005-Fix_header.patch 2020-02-23 17:21:56.000000000 +0000 @@ -0,0 +1,14 @@ +Description: Fix clxclient header +Author: Dennis Braun + +--- a/source/enumip.cc ++++ b/source/enumip.cc +@@ -19,7 +19,7 @@ + // --------------------------------------------------------------------------------- + + +-#include ++#include "clxclient.h" + #include + + diff -Nru clxclient-3.9.0/debian/patches/01-makefile.patch clxclient-3.9.2/debian/patches/01-makefile.patch --- clxclient-3.9.0/debian/patches/01-makefile.patch 2018-12-16 12:06:29.000000000 +0000 +++ clxclient-3.9.2/debian/patches/01-makefile.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -Description: Change install prefix from /usr/local/bin to /usr/bin -Origin: Debian -Forwarded: not-needed ---- ---- - Makefile | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - ---- clxclient.orig/Makefile -+++ clxclient/Makefile -@@ -21,9 +21,9 @@ - - # Modify as required. - # --PREFIX = /usr/local -+PREFIX ?= /usr/local - SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/') --LIBDIR = lib$(SUFFIX) -+LIBDIR ?= lib$(SUFFIX) - - - MAJVERS = 3 -@@ -50,11 +50,11 @@ $(CLXCLIENT_MIN): $(CLXCLIENT_O) - - - install: $(CLXCLIENT_MIN) -- install -d $(PREFIX)/$(LIBDIR) -- install -m 644 $(CLXCLIENT_H) $(PREFIX)/include -- install -m 755 $(CLXCLIENT_MIN) $(PREFIX)/$(LIBDIR) -- ldconfig -- ln -sf $(CLXCLIENT_MIN) $(PREFIX)/$(LIBDIR)/$(CLXCLIENT_SO) -+ install -d $(DESTDIR)$(PREFIX)/$(LIBDIR) -+ install -d $(DESTDIR)$(PREFIX)/include -+ install -m 644 $(CLXCLIENT_H) $(DESTDIR)$(PREFIX)/include -+ install -m 755 $(CLXCLIENT_MIN) $(DESTDIR)$(PREFIX)/$(LIBDIR) -+ ln -sf $(CLXCLIENT_MIN) $(DESTDIR)$(PREFIX)/$(LIBDIR)/$(CLXCLIENT_SO) - - - clean: diff -Nru clxclient-3.9.0/debian/patches/02-makefile.patch clxclient-3.9.2/debian/patches/02-makefile.patch --- clxclient-3.9.0/debian/patches/02-makefile.patch 2018-12-16 12:06:29.000000000 +0000 +++ clxclient-3.9.2/debian/patches/02-makefile.patch 2020-02-23 17:21:56.000000000 +0000 @@ -1,20 +1,15 @@ -Description: Patch is applied to fix build failure with binutils-gold. +Description: Patch is applied to fix build failures (with binutils-gold). Origin: Debian Bug-Debian: http://bugs.debian.org/558847 Forwarded: fons@kokkinizita.net ---- ---- - Makefile | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) ---- clxclient.orig/Makefile -+++ clxclient/Makefile -@@ -32,14 +32,14 @@ VERSION = $(MAJVERS).$(MINVERS) - - - CPPFLAGS += -Wall -I. -I/usr/X11R6/include `freetype-config --cflags` -fpic -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O2 --LDFLAGS += -L/usr/X11R6/$(LIBDIR) `freetype-config --libs` -+LDFLAGS += -L/usr/X11R6/$(LIBDIR) -Wl,--as-needed `freetype-config --libs` +--- a/source/Makefile ++++ b/source/Makefile +@@ -33,14 +33,13 @@ + CPPFLAGS += $(shell pkgconf --cflags freetype2) + CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS $(PCONFCFL) + CXXFLAGS += -Wall -O2 -fPIC +-CXXFLAGS += -march=native LDLIBS += @@ -26,11 +21,24 @@ CLXCLIENT_O = xdisplay.o xresman.o xhandler.o xwindow.o xdraw.o \ button.o textip.o enumip.o menuwin.o scale.o slider.o scroll.o mclist.o meter.o CLXCLIENT_H = clxclient.h -@@ -54,6 +54,7 @@ install: $(CLXCLIENT_MIN) - install -d $(DESTDIR)$(PREFIX)/include - install -m 644 $(CLXCLIENT_H) $(DESTDIR)$(PREFIX)/include - install -m 755 $(CLXCLIENT_MIN) $(DESTDIR)$(PREFIX)/$(LIBDIR) +@@ -52,15 +52,15 @@ + + install: $(CLXCLIENT_MIN) + install -d $(DESTDIR)$(INCDIR) +- install -d $(DESTDIR)$(LIBDIR) ++ install -d $(DESTDIR)$(PREFIX)/$(LIBDIR) + install -m 644 $(CLXCLIENT_H) $(DESTDIR)$(INCDIR) +- install -m 755 $(CLXCLIENT_MIN) $(DESTDIR)$(LIBDIR) +- ldconfig +- ln -sf $(CLXCLIENT_MIN) $(DESTDIR)$(LIBDIR)/$(CLXCLIENT_SO) ++ install -m 755 $(CLXCLIENT_MIN) $(DESTDIR)$(PREFIX)/$(LIBDIR) + /sbin/ldconfig -n $(DESTDIR)$(PREFIX)/$(LIBDIR) - ln -sf $(CLXCLIENT_MIN) $(DESTDIR)$(PREFIX)/$(LIBDIR)/$(CLXCLIENT_SO) ++ ln -sf $(CLXCLIENT_MIN) $(DESTDIR)$(PREFIX)/$(LIBDIR)/$(CLXCLIENT_SO) + uninstall: + rm -rf $(DESTDIR)$(INCDIR)/$(CLXCLIENT_H) +- rm -rf $(DESTDIR)$(LIBDIR)/libclxclient* ++ rm -rf $(DESTDIR)$(PREFIX)/$(LIBDIR)/libclxclient* + clean: + /bin/rm -f *~ *.o *.a *.d *.so.* diff -Nru clxclient-3.9.0/debian/patches/03-makefile.patch clxclient-3.9.2/debian/patches/03-makefile.patch --- clxclient-3.9.0/debian/patches/03-makefile.patch 2018-12-16 12:06:29.000000000 +0000 +++ clxclient-3.9.2/debian/patches/03-makefile.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -Description: make C++ compiler overridable for cross compilation -Author: Helmut Grohne -Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853012 -Forwarded: Fons Adriaensen - -Index: clxclient/Makefile -=================================================================== ---- clxclient.orig/Makefile -+++ clxclient/Makefile -@@ -46,7 +46,7 @@ CLXCLIENT_H = clxclient.h - - - $(CLXCLIENT_MIN): $(CLXCLIENT_O) -- g++ -shared $(LDFLAGS) -Wl,-soname,$(CLXCLIENT_MAJ) -o $(CLXCLIENT_MIN) $(CLXCLIENT_O) $(CLXCLIENT_DEP) -+ $(CXX) -shared $(LDFLAGS) -Wl,-soname,$(CLXCLIENT_MAJ) -o $(CLXCLIENT_MIN) $(CLXCLIENT_O) $(CLXCLIENT_DEP) - - - install: $(CLXCLIENT_MIN) diff -Nru clxclient-3.9.0/debian/patches/series clxclient-3.9.2/debian/patches/series --- clxclient-3.9.0/debian/patches/series 2018-12-16 12:00:39.000000000 +0000 +++ clxclient-3.9.2/debian/patches/series 2020-02-23 17:21:56.000000000 +0000 @@ -1,4 +1,3 @@ -01-makefile.patch 02-makefile.patch -03-makefile.patch 0004-Use-pkg-config-to-handle-xft-and-x11.patch +0005-Fix_header.patch diff -Nru clxclient-3.9.0/debian/rules clxclient-3.9.2/debian/rules --- clxclient-3.9.0/debian/rules 2018-12-16 12:02:48.000000000 +0000 +++ clxclient-3.9.2/debian/rules 2020-02-23 17:21:56.000000000 +0000 @@ -1,12 +1,16 @@ #!/usr/bin/make -f +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + include /usr/share/dpkg/architecture.mk +include /usr/share/dpkg/buildtools.mk + +export PKG_CONF=$(PKG_CONFIG) export PREFIX=/usr export LIBDIR=lib/$(DEB_HOST_MULTIARCH) export DESTDIR=$(CURDIR)/debian/tmp -export DEB_BUILD_MAINT_OPTIONS = hardening=+all - %: - dh $@ -Smakefile + dh $@ -Dsource diff -Nru clxclient-3.9.0/debian/watch clxclient-3.9.2/debian/watch --- clxclient-3.9.0/debian/watch 2018-12-16 11:41:21.000000000 +0000 +++ clxclient-3.9.2/debian/watch 2020-02-23 17:21:56.000000000 +0000 @@ -1,4 +1,4 @@ -version=3 +version=4 -http://kokkinizita.linuxaudio.org/linuxaudio/downloads/index.html \ +https://kokkinizita.linuxaudio.org/linuxaudio/downloads/index.html \ clxclient-(.*)\.tar\.bz2 diff -Nru clxclient-3.9.0/enumip.cc clxclient-3.9.2/enumip.cc --- clxclient-3.9.0/enumip.cc 2013-06-28 14:45:37.000000000 +0000 +++ clxclient-3.9.2/enumip.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,285 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include -#include - - -#define DX 8 - - -XIC X_enumip::_xic = 0; -unsigned char X_enumip::_utf8mark [6] = { 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - -X_enumip::X_enumip (X_window *parent, - X_callback *callb, - X_textln_style *style, - int xp, - int yp, - int xs, - int ys, - X_enip_item *list, - X_linked *back, - X_linked *forw) : - X_window (parent, xp, yp, xs, ys, style->color.normal.bgnd), - X_linked (back, forw), - _callb (callb), - _style (style), - _list (list), - _bg (_style->color.normal.bgnd), - _fg (_style->color.normal.text), - _txt (0), - _ind (0), - _len (0), - _foc (0), - _xs (xs), - _ys (ys), - _x0 (xs - DX) -{ - int i, l, m; - - x_add_events (ExposureMask | ButtonPressMask | FocusChangeMask); - _y0 = (_ys + style->font->ascent - style->font->descent) / 2; - if (callb) - { - x_add_events (ButtonPressMask | FocusChangeMask); - if (! _xic) _xic = XCreateIC (xim (), XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, win (), XNFocusWindow, win (), NULL); - } - if (_list) - { - for (i = m = 0; _list [i]._text; i++) - { - l = strlen (list [i]._text); - if (l > m) m = l; - } - _max = i; - _txt = new char [m]; - } - else _max = 0; -} - - -X_enumip::~X_enumip (void) -{ - delete [] _txt; -} - - -void X_enumip::set_ind (int ind) -{ - if ((ind < 0) || (ind >= _max)) - { - _ind = -1; - _len = 0; - } - else - { - strcpy (_txt, _list [_ind = ind]._text); - _len = strlen (_txt); - } - _x0 = _xs - DX; - if (_len) _x0 -= textwidth (0, _len); - redraw (); -} - - -void X_enumip::select (void) -{ - if (_callb) _callb->handle_callb (X_callback::ENUMIP | BUT, this, 0); -} - - -void X_enumip::handle_event (XEvent *xe) -{ - switch (xe->type) - { - case Expose: - expose ((XExposeEvent *) xe); - break; - - case ButtonPress: - bpress ((XButtonEvent *) xe); - break; - - case KeyPress: - keypress ((XKeyEvent *) xe); - break; - - case FocusIn: - setfocus ((XFocusChangeEvent *) xe); - break; - - case FocusOut: - remfocus ((XFocusChangeEvent *) xe); - break; - } -} - - -void X_enumip::expose (XExposeEvent *e) -{ - redraw (); -} - - -void X_enumip::bpress (XButtonEvent *e) -{ - if (e->button == Button2) - { - // if (_foc) XConvertSelection (dpy (), XA_PRIMARY, XA_STRING, XInternAtom (dpy (), - // "XTIPSEL", False), win (), e->time); - } - else - { - select (); - } -} - - -void X_enumip::keypress (XKeyEvent *e) -{ - int k; - unsigned char t [8]; - - if (XFilterEvent ((XEvent *) e, win ())) return; - if ( (k = Xutf8LookupString (_xic, e, (char *) t, 8, 0, 0)) - && ((*t >= 192) || ((*t >= 32) && (*t < 127)))) - { - } - else spkey (e); -} - - -void X_enumip::spkey (XKeyEvent *e) -{ - int k = XLookupKeysym (e, 0); - - switch (k) - { - case XK_Left: - case 'b': - if (--_ind < 0) _ind = _max - 1; - set_ind (_ind); - break; - - case XK_Right: - case 'f': - if (++_ind == _max) _ind = 0; - set_ind (_ind); - break; - - case XK_Tab: - if (e->state & ControlMask) { if (_back) _back->select (); } - else { if (_forw) _forw->select (); } - break; - - case XK_Up: - case XK_Down: - cbkey (k); - break; - - case XK_Return: - case XK_KP_Enter: - if (_forw) _forw->select (); - else cbkey (XK_Return); - break; - - default: - cbkey (k); - } -} - - -void X_enumip::cbkey (int k) -{ - _key = k; - if (_callb) _callb->handle_callb (X_callback::ENUMIP | KEY, this, 0); -} - - -void X_enumip::redraw (void) -{ - GC gc = dgc (); - XftDraw *D = xft (); - XftColor *C; - - XClearWindow (dpy (), win ()); - if (_len) - { - XftDrawChange (D, win ()); - C = _foc ? _style->color.focus.text : _fg; - XftDrawStringUtf8 (D, C, _style->font, _x0, _y0, (const FcChar8 *) _txt, _len); - } - if (_callb) - { - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - XSetFunction (dpy (), gc, GXcopy); - XSetForeground (dpy (), gc, _style->color.shadow.dark); - XDrawLine (dpy (), win (), gc, 0, 0, 0, _ys - 1); - XDrawLine (dpy (), win (), gc, 0, 0, _xs - 1, 0); - XSetForeground (dpy (), gc, _style->color.shadow.lite); - XDrawLine (dpy (), win (), gc, _xs - 1, 1, _xs - 1, _ys); - XDrawLine (dpy (), win (), gc, 1, _ys - 1, _xs, _ys - 1); - XSetForeground (dpy (), gc, _style->color.shadow.bgnd); - XDrawPoint (dpy (), win (), gc, 0, _ys - 1); - XDrawPoint (dpy (), win (), gc, _xs - 1, 0); - } -} - - -void X_enumip::setfocus (XFocusChangeEvent *e) -{ - if (e->detail != NotifyPointer && ! _foc) - { - _foc = 1; - x_add_events (KeyPressMask); - XSetWindowBackground (dpy (), win (),_style->color.focus.bgnd); - XSetICValues (_xic, XNFocusWindow, win (), NULL); - redraw (); - } -} - - -void X_enumip::remfocus (XFocusChangeEvent *e) -{ - if (_foc) - { - _foc = 0; - x_rem_events (KeyPressMask); - XSetWindowBackground (dpy (), win (), _bg); - redraw (); - } -} - - -int X_enumip::textwidth (int i, int n) -{ - XGlyphInfo K; - - if (n == 0) return 0; - XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *)(_txt + i), n, &K); - return K.xOff; -} - - - diff -Nru clxclient-3.9.0/INSTALL clxclient-3.9.2/INSTALL --- clxclient-3.9.0/INSTALL 2012-01-10 17:50:32.000000000 +0000 +++ clxclient-3.9.2/INSTALL 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -To make and install the library, cd to this directory, su root, -and 'make install'. This will install the lib and header file in -/usr/local/lib and /usr/local/include. - -To install to other directories, see the Makefile. - diff -Nru clxclient-3.9.0/Makefile clxclient-3.9.2/Makefile --- clxclient-3.9.0/Makefile 2013-06-28 14:50:51.000000000 +0000 +++ clxclient-3.9.2/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -# --------------------------------------------------------------------------------- -# -# Copyright (C) 2003-2013 Fons Adriaensen -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# --------------------------------------------------------------------------------- - - -# Modify as required. -# -PREFIX = /usr/local -SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/') -LIBDIR = lib$(SUFFIX) - - -MAJVERS = 3 -MINVERS = 9.0 -VERSION = $(MAJVERS).$(MINVERS) - - -CPPFLAGS += -Wall -I. -I/usr/X11R6/include `freetype-config --cflags` -fpic -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O2 -LDFLAGS += -L/usr/X11R6/$(LIBDIR) `freetype-config --libs` -LDLIBS += - - -CLXCLIENT_SO = libclxclient.so -CLXCLIENT_MAJ = $(CLXCLIENT_SO).$(MAJVERS) -CLXCLIENT_MIN = $(CLXCLIENT_MAJ).$(MINVERS) -CLXCLIENT_DEP = -lpthread -lXft -lX11 -CLXCLIENT_O = xdisplay.o xresman.o xhandler.o xwindow.o xdraw.o \ - button.o textip.o enumip.o menuwin.o scale.o slider.o scroll.o mclist.o meter.o -CLXCLIENT_H = clxclient.h - - -$(CLXCLIENT_MIN): $(CLXCLIENT_O) - g++ -shared $(LDFLAGS) -Wl,-soname,$(CLXCLIENT_MAJ) -o $(CLXCLIENT_MIN) $(CLXCLIENT_O) $(CLXCLIENT_DEP) - - -install: $(CLXCLIENT_MIN) - install -d $(PREFIX)/$(LIBDIR) - install -m 644 $(CLXCLIENT_H) $(PREFIX)/include - install -m 755 $(CLXCLIENT_MIN) $(PREFIX)/$(LIBDIR) - ldconfig - ln -sf $(CLXCLIENT_MIN) $(PREFIX)/$(LIBDIR)/$(CLXCLIENT_SO) - - -clean: - /bin/rm -f *~ *.o *.a *.d *.so.* - diff -Nru clxclient-3.9.0/Makefile-osx clxclient-3.9.2/Makefile-osx --- clxclient-3.9.0/Makefile-osx 2013-06-28 14:44:29.000000000 +0000 +++ clxclient-3.9.2/Makefile-osx 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -# --------------------------------------------------------------------------------- -# -# Copyright (C) 2003-2013 Fons Adriaensen -# Copyright (C) 2008 Hans Fugal -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# --------------------------------------------------------------------------------- - - -# Modify as required. -# -PREFIX = /usr/local -SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/') -LIBDIR = lib$(SUFFIX) - - -MAJVERS = 3 -MINVERS = 9.0 -VERSION = $(MAJVERS).$(MINVERS) - - -CPPFLAGS += -Wall -I. -I/usr/X11R6/include `freetype-config --cflags` -dynamic -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O2 -LDFLAGS += -L$(PREFIX)/$(LIBDIR) -L/usr/X11R6/$(LIBDIR) `freetype-config --libs` -LDLIBS += - - -CLXCLIENT_l = libclxclient -CLXCLIENT_SO = $(CLXCLIENT_l).dylib -CLXCLIENT_MAJ = $(CLXCLIENT_l).$(MAJVERS).dylib -CLXCLIENT_MIN = $(CLXCLIENT_l).$(MAJVERS).$(MINVERS).dylib -CLXCLIENT_DEP = -lpthread -lXft -lX11 -CLXCLIENT_O = xdisplay.o xresman.o xhandler.o xwindow.o xdraw.o \ - button.o textip.o enumip.o menuwin.o scale.o slider.o scroll.o mclist.o meter.o -CLXCLIENT_H = clxclient.h - - -$(CLXCLIENT_MIN): $(CLXCLIENT_O) - g++ -dynamiclib -flat_namespace -undefined suppress \ - -current_version $(MAJVERS).$(MINVERS) \ - -compatibility_version $(MAJVERS) \ - -o $(CLXCLIENT_MIN) $(CLXCLIENT_O) $(CLXCLIENT_DEP) $(LDFLAGS) - - -install: $(CLXCLIENT_MIN) - /usr/bin/install -d $(PREFIX)/$(LIBDIR) - /usr/bin/install -m 644 $(CLXCLIENT_H) $(PREFIX)/include - /usr/bin/install -m 755 $(CLXCLIENT_MIN) $(PREFIX)/$(LIBDIR) - ln -sf $(CLXCLIENT_MIN) $(PREFIX)/$(LIBDIR)/$(CLXCLIENT_MAJ) - ln -sf $(CLXCLIENT_MIN) $(PREFIX)/$(LIBDIR)/$(CLXCLIENT_SO) - - -clean: - /bin/rm -f *~ *.o *.a *.d *.so.* *.so *.dylib diff -Nru clxclient-3.9.0/mclist.cc clxclient-3.9.2/mclist.cc --- clxclient-3.9.0/mclist.cc 2013-06-28 14:46:05.000000000 +0000 +++ clxclient-3.9.2/mclist.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,316 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -#define X0 8 -#define DX 28 - - -static char **cmpptr; - -extern "C" int compare (const void *a, const void *b) -{ - return strcoll (cmpptr [*(int *)a], cmpptr [*(int *)b]); -} - - -X_mclist::X_mclist (X_window *parent, X_callback *callb, X_mclist_style *style, - int xp, int yp, int xs, int ys, - int max_item, int max_char) : - X_window (parent, xp, yp, xs, ys, style->bg), - _style (style), - _callb (callb), - _max_item (max_item), - _max_char (max_char), - _xs (xs), - _ys (ys), - _nrow (0), - _nclm (0) -{ - _buff = new char [max_char]; - _ptr = new char* [max_item]; - _len = new short [max_item]; - _ext = new short [max_item]; - _col = new short [max_item]; - _ind = new int [max_item]; - _dxc = new int [max_item / 4]; - reset (); - x_add_events (ExposureMask | ButtonPressMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask ); -} - - -X_mclist::~X_mclist (void) -{ - delete []_buff; - delete []_ptr; - delete []_len; - delete []_ext; - delete []_col; - delete []_ind; - delete []_dxc; -} - - -void X_mclist::resize (int xs, int ys) -{ - if ((xs != _xs) || (ys != _ys)) - { - _xs = xs; - _ys = ys; - x_unmap (); - x_resize (_xs, _ys); - x_map (); - show (); - } -} - - -void X_mclist::forw (void) -{ -} - - -void X_mclist::back (void) -{ -} - - -void X_mclist::handle_event (XEvent *E) -{ - switch (E->type) - { - case Expose: - case GraphicsExpose: - expose ((XExposeEvent *) E); - break; - case ButtonPress: - bpress ((XButtonEvent *) E); - break; - case EnterNotify: - enter ((XEnterWindowEvent *) E); - break; - case LeaveNotify: - leave ((XLeaveWindowEvent *) E); - break; - case MotionNotify: - motion ((XPointerMovedEvent *) E); - break; - } -} - - -void X_mclist::expose (XExposeEvent *E) -{ - if (_nclm) update (E->x, E->y, E->width, E->height); -} - - -void X_mclist::bpress (XButtonEvent *E) -{ - _sel = find (E->x, E->y); - if (_sel >= 0) - { - _callb->handle_callb (X_callback::MCLIST | SEL, this, (XEvent *) E); - } -} - - -void X_mclist::enter (XEnterWindowEvent * E) -{ - hilite (find (E->x, E->y)); -} - - -void X_mclist::leave (XLeaveWindowEvent * E) -{ - hilite (-1);} - - -void X_mclist::motion (XPointerMovedEvent * E) -{ - hilite (find (E->x, E->y)); -} - - -int X_mclist::find (int x, int y) -{ - int c, d, k, r; - - if (! _nclm) return -1; - x += _offs - X0; - d = _style->dy; - r = y / d; - y -= r * d; - if ((y < 2) || (y > d - 2)) return -1; - for (c = 0, k = r; k < _n_item; c++, k += _nrow) - { - d = _dxc [c]; - if ((x > 0) && (x < d)) return _ind [k]; - x -= d + DX; - } - return -1; -} - - -int X_mclist::item (const char *txt, int col, int len) -{ - int i; - XGlyphInfo G; - - if (! len) len = strlen (txt); - if (! len) return 0; - i = _n_item; - if (i == _max_item) return 1; - if (_n_char + len + 1 > _max_char) return 2; - XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *) txt, len, &G); - _ptr [i] = _buff + _n_char; - _len [i] = len; - _ext [i] = G.width; - _col [i] = col; - _ind [i] = i; - strcpy (_buff + _n_char, txt); - _n_char += len + 1; - _n_item = ++i; - return 0; -} - - -void X_mclist::sort (void) -{ - cmpptr = _ptr; - qsort (_ind, _n_item, sizeof (int), compare); -} - - -void X_mclist::show (void) -{ - int i, j, r, c, d; - - _nrow = _ys / _style->dy; - _nclm = (_n_item + _nrow - 1) / _nrow; - _span = X0; - r = c = d = 0; - for (i = 0; i < _n_item; i++) - { - j = _ind [i]; - if (d < _ext [j]) d = _ext [j]; - if (++r == _nrow) - { - if (c) _span += DX; - _span += d; - _dxc [c++] = d; - d = r = 0; - } - } - if (d) - { - if (c) _span += DX; - _span += d; - _dxc [c++] = d; - } - _span += X0; - _offs = 0; - _sel = -1; - XClearWindow (dpy (), win ()); - update (0, 0, _xs, _ys); -} - - -void X_mclist::move (int offs) -{ - int d; - XGCValues G; - - d = offs - _offs; - G.graphics_exposures = True; - G.function = GXcopy; - XChangeGC (dpy (), dgc (), GCGraphicsExposures | GCFunction, &G); - XCopyArea (dpy (), win (), win (), dgc (), d, 0, _xs, _ys, 0, 0); - G.graphics_exposures = False; - XChangeGC (dpy (), dgc (), GCGraphicsExposures, &G); - _offs = offs; -} - - -void X_mclist::hilite (int ind) -{ - if (_sel != ind) - { - if (_sel >= 0) drawhl (_sel); - _sel = ind; - if (_sel >= 0) drawhl (_sel); - } -} - - -void X_mclist::drawhl (int ind) -{ -} - - -void X_mclist::update (int xx, int yy, int ww, int hh) -{ - int i, j, c, r; - int x, dx, y, ya, yd, yb, dy; - XftDraw *D = xft (); - XftColor *C; - XftFont *F = _style->font; - - ya = _style->font->ascent; - yd = _style->font->descent; - dy = _style->dy; - yb = (dy + ya - yd) / 2; - XSetForeground (dpy (), dgc (), _style->bg); - XSetFunction (dpy (), dgc (), GXcopy); - XftDrawChange (D, win ()); - - x = X0 - _offs; - for (c = 0; c < _nclm; c++) - { - dx = _dxc [c]; - if (x >= xx + ww) break; - if (x + dx > xx) - { - y = 0; - for (r = 0; r < _nrow; r++) - { - i = c * _nrow + r; - if (i >= _n_item) break; - if (y + yb - ya >= yy + hh) break; - if (y + yb + yd > yy) - { - j = _ind [i]; - if (x + _ext [j] > xx) - { - XFillRectangle (dpy (), win (), dgc (), x, y, dx, dy); - C = _style->fg [_col [j] & 3]; - XftDrawStringUtf8 (D, C, F, x, y + yb, (const FcChar8 *) _ptr [j], _len [j]); - } - } - y += dy; - } - } - x += dx + DX; - } -} - diff -Nru clxclient-3.9.0/menuwin.cc clxclient-3.9.2/menuwin.cc --- clxclient-3.9.0/menuwin.cc 2013-06-28 14:46:30.000000000 +0000 +++ clxclient-3.9.2/menuwin.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -X_menuwin::X_menuwin (X_window *parent, - X_callback *callb, - X_menuwin_style *style, - int xp, - int yp, - X_menuwin_item *items) : - X_window (parent, xp, yp, 100, 100, style->color.bg->pixel), - _style (style), - _callb (callb), - _items (items), - _xs (10), - _ys (10), - _isel (-1), - _open (0) -{ - int i, k, ys, xm; - X_menuwin_item *P; - XGlyphInfo G; - - xm = 0; - ys = 1; - i = 0; - P = items; - while (i < MAXITEM) - { - if (P->_bits & X_menuwin_item::SPACE) ys += _style->step / 2; - _ypos [i] = ys; - _tlen [i] = k = strlen (P->_text); - XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *)(P->_text), k, &G); - if (xm < G.width) xm = G.width; - i++; - ys += _style->step; - if (P->_bits & X_menuwin_item::TITLE) ys++; - if (P->_bits & X_menuwin_item::LAST) break; - P++; - } - - _nit = i; - _xs = xm + DL + DR; - _ys = ys + 2; - - if (_style->type & X_menuwin_style::PDOWN) - { - x_resize (_xs, _style->step); - x_map (); - } - else x_resize (_xs, _ys); - - x_add_events (ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask); -} - - -X_menuwin::~X_menuwin (void) -{ -} - - -void X_menuwin::show (void) -{ - if (_style->type & X_menuwin_style::PDOWN) x_resize (_xs, _ys); - x_mapraised (); - _open = true; - _isel = -1; -} - - -void X_menuwin::hide (void) -{ - if (_style->type & X_menuwin_style::PDOWN) x_resize (_xs, _style->step); - else x_unmap (); - _open = false; -} - - -void X_menuwin::handle_event (XEvent *E) -{ - switch (E->type) - { - case Expose: - expose ((XExposeEvent *) E); - break; - - case ButtonPress: - bpress ((XButtonEvent *) E); - break; - - case ButtonRelease: - brelse ((XButtonEvent *) E); - break; - - case EnterNotify: - enter ((XEnterWindowEvent *) E); - break; - - case LeaveNotify: - leave ((XLeaveWindowEvent *) E); - break; - - case MotionNotify: - motion ((XPointerMovedEvent *) E); - break; - } -} - - -void X_menuwin::bpress (XButtonEvent *E) -{ - if (_open) - { - if (_isel >= 0) _callb->handle_callb (X_callback::MENU | SEL, this, (XEvent *) E); - else _callb->handle_callb (X_callback::MENU | CAN, this, (XEvent *) E); - } - else _callb->handle_callb (X_callback::MENU | OPEN, this, (XEvent *) E); -} - - -void X_menuwin::brelse (XButtonEvent *E) -{ - if (_open) - { - if (_isel >= 0) _callb->handle_callb (X_callback::MENU | SEL, this, (XEvent *) E); - else _callb->handle_callb (X_callback::MENU | CAN, this, (XEvent *) E); - } -} - - -void X_menuwin::expose (XExposeEvent * E) -{ - if (E->count == 0) redraw (true); -} - - -void X_menuwin::enter (XEnterWindowEvent * E) -{ - if (_open) select (findit (E->x, E->y)); -} - - -void X_menuwin::leave (XLeaveWindowEvent * E) -{ - if (_open) select (-1); -} - - -void X_menuwin::motion (XPointerMovedEvent * E) -{ - if (_open) select (findit (E->x, E->y)); -} - - -void X_menuwin::redraw (bool clear) -{ - int i, x, y; - GC gc = disp ()->dgc (); - const X_menuwin_item *P; - - if (clear) XClearWindow (dpy (), win ()); - - XSetFunction (dpy (), gc, GXcopy); - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - - for (i = 0, P = _items; i < _nit; i++, P++) - { - y = _ypos [i]; - drawit (i, i == _isel); - if (! _open) break; - if (P->_bits & X_menuwin_item::TITLE) - { - y += _style->step; - XSetForeground (dpy (), dgc (), _style->color.fg [0]->pixel); - XDrawLine (dpy (), win (), gc, 1, y, _xs - 2, y); - } - } - - y = _open ? _ys - 1 : _style->step - 1; - x = _xs - 1; - switch (_style->type & 255) - { - case X_menuwin_style::BORDER: - XSetForeground (dpy (), gc, _style->color.fg [0]->pixel); - XDrawRectangle (dpy (), win (), gc, 0, 0, x, y); - break; - - case X_menuwin_style::RAISED: - XSetForeground (dpy (), gc, _style->color.shadow.lite); - XDrawLine (dpy (), win (), gc, 0, 0, 0, y); - XDrawLine (dpy (), win (), gc, 0, 0, x, 0); - XSetForeground (dpy (), gc, _style->color.shadow.dark); - XDrawLine (dpy (), win (), gc, x, y, x, 1); - XDrawLine (dpy (), win (), gc, x, y, 1, y); - break; - } -} - - -void X_menuwin::drawit (int k, bool inv) -{ - X_menuwin_item *P = _items + k; - int y = _ypos [k]; - int d = (_style->step + _style->font->ascent - _style->font->descent) / 2; - XftColor *bg = _style->color.bg; - XftColor *fg = (P->_bits & X_menuwin_item::MASKED) ? _style->color.mm : _style->color.fg [P->_bits & X_menuwin_item::COLMASK]; - - if (XftDrawDrawable (xft ()) != win ()) XftDrawChange (xft (), win ()); - XSetFunction (dpy (), dgc (), GXcopy); - XSetForeground (dpy (), dgc (), (inv) ? fg->pixel : bg->pixel); - XFillRectangle (dpy (), win (), dgc (), DL - 2, y, _xs - DL - DR + 4, _style->step); - XftDrawStringUtf8 (xft (), (inv) ? bg : fg , _style->font, DL, y + d, (const FcChar8 *)(P->_text), _tlen [k]); -} - - -void X_menuwin::select (int k) -{ - if (k != _isel) - { - if (_isel >= 0) drawit (_isel, false); - _isel = k; - if (_isel >= 0) drawit (_isel, true); - } -} - - -int X_menuwin::findit (int x, int y) -{ - int i; - - for (i = 0; i < _nit; i++) - { - if ( (y > _ypos [i]) - && (y < _ypos [i] + _style->step - 1) - && (! (_items [i]._bits & (X_menuwin_item::MASKED | X_menuwin_item::TITLE)))) return i; - } - return -1; -} - - -void X_menuwin::set_mask (unsigned m) -{ - for (int i = 0; i < _nit; i++) - { - if (m & 1) _items [i]._bits |= X_menuwin_item::MASKED; - m >>= 1; - } -} - - -void X_menuwin::clr_mask (unsigned m) -{ - for (int i = 0; i < _nit; i++) - { - if (m & 1) _items [i]._bits &= ~X_menuwin_item::MASKED; - m >>= 1; - } -} - - diff -Nru clxclient-3.9.0/meter.cc clxclient-3.9.2/meter.cc --- clxclient-3.9.0/meter.cc 2013-06-28 14:47:06.000000000 +0000 +++ clxclient-3.9.2/meter.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -X_meter::X_meter (X_window *parent, X_meter_style *style, X_scale_style *scale, - int xp, int yp, int xs, int ys) : - X_window (parent, xp, yp, xs, ys, style->bg), - _style (style), - _scale (scale), - _x (scale->marg), - _y (scale->marg), - _d (0) -{ - _d0 = _i = -1; - _d1 = _d2 = _scale->pixlen () - 1; - x_add_events (ExposureMask); -} - - -void X_meter::handle_event (XEvent *E) -{ - switch (E->type) - { - case Expose: - expose ((XExposeEvent *) E); - break; - } -} - - -void X_meter::expose (XExposeEvent *) -{ - XClearWindow (dpy (), win ()); - XSetLineAttributes (dpy (), dgc (), 0, LineSolid, CapButt, JoinBevel); - plotsect (_d0, _i, _d0, _d1, _style->act.c0, _style->off.c0); - plotsect (_d1, _i, _d0, _d1, _style->act.c0, _style->off.c0); - plotsect (_d1, _i, _d1, _d2, _style->act.c1, _style->off.c1); - plotsect (_d2, _i, _d1, _d2, _style->act.c1, _style->off.c1); -} - - -void X_meter::set_val (float v) -{ - int i = _scale->calcpix (v); - - if (i != _i) - { - plotsect (_i, i, _d0, _d1, _style->act.c0, _style->off.c0); - plotsect (_i, i, _d1, _d2, _style->act.c1, _style->off.c1); - _i = i; - } -} - - -void X_meter::set_ref (float v) -{ - int t = _scale->calcpix (v) - 1; - - if (t < _d0) t = _d0; - if (t != _d1) - { - plotsect (_d1, t, _d0, _i, _style->act.c0, _style->act.c1); - plotsect (_d1, t, _i, _d2, _style->off.c0, _style->off.c1); - _d1 = t; - } -} - - -void X_meter::plotsect (int i0, int i1, int imin, int imax, int cl, int cr) -{ - int a, b; - - a = (i0 < imin) ? imin : (i0 > imax) ? imax : i0; - b = (i1 < imin) ? imin : (i1 > imax) ? imax : i1; - - if (a != b) - { - GC gc = disp ()->dgc (); - XSetFunction (dpy (), gc, GXcopy); - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - - if (a < b) - { - XSetForeground (dpy (), gc, cl); - psect (gc, b, a); - plotmarks (a, b, cl); - } - else - { - XSetForeground (dpy (), gc, cr); - psect (gc, a, b); - plotmarks (b, a, cr); - } - } -} - - -void X_meter::plotmarks (int a, int b, unsigned long c) -{ - int i, k, *p; - - k = _scale->nseg + 1; - p = _scale->pix; - if (c == _style->act.c0 || c == _style->act.c1) XSetForeground (dpy (), dgc (), _style->act.mk); - else XSetForeground (dpy (), dgc (), _style->off.mk); - while (k--) - { - i = *p++; - if (i > b) break; - if (i > a) pmark (dgc (), i); - } -} - - - - -X_hmeter::X_hmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, - int xp, int yp, int h) : - X_meter (parent, style, scale, xp, yp, scale->length (), h) -{ - _d = h - 2 * scale->marg; -} - - -void X_hmeter::psect (GC g, int a, int b) -{ - XFillRectangle (dpy (), win (), g, _x + b + 1, _y, a - b, _d); -} - - -void X_hmeter::pmark (GC g, int a) -{ - XDrawLine (dpy (), win (), g, _x + a, _y + 1, _x + a, _y + _d); -} - - - - -X_vmeter::X_vmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, - int xp, int yp, int w) : - X_meter (parent, style, scale, xp, yp, w, scale->length ()) -{ - _d = w - 2 * scale->marg; - _y += scale->pixlen () - 1; -} - - -void X_vmeter::psect (GC g, int a, int b) -{ - XFillRectangle (dpy (), win (), g, _x, _y - a, _d, a - b); -} - - -void X_vmeter::pmark (GC g, int a) -{ - XDrawLine (dpy (), win (), g, _x, _y - a, _x + _d, _y - a); -} - - diff -Nru clxclient-3.9.0/scale.cc clxclient-3.9.2/scale.cc --- clxclient-3.9.0/scale.cc 2013-06-28 14:47:37.000000000 +0000 +++ clxclient-3.9.2/scale.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -int X_scale_style::calcpix (float v) -{ - int k, *P, p0, p1; - float *V, v0, v1; - - k = nseg; - P = pix; - V = val; - - p0 = *P++; - v0 = *V++; - if (v < v0) return p0; - while (k--) - { - p1 = *P++; - v1 = *V++; - if (v > v1) - { - p0 = p1; - v0 = v1; - } - else return (int)(p0 + (p1 - p0) * (v - v0) / (v1 - v0) + 0.5); - } - return p0; -} - - -float X_scale_style::calcval (int p) -{ - int k, *P, p0, p1; - float *V, v0, v1; - - k = nseg; - P = pix; - V = val; - - p0 = *P++; - v0 = *V++; - if (p < p0) return v0; - while (k--) - { - p1 = *P++; - v1 = *V++; - if (p > p1) - { - p0 = p1; - v0 = v1; - } - else return v0 + (v1 - v0) * (p - p0) / (p1 - p0); - } - return v0; -} - - -int X_scale_style::limit (int i) -{ - if (i < pix [0]) return pix [0]; - if (i > pix [nseg]) return pix [nseg]; - return i; -} - - - -X_hscale::X_hscale (X_window *parent, X_scale_style *style, int xp, int yp, int h, int d) : - X_window (parent, xp, yp, style->length (), h, style->bg), - _style (style), - _h (h), - _d (d) -{ - x_add_events (ExposureMask); -} - - -void X_hscale::handle_event (XEvent *E) -{ - switch (E->type) - { - case Expose: - expose ((XExposeEvent *) E); - break; - } -} - - -void X_hscale::expose (XExposeEvent *) -{ - int k, l, m, x, y, *p; - const char **t; - XftColor *C = _style->fg; - XftFont *F = _style->font; - XGlyphInfo K; - - XClearWindow (dpy (), win ()); - XftDrawChange (xft (), win ()); - - k = _style->nseg + 1; - p = _style->pix; - t = _style->text; - m = _style->marg; - y = (_h + F->ascent - F->descent) / 2; - while (k--) - { - if (*t) - { - l = strlen (*t); - XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) *t, l, &K); - x = m + *p - K.width / 2; - XftDrawStringUtf8 (xft (), C, F, x, y, (const FcChar8 *) *t, l); - } - p++; - t++; - } -} - - - -X_vscale::X_vscale (X_window *parent, X_scale_style *style, int xp, int yp, int w, int d) : - X_window (parent, xp, yp, w, style->length (), style->bg), - _style (style), - _w (w), - _d (d) -{ - x_add_events (ExposureMask); -} - - -void X_vscale::handle_event (XEvent *E) -{ - switch (E->type) - { - case Expose: - expose ((XExposeEvent *) E); - break; - } -} - - -void X_vscale::expose (XExposeEvent *) -{ - int k, l, m, x, y, *p; - const char **t; - XftColor *C = _style->fg; - XftFont *F = _style->font; - XGlyphInfo K; - - XClearWindow (dpy (), win ()); - XftDrawChange (xft (), win ()); - - k = _style->nseg + 1; - p = _style->pix; - t = _style->text; - m = _style->marg + _style->pixlen () - 1 + F->ascent / 2; - while (k--) - { - if (*t) - { - l = strlen (*t); - y = m - *p; - if (_d <= 0) - { - XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) *t, l, &K); - if (_d) x = _w + _d - K.width; - else x = (_w - K.width) / 2; - } - else x = _d; - XftDrawStringUtf8 (xft (), C, F, x, y, (const FcChar8 *) *t, l); - } - p++; - t++; - } -} - diff -Nru clxclient-3.9.0/scroll.cc clxclient-3.9.2/scroll.cc --- clxclient-3.9.0/scroll.cc 2013-06-28 14:47:47.000000000 +0000 +++ clxclient-3.9.2/scroll.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,282 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -#define DL 17 -#define DW 13 - - -X_scroll::X_scroll (X_window *parent, - X_callback *callb, - X_button_style *style, - int xp, - int yp, - int xs, - int ys, - int opts) : - X_window (parent, xp, yp, xs, ys, style->color.shadow.bgnd), - _style (style), - _callb (callb), - _xs (xs), - _ys (ys), - _km (0), - _k0 (0), - _dk (0), - _dw (0), - _zz (INT_MIN), - _offs (0.0f), - _frac (1.0f) -{ - X_ibutton *B; - - x_add_events (ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask); - style->type = X_button_style::RAISED; - - if (xs >= 2 * ys) - { - style->size.x = DL; - style->size.y = DW; - _km = xs - 1; - _dw = (ys - DW) >> 1; - if (opts & ENDGAP) _km -= _ys; - if (opts & PLUSMIN) - { - _km -= DL; - B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_MI), X_callback::SCROLL | B1MI); - B->x_set_win_gravity (NorthEastGravity); - B->x_map (); - _km -= DL; - B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_PL), X_callback::SCROLL | B1PL); - B->x_set_win_gravity (NorthEastGravity); - B->x_map (); - } - if (opts & MIDGAP) _km -= _ys; - if (opts & ARROWS) - { - _km -= DL; - B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_RT), X_callback::SCROLL | B1RD); - B->x_set_win_gravity (NorthEastGravity); - B->x_map (); - _km -= DL; - B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_LT), X_callback::SCROLL | B1LU); - B->x_set_win_gravity (NorthEastGravity); - B->x_map (); - } - } - else if (ys >= 2 * xs) - { - style->size.x = DW; - style->size.y = DL; - _km = ys - 1; - _dw = (xs - DW) >> 1; - if (opts & ENDGAP) _km -= _xs; - if (opts & PLUSMIN) - { - _km -= DL; - B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_MI), X_callback::SCROLL | B1MI); - B->x_set_win_gravity (SouthWestGravity); - B->x_map (); - _km -= DL; - B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_PL), X_callback::SCROLL | B1PL); - B->x_set_win_gravity (SouthWestGravity); - B->x_map (); - } - if (opts & MIDGAP) _km -= _xs; - if (opts & ARROWS) - { - _km -= DL; - B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_DN), X_callback::SCROLL | B1RD); - B->x_set_win_gravity (SouthWestGravity); - B->x_map (); - _km -= DL; - B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_UP), X_callback::SCROLL | B1LU); - B->x_set_win_gravity (SouthWestGravity); - B->x_map (); - } - } - _km -= 1; -} - - -X_scroll::~X_scroll (void) -{ -} - - -void X_scroll::handle_event (XEvent *E) -{ - switch (E->type) - { - case Expose: - expose ((XExposeEvent *) E); - break; - - case ButtonPress: - bpress ((XButtonEvent *) E); - break; - - case ButtonRelease: - brelease ((XButtonEvent *) E); - break; - - case MotionNotify: - bmotion ((XMotionEvent *) E); - break; - } -} - - -void X_scroll::bpress (XButtonEvent *E) -{ - int k; - - k = (_xs > _ys) ? E->x - 1 : E->y - 1; - if (! _callb || (k < 0) || (k >= _km)) return; - k -= _k0; - if (k >= _dk) _callb->handle_callb (X_callback::SCROLL | ((E->button == Button3) ? C3RD : C1RD), this, 0); - else if (k < 0) _callb->handle_callb (X_callback::SCROLL | ((E->button == Button3) ? C3LU : C1LU), this, 0); - else _zz = k + _k0; -} - - -void X_scroll::brelease (XButtonEvent *E) -{ - if (_zz != INT_MIN) - { - _zz = INT_MIN; - _callb->handle_callb (X_callback::SCROLL | STOP, this, 0); - } -} - - -void X_scroll::bmotion (XMotionEvent *E) -{ - int d, k; - - if (_zz == INT_MIN) return; - k = (_xs > _ys) ? E->x - 1 : E->y - 1; - d = k - _zz; - if (_k0 + d <= 0) - { - d = -_k0; - _offs = 0.0f; - } - else if (_k0 + d >= _km - _dk) - { - d = _km - _dk - _k0; - _offs = 1.0f; - } - else - { - _offs += d / (float)(_km - _dk); - } - if (d) - { - _zz += d; - _callb->handle_callb (X_callback::SCROLL | MOVE, this, 0); - redraw (); - } -} - - -void X_scroll::expose (XExposeEvent *E) -{ - if (E->count == 0) redraw (); -} - - -void X_scroll::geom (float offs, float frac, int size) -{ - if (size) - { - if (_xs > _ys) - { - _km += size - _xs; - _xs = size; - } - else - { - _km += size - _ys; - _ys = size; - } - XResizeWindow (dpy (), win (), _xs, _ys); - } - _offs = offs; - _frac = frac; - redraw (); -} - - -void X_scroll::move (float drel) -{ - _offs += drel * _frac; - if (_offs < 0.0f) _offs = 0.0f; - if (_offs > 1.0f) _offs = 1.0f; - redraw (); -} - - -void X_scroll::redraw (void) -{ - _dk = (int)(_frac * _km + 0.5f); - if (_dk < 8) _dk = 8; - _k0 = (int)(_offs * (_km - _dk) + 0.5f); - XSetFunction (dpy (), dgc (), GXcopy); - XSetLineAttributes (dpy (), dgc (), 0, LineSolid, CapButt, JoinBevel); - if (_xs > _ys) - { - XSetForeground (dpy (), dgc (), _style->color.shadow.bgnd); - XFillRectangle (dpy (), win (), dgc (), 0, 0, _k0 + 2, _ys); - XFillRectangle (dpy (), win (), dgc (), _k0 + _dk, 0, _km - _k0 - _dk + 1, _ys); - XSetForeground (dpy (), dgc (), _style->color.bg [1]); - XFillRectangle (dpy (), win (), dgc (), _k0 + 2, _dw + 1, _dk - 2, 11); - XSetForeground (dpy (), dgc (), _style->color.shadow.lite); - XDrawLine (dpy (), win (), dgc (), _k0 + 1, _dw, _k0 + 1, _dw + DW - 2); - XDrawLine (dpy (), win (), dgc (), _k0 + 1, _dw, _k0 + _dk - 1, _dw); - XSetForeground (dpy (), dgc (), _style->color.shadow.dark); - XDrawLine (dpy (), win (), dgc (), _k0 + _dk, _dw + DW - 1, _k0 + 2, _dw + DW - 1); - XDrawLine (dpy (), win (), dgc (), _k0 + _dk, _dw + DW - 1, _k0 + _dk, _dw + 1); - } - else - { - XSetForeground (dpy (), dgc (), _style->color.shadow.bgnd); - XFillRectangle (dpy (), win (), dgc (), 0, 0, _xs, _k0 + 2); - XFillRectangle (dpy (), win (), dgc (), 0, _k0 + _dk, _xs, _km - _k0 - _dk + 1); - XSetForeground (dpy (), dgc (), _style->color.bg [1]); - XFillRectangle (dpy (), win (), dgc (), _dw + 1, _k0 + 2, 11, _dk - 2); - XSetForeground (dpy (), dgc (), _style->color.shadow.lite); - XDrawLine (dpy (), win (), dgc (), _dw, _k0 + 1, _dw + DW - 2, _k0 + 1); - XDrawLine (dpy (), win (), dgc (), _dw, _k0 + 1, _dw, _k0 + _dk - 1); - XSetForeground (dpy (), dgc (), _style->color.shadow.dark); - XDrawLine (dpy (), win (), dgc (), _dw + DW - 1, _k0 + _dk, _dw + DW - 1, _k0 + 2); - XDrawLine (dpy (), win (), dgc (), _dw + DW - 1, _k0 + _dk, _dw + 1, _k0 + _dk); - } -} - - -void X_scroll::handle_callb (int type, X_window *W, XEvent *E) -{ - X_button *B = (X_button *) W; - XButtonEvent *Z = (XButtonEvent *) E; - if (_callb) _callb->handle_callb (B->cbid () + ((Z->button == Button3) ? 1 : 0), this, E); -} diff -Nru clxclient-3.9.0/slider.cc clxclient-3.9.2/slider.cc --- clxclient-3.9.0/slider.cc 2013-06-28 14:47:55.000000000 +0000 +++ clxclient-3.9.2/slider.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,356 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -X_slider::X_slider (X_window *parent, X_callback *callb, X_slider_style *style, X_scale_style *scale, - int xp, int yp, int xs, int ys, int cbid) : - X_window (parent, xp, yp, xs, ys, style->bg), - _callb (callb), - _style (style), - _scale (scale), - _x (0), - _y (0), - _i (_scale->pix [0]), - _d (9999), - _cbid (cbid), - _knob (_style->knob), - _mark (_style->mark) -{ - x_add_events (ExposureMask | Button1MotionMask | ButtonPressMask | ButtonReleaseMask); -} - - -void X_slider::brelease (XButtonEvent *E) -{ - _d = 9999; - if (_callb) _callb->handle_callb (X_callback::SLIDER | STOP, this, (XEvent *) E); -} - - - - - -X_hslider::X_hslider (X_window *parent, X_callback *callb, X_slider_style *style, X_scale_style *scale, - int xp, int yp, int h, int cbid) : - X_slider (parent, callb, style, scale, xp, yp, scale->length (), h, cbid) -{ - _y = h; - _x = _scale->marg; -} - - -void X_hslider::handle_event (XEvent *E) -{ - XMotionEvent *M = (XMotionEvent *) E; - XButtonEvent *B = (XButtonEvent *) E; - - switch (E->type) - { - case Expose: - plines (); - plknob (_i); - break; - - case ButtonPress: - if (B->button == Button4) - { - if (domove (_scale->limit (_i + 1)) && _callb) - { - _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); - } - } - else if (B->button == Button5) - { - if (domove (_scale->limit (_i - 1)) && _callb) - { - _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); - } - } - else - { - _d = B->x - _x - _i; - if (abs (2 * _d) >= _style->h) _d = 9999; - } - break; - - case ButtonRelease: - brelease (B); - break; - - case MotionNotify: - if ((_d < 9999) && domove (_scale->limit (M->x - _x - _d)) && _callb) - { - _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); - } - - break; - - default: - fprintf (stderr, "X_slider: event %d\n", E->type ); - } -} - - -void X_hslider::set_color (unsigned long knob, unsigned long mark) -{ - if ((_knob != knob) || (_mark != mark)) - { - _knob = knob; - _mark = mark; - plknob (_i); - } -} - - -void X_hslider::set_val (float v) -{ - domove (_scale->calcpix (v)); -} - - -bool X_hslider::domove (int i) -{ - if (i == _i) return false; - erase (_i); - plines (); - plknob (_i = i); - return true; -} - - -void X_hslider::plines (void) -{ - int x, k, *p; - GC gc = disp ()->dgc (); - - XSetFunction (dpy (), gc, GXcopy); - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - XSetForeground (dpy (), gc, _scale->fg->pixel); - k = _scale->nseg + 1; - p = _scale->pix; - while (k--) - { - x = _x + *p++; - XDrawLine (dpy (), win (), gc, x, 0, x, _y); - } - k = _y / 2; - XSetForeground (dpy (), gc, _style->dark); - XDrawLine (dpy (), win (), gc, _x, k - 1, _x + _scale->pixlen (), k - 1); - XSetForeground (dpy (), gc, _style->lite); - XDrawLine (dpy (), win (), gc, _x, k, _x + _scale->pixlen (), k); -} - - -void X_hslider::plknob (int i) -{ - int x, y, h, w; - GC gc = disp ()->dgc (); - - h = _style->h; - w = _style->w; - x = i + _x - h / 2; - y = (_y - w) / 2; - XSetFunction (dpy (), gc, GXcopy); - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - XSetForeground (dpy (), gc, _knob); - XFillRectangle (dpy (), win (), gc, x, y, h, w); - XSetForeground (dpy (), gc, _mark); - XDrawLine (dpy (), win (), gc, x + h / 2, y, x + h / 2, y + w); - - XSetForeground (dpy (), gc, _style->lite); - XDrawLine (dpy (), win (), gc, x - 1, y - 1, x - 1, y + w); - XDrawLine (dpy (), win (), gc, x - 1, y - 1, x + h, y - 1); - - XSetForeground (dpy (), gc, _style->dark); - XDrawLine (dpy (), win (), gc, x + h, y + w, x + h, y); - XDrawLine (dpy (), win (), gc, x + h, y + w, x, y + w); -} - - -void X_hslider::erase (int i) -{ - int x, y, h, w; - GC gc = disp ()->dgc (); - - h = _style->h; - w = _style->w; - x = i + _x - h / 2; - y = (_y - w) / 2; - XSetFunction (dpy (), gc, GXcopy); - XSetForeground (dpy (), gc, _style->bg); - XFillRectangle (dpy (), win (), gc, x - 1, y - 1, h + 2, w + 2); -} - - - -X_vslider::X_vslider (X_window *parent, X_callback *callb, X_slider_style *style, X_scale_style *scale, - int xp, int yp, int w, int cbid) : - X_slider (parent, callb, style, scale, xp, yp, w, scale->length (), cbid) -{ - _x = w; - _y = _scale->marg + scale->pixlen () - 1; -} - - -void X_vslider::handle_event (XEvent *E) -{ - XMotionEvent *M = (XMotionEvent *) E; - XButtonEvent *B = (XButtonEvent *) E; - - switch (E->type) - { - case Expose: - plines (); - plknob (_i); - break; - - case ButtonPress: - if (B->button == Button4) - { - if (domove (_scale->limit (_i + 1)) && _callb) - { - _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); - } - } - else if (B->button == Button5) - { - if (domove (_scale->limit (_i - 1)) && _callb) - { - _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); - } - } - else - { - _d = M->y - _y + _i; - if (abs (2 * _d) >= _style->h) _d = 9999; - } - break; - - case ButtonRelease: - brelease (B); - break; - - case MotionNotify: - if ((_d < 9999) && domove (_scale->limit (_d + _y - M->y)) && _callb) - { - _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); - } - break; - - default: - fprintf (stderr, "X_slider: event %d\n", E->type ); - } -} - - -void X_vslider::set_color (unsigned long knob, unsigned long mark) -{ - if ((_knob != knob) || (_mark != mark)) - { - _knob = knob; - _mark = mark; - plknob (_i); - } -} - - -void X_vslider::set_val (float v) -{ - domove (_scale->calcpix (v)); -} - - -bool X_vslider::domove (int i) -{ - if (i == _i) return false; - erase (_i); - plines (); - plknob (_i = i); - return true; -} - - -void X_vslider::plines (void) -{ - int k, y, *p; - - GC gc = disp ()->dgc (); - - XSetFunction (dpy (), gc, GXcopy); - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - XSetForeground (dpy (), gc, _scale->fg->pixel); - k = _scale->nseg + 1; - p = _scale->pix; - while (k--) - { - y = _y - *p++; - XDrawLine (dpy (), win (), gc, 0, y, _x, y); - } - k = _x / 2; - XSetForeground (dpy (), gc, _style->dark); - XDrawLine (dpy (), win (), gc, k - 1, _y - _scale->pixlen (), k - 1, _y); - XSetForeground (dpy (), gc, _style->lite); - XDrawLine (dpy (), win (), gc, k, _y - _scale->pixlen (), k, _y); -} - - -void X_vslider::plknob (int i) -{ - int x, y, h, w; - GC gc = disp ()->dgc (); - - h = _style->h; - w = _style->w; - x = (_x - w) / 2; - y = _y - i - h / 2; - - XSetFunction (dpy (), gc, GXcopy); - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - XSetForeground (dpy (), gc, _knob); - XFillRectangle (dpy (), win (), gc, x, y, w, h); - XSetForeground (dpy (), gc, _mark); - XDrawLine (dpy (), win (), gc, x, y + h / 2, x + w, y + h / 2); - - XSetForeground (dpy (), gc, _style->lite); - XDrawLine (dpy (), win (), gc, x - 1, y - 1, x - 1, y + h); - XDrawLine (dpy (), win (), gc, x - 1, y - 1, x + w, y - 1); - XSetForeground (dpy (), gc, _style->dark); - XDrawLine (dpy (), win (), gc, x + w, y + h, x, y + h); - XDrawLine (dpy (), win (), gc, x + w, y + h, x + w, y); -} - - -void X_vslider::erase (int i) -{ - int x, y, h, w; - GC gc = disp ()->dgc (); - - h = _style->h; - w = _style->w; - x = (_x - w) / 2; - y = _y - i - h / 2; - XSetFunction (dpy (), gc, GXcopy); - XSetForeground (dpy (), gc, _style->bg); - XFillRectangle (dpy (), win (), gc, x - 1, y - 1, w + 2, h + 2); -} - diff -Nru clxclient-3.9.0/source/button.cc clxclient-3.9.2/source/button.cc --- clxclient-3.9.0/source/button.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/button.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,311 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +X_button::X_button (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, int yp, + int cbid) : + X_window (parent, xp, yp, style->size.x, style->size.y, style->color.shadow.bgnd), + _style (style), + _callb (callb), + _xs (style->size.x), + _ys (style->size.y), + _cbid (cbid), + _down (0), + _stat (0) +{ + x_add_events (ExposureMask); + if (_callb) x_add_events (ButtonPressMask | ButtonReleaseMask | Button1MotionMask | LeaveWindowMask); +} + + +X_button::~X_button (void) +{ +} + + +void X_button::handle_event (XEvent *E) +{ + switch (E->type) + { + case Expose: + expose ((XExposeEvent *) E); + break; + + case ButtonPress: + bpress ((XButtonEvent *) E); + break; + + case ButtonRelease: + brelease ((XButtonEvent *) E); + break; + + case MotionNotify: + _callb->handle_callb (X_callback::BUTTON | MOVE, this, E); + break; + + case LeaveNotify: + release (); + break; + } +} + + +void X_button::bpress (XButtonEvent *E) +{ + _down = 1; + redraw (); + _callb->handle_callb (X_callback::BUTTON | PRESS, this, (XEvent *) E); +} + + +void X_button::brelease (XButtonEvent *E) +{ + _down = 0; + redraw (); + _callb->handle_callb (X_callback::BUTTON | RELSE, this, (XEvent *) E); +} + + +void X_button::expose (XExposeEvent *E) +{ + if (E->count == 0) redraw (); +} + + +void X_button::release (void) +{ + if (_style->type & X_button_style::HOLDPTR) return; + XUngrabPointer (dpy (), CurrentTime); + _down = 0; + redraw (); +} + + +void X_button::set_stat (int stat) +{ + if (_stat != stat) + { + _stat = stat; + redraw (); + } +} + + +void X_button::redraw (void) +{ + GC gc = disp ()->dgc (); + + XSetFunction (dpy (), gc, GXcopy); + XSetLineAttributes (dpy (), gc, 0, LineSolid, CapButt, JoinBevel); + switch (_style->type & 3) + { + case X_button_style::RAISED: + XSetForeground (dpy (), gc, _down ? _style->color.shadow.dark : _style->color.shadow.lite); + XDrawLine (dpy (), win (), gc, 0, 0, 0, _ys - 2); + XDrawLine (dpy (), win (), gc, 0, 0, _xs - 2, 0); + XSetForeground (dpy (), gc, _down ? _style->color.shadow.lite : _style->color.shadow.dark); + XDrawLine (dpy (), win (), gc, _xs - 1, 1, _xs - 1, _ys); + XDrawLine (dpy (), win (), gc, 1, _ys - 1, _xs, _ys - 1); + XSetForeground (dpy (), gc, _style->color.shadow.bgnd); + XDrawPoint (dpy (), win (), gc, 0, _ys - 1); + XDrawPoint (dpy (), win (), gc, _xs - 1, 0); + break; + } +} + + + +X_tbutton::X_tbutton (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + const char *text1, + const char *text2, + int cbid) : + X_button (parent, callb, style, xp, yp, cbid), + _bg (0), + _fg (0), + _len1 (0), + _len2 (0) +{ + set_text (text1, text2); +} + + +X_tbutton::~X_tbutton (void) +{ +} + + +void X_tbutton::set_text (const char *text1, const char *text2) +{ + _len1 = 0; + _len2 = 0; + if (text1) while (((*(unsigned char *) text1) >= ' ') && (_len1 < MAXLEN - 1)) _text1 [_len1++] = *text1++; + if (text2) while (((*(unsigned char *) text2) >= ' ') && (_len2 < MAXLEN - 1)) _text2 [_len2++] = *text2++; + _text1 [_len1] = 0; + _text2 [_len2] = 0; +} + + +void X_tbutton::redraw (void) +{ + int a, d, u, x, y; + GC G = dgc (); + XftDraw *D = xft (); + XftColor *C; + XftFont *F = _style->font; + XGlyphInfo K; + unsigned long b; + + XftDrawChange (D, win ()); + XSetFunction (dpy (), G, GXcopy); + b = (_stat > 3) ? _bg : _style->color.bg [_stat]; + XSetForeground (dpy (), G, b); + XFillRectangle (dpy (), win (), G, 0, 0, _xs, _ys); + + a = F->ascent; + d = F->descent; + u = a + d - _ys / 2; + if (u < 0) u = 0; + + C = (_stat > 3) ? _fg : _style->color.fg [_stat]; + if (_len1) + { + y = (_len2) ? _ys / 2 - d + u : (_ys + a - d) / 2; + if (_style->type & X_button_style::ALEFT) x = 6; + else + { + XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) _text1, _len1, &K); + if (_style->type & X_button_style::ARIGHT) x = _xs - K.width - 6; + else x = (_xs - K.width) / 2; + } + if (_down) { x += 1; y += 1; } + XftDrawStringUtf8 (D, C, F, x, y, (const FcChar8 *) _text1, _len1); + } + if (_len2) + { + y = (_len1) ? _ys / 2 + a - u : (_ys + a - d) / 2; + if (_style->type & X_button_style::ALEFT) x = 6; + else + { + XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) _text2, _len2, &K); + if (_style->type & X_button_style::ARIGHT) x = _xs - K.width - 6; + else x = (_xs - K.width) / 2; + } + if (_down) { x += 1; y += 1; } + XftDrawStringUtf8 (D, C, F, x, y, (const FcChar8 *) _text2, _len2); + } + if ((_style->type & 3) == X_button_style::BORDER) + { + XSetLineAttributes (dpy (), G, 1, LineSolid, CapButt, JoinBevel); + XSetForeground (dpy (), G, C->pixel); + XDrawRectangle (dpy (), win (), G, 0, 0, _xs - 1, _ys - 1); + } + else X_button::redraw (); +} + + + +X_ibutton::X_ibutton (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + XImage *image, + int cbid) : + X_button (parent, callb, style, xp, yp, cbid), + _bg (0), + _fg (0), + _image (image) +{ +} + + +X_ibutton::~X_ibutton (void) +{ +} + + +void X_ibutton::redraw (void) +{ + int x, y; + unsigned long b, f; + + b = (_stat > 3) ? _bg : _style->color.bg [_stat]; + f = (_stat > 3) ? _fg : _style->color.fg [_stat]->pixel; + XSetState (dpy (), dgc (), f, b, GXcopy, ~0); + XSetWindowBackground (dpy (), win (), b); + XClearWindow (dpy (), win ()); + if (_image) + { + x = (_xs - _image->width) / 2; + y = (_ys - _image->height) / 2; + XPutImage (dpy (), win (), dgc (), _image, 0, 0, x, y, _xs, _ys); + } + if ((_style->type & 3) == X_button_style::BORDER) + { + XSetLineAttributes (dpy (), dgc (), 1, LineSolid, CapButt, JoinBevel); + XSetForeground (dpy (), dgc (), f); + XDrawRectangle (dpy (), win (), dgc (), 0, 0, _xs - 1, _ys - 1); + } + else X_button::redraw (); +} + + + +X_pbutton::X_pbutton (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, int yp, + Pixmap map0, + Pixmap map1, + int cbid) : + X_button (parent, callb, style, xp, yp, cbid), + _map0 (map0), + _map1 (map1) +{ + if (_map0) XSetWindowBackgroundPixmap (dpy (), win (), _map0); +} + + +X_pbutton::~X_pbutton (void) +{ +} + + +void X_pbutton::set_stat (bool stat) +{ + if (_stat != stat) + { + if (_map1) XSetWindowBackgroundPixmap (dpy (), win (), stat ? _map1 : _map0); + _stat = stat; + XClearWindow (dpy (), win ()); + X_button::redraw (); + } +} + diff -Nru clxclient-3.9.0/source/clxclient.h clxclient-3.9.2/source/clxclient.h --- clxclient-3.9.0/source/clxclient.h 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/clxclient.h 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,1289 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#ifndef __CLXCLIENT_H +#define __CLXCLIENT_H + + +#include +#include +#include +#include +#include +#include +#include + + +// ------------------------------------------------------------------------------------------- + +const char *clxclient_version (void); + +// ------------------------------------------------------------------------------------------- + + +class X_display +{ +public: + + X_display (const char *dispname); + ~X_display (void); + + unsigned long blackpixel (void) const { return BlackPixel (_dpy, _dsn); } + unsigned long whitepixel (void) const { return WhitePixel (_dpy, _dsn); } + + Display *dpy (void) const { return _dpy; } + int dsn (void) const { return _dsn; } + Colormap dcm (void) const { return _dcm; } + GC dgc (void) const { return _dgc; } + Visual *dvi (void) const { return _dvi; } + XftDraw *xft (void) const { return _xft; } + XIM xim (void) const { return _xim; } + + int depth (void) const { return DefaultDepth (_dpy, _dsn); } + int xsize (void) const { return WidthOfScreen (ScreenOfDisplay (_dpy, _dsn)); } + int ysize (void) const { return HeightOfScreen (ScreenOfDisplay (_dpy, _dsn)); } + int gray (void) const { return 0; } + + unsigned long alloc_color (const char *name, unsigned long d); + unsigned long alloc_color (float r, float g, float b); + XftColor *alloc_xftcolor (const char *name, XftColor *D); + XftColor *alloc_xftcolor (float r, float g, float b, float a); + void free_xftcolor (XftColor *C); + + XFontStruct *alloc_font (const char *name); + XftFont *alloc_xftfont (const char *name); + void free_xftfont (XftFont *F); + + enum { IMG_LT, IMG_RT, IMG_UP, IMG_DN, IMG_PL, IMG_MI, IMG_SQ, IMG_PT, N_IMG1515 }; + + void nofocus (void) { XSetInputFocus (_dpy, PointerRoot, PointerRoot, CurrentTime); } + + XImage *image1515 (unsigned int i); + +private: + + friend class X_rootwin; + friend class X_window; + friend class X_handler; + + Display *_dpy; + int _dsn; + Colormap _dcm; + GC _dgc; + Visual *_dvi; + XftDraw *_xft; + XIM _xim; + + static unsigned char _imgdef1515 [N_IMG1515 * 30]; + XImage *_imgptr1515 [N_IMG1515]; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_hints +{ +public: + + X_hints (void) { _sh.flags = 0; _mh.flags = 0; _ch.res_name = 0; _ch.res_class = 0; } + + void position (int x, int y); + void size (int x, int y); + void minsize (int x, int y); + void maxsize (int x, int y); + void sizeinc (int x, int y); + void input (int input); + void state (int state); + void group (Window group); + void rname (const char *rname) { _ch.res_name = (char *) rname; } + void rclas (const char *rclas) { _ch.res_class = (char *) rclas; } + + friend class X_window; + +private: + + XSizeHints _sh; + XWMHints _mh; + XClassHint _ch; + +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_window +{ +public: + + X_window (X_window *pwin, int xpos, int ypos, int xsize, int ysize, + unsigned long bgcol, unsigned long bdcol = 0, int bdpix = 0); + + virtual ~X_window (void); + + X_display* disp (void) const { return _disp; } + + Display *dpy (void) const { return _disp->_dpy; } + int dsn (void) const { return _disp->_dsn; } + Colormap dcm (void) const { return _disp->_dcm; } + GC dgc (void) const { return _disp->_dgc; } + Visual *dvi (void) const { return _disp->_dvi; } + XftDraw *xft (void) const { return _disp->_xft; } + XIM xim (void) const { return _disp->_xim; } + Window win (void) const { return _wind; } + + virtual void handle_event (XEvent *E) {} + + int x_map (void) const { return XMapWindow (_disp->_dpy, _wind); } + int x_mapraised (void) const { return XMapRaised (_disp->_dpy, _wind); } + int x_unmap (void) const { return XUnmapWindow (_disp->_dpy, _wind); } + int x_clear (void) const { return XClearWindow (_disp->_dpy, _wind); } + int x_raise (void) const { return XRaiseWindow (_disp->_dpy, _wind); } + int x_move (int xp, int yp) const; + int x_resize (int xs, int ys) const; + int x_moveresize (int xp, int yp, int xs, int ys) const; + int x_set_attrib (unsigned long mask, XSetWindowAttributes *attr) const; + int x_set_win_gravity (int gravity) const; + int x_set_bit_gravity (int gravity) const; + int x_add_events (unsigned long events); + int x_rem_events (unsigned long events); + int x_set_title (const char *title); + int x_set_background (unsigned long color); + void x_apply (X_hints *hints); + + X_window *pwin (void) { return _pwin; } + + friend class X_rootwin; + +private: + + X_window (X_display *disp); + X_window (const X_window&); + X_window& operator=(const X_window&); + X_window *find (Window w); + + unsigned long _ebits; + X_display *_disp; + X_window *_pwin; + X_window *_next; + X_window *_list; + Window _wind; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_subwin : public X_window +{ +public: + + X_subwin (X_window *pwin, int xpos, int ypos, int xsize, int ysize, + unsigned long bgcol, unsigned long bdcol = 0, int bdpix = 0) : + X_window (pwin, xpos, ypos, xsize, ysize, bgcol, bdcol, bdpix) + {} + + virtual void handle_event (XEvent *E) { pwin ()->handle_event (E); } +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_rootwin : public X_window +{ +public: + + X_rootwin (X_display *disp); + virtual ~X_rootwin (void); + + void handle_event (void); + void handle_event (XEvent *E); + bool check_done (void) const { return _list == 0; } + +private: + + Window _window; + X_window *_object; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_resman +{ +public: + + enum { NDEFOPT = 13 }; + + X_resman (void); + ~X_resman (void); + X_resman (const X_resman&); + X_resman& operator=(const X_resman&); + + void init (int *argc, char *argv [], char *name, XrmOptionDescRec *opt, int nopt); + + const char *get (const char *res, const char *def) const; + int getb (const char *res, int def) const; + void geometry (const char *res, int xd, int yd, int bd, + int &xp, int &yp, int &xs, int &ys); + + const char *rname (void) { return _rname; } + const char *rclas (void) { return _rclas; } + +private: + + char _rname [64]; + char _rclas [64]; + char *_home; + XrmDatabase _xrmdata; + + static XrmOptionDescRec defopt [X_resman::NDEFOPT]; +}; + + + +// ------------------------------------------------------------------------------------------- + + +extern "C" int x_handler_error (Display *dpy, XErrorEvent *err); + + +class X_handler : public H_thread +{ +public: + + X_handler (X_display *disp, Edest *dest, int ipid); + ~X_handler (void); + + void thr_main (void); + void next_event (void) { put_event (ITC_ip1q::N_MQ, 1); } + +private: + + int _conn; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_callback +{ +public: + + virtual ~X_callback (void) {} + + enum + { + BUTTON = 0x010000, + TEXTIP = 0x010100, + ENUMIP = 0x010200, + ROTARY = 0x010300, + SLIDER = 0x010400, + SCROLL = 0x010500, + MENU = 0x010600, + MCLIST = 0x010700 + }; + + virtual void handle_callb (int /*type*/, X_window */*W*/, XEvent */*E*/) = 0; + static int cb_class (int k) { return k & 0xFFFFFF00; } + static int cb_event (int k) { return k & 0x000000FF; } +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_draw +{ +public: + + X_draw (Display *dpy, Drawable drw, GC gct, XftDraw *xft); + ~X_draw (void) {} + + void setfont (XFontStruct *font) { _xft_font = 0; _x11_font = font; XSetFont (_dpy, _gct, font->fid); } + void setfont (XftFont *font) { _x11_font = 0; _xft_font = font; } + void setcolor (unsigned long c) { _xft_color = 0; XSetForeground (_dpy, _gct, c); } + void setcolor (XftColor *c) { _xft_color = c; XSetForeground (_dpy, _gct, c->pixel); } + void setfunc (int f) { XSetFunction (_dpy, _gct, f); } + void setline (int d, int f = LineSolid, int c = CapButt, int j = JoinBevel) { XSetLineAttributes (_dpy, _gct, d, f, c, j); } + void setdash (char *v, int n, int i = 0) { XSetDashes (_dpy, _gct, i, v, n); } + void move (int x, int y) { _xx = x; _yy = y; } + void rmove (int x, int y) { _xx += x; _yy += y; } + void draw (int x, int y) { XDrawLine (_dpy, _drw, _gct, _xx, _yy, x, y); _xx = x; _yy = y; } + void rdraw (int x, int y) { XDrawLine (_dpy, _drw, _gct, _xx, _yy, _xx + x, _yy + y); _xx += x; _yy += y; } + void drawline (int x0, int y0, int x1, int y1) { XDrawLine (_dpy, _drw, _gct, x0, y0, x1, y1); } + void drawrect (int x0, int y0, int x1, int y1) { XDrawRectangle (_dpy, _drw, _gct, x0, y0, x1 - x0, y1 - y0); } + void fillrect (int x0, int y0, int x1, int y1) { XFillRectangle (_dpy, _drw, _gct, x0, y0, x1 - x0, y1 - y0); } + void drawrect (int dx, int dy) { XDrawRectangle (_dpy, _drw, _gct, _xx, _yy, dx, dy); } + void fillrect (int dx, int dy) { XFillRectangle (_dpy, _drw, _gct, _xx, _yy, dx, dy); } + void drawarc (int dx, int dy, int a1, int a2) { XDrawArc (_dpy, _drw, _gct, _xx, _yy, dx, dy, a1, a2); } + void fillarc (int dx, int dy, int a1, int a2) { XFillArc (_dpy, _drw, _gct, _xx, _yy, dx, dy, a1, a2); } + void movepix (int dx, int dy, int xs, int ys); + void setclip (int x0, int y0, int x1, int y1); + void noclip (void) { XSetClipMask (_dpy, _gct, None); } + void drawpoints (int n, XPoint *P); + void drawlines (int n, XPoint *P); + void drawsegments (int n, XSegment *S); + void putimage (XImage *I) { XPutImage (_dpy, _drw, _gct, I, 0, 0, _xx, _yy, I->width, I->height); } + void clearwin (void) { XClearWindow (_dpy, _drw); } + + int textwidth (const char *str); + int textascent (void) { return _xft_font ? _xft_font->ascent : (_x11_font ? _x11_font->ascent : 0); } + int textdescent (void) { return _xft_font ? _xft_font->descent : (_x11_font ? _x11_font->descent : 0); } + void drawstring (const char *str, int xal); + +private: + + Display *_dpy; + Drawable _drw; + GC _gct; + XftDraw *_xft_draw; + XftColor *_xft_color; + XftFont *_xft_font; + XFontStruct *_x11_font; + int _xx; + int _yy; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_linked +{ +private: + + X_linked (X_linked *back, X_linked *forw) : + _back (back), + _forw (forw) + { + if (back) back->_forw = this; + if (forw) forw->_back = this; + } + + virtual ~X_linked (void) + { + if (_back) _back->_forw = _forw; + if (_forw) _forw->_back = _back; + } + + virtual void select (void) = 0; + + friend class X_textip; + friend class X_enumip; + + X_linked *_back; + X_linked *_forw; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_button_style +{ +public: + + enum { PLAIN = 0, BORDER = 1, RAISED = 2, ALEFT = 4, ARIGHT = 8, HOLDPTR = 16 }; + + XftFont *font; + struct + { + unsigned long bg [4]; + XftColor *fg [4]; + struct + { + unsigned long bgnd; + unsigned long lite; + unsigned long dark; + } shadow; + } color; + struct + { + int x; + int y; + } size; + int type; +}; + + +class X_button : public X_window +{ +public: + + enum { MOVE, PRESS, RELSE }; + + int cbid (void) const { return _cbid; } + int stat (void) const { return _stat; } + void set_cbid (int cbid) { _cbid = cbid; } + void release (void); + virtual void set_stat (int stat); + virtual void redraw (void); + +protected: + + X_button (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + int cbid); + + ~X_button (void); + + void handle_event (XEvent *E); + void expose (XExposeEvent *E); + void bpress (XButtonEvent *E); + void brelease (XButtonEvent *E); + + const X_button_style *_style; + X_callback *_callb; + int _xs; + int _ys; + int _cbid; + int _down; + int _stat; +}; + + +class X_tbutton : public X_button +{ +public: + + enum { MAXLEN = 24 }; + + X_tbutton (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + const char *text1 = 0, + const char *text2 = 0, + int cbid = 0); + + ~X_tbutton (void); + + virtual void redraw (void); + + void set_col (unsigned long bg, XftColor *fg) { _bg = bg, _fg = fg; } + void set_text (const char *txt1, const char *txt2); + const char *text1 (void) const { return _text1; } + const char *text2 (void) const { return _text2; } + +private: + + unsigned long _bg; + XftColor *_fg; + int _len1; + int _len2; + char _text1 [MAXLEN]; + char _text2 [MAXLEN]; +}; + + +class X_ibutton : public X_button +{ +public: + + enum { MAXLEN = 24 }; + + X_ibutton (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + XImage *image, + int cbid = 0); + + ~X_ibutton (void); + + virtual void redraw (void); + + void set_col (unsigned long bg, unsigned long fg) { _bg = bg, _fg = fg; } + void set_image (XImage *image) { _image = image; } + const XImage *image (void) const { return _image; } + +private: + + unsigned long _bg; + unsigned long _fg; + XImage *_image; +}; + + +class X_pbutton : public X_button +{ +public: + + X_pbutton (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + Pixmap map0, + Pixmap map1, + int cbid = 0); + + ~X_pbutton (void); + + virtual void set_stat (bool stat); + + const Pixmap map0 (void) const { return _map0; } + const Pixmap map1 (void) const { return _map1; } + +private: + + Pixmap _map0; + Pixmap _map1; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_scroll : public X_window, public X_callback +{ +public: + + enum { ENDGAP = 1, PLUSMIN = 2, MIDGAP = 4, ARROWS = 8 }; + enum { MOVE, STOP, C1LU, C3LU, C1RD, C3RD, B1LU, B3LU, B1RD, B3RD, B1PL, B3PL, B1MI, B3MI, MB4, MB5 }; + + void redraw (void); + + X_scroll (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + int xs, + int ys, + int opts); + + ~X_scroll (void); + + float offs (void) const { return _offs; } + float frac (void) const { return _frac; } + void geom (float offs, float frac, int size = 0); + void move (float drel); + +private: + + void handle_event (XEvent *E); + void bpress (XButtonEvent *E); + void brelease (XButtonEvent *E); + void bmotion (XMotionEvent *E); + void expose (XExposeEvent *E); + + virtual void handle_callb (int type, X_window *W, XEvent *E); + + const X_button_style *_style; + X_callback *_callb; + int _xs; + int _ys; + int _km; + int _k0; + int _dk; + int _dw; + int _zz; + float _offs; + float _frac; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_textln_style +{ + +public: + + XftFont *font; + struct + { + struct + { + unsigned long bgnd; + XftColor *text; + } normal; + struct + { + unsigned long bgnd; + XftColor *text; + unsigned long line; + } focus; + struct + { + unsigned long bgnd; + unsigned long lite; + unsigned long dark; + } shadow; + } color; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_textln : public X_window +{ +public: + + X_textln (X_window *parent, + X_textln_style *style, + int xp, + int yp, + int xs, + int ys, + const char *text, + int xal); + + ~X_textln (void); + + int base (void) const { return _y0; }; + +private: + + void handle_event (XEvent *xe); + void expose (XExposeEvent *e); + + X_textln_style *_style; + const char *_text; + int _len; + int _x0; + int _y0; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_textip : public X_window, public X_linked +{ +public: + + enum { KEY, BUT, MODIF }; + + X_textip (X_window *parent, + X_callback *callb, + X_textln_style *style, + int xp, + int yp, + int xs, + int ys, + int max, + X_linked *back = 0, + X_linked *forw = 0); + + ~X_textip (void); + + void set_text (const char *txt); + void set_color (unsigned long bg, XftColor *fg); + void set_align (int xal); + void enable (void); + void clear_modified (void) { _flags |= CLEAR; } + void callb_modified (void) { if (_callb) _flags |= CALLB; } + + const char *text (void) { _txt [_i1] = 0; return (char *) _txt; } + int base (void) const { return _y0; }; + int key (void) const { return _key; } + X_linked *forw (void) const { return _forw; } + X_linked *back (void) const { return _back; } + +private: + + enum { FOCUS = 1, CLEAR = 2, CALLB = 4, RIGHT = 8, CENTER = 16 }; + + int test_utf8 (int k, const unsigned char *t); + void insert (int k, const unsigned char *t); + void go_sol (void); + void go_lt (void); + void del_rt (void); + void go_eol (void); + void go_rt (void); + void del_eol (void); + void del_all (void); + void del_lt (void); + void spkey (XKeyEvent *e); + void cbkey (int k, XKeyEvent *e); + + void handle_event (XEvent *xe); + void expose (XExposeEvent *e); + void bpress (XButtonEvent *e); + void keypress (XKeyEvent *e); + void paste (XSelectionEvent *e); + void setfocus (XFocusChangeEvent *e); + void remfocus (XFocusChangeEvent *e); + void update (bool f); + void redraw (void); + void xorcursor (void); + void checkclear (void); + void checkcallb (void); + void select (void); + int findindex (int x); + int textwidth (int i, int n); + + X_callback *_callb; + X_textln_style *_style; + unsigned long _bg; + XftColor *_fg; + int _flags; + int _xs; + int _ys; + unsigned char *_txt; + int _max; + int _key; + int _ic; + int _i1; + int _xc; + int _x0; + int _x1; + int _y0; + + static XIC _xic; + static unsigned char _utf8mark [6]; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_enip_item +{ +public: + int _code; + const char *_text; +}; + + +class X_enumip : public X_window, public X_linked +{ +public: + + enum { KEY, BUT }; + + X_enumip (X_window *parent, + X_callback *callb, + X_textln_style *style, + int xp, + int yp, + int xs, + int ys, + X_enip_item *list, + X_linked *back = 0, + X_linked *forw = 0); + + ~X_enumip (void); + + void set_ind (int ind); + int base (void) const { return _y0; }; + int key (void) const { return _key; } + int ind (void) const { return _ind; } + + virtual void handle_event (XEvent *xe); + +private: + + void spkey (XKeyEvent *e); + void cbkey (int k); + + void expose (XExposeEvent *e); + void bpress (XButtonEvent *e); + void keypress (XKeyEvent *e); + void setfocus (XFocusChangeEvent *e); + void remfocus (XFocusChangeEvent *e); + void redraw (void); + int textwidth (int i, int n); + + virtual void select (void); + + X_callback *_callb; + X_textln_style *_style; + X_enip_item *_list; + unsigned long _bg; + XftColor *_fg; + char *_txt; + int _ind; + int _max; + int _len; + int _foc; + int _key; + int _xs; + int _ys; + int _x0; + int _y0; + + static XIC _xic; + static unsigned char _utf8mark [6]; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_menuwin_style +{ +public: + + enum { PLAIN = 0, BORDER = 1, RAISED = 2, PDOWN = 256 }; + + XftFont *font; + int step; + int type; + struct + { + XftColor *bg; + XftColor *fg [4]; + XftColor *mm; + struct + { + unsigned long bgnd; + unsigned long lite; + unsigned long dark; + } shadow; + } color; +}; + + +class X_menuwin_item +{ +public: + + enum { COLMASK = 3, TITLE = 0x010000, SPACE = 0x020000, LAST = 0x040000, MARK = 0x080000, MASKED = 0x100000 }; + + const char *_text; + int _bits; + X_menuwin_item *_link; +}; + + + +class X_menuwin : public X_window +{ +public: + + enum { OPEN, SEL, CAN }; + enum { MAXITEM = 32, DL = 6, DR = 6 }; + + X_menuwin (X_window *parent, + X_callback *callb, + X_menuwin_style *style, + int xp, + int yp, + X_menuwin_item *items); + + ~X_menuwin (void); + + void show (void); + void hide (void); + void set_mask (unsigned m); + void clr_mask (unsigned m); + int xs (void) { return _xs; } + int ys (void) { return _ys; } + int selection (void) { return _isel; } + + +private: + + void handle_event (XEvent *E); + void expose (XExposeEvent *E); + void enter (XEnterWindowEvent *E); + void leave (XLeaveWindowEvent *E); + void motion (XPointerMovedEvent *E); + void bpress (XButtonEvent *E); + void brelse (XButtonEvent *E); + void redraw (bool clear); + void drawit (int k, bool inv); + void select (int k); + int findit (int x, int y); + + const X_menuwin_style *_style; + X_callback *_callb; + X_menuwin_item *_items; + int _xs; + int _ys; + int _nit; + int _isel; + int _open; + int _ypos [MAXITEM]; + int _tlen [MAXITEM]; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_scale_style +{ + +public: + + enum { SEGMAX = 20 }; + + int marg; + int nseg; + int pix [SEGMAX + 1]; + float val [SEGMAX + 1]; + const char *text [SEGMAX + 1]; + XftFont *font; + unsigned long bg; + XftColor *fg; + + void set_tick (int i, int p, float v, const char *t) { pix [i] = p; val [i] = v; text [i] = t; } + void set_text (int i, const char *t) { text [i] = t; } + int pixlen (void) const { return pix [0] + pix [nseg] + 1; } + int length (void) const { return 2 * marg + pixlen (); } + int limit (int i); + int calcpix (float x); + float calcval (int p); +}; + + +class X_hscale : public X_window +{ +public: + + X_hscale (X_window *parent, + X_scale_style *style, + int xp, + int yp, + int h, + int d = 0); + +private: + + void handle_event (XEvent *xe); + void expose (XExposeEvent *e); + + X_scale_style *_style; + int _h; + int _d; +}; + + +class X_vscale : public X_window +{ +public: + + X_vscale (X_window *parent, + X_scale_style *style, + int xp, + int yp, + int w, + int d = 0); + +private: + + void handle_event (XEvent *xe); + void expose (XExposeEvent *e); + + X_scale_style *_style; + int _w; + int _d; +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_meter_style +{ +public: + + unsigned long bg; + struct + { + unsigned long c0; + unsigned long c1; + unsigned long mk; + } off; + struct + { + unsigned long c0; + unsigned long c1; + unsigned long mk; + } act; +}; + + +class X_meter : public X_window +{ +public: + + X_meter (X_window *parent, X_meter_style *style, X_scale_style *scale, int xp, int yp, int xs, int ys); + + void handle_event (XEvent *xe); + void set_val (float v); + void set_ref (float v); + + friend class X_hmeter; + friend class X_vmeter; + +private: + + void expose (XExposeEvent *e); + void plotsect (int i0, int i1, int imin, int imax, int cl, int cr); + void plotmarks (int a, int b, unsigned long c); + + virtual void psect (GC g, int a, int b) = 0; + virtual void pmark (GC g, int a) = 0; + + X_meter_style *_style; + X_scale_style *_scale; + + int _x; + int _y; + int _d; + int _i; + int _s; + int _d0; + int _d1; + int _d2; +}; + + +class X_hmeter : public X_meter +{ +public: + + X_hmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, int xp, int yp, int h); + +private: + + virtual void psect (GC g, int a, int b); + virtual void pmark (GC g, int a); +}; + + +class X_vmeter : public X_meter +{ +public: + + X_vmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, int xp, int yp, int w); + +private: + + virtual void psect (GC g, int a, int b); + virtual void pmark (GC g, int a); +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_slider_style +{ +public: + + unsigned long bg; + unsigned long lite; + unsigned long dark; + unsigned long knob; + unsigned long mark; + int w; + int h; +}; + + +class X_slider : public X_window +{ +public: + + enum { MOVE, STOP }; + + X_slider (X_window *parent, + X_callback *callb, + X_slider_style *style, + X_scale_style *scale, + int xp, int yp, + int xs, int ys, + int cbid = 0); + + virtual void set_val (float v) = 0; + virtual void set_color (unsigned long knob, unsigned long mark) = 0; + float get_val (void) { return _scale->calcval (_i); } + int cbid (void) const { return _cbid; } + + friend class X_hslider; + friend class X_vslider; + +private: + + void brelease (XButtonEvent *E); + + X_callback *_callb; + X_slider_style *_style; + X_scale_style *_scale; + + int _x; + int _y; + int _i; + int _d; + int _cbid; + unsigned long _knob; + unsigned long _mark; +}; + + +class X_hslider : public X_slider +{ +public: + + X_hslider (X_window *parent, + X_callback *callb, + X_slider_style *style, + X_scale_style *scale, + int xp, int yp, + int h, + int cbid); + + virtual void handle_event (XEvent *E); + virtual void set_color (unsigned long knob, unsigned long mark); + virtual void set_val (float v); + +private: + + bool domove (int i); + void plines (void); + void plknob (int i); + void erase (int i); +}; + + +class X_vslider : public X_slider +{ +public: + + X_vslider (X_window *parent, + X_callback *callb, + X_slider_style *style, + X_scale_style *scale, + int xp, int yp, + int w, + int cbid); + + virtual void handle_event (XEvent *E); + virtual void set_color (unsigned long knob, unsigned long mark); + virtual void set_val (float v); + +private: + + bool domove (int i); + void plines (void); + void plknob (int i); + void erase (int i); +}; + + +// ------------------------------------------------------------------------------------------- + + +class X_mclist_style +{ +public: + + unsigned long bg; + XftColor *fg [4]; + XftFont *font; + int dy; +}; + + +class X_mclist : public X_window +{ +public: + + enum { OPEN, SEL, CAN, MB4, MB5 }; + + X_mclist (X_window *parent, + X_callback *callb, + X_mclist_style *style, + int xp, + int yp, + int xs, + int ys, + int max_item, + int max_char); + + ~X_mclist (void); + + void reset (void) { _n_item = _n_char = 0; _sel = -1; } + int item (const char *txt, int col, int len = 0); + void sort (void); + void show (void); + void move (int offs); + void resize (int xs, int ys); + void forw (void); + void back (void); + + int xs (void) const { return _xs; } + int ys (void) const { return _ys; } + int span (void) const { return _span; } + int offs (void) const { return _offs; } + const char *ptr (void) const { return _ptr [_sel]; } + int col (void) const { return _col [_sel]; } + int len (void) const { return _len [_sel]; } + +private: + + void handle_event (XEvent *xE); + void expose (XExposeEvent *E); + void bpress (XButtonEvent *E); + void update (int xx, int yy, int ww, int hh); + int find (int x, int y); + void enter (XEnterWindowEvent * E); + void leave (XLeaveWindowEvent * E); + void motion (XPointerMovedEvent * E); + void hilite (int ind); + void drawhl (int ind); + + X_mclist_style *_style; + X_callback *_callb; + int _max_item; + int _max_char; + int _n_item; + int _n_char; + int _xs; + int _ys; + int _offs; + int _span; + int _nrow; + int _nclm; + int _sel; + char *_buff; + char **_ptr; + short *_len; + short *_ext; + short *_col; + int *_ind; + int *_dxc; +}; + + +// ------------------------------------------------------------------------------------------- + + +#endif + diff -Nru clxclient-3.9.0/source/enumip.cc clxclient-3.9.2/source/enumip.cc --- clxclient-3.9.0/source/enumip.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/enumip.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,285 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include +#include + + +#define DX 8 + + +XIC X_enumip::_xic = 0; +unsigned char X_enumip::_utf8mark [6] = { 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + +X_enumip::X_enumip (X_window *parent, + X_callback *callb, + X_textln_style *style, + int xp, + int yp, + int xs, + int ys, + X_enip_item *list, + X_linked *back, + X_linked *forw) : + X_window (parent, xp, yp, xs, ys, style->color.normal.bgnd), + X_linked (back, forw), + _callb (callb), + _style (style), + _list (list), + _bg (_style->color.normal.bgnd), + _fg (_style->color.normal.text), + _txt (0), + _ind (0), + _len (0), + _foc (0), + _xs (xs), + _ys (ys), + _x0 (xs - DX) +{ + int i, l, m; + + x_add_events (ExposureMask | ButtonPressMask | FocusChangeMask); + _y0 = (_ys + style->font->ascent - style->font->descent) / 2; + if (callb) + { + x_add_events (ButtonPressMask | FocusChangeMask); + if (! _xic) _xic = XCreateIC (xim (), XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, win (), XNFocusWindow, win (), NULL); + } + if (_list) + { + for (i = m = 0; _list [i]._text; i++) + { + l = strlen (list [i]._text); + if (l > m) m = l; + } + _max = i; + _txt = new char [m]; + } + else _max = 0; +} + + +X_enumip::~X_enumip (void) +{ + delete [] _txt; +} + + +void X_enumip::set_ind (int ind) +{ + if ((ind < 0) || (ind >= _max)) + { + _ind = -1; + _len = 0; + } + else + { + strcpy (_txt, _list [_ind = ind]._text); + _len = strlen (_txt); + } + _x0 = _xs - DX; + if (_len) _x0 -= textwidth (0, _len); + redraw (); +} + + +void X_enumip::select (void) +{ + if (_callb) _callb->handle_callb (X_callback::ENUMIP | BUT, this, 0); +} + + +void X_enumip::handle_event (XEvent *xe) +{ + switch (xe->type) + { + case Expose: + expose ((XExposeEvent *) xe); + break; + + case ButtonPress: + bpress ((XButtonEvent *) xe); + break; + + case KeyPress: + keypress ((XKeyEvent *) xe); + break; + + case FocusIn: + setfocus ((XFocusChangeEvent *) xe); + break; + + case FocusOut: + remfocus ((XFocusChangeEvent *) xe); + break; + } +} + + +void X_enumip::expose (XExposeEvent *e) +{ + redraw (); +} + + +void X_enumip::bpress (XButtonEvent *e) +{ + if (e->button == Button2) + { + // if (_foc) XConvertSelection (dpy (), XA_PRIMARY, XA_STRING, XInternAtom (dpy (), + // "XTIPSEL", False), win (), e->time); + } + else + { + select (); + } +} + + +void X_enumip::keypress (XKeyEvent *e) +{ + int k; + unsigned char t [8]; + + if (XFilterEvent ((XEvent *) e, win ())) return; + if ( (k = Xutf8LookupString (_xic, e, (char *) t, 8, 0, 0)) + && ((*t >= 192) || ((*t >= 32) && (*t < 127)))) + { + } + else spkey (e); +} + + +void X_enumip::spkey (XKeyEvent *e) +{ + int k = XLookupKeysym (e, 0); + + switch (k) + { + case XK_Left: + case 'b': + if (--_ind < 0) _ind = _max - 1; + set_ind (_ind); + break; + + case XK_Right: + case 'f': + if (++_ind == _max) _ind = 0; + set_ind (_ind); + break; + + case XK_Tab: + if (e->state & ControlMask) { if (_back) _back->select (); } + else { if (_forw) _forw->select (); } + break; + + case XK_Up: + case XK_Down: + cbkey (k); + break; + + case XK_Return: + case XK_KP_Enter: + if (_forw) _forw->select (); + else cbkey (XK_Return); + break; + + default: + cbkey (k); + } +} + + +void X_enumip::cbkey (int k) +{ + _key = k; + if (_callb) _callb->handle_callb (X_callback::ENUMIP | KEY, this, 0); +} + + +void X_enumip::redraw (void) +{ + GC gc = dgc (); + XftDraw *D = xft (); + XftColor *C; + + XClearWindow (dpy (), win ()); + if (_len) + { + XftDrawChange (D, win ()); + C = _foc ? _style->color.focus.text : _fg; + XftDrawStringUtf8 (D, C, _style->font, _x0, _y0, (const FcChar8 *) _txt, _len); + } + if (_callb) + { + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + XSetFunction (dpy (), gc, GXcopy); + XSetForeground (dpy (), gc, _style->color.shadow.dark); + XDrawLine (dpy (), win (), gc, 0, 0, 0, _ys - 1); + XDrawLine (dpy (), win (), gc, 0, 0, _xs - 1, 0); + XSetForeground (dpy (), gc, _style->color.shadow.lite); + XDrawLine (dpy (), win (), gc, _xs - 1, 1, _xs - 1, _ys); + XDrawLine (dpy (), win (), gc, 1, _ys - 1, _xs, _ys - 1); + XSetForeground (dpy (), gc, _style->color.shadow.bgnd); + XDrawPoint (dpy (), win (), gc, 0, _ys - 1); + XDrawPoint (dpy (), win (), gc, _xs - 1, 0); + } +} + + +void X_enumip::setfocus (XFocusChangeEvent *e) +{ + if (e->detail != NotifyPointer && ! _foc) + { + _foc = 1; + x_add_events (KeyPressMask); + XSetWindowBackground (dpy (), win (),_style->color.focus.bgnd); + XSetICValues (_xic, XNFocusWindow, win (), NULL); + redraw (); + } +} + + +void X_enumip::remfocus (XFocusChangeEvent *e) +{ + if (_foc) + { + _foc = 0; + x_rem_events (KeyPressMask); + XSetWindowBackground (dpy (), win (), _bg); + redraw (); + } +} + + +int X_enumip::textwidth (int i, int n) +{ + XGlyphInfo K; + + if (n == 0) return 0; + XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *)(_txt + i), n, &K); + return K.xOff; +} + + + diff -Nru clxclient-3.9.0/source/Makefile clxclient-3.9.2/source/Makefile --- clxclient-3.9.0/source/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/Makefile 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,67 @@ +# --------------------------------------------------------------------------------- +# +# Copyright (C) 2003-2018 Fons Adriaensen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# --------------------------------------------------------------------------------- + + +# Modify as required. +# +SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/') +PREFIX ?= /usr/local +INCDIR ?= $(PREFIX)/include +LIBDIR ?= $(PREFIX)/lib$(SUFFIX) + +MAJVERS = 3 +MINVERS = 9.2 +VERSION = $(MAJVERS).$(MINVERS) + + +CPPFLAGS += $(shell pkgconf --cflags freetype2) +CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS $(PCONFCFL) +CXXFLAGS += -Wall -O2 -fPIC +CXXFLAGS += -march=native +LDLIBS += + + +CLXCLIENT_SO = libclxclient.so +CLXCLIENT_MAJ = $(CLXCLIENT_SO).$(MAJVERS) +CLXCLIENT_MIN = $(CLXCLIENT_MAJ).$(MINVERS) +CLXCLIENT_DEP = -lpthread -lXft -lX11 +CLXCLIENT_O = xdisplay.o xresman.o xhandler.o xwindow.o xdraw.o \ + button.o textip.o enumip.o menuwin.o scale.o slider.o scroll.o mclist.o meter.o +CLXCLIENT_H = clxclient.h + + +$(CLXCLIENT_MIN): $(CLXCLIENT_O) + $(CXX) -shared $(LDFLAGS) -Wl,-soname,$(CLXCLIENT_MAJ) -o $(CLXCLIENT_MIN) $(CLXCLIENT_O) $(CLXCLIENT_DEP) + + +install: $(CLXCLIENT_MIN) + install -d $(DESTDIR)$(INCDIR) + install -d $(DESTDIR)$(LIBDIR) + install -m 644 $(CLXCLIENT_H) $(DESTDIR)$(INCDIR) + install -m 755 $(CLXCLIENT_MIN) $(DESTDIR)$(LIBDIR) + ldconfig + ln -sf $(CLXCLIENT_MIN) $(DESTDIR)$(LIBDIR)/$(CLXCLIENT_SO) + +uninstall: + rm -rf $(DESTDIR)$(INCDIR)/$(CLXCLIENT_H) + rm -rf $(DESTDIR)$(LIBDIR)/libclxclient* + +clean: + /bin/rm -f *~ *.o *.a *.d *.so.* + diff -Nru clxclient-3.9.0/source/mclist.cc clxclient-3.9.2/source/mclist.cc --- clxclient-3.9.0/source/mclist.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/mclist.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,327 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +#define X0 8 +#define DX 28 + + +static char **cmpptr; + +extern "C" int compare (const void *a, const void *b) +{ + return strcoll (cmpptr [*(int *)a], cmpptr [*(int *)b]); +} + + +X_mclist::X_mclist (X_window *parent, X_callback *callb, X_mclist_style *style, + int xp, int yp, int xs, int ys, + int max_item, int max_char) : + X_window (parent, xp, yp, xs, ys, style->bg), + _style (style), + _callb (callb), + _max_item (max_item), + _max_char (max_char), + _xs (xs), + _ys (ys), + _nrow (0), + _nclm (0) +{ + _buff = new char [max_char]; + _ptr = new char* [max_item]; + _len = new short [max_item]; + _ext = new short [max_item]; + _col = new short [max_item]; + _ind = new int [max_item]; + _dxc = new int [max_item / 4]; + reset (); + x_add_events (ExposureMask | ButtonPressMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask ); +} + + +X_mclist::~X_mclist (void) +{ + delete []_buff; + delete []_ptr; + delete []_len; + delete []_ext; + delete []_col; + delete []_ind; + delete []_dxc; +} + + +void X_mclist::resize (int xs, int ys) +{ + if ((xs != _xs) || (ys != _ys)) + { + _xs = xs; + _ys = ys; + x_unmap (); + x_resize (_xs, _ys); + x_map (); + show (); + } +} + + +void X_mclist::forw (void) +{ +} + + +void X_mclist::back (void) +{ +} + + +void X_mclist::handle_event (XEvent *E) +{ + switch (E->type) + { + case Expose: + case GraphicsExpose: + expose ((XExposeEvent *) E); + break; + case ButtonPress: + bpress ((XButtonEvent *) E); + break; + case EnterNotify: + enter ((XEnterWindowEvent *) E); + break; + case LeaveNotify: + leave ((XLeaveWindowEvent *) E); + break; + case MotionNotify: + motion ((XPointerMovedEvent *) E); + break; + } +} + + +void X_mclist::expose (XExposeEvent *E) +{ + if (_nclm) update (E->x, E->y, E->width, E->height); +} + + +void X_mclist::bpress (XButtonEvent *E) +{ + switch (E->button) + { + case Button2: + return; + case Button4: + _callb->handle_callb (X_callback::MCLIST | MB4, this, 0); + return; + case Button5: + _callb->handle_callb (X_callback::MCLIST | MB5, this, 0); + return; + } + _sel = find (E->x, E->y); + if (_sel >= 0) + { + _callb->handle_callb (X_callback::MCLIST | SEL, this, (XEvent *) E); + } +} + + +void X_mclist::enter (XEnterWindowEvent * E) +{ + hilite (find (E->x, E->y)); +} + + +void X_mclist::leave (XLeaveWindowEvent * E) +{ + hilite (-1);} + + +void X_mclist::motion (XPointerMovedEvent * E) +{ + hilite (find (E->x, E->y)); +} + + +int X_mclist::find (int x, int y) +{ + int c, d, k, r; + + if (! _nclm) return -1; + x += _offs - X0; + d = _style->dy; + r = y / d; + y -= r * d; + if ((y < 2) || (y > d - 2)) return -1; + for (c = 0, k = r; k < _n_item; c++, k += _nrow) + { + d = _dxc [c]; + if ((x > 0) && (x < d)) return _ind [k]; + x -= d + DX; + } + return -1; +} + + +int X_mclist::item (const char *txt, int col, int len) +{ + int i; + XGlyphInfo G; + + if (! len) len = strlen (txt); + if (! len) return 0; + i = _n_item; + if (i == _max_item) return 1; + if (_n_char + len + 1 > _max_char) return 2; + XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *) txt, len, &G); + _ptr [i] = _buff + _n_char; + _len [i] = len; + _ext [i] = G.width; + _col [i] = col; + _ind [i] = i; + strcpy (_buff + _n_char, txt); + _n_char += len + 1; + _n_item = ++i; + return 0; +} + + +void X_mclist::sort (void) +{ + cmpptr = _ptr; + qsort (_ind, _n_item, sizeof (int), compare); +} + + +void X_mclist::show (void) +{ + int i, j, r, c, d; + + _nrow = _ys / _style->dy; + _nclm = (_n_item + _nrow - 1) / _nrow; + _span = X0; + r = c = d = 0; + for (i = 0; i < _n_item; i++) + { + j = _ind [i]; + if (d < _ext [j]) d = _ext [j]; + if (++r == _nrow) + { + if (c) _span += DX; + _span += d; + _dxc [c++] = d; + d = r = 0; + } + } + if (d) + { + if (c) _span += DX; + _span += d; + _dxc [c++] = d; + } + _span += X0; + _offs = 0; + _sel = -1; + XClearWindow (dpy (), win ()); + update (0, 0, _xs, _ys); +} + + +void X_mclist::move (int offs) +{ + int d; + XGCValues G; + + d = offs - _offs; + G.graphics_exposures = True; + G.function = GXcopy; + XChangeGC (dpy (), dgc (), GCGraphicsExposures | GCFunction, &G); + XCopyArea (dpy (), win (), win (), dgc (), d, 0, _xs, _ys, 0, 0); + G.graphics_exposures = False; + XChangeGC (dpy (), dgc (), GCGraphicsExposures, &G); + _offs = offs; +} + + +void X_mclist::hilite (int ind) +{ + if (_sel != ind) + { + if (_sel >= 0) drawhl (_sel); + _sel = ind; + if (_sel >= 0) drawhl (_sel); + } +} + + +void X_mclist::drawhl (int ind) +{ +} + + +void X_mclist::update (int xx, int yy, int ww, int hh) +{ + int i, j, c, r; + int x, dx, y, ya, yd, yb, dy; + XftDraw *D = xft (); + XftColor *C; + XftFont *F = _style->font; + + ya = _style->font->ascent; + yd = _style->font->descent; + dy = _style->dy; + yb = (dy + ya - yd) / 2; + XSetForeground (dpy (), dgc (), _style->bg); + XSetFunction (dpy (), dgc (), GXcopy); + XftDrawChange (D, win ()); + + x = X0 - _offs; + for (c = 0; c < _nclm; c++) + { + dx = _dxc [c]; + if (x >= xx + ww) break; + if (x + dx > xx) + { + y = 0; + for (r = 0; r < _nrow; r++) + { + i = c * _nrow + r; + if (i >= _n_item) break; + if (y + yb - ya >= yy + hh) break; + if (y + yb + yd > yy) + { + j = _ind [i]; + if (x + _ext [j] > xx) + { + XFillRectangle (dpy (), win (), dgc (), x, y, dx, dy); + C = _style->fg [_col [j] & 3]; + XftDrawStringUtf8 (D, C, F, x, y + yb, (const FcChar8 *) _ptr [j], _len [j]); + } + } + y += dy; + } + } + x += dx + DX; + } +} + diff -Nru clxclient-3.9.0/source/menuwin.cc clxclient-3.9.2/source/menuwin.cc --- clxclient-3.9.0/source/menuwin.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/menuwin.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,280 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +X_menuwin::X_menuwin (X_window *parent, + X_callback *callb, + X_menuwin_style *style, + int xp, + int yp, + X_menuwin_item *items) : + X_window (parent, xp, yp, 100, 100, style->color.bg->pixel), + _style (style), + _callb (callb), + _items (items), + _xs (10), + _ys (10), + _isel (-1), + _open (0) +{ + int i, k, ys, xm; + X_menuwin_item *P; + XGlyphInfo G; + + xm = 0; + ys = 1; + i = 0; + P = items; + while (i < MAXITEM) + { + if (P->_bits & X_menuwin_item::SPACE) ys += _style->step / 2; + _ypos [i] = ys; + _tlen [i] = k = strlen (P->_text); + XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *)(P->_text), k, &G); + if (xm < G.width) xm = G.width; + i++; + ys += _style->step; + if (P->_bits & X_menuwin_item::TITLE) ys++; + if (P->_bits & X_menuwin_item::LAST) break; + P++; + } + + _nit = i; + _xs = xm + DL + DR; + _ys = ys + 2; + + if (_style->type & X_menuwin_style::PDOWN) + { + x_resize (_xs, _style->step); + x_map (); + } + else x_resize (_xs, _ys); + + x_add_events (ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask); +} + + +X_menuwin::~X_menuwin (void) +{ +} + + +void X_menuwin::show (void) +{ + if (_style->type & X_menuwin_style::PDOWN) x_resize (_xs, _ys); + x_mapraised (); + _open = true; + _isel = -1; +} + + +void X_menuwin::hide (void) +{ + if (_style->type & X_menuwin_style::PDOWN) x_resize (_xs, _style->step); + else x_unmap (); + _open = false; +} + + +void X_menuwin::handle_event (XEvent *E) +{ + switch (E->type) + { + case Expose: + expose ((XExposeEvent *) E); + break; + + case ButtonPress: + bpress ((XButtonEvent *) E); + break; + + case ButtonRelease: + brelse ((XButtonEvent *) E); + break; + + case EnterNotify: + enter ((XEnterWindowEvent *) E); + break; + + case LeaveNotify: + leave ((XLeaveWindowEvent *) E); + break; + + case MotionNotify: + motion ((XPointerMovedEvent *) E); + break; + } +} + + +void X_menuwin::bpress (XButtonEvent *E) +{ + if (_open) + { + if (_isel >= 0) _callb->handle_callb (X_callback::MENU | SEL, this, (XEvent *) E); + else _callb->handle_callb (X_callback::MENU | CAN, this, (XEvent *) E); + } + else _callb->handle_callb (X_callback::MENU | OPEN, this, (XEvent *) E); +} + + +void X_menuwin::brelse (XButtonEvent *E) +{ + if (_open) + { + if (_isel >= 0) _callb->handle_callb (X_callback::MENU | SEL, this, (XEvent *) E); + else _callb->handle_callb (X_callback::MENU | CAN, this, (XEvent *) E); + } +} + + +void X_menuwin::expose (XExposeEvent * E) +{ + if (E->count == 0) redraw (true); +} + + +void X_menuwin::enter (XEnterWindowEvent * E) +{ + if (_open) select (findit (E->x, E->y)); +} + + +void X_menuwin::leave (XLeaveWindowEvent * E) +{ + if (_open) select (-1); +} + + +void X_menuwin::motion (XPointerMovedEvent * E) +{ + if (_open) select (findit (E->x, E->y)); +} + + +void X_menuwin::redraw (bool clear) +{ + int i, x, y; + GC gc = disp ()->dgc (); + const X_menuwin_item *P; + + if (clear) XClearWindow (dpy (), win ()); + + XSetFunction (dpy (), gc, GXcopy); + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + + for (i = 0, P = _items; i < _nit; i++, P++) + { + y = _ypos [i]; + drawit (i, i == _isel); + if (! _open) break; + if (P->_bits & X_menuwin_item::TITLE) + { + y += _style->step; + XSetForeground (dpy (), dgc (), _style->color.fg [0]->pixel); + XDrawLine (dpy (), win (), gc, 1, y, _xs - 2, y); + } + } + + y = _open ? _ys - 1 : _style->step - 1; + x = _xs - 1; + switch (_style->type & 255) + { + case X_menuwin_style::BORDER: + XSetForeground (dpy (), gc, _style->color.fg [0]->pixel); + XDrawRectangle (dpy (), win (), gc, 0, 0, x, y); + break; + + case X_menuwin_style::RAISED: + XSetForeground (dpy (), gc, _style->color.shadow.lite); + XDrawLine (dpy (), win (), gc, 0, 0, 0, y); + XDrawLine (dpy (), win (), gc, 0, 0, x, 0); + XSetForeground (dpy (), gc, _style->color.shadow.dark); + XDrawLine (dpy (), win (), gc, x, y, x, 1); + XDrawLine (dpy (), win (), gc, x, y, 1, y); + break; + } +} + + +void X_menuwin::drawit (int k, bool inv) +{ + X_menuwin_item *P = _items + k; + int y = _ypos [k]; + int d = (_style->step + _style->font->ascent - _style->font->descent) / 2; + XftColor *bg = _style->color.bg; + XftColor *fg = (P->_bits & X_menuwin_item::MASKED) ? _style->color.mm : _style->color.fg [P->_bits & X_menuwin_item::COLMASK]; + + if (XftDrawDrawable (xft ()) != win ()) XftDrawChange (xft (), win ()); + XSetFunction (dpy (), dgc (), GXcopy); + XSetForeground (dpy (), dgc (), (inv) ? fg->pixel : bg->pixel); + XFillRectangle (dpy (), win (), dgc (), DL - 2, y, _xs - DL - DR + 4, _style->step); + XftDrawStringUtf8 (xft (), (inv) ? bg : fg , _style->font, DL, y + d, (const FcChar8 *)(P->_text), _tlen [k]); +} + + +void X_menuwin::select (int k) +{ + if (k != _isel) + { + if (_isel >= 0) drawit (_isel, false); + _isel = k; + if (_isel >= 0) drawit (_isel, true); + } +} + + +int X_menuwin::findit (int x, int y) +{ + int i; + + for (i = 0; i < _nit; i++) + { + if ( (y > _ypos [i]) + && (y < _ypos [i] + _style->step - 1) + && (! (_items [i]._bits & (X_menuwin_item::MASKED | X_menuwin_item::TITLE)))) return i; + } + return -1; +} + + +void X_menuwin::set_mask (unsigned m) +{ + for (int i = 0; i < _nit; i++) + { + if (m & 1) _items [i]._bits |= X_menuwin_item::MASKED; + m >>= 1; + } +} + + +void X_menuwin::clr_mask (unsigned m) +{ + for (int i = 0; i < _nit; i++) + { + if (m & 1) _items [i]._bits &= ~X_menuwin_item::MASKED; + m >>= 1; + } +} + + diff -Nru clxclient-3.9.0/source/meter.cc clxclient-3.9.2/source/meter.cc --- clxclient-3.9.0/source/meter.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/meter.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,179 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +X_meter::X_meter (X_window *parent, X_meter_style *style, X_scale_style *scale, + int xp, int yp, int xs, int ys) : + X_window (parent, xp, yp, xs, ys, style->bg), + _style (style), + _scale (scale), + _x (scale->marg), + _y (scale->marg), + _d (0) +{ + _d0 = _i = -1; + _d1 = _d2 = _scale->pixlen () - 1; + x_add_events (ExposureMask); +} + + +void X_meter::handle_event (XEvent *E) +{ + switch (E->type) + { + case Expose: + expose ((XExposeEvent *) E); + break; + } +} + + +void X_meter::expose (XExposeEvent *) +{ + XClearWindow (dpy (), win ()); + XSetLineAttributes (dpy (), dgc (), 0, LineSolid, CapButt, JoinBevel); + plotsect (_d0, _i, _d0, _d1, _style->act.c0, _style->off.c0); + plotsect (_d1, _i, _d0, _d1, _style->act.c0, _style->off.c0); + plotsect (_d1, _i, _d1, _d2, _style->act.c1, _style->off.c1); + plotsect (_d2, _i, _d1, _d2, _style->act.c1, _style->off.c1); +} + + +void X_meter::set_val (float v) +{ + int i = _scale->calcpix (v); + + if (i != _i) + { + plotsect (_i, i, _d0, _d1, _style->act.c0, _style->off.c0); + plotsect (_i, i, _d1, _d2, _style->act.c1, _style->off.c1); + _i = i; + } +} + + +void X_meter::set_ref (float v) +{ + int t = _scale->calcpix (v) - 1; + + if (t < _d0) t = _d0; + if (t != _d1) + { + plotsect (_d1, t, _d0, _i, _style->act.c0, _style->act.c1); + plotsect (_d1, t, _i, _d2, _style->off.c0, _style->off.c1); + _d1 = t; + } +} + + +void X_meter::plotsect (int i0, int i1, int imin, int imax, int cl, int cr) +{ + int a, b; + + a = (i0 < imin) ? imin : (i0 > imax) ? imax : i0; + b = (i1 < imin) ? imin : (i1 > imax) ? imax : i1; + + if (a != b) + { + GC gc = disp ()->dgc (); + XSetFunction (dpy (), gc, GXcopy); + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + + if (a < b) + { + XSetForeground (dpy (), gc, cl); + psect (gc, b, a); + plotmarks (a, b, cl); + } + else + { + XSetForeground (dpy (), gc, cr); + psect (gc, a, b); + plotmarks (b, a, cr); + } + } +} + + +void X_meter::plotmarks (int a, int b, unsigned long c) +{ + int i, k, *p; + + k = _scale->nseg + 1; + p = _scale->pix; + if (c == _style->act.c0 || c == _style->act.c1) XSetForeground (dpy (), dgc (), _style->act.mk); + else XSetForeground (dpy (), dgc (), _style->off.mk); + while (k--) + { + i = *p++; + if (i > b) break; + if (i > a) pmark (dgc (), i); + } +} + + + + +X_hmeter::X_hmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, + int xp, int yp, int h) : + X_meter (parent, style, scale, xp, yp, scale->length (), h) +{ + _d = h - 2 * scale->marg; +} + + +void X_hmeter::psect (GC g, int a, int b) +{ + XFillRectangle (dpy (), win (), g, _x + b + 1, _y, a - b, _d); +} + + +void X_hmeter::pmark (GC g, int a) +{ + XDrawLine (dpy (), win (), g, _x + a, _y + 1, _x + a, _y + _d); +} + + + + +X_vmeter::X_vmeter (X_window *parent, X_meter_style *style, X_scale_style *scale, + int xp, int yp, int w) : + X_meter (parent, style, scale, xp, yp, w, scale->length ()) +{ + _d = w - 2 * scale->marg; + _y += scale->pixlen () - 1; +} + + +void X_vmeter::psect (GC g, int a, int b) +{ + XFillRectangle (dpy (), win (), g, _x, _y - a, _d, a - b); +} + + +void X_vmeter::pmark (GC g, int a) +{ + XDrawLine (dpy (), win (), g, _x, _y - a, _x + _d, _y - a); +} + + diff -Nru clxclient-3.9.0/source/scale.cc clxclient-3.9.2/source/scale.cc --- clxclient-3.9.0/source/scale.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/scale.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,199 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +int X_scale_style::calcpix (float v) +{ + int k, *P, p0, p1; + float *V, v0, v1; + + k = nseg; + P = pix; + V = val; + + p0 = *P++; + v0 = *V++; + if (v < v0) return p0; + while (k--) + { + p1 = *P++; + v1 = *V++; + if (v > v1) + { + p0 = p1; + v0 = v1; + } + else + { + return (int)(p0 + (p1 - p0) * (v - v0) / (v1 - v0) + 0.5); + } + } + return p0; +} + + +float X_scale_style::calcval (int p) +{ + int k, *P, p0, p1; + float *V, v0, v1; + + k = nseg; + P = pix; + V = val; + + p0 = *P++; + v0 = *V++; + if (p < p0) return v0; + while (k--) + { + p1 = *P++; + v1 = *V++; + if (p > p1) + { + p0 = p1; + v0 = v1; + } + else return v0 + (v1 - v0) * (p - p0) / (p1 - p0); + } + return v0; +} + + +int X_scale_style::limit (int i) +{ + if (i < pix [0]) return pix [0]; + if (i > pix [nseg]) return pix [nseg]; + return i; +} + + + +X_hscale::X_hscale (X_window *parent, X_scale_style *style, int xp, int yp, int h, int d) : + X_window (parent, xp, yp, style->length (), h, style->bg), + _style (style), + _h (h), + _d (d) +{ + x_add_events (ExposureMask); +} + + +void X_hscale::handle_event (XEvent *E) +{ + switch (E->type) + { + case Expose: + expose ((XExposeEvent *) E); + break; + } +} + + +void X_hscale::expose (XExposeEvent *) +{ + int k, l, m, x, y, *p; + const char **t; + XftColor *C = _style->fg; + XftFont *F = _style->font; + XGlyphInfo K; + + XClearWindow (dpy (), win ()); + XftDrawChange (xft (), win ()); + + k = _style->nseg + 1; + p = _style->pix; + t = _style->text; + m = _style->marg; + y = (_h + F->ascent - F->descent) / 2; + while (k--) + { + if (*t) + { + l = strlen (*t); + XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) *t, l, &K); + x = m + *p - K.width / 2; + XftDrawStringUtf8 (xft (), C, F, x, y, (const FcChar8 *) *t, l); + } + p++; + t++; + } +} + + + +X_vscale::X_vscale (X_window *parent, X_scale_style *style, int xp, int yp, int w, int d) : + X_window (parent, xp, yp, w, style->length (), style->bg), + _style (style), + _w (w), + _d (d) +{ + x_add_events (ExposureMask); +} + + +void X_vscale::handle_event (XEvent *E) +{ + switch (E->type) + { + case Expose: + expose ((XExposeEvent *) E); + break; + } +} + + +void X_vscale::expose (XExposeEvent *) +{ + int k, l, m, x, y, *p; + const char **t; + XftColor *C = _style->fg; + XftFont *F = _style->font; + XGlyphInfo K; + + XClearWindow (dpy (), win ()); + XftDrawChange (xft (), win ()); + + k = _style->nseg + 1; + p = _style->pix; + t = _style->text; + m = _style->marg + _style->pixlen () - 1 + F->ascent / 2; + while (k--) + { + if (*t) + { + l = strlen (*t); + y = m - *p; + if (_d <= 0) + { + XftTextExtentsUtf8 (dpy (), F, (const FcChar8 *) *t, l, &K); + if (_d) x = _w + _d - K.width; + else x = (_w - K.width) / 2; + } + else x = _d; + XftDrawStringUtf8 (xft (), C, F, x, y, (const FcChar8 *) *t, l); + } + p++; + t++; + } +} + diff -Nru clxclient-3.9.0/source/scroll.cc clxclient-3.9.2/source/scroll.cc --- clxclient-3.9.0/source/scroll.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/scroll.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,293 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +#define DL 17 +#define DW 13 + + +X_scroll::X_scroll (X_window *parent, + X_callback *callb, + X_button_style *style, + int xp, + int yp, + int xs, + int ys, + int opts) : + X_window (parent, xp, yp, xs, ys, style->color.shadow.bgnd), + _style (style), + _callb (callb), + _xs (xs), + _ys (ys), + _km (0), + _k0 (0), + _dk (0), + _dw (0), + _zz (INT_MIN), + _offs (0.0f), + _frac (1.0f) +{ + X_ibutton *B; + + x_add_events (ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask); + style->type = X_button_style::RAISED; + + if (xs >= 2 * ys) + { + style->size.x = DL; + style->size.y = DW; + _km = xs - 1; + _dw = (ys - DW) >> 1; + if (opts & ENDGAP) _km -= _ys; + if (opts & PLUSMIN) + { + _km -= DL; + B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_MI), X_callback::SCROLL | B1MI); + B->x_set_win_gravity (NorthEastGravity); + B->x_map (); + _km -= DL; + B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_PL), X_callback::SCROLL | B1PL); + B->x_set_win_gravity (NorthEastGravity); + B->x_map (); + } + if (opts & MIDGAP) _km -= _ys; + if (opts & ARROWS) + { + _km -= DL; + B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_RT), X_callback::SCROLL | B1RD); + B->x_set_win_gravity (NorthEastGravity); + B->x_map (); + _km -= DL; + B = new X_ibutton (this, this, style, _km, _dw, disp ()->image1515 (X_display::IMG_LT), X_callback::SCROLL | B1LU); + B->x_set_win_gravity (NorthEastGravity); + B->x_map (); + } + } + else if (ys >= 2 * xs) + { + style->size.x = DW; + style->size.y = DL; + _km = ys - 1; + _dw = (xs - DW) >> 1; + if (opts & ENDGAP) _km -= _xs; + if (opts & PLUSMIN) + { + _km -= DL; + B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_MI), X_callback::SCROLL | B1MI); + B->x_set_win_gravity (SouthWestGravity); + B->x_map (); + _km -= DL; + B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_PL), X_callback::SCROLL | B1PL); + B->x_set_win_gravity (SouthWestGravity); + B->x_map (); + } + if (opts & MIDGAP) _km -= _xs; + if (opts & ARROWS) + { + _km -= DL; + B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_DN), X_callback::SCROLL | B1RD); + B->x_set_win_gravity (SouthWestGravity); + B->x_map (); + _km -= DL; + B = new X_ibutton (this, this, style, _dw, _km, disp ()->image1515 (X_display::IMG_UP), X_callback::SCROLL | B1LU); + B->x_set_win_gravity (SouthWestGravity); + B->x_map (); + } + } + _km -= 1; +} + + +X_scroll::~X_scroll (void) +{ +} + + +void X_scroll::handle_event (XEvent *E) +{ + switch (E->type) + { + case Expose: + expose ((XExposeEvent *) E); + break; + + case ButtonPress: + bpress ((XButtonEvent *) E); + break; + + case ButtonRelease: + brelease ((XButtonEvent *) E); + break; + + case MotionNotify: + bmotion ((XMotionEvent *) E); + break; + } +} + + +void X_scroll::bpress (XButtonEvent *E) +{ + int b, k; + + b = E->button; + switch (b) + { + case Button2: return; + case Button4: + _callb->handle_callb (X_callback::SCROLL | MB4, this, 0); + return; + case Button5: + _callb->handle_callb (X_callback::SCROLL | MB5, this, 0); + return; + } + k = (_xs > _ys) ? E->x - 1 : E->y - 1; + if (! _callb || (k < 0) || (k >= _km)) return; + k -= _k0; + if (k >= _dk) _callb->handle_callb (X_callback::SCROLL | (b == Button3 ? C3RD : C1RD), this, 0); + else if (k < 0) _callb->handle_callb (X_callback::SCROLL | (b == Button3 ? C3LU : C1LU), this, 0); + else _zz = k + _k0; +} + + +void X_scroll::brelease (XButtonEvent *E) +{ + if (_zz != INT_MIN) + { + _zz = INT_MIN; + _callb->handle_callb (X_callback::SCROLL | STOP, this, 0); + } +} + + +void X_scroll::bmotion (XMotionEvent *E) +{ + int d, k; + + if (_zz == INT_MIN) return; + k = (_xs > _ys) ? E->x - 1 : E->y - 1; + d = k - _zz; + if (_k0 + d <= 0) + { + d = -_k0; + _offs = 0.0f; + } + else if (_k0 + d >= _km - _dk) + { + d = _km - _dk - _k0; + _offs = 1.0f; + } + else + { + _offs += d / (float)(_km - _dk); + } + if (d) + { + _zz += d; + _callb->handle_callb (X_callback::SCROLL | MOVE, this, 0); + redraw (); + } +} + + +void X_scroll::expose (XExposeEvent *E) +{ + if (E->count == 0) redraw (); +} + + +void X_scroll::geom (float offs, float frac, int size) +{ + if (size) + { + if (_xs > _ys) + { + _km += size - _xs; + _xs = size; + } + else + { + _km += size - _ys; + _ys = size; + } + XResizeWindow (dpy (), win (), _xs, _ys); + } + _offs = offs; + _frac = frac; + redraw (); +} + + +void X_scroll::move (float drel) +{ + _offs += drel * _frac; + if (_offs < 0.0f) _offs = 0.0f; + if (_offs > 1.0f) _offs = 1.0f; + redraw (); +} + + +void X_scroll::redraw (void) +{ + _dk = (int)(_frac * _km + 0.5f); + if (_dk < 8) _dk = 8; + _k0 = (int)(_offs * (_km - _dk) + 0.5f); + XSetFunction (dpy (), dgc (), GXcopy); + XSetLineAttributes (dpy (), dgc (), 0, LineSolid, CapButt, JoinBevel); + if (_xs > _ys) + { + XSetForeground (dpy (), dgc (), _style->color.shadow.bgnd); + XFillRectangle (dpy (), win (), dgc (), 0, 0, _k0 + 2, _ys); + XFillRectangle (dpy (), win (), dgc (), _k0 + _dk, 0, _km - _k0 - _dk + 1, _ys); + XSetForeground (dpy (), dgc (), _style->color.bg [1]); + XFillRectangle (dpy (), win (), dgc (), _k0 + 2, _dw + 1, _dk - 2, 11); + XSetForeground (dpy (), dgc (), _style->color.shadow.lite); + XDrawLine (dpy (), win (), dgc (), _k0 + 1, _dw, _k0 + 1, _dw + DW - 2); + XDrawLine (dpy (), win (), dgc (), _k0 + 1, _dw, _k0 + _dk - 1, _dw); + XSetForeground (dpy (), dgc (), _style->color.shadow.dark); + XDrawLine (dpy (), win (), dgc (), _k0 + _dk, _dw + DW - 1, _k0 + 2, _dw + DW - 1); + XDrawLine (dpy (), win (), dgc (), _k0 + _dk, _dw + DW - 1, _k0 + _dk, _dw + 1); + } + else + { + XSetForeground (dpy (), dgc (), _style->color.shadow.bgnd); + XFillRectangle (dpy (), win (), dgc (), 0, 0, _xs, _k0 + 2); + XFillRectangle (dpy (), win (), dgc (), 0, _k0 + _dk, _xs, _km - _k0 - _dk + 1); + XSetForeground (dpy (), dgc (), _style->color.bg [1]); + XFillRectangle (dpy (), win (), dgc (), _dw + 1, _k0 + 2, 11, _dk - 2); + XSetForeground (dpy (), dgc (), _style->color.shadow.lite); + XDrawLine (dpy (), win (), dgc (), _dw, _k0 + 1, _dw + DW - 2, _k0 + 1); + XDrawLine (dpy (), win (), dgc (), _dw, _k0 + 1, _dw, _k0 + _dk - 1); + XSetForeground (dpy (), dgc (), _style->color.shadow.dark); + XDrawLine (dpy (), win (), dgc (), _dw + DW - 1, _k0 + _dk, _dw + DW - 1, _k0 + 2); + XDrawLine (dpy (), win (), dgc (), _dw + DW - 1, _k0 + _dk, _dw + 1, _k0 + _dk); + } +} + + +void X_scroll::handle_callb (int type, X_window *W, XEvent *E) +{ + X_button *B = (X_button *) W; + XButtonEvent *Z = (XButtonEvent *) E; + if (_callb) _callb->handle_callb (B->cbid () + ((Z->button == Button3) ? 1 : 0), this, E); +} diff -Nru clxclient-3.9.0/source/slider.cc clxclient-3.9.2/source/slider.cc --- clxclient-3.9.0/source/slider.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/slider.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,356 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +X_slider::X_slider (X_window *parent, X_callback *callb, X_slider_style *style, X_scale_style *scale, + int xp, int yp, int xs, int ys, int cbid) : + X_window (parent, xp, yp, xs, ys, style->bg), + _callb (callb), + _style (style), + _scale (scale), + _x (0), + _y (0), + _i (_scale->pix [0]), + _d (9999), + _cbid (cbid), + _knob (_style->knob), + _mark (_style->mark) +{ + x_add_events (ExposureMask | Button1MotionMask | ButtonPressMask | ButtonReleaseMask); +} + + +void X_slider::brelease (XButtonEvent *E) +{ + _d = 9999; + if (_callb) _callb->handle_callb (X_callback::SLIDER | STOP, this, (XEvent *) E); +} + + + + + +X_hslider::X_hslider (X_window *parent, X_callback *callb, X_slider_style *style, X_scale_style *scale, + int xp, int yp, int h, int cbid) : + X_slider (parent, callb, style, scale, xp, yp, scale->length (), h, cbid) +{ + _y = h; + _x = _scale->marg; +} + + +void X_hslider::handle_event (XEvent *E) +{ + XMotionEvent *M = (XMotionEvent *) E; + XButtonEvent *B = (XButtonEvent *) E; + + switch (E->type) + { + case Expose: + plines (); + plknob (_i); + break; + + case ButtonPress: + if (B->button == Button4) + { + if (domove (_scale->limit (_i + 1)) && _callb) + { + _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); + } + } + else if (B->button == Button5) + { + if (domove (_scale->limit (_i - 1)) && _callb) + { + _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); + } + } + else + { + _d = B->x - _x - _i; + if (abs (2 * _d) >= _style->h) _d = 9999; + } + break; + + case ButtonRelease: + brelease (B); + break; + + case MotionNotify: + if ((_d < 9999) && domove (_scale->limit (M->x - _x - _d)) && _callb) + { + _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); + } + + break; + + default: + fprintf (stderr, "X_slider: event %d\n", E->type ); + } +} + + +void X_hslider::set_color (unsigned long knob, unsigned long mark) +{ + if ((_knob != knob) || (_mark != mark)) + { + _knob = knob; + _mark = mark; + plknob (_i); + } +} + + +void X_hslider::set_val (float v) +{ + domove (_scale->calcpix (v)); +} + + +bool X_hslider::domove (int i) +{ + if (i == _i) return false; + erase (_i); + plines (); + plknob (_i = i); + return true; +} + + +void X_hslider::plines (void) +{ + int x, k, *p; + GC gc = disp ()->dgc (); + + XSetFunction (dpy (), gc, GXcopy); + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + XSetForeground (dpy (), gc, _scale->fg->pixel); + k = _scale->nseg + 1; + p = _scale->pix; + while (k--) + { + x = _x + *p++; + XDrawLine (dpy (), win (), gc, x, 0, x, _y); + } + k = _y / 2; + XSetForeground (dpy (), gc, _style->dark); + XDrawLine (dpy (), win (), gc, _x, k - 1, _x + _scale->pixlen (), k - 1); + XSetForeground (dpy (), gc, _style->lite); + XDrawLine (dpy (), win (), gc, _x, k, _x + _scale->pixlen (), k); +} + + +void X_hslider::plknob (int i) +{ + int x, y, h, w; + GC gc = disp ()->dgc (); + + h = _style->h; + w = _style->w; + x = i + _x - h / 2; + y = (_y - w) / 2; + XSetFunction (dpy (), gc, GXcopy); + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + XSetForeground (dpy (), gc, _knob); + XFillRectangle (dpy (), win (), gc, x, y, h, w); + XSetForeground (dpy (), gc, _mark); + XDrawLine (dpy (), win (), gc, x + h / 2, y, x + h / 2, y + w); + + XSetForeground (dpy (), gc, _style->lite); + XDrawLine (dpy (), win (), gc, x - 1, y - 1, x - 1, y + w); + XDrawLine (dpy (), win (), gc, x - 1, y - 1, x + h, y - 1); + + XSetForeground (dpy (), gc, _style->dark); + XDrawLine (dpy (), win (), gc, x + h, y + w, x + h, y); + XDrawLine (dpy (), win (), gc, x + h, y + w, x, y + w); +} + + +void X_hslider::erase (int i) +{ + int x, y, h, w; + GC gc = disp ()->dgc (); + + h = _style->h; + w = _style->w; + x = i + _x - h / 2; + y = (_y - w) / 2; + XSetFunction (dpy (), gc, GXcopy); + XSetForeground (dpy (), gc, _style->bg); + XFillRectangle (dpy (), win (), gc, x - 1, y - 1, h + 2, w + 2); +} + + + +X_vslider::X_vslider (X_window *parent, X_callback *callb, X_slider_style *style, X_scale_style *scale, + int xp, int yp, int w, int cbid) : + X_slider (parent, callb, style, scale, xp, yp, w, scale->length (), cbid) +{ + _x = w; + _y = _scale->marg + scale->pixlen () - 1; +} + + +void X_vslider::handle_event (XEvent *E) +{ + XMotionEvent *M = (XMotionEvent *) E; + XButtonEvent *B = (XButtonEvent *) E; + + switch (E->type) + { + case Expose: + plines (); + plknob (_i); + break; + + case ButtonPress: + if (B->button == Button4) + { + if (domove (_scale->limit (_i + 1)) && _callb) + { + _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); + } + } + else if (B->button == Button5) + { + if (domove (_scale->limit (_i - 1)) && _callb) + { + _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); + } + } + else + { + _d = M->y - _y + _i; + if (abs (2 * _d) >= _style->h) _d = 9999; + } + break; + + case ButtonRelease: + brelease (B); + break; + + case MotionNotify: + if ((_d < 9999) && domove (_scale->limit (_d + _y - M->y)) && _callb) + { + _callb->handle_callb (X_callback::SLIDER | MOVE, this, (XEvent *) E); + } + break; + + default: + fprintf (stderr, "X_slider: event %d\n", E->type ); + } +} + + +void X_vslider::set_color (unsigned long knob, unsigned long mark) +{ + if ((_knob != knob) || (_mark != mark)) + { + _knob = knob; + _mark = mark; + plknob (_i); + } +} + + +void X_vslider::set_val (float v) +{ + domove (_scale->calcpix (v)); +} + + +bool X_vslider::domove (int i) +{ + if (i == _i) return false; + erase (_i); + plines (); + plknob (_i = i); + return true; +} + + +void X_vslider::plines (void) +{ + int k, y, *p; + + GC gc = disp ()->dgc (); + + XSetFunction (dpy (), gc, GXcopy); + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + XSetForeground (dpy (), gc, _scale->fg->pixel); + k = _scale->nseg + 1; + p = _scale->pix; + while (k--) + { + y = _y - *p++; + XDrawLine (dpy (), win (), gc, 0, y, _x, y); + } + k = _x / 2; + XSetForeground (dpy (), gc, _style->dark); + XDrawLine (dpy (), win (), gc, k - 1, _y - _scale->pixlen (), k - 1, _y); + XSetForeground (dpy (), gc, _style->lite); + XDrawLine (dpy (), win (), gc, k, _y - _scale->pixlen (), k, _y); +} + + +void X_vslider::plknob (int i) +{ + int x, y, h, w; + GC gc = disp ()->dgc (); + + h = _style->h; + w = _style->w; + x = (_x - w) / 2; + y = _y - i - h / 2; + + XSetFunction (dpy (), gc, GXcopy); + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + XSetForeground (dpy (), gc, _knob); + XFillRectangle (dpy (), win (), gc, x, y, w, h); + XSetForeground (dpy (), gc, _mark); + XDrawLine (dpy (), win (), gc, x, y + h / 2, x + w, y + h / 2); + + XSetForeground (dpy (), gc, _style->lite); + XDrawLine (dpy (), win (), gc, x - 1, y - 1, x - 1, y + h); + XDrawLine (dpy (), win (), gc, x - 1, y - 1, x + w, y - 1); + XSetForeground (dpy (), gc, _style->dark); + XDrawLine (dpy (), win (), gc, x + w, y + h, x, y + h); + XDrawLine (dpy (), win (), gc, x + w, y + h, x + w, y); +} + + +void X_vslider::erase (int i) +{ + int x, y, h, w; + GC gc = disp ()->dgc (); + + h = _style->h; + w = _style->w; + x = (_x - w) / 2; + y = _y - i - h / 2; + XSetFunction (dpy (), gc, GXcopy); + XSetForeground (dpy (), gc, _style->bg); + XFillRectangle (dpy (), win (), gc, x - 1, y - 1, w + 2, h + 2); +} + diff -Nru clxclient-3.9.0/source/textip.cc clxclient-3.9.2/source/textip.cc --- clxclient-3.9.0/source/textip.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/textip.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,703 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include +#include "clxclient.h" + + +#define DX 4 + + +X_textln::X_textln (X_window *parent, + X_textln_style *style, + int xp, + int yp, + int xs, + int ys, + const char *text, + int xal) : + X_window (parent, xp, yp, xs, ys, style->color.normal.bgnd), + _style (style), + _text (text) +{ + XGlyphInfo K; + + x_add_events (ExposureMask); + _len = strlen (text); + _x0 = 2; + _y0 = (ys + style->font->ascent - style->font->descent) / 2; + if (xal >= 0) + { + XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *) _text, _len, &K); + _x0 = xs - K.width - 2; + if (xal == 0) _x0 /= 2; + } +} + + +X_textln::~X_textln (void) +{ +} + + +void X_textln::handle_event (XEvent *xe) +{ + switch (xe->type) + { + case Expose: + expose ((XExposeEvent *) xe); + break; + } +} + + +void X_textln::expose (XExposeEvent *e) +{ + if (e->count == 0) + { + XClearWindow (dpy (), win ()); + if (_len) + { + XftDrawChange (xft (), win ()); + XftDrawStringUtf8 (xft (), _style->color.normal.text, _style->font, _x0, _y0, (const FcChar8 *) _text, _len); + } + } +} + + +XIC X_textip::_xic = 0; +unsigned char X_textip::_utf8mark [6] = { 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + +X_textip::X_textip (X_window *parent, + X_callback *callb, + X_textln_style *style, + int xp, + int yp, + int xs, + int ys, + int max, + X_linked *back, + X_linked *forw) : + X_window (parent, xp, yp, xs, ys, style->color.normal.bgnd), + X_linked (back, forw), + _callb (callb), + _style (style), + _bg (_style->color.normal.bgnd), + _fg (_style->color.normal.text), + _flags (0), + _xs (xs), + _ys (ys), + _txt (0), + _max (max), + _ic (0), + _i1 (0) +{ + x_add_events (ExposureMask); + _txt = new unsigned char [_max + 1]; + _y0 = (_ys + style->font->ascent - style->font->descent) / 2; + _x0 = _x1 = _xc = DX; + if (callb) + { + x_add_events (ButtonPressMask | FocusChangeMask); + if (! _xic) _xic = XCreateIC (xim (), XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, win (), XNFocusWindow, win (), NULL); + } +} + + +X_textip::~X_textip (void) +{ + delete [] _txt; +} + + +void X_textip::set_text (const char *txt) +{ + _i1 = 0; + if (txt) while ((*((unsigned char *) txt) >= ' ') && (_i1 < _max)) _txt [_i1++] = *txt++; + if (_flags & RIGHT) { _x0 = _xs - DX; _ic = _i1; } + else { _x0 = DX; _ic = 0; } + xorcursor (); + update (true); +} + + +void X_textip::set_color (unsigned long bg, XftColor *fg) +{ + if ((_fg != fg) || (_bg != bg)) + { + _fg = fg; + _bg = bg; + redraw (); + } +} + + +void X_textip::set_align (int k) +{ + if (k > 0) + { + _flags &= ~CENTER; + _flags |= RIGHT; + _x0 = _xs - DX; + _ic = _i1; + } + else if (k < 0) + { + _flags &= ~(RIGHT | CENTER); + _x0 = DX; + _ic = 0; + } + else + { + _flags |= CENTER; + _flags &= ~RIGHT; + } + xorcursor (); + update (true); +} + + + +void X_textip::enable (void) +{ + XSetInputFocus (dpy (), win (), RevertToParent, CurrentTime); +} + + +void X_textip::select (void) +{ + if (_callb) _callb->handle_callb (X_callback::TEXTIP | BUT, this, 0); +} + + +void X_textip::handle_event (XEvent *xe) +{ + switch (xe->type) + { + case Expose: + expose ((XExposeEvent *) xe); + break; + + case ButtonPress: + bpress ((XButtonEvent *) xe); + break; + + case KeyPress: + keypress ((XKeyEvent *) xe); + break; + + case FocusIn: + setfocus ((XFocusChangeEvent *) xe); + break; + + case FocusOut: + remfocus ((XFocusChangeEvent *) xe); + break; + + case SelectionNotify: + paste ((XSelectionEvent *) xe); + break; + } +} + + +void X_textip::expose (XExposeEvent *e) +{ + if (e->count == 0) redraw (); +} + + +void X_textip::bpress (XButtonEvent *e) +{ + if (e->button == Button2) + { +// XConvertSelection (dpy (), XA_PRIMARY, XA_STRING, XA_PRIMARY, win (), e->time); + } + else + { + xorcursor (); + _ic = findindex (e->x); + _xc = _x0 + textwidth (0, _ic); + if (_callb) _callb->handle_callb (X_callback::TEXTIP | BUT, this, (XEvent *) e); + xorcursor (); + } +} + + +void X_textip::keypress (XKeyEvent *e) +{ + int k; + unsigned char t [8]; + + if (XFilterEvent ((XEvent *) e, win ())) return; + if ( (k = Xutf8LookupString (_xic, e, (char *) t, 8, 0, 0)) + && ((*t >= 192) || ((*t >= 32) && (*t < 127)))) + { + checkclear (); + insert (k, t); + xorcursor (); + update (true); + checkcallb (); + } + else spkey (e); +} + + +int X_textip::test_utf8 (int k, const unsigned char *t) +{ + int c, i, n; + + c = *t++; + if ((c < 0x20) || (c == 0x7F) || (c >= 0xFE)) return 0; + if (c < 0x7F) return 1; + for (n = 5; n; n--) + { + if (c >= _utf8mark [n]) + { + if (n >= k) return 0; + for (i = 0; i < n; i++) + { + c = *t++; + if ((c < 0x80) || (c >= 0xC0)) return 0; + } + return n + 1; + } + } + return 0; +} + + +void X_textip::insert (int k, const unsigned char *t) +{ + int i; + + if (_i1 + k <= _max) + { + _i1 += k; + for (i = _i1; i > _ic; i--) _txt [i] = _txt [i - k]; + while (k--) _txt [_ic++] = *t++; + } + else XBell (dpy (), 0); +} + + +void X_textip::paste (XSelectionEvent *e) +{ + int k, n; + const unsigned char *p; + XTextProperty t; + + if (e->target != None) + { + XGetTextProperty (dpy (), win (), &t, e->property); + n = t.nitems; + if (n > _max - _i1) XBell (dpy (), 0); + else if (n) + { + checkclear (); + p = (const unsigned char *)(t.value); + while (n) + { + if ((k = test_utf8 (n, p))) + { + insert (k, p); + n -= k; + p += k; + } + else + { + k--; + p++; + } + } + xorcursor (); + update (true); + checkcallb (); + } + } +} + + +void X_textip::spkey (XKeyEvent *e) +{ + int k = XLookupKeysym (e, 0); + + switch (k) + { + case XK_Home: + case 'a': + go_sol (); + break; + + case XK_End: + case 'e': + go_eol (); + break; + + case XK_Left: + if (e->state & (ControlMask | ShiftMask)) cbkey (k, e); + else go_lt (); + break; + + case 'b': + go_lt (); + break; + + case XK_Right: + if (e->state & (ControlMask | ShiftMask)) cbkey (k, e); + else go_rt (); + break; + + case 'f': + go_rt (); + break; + + case XK_Delete: + case 'd': + del_rt (); + break; + + case 'k': + del_eol (); + break; + + case 'u': + del_all (); + break; + + case XK_BackSpace: + del_lt (); + break; + + case XK_Tab: + go_eol (); + if (e->state & ControlMask) { if (_back) _back->select (); } + else { if (_forw) _forw->select (); } + break; + + case XK_Up: + case XK_Down: + cbkey (k, e); + break; + + case XK_Return: + case XK_KP_Enter: + go_eol (); + if (_forw) _forw->select (); + else cbkey (XK_Return, e); + break; + + default: + cbkey (k, e); + } +} + + +void X_textip::cbkey (int k, XKeyEvent *e) +{ + _key = k; + if (_callb) _callb->handle_callb (X_callback::TEXTIP | KEY, this, (XEvent *) e); +} + + +void X_textip::go_sol (void) +{ + _flags &= ~CLEAR; + if (_i1) + { + xorcursor (); + _ic = 0; + _xc = _x0; + update (false); + } +} + + +void X_textip::go_eol (void) +{ + _flags &= ~CLEAR; + if (_i1) + { + xorcursor (); + _ic = _i1; + _xc = _x1; + update (false); + } +} + + +void X_textip::go_lt (void) +{ + int i, d; + + _flags &= ~CLEAR; + if (_ic > 0) + { + for (i = _ic - 1, d = 1; (i > 0) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i--, d++); + xorcursor (); + _ic -= d; + _xc = _x0 + textwidth (0, _ic); + update (false); + } +} + + +void X_textip::go_rt (void) +{ + int i, d; + + _flags &= ~CLEAR; + if (_ic < _i1) + { + for (i = _ic + 1, d = 1; (i < _i1) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i++, d++); + xorcursor (); + _ic += d; + _xc = _x0 + textwidth (0, _ic); + update (false); + } +} + + +void X_textip::del_lt (void) +{ + int i, d; + + _flags &= ~CLEAR; + if (_ic > 0) + { + for (i = _ic - 1, d = 1; (i > 0) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i--, d++); + _ic -= d; + _i1 -= d; + for (i = _ic; i < _i1; i++) _txt [i] = _txt [i + d]; + xorcursor (); + update (true); + checkcallb (); + } +} + + +void X_textip::del_rt (void) +{ + int i, d; + + _flags &= ~CLEAR; + if (_ic < _i1) + { + for (i = _ic + 1, d = 1; (i < _i1) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i++, d++); + _i1 -= d; + for (i = _ic; i < _i1; i++) _txt [i] = _txt [i + d]; + xorcursor (); + update (true); + checkcallb (); + } +} + + +void X_textip::del_eol (void) +{ + _flags &= ~CLEAR; + if (_ic < _i1) + { + _i1 = _ic; + xorcursor (); + update (true); + checkcallb (); + } +} + + +void X_textip::del_all (void) +{ + _flags &= ~CLEAR; + if (_i1) + { + _ic = _i1 = 0; + _xc = (_flags & RIGHT) ? _xs - DX : DX; + _x0 = _x1 = _xc; + redraw (); + checkcallb (); + } +} + + +void X_textip::update (bool f) +{ + int d; + + _xc = _x0 + textwidth (0, _ic); + _x1 = _xc + textwidth (_ic, _i1 - _ic); + + if (_flags & CENTER) + { + d = (_x0 + _x1 - _xs) / 2; + if (d > _xc - DX) d = _xc - DX; + if (d < _xc - _xs + DX) d = _xc - _xs + DX; + } + else if (_flags & RIGHT) + { + d = _x1 - _xs + DX; + if (d > _xc - DX) d = _xc - DX; + } + else + { + d = _x0 - DX; + if (d < _xc - _xs + DX) d = _xc - _xs + DX; + } + _xc -= d; + _x0 -= d; + _x1 -= d; + if (d | f) redraw (); + else xorcursor (); +} + + +void X_textip::redraw (void) +{ + GC gc = disp ()->dgc (); + XftDraw *D = xft (); + XftColor *C; + unsigned long dark, lite, bgnd; + + XSetWindowBackground (dpy (), win (), (_flags & FOCUS) ? _style->color.focus.bgnd : _bg); + XClearWindow (dpy (), win ()); + + if (_i1) + { + XftDrawChange (D, win ()); + C = (_flags & FOCUS) ? _style->color.focus.text : _fg; + XftDrawStringUtf8 (D, C, _style->font, _x0, _y0, (const FcChar8 *) _txt, _i1); + } + if (_callb) + { + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + XSetFunction (dpy (), gc, GXcopy); + dark = _style->color.shadow.dark; + lite = _style->color.shadow.lite; + bgnd = _style->color.shadow.bgnd; + if (dark == lite) + { + XSetForeground (dpy (), gc, dark); + XDrawRectangle (dpy (), win (), dgc (), 0, 0, _xs - 1, _ys - 1); + } + else + { + XSetForeground (dpy (), gc, dark); + XDrawLine (dpy (), win (), gc, 0, 0, 0, _ys - 1); + XDrawLine (dpy (), win (), gc, 0, 0, _xs - 1, 0); + XSetForeground (dpy (), gc, lite); + XDrawLine (dpy (), win (), gc, _xs - 1, 1, _xs - 1, _ys); + XDrawLine (dpy (), win (), gc, 1, _ys - 1, _xs, _ys - 1); + XSetForeground (dpy (), gc, bgnd); + XDrawPoint (dpy (), win (), gc, 0, _ys - 1); + XDrawPoint (dpy (), win (), gc, _xs - 1, 0); + } + } + xorcursor (); +} + + +void X_textip::setfocus (XFocusChangeEvent *e) +{ + if (e->detail != NotifyPointer && ! (_flags & FOCUS)) + { + _flags ^= FOCUS; + x_add_events (KeyPressMask); + XSetICValues (_xic, XNFocusWindow, win (), NULL); + XSetICFocus (_xic); + redraw (); + } +} + + +void X_textip::remfocus (XFocusChangeEvent *e) +{ + if (_flags & FOCUS) + { + _flags ^= FOCUS; + x_rem_events (KeyPressMask); + XUnsetICFocus (_xic); + redraw (); + } +} + + +void X_textip::xorcursor (void) +{ + int y0, y1; + + if (_flags & FOCUS) + { + GC gc = disp ()->dgc (); + XSetForeground (dpy (), gc, _style->color.focus.bgnd ^ _style->color.focus.line); + XSetFunction (dpy (), gc, GXxor); + XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); + y0 = _y0 - _style->font->ascent; + y1 = _y0 + _style->font->descent; + if (y0 < 1) y0 = 1; + if (y1 > _ys - 1) y1 = _ys - 1; + XDrawLine (dpy (), win (), gc, _xc, y0, _xc, y1); + } +} + + +int X_textip::findindex (int x) +{ + int i, i0, i1; + + if (x < _x0) return 0; + i0 = 0; + i1 = _i1; + while (i1 > i0 + 1) + { + i = (i0 + i1) / 2; + if (_x0 + textwidth (0, i) > x) i1 = i; + else i0 = i; + } + return i1; +} + + +int X_textip::textwidth (int i, int n) +{ + XGlyphInfo K; + + if (n == 0) return 0; + XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *)(_txt + i), n, &K); + return K.xOff; +} + + +void X_textip::checkclear (void) +{ + if (_flags & CLEAR) del_all (); +} + + +void X_textip::checkcallb (void) +{ + if (_flags & CALLB) + { + _callb->handle_callb (X_callback::TEXTIP | MODIF, this, 0); + _flags ^= CALLB; + } +} diff -Nru clxclient-3.9.0/source/xdisplay.cc clxclient-3.9.2/source/xdisplay.cc --- clxclient-3.9.0/source/xdisplay.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/xdisplay.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,200 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +const char *clxclient_version (void) { return VERSION; } + + +X_display::X_display (const char *name) : + _dsn (0), _dcm (0), _dgc (0), _dvi (0), _xft (0), _xim (0) +{ + int i; + XImage *I; + + _dpy = XOpenDisplay (name); + if (! _dpy) return; + + _dsn = DefaultScreen (_dpy); + _dcm = DefaultColormap (_dpy, _dsn); + _dgc = DefaultGC (_dpy, _dsn); + _dvi = DefaultVisual (_dpy, _dsn); + _xim = XOpenIM (_dpy, 0, 0, 0); + + for (i = 0; i < N_IMG1515; i++) + { + I = XCreateImage (_dpy, _dvi, 1, XYBitmap, 0, (char *) _imgdef1515 + 30 * i, 15, 15, 8, 2); + I->bitmap_unit = 8; + I->bitmap_pad = 8; + I->bitmap_bit_order = LSBFirst; + XInitImage (I); + _imgptr1515 [i] = I; + } +} + + +X_display::~X_display (void) +{ + int i; + + if (!_dpy) return; + for (i = 0; i < N_IMG1515; i++) + { + _imgptr1515 [i]->data = 0; + XDestroyImage (_imgptr1515 [i]); + } + if (_xim) XCloseIM (_xim); + XCloseDisplay (_dpy); +} + + +unsigned long X_display::alloc_color (const char *name, unsigned long d) +{ + XColor C; + + if (XParseColor (_dpy, _dcm, name, &C)) + { + if (XAllocColor (_dpy, _dcm, &C)) return C.pixel; + else fprintf (stderr, "-- Can't alloc '%s', using default (%ld).\n", name, d); + } + else fprintf (stderr, "-- Can't parse '%s', using default (%ld).\n", name, d); + return d; +} + + + +unsigned long X_display::alloc_color (float r, float g, float b) +{ + XColor C; + + C.red = (int)(65535 * r); + C.green = (int)(65535 * g); + C.blue = (int)(65535 * b); + + if (XAllocColor (_dpy, _dcm, &C)) return C.pixel; + else return 0; +} + + + +XftColor *X_display::alloc_xftcolor (const char *name, XftColor *D) +{ + XftColor *C = new XftColor; + + if (! XftColorAllocName (_dpy, _dvi, _dcm, name, C)) + { + if (D) + { + XftColorAllocValue (_dpy, _dvi, _dcm, &(D->color), C); + fprintf (stderr, " -- Can't alloc '%s', using default (%ld).\n", name, D->pixel); + } + else fprintf (stderr, " -- Can't alloc '%s', no default provided.\n", name); + } + return C; +} + + +XftColor *X_display::alloc_xftcolor (float r, float g, float b, float a) +{ + XftColor *C = new XftColor; + XRenderColor R; + + R.red = (int)(65535 * r); + R.green = (int)(65535 * g); + R.blue = (int)(65535 * b); + R.alpha = (int)(65535 * a); + + XftColorAllocValue (_dpy, _dvi, _dcm, &R, C); + return C; +} + + +void X_display::free_xftcolor (XftColor *C) +{ + XftColorFree (_dpy, _dvi, _dcm, C); + delete C; +} + + +#define FALLBACK "Fixed" + + +XFontStruct *X_display::alloc_font (const char *name) +{ + XFontStruct *F = NULL; + + if (name) + { + if (! (F = XLoadQueryFont (_dpy, name))) + { + fprintf (stderr, "-- Can't load font '%s'\n", name); + fprintf (stderr, "-- Trying to use %s instead.\n", FALLBACK); + } + } + if (! F) + { + if (! (F = XLoadQueryFont (_dpy, FALLBACK))) + { + fprintf(stderr, "-- Can't load font %s \n", FALLBACK); + fprintf(stderr, "-- No useable font - X11 aborted.\n"); + exit (1); + } + } + return F; +} + + +XftFont *X_display::alloc_xftfont (const char *name) +{ + return XftFontOpenName (_dpy, _dsn, name); +} + + +void X_display::free_xftfont (XftFont *F) +{ + XftFontClose (_dpy, F); +} + + +XImage *X_display::image1515 (unsigned int i) +{ + return (i < N_IMG1515) ? _imgptr1515 [i] : 0; +} + + +unsigned char X_display::_imgdef1515 [N_IMG1515 * 30] = +{ + 0,0,0,0,0,0,0,2,0,3,128,3,192,3,224,3,192,3,128,3,0,3,0,2,0,0,0,0,0,0, + 0,0,0,0,0,0,32,0,96,0,224,0,224,1,224,3,224,1,224,0,96,0,32,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,128,0,192,1,224,3,240,7,248,15,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,248,15,240,7,224,3,192,1,128,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,192,1,192,1,192,1,248,15,248,15,248,15,192,1,192,1,192,1,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,248,15,248,15,248,15,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,248,15,248,15,24,12,24,12,24,12,24,12,24,12,248,15,248,15,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,224,3,224,3,224,3,224,3,224,3,0,0,0,0,0,0,0,0,0,0 +}; + + + + + + diff -Nru clxclient-3.9.0/source/xdraw.cc clxclient-3.9.2/source/xdraw.cc --- clxclient-3.9.0/source/xdraw.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/xdraw.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,137 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include +#include "clxclient.h" + + +X_draw::X_draw (Display *dpy, Drawable drw, GC gct, XftDraw *xft) : + _dpy (dpy), _drw (drw), _gct (gct), + _xft_draw (xft), _xft_color (0), _xft_font (0), + _xx (0), _yy (0) +{ + if (_xft_draw && XftDrawDrawable (_xft_draw) != _drw) XftDrawChange (_xft_draw, _drw); +} + + +int X_draw::textwidth (const char *str) +{ + int len; + XGlyphInfo G; + + if (str && (len = strlen (str))) + { + if (_xft_font) + { + XftTextExtentsUtf8 (_dpy, _xft_font, (const FcChar8 *) str, len, &G); + return G.width; + } + else if (_x11_font) return XTextWidth (_x11_font, str, len); + } + return 0; +} + + +void X_draw::drawstring (const char *str, int xal) +{ + int len, dx = 0; + XGlyphInfo G; + + if (str && (len = strlen (str))) + { + if (_xft_font) + { + if (xal >= 0) + { + XftTextExtentsUtf8 (_dpy, _xft_font, (const FcChar8 *) str, len, &G); + dx = G.width; + if (xal == 0) dx /= 2; + } + XftDrawStringUtf8 (_xft_draw, _xft_color, _xft_font, _xx - dx, _yy, (const FcChar8 *) str, len); + } + else if (_x11_font) + { + if (xal >= 0) + { + dx = XTextWidth (_x11_font, str, len); + if (xal == 0) dx /= 2; + } + XDrawString (_dpy, _drw, _gct, _xx - dx, _yy, str, len); + } + } +} + + +void X_draw::drawpoints (int n, XPoint *P) +{ + XDrawPoints (_dpy, _drw, _gct, P, n, CoordModeOrigin); +} + + +void X_draw::drawlines (int n, XPoint *P) +{ + int k, m; + + m = (XMaxRequestSize (_dpy) - 3) / 2; + while (n > 1) + { + if (n > m) k = m; + else k = n; + XDrawLines (_dpy, _drw, _gct, P, k, CoordModeOrigin); + P += k - 1; + n -= k - 1; + } +} + + +void X_draw::drawsegments (int n, XSegment *S) +{ + XDrawSegments (_dpy, _drw, _gct, S, n); +} + + +void X_draw::setclip (int x0, int y0, int x1, int y1) +{ + XRectangle R; + + R.x = x0; + R.y = y0; + R.width = x1 - x0; + R.height = y1 - y0; + XSetClipRectangles (_dpy, _gct, 0, 0, &R, 1, Unsorted); +} + + +void X_draw::movepix (int dx, int dy, int xs, int ys) +{ + XGCValues G; + + G.graphics_exposures = True; + G.function = GXcopy; + XChangeGC (_dpy, _gct, GCGraphicsExposures | GCFunction, &G); + XCopyArea (_dpy, _drw, _drw, _gct, dx, dy, xs, ys, 0, 0); + G.graphics_exposures = False; + XChangeGC (_dpy, _gct, GCGraphicsExposures, &G); +} + + + + diff -Nru clxclient-3.9.0/source/xhandler.cc clxclient-3.9.2/source/xhandler.cc --- clxclient-3.9.0/source/xhandler.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/xhandler.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,70 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include +#include "clxclient.h" + + +X_handler::X_handler (X_display *disp, Edest *dest, int ipid) : + H_thread (dest, ipid), + _conn (ConnectionNumber (disp-> dpy ())) +{ + thr_start (SCHED_OTHER, 0, 0x00010000); +} + + +X_handler::~X_handler (void) +{ + sepuku (); +} + + +extern "C" int x_handler_error (Display *dpy, XErrorEvent *err) +{ + char s [256]; + + XGetErrorText (dpy, err->error_code, s, 256); + fprintf (stderr, "X_handler::error () %s\n", s); + return 0; +} + + +void X_handler::thr_main (void) +{ + struct pollfd pfd [1]; + + XSetErrorHandler (x_handler_error); + + get_event (); + while (1) + { + pfd [0].fd = _conn; + pfd [0].events = POLLIN | POLLERR; + if (poll (pfd, 1, -1) < 0) + { + if (errno == EINTR) continue; + perror ("X_handler: poll()"); + } + if (pfd [0].revents & POLLIN) reply (); + else return; + get_event (); + } +} diff -Nru clxclient-3.9.0/source/xresman.cc clxclient-3.9.2/source/xresman.cc --- clxclient-3.9.0/source/xresman.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/xresman.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,165 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include +#include +#include "clxclient.h" + + +XrmOptionDescRec X_resman::defopt [X_resman::NDEFOPT] = +{ + {(char *)("-display"), (char *)(".display"), XrmoptionSepArg, NULL }, + {(char *)("-name"), (char *)(".name"), XrmoptionSepArg, NULL }, + {(char *)("-title"), (char *)(".title"), XrmoptionSepArg, NULL }, + {(char *)("-iconic"), (char *)("*iconic"), XrmoptionNoArg, (char *)("on") }, + {(char *)("-mono"), (char *)(".mono"), XrmoptionNoArg, (char *)("on") }, + {(char *)("-gray"), (char *)(".gray"), XrmoptionNoArg, (char *)("on") }, + {(char *)("-geometry"), (char *)("*geometry"), XrmoptionSepArg, NULL }, + {(char *)("-background"), (char *)("*background"), XrmoptionSepArg, NULL }, + {(char *)("-bg"), (char *)("*background"), XrmoptionSepArg, NULL }, + {(char *)("-foreground"), (char *)("*foreground"), XrmoptionSepArg, NULL }, + {(char *)("-fg"), (char *)("*foreground"), XrmoptionSepArg, NULL }, + {(char *)("-font"), (char *)("*font"), XrmoptionSepArg, NULL }, + {(char *)("-fn"), (char *)("*font"), XrmoptionSepArg, NULL }, +}; + + + +X_resman::X_resman (void) : + _xrmdata (NULL) +{ +} + + +X_resman::~X_resman (void) +{ +} + + +void X_resman::init (int *argc, char *argv [], char *name, + XrmOptionDescRec *opt, int nopt) +{ + XrmDatabase cmd_db = NULL; + XrmDatabase def_db = NULL; + XrmDatabase app_db = NULL; + + char line [256]; + int ac; + char **av; + + _home = getenv ("HOME"); + if (_home == 0) _home = (char *)""; + + // set default name and class + strncpy (_rname, name, 63); + strncpy (_rclas, name, 63); + _rclas [0] = toupper (_rclas [0]); + + // Scan command line args for -name and -class + ac = *argc; + av = argv; + while (++av, --ac > 0) + { + if (! strcmp (*av, "-name") && ac > 1) strncpy (_rname, av [1], 63); + if (! strcmp (*av, "-class") && ac > 1) strncpy (_rclas, av [1], 63); + } + + // Initialise X resource manager + XrmInitialize (); + + // Read user default options. + sprintf (line, "%s/.Xdefaults", _home); + def_db = XrmGetFileDatabase (line); + + // Read options from application options file or system wide config file + sprintf (line, "%s/.%src", _home, _rname); + app_db = XrmGetFileDatabase (line); + if (! app_db) + { + sprintf (line, "/etc/%s.conf", _rname); + app_db = XrmGetFileDatabase (line); + } + + // Scan command line for options. + if (opt && nopt) XrmParseCommand (&cmd_db, opt, nopt, _rname, argc, argv); + + // Merge all Xrm databases + XrmMergeDatabases (def_db, &_xrmdata); + XrmMergeDatabases (app_db, &_xrmdata); + XrmMergeDatabases (cmd_db, &_xrmdata); +} + + +const char *X_resman::get (const char *res, const char *def) const +{ + char r1 [128]; + char r2 [128]; + char *t [20]; + XrmValue v; + + strcpy (r1, _rname); + strcat (r1, res); + strcpy (r2, _rclas); + strcat (r2, res); + return XrmGetResource (_xrmdata, r1, r2, t, &v) ? (char *) v.addr : def; +} + + +int X_resman::getb (const char *res, int def) const +{ + const char *val; + + val = get (res, 0); + if (val) return ! ( strcmp (val, "on") + && strcmp (val, "true") + && strcmp (val, "On") + && strcmp (val, "True")); + else return def; +} + + +void X_resman::geometry (const char *res, int xd, int yd, int bd, int &xp, int &yp, int &xs, int &ys) +{ + const char *g; + int f, xp1, yp1; + unsigned int xs1, ys1; + + g = get (res, NULL); + if (g) + { + f = XParseGeometry (g, &xp1, &yp1, &xs1, &ys1); + + if (f & WidthValue) xs = xs1; + if (f & HeightValue) ys = ys1; + + if (f & XValue) + { + if (f & XNegative) xp1 += xd - xs - bd; + xp = xp1; + } + if (f & YValue) + { + if (f & YNegative) yp1 += yd - ys - bd; + yp = yp1; + } + } +} + diff -Nru clxclient-3.9.0/source/xwindow.cc clxclient-3.9.2/source/xwindow.cc --- clxclient-3.9.0/source/xwindow.cc 1970-01-01 00:00:00.000000000 +0000 +++ clxclient-3.9.2/source/xwindow.cc 2018-08-24 18:50:31.000000000 +0000 @@ -0,0 +1,268 @@ +// --------------------------------------------------------------------------------- +// +// Copyright (C) 2003-2013 Fons Adriaensen +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// --------------------------------------------------------------------------------- + + +#include "clxclient.h" + + +void X_hints::position (int x, int y) +{ + _sh.flags |= PPosition; + _sh.x = x; + _sh.y = y; +} + + +void X_hints::size (int x, int y) +{ + _sh.flags |= PSize; + _sh.width = x; + _sh.height = y; +} + + +void X_hints::minsize (int x, int y) +{ + _sh.flags |= PMinSize; + _sh.min_width = x; + _sh.min_height = y; +} + + +void X_hints::maxsize (int x, int y) +{ + _sh.flags |= PMaxSize; + _sh.max_width = x; + _sh.max_height = y; +} + + +void X_hints::sizeinc (int x, int y) +{ + _sh.flags |= PResizeInc; + _sh.width_inc = x; + _sh.height_inc = y; +} + + +void X_hints::input (int input) +{ + _mh.flags |= InputHint; + _mh.input = input; +} + + +void X_hints::state (int state) +{ + _mh.flags |= StateHint; + _mh.initial_state = state; +} + +void X_hints::group (Window group) +{ + _mh.flags |= WindowGroupHint; + _mh.window_group = group; +} + + + + +X_window::X_window (X_display *disp) : + _ebits (0), _disp (disp), _pwin (0), _next (0), _list (0) +{ + _wind = DefaultRootWindow (disp->_dpy); +} + + +X_window::X_window (X_window *pwin, int xpos, int ypos, int xsize, int ysize, + unsigned long bgcol, unsigned long bdcol, int bdpix) : + _ebits (0), _disp (pwin->_disp), _pwin (pwin), _next (pwin->_list), _list (0) +{ + _pwin->_list = this; + _wind = XCreateSimpleWindow (_disp->_dpy, pwin->_wind, + xpos, ypos, xsize, ysize, + bdpix, bdcol, bgcol); +} + + +X_window::~X_window (void) +{ + X_window *T; + + while (_list) delete _list; + if (_pwin) + { + T = _pwin->_list; + if (T == this) _pwin->_list = _next; + else + { + while (T && T->_next != this) T = T->_next; + if (T) T->_next = _next; + } + XDestroyWindow (_disp->_dpy, _wind); + XFlush (dpy ()); + } +} + + +X_window *X_window::find (Window w) +{ + X_window *T, *W; + + if (_wind == w) return this; + for (T = _list, W = 0; T && ! (W = T->find (w)); T = T->_next); + return W; +} + + +int X_window::x_resize (int xs, int ys) const +{ + return XResizeWindow (_disp->_dpy, _wind, xs, ys); +} + + +int X_window::x_move (int xp, int yp) const +{ + return XMoveWindow (_disp->_dpy, _wind, xp, yp); +} + + +int X_window::x_moveresize (int xp, int yp, int xs, int ys) const +{ + return XMoveResizeWindow (_disp->_dpy, _wind, xp, yp, xs, ys); +} + + +int X_window::x_set_attrib (unsigned long mask, XSetWindowAttributes *attr) const +{ + return XChangeWindowAttributes (_disp->_dpy, _wind, mask, attr); +} + + +int X_window::x_set_win_gravity (int gravity) const +{ + XSetWindowAttributes attr; + + attr.win_gravity = gravity; + return XChangeWindowAttributes (_disp->_dpy, _wind, CWWinGravity, &attr); +} + + +int X_window::x_set_bit_gravity (int gravity) const +{ + XSetWindowAttributes attr; + + attr.bit_gravity = gravity; + return XChangeWindowAttributes (_disp->_dpy, _wind, CWBitGravity, &attr); +} + + +int X_window::x_add_events (unsigned long events) +{ + _ebits |= events; + return XSelectInput (_disp->_dpy, _wind, _ebits); +} + + +int X_window::x_rem_events (unsigned long events) +{ + _ebits &= ~events; + return XSelectInput (_disp->_dpy, _wind, _ebits); +} + + +int X_window::x_set_title (const char *title) +{ + return XStoreName (_disp->_dpy, _wind, title); +} + + +int X_window::x_set_background (unsigned long color) +{ + return XSetWindowBackground (_disp->_dpy, _wind, color); +} + + +void X_window::x_apply (X_hints *hints) +{ + if (hints->_sh.flags) XSetWMNormalHints (_disp->_dpy, _wind, &(hints->_sh)); + if (hints->_mh.flags) XSetWMHints (_disp->_dpy, _wind, &(hints->_mh)); + XSetClassHint (_disp->_dpy, _wind, &(hints->_ch)); + hints->_sh.flags = 0; + hints->_mh.flags = 0; +} + + + +X_rootwin::X_rootwin (X_display *disp) : + X_window (disp), + _object (0) +{ + _disp->_xft = XftDrawCreate (_disp->_dpy, _wind, _disp->_dvi, _disp->_dcm); +} + + +X_rootwin::~X_rootwin (void) +{ +// if (_disp->_xft) XftDrawDestroy (_disp->_xft); +} + + +static Bool check_event (Display *dpy, XEvent *ev, char *arg) +{ + return True; +} + + +void X_rootwin::handle_event (void) +{ + XEvent E; + while (XCheckIfEvent (_disp->_dpy, &E, &check_event, 0)) + { + handle_event (&E); + } +} + + +void X_rootwin::handle_event (XEvent *E) +{ + X_window *W; + Window k; + + k = ((XAnyEvent *) E)->window; +// if (XFilterEvent (E, k)) return; + if (_object && _window == k) + { + _object->handle_event (E); + } + else + { + W = find (k); + if (W && W != this) + { + W->handle_event (E); + _window = k; + _object = W; + } + } + XFlush (_disp->_dpy); +} + + diff -Nru clxclient-3.9.0/textip.cc clxclient-3.9.2/textip.cc --- clxclient-3.9.0/textip.cc 2013-06-28 14:48:05.000000000 +0000 +++ clxclient-3.9.2/textip.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,703 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include -#include "clxclient.h" - - -#define DX 4 - - -X_textln::X_textln (X_window *parent, - X_textln_style *style, - int xp, - int yp, - int xs, - int ys, - const char *text, - int xal) : - X_window (parent, xp, yp, xs, ys, style->color.normal.bgnd), - _style (style), - _text (text) -{ - XGlyphInfo K; - - x_add_events (ExposureMask); - _len = strlen (text); - _x0 = 2; - _y0 = (ys + style->font->ascent - style->font->descent) / 2; - if (xal >= 0) - { - XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *) _text, _len, &K); - _x0 = xs - K.width - 2; - if (xal == 0) _x0 /= 2; - } -} - - -X_textln::~X_textln (void) -{ -} - - -void X_textln::handle_event (XEvent *xe) -{ - switch (xe->type) - { - case Expose: - expose ((XExposeEvent *) xe); - break; - } -} - - -void X_textln::expose (XExposeEvent *e) -{ - if (e->count == 0) - { - XClearWindow (dpy (), win ()); - if (_len) - { - XftDrawChange (xft (), win ()); - XftDrawStringUtf8 (xft (), _style->color.normal.text, _style->font, _x0, _y0, (const FcChar8 *) _text, _len); - } - } -} - - -XIC X_textip::_xic = 0; -unsigned char X_textip::_utf8mark [6] = { 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - -X_textip::X_textip (X_window *parent, - X_callback *callb, - X_textln_style *style, - int xp, - int yp, - int xs, - int ys, - int max, - X_linked *back, - X_linked *forw) : - X_window (parent, xp, yp, xs, ys, style->color.normal.bgnd), - X_linked (back, forw), - _callb (callb), - _style (style), - _bg (_style->color.normal.bgnd), - _fg (_style->color.normal.text), - _flags (0), - _xs (xs), - _ys (ys), - _txt (0), - _max (max), - _ic (0), - _i1 (0) -{ - x_add_events (ExposureMask); - _txt = new unsigned char [_max + 1]; - _y0 = (_ys + style->font->ascent - style->font->descent) / 2; - _x0 = _x1 = _xc = DX; - if (callb) - { - x_add_events (ButtonPressMask | FocusChangeMask); - if (! _xic) _xic = XCreateIC (xim (), XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, win (), XNFocusWindow, win (), NULL); - } -} - - -X_textip::~X_textip (void) -{ - delete [] _txt; -} - - -void X_textip::set_text (const char *txt) -{ - _i1 = 0; - if (txt) while ((*((unsigned char *) txt) >= ' ') && (_i1 < _max)) _txt [_i1++] = *txt++; - if (_flags & RIGHT) { _x0 = _xs - DX; _ic = _i1; } - else { _x0 = DX; _ic = 0; } - xorcursor (); - update (true); -} - - -void X_textip::set_color (unsigned long bg, XftColor *fg) -{ - if ((_fg != fg) || (_bg != bg)) - { - _fg = fg; - _bg = bg; - redraw (); - } -} - - -void X_textip::set_align (int k) -{ - if (k > 0) - { - _flags &= ~CENTER; - _flags |= RIGHT; - _x0 = _xs - DX; - _ic = _i1; - } - else if (k < 0) - { - _flags &= ~(RIGHT | CENTER); - _x0 = DX; - _ic = 0; - } - else - { - _flags |= CENTER; - _flags &= ~RIGHT; - } - xorcursor (); - update (true); -} - - - -void X_textip::enable (void) -{ - XSetInputFocus (dpy (), win (), RevertToParent, CurrentTime); -} - - -void X_textip::select (void) -{ - if (_callb) _callb->handle_callb (X_callback::TEXTIP | BUT, this, 0); -} - - -void X_textip::handle_event (XEvent *xe) -{ - switch (xe->type) - { - case Expose: - expose ((XExposeEvent *) xe); - break; - - case ButtonPress: - bpress ((XButtonEvent *) xe); - break; - - case KeyPress: - keypress ((XKeyEvent *) xe); - break; - - case FocusIn: - setfocus ((XFocusChangeEvent *) xe); - break; - - case FocusOut: - remfocus ((XFocusChangeEvent *) xe); - break; - - case SelectionNotify: - paste ((XSelectionEvent *) xe); - break; - } -} - - -void X_textip::expose (XExposeEvent *e) -{ - if (e->count == 0) redraw (); -} - - -void X_textip::bpress (XButtonEvent *e) -{ - if (e->button == Button2) - { -// XConvertSelection (dpy (), XA_PRIMARY, XA_STRING, XA_PRIMARY, win (), e->time); - } - else - { - xorcursor (); - _ic = findindex (e->x); - _xc = _x0 + textwidth (0, _ic); - if (_callb) _callb->handle_callb (X_callback::TEXTIP | BUT, this, (XEvent *) e); - xorcursor (); - } -} - - -void X_textip::keypress (XKeyEvent *e) -{ - int k; - unsigned char t [8]; - - if (XFilterEvent ((XEvent *) e, win ())) return; - if ( (k = Xutf8LookupString (_xic, e, (char *) t, 8, 0, 0)) - && ((*t >= 192) || ((*t >= 32) && (*t < 127)))) - { - checkclear (); - insert (k, t); - xorcursor (); - update (true); - checkcallb (); - } - else spkey (e); -} - - -int X_textip::test_utf8 (int k, const unsigned char *t) -{ - int c, i, n; - - c = *t++; - if ((c < 0x20) || (c == 0x7F) || (c >= 0xFE)) return 0; - if (c < 0x7F) return 1; - for (n = 5; n; n--) - { - if (c >= _utf8mark [n]) - { - if (n >= k) return 0; - for (i = 0; i < n; i++) - { - c = *t++; - if ((c < 0x80) || (c >= 0xC0)) return 0; - } - return n + 1; - } - } - return 0; -} - - -void X_textip::insert (int k, const unsigned char *t) -{ - int i; - - if (_i1 + k <= _max) - { - _i1 += k; - for (i = _i1; i > _ic; i--) _txt [i] = _txt [i - k]; - while (k--) _txt [_ic++] = *t++; - } - else XBell (dpy (), 0); -} - - -void X_textip::paste (XSelectionEvent *e) -{ - int k, n; - const unsigned char *p; - XTextProperty t; - - if (e->target != None) - { - XGetTextProperty (dpy (), win (), &t, e->property); - n = t.nitems; - if (n > _max - _i1) XBell (dpy (), 0); - else if (n) - { - checkclear (); - p = (const unsigned char *)(t.value); - while (n) - { - if ((k = test_utf8 (n, p))) - { - insert (k, p); - n -= k; - p += k; - } - else - { - k--; - p++; - } - } - xorcursor (); - update (true); - checkcallb (); - } - } -} - - -void X_textip::spkey (XKeyEvent *e) -{ - int k = XLookupKeysym (e, 0); - - switch (k) - { - case XK_Home: - case 'a': - go_sol (); - break; - - case XK_End: - case 'e': - go_eol (); - break; - - case XK_Left: - if (e->state & (ControlMask | ShiftMask)) cbkey (k, e); - else go_lt (); - break; - - case 'b': - go_lt (); - break; - - case XK_Right: - if (e->state & (ControlMask | ShiftMask)) cbkey (k, e); - else go_rt (); - break; - - case 'f': - go_rt (); - break; - - case XK_Delete: - case 'd': - del_rt (); - break; - - case 'k': - del_eol (); - break; - - case 'u': - del_all (); - break; - - case XK_BackSpace: - del_lt (); - break; - - case XK_Tab: - go_eol (); - if (e->state & ControlMask) { if (_back) _back->select (); } - else { if (_forw) _forw->select (); } - break; - - case XK_Up: - case XK_Down: - cbkey (k, e); - break; - - case XK_Return: - case XK_KP_Enter: - go_eol (); - if (_forw) _forw->select (); - else cbkey (XK_Return, e); - break; - - default: - cbkey (k, e); - } -} - - -void X_textip::cbkey (int k, XKeyEvent *e) -{ - _key = k; - if (_callb) _callb->handle_callb (X_callback::TEXTIP | KEY, this, (XEvent *) e); -} - - -void X_textip::go_sol (void) -{ - _flags &= ~CLEAR; - if (_i1) - { - xorcursor (); - _ic = 0; - _xc = _x0; - update (false); - } -} - - -void X_textip::go_eol (void) -{ - _flags &= ~CLEAR; - if (_i1) - { - xorcursor (); - _ic = _i1; - _xc = _x1; - update (false); - } -} - - -void X_textip::go_lt (void) -{ - int i, d; - - _flags &= ~CLEAR; - if (_ic > 0) - { - for (i = _ic - 1, d = 1; (i > 0) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i--, d++); - xorcursor (); - _ic -= d; - _xc = _x0 + textwidth (0, _ic); - update (false); - } -} - - -void X_textip::go_rt (void) -{ - int i, d; - - _flags &= ~CLEAR; - if (_ic < _i1) - { - for (i = _ic + 1, d = 1; (i < _i1) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i++, d++); - xorcursor (); - _ic += d; - _xc = _x0 + textwidth (0, _ic); - update (false); - } -} - - -void X_textip::del_lt (void) -{ - int i, d; - - _flags &= ~CLEAR; - if (_ic > 0) - { - for (i = _ic - 1, d = 1; (i > 0) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i--, d++); - _ic -= d; - _i1 -= d; - for (i = _ic; i < _i1; i++) _txt [i] = _txt [i + d]; - xorcursor (); - update (true); - checkcallb (); - } -} - - -void X_textip::del_rt (void) -{ - int i, d; - - _flags &= ~CLEAR; - if (_ic < _i1) - { - for (i = _ic + 1, d = 1; (i < _i1) && (_txt [i] >= 0x80) && (_txt [i] < 0xC0); i++, d++); - _i1 -= d; - for (i = _ic; i < _i1; i++) _txt [i] = _txt [i + d]; - xorcursor (); - update (true); - checkcallb (); - } -} - - -void X_textip::del_eol (void) -{ - _flags &= ~CLEAR; - if (_ic < _i1) - { - _i1 = _ic; - xorcursor (); - update (true); - checkcallb (); - } -} - - -void X_textip::del_all (void) -{ - _flags &= ~CLEAR; - if (_i1) - { - _ic = _i1 = 0; - _xc = (_flags & RIGHT) ? _xs - DX : DX; - _x0 = _x1 = _xc; - redraw (); - checkcallb (); - } -} - - -void X_textip::update (bool f) -{ - int d; - - _xc = _x0 + textwidth (0, _ic); - _x1 = _xc + textwidth (_ic, _i1 - _ic); - - if (_flags & CENTER) - { - d = (_x0 + _x1 - _xs) / 2; - if (d > _xc - DX) d = _xc - DX; - if (d < _xc - _xs + DX) d = _xc - _xs + DX; - } - else if (_flags & RIGHT) - { - d = _x1 - _xs + DX; - if (d > _xc - DX) d = _xc - DX; - } - else - { - d = _x0 - DX; - if (d < _xc - _xs + DX) d = _xc - _xs + DX; - } - _xc -= d; - _x0 -= d; - _x1 -= d; - if (d | f) redraw (); - else xorcursor (); -} - - -void X_textip::redraw (void) -{ - GC gc = disp ()->dgc (); - XftDraw *D = xft (); - XftColor *C; - unsigned long dark, lite, bgnd; - - XSetWindowBackground (dpy (), win (), (_flags & FOCUS) ? _style->color.focus.bgnd : _bg); - XClearWindow (dpy (), win ()); - - if (_i1) - { - XftDrawChange (D, win ()); - C = (_flags & FOCUS) ? _style->color.focus.text : _fg; - XftDrawStringUtf8 (D, C, _style->font, _x0, _y0, (const FcChar8 *) _txt, _i1); - } - if (_callb) - { - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - XSetFunction (dpy (), gc, GXcopy); - dark = _style->color.shadow.dark; - lite = _style->color.shadow.lite; - bgnd = _style->color.shadow.bgnd; - if (dark == lite) - { - XSetForeground (dpy (), gc, dark); - XDrawRectangle (dpy (), win (), dgc (), 0, 0, _xs - 1, _ys - 1); - } - else - { - XSetForeground (dpy (), gc, dark); - XDrawLine (dpy (), win (), gc, 0, 0, 0, _ys - 1); - XDrawLine (dpy (), win (), gc, 0, 0, _xs - 1, 0); - XSetForeground (dpy (), gc, lite); - XDrawLine (dpy (), win (), gc, _xs - 1, 1, _xs - 1, _ys); - XDrawLine (dpy (), win (), gc, 1, _ys - 1, _xs, _ys - 1); - XSetForeground (dpy (), gc, bgnd); - XDrawPoint (dpy (), win (), gc, 0, _ys - 1); - XDrawPoint (dpy (), win (), gc, _xs - 1, 0); - } - } - xorcursor (); -} - - -void X_textip::setfocus (XFocusChangeEvent *e) -{ - if (e->detail != NotifyPointer && ! (_flags & FOCUS)) - { - _flags ^= FOCUS; - x_add_events (KeyPressMask); - XSetICValues (_xic, XNFocusWindow, win (), NULL); - XSetICFocus (_xic); - redraw (); - } -} - - -void X_textip::remfocus (XFocusChangeEvent *e) -{ - if (_flags & FOCUS) - { - _flags ^= FOCUS; - x_rem_events (KeyPressMask); - XUnsetICFocus (_xic); - redraw (); - } -} - - -void X_textip::xorcursor (void) -{ - int y0, y1; - - if (_flags & FOCUS) - { - GC gc = disp ()->dgc (); - XSetForeground (dpy (), gc, _style->color.focus.bgnd ^ _style->color.focus.line); - XSetFunction (dpy (), gc, GXxor); - XSetLineAttributes (dpy (), gc, 1, LineSolid, CapButt, JoinBevel); - y0 = _y0 - _style->font->ascent; - y1 = _y0 + _style->font->descent; - if (y0 < 1) y0 = 1; - if (y1 > _ys - 1) y1 = _ys - 1; - XDrawLine (dpy (), win (), gc, _xc, y0, _xc, y1); - } -} - - -int X_textip::findindex (int x) -{ - int i, i0, i1; - - if (x < _x0) return 0; - i0 = 0; - i1 = _i1; - while (i1 > i0 + 1) - { - i = (i0 + i1) / 2; - if (_x0 + textwidth (0, i) > x) i1 = i; - else i0 = i; - } - return i1; -} - - -int X_textip::textwidth (int i, int n) -{ - XGlyphInfo K; - - if (n == 0) return 0; - XftTextExtentsUtf8 (dpy (), _style->font, (const FcChar8 *)(_txt + i), n, &K); - return K.xOff; -} - - -void X_textip::checkclear (void) -{ - if (_flags & CLEAR) del_all (); -} - - -void X_textip::checkcallb (void) -{ - if (_flags & CALLB) - { - _callb->handle_callb (X_callback::TEXTIP | MODIF, this, 0); - _flags ^= CALLB; - } -} diff -Nru clxclient-3.9.0/xdisplay.cc clxclient-3.9.2/xdisplay.cc --- clxclient-3.9.0/xdisplay.cc 2013-06-28 14:48:16.000000000 +0000 +++ clxclient-3.9.2/xdisplay.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -const char *clxclient_version (void) { return VERSION; } - - -X_display::X_display (const char *name) : - _dsn (0), _dcm (0), _dgc (0), _dvi (0), _xft (0), _xim (0) -{ - int i; - XImage *I; - - _dpy = XOpenDisplay (name); - if (! _dpy) return; - - _dsn = DefaultScreen (_dpy); - _dcm = DefaultColormap (_dpy, _dsn); - _dgc = DefaultGC (_dpy, _dsn); - _dvi = DefaultVisual (_dpy, _dsn); - _xim = XOpenIM (_dpy, 0, 0, 0); - - for (i = 0; i < N_IMG1515; i++) - { - I = XCreateImage (_dpy, _dvi, 1, XYBitmap, 0, (char *) _imgdef1515 + 30 * i, 15, 15, 8, 2); - I->bitmap_unit = 8; - I->bitmap_pad = 8; - I->bitmap_bit_order = LSBFirst; - XInitImage (I); - _imgptr1515 [i] = I; - } -} - - -X_display::~X_display (void) -{ - int i; - - if (!_dpy) return; - for (i = 0; i < N_IMG1515; i++) - { - _imgptr1515 [i]->data = 0; - XDestroyImage (_imgptr1515 [i]); - } - if (_xim) XCloseIM (_xim); - XCloseDisplay (_dpy); -} - - -unsigned long X_display::alloc_color (const char *name, unsigned long d) -{ - XColor C; - - if (XParseColor (_dpy, _dcm, name, &C)) - { - if (XAllocColor (_dpy, _dcm, &C)) return C.pixel; - else fprintf (stderr, "-- Can't alloc '%s', using default (%ld).\n", name, d); - } - else fprintf (stderr, "-- Can't parse '%s', using default (%ld).\n", name, d); - return d; -} - - - -unsigned long X_display::alloc_color (float r, float g, float b) -{ - XColor C; - - C.red = (int)(65535 * r); - C.green = (int)(65535 * g); - C.blue = (int)(65535 * b); - - if (XAllocColor (_dpy, _dcm, &C)) return C.pixel; - else return 0; -} - - - -XftColor *X_display::alloc_xftcolor (const char *name, XftColor *D) -{ - XftColor *C = new XftColor; - - if (! XftColorAllocName (_dpy, _dvi, _dcm, name, C)) - { - if (D) - { - XftColorAllocValue (_dpy, _dvi, _dcm, &(D->color), C); - fprintf (stderr, " -- Can't alloc '%s', using default (%ld).\n", name, D->pixel); - } - else fprintf (stderr, " -- Can't alloc '%s', no default provided.\n", name); - } - return C; -} - - -XftColor *X_display::alloc_xftcolor (float r, float g, float b, float a) -{ - XftColor *C = new XftColor; - XRenderColor R; - - R.red = (int)(65535 * r); - R.green = (int)(65535 * g); - R.blue = (int)(65535 * b); - R.alpha = (int)(65535 * a); - - XftColorAllocValue (_dpy, _dvi, _dcm, &R, C); - return C; -} - - -void X_display::free_xftcolor (XftColor *C) -{ - XftColorFree (_dpy, _dvi, _dcm, C); - delete C; -} - - -#define FALLBACK "Fixed" - - -XFontStruct *X_display::alloc_font (const char *name) -{ - XFontStruct *F = NULL; - - if (name) - { - if (! (F = XLoadQueryFont (_dpy, name))) - { - fprintf (stderr, "-- Can't load font '%s'\n", name); - fprintf (stderr, "-- Trying to use %s instead.\n", FALLBACK); - } - } - if (! F) - { - if (! (F = XLoadQueryFont (_dpy, FALLBACK))) - { - fprintf(stderr, "-- Can't load font %s \n", FALLBACK); - fprintf(stderr, "-- No useable font - X11 aborted.\n"); - exit (1); - } - } - return F; -} - - -XftFont *X_display::alloc_xftfont (const char *name) -{ - return XftFontOpenName (_dpy, _dsn, name); -} - - -void X_display::free_xftfont (XftFont *F) -{ - XftFontClose (_dpy, F); -} - - -XImage *X_display::image1515 (unsigned int i) -{ - return (i < N_IMG1515) ? _imgptr1515 [i] : 0; -} - - -unsigned char X_display::_imgdef1515 [N_IMG1515 * 30] = -{ - 0,0,0,0,0,0,0,2,0,3,128,3,192,3,224,3,192,3,128,3,0,3,0,2,0,0,0,0,0,0, - 0,0,0,0,0,0,32,0,96,0,224,0,224,1,224,3,224,1,224,0,96,0,32,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,128,0,192,1,224,3,240,7,248,15,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,248,15,240,7,224,3,192,1,128,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,192,1,192,1,192,1,248,15,248,15,248,15,192,1,192,1,192,1,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,248,15,248,15,248,15,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,248,15,248,15,24,12,24,12,24,12,24,12,24,12,248,15,248,15,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,224,3,224,3,224,3,224,3,224,3,0,0,0,0,0,0,0,0,0,0 -}; - - - - - - diff -Nru clxclient-3.9.0/xdraw.cc clxclient-3.9.2/xdraw.cc --- clxclient-3.9.0/xdraw.cc 2013-06-28 14:48:23.000000000 +0000 +++ clxclient-3.9.2/xdraw.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include -#include "clxclient.h" - - -X_draw::X_draw (Display *dpy, Drawable drw, GC gct, XftDraw *xft) : - _dpy (dpy), _drw (drw), _gct (gct), - _xft_draw (xft), _xft_color (0), _xft_font (0), - _xx (0), _yy (0) -{ - if (_xft_draw && XftDrawDrawable (_xft_draw) != _drw) XftDrawChange (_xft_draw, _drw); -} - - -int X_draw::textwidth (const char *str) -{ - int len; - XGlyphInfo G; - - if (str && (len = strlen (str))) - { - if (_xft_font) - { - XftTextExtentsUtf8 (_dpy, _xft_font, (const FcChar8 *) str, len, &G); - return G.width; - } - else if (_x11_font) return XTextWidth (_x11_font, str, len); - } - return 0; -} - - -void X_draw::drawstring (const char *str, int xal) -{ - int len, dx = 0; - XGlyphInfo G; - - if (str && (len = strlen (str))) - { - if (_xft_font) - { - if (xal >= 0) - { - XftTextExtentsUtf8 (_dpy, _xft_font, (const FcChar8 *) str, len, &G); - dx = G.width; - if (xal == 0) dx /= 2; - } - XftDrawStringUtf8 (_xft_draw, _xft_color, _xft_font, _xx - dx, _yy, (const FcChar8 *) str, len); - } - else if (_x11_font) - { - if (xal >= 0) - { - dx = XTextWidth (_x11_font, str, len); - if (xal == 0) dx /= 2; - } - XDrawString (_dpy, _drw, _gct, _xx - dx, _yy, str, len); - } - } -} - - -void X_draw::drawpoints (int n, XPoint *P) -{ - XDrawPoints (_dpy, _drw, _gct, P, n, CoordModeOrigin); -} - - -void X_draw::drawlines (int n, XPoint *P) -{ - int k, m; - - m = (XMaxRequestSize (_dpy) - 3) / 2; - while (n > 1) - { - if (n > m) k = m; - else k = n; - XDrawLines (_dpy, _drw, _gct, P, k, CoordModeOrigin); - P += k - 1; - n -= k - 1; - } -} - - -void X_draw::drawsegments (int n, XSegment *S) -{ - XDrawSegments (_dpy, _drw, _gct, S, n); -} - - -void X_draw::setclip (int x0, int y0, int x1, int y1) -{ - XRectangle R; - - R.x = x0; - R.y = y0; - R.width = x1 - x0; - R.height = y1 - y0; - XSetClipRectangles (_dpy, _gct, 0, 0, &R, 1, Unsorted); -} - - -void X_draw::movepix (int dx, int dy, int xs, int ys) -{ - XGCValues G; - - G.graphics_exposures = True; - G.function = GXcopy; - XChangeGC (_dpy, _gct, GCGraphicsExposures | GCFunction, &G); - XCopyArea (_dpy, _drw, _drw, _gct, dx, dy, xs, ys, 0, 0); - G.graphics_exposures = False; - XChangeGC (_dpy, _gct, GCGraphicsExposures, &G); -} - - - - diff -Nru clxclient-3.9.0/xhandler.cc clxclient-3.9.2/xhandler.cc --- clxclient-3.9.0/xhandler.cc 2013-06-28 14:48:33.000000000 +0000 +++ clxclient-3.9.2/xhandler.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include -#include "clxclient.h" - - -X_handler::X_handler (X_display *disp, Edest *dest, int ipid) : - H_thread (dest, ipid), - _conn (ConnectionNumber (disp-> dpy ())) -{ - thr_start (SCHED_OTHER, 0, 0x00010000); -} - - -X_handler::~X_handler (void) -{ - sepuku (); -} - - -extern "C" int x_handler_error (Display *dpy, XErrorEvent *err) -{ - char s [256]; - - XGetErrorText (dpy, err->error_code, s, 256); - fprintf (stderr, "X_handler::error () %s\n", s); - return 0; -} - - -void X_handler::thr_main (void) -{ - struct pollfd pfd [1]; - - XSetErrorHandler (x_handler_error); - - get_event (); - while (1) - { - pfd [0].fd = _conn; - pfd [0].events = POLLIN | POLLERR; - if (poll (pfd, 1, -1) < 0) - { - if (errno == EINTR) continue; - perror ("X_handler: poll()"); - } - if (pfd [0].revents & POLLIN) reply (); - else return; - get_event (); - } -} diff -Nru clxclient-3.9.0/xresman.cc clxclient-3.9.2/xresman.cc --- clxclient-3.9.0/xresman.cc 2013-06-28 14:49:39.000000000 +0000 +++ clxclient-3.9.2/xresman.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include -#include -#include "clxclient.h" - - -XrmOptionDescRec X_resman::defopt [X_resman::NDEFOPT] = -{ - {(char *)("-display"), (char *)(".display"), XrmoptionSepArg, NULL }, - {(char *)("-name"), (char *)(".name"), XrmoptionSepArg, NULL }, - {(char *)("-title"), (char *)(".title"), XrmoptionSepArg, NULL }, - {(char *)("-iconic"), (char *)("*iconic"), XrmoptionNoArg, (char *)("on") }, - {(char *)("-mono"), (char *)(".mono"), XrmoptionNoArg, (char *)("on") }, - {(char *)("-gray"), (char *)(".gray"), XrmoptionNoArg, (char *)("on") }, - {(char *)("-geometry"), (char *)("*geometry"), XrmoptionSepArg, NULL }, - {(char *)("-background"), (char *)("*background"), XrmoptionSepArg, NULL }, - {(char *)("-bg"), (char *)("*background"), XrmoptionSepArg, NULL }, - {(char *)("-foreground"), (char *)("*foreground"), XrmoptionSepArg, NULL }, - {(char *)("-fg"), (char *)("*foreground"), XrmoptionSepArg, NULL }, - {(char *)("-font"), (char *)("*font"), XrmoptionSepArg, NULL }, - {(char *)("-fn"), (char *)("*font"), XrmoptionSepArg, NULL }, -}; - - - -X_resman::X_resman (void) : - _xrmdata (NULL) -{ -} - - -X_resman::~X_resman (void) -{ -} - - -void X_resman::init (int *argc, char *argv [], char *name, - XrmOptionDescRec *opt, int nopt) -{ - XrmDatabase cmd_db = NULL; - XrmDatabase def_db = NULL; - XrmDatabase app_db = NULL; - - char line [256]; - int ac; - char **av; - - _home = getenv ("HOME"); - if (_home == 0) _home = (char *)""; - - // set default name and class - strncpy (_rname, name, 64); - strncpy (_rclas, name, 64); - _rclas [0] = toupper (_rclas [0]); - - // Scan command line args for -name and -class - ac = *argc; - av = argv; - while (++av, --ac > 0) - { - if (! strcmp (*av, "-name") && ac > 1) strncpy (_rname, av [1], 64); - if (! strcmp (*av, "-class") && ac > 1) strncpy (_rclas, av [1], 64); - } - - // Initialise X resource manager - XrmInitialize (); - - // Read user default options. - sprintf (line, "%s/.Xdefaults", _home); - def_db = XrmGetFileDatabase (line); - - // Read options from application options file or system wide config file - sprintf (line, "%s/.%src", _home, _rname); - app_db = XrmGetFileDatabase (line); - if (! app_db) - { - sprintf (line, "/etc/%s.conf", _rname); - app_db = XrmGetFileDatabase (line); - } - - // Scan command line for options. - if (opt && nopt) XrmParseCommand (&cmd_db, opt, nopt, _rname, argc, argv); - - // Merge all Xrm databases - XrmMergeDatabases (def_db, &_xrmdata); - XrmMergeDatabases (app_db, &_xrmdata); - XrmMergeDatabases (cmd_db, &_xrmdata); -} - - -const char *X_resman::get (const char *res, const char *def) const -{ - char r1 [128]; - char r2 [128]; - char *t [20]; - XrmValue v; - - strcpy (r1, _rname); - strcat (r1, res); - strcpy (r2, _rclas); - strcat (r2, res); - return XrmGetResource (_xrmdata, r1, r2, t, &v) ? (char *) v.addr : def; -} - - -int X_resman::getb (const char *res, int def) const -{ - const char *val; - - val = get (res, 0); - if (val) return ! ( strcmp (val, "on") - && strcmp (val, "true") - && strcmp (val, "On") - && strcmp (val, "True")); - else return def; -} - - -void X_resman::geometry (const char *res, int xd, int yd, int bd, int &xp, int &yp, int &xs, int &ys) -{ - const char *g; - int f, xp1, yp1; - unsigned int xs1, ys1; - - g = get (res, NULL); - if (g) - { - f = XParseGeometry (g, &xp1, &yp1, &xs1, &ys1); - - if (f & WidthValue) xs = xs1; - if (f & HeightValue) ys = ys1; - - if (f & XValue) - { - if (f & XNegative) xp1 += xd - xs - bd; - xp = xp1; - } - if (f & YValue) - { - if (f & YNegative) yp1 += yd - ys - bd; - yp = yp1; - } - } -} - diff -Nru clxclient-3.9.0/xwindow.cc clxclient-3.9.2/xwindow.cc --- clxclient-3.9.0/xwindow.cc 2013-06-28 14:48:46.000000000 +0000 +++ clxclient-3.9.2/xwindow.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,268 +0,0 @@ -// --------------------------------------------------------------------------------- -// -// Copyright (C) 2003-2013 Fons Adriaensen -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// --------------------------------------------------------------------------------- - - -#include "clxclient.h" - - -void X_hints::position (int x, int y) -{ - _sh.flags |= PPosition; - _sh.x = x; - _sh.y = y; -} - - -void X_hints::size (int x, int y) -{ - _sh.flags |= PSize; - _sh.width = x; - _sh.height = y; -} - - -void X_hints::minsize (int x, int y) -{ - _sh.flags |= PMinSize; - _sh.min_width = x; - _sh.min_height = y; -} - - -void X_hints::maxsize (int x, int y) -{ - _sh.flags |= PMaxSize; - _sh.max_width = x; - _sh.max_height = y; -} - - -void X_hints::sizeinc (int x, int y) -{ - _sh.flags |= PResizeInc; - _sh.width_inc = x; - _sh.height_inc = y; -} - - -void X_hints::input (int input) -{ - _mh.flags |= InputHint; - _mh.input = input; -} - - -void X_hints::state (int state) -{ - _mh.flags |= StateHint; - _mh.initial_state = state; -} - -void X_hints::group (Window group) -{ - _mh.flags |= WindowGroupHint; - _mh.window_group = group; -} - - - - -X_window::X_window (X_display *disp) : - _ebits (0), _disp (disp), _pwin (0), _next (0), _list (0) -{ - _wind = DefaultRootWindow (disp->_dpy); -} - - -X_window::X_window (X_window *pwin, int xpos, int ypos, int xsize, int ysize, - unsigned long bgcol, unsigned long bdcol, int bdpix) : - _ebits (0), _disp (pwin->_disp), _pwin (pwin), _next (pwin->_list), _list (0) -{ - _pwin->_list = this; - _wind = XCreateSimpleWindow (_disp->_dpy, pwin->_wind, - xpos, ypos, xsize, ysize, - bdpix, bdcol, bgcol); -} - - -X_window::~X_window (void) -{ - X_window *T; - - while (_list) delete _list; - if (_pwin) - { - T = _pwin->_list; - if (T == this) _pwin->_list = _next; - else - { - while (T && T->_next != this) T = T->_next; - if (T) T->_next = _next; - } - XDestroyWindow (_disp->_dpy, _wind); - XFlush (dpy ()); - } -} - - -X_window *X_window::find (Window w) -{ - X_window *T, *W; - - if (_wind == w) return this; - for (T = _list, W = 0; T && ! (W = T->find (w)); T = T->_next); - return W; -} - - -int X_window::x_resize (int xs, int ys) const -{ - return XResizeWindow (_disp->_dpy, _wind, xs, ys); -} - - -int X_window::x_move (int xp, int yp) const -{ - return XMoveWindow (_disp->_dpy, _wind, xp, yp); -} - - -int X_window::x_moveresize (int xp, int yp, int xs, int ys) const -{ - return XMoveResizeWindow (_disp->_dpy, _wind, xp, yp, xs, ys); -} - - -int X_window::x_set_attrib (unsigned long mask, XSetWindowAttributes *attr) const -{ - return XChangeWindowAttributes (_disp->_dpy, _wind, mask, attr); -} - - -int X_window::x_set_win_gravity (int gravity) const -{ - XSetWindowAttributes attr; - - attr.win_gravity = gravity; - return XChangeWindowAttributes (_disp->_dpy, _wind, CWWinGravity, &attr); -} - - -int X_window::x_set_bit_gravity (int gravity) const -{ - XSetWindowAttributes attr; - - attr.bit_gravity = gravity; - return XChangeWindowAttributes (_disp->_dpy, _wind, CWBitGravity, &attr); -} - - -int X_window::x_add_events (unsigned long events) -{ - _ebits |= events; - return XSelectInput (_disp->_dpy, _wind, _ebits); -} - - -int X_window::x_rem_events (unsigned long events) -{ - _ebits &= ~events; - return XSelectInput (_disp->_dpy, _wind, _ebits); -} - - -int X_window::x_set_title (const char *title) -{ - return XStoreName (_disp->_dpy, _wind, title); -} - - -int X_window::x_set_background (unsigned long color) -{ - return XSetWindowBackground (_disp->_dpy, _wind, color); -} - - -void X_window::x_apply (X_hints *hints) -{ - if (hints->_sh.flags) XSetWMNormalHints (_disp->_dpy, _wind, &(hints->_sh)); - if (hints->_mh.flags) XSetWMHints (_disp->_dpy, _wind, &(hints->_mh)); - XSetClassHint (_disp->_dpy, _wind, &(hints->_ch)); - hints->_sh.flags = 0; - hints->_mh.flags = 0; -} - - - -X_rootwin::X_rootwin (X_display *disp) : - X_window (disp), - _object (0) -{ - _disp->_xft = XftDrawCreate (_disp->_dpy, _wind, _disp->_dvi, _disp->_dcm); -} - - -X_rootwin::~X_rootwin (void) -{ -// if (_disp->_xft) XftDrawDestroy (_disp->_xft); -} - - -static Bool check_event (Display *dpy, XEvent *ev, char *arg) -{ - return True; -} - - -void X_rootwin::handle_event (void) -{ - XEvent E; - while (XCheckIfEvent (_disp->_dpy, &E, &check_event, 0)) - { - handle_event (&E); - } -} - - -void X_rootwin::handle_event (XEvent *E) -{ - X_window *W; - Window k; - - k = ((XAnyEvent *) E)->window; -// if (XFilterEvent (E, k)) return; - if (_object && _window == k) - { - _object->handle_event (E); - } - else - { - W = find (k); - if (W && W != this) - { - W->handle_event (E); - _window = k; - _object = W; - } - } - XFlush (_disp->_dpy); -} - -