]> git.tdb.fi Git - libs/gui.git/commitdiff
Style update: spaces around assignments
authorMikko Rasa <tdb@tdb.fi>
Tue, 16 Aug 2011 12:50:01 +0000 (15:50 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 25 Aug 2011 09:18:44 +0000 (12:18 +0300)
17 files changed:
source/gbase/display.cpp
source/gbase/display.h
source/gbase/drawcontext.cpp
source/gbase/glcontext.cpp
source/gbase/glcontext.h
source/gbase/image.cpp
source/gbase/window.cpp
source/gbase/window.h
source/input/binarycontrol.cpp
source/input/control.cpp
source/input/control.h
source/input/device.cpp
source/input/hub.cpp
source/input/keyboard.cpp
source/input/keys.cpp
source/input/mouse.cpp
source/input/smoothcontrol.cpp

index d004b05be1f3768f345f5cf9bec7941515bcf9b9..10e86fa064503c20a888216dee32aa0cf88bb08a 100644 (file)
@@ -16,7 +16,7 @@ using namespace std;
 
 namespace {
 
-bool error_flag=false;
+bool error_flag = false;
 std::string error_msg;
 
 #ifndef WIN32
@@ -25,18 +25,18 @@ int x_error_handler(Display *display, XErrorEvent *event)
        char err[128];
        XGetErrorText(display, event->error_code, err, sizeof(err));
 
-       string request_code=Msp::lexical_cast(static_cast<int>(event->request_code));
+       string request_code = Msp::lexical_cast(static_cast<int>(event->request_code));
        char req[128];
        XGetErrorDatabaseText(display, "XRequest", request_code.c_str(), request_code.c_str(), req, sizeof(req));
 
-       string msg=Msp::format("Request %s failed with %s [%08X]", req, err, event->resourceid);
+       string msg = Msp::format("Request %s failed with %s [%08X]", req, err, event->resourceid);
        if(error_flag)
                cerr<<"Discarding error: "<<msg<<'\n';
        else
        {
                cerr<<msg<<'\n';
-               error_msg=msg;
-               error_flag=true;
+               error_msg = msg;
+               error_flag = true;
        }
 
        return 0;
@@ -61,39 +61,39 @@ Display::Display(const string &disp_name):
                        break;
 
                VideoMode mode(info.dmPelsWidth, info.dmPelsHeight);
-               mode.rate=info.dmDisplayFrequency;
+               mode.rate = info.dmDisplayFrequency;
                modes.push_back(mode);
        }
        
        DEVMODE info;
        if(EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &info))
        {
-               orig_mode=VideoMode(info.dmPelsWidth, info.dmPelsHeight);
-               orig_mode.rate=info.dmDisplayFrequency;
+               orig_mode = VideoMode(info.dmPelsWidth, info.dmPelsHeight);
+               orig_mode.rate = info.dmDisplayFrequency;
        }
 #else
        if(disp_name.empty())
-               priv->display=XOpenDisplay(0);
+               priv->display = XOpenDisplay(0);
        else
-               priv->display=XOpenDisplay(disp_name.c_str());
+               priv->display = XOpenDisplay(disp_name.c_str());
        if(!priv->display)
                throw Exception("Couldn't open X display");
 
        XSetErrorHandler(x_error_handler);
 
 #ifdef WITH_XF86VIDMODE
-       int screen=DefaultScreen(priv->display);
+       int screen = DefaultScreen(priv->display);
 
        int nmodes;
        XF86VidModeModeInfo **infos;
        XF86VidModeGetAllModeLines(priv->display, screen, &nmodes, &infos);
        for(int i=0; i<nmodes; ++i)
        {
-               XF86VidModeModeInfo &info=*infos[i];
+               XF86VidModeModeInfo &info = *infos[i];
        
                VideoMode mode(info.hdisplay, info.vdisplay);
                if(info.htotal && info.vtotal)
-                       mode.rate=info.dotclock/(info.htotal*info.vtotal);
+                       mode.rate = info.dotclock/(info.htotal*info.vtotal);
                modes.push_back(mode);
        }
 
@@ -102,9 +102,9 @@ Display::Display(const string &disp_name):
        XF86VidModeModeLine modeline;
        int dotclock;
        XF86VidModeGetModeLine(priv->display, screen, &dotclock, &modeline);
-       orig_mode=VideoMode(modeline.hdisplay, modeline.vdisplay);
+       orig_mode = VideoMode(modeline.hdisplay, modeline.vdisplay);
        if(modeline.htotal && modeline.vtotal)
-               orig_mode.rate=dotclock/(modeline.htotal*modeline.vtotal);
+               orig_mode.rate = dotclock/(modeline.htotal*modeline.vtotal);
 #endif
 #endif
 }
@@ -119,7 +119,7 @@ Display::~Display()
 
 void Display::add_window(Window &wnd)
 {
-       priv->windows[wnd.get_private().window]=&wnd;
+       priv->windows[wnd.get_private().window] = &wnd;
 }
 
 void Display::remove_window(Window &wnd)
@@ -131,30 +131,30 @@ void Display::set_mode(const VideoMode &mode)
 {
 #if defined(WIN32)
        DEVMODE info;
-       info.dmSize=sizeof(DEVMODE);
-       info.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT;
-       info.dmPelsWidth=mode.width;
-       info.dmPelsHeight=mode.height;
+       info.dmSize = sizeof(DEVMODE);
+       info.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT;
+       info.dmPelsWidth = mode.width;
+       info.dmPelsHeight = mode.height;
        if(mode.rate)
        {
-               info.dmFields|=DM_DISPLAYFREQUENCY;
-               info.dmDisplayFrequency=mode.rate;
+               info.dmFields |= DM_DISPLAYFREQUENCY;
+               info.dmDisplayFrequency = mode.rate;
        }
 
        ChangeDisplaySettings(&info, CDS_FULLSCREEN);
 #elif defined(WITH_XF86VIDMODE)
-       int screen=DefaultScreen(priv->display);
+       int screen = DefaultScreen(priv->display);
 
        int nmodes;
        XF86VidModeModeInfo **infos;
        XF86VidModeGetAllModeLines(priv->display, screen, &nmodes, &infos);
        for(int i=0; i<nmodes; ++i)
        {
-               XF86VidModeModeInfo &info=*infos[i];
+               XF86VidModeModeInfo &info = *infos[i];
 
-               unsigned rate=0;
+               unsigned rate = 0;
                if(info.htotal && info.vtotal)
-                       rate=info.dotclock/(info.htotal*info.vtotal);
+                       rate = info.dotclock/(info.htotal*info.vtotal);
                if(info.hdisplay==mode.width && info.vdisplay==mode.height && (mode.rate==0 || rate==mode.rate))
                {
                        XF86VidModeSwitchToMode(priv->display, screen, &info);
@@ -183,7 +183,7 @@ void Display::tick()
                else
                        break;
 #else
-               int pending=XPending(priv->display);
+               int pending = XPending(priv->display);
                if(pending==0)
                        break;
 
@@ -194,7 +194,7 @@ void Display::tick()
 
                        check_error();
 
-                       map<WindowHandle, Window *>::iterator j=priv->windows.find(event.xevent.xany.window);
+                       map<WindowHandle, Window *>::iterator j = priv->windows.find(event.xevent.xany.window);
                        if(j!=priv->windows.end())
                        {
                                /* Filter keyboard autorepeat.  If this packet is a KeyRelease and
@@ -202,12 +202,12 @@ void Display::tick()
                                indicate autorepeat and must be dropped. */
                                if(event.xevent.type==KeyRelease && !j->second->get_keyboard_autorepeat() && pending>0)
                                {
-                                       XKeyEvent &kev=event.xevent.xkey;
+                                       XKeyEvent &kev = event.xevent.xkey;
                                        XEvent ev2;
                                        XPeekEvent(priv->display, &ev2);
                                        if(ev2.type==KeyPress)
                                        {
-                                               XKeyEvent &kev2=ev2.xkey;
+                                               XKeyEvent &kev2 = ev2.xkey;
                                                if(kev2.window==kev.window && kev2.time==kev.time && kev2.keycode==kev.keycode)
                                                {
                                                        XNextEvent(priv->display, &ev2);
@@ -228,7 +228,7 @@ void Display::check_error()
 {
        if(error_flag)
        {
-               error_flag=false;
+               error_flag = false;
                throw Exception(error_msg);
        }
 }
index 1648fa4c8a9ab0bb25cbe7b4118cf2a06455fd19..c058e4118c80faec75c9dd0046a4add0d576ca82 100644 (file)
@@ -31,7 +31,7 @@ private:
        Private *priv;
 
 public:
-       Display(const std::string &disp_name=std::string());
+       Display(const std::string &disp_name = std::string());
        ~Display();
 
        const Private &get_private() const { return *priv; }
index 46807aa78b09d029431e78eb88a051a045976776..0f8d44b25539196f69f428ac8497c6fce9a57eb6 100644 (file)
@@ -30,24 +30,24 @@ DrawContext::DrawContext(Window &w):
 #ifdef WIN32
        throw Exception("DrawContext not supported on win32 yet");
 #else
-       priv=new Private;
+       priv = new Private;
 
-       ::Display *dpy=display.get_private().display;
+       ::Display *dpy = display.get_private().display;
 
-       priv->use_shm=XShmQueryExtension(dpy);
+       priv->use_shm = XShmQueryExtension(dpy);
 
        XWindowAttributes wa;
        XGetWindowAttributes(dpy, window.get_private().window, &wa);
 
        if(priv->use_shm)
        {
-               priv->image=XShmCreateImage(dpy, wa.visual, wa.depth, ZPixmap, 0, &priv->shminfo, wa.width, wa.height);
+               priv->image = XShmCreateImage(dpy, wa.visual, wa.depth, ZPixmap, 0, &priv->shminfo, wa.width, wa.height);
                if(!priv->image)
                        throw Exception("Could not create shared memory XImage");
 
-               priv->shminfo.shmid=shmget(IPC_PRIVATE, priv->image->bytes_per_line*priv->image->height, IPC_CREAT|0666);
-               priv->shminfo.shmaddr=priv->image->data=reinterpret_cast<char *>(shmat(priv->shminfo.shmid, 0, 0));
-               priv->shminfo.readOnly=false;
+               priv->shminfo.shmid = shmget(IPC_PRIVATE, priv->image->bytes_per_line*priv->image->height, IPC_CREAT|0666);
+               priv->shminfo.shmaddr=priv->image->data = reinterpret_cast<char *>(shmat(priv->shminfo.shmid, 0, 0));
+               priv->shminfo.readOnly = false;
 
                XShmAttach(dpy, &priv->shminfo);
 
@@ -56,10 +56,10 @@ DrawContext::DrawContext(Window &w):
        }
        else
        {
-               priv->image=XCreateImage(dpy, wa.visual, wa.depth, ZPixmap, 0, 0, wa.width, wa.height, 8, 0);
+               priv->image = XCreateImage(dpy, wa.visual, wa.depth, ZPixmap, 0, 0, wa.width, wa.height, 8, 0);
                if(!priv->image)
                        throw Exception("Could not create XImage");
-               priv->image->data=new char[priv->image->bytes_per_line*priv->image->height];
+               priv->image->data = new char[priv->image->bytes_per_line*priv->image->height];
        }
 #endif
 }
@@ -101,10 +101,10 @@ unsigned char *DrawContext::get_data()
 void DrawContext::update()
 {
 #ifndef WIN32
-       ::Display *dpy=display.get_private().display;
-       WindowHandle wnd=window.get_private().window;
+       ::Display *dpy = display.get_private().display;
+       WindowHandle wnd = window.get_private().window;
 
-       GC gc=XCreateGC(dpy, wnd, 0, 0);
+       GC gc = XCreateGC(dpy, wnd, 0, 0);
 
        if(priv->use_shm)
                XShmPutImage(dpy, wnd, gc, priv->image, 0, 0, 0, 0, priv->image->width, priv->image->height, false);
index 40175fd7ddecfb09439fb1351598789fe636995c..22dca9010462d922ad800f19447609e5a1735024 100644 (file)
@@ -49,32 +49,32 @@ GLContext::GLContext(Window &wnd, const GLOptions &opts):
        window(wnd)
 {
 #ifdef WITH_OPENGL
-       priv=new Private;
+       priv = new Private;
 
 #ifdef WIN32
-       HDC dc=GetDC(window.get_private().window);
+       HDC dc = GetDC(window.get_private().window);
 
        PIXELFORMATDESCRIPTOR pfd;
        memset(&pfd, 0, sizeof(pfd));
 
-       pfd.nSize=sizeof(pfd);
-       pfd.nVersion=1;
-       pfd.dwFlags=PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
+       pfd.nSize = sizeof(pfd);
+       pfd.nVersion = 1;
+       pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
        if(opts.doublebuffer)
-               pfd.dwFlags|=PFD_DOUBLEBUFFER;
-       pfd.iPixelType=PFD_TYPE_RGBA;
+               pfd.dwFlags |= PFD_DOUBLEBUFFER;
+       pfd.iPixelType = PFD_TYPE_RGBA;
        if(opts.alpha)
-               pfd.cAlphaBits=1;
-       pfd.cDepthBits=1;
+               pfd.cAlphaBits = 1;
+       pfd.cDepthBits = 1;
        if(opts.stencil)
-               pfd.cStencilBits=1;
+               pfd.cStencilBits = 1;
 
-       int pf_index=ChoosePixelFormat(dc, &pfd);
+       int pf_index = ChoosePixelFormat(dc, &pfd);
        if(!pf_index)
                throw Exception("Couldn't find a suitable pixel format");
        SetPixelFormat(dc, pf_index, &pfd);
 
-       priv->context=wglCreateContext(dc);
+       priv->context = wglCreateContext(dc);
        wglMakeCurrent(dc, priv->context);
 
        ReleaseDC(window.get_private().window, dc);
@@ -108,17 +108,17 @@ GLContext::GLContext(Window &wnd, const GLOptions &opts):
        
        attribs.push_back(0);
 
-       ::Display *dpy=display.get_private().display;
+       ::Display *dpy = display.get_private().display;
 
-       XVisualInfo *vi=glXChooseVisual(dpy, DefaultScreen(dpy), &attribs.front());
+       XVisualInfo *vi = glXChooseVisual(dpy, DefaultScreen(dpy), &attribs.front());
        if(!vi)
                throw Exception("Couldn't find a suitable GLX visual");
-       priv->context=glXCreateContext(dpy, vi, 0, true);
+       priv->context = glXCreateContext(dpy, vi, 0, true);
 
        XSetWindowAttributes attr;
-       attr.colormap=XCreateColormap(dpy, DefaultRootWindow(dpy), vi->visual, AllocNone);
+       attr.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), vi->visual, AllocNone);
 
-       priv->subwnd=XCreateWindow(dpy, window.get_private().window, 0, 0, window.get_width(), window.get_height(), 0, vi->depth, InputOutput, vi->visual, CWColormap, &attr);
+       priv->subwnd = XCreateWindow(dpy, window.get_private().window, 0, 0, window.get_width(), window.get_height(), 0, vi->depth, InputOutput, vi->visual, CWColormap, &attr);
        XMapWindow(dpy, priv->subwnd);
 
        XFree(vi);
@@ -141,7 +141,7 @@ GLContext::~GLContext()
        wglMakeCurrent(0, 0);
        wglDeleteContext(priv->context);
 #else
-       ::Display *dpy=display.get_private().display;
+       ::Display *dpy = display.get_private().display;
 
        glXMakeCurrent(dpy, 0, 0);
        glXDestroyContext(dpy, priv->context);
@@ -155,7 +155,7 @@ void GLContext::swap_buffers()
 {
 #ifdef WITH_OPENGL
 #ifdef WIN32
-       HDC dc=GetDC(window.get_private().window);
+       HDC dc = GetDC(window.get_private().window);
        SwapBuffers(dc);
        ReleaseDC(window.get_private().window, dc);
 #else
index 02b383abbfa63fcbde006060492337ad99c99e20..a719b85d82ee134174e444bd68e33a21797a75c9 100644 (file)
@@ -27,7 +27,7 @@ private:
        Private *priv;
 
 public:
-       GLContext(Window &wnd, const GLOptions &opts=GLOptions());
+       GLContext(Window &wnd, const GLOptions &opts = GLOptions());
        ~GLContext();
 
        void swap_buffers();
index 4fc74221057d16ba62af5e945d93e5ca9526667d..24b760e0aaedb33de123b495bcdb9ac52e79910b 100644 (file)
@@ -32,13 +32,13 @@ struct Image::Private
 Image::Private::Private()
 {
 #ifdef WITH_DEVIL
-       id=0;
+       id = 0;
 #endif
 #ifdef WITH_LIBPNG
-       fmt=RGB;
-       width=0;
-       height=0;
-       data=0;
+       fmt = RGB;
+       width = 0;
+       height = 0;
+       data = 0;
 #endif
 }
 
@@ -48,20 +48,20 @@ namespace {
 #ifdef WITH_LIBPNG
 void read(png_struct *png, png_byte *data, png_size_t size)
 {
-       IO::Base *in=reinterpret_cast<IO::Base *>(png_get_io_ptr(png));
+       IO::Base *in = reinterpret_cast<IO::Base *>(png_get_io_ptr(png));
        in->read(reinterpret_cast<char *>(data), size);
 }
 
 void load_png(IO::Base &in, Image::Private &priv)
 {
-       png_struct *png=0;
-       png_info *info=0;
-       priv.data=0;
+       png_struct *png = 0;
+       png_info *info = 0;
+       priv.data = 0;
 
        try
        {
-               png=png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
-               info=png_create_info_struct(png);
+               png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+               info = png_create_info_struct(png);
 
                if(setjmp(png_jmpbuf(png)))
                        throw Exception("Error loading PNG image");
@@ -73,26 +73,26 @@ void load_png(IO::Base &in, Image::Private &priv)
                int depth;
                int color;
                png_get_IHDR(png, info, &width, &height, &depth, &color, 0, 0, 0);
-               priv.width=width;
-               priv.height=height;
+               priv.width = width;
+               priv.height = height;
                if(depth!=8)
                        throw Exception("Only 8-bit PNG images are supported");
                switch(color)
                {
-               case PNG_COLOR_TYPE_PALETTE:    priv.fmt=COLOR_INDEX; break;
-               case PNG_COLOR_TYPE_GRAY:       priv.fmt=LUMINANCE; break;
-               case PNG_COLOR_TYPE_GRAY_ALPHA: priv.fmt=LUMINANCE_ALPHA; break;
-               case PNG_COLOR_TYPE_RGB:        priv.fmt=RGB; break;
-               case PNG_COLOR_TYPE_RGB_ALPHA:  priv.fmt=RGBA; break;
+               case PNG_COLOR_TYPE_PALETTE:    priv.fmt = COLOR_INDEX; break;
+               case PNG_COLOR_TYPE_GRAY:       priv.fmt = LUMINANCE; break;
+               case PNG_COLOR_TYPE_GRAY_ALPHA: priv.fmt = LUMINANCE_ALPHA; break;
+               case PNG_COLOR_TYPE_RGB:        priv.fmt = RGB; break;
+               case PNG_COLOR_TYPE_RGB_ALPHA:  priv.fmt = RGBA; break;
                default: throw Exception("Unknown color type");
                }
 
-               unsigned nchans=png_get_channels(png, info);
+               unsigned nchans = png_get_channels(png, info);
                if(nchans==4 && priv.fmt==RGB)
                        png_set_strip_alpha(png);
 
-               unsigned rowstride=priv.width*nchans;
-               priv.data=new char[rowstride*priv.height];
+               unsigned rowstride = priv.width*nchans;
+               priv.data = new char[rowstride*priv.height];
                for(unsigned y=0; y<priv.height; ++y)
                        png_read_row(png, reinterpret_cast<png_byte *>(priv.data+rowstride*(priv.height-1-y)), 0);
 
@@ -111,14 +111,14 @@ void load_png(IO::Base &in, Image::Private &priv)
 #ifdef WITH_DEVIL
 void ensure_devil_image(unsigned &id)
 {
-       static bool init_done=false;
+       static bool init_done = false;
 
        if(!init_done)
        {
                ilInit();
                ilEnable(IL_ORIGIN_SET);
                ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
-               init_done=true;
+               init_done = true;
        }
 
        if(!id)
index 0b59a110c964f9073382432b93004492ce1ec2c7..fbcbd519f99dbe01a49f70490b4f6de259d6c87b 100644 (file)
@@ -23,16 +23,16 @@ LRESULT CALLBACK wndproc_(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 {
        if(msg==WM_CREATE)
        {
-               CREATESTRUCT *cs=reinterpret_cast<CREATESTRUCT *>(lparam);
+               CREATESTRUCT *cs = reinterpret_cast<CREATESTRUCT *>(lparam);
                SetWindowLong(hwnd, 0, reinterpret_cast<LONG>(cs->lpCreateParams));
        }
        else
        {
-               Msp::Graphics::Window *wnd=reinterpret_cast<Msp::Graphics::Window *>(GetWindowLong(hwnd, 0));
+               Msp::Graphics::Window *wnd = reinterpret_cast<Msp::Graphics::Window *>(GetWindowLong(hwnd, 0));
                Msp::Graphics::Window::Event ev;
-               ev.msg=msg;
-               ev.wparam=wparam;
-               ev.lparam=lparam;
+               ev.msg = msg;
+               ev.wparam = wparam;
+               ev.lparam = lparam;
                if(wnd && wnd->event(ev))
                        return 0;
        }
@@ -62,9 +62,9 @@ WindowOptions::WindowOptions():
 Window::Window(Display &dpy, unsigned w, unsigned h, bool fs):
        display(dpy)
 {
-       options.width=w;
-       options.height=h;
-       options.fullscreen=fs;
+       options.width = w;
+       options.height = h;
+       options.fullscreen = fs;
 
        init();
 }
@@ -78,47 +78,47 @@ Window::Window(Display &dpy, const WindowOptions &opts):
 
 void Window::init()
 {
-       visible=false;
-       kbd_autorepeat=true;
-       resizing=false;
-       priv=new Private;
+       visible = false;
+       kbd_autorepeat = true;
+       resizing = false;
+       priv = new Private;
 
 #ifdef WIN32
-       static bool wndclass_created=false;
+       static bool wndclass_created = false;
 
        if(!wndclass_created)
        {
                WNDCLASSEX wndcl;
 
-               wndcl.cbSize=sizeof(WNDCLASSEX);
-               wndcl.style=0;
-               wndcl.lpfnWndProc=&wndproc_;
-               wndcl.cbClsExtra=0;
-               wndcl.cbWndExtra=sizeof(Window *);
-               wndcl.hInstance=reinterpret_cast<HINSTANCE>(Application::get_data());
-               wndcl.hIcon=0;
-               wndcl.hCursor=LoadCursor(0, IDC_ARROW);
-               wndcl.hbrBackground=0;
-               wndcl.lpszMenuName=0;
-               wndcl.lpszClassName="mspgbase";
-               wndcl.hIconSm=0;
+               wndcl.cbSize = sizeof(WNDCLASSEX);
+               wndcl.style = 0;
+               wndcl.lpfnWndProc = &wndproc_;
+               wndcl.cbClsExtra = 0;
+               wndcl.cbWndExtra = sizeof(Window *);
+               wndcl.hInstance = reinterpret_cast<HINSTANCE>(Application::get_data());
+               wndcl.hIcon = 0;
+               wndcl.hCursor = LoadCursor(0, IDC_ARROW);
+               wndcl.hbrBackground = 0;
+               wndcl.lpszMenuName = 0;
+               wndcl.lpszClassName = "mspgbase";
+               wndcl.hIconSm = 0;
 
                if(!RegisterClassEx(&wndcl))
                        throw Exception("Couldn't register window class");
 
-               wndclass_created=true;
+               wndclass_created = true;
        }
 
        RECT rect;
        SetRect(&rect, 0, 0, options.width, options.height);
 
-       int style=(options.fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW);
+       int style = (options.fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW);
        if(!options.resizable)
-               style&=~WS_THICKFRAME;
-       int exstyle=(options.fullscreen ? WS_EX_APPWINDOW : WS_EX_OVERLAPPEDWINDOW);
+               style &= ~WS_THICKFRAME;
+       int exstyle = (options.fullscreen ? WS_EX_APPWINDOW : WS_EX_OVERLAPPEDWINDOW);
        AdjustWindowRectEx(&rect, style, false, exstyle);
 
-       priv->window=CreateWindowEx(exstyle,
+       priv->window = CreateWindowEx(exstyle,
                "mspgbase",
                "Window",
                style,
@@ -132,16 +132,16 @@ void Window::init()
                throw Exception("CreateWindowEx failed");
 
 #else
-       ::Display *dpy=display.get_private().display;
+       ::Display *dpy = display.get_private().display;
 
-       priv->wm_delete_window=XInternAtom(dpy, "WM_DELETE_WINDOW", true);
-       priv->invisible_cursor=0;
+       priv->wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", true);
+       priv->invisible_cursor = 0;
 
        XSetWindowAttributes attr;
-       attr.override_redirect=options.fullscreen;
-       attr.event_mask=ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask;
+       attr.override_redirect = options.fullscreen;
+       attr.event_mask = ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask;
 
-       priv->window=XCreateWindow(dpy,
+       priv->window = XCreateWindow(dpy,
                DefaultRootWindow(dpy),
                0, 0,
                options.width, options.height,
@@ -156,9 +156,9 @@ void Window::init()
        if(!options.resizable)
        {
                XSizeHints hints;
-               hints.flags=PMinSize|PMaxSize;
-               hints.min_width=hints.max_width=options.width;
-               hints.min_height=hints.max_height=options.height;
+               hints.flags = PMinSize|PMaxSize;
+               hints.min_width=hints.max_width = options.width;
+               hints.min_height=hints.max_height = options.height;
                XSetWMNormalHints(dpy, priv->window, &hints);
        }
 
@@ -195,10 +195,10 @@ void Window::set_title(const string &title)
 #else
        vector<unsigned char> buf(title.begin(), title.end());
        XTextProperty prop;
-       prop.value=&buf[0];
-       prop.encoding=XA_STRING;
-       prop.format=8;
-       prop.nitems=title.size();
+       prop.value = &buf[0];
+       prop.encoding = XA_STRING;
+       prop.format = 8;
+       prop.nitems = title.size();
        XSetWMName(display.get_private().display, priv->window, &prop);
        display.check_error();
 #endif
@@ -206,19 +206,19 @@ void Window::set_title(const string &title)
 
 void Window::reconfigure(const WindowOptions &opts)
 {
-       bool fullscreen_changed=(opts.fullscreen!=options.fullscreen);
-       resizing=(opts.width!=options.width || opts.height!=options.height);
+       bool fullscreen_changed = (opts.fullscreen!=options.fullscreen);
+       resizing = (opts.width!=options.width || opts.height!=options.height);
 
-       options=opts;
+       options = opts;
 
 #ifdef WIN32
        RECT rect;
        SetRect(&rect, 0, 0, options.width, options.height);
 
-       int style=(options.fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW);
+       int style = (options.fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW);
        if(!options.resizable)
-               style&=~WS_THICKFRAME;
-       int exstyle=(options.fullscreen ? WS_EX_APPWINDOW : WS_EX_OVERLAPPEDWINDOW);
+               style &= ~WS_THICKFRAME;
+       int exstyle = (options.fullscreen ? WS_EX_APPWINDOW : WS_EX_OVERLAPPEDWINDOW);
        AdjustWindowRectEx(&rect, style, false, exstyle);
 
        if(fullscreen_changed)
@@ -234,9 +234,9 @@ void Window::reconfigure(const WindowOptions &opts)
        else
                SetWindowPos(priv->window, 0, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE|SWP_NOZORDER);
 #else
-       ::Display *dpy=display.get_private().display;
+       ::Display *dpy = display.get_private().display;
 
-       bool was_visible=visible;
+       bool was_visible = visible;
        if(fullscreen_changed)
        {
                if(was_visible)
@@ -245,23 +245,23 @@ void Window::reconfigure(const WindowOptions &opts)
 
                        // Wait for the window to be unmapped.  This makes window managers happy.
                        XEvent ev;
-                       int ev_type=UnmapNotify;
+                       int ev_type = UnmapNotify;
                        XPeekIfEvent(dpy, &ev, match_event_type, reinterpret_cast<char *>(&ev_type));
                }
 
                XSetWindowAttributes attr;
-               attr.override_redirect=options.fullscreen;
+               attr.override_redirect = options.fullscreen;
                XChangeWindowAttributes(dpy, priv->window, CWOverrideRedirect, &attr);
        }
 
        XSizeHints hints;
        if(options.resizable)
-               hints.flags=0;
+               hints.flags = 0;
        else
        {
-               hints.flags=PMinSize|PMaxSize;
-               hints.min_width=hints.max_width=options.width;
-               hints.min_height=hints.max_height=options.height;
+               hints.flags = PMinSize|PMaxSize;
+               hints.min_width=hints.max_width = options.width;
+               hints.min_height=hints.max_height = options.height;
        }
        XSetWMNormalHints(dpy, priv->window, &hints);
 
@@ -288,7 +288,7 @@ void Window::reconfigure(const WindowOptions &opts)
 
 void Window::set_keyboard_autorepeat(bool r)
 {
-       kbd_autorepeat=r;
+       kbd_autorepeat = r;
 }
 
 void Window::show_cursor(bool s)
@@ -296,7 +296,7 @@ void Window::show_cursor(bool s)
 #ifdef WIN32
        ShowCursor(s);
 #else
-       ::Display *dpy=display.get_private().display;
+       ::Display *dpy = display.get_private().display;
 
        if(s)
                XUndefineCursor(dpy, priv->window);
@@ -304,19 +304,19 @@ void Window::show_cursor(bool s)
        {
                if(!priv->invisible_cursor)
                {
-                       int screen=DefaultScreen(dpy);
+                       int screen = DefaultScreen(dpy);
 
-                       Pixmap pm=XCreatePixmap(dpy, priv->window, 1, 1, 1);
-                       GC gc=XCreateGC(dpy, pm, 0, 0);
+                       Pixmap pm = XCreatePixmap(dpy, priv->window, 1, 1, 1);
+                       GC gc = XCreateGC(dpy, pm, 0, 0);
                        XSetFunction(dpy, gc, GXclear);
                        XDrawPoint(dpy, pm, gc, 0, 0);
                        XFreeGC(dpy, gc);
 
                        XColor black;
-                       black.pixel=BlackPixel(dpy, screen);
+                       black.pixel = BlackPixel(dpy, screen);
                        XQueryColor(dpy, DefaultColormap(dpy, screen), &black);
 
-                       priv->invisible_cursor=XCreatePixmapCursor(dpy, pm, pm, &black, &black, 0, 0);
+                       priv->invisible_cursor = XCreatePixmapCursor(dpy, pm, pm, &black, &black, 0, 0);
 
                        XFreePixmap(dpy, pm);
                }
@@ -342,7 +342,7 @@ void Window::show()
 #else
        XMapRaised(display.get_private().display, priv->window);
 #endif
-       visible=true;
+       visible = true;
 
        if(options.fullscreen)
        {
@@ -360,7 +360,7 @@ void Window::hide()
 #else
        XUnmapWindow(display.get_private().display, priv->window);
 #endif
-       visible=false;
+       visible = false;
 
        if(options.fullscreen)
                display.restore_mode();
@@ -369,8 +369,8 @@ void Window::hide()
 bool Window::event(const Event &evnt)
 {
 #ifdef WIN32
-       WPARAM wp=evnt.wparam;
-       LPARAM lp=evnt.lparam;
+       WPARAM wp = evnt.wparam;
+       LPARAM lp = evnt.lparam;
        switch(evnt.msg)
        {
        case WM_KEYDOWN:
@@ -408,8 +408,8 @@ bool Window::event(const Event &evnt)
                signal_pointer_motion.emit(GET_X_LPARAM(lp), GET_Y_LPARAM(lp));
                break;
        case WM_SIZE:
-               options.width=LOWORD(lp);
-               options.height=HIWORD(lp);
+               options.width = LOWORD(lp);
+               options.height = HIWORD(lp);
                signal_resize.emit(options.width, options.height);
                break;
        case WM_CLOSE:
@@ -419,7 +419,7 @@ bool Window::event(const Event &evnt)
                return false;
        }
 #else
-       const XEvent &ev=evnt.xevent;
+       const XEvent &ev = evnt.xevent;
        switch(ev.type)
        {
        case ButtonPress:
@@ -445,16 +445,16 @@ bool Window::event(const Event &evnt)
        case ConfigureNotify:
                if((ev.xconfigure.width==static_cast<int>(options.width) && ev.xconfigure.height==static_cast<int>(options.height)) == resizing)
                {
-                       options.width=ev.xconfigure.width;
-                       options.height=ev.xconfigure.height;
-                       resizing=false;
+                       options.width = ev.xconfigure.width;
+                       options.height = ev.xconfigure.height;
+                       resizing = false;
                        signal_resize.emit(options.width, options.height);
                }
 #ifdef WITH_XF86VIDMODE
                if(options.fullscreen)
                {
-                       ::Display *dpy=display.get_private().display;
-                       int screen=DefaultScreen(dpy);
+                       ::Display *dpy = display.get_private().display;
+                       int screen = DefaultScreen(dpy);
                        XF86VidModeSetViewPort(dpy, screen, ev.xconfigure.x, ev.xconfigure.y);
                }
 #endif
index a7e7df42fe4f10f3b04efd6a292144494fb15d45..a390b8cf4543da9d06ac7dfda37c9e1a9a3a3d4c 100644 (file)
@@ -37,7 +37,7 @@ protected:
        Private *priv;
 
 public:
-       Window(Display &, unsigned w, unsigned h, bool fs=false);
+       Window(Display &, unsigned w, unsigned h, bool fs = false);
        Window(Display &, const WindowOptions &);
 private:
        void init();
index 70a816570fb2d33bcc697ec52fe1fe770cd19147..57c63427839bda9ac6c1d41f5c234e100790d87d 100644 (file)
@@ -23,14 +23,14 @@ BinaryControl::BinaryControl(Device &d, ControlSrcType t, unsigned i):
 
 void BinaryControl::set_threshold(float t)
 {
-       threshold=t;
+       threshold = t;
 }
 
 void BinaryControl::on_press()
 {
        if(!state)
        {
-               state=true;
+               state = true;
                signal_press.emit();
        }
 }
@@ -39,7 +39,7 @@ void BinaryControl::on_release()
 {
        if(state)
        {
-               state=false;
+               state = false;
                signal_release.emit();
        }
 }
index 6ff80883f8d39d8df19892b9fd2cf114aac7cc4a..565d5c3242a35fc968e1efc60443f8f131c66b4a 100644 (file)
@@ -52,7 +52,7 @@ Control::Control(Device &d, ControlSrcType t, unsigned i):
 void Control::capture(Device &d)
 {
        notify_callbacks();
-       capture_dev=&d;
+       capture_dev = &d;
        capture_dev->signal_button_press.connect(sigc::mem_fun(this, &Control::button_press));
        capture_dev->signal_axis_motion.connect(sigc::mem_fun(this, &Control::axis_motion));
 }
@@ -60,7 +60,7 @@ void Control::capture(Device &d)
 void Control::cancel_capture()
 {
        notify_callbacks();
-       capture_dev=0;
+       capture_dev = 0;
        connect_signals();
 }
 
@@ -72,7 +72,7 @@ void Control::set_source(Device &d, ControlSrcType t, unsigned i)
 void Control::set_source(const ControlSource &s)
 {
        notify_callbacks();
-       src=s;
+       src = s;
        connect_signals();
 }
 
@@ -99,12 +99,12 @@ void Control::button_press(unsigned i)
 {
        if(capture_dev)
        {
-               src.dev=capture_dev;
-               src.type=BUTTON;
-               src.index=i;
+               src.dev = capture_dev;
+               src.type = BUTTON;
+               src.index = i;
 
                notify_callbacks();
-               capture_dev=0;
+               capture_dev = 0;
                connect_signals();
                signal_capture_complete.emit();
        }
@@ -122,20 +122,20 @@ void Control::axis_motion(unsigned i, float v, float r)
 {
        if(capture_dev)
        {
-               ControlSrcType type=NONE;
+               ControlSrcType type = NONE;
                if(v<-0.9)
-                       type=AXIS_NEG;
+                       type = AXIS_NEG;
                else if(v>0.9)
-                       type=AXIS_POS;
+                       type = AXIS_POS;
 
                if(type!=NONE)
                {
-                       src.dev=capture_dev;
-                       src.type=type;
-                       src.index=i;
+                       src.dev = capture_dev;
+                       src.type = type;
+                       src.index = i;
 
                        notify_callbacks();
-                       capture_dev=0;
+                       capture_dev = 0;
                        connect_signals();
                        signal_capture_complete.emit();
                }
index 7d137bbf7342e93d033f6dafab946f1064dc2248..a2f002c08557d57807bbaaaafb4171e9400c7923 100644 (file)
@@ -63,9 +63,9 @@ public:
        void set_source(const ControlSource &);
        const ControlSource &get_source() const { return src; }
 protected:
-       virtual void on_press() =0;
-       virtual void on_release() =0;
-       virtual void on_motion(float, float) =0;
+       virtual void on_press() = 0;
+       virtual void on_release() = 0;
+       virtual void on_motion(float, float) = 0;
 
 private:
        void connect_signals();
index 8bca47671d0079127af2be446089ed0498574c25..1fdb170db8d70c95534680844e9199f1474e0550 100644 (file)
@@ -37,7 +37,7 @@ void Device::set_button_state(unsigned btn, bool state, bool event)
 
        if(state!=buttons[btn])
        {
-               buttons[btn]=state;
+               buttons[btn] = state;
 
                if(event)
                {
@@ -56,8 +56,8 @@ void Device::set_axis_value(unsigned axis, float value, bool event)
 
        if(value!=axes[axis])
        {
-               float old=axes[axis];
-               axes[axis]=value;
+               float old = axes[axis];
+               axes[axis] = value;
 
                if(event)
                        signal_axis_motion.emit(axis, value, value-old);
index 1be5d1382dc34552157ed26c8877d7d31bb7b102..6a78882c06273f209830253202acc79c8aa96f84 100644 (file)
@@ -7,12 +7,12 @@ namespace Input {
 
 Hub::Hub()
 {
-       name="Hub";
+       name = "Hub";
 }
 
 unsigned Hub::attach(Device &dev)
 {
-       unsigned index=devices.size();
+       unsigned index = devices.size();
        devices.push_back(&dev);
        dev.signal_button_press.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_press), index));
        dev.signal_button_release.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_release), index));
@@ -22,21 +22,21 @@ unsigned Hub::attach(Device &dev)
 
 std::string Hub::get_button_name(unsigned btn) const
 {
-       unsigned dev_index=btn>>12;
+       unsigned dev_index = btn>>12;
        if(dev_index>=devices.size())
                throw InvalidParameterValue("Button does not exist");
 
-       const Device &dev=*devices[dev_index];
+       const Device &dev = *devices[dev_index];
        return dev.get_name()+": "+dev.get_button_name(btn&0xFFF);
 }
 
 std::string Hub::get_axis_name(unsigned axis) const
 {
-       unsigned dev_index=axis>>12;
+       unsigned dev_index = axis>>12;
        if(dev_index>=devices.size())
                throw InvalidParameterValue("Axis does not exist");
 
-       const Device &dev=*devices[dev_index];
+       const Device &dev = *devices[dev_index];
        return dev.get_name()+": "+dev.get_axis_name(axis&0xFFF);
 }
 
index 324ec802fca57ba581d5063a0832f81fbe660926..fff0678441786d7610a8a1e6c23dae1d85d441b8 100644 (file)
@@ -16,7 +16,7 @@ namespace Input {
 Keyboard::Keyboard(Graphics::EventSource &s):
        source(s)
 {
-       name="Keyboard";
+       name = "Keyboard";
 
        buttons.resize(N_KEYS_, false);
 
@@ -29,13 +29,13 @@ std::string Keyboard::get_button_name(unsigned btn) const
        if(btn==0)
                return "None";
 #ifndef WIN32
-       const char *str=XKeysymToString(key_to_sys(btn));
+       const char *str = XKeysymToString(key_to_sys(btn));
        if(!str)
                return format("Key %d", btn);
        return str;
 #else
        char buf[128];
-       unsigned scan=MapVirtualKey(key_to_sys(btn), MAPVK_VK_TO_VSC);
+       unsigned scan = MapVirtualKey(key_to_sys(btn), MAPVK_VK_TO_VSC);
        if(!GetKeyNameText(scan<<16, buf, sizeof(buf)))
                return format("Key %d", btn);
        return buf;
index 37a376aaa6c662eb391aaa4704148f5adcb8e8dd..082e02299b9c829f4458024147d8fe3d16b0f099 100644 (file)
@@ -113,19 +113,19 @@ namespace Input {
 
 unsigned key_from_sys(unsigned code)
 {
-       static bool init_done=false;
+       static bool init_done = false;
        static map<unsigned, unsigned> reverse_map;
 
        if(!init_done)
        {
                for(unsigned i=0; i<N_KEYS_; ++i)
                        if(keymap[i])
-                               reverse_map[keymap[i]]=i;
+                               reverse_map[keymap[i]] = i;
 
-               init_done=true;
+               init_done = true;
        }
 
-       map<unsigned, unsigned>::const_iterator i=reverse_map.find(code);
+       map<unsigned, unsigned>::const_iterator i = reverse_map.find(code);
        if(i!=reverse_map.end())
                return i->second;
 
@@ -144,7 +144,7 @@ unsigned mod_from_sys(unsigned mod)
        unsigned result = 0;
        for(unsigned i=0; i<N_MODS_; ++i)
                if(mod&modmap[i])
-                       result|=1<<i;
+                       result |= 1<<i;
        return result;
 }
 
index 6a3151adf812ba2a75631d87d6f884d0ad8f31a3..1c2bc8992521811d74b0cd8ba597592d09cbe254 100644 (file)
@@ -7,7 +7,7 @@ namespace Input {
 Mouse::Mouse(Graphics::EventSource &s):
        source(s)
 {
-       name="Mouse";
+       name = "Mouse";
 
        buttons.resize(3);
        axes.resize(2);
index eb308784b3175e86611186dd7622a94e3f5df099..f32e551d89c682e34e9de5157c83e400a6dd8938 100644 (file)
@@ -33,12 +33,12 @@ SmoothControl::~SmoothControl()
 
 void SmoothControl::set_dead_zone(float d)
 {
-       dead_zone=d;
+       dead_zone = d;
 }
 
 void SmoothControl::set_threshold(float t)
 {
-       threshold=t;
+       threshold = t;
 }
 
 void SmoothControl::pair(SmoothControl *ctrl)
@@ -48,12 +48,12 @@ void SmoothControl::pair(SmoothControl *ctrl)
 
        if(paired_ctrl)
        {
-               SmoothControl *old_pair=paired_ctrl;
-               paired_ctrl=0;
+               SmoothControl *old_pair = paired_ctrl;
+               paired_ctrl = 0;
                old_pair->pair(0);
        }
 
-       paired_ctrl=ctrl;
+       paired_ctrl = ctrl;
 
        if(paired_ctrl)
                paired_ctrl->pair(this);
@@ -73,15 +73,15 @@ void SmoothControl::on_release()
 void SmoothControl::on_motion(float v, float r)
 {
        if(v<-threshold)
-               value=-1;
+               value = -1;
        else if(v>threshold)
-               value=1;
+               value = 1;
        else if(v<-dead_zone)
-               value=(v+dead_zone)/(threshold-dead_zone);
+               value = (v+dead_zone)/(threshold-dead_zone);
        else if(v>dead_zone)
-               value=(v-dead_zone)/(threshold-dead_zone);
+               value = (v-dead_zone)/(threshold-dead_zone);
        else
-               value=0;
+               value = 0;
 
        signal_motion.emit(value);