comparison src/video/directfb/SDL_DirectFB_mouse.c @ 3023:d72a0dd80e8b

DirectFB cleanups & simple window manager - use SDL_getenv, not getenv ... - no more support for 0.9.25 - not even mentioned any longer on directfb.org - fix fullscreen issues - add a simple window manager unless the directfb team comes up with a working wm. The driver has support for a very, very basic window manager you may want to use when runnning with "wm=default". Use export SDL_DIRECTFB_WM=1 to enable basic window borders including icon support. In order to have the window title rendered, you need to have the following font installed: /usr/share/fonts/truetype/freefont/FreeSans.ttf
author Couriersud <couriersud@arcor.de>
date Sun, 11 Jan 2009 23:49:23 +0000
parents 8cc00819c8d6
children 64ce267332c6
comparison
equal deleted inserted replaced
3022:db20dde98dd3 3023:d72a0dd80e8b
24 #include "SDL_DirectFB_video.h" 24 #include "SDL_DirectFB_video.h"
25 25
26 #include "../SDL_sysvideo.h" 26 #include "../SDL_sysvideo.h"
27 #include "../../events/SDL_mouse_c.h" 27 #include "../../events/SDL_mouse_c.h"
28 28
29 static SDL_Cursor *DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, 29 static SDL_Cursor *DirectFB_CreateCursor(SDL_Surface * surface,
30 int hot_y); 30 int hot_x, int hot_y);
31 static int DirectFB_ShowCursor(SDL_Cursor * cursor); 31 static int DirectFB_ShowCursor(SDL_Cursor * cursor);
32 static void DirectFB_MoveCursor(SDL_Cursor * cursor); 32 static void DirectFB_MoveCursor(SDL_Cursor * cursor);
33 static void DirectFB_FreeCursor(SDL_Cursor * cursor); 33 static void DirectFB_FreeCursor(SDL_Cursor * cursor);
34 static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, 34 static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID,
35 int x, int y); 35 int x, int y);
36 static void DirectFB_FreeMouse(SDL_Mouse * mouse); 36 static void DirectFB_FreeMouse(SDL_Mouse * mouse);
37 37
38 static int id_mask; 38 static int id_mask;
39 39
40 static DFBEnumerationResult 40 static DFBEnumerationResult
41 EnumMice(DFBInputDeviceID device_id, 41 EnumMice(DFBInputDeviceID device_id, DFBInputDeviceDescription desc,
42 DFBInputDeviceDescription desc, void *callbackdata) 42 void *callbackdata)
43 { 43 {
44 DFB_DeviceData *devdata = callbackdata; 44 DFB_DeviceData *devdata = callbackdata;
45 45
46 if ((desc.type & DIDTF_MOUSE) && (device_id & id_mask)) { 46 if ((desc.type & DIDTF_MOUSE) && (device_id & id_mask)) {
47 SDL_Mouse mouse; 47 SDL_Mouse mouse;
130 dsc.caps = DSCAPS_VIDEOONLY; 130 dsc.caps = DSCAPS_VIDEOONLY;
131 dsc.width = surface->w; 131 dsc.width = surface->w;
132 dsc.height = surface->h; 132 dsc.height = surface->h;
133 dsc.pixelformat = DSPF_ARGB; 133 dsc.pixelformat = DSPF_ARGB;
134 134
135 SDL_DFB_CHECKERR(devdata->dfb-> 135 SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc,
136 CreateSurface(devdata->dfb, &dsc, &curdata->surf)); 136 &curdata->surf));
137 curdata->hotx = hot_x; 137 curdata->hotx = hot_x;
138 curdata->hoty = hot_y; 138 curdata->hoty = hot_y;
139 cursor->driverdata = curdata; 139 cursor->driverdata = curdata;
140 140
141 SDL_DFB_CHECKERR(curdata->surf-> 141 SDL_DFB_CHECKERR(curdata->surf->Lock(curdata->surf, DSLF_WRITE,
142 Lock(curdata->surf, DSLF_WRITE, (void *) &dest, &pitch)); 142 (void *) &dest, &pitch));
143 143
144 /* Relies on the fact that this is only called with ARGB surface. */ 144 /* Relies on the fact that this is only called with ARGB surface. */
145 p = surface->pixels; 145 p = surface->pixels;
146 for (i = 0; i < surface->h; i++) 146 for (i = 0; i < surface->h; i++)
147 memcpy((char *) dest + i * pitch, (char *) p + i * surface->pitch, 147 memcpy((char *) dest + i * pitch,
148 4 * surface->w); 148 (char *) p + i * surface->pitch, 4 * surface->w);
149 149
150 curdata->surf->Unlock(curdata->surf); 150 curdata->surf->Unlock(curdata->surf);
151 return cursor; 151 return cursor;
152 error: 152 error:
153 return NULL; 153 return NULL;
160 SDL_DFB_CURSORDATA(cursor); 160 SDL_DFB_CURSORDATA(cursor);
161 DFBResult ret; 161 DFBResult ret;
162 SDL_WindowID wid; 162 SDL_WindowID wid;
163 163
164 wid = SDL_GetFocusWindow(); 164 wid = SDL_GetFocusWindow();
165 if (wid < 0) 165 if (wid <= 0)
166 return -1; 166 return -1;
167 else { 167 else {
168 SDL_Window *window = SDL_GetWindowFromID(wid); 168 SDL_Window *window = SDL_GetWindowFromID(wid);
169 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 169 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
170 170
177 SDL_DFB_CHECKERR(windata->window-> 177 SDL_DFB_CHECKERR(windata->window->
178 SetCursorShape(windata->window, 178 SetCursorShape(windata->window,
179 curdata->surf, curdata->hotx, 179 curdata->surf, curdata->hotx,
180 curdata->hoty)); 180 curdata->hoty));
181 181
182 /* fprintf(stdout, "Cursor is %s\n", cursor ? "on" : "off"); */
183 SDL_DFB_CHECKERR(dispdata->layer-> 182 SDL_DFB_CHECKERR(dispdata->layer->
184 SetCooperativeLevel(dispdata->layer, 183 SetCooperativeLevel(dispdata->layer,
185 DLSCL_ADMINISTRATIVE)); 184 DLSCL_ADMINISTRATIVE));
186 SDL_DFB_CHECKERR(dispdata->layer-> 185 SDL_DFB_CHECKERR(dispdata->layer->
187 SetCursorOpacity(dispdata->layer, 186 SetCursorOpacity(dispdata->layer,
225 DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; 224 DFB_WindowData *windata = (DFB_WindowData *) window->driverdata;
226 DFBResult ret; 225 DFBResult ret;
227 int cx, cy; 226 int cx, cy;
228 227
229 SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy)); 228 SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy));
230 SDL_DFB_CHECKERR(dispdata->layer-> 229 SDL_DFB_CHECKERR(dispdata->layer->WarpCursor(dispdata->layer,
231 WarpCursor(dispdata->layer, cx + x, cy + y)); 230 cx + x + windata->client.x,
231 cy + y + windata->client.y));
232 232
233 error: 233 error:
234 return; 234 return;
235 } 235 }
236 236