diff options
Diffstat (limited to 'libwinnie/src/sdl')
-rw-r--r-- | libwinnie/src/sdl/event.cc | 6 | ||||
-rw-r--r-- | libwinnie/src/sdl/event.h | 47 | ||||
-rw-r--r-- | libwinnie/src/sdl/gfx.cc | 2 | ||||
-rw-r--r-- | libwinnie/src/sdl/gfx.h | 63 | ||||
-rw-r--r-- | libwinnie/src/sdl/keyboard.cc | 2 | ||||
-rw-r--r-- | libwinnie/src/sdl/keyboard.h | 34 | ||||
-rw-r--r-- | libwinnie/src/sdl/mouse.cc | 2 | ||||
-rw-r--r-- | libwinnie/src/sdl/mouse.h | 42 |
8 files changed, 192 insertions, 6 deletions
diff --git a/libwinnie/src/sdl/event.cc b/libwinnie/src/sdl/event.cc index 889e153..5835704 100644 --- a/libwinnie/src/sdl/event.cc +++ b/libwinnie/src/sdl/event.cc @@ -23,9 +23,9 @@ Author: Eleni Maria Stea <elene.mst@gmail.com> #include <stdlib.h> #include <SDL/SDL.h> -#include "event.h" -#include "keyboard.h" -#include "mouse.h" +#include "sdl/event.h" +#include "sdl/keyboard.h" +#include "sdl/mouse.h" #include "wm.h" enum { diff --git a/libwinnie/src/sdl/event.h b/libwinnie/src/sdl/event.h new file mode 100644 index 0000000..5c1db45 --- /dev/null +++ b/libwinnie/src/sdl/event.h @@ -0,0 +1,47 @@ +/* +winnie - an experimental window system + +Copyright (C) 2013 Eleni Maria Stea + +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 3 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 <http://www.gnu.org/licenses/>. + +Author: Eleni Maria Stea <elene.mst@gmail.com> +*/ + +#ifndef EVENT_H_ +#define EVENT_H_ + +class Window; + +typedef void (*DisplayFuncType)(Window *win); +typedef void (*KeyboardFuncType)(Window *win, int key, bool pressed); +typedef void (*MouseButtonFuncType)(Window *win, int bn, bool pressed, int x, int y); +typedef void (*MouseMotionFuncType)(Window *win, int x, int y); +typedef void (*TimerFuncType)(Window *win); + +struct Callbacks { + DisplayFuncType display; + KeyboardFuncType keyboard; + MouseButtonFuncType button; + MouseMotionFuncType motion; + TimerFuncType timer; +}; + +void process_events(); + +enum TimerMode {TIMER_ONESHOT, TIMER_REPEAT}; + +void set_window_timer(Window *win, unsigned int msec, TimerMode mode = TIMER_ONESHOT); + +#endif diff --git a/libwinnie/src/sdl/gfx.cc b/libwinnie/src/sdl/gfx.cc index 9f31a4e..5671764 100644 --- a/libwinnie/src/sdl/gfx.cc +++ b/libwinnie/src/sdl/gfx.cc @@ -24,7 +24,7 @@ Author: Eleni Maria Stea <elene.mst@gmail.com> #include <stdlib.h> #include <SDL/SDL.h> -#include "gfx.h" +#include "sdl/gfx.h" #include "shalloc.h" #include "winnie.h" diff --git a/libwinnie/src/sdl/gfx.h b/libwinnie/src/sdl/gfx.h new file mode 100644 index 0000000..cb1c7ef --- /dev/null +++ b/libwinnie/src/sdl/gfx.h @@ -0,0 +1,63 @@ +/* +winnie - an experimental window system + +Copyright (C) 2013 Eleni Maria Stea + +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 3 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 <http://www.gnu.org/licenses/>. + +Author: Eleni Maria Stea <elene.mst@gmail.com> +*/ + +#ifndef GFX_H_ +#define GFX_H_ + +#include "geom.h" +#include "pixmap.h" + +bool init_gfx(); +void destroy_gfx(); + +bool client_open_gfx(void *smem_start, int offset); +void client_close_gfx(); + +unsigned char *get_framebuffer(); +Pixmap *get_framebuffer_pixmap(); + +Rect get_screen_size(); +int get_color_depth(); + +void set_clipping_rect(const Rect &clip_rect); +const Rect &get_clipping_rect(); + +void clear_screen(int r, int g, int b); +void fill_rect(const Rect &rect, int r, int g, int b); + +void set_cursor_visibility(bool visible); + +void blit(unsigned char *src_img, const Rect &src_rect, unsigned char* dest_img, + const Rect &dest_rect, int dest_x, int dest_y); + +void blit_key(unsigned char *src_img, const Rect &src_rect, unsigned char* dest_img, + const Rect &dest_rect, int dest_x, int dest_y, int key_r, int key_g, int key_b); + +void draw_line(Pixmap *pixmap, int x0, int y0, int x1, int y1, int r, int g, int b); +void draw_polygon(Pixmap *pixmap, int *vpos, int *vtex, int num_verts, int r, int g, int b); + +void gfx_update(const Rect &rect); + +void wait_vsync(); // vertical synchronization + +void get_rgb_order(int *r, int *g, int *b); + +#endif //GFX_H_ diff --git a/libwinnie/src/sdl/keyboard.cc b/libwinnie/src/sdl/keyboard.cc index 042bbbb..b9241f4 100644 --- a/libwinnie/src/sdl/keyboard.cc +++ b/libwinnie/src/sdl/keyboard.cc @@ -22,7 +22,7 @@ Author: Eleni Maria Stea <elene.mst@gmail.com> #ifdef WINNIE_SDL #include <SDL/SDL.h> -#include "keyboard.h" +#include "sdl/keyboard.h" #include "window.h" #include "wm.h" diff --git a/libwinnie/src/sdl/keyboard.h b/libwinnie/src/sdl/keyboard.h new file mode 100644 index 0000000..4d55cba --- /dev/null +++ b/libwinnie/src/sdl/keyboard.h @@ -0,0 +1,34 @@ +/* +winnie - an experimental window system + +Copyright (C) 2013 Eleni Maria Stea + +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 3 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 <http://www.gnu.org/licenses/>. + +Author: Eleni Maria Stea <elene.mst@gmail.com> +*/ + +#ifndef KEYBOARD_H_ +#define KEYBOARD_H_ + +bool init_keyboard(); +void destroy_keyboard(); + +bool client_open_keyboard(void *smem_start, int offset); +void client_close_keyboard(); + +int get_keyboard_fd(); +void process_keyboard_event(); + +#endif // KEYBOARD_H_ diff --git a/libwinnie/src/sdl/mouse.cc b/libwinnie/src/sdl/mouse.cc index 9196a93..80f33fb 100644 --- a/libwinnie/src/sdl/mouse.cc +++ b/libwinnie/src/sdl/mouse.cc @@ -22,7 +22,7 @@ Author: Eleni Maria Stea <elene.mst@gmail.com> #ifdef WINNIE_SDL #include <SDL/SDL.h> -#include "mouse.h" +#include "sdl/mouse.h" #include "shalloc.h" #include "wm.h" #include "window.h" diff --git a/libwinnie/src/sdl/mouse.h b/libwinnie/src/sdl/mouse.h new file mode 100644 index 0000000..9e55496 --- /dev/null +++ b/libwinnie/src/sdl/mouse.h @@ -0,0 +1,42 @@ +/* +winnie - an experimental window system + +Copyright (C) 2013 Eleni Maria Stea + +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 3 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 <http://www.gnu.org/licenses/>. + +Author: Eleni Maria Stea <elene.mst@gmail.com> +*/ + +#ifndef MOUSE_H_ +#define MOUSE_H_ + +struct Rect; + +bool init_mouse(); +void destroy_mouse(); + +bool client_open_mouse(void *smem_start, int offset); +void client_close_mouse(); + +void set_mouse_bounds(const Rect &rect); + +int get_mouse_fd(); +void process_mouse_event(); + +void get_pointer_pos(int *x, int *y); +int get_button_state(); +int get_button(int bn); + +#endif // MOUSE_H_ |