From 821cea8627597a5458c1cb02c0652384bb3431a4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 16 Aug 2011 15:50:01 +0300 Subject: [PATCH] Style update: spaces around assignments --- source/gbase/display.cpp | 62 +++++++------- source/gbase/display.h | 2 +- source/gbase/drawcontext.cpp | 24 +++--- source/gbase/glcontext.cpp | 38 ++++----- source/gbase/glcontext.h | 2 +- source/gbase/image.cpp | 46 +++++----- source/gbase/window.cpp | 152 ++++++++++++++++----------------- source/gbase/window.h | 2 +- source/input/binarycontrol.cpp | 6 +- source/input/control.cpp | 28 +++--- source/input/control.h | 6 +- source/input/device.cpp | 6 +- source/input/hub.cpp | 12 +-- source/input/keyboard.cpp | 6 +- source/input/keys.cpp | 10 +-- source/input/mouse.cpp | 2 +- source/input/smoothcontrol.cpp | 20 ++--- 17 files changed, 212 insertions(+), 212 deletions(-) diff --git a/source/gbase/display.cpp b/source/gbase/display.cpp index d004b05..10e86fa 100644 --- a/source/gbase/display.cpp +++ b/source/gbase/display.cpp @@ -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(event->request_code)); + string request_code = Msp::lexical_cast(static_cast(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: "<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; idisplay, 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; idisplay, 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::iterator j=priv->windows.find(event.xevent.xany.window); + map::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); } } diff --git a/source/gbase/display.h b/source/gbase/display.h index 1648fa4..c058e41 100644 --- a/source/gbase/display.h +++ b/source/gbase/display.h @@ -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; } diff --git a/source/gbase/drawcontext.cpp b/source/gbase/drawcontext.cpp index 46807aa..0f8d44b 100644 --- a/source/gbase/drawcontext.cpp +++ b/source/gbase/drawcontext.cpp @@ -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(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(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); diff --git a/source/gbase/glcontext.cpp b/source/gbase/glcontext.cpp index 40175fd..22dca90 100644 --- a/source/gbase/glcontext.cpp +++ b/source/gbase/glcontext.cpp @@ -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 diff --git a/source/gbase/glcontext.h b/source/gbase/glcontext.h index 02b383a..a719b85 100644 --- a/source/gbase/glcontext.h +++ b/source/gbase/glcontext.h @@ -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(); diff --git a/source/gbase/image.cpp b/source/gbase/image.cpp index 4fc7422..24b760e 100644 --- a/source/gbase/image.cpp +++ b/source/gbase/image.cpp @@ -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(png_get_io_ptr(png)); + IO::Base *in = reinterpret_cast(png_get_io_ptr(png)); in->read(reinterpret_cast(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.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) diff --git a/source/gbase/window.cpp b/source/gbase/window.cpp index 0b59a11..fbcbd51 100644 --- a/source/gbase/window.cpp +++ b/source/gbase/window.cpp @@ -23,16 +23,16 @@ LRESULT CALLBACK wndproc_(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if(msg==WM_CREATE) { - CREATESTRUCT *cs=reinterpret_cast(lparam); + CREATESTRUCT *cs = reinterpret_cast(lparam); SetWindowLong(hwnd, 0, reinterpret_cast(cs->lpCreateParams)); } else { - Msp::Graphics::Window *wnd=reinterpret_cast(GetWindowLong(hwnd, 0)); + Msp::Graphics::Window *wnd = reinterpret_cast(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(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(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 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(&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(options.width) && ev.xconfigure.height==static_cast(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 diff --git a/source/gbase/window.h b/source/gbase/window.h index a7e7df4..a390b8c 100644 --- a/source/gbase/window.h +++ b/source/gbase/window.h @@ -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(); diff --git a/source/input/binarycontrol.cpp b/source/input/binarycontrol.cpp index 70a8165..57c6342 100644 --- a/source/input/binarycontrol.cpp +++ b/source/input/binarycontrol.cpp @@ -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(); } } diff --git a/source/input/control.cpp b/source/input/control.cpp index 6ff8088..565d5c3 100644 --- a/source/input/control.cpp +++ b/source/input/control.cpp @@ -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(); } diff --git a/source/input/control.h b/source/input/control.h index 7d137bb..a2f002c 100644 --- a/source/input/control.h +++ b/source/input/control.h @@ -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(); diff --git a/source/input/device.cpp b/source/input/device.cpp index 8bca476..1fdb170 100644 --- a/source/input/device.cpp +++ b/source/input/device.cpp @@ -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); diff --git a/source/input/hub.cpp b/source/input/hub.cpp index 1be5d13..6a78882 100644 --- a/source/input/hub.cpp +++ b/source/input/hub.cpp @@ -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); } diff --git a/source/input/keyboard.cpp b/source/input/keyboard.cpp index 324ec80..fff0678 100644 --- a/source/input/keyboard.cpp +++ b/source/input/keyboard.cpp @@ -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; diff --git a/source/input/keys.cpp b/source/input/keys.cpp index 37a376a..082e022 100644 --- a/source/input/keys.cpp +++ b/source/input/keys.cpp @@ -113,19 +113,19 @@ namespace Input { unsigned key_from_sys(unsigned code) { - static bool init_done=false; + static bool init_done = false; static map reverse_map; if(!init_done) { for(unsigned i=0; i::const_iterator i=reverse_map.find(code); + map::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; ipair(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); -- 2.45.2