/* Display a generic popup menu for the display background. */ void AG_WM_BackgroundPopupMenu(AG_DriverSw *dsw) { AG_Menu *me; AG_MenuItem *mi; AG_Window *win; int nWindows = 0; me = AG_MenuNew(NULL, 0); mi = me->itemSel = AG_MenuNode(me->root, NULL, NULL); AG_FOREACH_WINDOW_REVERSE(win, dsw) { if (strcmp(win->caption, "win-popup") == 0) { continue; } AG_MenuAction(mi, win->caption[0] != '\0' ? win->caption : _("Untitled"), agIconWinMaximize.s, UnminimizeWindow, "%p", win); nWindows++; } if (nWindows > 0) { AG_MenuSeparator(mi); } #ifdef AG_DEBUG AG_MenuAction(mi, _("GUI debugger"), agIconMagnifier.s, OpenGuiDebugger, NULL); #endif AG_MenuAction(mi, _("Exit application"), agIconWinClose.s, ExitApplication, NULL); AG_MenuExpand(NULL, mi, AGDRIVER(dsw)->mouse->x + 4, AGDRIVER(dsw)->mouse->y + 4); }
static void SDLGL_Close(void *obj) { AG_Driver *drv = obj; AG_DriverSDLGL *sgl = obj; #ifdef AG_DEBUG if (nDrivers != 1) { AG_FatalError("Driver close without open"); } #endif AG_FreeCursors(AGDRIVER(sgl)); if (AG_CfgBool("view.full-screen")) { SDL_WM_ToggleFullScreen(sgl->s); } if (initedSDLVideo) { SDL_QuitSubSystem(SDL_INIT_VIDEO); initedSDLVideo = 0; } AG_ObjectDetach(drv->mouse); AG_ObjectDestroy(drv->mouse); AG_ObjectDetach(drv->kbd); AG_ObjectDestroy(drv->kbd); drv->mouse = NULL; drv->kbd = NULL; if (sgl->outMode != AG_SDLGL_OUT_NONE) { Free(sgl->outBuf); sgl->outBuf = NULL; sgl->outMode = AG_SDLGL_OUT_NONE; } nDrivers = 0; }
void InitMouseSub(void) { AG_Driver *drv = NULL; nMouseOldX = 0; nMouseOldY = 0; nPhysicalX = 0; nPhysicalY = 0; bMouseCursor = TRUE; memset(pMouseCursor, 0x00, sizeof(pMouseCursor)); memset(pMouseCursor, 0x00, sizeof(pMouseMask)); #ifdef USE_OPENGL if(GLDrawArea != NULL) { drv = AGDRIVER(GLDrawArea); } else #endif if (DrawArea != NULL) { drv = AGDRIVER(DrawArea); } if(drv != NULL) { // pCursor = AG_CursorNew(drv, 8, 8, (Uint8 *)pMouseCursor, (Uint8 *)pMouseMask, 1, 1); } }
static void SDLGL_Close(void *obj) { AG_Driver *drv = obj; AG_DriverSw *dsw = obj; AG_DriverSDLGL *sgl = obj; AG_DelEventSpinner(sglEventSpinner); sglEventSpinner = NULL; AG_DelEventEpilogue(sglEventEpilogue); sglEventEpilogue = NULL; if (drv->gl != NULL) AG_GL_DestroyContext(sgl); #ifdef AG_DEBUG if (nDrivers != 1) { AG_FatalError("Driver close without open"); } #endif AG_FreeCursors(AGDRIVER(sgl)); if (dsw->flags & AG_DRIVER_SW_FULLSCREEN) { if (SDL_WM_ToggleFullScreen(sgl->s)) dsw->flags &= ~(AG_DRIVER_SW_FULLSCREEN); } if (initedSDLVideo) { SDL_QuitSubSystem(SDL_INIT_VIDEO); initedSDLVideo = 0; } AG_ObjectDelete(drv->mouse); drv->mouse = NULL; AG_ObjectDelete(drv->kbd); drv->kbd = NULL; if (sgl->outMode != AG_SDLGL_OUT_NONE) { Free(sgl->outBuf); sgl->outBuf = NULL; sgl->outMode = AG_SDLGL_OUT_NONE; } nDrivers = 0; }
/* Initialize the default cursor. */ int AG_SDL_InitDefaultCursor(void *obj) { AG_Driver *drv = AGDRIVER(obj); AG_Cursor *ac; SDL_Cursor *sc; if ((sc = SDL_GetCursor()) == NULL) { AG_SetError("SDL_GetCursor() returned NULL"); return (-1); } if ((drv->cursors = TryMalloc(sizeof(AG_Cursor))) == NULL) { return (-1); } ac = &drv->cursors[0]; drv->nCursors = 1; AG_CursorInit(ac); ac->w = (Uint)sc->area.w; ac->h = (Uint)sc->area.h; ac->xHot = (int)sc->hot_x; ac->yHot = (int)sc->hot_y; ac->p = sc; return (0); }
/* * マウス キャプチャ状態設定 */ void SetMouseCapture(BOOL en) { int x; int y; //SDL_SysWMinfo sdlinfo; /* * キャプチャ停止中/VM停止中/非アクティブ時は強制的に無効 */ if (!mos_capture || stopreq_flag || !run_flag || !bActivate) { en = FALSE; } /* * カーソル表示/消去 */ if (bMouseCursor == en) { if (!en) { #ifdef USE_OPENGL if(GLDrawArea != NULL) { AG_HideCursor(AGDRIVER(GLDrawArea)); } else #endif if (DrawArea != NULL) { AG_HideCursor(AGDRIVER(DrawArea)); } } else { #ifdef USE_OPENGL if(GLDrawArea != NULL) { AG_ShowCursor(AGDRIVER(GLDrawArea)); } else #endif if (DrawArea != NULL) { AG_ShowCursor(AGDRIVER(DrawArea)); } } bMouseCursor = !en; } /* * キャプチャ状態に変化がなければ帰る */ if (bMouseCaptureFlag == en) { return; } if (en) { /* * カーソル位置を保存 */ // gtk_widget_get_pointer(drawArea, &x, &y); GetMousePos(&x, &y); nMouseSX = x; nMouseSY = y; /* * 描画ウィンドウのサイズを求める */ // gdk_window_get_size(drawArea->window, &nDAreaW, &nDAreaH); /* * 中心座標を求める */ /* * カーソルをウィンドウ中央に固定 */ #ifdef USE_OPENGL if(GLDrawArea != NULL) { x = GLDrawArea->wid.w / 2; y = GLDrawArea->wid.h / 2; AG_ExecMouseAction (GLDrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(GLDrawArea))) SDL_WM_GrabInput(SDL_GRAB_ON); } else #endif if(DrawArea != NULL) { x = AGWIDGET(DrawArea)->w / 2; y = AGWIDGET(DrawArea)->h / 2; AG_ExecMouseAction (DrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(DrawArea))) SDL_WM_GrabInput(SDL_GRAB_ON); } } else { /* * クリップ解除 */ //gdk_pointer_ungrab(GDK_CURRENT_TIME); // if(SDL_GetWMInfo(&sdlinfo)) { // XUngrabPointer(sdlinfo.info.x11.display, CurrentTime); //} /* * カーソル位置を復元 */ #ifdef USE_OPENGL if(GLDrawArea != NULL) { x = nMouseSX; y = nMouseSY; AG_ExecMouseAction (GLDrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(GLDrawArea))) SDL_WM_GrabInput(SDL_GRAB_OFF); } else #endif if(DrawArea != NULL) { x = nMouseSX; y = nMouseSY; AG_ExecMouseAction (DrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(DrawArea))) SDL_WM_GrabInput(SDL_GRAB_OFF); } } /* * キャプチャ状態を保存 */ bMouseCaptureFlag = en; /* * マウス移動距離をクリア */ nMouseX = 0; nMouseY = 0; }