/* Gradient_x_y = sqrt(pow(gaussian_x,2)+pow(gaussian_y,2) */ void gradient_x_y_filter(float sigma){ int i,j,k,length_deriv; float deriv_gaussian[SIZE1]; matrix dgaux, dgauy, gradient_x_y, m; float rmin,rmax,rng; /* Fill in the image with background color */ for(i=0; i<IMAGE_WIDTH; i++) for(j=0; j<IMAGE_HEIGHT; j++) XPutPixel(theXImage_2,i,j,bg); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_1),XtWindow(draw_2),0,0,0,0,True); /* Associate the watch cursor with the main window */ XDefineCursor(XtDisplay(draw_1), XtWindow(main_window), theCursor); /* Flush the request buffer and wait for all events */ /* and errors to be processed by the server. */ XSync(XtDisplay(draw_1), False); get_derigaussian(sigma,deriv_gaussian,&length_deriv); for(i=0;i<IMAGE_WIDTH;i++) for(j=0;j<IMAGE_HEIGHT;j++) m[i][j]= XGetPixel(theXImage_1,i,j); /* Apply convolution with derivative of a gaussian to the rows */ convo_vectorx(m,deriv_gaussian,length_deriv,&rmax,&rmin,dgaux); /* Apply convolution with derivative of a gaussian to the columns */ convo_vectory(m,deriv_gaussian,length_deriv,&rmax,&rmin,dgauy); for(i=0;i<IMAGE_WIDTH;i++) for(j=0;j<IMAGE_HEIGHT;j++){ gradient_x_y[i][j]=sqrt(pow(dgaux[i][j],2)+ pow(dgauy[i][j],2)); if (i==0 && j==0){rmax=gradient_x_y[0][0]; rmin=rmax;} if (gradient_x_y[i][j]>rmax) rmax=gradient_x_y[i][j]; if (gradient_x_y[i][j]<rmin) rmin=gradient_x_y[i][j]; } rng=(rmax-rmin); for(i=0;i<IMAGE_WIDTH;i++) for(j=0;j<IMAGE_HEIGHT;j++) XPutPixel(theXImage_2,i,j,(unsigned long) (((float)(gradient_x_y[i][j]-rmin)/rng)*255.0)); /* Copy image into pixmap */ XPutImage(XtDisplay(draw_2), thePixmap_2,image_gc_2, theXImage_2, 0, 0, 0, 0, theXImage_2->width, theXImage_2->height); /* Disassociate the watch cursor from the main window */ XUndefineCursor(XtDisplay(draw_1), XtWindow(main_window)); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_2),XtWindow(draw_2),0,0,0,0,True); }
void MainLoop() override { bool fullscreen = SConfig::GetInstance().bFullscreen; int last_window_width = SConfig::GetInstance().iRenderWindowWidth; int last_window_height = SConfig::GetInstance().iRenderWindowHeight; if (fullscreen) { rendererIsFullscreen = X11Utils::ToggleFullscreen(dpy, win); #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRConfig->ToggleDisplayMode(True); #endif } // The actual loop while (s_running.IsSet()) { if (s_shutdown_requested.TestAndClear()) { const auto ios = IOS::HLE::GetIOS(); const auto stm = ios ? ios->GetDeviceByName("/dev/stm/eventhook") : nullptr; if (!s_tried_graceful_shutdown.IsSet() && stm && std::static_pointer_cast<IOS::HLE::Device::STMEventHook>(stm)->HasHookInstalled()) { ProcessorInterface::PowerButton_Tap(); s_tried_graceful_shutdown.Set(); } else { s_running.Clear(); } } XEvent event; KeySym key; for (int num_events = XPending(dpy); num_events > 0; num_events--) { XNextEvent(dpy, &event); switch (event.type) { case KeyPress: key = XLookupKeysym((XKeyEvent*)&event, 0); if (key == XK_Escape) { if (Core::GetState() == Core::State::Running) { if (SConfig::GetInstance().bHideCursor) XUndefineCursor(dpy, win); Core::SetState(Core::State::Paused); } else { if (SConfig::GetInstance().bHideCursor) XDefineCursor(dpy, win, blankCursor); Core::SetState(Core::State::Running); } } else if ((key == XK_Return) && (event.xkey.state & Mod1Mask)) { fullscreen = !fullscreen; X11Utils::ToggleFullscreen(dpy, win); #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRConfig->ToggleDisplayMode(fullscreen); #endif } else if (key >= XK_F1 && key <= XK_F8) { int slot_number = key - XK_F1 + 1; if (event.xkey.state & ShiftMask) State::Save(slot_number); else State::Load(slot_number); } else if (key == XK_F9) Core::SaveScreenShot(); else if (key == XK_F11) State::LoadLastSaved(); else if (key == XK_F12) { if (event.xkey.state & ShiftMask) State::UndoLoadState(); else State::UndoSaveState(); } break; case FocusIn: rendererHasFocus = true; if (SConfig::GetInstance().bHideCursor && Core::GetState() != Core::State::Paused) XDefineCursor(dpy, win, blankCursor); break; case FocusOut: rendererHasFocus = false; if (SConfig::GetInstance().bHideCursor) XUndefineCursor(dpy, win); break; case ClientMessage: if ((unsigned long)event.xclient.data.l[0] == XInternAtom(dpy, "WM_DELETE_WINDOW", False)) s_shutdown_requested.Set(); break; case ConfigureNotify: { if (last_window_width != event.xconfigure.width || last_window_height != event.xconfigure.height) { last_window_width = event.xconfigure.width; last_window_height = event.xconfigure.height; // We call Renderer::ChangeSurface here to indicate the size has changed, // but pass the same window handle. This is needed for the Vulkan backend, // otherwise it cannot tell that the window has been resized on some drivers. if (g_renderer) g_renderer->ChangeSurface(s_window_handle); } } break; } } if (!fullscreen) { Window winDummy; unsigned int borderDummy, depthDummy; XGetGeometry(dpy, win, &winDummy, &SConfig::GetInstance().iRenderWindowXPos, &SConfig::GetInstance().iRenderWindowYPos, (unsigned int*)&SConfig::GetInstance().iRenderWindowWidth, (unsigned int*)&SConfig::GetInstance().iRenderWindowHeight, &borderDummy, &depthDummy); rendererIsFullscreen = false; } Core::HostDispatchJobs(); usleep(100000); } }
void X11_MainLoop() { bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen; while (Core::GetState() == Core::CORE_UNINITIALIZED) updateMainFrameEvent.Wait(); Display *dpy = XOpenDisplay(0); Window win = (Window)Core::GetWindowHandle(); XSelectInput(dpy, win, KeyPressMask | FocusChangeMask); if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) X11Utils::InhibitScreensaver(dpy, win, true); #if defined(HAVE_XRANDR) && HAVE_XRANDR X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win); #endif Cursor blankCursor = None; if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) { // make a blank cursor Pixmap Blank; XColor DummyColor; char ZeroData[1] = {0}; Blank = XCreateBitmapFromData (dpy, win, ZeroData, 1, 1); blankCursor = XCreatePixmapCursor(dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0); XFreePixmap (dpy, Blank); XDefineCursor(dpy, win, blankCursor); } if (fullscreen) { X11Utils::EWMH_Fullscreen(dpy, _NET_WM_STATE_TOGGLE); #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRConfig->ToggleDisplayMode(True); #endif } // The actual loop while (running) { XEvent event; KeySym key; for (int num_events = XPending(dpy); num_events > 0; num_events--) { XNextEvent(dpy, &event); switch(event.type) { case KeyPress: key = XLookupKeysym((XKeyEvent*)&event, 0); if (key == XK_Escape) { if (Core::GetState() == Core::CORE_RUN) { if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XUndefineCursor(dpy, win); Core::SetState(Core::CORE_PAUSE); } else { if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XDefineCursor(dpy, win, blankCursor); Core::SetState(Core::CORE_RUN); } } else if ((key == XK_Return) && (event.xkey.state & Mod1Mask)) { fullscreen = !fullscreen; X11Utils::EWMH_Fullscreen(dpy, _NET_WM_STATE_TOGGLE); #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRConfig->ToggleDisplayMode(fullscreen); #endif } else if (key >= XK_F1 && key <= XK_F8) { int slot_number = key - XK_F1 + 1; if (event.xkey.state & ShiftMask) State::Save(slot_number); else State::Load(slot_number); } else if (key == XK_F9) Core::SaveScreenShot(); else if (key == XK_F11) State::LoadLastSaved(); else if (key == XK_F12) { if (event.xkey.state & ShiftMask) State::UndoLoadState(); else State::UndoSaveState(); } break; case FocusIn: rendererHasFocus = true; if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && Core::GetState() != Core::CORE_PAUSE) XDefineCursor(dpy, win, blankCursor); break; case FocusOut: rendererHasFocus = false; if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XUndefineCursor(dpy, win); break; } } if (!fullscreen) { Window winDummy; unsigned int borderDummy, depthDummy; XGetGeometry(dpy, win, &winDummy, &SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos, &SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos, (unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth, (unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight, &borderDummy, &depthDummy); } usleep(100000); } #if defined(HAVE_XRANDR) && HAVE_XRANDR delete XRRConfig; #endif if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) X11Utils::InhibitScreensaver(dpy, win, false); if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XFreeCursor(dpy, blankCursor); XCloseDisplay(dpy); Core::Stop(); }
void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor) { static int originalmouseparms_num; static int originalmouseparms_denom; static int originalmouseparms_threshold; static qboolean restore_spi; #ifdef USEDGA qboolean usedgamouse; #endif if (!vidx11_display || !win) return; if (relative) fullscreengrab = true; if (!mouse_avail) fullscreengrab = relative = hidecursor = false; #ifdef USEDGA usedgamouse = relative && vid_dgamouse.integer; if (!vid_x11_dgasupported) usedgamouse = false; if (fullscreengrab && vid_usingmouse && (vid_usingdgamouse != usedgamouse)) VID_SetMouse(false, false, false); // ungrab first! #endif if (vid_usingmousegrab != fullscreengrab) { vid_usingmousegrab = fullscreengrab; cl_ignoremousemoves = 2; if (fullscreengrab) { XGrabPointer(vidx11_display, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime); if (vid_grabkeyboard.integer || vid_isoverrideredirect) XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); } else { XUngrabPointer(vidx11_display, CurrentTime); XUngrabKeyboard(vidx11_display, CurrentTime); } } if (relative) { if (!vid_usingmouse) { XWindowAttributes attribs_1; XSetWindowAttributes attribs_2; XGetWindowAttributes(vidx11_display, win, &attribs_1); attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK; XChangeWindowAttributes(vidx11_display, win, CWEventMask, &attribs_2); #ifdef USEDGA vid_usingdgamouse = usedgamouse; if (usedgamouse) { XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), XF86DGADirectMouse); XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, 0, 0); } else #endif XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2); // COMMANDLINEOPTION: X11 Input: -noforcemparms disables setting of mouse parameters (not used with DGA, windows only) #ifdef USEDGA if (!COM_CheckParm ("-noforcemparms") && !usedgamouse) #else if (!COM_CheckParm ("-noforcemparms")) #endif { XGetPointerControl(vidx11_display, &originalmouseparms_num, &originalmouseparms_denom, &originalmouseparms_threshold); XChangePointerControl (vidx11_display, true, false, 1, 1, -1); // TODO maybe change threshold here, or remove this comment restore_spi = true; } else restore_spi = false; cl_ignoremousemoves = 2; vid_usingmouse = true; } } else { if (vid_usingmouse) { #ifdef USEDGA if (vid_usingdgamouse) XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), 0); vid_usingdgamouse = false; #endif cl_ignoremousemoves = 2; if (restore_spi) XChangePointerControl (vidx11_display, true, true, originalmouseparms_num, originalmouseparms_denom, originalmouseparms_threshold); restore_spi = false; vid_usingmouse = false; } } if (vid_usinghidecursor != hidecursor) { vid_usinghidecursor = hidecursor; if (hidecursor) XDefineCursor(vidx11_display, win, CreateNullCursor(vidx11_display, win)); else XUndefineCursor(vidx11_display, win); } }
void start_split(Widget w, XtPointer client_data, XmSelectionBoxCallbackStruct *call_data) { short i,j,condition; char *cond; /* Get threshold value from user's selection */ XmStringGetLtoR(call_data->value, XmSTRING_DEFAULT_CHARSET, &cond); condition = atoi(cond); if (!(condition>=0 && condition<=20512) ) { XBell(XtDisplay(w),100); return; } /* Fill in the image with background color */ for(i=0; i<IMAGE_WIDTH; i++) for(j=0; j<IMAGE_HEIGHT; j++) XPutPixel(theXImage_2,i,j,bg); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_1),XtWindow(draw_2),0,0,0,0,True); /* Associate the watch cursor with the main window */ XDefineCursor(XtDisplay(draw_1), XtWindow(main_window), theCursor); /* Flush the request buffer and wait for all events */ /* and errors to be processed by the server. */ XSync(XtDisplay(draw_1), False); /* Free the memory used for giving room to the structure */ /* that represents the merged regions if any */ if (merged_region_list!=NULL) free_merge(&merged_region_list); /* Free the memory used for giving room to the tree structure if any */ if (root!=NULL) free_tree(root); root=NULL; num_reg=0; num_split=0; /* Generate the quadtree structure */ root = split(condition,0,0,0); /* Show usefull information on the screen */ fprintf (stderr,"\n\n\n************************ SPLIT ***********************\n"); fprintf (stderr," Standard deviation: %i\n", condition); fprintf (stderr," Number of split operations: %i\n", num_split); fprintf (stderr," Number of regions after split: %i\n", num_reg); display_tree(root); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_1),XtWindow(draw_1),0,0,0,0,True); /* Disassociate the watch cursor from the main window */ XUndefineCursor(XtDisplay(draw_1), XtWindow(main_window)); /* Copy image into pixmap */ XPutImage(XtDisplay(draw_2), thePixmap_2, image_gc_2, theXImage_2, 0, 0, 0, 0, theXImage_2->width, theXImage_2->height); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_1),XtWindow(draw_2),0,0,0,0,True); }
void MWindow::showCursor(void) { XUngrabPointer(display, CurrentTime); XUndefineCursor(display, window); }
/* * Set the cursor image to be used for the current window */ void fgSetCursor ( SFG_Window *window, int cursorID ) { #if TARGET_HOST_POSIX_X11 { Cursor cursor; /* * XXX FULL_CROSSHAIR demotes to plain CROSSHAIR. Old GLUT allows * for this, but if there is a system that easily supports a full- * window (or full-screen) crosshair, we might consider it. */ int cursorIDToUse = ( cursorID == GLUT_CURSOR_FULL_CROSSHAIR ) ? GLUT_CURSOR_CROSSHAIR : cursorID; if( ( cursorIDToUse >= 0 ) && ( cursorIDToUse < sizeof( cursorCache ) / sizeof( cursorCache[0] ) ) ) { cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ]; if( entry->cachedCursor == None ) { entry->cachedCursor = XCreateFontCursor( fgDisplay.Display, entry->cursorShape ); } cursor = entry->cachedCursor; } else { switch( cursorIDToUse ) { case GLUT_CURSOR_NONE: cursor = getEmptyCursor( ); break; case GLUT_CURSOR_INHERIT: cursor = None; break; default: fgError( "Unknown cursor type: %d", cursorIDToUse ); return; } } if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) { XUndefineCursor( fgDisplay.Display, window->Window.Handle ); } else if ( cursor != None ) { XDefineCursor( fgDisplay.Display, window->Window.Handle, cursor ); } else if ( cursorIDToUse != GLUT_CURSOR_NONE ) { fgError( "Failed to create cursor" ); } } #elif TARGET_HOST_MS_WINDOWS /* * Joe Krahn is re-writing the following code. */ /* Set the cursor AND change it for this window class. */ #if !defined(__MINGW64__) && _MSC_VER <= 1200 # define MAP_CURSOR(a,b) \ case a: \ SetCursor( LoadCursor( NULL, b ) ); \ SetClassLong( window->Window.Handle, \ GCL_HCURSOR, \ ( LONG )LoadCursor( NULL, b ) ); \ break; /* Nuke the cursor AND change it for this window class. */ # define ZAP_CURSOR(a,b) \ case a: \ SetCursor( NULL ); \ SetClassLong( window->Window.Handle, \ GCL_HCURSOR, ( LONG )NULL ); \ break; #else # define MAP_CURSOR(a,b) \ case a: \ SetCursor( LoadCursor( NULL, b ) ); \ SetClassLongPtr( window->Window.Handle, \ GCLP_HCURSOR, \ ( LONG )( LONG_PTR )LoadCursor( NULL, b ) ); \ break; /* Nuke the cursor AND change it for this window class. */ # define ZAP_CURSOR(a,b) \ case a: \ SetCursor( NULL ); \ SetClassLongPtr( window->Window.Handle, \ GCLP_HCURSOR, ( LONG )( LONG_PTR )NULL ); \ break; #endif switch( cursorID ) { MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL ); MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT ); MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_IBEAM ); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_SIZENS ); MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, IDC_SIZEWE ); MAP_CURSOR( GLUT_CURSOR_TOP_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_BOTTOM_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_LEFT_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_RIGHT_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, IDC_SIZENWSE ); MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, IDC_SIZENESW ); MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, IDC_SIZENWSE ); MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, IDC_SIZENESW ); MAP_CURSOR( GLUT_CURSOR_INHERIT, IDC_ARROW ); /* XXX ToDo */ ZAP_CURSOR( GLUT_CURSOR_NONE, NULL ); MAP_CURSOR( GLUT_CURSOR_FULL_CROSSHAIR, IDC_CROSS ); /* XXX ToDo */ default: fgError( "Unknown cursor type: %d", cursorID ); break; } #endif window->State.Cursor = cursorID; }
bool InputDeviceAdapterMouse::keyPressed(int keyCode,int modifierMask,const char* string) { bool stateChanged=false; if(keyCode==keyboardModeToggleKeyCode) { keyboardMode=!keyboardMode; if(fakeMouseCursor) { /* Change the glyph renderer's cursor type to a text cursor: */ } else if(keyboardMode) { /* Change the cursor in all windows to a text cursor: */ for(int i=0; i<getNumWindows(); ++i) { VRWindow* win=Vrui::getWindow(i); if(win!=0) { Cursor cursor=XCreateFontCursor(win->getContext().getDisplay(),XC_xterm); XDefineCursor(win->getContext().getDisplay(),win->getWindow(),cursor); XFreeCursor(win->getContext().getDisplay(),cursor); } } } else { /* Change the cursor in all windows back to the regular: */ for(int i=0; i<getNumWindows(); ++i) { VRWindow* win=Vrui::getWindow(i); if(win!=0) XUndefineCursor(win->getContext().getDisplay(),win->getWindow()); } } } else if(keyboardMode) { /* Process the key event: */ ControlKeyMap::Iterator ckmIt=controlKeyMap.findEntry(ControlKey(keyCode,modifierMask&(ShiftMask|ControlMask))); if(!ckmIt.isFinished()) { /* Store a text control event: */ textControlEvents.push_back(std::pair<int,GLMotif::TextControlEvent>(nextEventOrdinal,ckmIt->getDest())); ++nextEventOrdinal; } else if(string!=0&&string[0]!='\0') { /* Store a text event: */ textEvents.push_back(std::pair<int,GLMotif::TextEvent>(nextEventOrdinal,GLMotif::TextEvent(string))); ++nextEventOrdinal; } stateChanged=true; } else { /* Check if the key is a button key: */ int buttonIndex=getButtonIndex(keyCode); if(buttonIndex>=0) { /* Set button state: */ int stateIndex=(numButtons+numButtonKeys)*modifierKeyMask+numButtons+buttonIndex; stateChanged=changeButtonState(stateIndex,true); } /* Check if the key is a modifier key: */ int modifierIndex=getModifierIndex(keyCode); if(modifierIndex>=0) { /* Change current modifier mask: */ changeModifierKeyMask(modifierKeyMask|(0x1<<modifierIndex)); stateChanged=true; } } // requestUpdate(); return stateChanged; }
/************************************************************************** This function is called if the client disconnects from the server **************************************************************************/ void remove_net_input(void) { XtRemoveInput(x_input_id); XUndefineCursor(display, XtWindow(map_canvas)); }
void MakeChooser( void ) { int i; /** greeting **/ XtGetSubresources(table, &greetInfo, "greeting", "Greeting", greetResources, XtNumber(greetResources), NULL, 0); i = InitArg(LabelG); xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_TITLE, MC_DEF_CHOOSER_TITLE); XtSetArg(argt[i], XmNtraversalOn, False); i++; XtSetArg(argt[i], XmNlabelString, xmstr); i++; XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNtopOffset, 10); i++; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER); i++; if ( greetInfo.fontList != NULL ) { XtSetArg(argt[i], XmNfontList, greetInfo.fontList); i++; } greeting = XmCreateLabel(matte1, "greeting", argt, i); XtManageChild(greeting); XmStringFree(xmstr); /** list head **/ i = InitArg(LabelG); xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_HEADING, MC_DEF_CHOOSER_HEADING); XtSetArg(argt[i], XmNtraversalOn, False); i++; XtSetArg(argt[i], XmNlabelString, xmstr); i++; XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNtopWidget, greeting); i++; XtSetArg(argt[i], XmNtopOffset, 10); i++; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNleftOffset, 13); i++; if (appInfo.chlistFont != NULL) { XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++; } list_head = XmCreateLabelGadget(matte1, "list_head", argt, i); XtManageChild(list_head); XmStringFree(xmstr); i = 0; XtSetArg(argt[i], XmNresizable, True); XtSetValues(matte, argt, i); XtSetValues(matte1, argt, i); /** chooser_list **/ i = 0; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNleftOffset, 10); i++; XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNrightOffset, 10); i++; XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNtopWidget, list_head); i++; XtSetArg(argt[i], XmNtopOffset, 1); i++; XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNbottomWidget, ok_button); i++; XtSetArg(argt[i], XmNbottomOffset, 10); i++; XtSetArg(argt[i], XmNallowShellResize, True); i++; XtSetArg(argt[i], XmNlistSizePolicy, XmCONSTANT); i++; XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++; if (appInfo.chlistFont != NULL) { XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++; } chooser_list = XmCreateScrolledList(matte1, "chooser_list", argt, i); XtAddCallback(chooser_list, XmNdefaultActionCallback, DoAccept, NULL); XtManageChild(chooser_list); if (appInfo.workspaceCursor) { MakeRootCursor(); } else { XUndefineCursor(dpyinfo.dpy, dpyinfo.root); } }
/* * Set the cursor image to be used for the current window */ void FGAPIENTRY glutSetCursor( int cursorID ) { freeglut_assert_ready; /* XXX WHY do we need the timer active for this? */ freeglut_assert_window; #if TARGET_HOST_UNIX_X11 /* * Open issues: * (a) Partial error checking. Is that a problem? * Is fgGetCursorError() correct? Should we abort on errors? * Should there be a freeglut-wide X error handler? Should * we use the X error-handler mechanism? * (b) FULL_CROSSHAIR demotes to plain CROSSHAIR. Old GLUT allows * for this, but if there is a system that easily supports a full- * window (or full-screen) crosshair, we might consider it. * (c) Out-of-range cursor-types generate warnings. Should we abort? */ { Cursor cursor = None; Pixmap no_cursor = None ; /* Used for GLUT_CURSOR_NONE */ int error = 0; #define MAP_CURSOR(a,b) \ case a: \ cursor = XCreateFontCursor( fgDisplay.Display, b ); \ break; if( GLUT_CURSOR_FULL_CROSSHAIR == cursorID ) cursorID = GLUT_CURSOR_CROSSHAIR; switch( cursorID ) { MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, XC_right_ptr); MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, XC_left_ptr); MAP_CURSOR( GLUT_CURSOR_INFO, XC_hand1); MAP_CURSOR( GLUT_CURSOR_DESTROY, XC_pirate); MAP_CURSOR( GLUT_CURSOR_HELP, XC_question_arrow); MAP_CURSOR( GLUT_CURSOR_CYCLE, XC_exchange); MAP_CURSOR( GLUT_CURSOR_SPRAY, XC_spraycan); MAP_CURSOR( GLUT_CURSOR_WAIT, XC_watch); MAP_CURSOR( GLUT_CURSOR_TEXT, XC_xterm); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, XC_crosshair); MAP_CURSOR( GLUT_CURSOR_UP_DOWN, XC_sb_v_double_arrow); MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, XC_sb_h_double_arrow); MAP_CURSOR( GLUT_CURSOR_TOP_SIDE, XC_top_side); MAP_CURSOR( GLUT_CURSOR_BOTTOM_SIDE, XC_bottom_side); MAP_CURSOR( GLUT_CURSOR_LEFT_SIDE, XC_left_side); MAP_CURSOR( GLUT_CURSOR_RIGHT_SIDE, XC_right_side); MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, XC_top_left_corner); MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, XC_top_right_corner); MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, XC_bottom_right_corner); MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, XC_bottom_left_corner); /* MAP_CURSOR( GLUT_CURSOR_NONE, XC_bogosity); */ case GLUT_CURSOR_NONE: { /* * Note that we *never* change {no_cursor_bits} from anything * but all-zeros. It is our image and mask. We also apparently * need to pick a color for foreground/background---but what * one we pick doesn't matter for GLUT_CURSOR_NONE. */ static char no_cursor_bits[ 32 ]; XColor black; no_cursor = XCreatePixmapFromBitmapData( fgDisplay.Display, fgDisplay.RootWindow, no_cursor_bits, 16, 16, 1, 0, 1 ); XParseColor( fgDisplay.Display, DefaultColormap( fgDisplay.Display, DefaultScreen( fgDisplay.Display ) ), "black", &black ); cursor = XCreatePixmapCursor( fgDisplay.Display, no_cursor, no_cursor, &black, &black, 0, 0 ); break; } case GLUT_CURSOR_INHERIT: break; default: fgWarning( "Unknown cursor type: %d\n", cursorID ); return; } error = fgGetCursorError( cursor ); if( GLUT_CURSOR_INHERIT == cursorID ) XUndefineCursor( fgDisplay.Display, fgStructure.Window->Window.Handle ); else { XDefineCursor( fgDisplay.Display, fgStructure.Window->Window.Handle, cursor ); XFreeCursor( fgDisplay.Display, cursor ); if( GLUT_CURSOR_NONE == cursorID ) XFreePixmap( fgDisplay.Display, no_cursor ); } } #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE /* * This is a temporary solution only... */ /* Set the cursor AND change it for this window class. */ # define MAP_CURSOR(a,b) \ case a: \ SetCursor( LoadCursor( NULL, b ) ); \ SetClassLong( fgStructure.Window->Window.Handle, \ GCL_HCURSOR, \ ( LONG )LoadCursor( NULL, b ) ); \ break; /* Nuke the cursor AND change it for this window class. */ # define ZAP_CURSOR(a,b) \ case a: \ SetCursor( NULL ); \ SetClassLong( fgStructure.Window->Window.Handle, \ GCL_HCURSOR, ( LONG )NULL ); \ break; switch( cursorID ) { MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL ); MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT ); MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW ); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS ); /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */ ZAP_CURSOR( GLUT_CURSOR_NONE, NULL ); default: MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW ); } #endif fgStructure.Window->State.Cursor = cursorID; }
void CLogMotif::reset_cursor() { XUndefineCursor( flow_Display(toplevel), flow_Window(toplevel)); }
/*ARGSUSED*/ static Boolean XawSimpleSetValues(Widget current, Widget request, Widget cnew, ArgList args, Cardinal *num_args) { SimpleWidget s_old = (SimpleWidget)current; SimpleWidget s_new = (SimpleWidget)cnew; Bool new_cursor = False; /* this disables user changes after creation */ s_new->simple.international = s_old->simple.international; if (XtIsSensitive(current) != XtIsSensitive(cnew)) (*((SimpleWidgetClass)XtClass(cnew))->simple_class.change_sensitive) (cnew); if (s_old->simple.cursor != s_new->simple.cursor) new_cursor = True; /* * We are not handling the string cursor_name correctly here */ if (s_old->simple.pointer_fg != s_new->simple.pointer_fg || s_old->simple.pointer_bg != s_new->simple.pointer_bg || s_old->simple.cursor_name != s_new->simple.cursor_name) { ConvertCursor(cnew); new_cursor = True; } if (new_cursor && XtIsRealized(cnew)) { if (s_new->simple.cursor != None) XDefineCursor(XtDisplay(cnew), XtWindow(cnew), s_new->simple.cursor); else XUndefineCursor(XtDisplay(cnew), XtWindow(cnew)); } #ifndef OLDXAW if (s_old->core.background_pixmap != s_new->core.background_pixmap) { XawPixmap *opix, *npix; opix = XawPixmapFromXPixmap(s_old->core.background_pixmap, XtScreen(s_old), s_old->core.colormap, s_old->core.depth); npix = XawPixmapFromXPixmap(s_new->core.background_pixmap, XtScreen(s_new), s_new->core.colormap, s_new->core.depth); if ((npix && npix->mask) || (opix && opix->mask)) XawReshapeWidget(cnew, npix); } if (s_old->simple.tip != s_new->simple.tip) { if (s_old->simple.tip) XtFree((XtPointer)s_old->simple.tip); if (s_new->simple.tip) s_new->simple.tip = XtNewString(s_new->simple.tip); } if (s_old->simple.tip && !s_new->simple.tip) XawTipDisable(cnew); else if (!s_old->simple.tip && s_new->simple.tip) XawTipEnable(cnew); if (s_old->simple.display_list != s_new->simple.display_list) return (True); #endif /* OLDXAW */ return (False); }
static void install_grabs( void ) { int res; int fevent; assert( x11display.dpy && x11display.win ); if( !x11display.features.wmStateFullscreen ) { res = XGrabKeyboard( x11display.dpy, x11display.win, False, GrabModeAsync, GrabModeAsync, CurrentTime ); if( res != GrabSuccess ) { Com_Printf( "Warning: XGrabKeyboard failed\n" ); return; } } XDefineCursor( x11display.dpy, x11display.win, CreateNullCursor( x11display.dpy, x11display.win ) ); res = XGrabPointer( x11display.dpy, x11display.win, True, 0, GrabModeAsync, GrabModeAsync, x11display.win, None, CurrentTime ); if( res != GrabSuccess ) { // TODO: Find a solution to Pointer Grabs at focus changes, which sometimes result // in Grabbing Errors. Like switches from Windowed/Fullscreen to Hidden State. //Com_Printf( "Warning: XGrabPointer failed\n" ); XUngrabKeyboard( x11display.dpy, CurrentTime ); XUndefineCursor( x11display.dpy, x11display.win ); return; } if( in_dgamouse->integer ) { int MajorVersion, MinorVersion; if( XF86DGAQueryVersion( x11display.dpy, &MajorVersion, &MinorVersion ) ) { XF86DGADirectVideo( x11display.dpy, x11display.scr, XF86DGADirectMouse ); XWarpPointer( x11display.dpy, None, x11display.win, 0, 0, 0, 0, x11display.win_width/2, x11display.win_height/2 ); dgamouse = qtrue; } else { // unable to query, probalby not supported Com_Printf( "Failed to detect XF86DGA Mouse\n" ); Cvar_Set( "in_dgamouse", "0" ); dgamouse = qfalse; } } else { XWarpPointer( x11display.dpy, None, x11display.win, 0, 0, 0, 0, x11display.win_width/2, x11display.win_height/2 ); } ignore_one = qtrue; // first mouse update after install_grabs is ignored mx = my = 0; mouse_active = qtrue; in_dgamouse->modified = qfalse; input_active = qtrue; // init X Input method, needed by Xutf8LookupString x11display.im = XOpenIM( x11display.dpy, NULL, NULL, NULL ); x11display.ic = XCreateIC( x11display.im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, x11display.win, NULL ); if ( x11display.ic ) { XGetICValues( x11display.ic, XNFilterEvents, &fevent, NULL ); XSelectInput( x11display.dpy, x11display.win, fevent | x11display.wa.event_mask ); } }
/*! \fn \brief Set the cursor image to be used for the current window \ingroup window \param cursorID Name of desired cursor. For the <i>current window</i>, sets the mouse-cursor to one of a set of predefined images. The GLUT symbolic constant IDs are: - \a GLUT_CURSOR_RIGHT_ARROW - \a GLUT_CURSOR_LEFT_ARROW - \a GLUT_CURSOR_INFO - \a GLUT_CURSOR_DESTROY - \a GLUT_CURSOR_HELP - \a GLUT_CURSOR_CYCLE - \a GLUT_CURSOR_SPRAY - \a GLUT_CURSOR_WAIT - \a GLUT_CURSOR_TEXT - \a GLUT_CURSOR_CROSSHAIR - \a GLUT_CURSOR_UP_DOWN - \a GLUT_CURSOR_LEFT_RIGHT - \a GLUT_CURSOR_TOP_SIDE - \a GLUT_CURSOR_BOTTOM_SIDE - \a GLUT_CURSOR_LEFT_SIDE - \a GLUT_CURSOR_RIGHT_SIDE - \a GLUT_CURSOR_TOP_LEFT_CORNER - \a GLUT_CURSOR_TOP_RIGHT_CORNER - \a GLUT_CURSOR_BOTTOM_RIGHT_CORNER - \a GLUT_CURSOR_BOTTOM_LEFT_CORNER Additionally, there are the following special cases: \a GLUT_CURSOR_FULL_CROSSHAIR This cursor, where supported, draws a crosshair the full width and height of the display. It may be mapped by OpenGLUT to the \a GLUT_CURSOR_CROSSHAIR, however. \a GLUT_CURSOR_NONE Turn the mouse cursor invisibile. \a GLUT_CURSOR_INHERIT Take the cursor that the parent window provides. \note The X branch of OpenGLUT does not do thorough error checking. \note The X branch of OpenGLUT always converts \a FULL_CROSSHAIR to \a CROSSHAIR. This is acceptable, but if a host system supports a fullscreen crosshair, it would be nice to support that. \note Out of range \a cursorID values generate warnings. \note Has no visible effect if the <i>current window</i> is of type \a GLUT_OFFSCREEN . \bug Some \a cursorID values are not yet supported on WIN32. */ void OGAPIENTRY glutSetCursor( int cursorID ) { int error = 0; freeglut_assert_ready; freeglut_assert_window; if( GL_FALSE == ogStructure.Window->State.IsOffscreen ) { #if TARGET_HOST_UNIX_X11 Cursor cursor = None; Pixmap no_cursor = None ; /* Used for GLUT_CURSOR_NONE */ #define MAP_CURSOR(a,b) \ case a: \ cursor = XCreateFontCursor( ogDisplay.Display, b ); \ break; if( GLUT_CURSOR_FULL_CROSSHAIR == cursorID ) cursorID = GLUT_CURSOR_CROSSHAIR; switch( cursorID ) { MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, XC_right_ptr); MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, XC_left_ptr); MAP_CURSOR( GLUT_CURSOR_INFO, XC_hand1); MAP_CURSOR( GLUT_CURSOR_DESTROY, XC_pirate); MAP_CURSOR( GLUT_CURSOR_HELP, XC_question_arrow); MAP_CURSOR( GLUT_CURSOR_CYCLE, XC_exchange); MAP_CURSOR( GLUT_CURSOR_SPRAY, XC_spraycan); MAP_CURSOR( GLUT_CURSOR_WAIT, XC_watch); MAP_CURSOR( GLUT_CURSOR_TEXT, XC_xterm); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, XC_crosshair); MAP_CURSOR( GLUT_CURSOR_UP_DOWN, XC_sb_v_double_arrow); MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, XC_sb_h_double_arrow); MAP_CURSOR( GLUT_CURSOR_TOP_SIDE, XC_top_side); MAP_CURSOR( GLUT_CURSOR_BOTTOM_SIDE, XC_bottom_side); MAP_CURSOR( GLUT_CURSOR_LEFT_SIDE, XC_left_side); MAP_CURSOR( GLUT_CURSOR_RIGHT_SIDE, XC_right_side); MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, XC_top_left_corner); MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, XC_top_right_corner); MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, XC_bottom_right_corner); MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, XC_bottom_left_corner); /* MAP_CURSOR( GLUT_CURSOR_NONE, XC_bogosity); */ case GLUT_CURSOR_NONE: { /* * Note that we *never* change {no_cursor_bits} from anything * but all-zeros. It is our image and mask. We also apparently * need to pick a color for foreground/background---but what * one we pick doesn't matter for GLUT_CURSOR_NONE. */ static char no_cursor_bits[ 32 ]; XColor black; no_cursor = XCreatePixmapFromBitmapData( ogDisplay.Display, ogDisplay.RootWindow, no_cursor_bits, 16, 16, 1, 0, 1 ); XParseColor( ogDisplay.Display, DefaultColormap( ogDisplay.Display, DefaultScreen( ogDisplay.Display ) ), "black", &black ); cursor = XCreatePixmapCursor( ogDisplay.Display, no_cursor, no_cursor, &black, &black, 0, 0 ); break; } case GLUT_CURSOR_INHERIT: break; default: ogWarning( "Unknown cursor type: %d", cursorID ); return; } error = ogGetCursorError( cursor ); if( GLUT_CURSOR_INHERIT == cursorID ) XUndefineCursor( ogDisplay.Display, ogStructure.Window->Window.Handle ); else { XDefineCursor( ogDisplay.Display, ogStructure.Window->Window.Handle, cursor ); XFreeCursor( ogDisplay.Display, cursor ); if( GLUT_CURSOR_NONE == cursorID ) XFreePixmap( ogDisplay.Display, no_cursor ); } #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE /* This is a temporary solution only... */ /* Set the cursor AND change it for this window class. */ # define MAP_CURSOR(a,b) \ case a: \ SetCursor( LoadCursor( NULL, b ) ); \ SetClassLong( ogStructure.Window->Window.Handle, \ GCL_HCURSOR, \ ( LONG )LoadCursor( NULL, b ) ); \ break; /* Nuke the cursor AND change it for this window class. */ # define ZAP_CURSOR(a,b) \ case a: \ SetCursor( NULL ); \ SetClassLong( ogStructure.Window->Window.Handle, \ GCL_HCURSOR, ( LONG )NULL ); \ break; switch( cursorID ) { MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL ); MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT ); MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW ); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS ); /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */ ZAP_CURSOR( GLUT_CURSOR_NONE, NULL ); default: MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW ); } #endif } if( !error ) ogStructure.Window->State.Cursor = cursorID; }
WlzPolygonDomain *HGU_XGetPolydmn( Display *dpy, Window win, int mode, HGU_XInteractCallbacks *callbacks, WlzPolygonDomain *start) { XEvent event; GC gc; XWindowAttributes win_att; WlzFVertex2 *vtxs=NULL, vtx, vtxp; int nvtxs=0, max_nvtxs=0; int finished = 0; HGU_XGetVtxsCallbackStruct cb_struct; int i; int dx, dy; WlzPolygonDomain *return_polydmn; static int current_cursor=2; /* initialise vertex */ vtxp.vtX = 0; vtxp.vtY = 0; /* set up the callback struct */ cb_struct.event = &event; /* get interact gc */ gc = HGU_XGetGC( dpy, win, HGU_XGC_INTERACT ); /* set the cursor */ HGU_XSetCursor( dpy, win, HGU_XCURSOR_POINT ); /* copy the given polygon */ if( (start != NULL) && (start->nvertices > 0) ){ for(i=0; i < start->nvertices; i++){ switch( start->type ){ case WLZ_POLYGON_INT: vtx.vtX = start->vtx[i].vtX; vtx.vtY = start->vtx[i].vtY; break; case WLZ_POLYGON_FLOAT: vtx.vtX = ((WlzFVertex2 *) start->vtx)[i].vtX; vtx.vtY = ((WlzFVertex2 *) start->vtx)[i].vtY; break; case WLZ_POLYGON_DOUBLE: vtx.vtX = ((WlzDVertex2 *) start->vtx)[i].vtX; vtx.vtY = ((WlzDVertex2 *) start->vtx)[i].vtY; break; default: vtx.vtX = 0; vtx.vtY = 0; break; } NEW_VTX((&vtx)); } /* warp pointer */ XWarpPointer(dpy,None,win,0,0,0,0,(int) (vtx.vtX), (int) (vtx.vtY)); } /* select input */ if( XGetWindowAttributes(dpy, win, &win_att) == 0 ){ HGU_XError(dpy, win, "HGU_XGetPolydmn", "failed to get window attributes", 0); return( NULL ); } XSelectInput(dpy, win, win_att.your_event_mask | KeyPressMask | KeyReleaseMask | EnterWindowMask | LeaveWindowMask ); if( QueryInWindow( dpy, win ) ){ HGU_XGrabPointer(dpy, win, mode&HGU_XConfineMask); } /* get the polyline */ while( !finished ){ XNextEvent(dpy, &event); if( event.xany.window != win ){ finished = HGU_XInteractNonwindowEvent(dpy, win, mode, callbacks, &event); continue; } switch( event.type ){ case ButtonPress: switch( event.xbutton.button ){ case Button1: /* new vertex or select */ case Button2: vtx.vtX = event.xbutton.x; vtx.vtY = event.xbutton.y; NEW_VTX((&vtx)); break; case Button3: finished = 1; break; default: break; } break; case ButtonRelease: switch( event.xbutton.button ){ case Button1: /* */ case Button2: /* CHECK NOCONFIRM */ break; case Button3: default: break; } break; case KeyPress: switch( XLookupKeysym(&event.xkey, 0) ){ case XK_Delete: case XK_BackSpace: vtx.vtX = event.xkey.x; vtx.vtY = event.xkey.y; REMOVE_VTX((&vtx)); break; case XK_Right: MOVE_POINTER(1,0,event.xkey.state&ControlMask); break; case XK_Left: MOVE_POINTER(-1,0,event.xkey.state&ControlMask); break; case XK_Up: MOVE_POINTER(0,-1,event.xkey.state&ControlMask); break; case XK_Down: MOVE_POINTER(0,1,event.xkey.state&ControlMask); break; case XK_space: vtx.vtX = event.xkey.x; vtx.vtY = event.xkey.y; NEW_VTX((&vtx)); break; case XK_Return: finished = 1; break; case XK_Help: HGU_XInteractHelpEvent(dpy, win, callbacks, help_str); break; case XK_C: case XK_c: /* <ctrl> c toggle cursor */ if( event.xkey.state & ControlMask ){ current_cursor++; switch( current_cursor%3 ){ case 0: /* normal cross cursor */ HGU_XSetCursor( dpy, win, HGU_XCURSOR_CROSS ); break; case 1: /* pointer cursor */ HGU_XSetCursor( dpy, win, HGU_XCURSOR_POINTER ); break; case 2: /* single point cursor */ HGU_XSetCursor( dpy, win, HGU_XCURSOR_POINT ); break; } } break; default: break; } break; case KeyRelease: switch( XLookupKeysym(&event.xkey, 0) ){ case XK_Delete: case XK_BackSpace: finished = mode & HGU_XNoConfirmMask; break; default: break; } break; case MotionNotify: /* check button masks */ vtx.vtX = event.xmotion.x; vtx.vtY = event.xmotion.y; if( event.xmotion.state & (Button1Mask|Button2Mask) ){ NEW_VTX((&vtx)); } else { MOVE_VTX((&vtx)); } cb_struct.x = event.xmotion.x; cb_struct.y = event.xmotion.y; cb_struct.vtxs = vtxs; cb_struct.nvtxs = nvtxs; finished = HGU_XInteractWindowEvent(dpy, win, mode, callbacks, (caddr_t) &cb_struct); break; case EnterNotify: HGU_XGrabPointer(dpy, win, mode&HGU_XConfineMask); break; case LeaveNotify: HGU_XUngrabPointer(dpy, win); break; default: break; } } /* remove the line */ for(i=1; i < nvtxs; i++) MyDrawLine(dpy, win, gc, &vtxs[i-1], &vtxs[i]); if( nvtxs ) MyDrawLine(dpy, win, gc, &vtxs[nvtxs-1], &vtxp); /* ungrab the pointer */ HGU_XUngrabPointer(dpy, win); /* undefine the cross cursor */ XUndefineCursor( dpy, win ); /* reset input mask */ XSelectInput(dpy, win, win_att.your_event_mask ); /* check for defined points */ if( nvtxs == 0 ){ if( vtxs != NULL ) AlcFree( (void *) vtxs ); return( NULL ); } /* make a polygondomain to return values */ vtxs = (WlzFVertex2 *) AlcRealloc(vtxs, sizeof(WlzFVertex2)*(nvtxs+2)); vtxs[nvtxs] = vtxp; vtxs[nvtxs+1] = vtxs[0]; /* return the new polygon */ return_polydmn = WlzMakePolygonDomain(WLZ_POLYGON_FLOAT, nvtxs+1, (WlzIVertex2 *) vtxs, nvtxs+2, 1, NULL); AlcFree( (void *) vtxs ); return return_polydmn; }
void x11_lightpen_update(void) { if (c == NULL) { #if LP_DEBUG fprintf(stderr, "x11_lightpen_update: c == NULL\n"); #endif return; } if (display == NULL) { #if LP_DEBUG fprintf(stderr, "x11_lightpen_update: display == NULL\n"); #endif return; } if (lightpen_enabled) { int x, y; float scalex, scaley; int offx, offy; geometry_t *geom = c->geometry; draw_buffer_t *draw_buffer = c->draw_buffer; viewport_t *viewport = c->viewport; XDefineCursor(display, XtWindow(c->emuwindow), cursor); /* * This information is gleaned from viewport.h, * video/video-viewport.c:video_viewport_resize(). * * geom->gfx_size: size inside borders, in C64 pixels * geom->screen_size: size including borders, in C64 pixels * draw_buffer->canvas_width, ..height: size + black padding, C64 * c->width, c->height: same size, in X pixels. * saved_w, saved_h: should be the same values. * * Note that in "full" or "debug" border mode the X coordinates * will still be too large. * * To make it more complicated, 80 column screens (128 VDC and PET) * are always stretched horizontally. On a real machine the double * number of pixels would fit in the same physical width, being * narrower pixels, but the emulation pixels remain square and * too wide. The lightpen_update() seems to compensate for that * itself, though. */ #if LP_DEBUG fprintf(stderr, " gfx_size.width=%3d gfx_size.height=%3d\n" " screen_size.width=%3d screen_size.height=%3d\n" " d_b->canvas_width=%3d canvas_height=%3d\n" " width=%3d height=%3d\n" " vp->x_offset=%3d y_offset=%3d border_left=%d\n" " vp->first_x=%3d vp->first_line=%3d first_displayed_line=%3d\n" " dblx=%3d x=%3d dbly=%3d y=%3d\n", geom->gfx_size.width, geom->gfx_size.height, geom->screen_size.width, geom->screen_size.height, draw_buffer->canvas_width, draw_buffer->canvas_height, c->width, c->height, viewport->x_offset, viewport->y_offset, geom->extra_offscreen_border_left, viewport->first_x, viewport->first_line, geom->first_displayed_line, c->videoconfig->doublesizex, saved_x, c->videoconfig->doublesizey, saved_y ); #endif #ifdef HAVE_XVIDEO if (c->videoconfig->hwscale && c->xv_image) { /* display_yuv_image() kindly stored these coordinates for us */ offx = c->xv_geometry.x; offy = c->xv_geometry.y; scalex = (float)c->xv_geometry.w / draw_buffer->canvas_width; scaley = (float)c->xv_geometry.h / draw_buffer->canvas_height; x = (saved_x - offx) / scalex; y = (saved_y - offy) / scaley; } else #endif { /* * Either * x_offset is > 0 (if the window is too large: black padding), * or first_x is > 0 (if the window is too small: clips). */ offx = viewport->x_offset - viewport->first_x; offy = viewport->y_offset - viewport->first_line + geom->first_displayed_line; scalex = (float)draw_buffer->canvas_physical_width / draw_buffer->canvas_width; scaley = (float)draw_buffer->canvas_physical_height / draw_buffer->canvas_height; x = (saved_x / scalex) - offx; y = (saved_y / scaley) - offy; } #if LP_DEBUG fprintf(stderr,"x=%d y=%d b=%02x scalex=%.3f scaley=%.3f offx=%d offy=%d appshell=%d\n", x, y, buttons, scalex, scaley, offx, offy, c->app_shell); #endif if (x >= geom->screen_size.width) { x = -1; } if (y >= geom->screen_size.height) { y = -1; } lightpen_update(c->app_shell, x, y, buttons); } else { if (c->emuwindow) { Window w = XtWindow(c->emuwindow); if (w) { XUndefineCursor(display, w); } } buttons = 0; } }
static void xskin_jobs( int pipe_in ) { XEvent e; int x,y; int window_x,window_y; int fspe=0; int pr=-1; int z; int p; int master_volume=0; char file_name[1024], tmp[1024]; int last_puttext_time; int last_window_x=-1, last_window_y=-1; int max_files; int i; fd_set fds; static struct timeval tv; Window t_w; unsigned int t_width, t_height, t_border, t_depth; xskin_pipe_write( "READY" ); shmid = shmget( IPC_PRIVATE, sizeof(char)*SPE_W, IPC_CREAT|0600 ); if ( shmid<0 ) xskin_pipe_write( "ERROR" ); else { sprintf( local_buf, "%d", shmid ); xskin_pipe_write( local_buf ); speana_buf = (unsigned char *)shmat( shmid, 0, 0 ); } xskin_pipe_read( local_buf, sizeof(local_buf) ); max_files = atoi( local_buf ); for ( i=0 ; i<max_files ; i++ ) { xskin_pipe_read( local_buf, sizeof(local_buf) ); } z=1; last_puttext_time=0; last_current_time=0; XGetGeometry( xskin_d, xskin_w, &t_w, &window_x, &window_y, &t_width, &t_height, &t_border, &t_depth ); while( z ) { XFlush( xskin_d ); FD_ZERO( &fds ); FD_SET( pipe_in, &fds ); tv.tv_sec=0; tv.tv_usec=20000L; /* 20 msec */ i=select( pipe_in+1, &fds, NULL, NULL, &tv ); if ( i!=0 ) { xskin_pipe_read( local_buf, sizeof(local_buf) ); switch (local_buf[0]) { case 'A': /* total time */ total_time=atoi( local_buf+2 ); last_current_time=0; last_puttext_time=0; break; case 'T': /* current time */ { int min,sec; sscanf( local_buf+2, "%02d:%02d", &min, &sec ); i=min*60+sec; if ( fremain==1 ) { sec =total_time-i; min =sec/60; sec-=min*60; } if ( i != last_current_time ) { ts_putnum( MIN_H_X, MIN_H_Y, min/10 ); ts_putnum( MIN_L_X, MIN_L_Y, min%10 ); ts_putnum( SEC_H_X, SEC_H_Y, sec/10 ); ts_putnum( SEC_L_X, SEC_L_Y, sec%10 ); p=100*i/total_time; play_val=ts_pos( OFF, -p ); last_current_time=i; if ( last_current_time - last_puttext_time == 3 ) { /* 3 sec */ sprintf( tmp, "%s [%02d:%02d]", file_name, total_time/60, total_time%60 ); ts_puttext( MESSAGE_X, MESSAGE_Y, tmp ); } } } break; case 'L': /* lylics/message */ ts_puttext( MESSAGE_X, MESSAGE_Y, local_buf+2 ); last_puttext_time=last_current_time; break; case 'F': /* filename */ strncpy( file_name, local_buf+2, 1023 ); file_name[1023]=0; break; case 'O': /* off the play button */ fplay=0; ts_play(OFF); ts_spectrum(fspe, NULL); /* erase spectrums */ break; case 'V': /* master volume */ master_volume=atoi( local_buf+2 ); p=100*((master_volume<200)?master_volume:200)/200; /* max:200% */ vol_val=ts_volume( OFF, -p ); break; case 'Q': /* quit */ z=1; break; case 'W': /* wave form */ ts_spectrum(fspe, speana_buf); break; default: break; } } if ( XPending( xskin_d )==0 ) continue; XNextEvent( xskin_d, &e ); switch ( e.type ) { /* case KeyPress: z=0; break; */ case Expose: repaint(); break; case EnterNotify: { Cursor cs; ts_titlebar(ON); cs = XCreateFontCursor( xskin_d, XC_top_left_arrow ); XDefineCursor( xskin_d, xskin_w, cs ); } break; case LeaveNotify: ts_titlebar(OFF); XUndefineCursor( xskin_d, xskin_w ); break; case MotionNotify: while( XCheckMaskEvent( xskin_d, Button1MotionMask, &e ) ) { XNextEvent( xskin_d, &e ); } x = e.xbutton.x; y = e.xbutton.y; switch( pr ) { /* case TS_POS: play_val=ts_pos( ON, x );break; */ case TS_VOLUME: vol_val=ts_volume( ON, x ); i=master_volume; master_volume=200*vol_val/100; sprintf( local_buf, "V %d", master_volume-i ); xskin_pipe_write( local_buf ); sprintf( tmp, " volume: %d%%", vol_val ); ts_puttext( MESSAGE_X, MESSAGE_Y, tmp ); last_puttext_time=last_current_time; break; /* case TS_PAN: pan_val=ts_pan( ON, x );break; */ default: if ( x != last_window_x || y != last_window_y ) { window_x += x-last_window_x; window_y += y-last_window_y; XMoveWindow( xskin_d, xskin_w, window_x, window_y ); } break; } break; case ButtonPress: x = e.xbutton.x; y = e.xbutton.y; last_window_x=x; last_win
void MainLoop() override { bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen; if (fullscreen) { rendererIsFullscreen = X11Utils::ToggleFullscreen(dpy, win); #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRConfig->ToggleDisplayMode(True); #endif } // The actual loop while (running) { XEvent event; KeySym key; for (int num_events = XPending(dpy); num_events > 0; num_events--) { XNextEvent(dpy, &event); switch (event.type) { case KeyPress: key = XLookupKeysym((XKeyEvent*)&event, 0); if (key == XK_Escape) { if (Core::GetState() == Core::CORE_RUN) { if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XUndefineCursor(dpy, win); Core::SetState(Core::CORE_PAUSE); } else { if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XDefineCursor(dpy, win, blankCursor); Core::SetState(Core::CORE_RUN); } } else if ((key == XK_Return) && (event.xkey.state & Mod1Mask)) { fullscreen = !fullscreen; X11Utils::ToggleFullscreen(dpy, win); #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRConfig->ToggleDisplayMode(fullscreen); #endif } else if (key >= XK_F1 && key <= XK_F8) { int slot_number = key - XK_F1 + 1; if (event.xkey.state & ShiftMask) State::Save(slot_number); else State::Load(slot_number); } else if (key == XK_F9) Core::SaveScreenShot(); else if (key == XK_F11) State::LoadLastSaved(); else if (key == XK_F12) { if (event.xkey.state & ShiftMask) State::UndoLoadState(); else State::UndoSaveState(); } break; case FocusIn: rendererHasFocus = true; if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && Core::GetState() != Core::CORE_PAUSE) XDefineCursor(dpy, win, blankCursor); break; case FocusOut: rendererHasFocus = false; if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XUndefineCursor(dpy, win); break; case ClientMessage: if ((unsigned long) event.xclient.data.l[0] == XInternAtom(dpy, "WM_DELETE_WINDOW", False)) running = false; break; } } if (!fullscreen) { Window winDummy; unsigned int borderDummy, depthDummy; XGetGeometry(dpy, win, &winDummy, &SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos, &SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos, (unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth, (unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight, &borderDummy, &depthDummy); rendererIsFullscreen = false; } usleep(100000); } }
static void defaultcursor() { XUndefineCursor(g_dpy, g_win); if (g_cursor) XFreeCursor(g_dpy, g_cursor); g_cursor = 0; }
void X11Window::restoreMouseCursor() { XUndefineCursor(m_display, m_window); m_cursor = None; }
void main_loop(void) { char key; int paper_w, paper_h; long diff; if (!landscape) { paper_w = XLENG / shrink; paper_h = YLENG / shrink; } else { paper_w = YLENG / shrink; paper_h = XLENG / shrink; } set_all(); XUndefineCursor(display, main_window); for (;;) { XNextEvent(display, &ev); switch (ev.type) { case Expose: if (ev.xexpose.count == 0) get_window_size(); realize_part(ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, ev.xexpose.x, ev.xexpose.y); break; case MappingNotify: /* XRefreshKeyboardMapping(&ev); */ XRefreshKeyboardMapping((XMappingEvent *) & ev); break; /* case ConfigureNotify: get_window_size(); shr_w = paper_w / window_w; shr_h = paper_h / window_h; shrink = (shr_w >= shr_h) ? shr_w :shr_h; rewind(stdin); plot(); main_loop(); origin_x += window_x; origin_y += window_y; realize(); realize_part(origin_x, origin_y, window_w, window_h, origin_x, origin_y); origin_x = paper_w - xsh.width; origin_y = paper_h - xsh.height; origin_x += xsh.x; origin_y += xsh.y; break; */ case MotionNotify: break; case ButtonPress: break; case KeyPress: get_window_size(); XLookupString(&ev.xkey, &key, 1, NULL, NULL); switch (key) { case 'j': diff = paper_h - window_h; if (origin_y >= diff) { beep(); break; } origin_y += window_h / 4; if (origin_y > diff) origin_y = diff; if (origin_y < 0) origin_y = 0; realize(); continue; break; case 'k': if (origin_y <= 0) { beep(); break; } origin_y -= window_h / 4; if (origin_y < 0) origin_y = 0; realize(); continue; break; case 'l': diff = paper_w - window_w; if (origin_x >= diff) { beep(); break; } origin_x += window_w / 4; if (origin_x > diff) origin_x = diff; if (origin_x < 0) origin_x = 0; realize(); continue; break; case 'h': if (origin_x <= 0) { beep(); break; } origin_x -= window_w / 4; if (origin_x < 0) origin_x = 0; realize(); continue; break; case 'q': case '\003': /* control-C */ case '\004': /* control-D */ close_window(); break; default: beep(); break; } break; default: break; } } }
void GLWindow::showCursor(void) { XUndefineCursor(display,window); }
void SingleOpenGLWindowImplT::Close() { #ifdef _WIN32 // Release DirectInput. DirectInput.Release(); // Rendering-Context zurückgeben. if (hRC) { // Vorher noch prüfen, ob es OpenGL-Fehler gab. while (true) { GLenum Error=glGetError(); switch (Error) { case GL_NO_ERROR : break; case GL_INVALID_ENUM : MessageBox(NULL, "GL_INVALID_ENUM ", NULL, MB_OK | MB_ICONERROR | MB_TOPMOST); break; case GL_INVALID_VALUE : MessageBox(NULL, "GL_INVALID_VALUE ", NULL, MB_OK | MB_ICONERROR | MB_TOPMOST); break; case GL_INVALID_OPERATION: MessageBox(NULL, "GL_INVALID_OPERATION", NULL, MB_OK | MB_ICONERROR | MB_TOPMOST); break; case GL_STACK_OVERFLOW : MessageBox(NULL, "GL_STACK_OVERFLOW ", NULL, MB_OK | MB_ICONERROR | MB_TOPMOST); break; case GL_STACK_UNDERFLOW : MessageBox(NULL, "GL_STACK_UNDERFLOW ", NULL, MB_OK | MB_ICONERROR | MB_TOPMOST); break; case GL_OUT_OF_MEMORY : MessageBox(NULL, "GL_OUT_OF_MEMORY ", NULL, MB_OK | MB_ICONERROR | MB_TOPMOST); break; default : MessageBox(NULL, "GL_UNKNOWN!!! ", NULL, MB_OK | MB_ICONERROR | MB_TOPMOST); break; } if (Error==GL_NO_ERROR) break; } if (!wglMakeCurrent (NULL, NULL)) MessageBox(NULL, "Unable to deactivate DC and RC.", NULL, MB_OK | MB_ICONERROR); if (!wglDeleteContext(hRC) ) MessageBox(NULL, "Unable to release rendering context.", NULL, MB_OK | MB_ICONERROR); hRC=NULL; } // Device-Context zurückgeben. if (hDC) { if (!ReleaseDC(hWindow, hDC)) MessageBox(NULL, "Unable to release device context.", NULL, MB_OK | MB_ICONERROR); hDC=NULL; } // Fenster schließen. if (hWindow) { if (!DestroyWindow(hWindow)) MessageBox(NULL, "Unable to destroy window.", NULL, MB_OK | MB_ICONERROR); hWindow=NULL; } // Fensterklasse abmelden. Dabei zurückgegebene Fehlercodes ignorieren. UnregisterClass("CafuMain", hInstance); // Standard-Display wiederherstellen. if (FullScreen) { ChangeDisplaySettings(NULL, 0); ShowCursor(true); } #else // De-activate the invisible mouse cursor again (restore the previous visible cursor). XUndefineCursor(DisplayPtr, Win); // Turn on auto-repeat. // XAutoRepeatOn(DisplayPtr); // WARNING: Omitting the following line worked when this library was a static library. // When it became a shared library, the next call to glXMakeCurrent() caused a segmentation fault without this line. // That's strange. Probably it's just a driver bug on my machine, but I thought I'd better mention it... glXDestroyContext(DisplayPtr, RC); XCloseDisplay(DisplayPtr); #endif // OpenGLWindow geschlossen. WindowIsOpen=false; }
bool KWD::Decorator::x11EventFilter (XEvent *xevent) { KWD::Window *client; int status; switch (xevent->type) { case ConfigureNotify: { XConfigureEvent *xce = reinterpret_cast <XConfigureEvent *> (xevent); if (mFrames.contains (xce->window)) mFrames[xce->window]->updateFrame (xce->window); } break; case SelectionRequest: decor_handle_selection_request (QX11Info::display (), xevent, mDmSnTimestamp); break; case SelectionClear: status = decor_handle_selection_clear (QX11Info::display (), xevent, 0); if (status == DECOR_SELECTION_GIVE_UP) KApplication::exit (0); break; case CreateNotify: /* We only care about windows that aren't managed here */ if (!KWindowSystem::hasWId (xevent->xcreatewindow.window)) { WId select; KWD::trapXError (); XSelectInput (QX11Info::display (), xevent->xcreatewindow.window, StructureNotifyMask | PropertyChangeMask); KWD::popXError (); if (KWD::readWindowProperty (xevent->xcreatewindow.window, Atoms::switchSelectWindow, (long *) &select)) handleWindowAdded (xevent->xcreatewindow.window); } case PropertyNotify: if (xevent->xproperty.atom == Atoms::netInputFrameWindow) { handleWindowAdded (xevent->xproperty.window); } else if (xevent->xproperty.atom == Atoms::netOutputFrameWindow) { handleWindowAdded (xevent->xproperty.window); } else if (xevent->xproperty.atom == Atoms::compizShadowInfo || xevent->xproperty.atom == Atoms::compizShadowColor) { updateShadowProperties (xevent->xproperty.window); } else if (xevent->xproperty.atom == Atoms::switchSelectWindow) { WId id = xevent->xproperty.window; if (!mSwitcher || mSwitcher->xid () != id) handleWindowAdded (id); mSwitcher->update (); } else if (xevent->xproperty.atom == Atoms::netWmWindowOpacity) { if (mClients.contains (xevent->xproperty.window)) mClients[xevent->xproperty.window]->updateOpacity (); } break; case EnterNotify: { XCrossingEvent *xce = reinterpret_cast <XCrossingEvent *> (xevent); QWidget *child; if (!mFrames.contains (xce->window)) break; client = mFrames[xce->window]; if (!client->decorWidget ()) break; child = client->childAt (xce->x, xce->y); if (child) { QEvent qe (QEvent::Enter); QApplication::sendEvent (child, &qe); client->setActiveChild (child); client->updateCursor (QPoint (xce->x, xce->y)); } } break; case LeaveNotify: { XCrossingEvent *xce = reinterpret_cast <XCrossingEvent *> (xevent); if (mFrames.contains (xce->window)) { QEvent qe (QEvent::Leave); client = mFrames[xce->window]; if (client->activeChild ()) QApplication::sendEvent (client->activeChild (), &qe); XUndefineCursor (QX11Info::display (), client->frameId ()); } } break; case MotionNotify: { XMotionEvent *xme = reinterpret_cast <XMotionEvent *> (xevent); QWidget *child; if (!mFrames.contains (xme->window)) break; client = mFrames[xme->window]; if (!client->decorWidget ()) break; child = client->childAt (xme->x, xme->y); if (child) { QPoint qp (xme->x, xme->y); if (child != client->activeChild ()) { QEvent qee (QEvent::Enter); QEvent qle (QEvent::Leave); if (client->activeChild ()) QApplication::sendEvent (client->activeChild (), &qle); QApplication::sendEvent (child, &qee); client->setActiveChild (child); } if (client->decorWidget () != child) qp = child->mapFrom (client->decorWidget (), qp); QMouseEvent qme (QEvent::MouseMove, qp, Qt::NoButton, Qt::NoButton, Qt::NoModifier); QApplication::sendEvent (child, &qme); client->updateCursor (QPoint (xme->x, xme->y)); } } break; case ButtonPress: case ButtonRelease: { XButtonEvent *xbe = reinterpret_cast <XButtonEvent *> (xevent); QWidget *child; if (!mFrames.contains (xbe->window)) break; client = mFrames[xbe->window]; if (!client->decorWidget ()) break; child = client->childAt (xbe->x, xbe->y); if (child) { XButtonEvent xbe2 = *xbe; xbe2.window = child->winId (); QPoint p; p = client->mapToChildAt (QPoint (xbe->x, xbe->y)); xbe2.x = p.x (); xbe2.y = p.y (); p = child->mapToGlobal(p); xbe2.x_root = p.x (); xbe2.y_root = p.y (); client->setFakeRelease (false); QApplication::x11ProcessEvent ((XEvent *) &xbe2); /* We won't get a button release event, because of the screengrabs in compiz */ if (client->getFakeRelease () && xevent->type == ButtonPress) { xbe2.type = ButtonRelease; QApplication::x11ProcessEvent ((XEvent *) &xbe2); } return true; } } break; case ClientMessage: if (xevent->xclient.message_type == Atoms::toolkitActionAtom) { unsigned long action; action = xevent->xclient.data.l[0]; if (action == Atoms::toolkitActionWindowMenuAtom) { if (mClients.contains (xevent->xclient.window)) { QPoint pos; client = mClients[xevent->xclient.window]; if (xevent->xclient.data.l[2]) { pos = QPoint (xevent->xclient.data.l[3], xevent->xclient.data.l[4]); } else { pos = client->clientGeometry ().topLeft (); } client->showWindowMenu (pos); } } else if (action == Atoms::toolkitActionForceQuitDialogAtom) { if (mClients.contains (xevent->xclient.window)) { Time timestamp = xevent->xclient.data.l[1]; client = mClients[xevent->xclient.window]; if (xevent->xclient.data.l[2]) client->showKillProcessDialog (timestamp); else client->hideKillProcessDialog (); } } } break; default: break; } return KApplication::x11EventFilter (xevent); }
gboolean cb_show_pointer(GtkWidget *widget, GdkEvent *event, gpointer data) { XUndefineCursor(GDK_WINDOW_XDISPLAY(GTK_WIDGET(widget)->window), GDK_WINDOW_XWINDOW(GTK_WIDGET(widget)->window)); return TRUE; }
// Restores the mouse cursor // static void restoreCursor(_GLFWwindow* window) { XUngrabPointer(_glfw.x11.display, CurrentTime); XUndefineCursor(_glfw.x11.display, window->x11.handle); }
int main(int argc, char* argv[]) { Display* display; /* pointer to X Display structure. */ int screen_num; /* number of screen to place the window on. */ Window win; /* pointer to the newly created window. */ unsigned int display_width, display_height; /* height and width of the X display. */ unsigned int width, height; /* height and width for the new window. */ char *display_name = getenv("DISPLAY"); /* address of the X display. */ GC gc; /* GC (graphics context) used for drawing */ /* in our window. */ Cursor font_cursor, /* handles for the cursors we will create. */ icon_cursor; /* open connection with the X server. */ display = XOpenDisplay(display_name); if (display == NULL) { fprintf(stderr, "%s: cannot connect to X server '%s'\n", argv[0], display_name); exit(1); } /* get the geometry of the default screen for our display. */ screen_num = DefaultScreen(display); display_width = DisplayWidth(display, screen_num); display_height = DisplayHeight(display, screen_num); /* make the new window occupy 1/9 of the screen's size. */ width = (display_width / 3); height = (display_height / 3); printf("window width - '%d'; height - '%d'\n", width, height); /* create a simple window, as a direct child of the screen's */ /* root window. Use the screen's white color as the background */ /* color of the window. Place the new window's top-left corner */ /* at the given 'x,y' coordinates. */ win = create_simple_window(display, width, height, 0, 0); /* allocate a new GC (graphics context) for drawing in the window. */ gc = create_gc(display, win, 0); XSync(display, False); /* play with cursors... */ { /* this variable will contain the ID of the newly created pixmap. */ Pixmap bitmap; /* these variables will contain the dimensions of the loaded bitmap. */ unsigned int bitmap_width, bitmap_height; /* these variables will contain the location of the hotspot of the */ /* loaded bitmap. */ int hotspot_x, hotspot_y; /* load the bitmap found in the file "icon.bmp", create a pixmap */ /* containing its data in the server, and put its ID in the 'bitmap' */ /* variable. */ int rc = XReadBitmapFile(display, win, "icon.bmp", &bitmap_width, &bitmap_height, &bitmap, &hotspot_x, &hotspot_y); /* check for failure or success. */ switch (rc) { case BitmapOpenFailed: fprintf(stderr, "XReadBitmapFile - could not open file 'icon.bmp'.\n"); exit(1); break; case BitmapFileInvalid: fprintf(stderr, "XReadBitmapFile - file '%s' doesn't contain a valid bitmap.\n", "icon.bmp"); exit(1); break; case BitmapNoMemory: fprintf(stderr, "XReadBitmapFile - not enough memory.\n"); exit(1); break; } /* create a 'watch' cursor. */ font_cursor = XCreateFontCursor(display, XC_watch); /* attach this cursor to our window. */ XDefineCursor(display, win, font_cursor); XSync(display, False); /* make a short delay. */ sleep(3); /* detach this cursor from our window. */ XUndefineCursor(display, win); /* create a 'box' cursor. */ font_cursor = XCreateFontCursor(display, XC_box_spiral); /* attach this cursor to our window. */ XDefineCursor(display, win, font_cursor); XSync(display, False); /* make a short delay. */ sleep(3); /* detach this cursor from our window. */ XUndefineCursor(display, win); /* create a cursor out of our icon's pixmap. */ { /* first, define forground and background colors for the cursor. */ XColor cursor_fg, cursor_bg; /* access the default color map of our screen. */ Colormap screen_colormap = DefaultColormap(display, DefaultScreen(display)); /* allocate black and while colors. */ Status rc = XAllocNamedColor(display, screen_colormap, "black", &cursor_fg, &cursor_fg); if (rc == 0) { fprintf(stderr, "XAllocNamedColor - canot allocate 'black' !\n"); exit(1); } rc = XAllocNamedColor(display, screen_colormap, "white", &cursor_bg, &cursor_bg); if (rc == 0) { fprintf(stderr, "XAllocNamedColor - canot allocate 'white' !\n"); exit(1); } /* finally, generate the cursor. make the 'hot spot' be close to the */ /* top-left corner of the cursor - location (x=5, y=4). */ icon_cursor = XCreatePixmapCursor(display, bitmap, bitmap, &cursor_fg, &cursor_bg, 5, 4); } /* attach the icon cursor to our window. */ XDefineCursor(display, win, icon_cursor); XSync(display, False); /* make a short delay. */ sleep(4); /* detach this cursor from our window. */ XUndefineCursor(display, win); /* finally, free our icon pixmap. */ XFreePixmap(display, bitmap); } /* flush all pending requests to the X server. */ XFlush(display); /* make a delay for a short period. */ sleep(4); /* close the connection to the X server. */ XCloseDisplay(display); return(0); }
static void xskin_jobs( int pipe_in ) { XEvent e; int x,y; int window_x,window_y; int fspe=0; int pr=-1; int z; int p; int master_volume=0; char file_name[1024], tmp[1024]; int last_puttext_time; int last_window_x=-1, last_window_y=-1; int max_files; int i; fd_set fds; static struct timeval tv; Window t_w; unsigned int t_width, t_height, t_border, t_depth; xskin_pipe_write( "READY" ); shmid = shmget( IPC_PRIVATE, sizeof(char)*SPE_W, IPC_CREAT|0600 ); if ( shmid<0 ) xskin_pipe_write( "ERROR" ); else { sprintf( local_buf, "%d", shmid ); xskin_pipe_write( local_buf ); speana_buf = (unsigned char *)shmat( shmid, 0, 0 ); } xskin_pipe_read( local_buf, sizeof(local_buf) ); max_files = atoi( local_buf ); for ( i=0 ; i<max_files ; i++ ) { xskin_pipe_read( local_buf, sizeof(local_buf) ); } z=1; last_puttext_time=0; last_current_time=0; XGetGeometry( xskin_d, xskin_w, &t_w, &window_x, &window_y, &t_width, &t_height, &t_border, &t_depth ); while( z ) { XFlush( xskin_d ); FD_ZERO( &fds ); FD_SET( pipe_in, &fds ); tv.tv_sec=0; tv.tv_usec=20000L; /* 20 msec */ i=select( pipe_in+1, &fds, NULL, NULL, &tv ); if ( i!=0 ) { xskin_pipe_read( local_buf, sizeof(local_buf) ); switch (local_buf[0]) { case 'A': /* total time */ total_time=atoi( local_buf+2 ); last_current_time=0; last_puttext_time=0; break; case 'T': /* current time */ { int min,sec; sscanf( local_buf+2, "%02d:%02d", &min, &sec ); i=min*60+sec; if ( fremain==1 ) { sec =total_time-i; min =sec/60; sec-=min*60; } if ( i != last_current_time ) { ts_putnum( MIN_H_X, MIN_H_Y, min/10 ); ts_putnum( MIN_L_X, MIN_L_Y, min%10 ); ts_putnum( SEC_H_X, SEC_H_Y, sec/10 ); ts_putnum( SEC_L_X, SEC_L_Y, sec%10 ); p=100*i/total_time; play_val=ts_pos( OFF, -p ); last_current_time=i; if ( last_current_time - last_puttext_time == 3 ) { /* 3 sec */ sprintf( tmp, "%s [%02d:%02d]", file_name, total_time/60, total_time%60 ); ts_puttext( MESSAGE_X, MESSAGE_Y, tmp ); } } } break; case 'L': /* lylics/message */ ts_puttext( MESSAGE_X, MESSAGE_Y, local_buf+2 ); last_puttext_time=last_current_time; break; case 'F': /* filename */ strncpy( file_name, local_buf+2, 1023 ); file_name[1023]=0; break; case 'O': /* off the play button */ fplay=0; ts_play(OFF); ts_spectrum(fspe, NULL); /* erase spectrums */ break; case 'V': /* master volume */ master_volume=atoi( local_buf+2 ); p=100*((master_volume<200)?master_volume:200)/200; /* max:200% */ vol_val=ts_volume( OFF, -p ); break; case 'Q': /* quit */ z=1; break; case 'W': /* wave form */ ts_spectrum(fspe, speana_buf); break; default: break; } } if ( XPending( xskin_d )==0 ) continue; XNextEvent( xskin_d, &e ); switch ( e.type ) { /* case KeyPress: z=0; break; */ case Expose: repaint(); break; case EnterNotify: { Cursor cs; ts_titlebar(ON); cs = XCreateFontCursor( xskin_d, XC_top_left_arrow ); XDefineCursor( xskin_d, xskin_w, cs ); } break; case LeaveNotify: ts_titlebar(OFF); XUndefineCursor( xskin_d, xskin_w ); break; case MotionNotify: while( XCheckMaskEvent( xskin_d, Button1MotionMask, &e ) ) { XNextEvent( xskin_d, &e ); } x = e.xbutton.x; y = e.xbutton.y; switch( pr ) { /* case TS_POS: play_val=ts_pos( ON, x );break; */ case TS_VOLUME: vol_val=ts_volume( ON, x ); i=master_volume; master_volume=200*vol_val/100; sprintf( local_buf, "V %d", master_volume-i ); xskin_pipe_write( local_buf ); sprintf( tmp, " volume: %d%%", vol_val ); ts_puttext( MESSAGE_X, MESSAGE_Y, tmp ); last_puttext_time=last_current_time; break; /* case TS_PAN: pan_val=ts_pan( ON, x );break; */ default: if ( x != last_window_x || y != last_window_y ) { window_x += x-last_window_x; window_y += y-last_window_y; XMoveWindow( xskin_d, xskin_w, window_x, window_y ); } break; } break; case ButtonPress: x = e.xbutton.x; y = e.xbutton.y; last_window_x=x; last_window_y=y; if ( ISIN( x, y,EXITBUTTON_DX,EXITBUTTON_DY, EXITBUTTON_W,EXITBUTTON_H ) ) { ts_exitbutton(ON);pr=TS_EXITBUTTON; } else if ( ISIN( x, y, PREV_DX, PREV_DY, PREV_W, PREV_H ) ) { ts_prev(ON);pr=TS_PREV; } else if ( ISIN( x, y, PLAY_DX, PLAY_DY, PLAY_W, PLAY_H ) ) { ts_play(ON);pr=TS_PLAY; } else if ( ISIN( x, y, PAUSE_DX, PAUSE_DY, PAUSE_W, PAUSE_H ) ) { ts_pause(ON);pr=TS_PAUSE; } else if ( ISIN( x, y, STOP_DX, STOP_DY, STOP_W, STOP_H ) ) { ts_stop(ON);pr=TS_STOP; } else if ( ISIN( x, y, NEXT_DX, NEXT_DY, NEXT_W, NEXT_H ) ) { ts_next(ON);pr=TS_NEXT; } else if ( ISIN( x, y, EJECT_DX, EJECT_DY, EJECT_W, EJECT_H ) ) { ts_eject(ON);pr=TS_EJECT; } else if ( ISIN( x, y,164, 89, 47, 15 ) ) { /* shuffle */ if ( fshuf==0 ) { ts_shuf(OFFON);pr=TS_SHUFON; } else { ts_shuf(ONOFF);pr=TS_SHUFOFF; } } else if ( ISIN( x, y,210, 89, 28, 15 ) ) { /* repeat */ if ( frep==0 ) { ts_rep(OFFON);pr=TS_REPON; } else { ts_rep(ONOFF);pr=TS_REPOFF; } } else if ( ISIN( x, y,219, 58, 23, 12 ) ) { /* equalizer */ if ( fequ==0 ) { ts_equ(OFFON);pr=TS_EQUON; } else { ts_equ(ONOFF);pr=TS_EQUOFF; } } else if ( ISIN( x, y,242, 58, 23, 12 ) ) { /* playlist */ if ( fpll==0 ) { ts_plist(OFFON);pr=TS_PLISTON; } else { ts_plist(ONOFF);pr=TS_PLISTOFF; } } else if ( ISIN( x, y, MENUBUTTON_DX, MENUBUTTON_DY, MENUBUTTON_W, MENUBUTTON_H ) ) { ts_menubutton(ON);pr=TS_MENUBUTTON; } else if ( ISIN( x, y, ICONBUTTON_DX, ICONBUTTON_DY, ICONBUTTON_W, ICONBUTTON_H ) ) { ts_iconbutton(ON);pr=TS_ICONBUTTON; } else if ( ISIN( x, y, MINIBUTTON_DX, MINIBUTTON_DY, MINIBUTTON_W, MINIBUTTON_H ) ) { ts_minibutton(ON);pr=TS_MINIBUTTON; /* } else if ( ISIN( x, y,POS_MIN_DX+(POS_MAX_DX-POS_MIN_DX)*play_val/100, POS_DY, POS_W, POS_H ) ) { ts_pos( ON, -play_val );pr=TS_POS; */ } else if ( ISIN( x, y,VOL_MIN_DX+(VOL_MAX_DX-VOL_MIN_DX)*vol_val/100, VOL_DY, VOL_W, VOL_H ) ) { ts_volume( ON, -vol_val );pr=TS_VOLUME; sprintf( tmp, " volume: %d%%", vol_val ); ts_puttext( MESSAGE_X, MESSAGE_Y, tmp ); last_puttext_time=last_current_time; /* } else if ( ISIN( x, y,PAN_MIN_DX+(PAN_MAX_DX-PAN_MIN_DX)*pan_val/100, PAN_DY, PAN_W, PAN_H ) ) { ts_pan( ON, -pan_val );pr=TS_PAN; */ } else if ( ISIN( x, y, MIN_H_X, MIN_H_Y, SEC_L_X+NUM_W-MIN_H_X, NUM_H ) ) { int min,sec; fremain=(fremain==0)?1:0; sec=(fremain==0)?last_current_time:total_time-last_current_time; min =sec/60; sec-=min*60; ts_putnum( MIN_H_X, MIN_H_Y, min/10 ); ts_putnum( MIN_L_X, MIN_L_Y, min%10 ); ts_putnum( SEC_H_X, SEC_H_Y, sec/10 ); ts_putnum( SEC_L_X, SEC_L_Y, sec%10 ); } else if ( ISIN( x, y, SPE_SX, SPE_SY, SPE_W, SPE_H ) ) { pr=TS_SPECTRUM; } else { XRaiseWindow( xskin_d, xskin_w ); } break; case ButtonRelease: last_window_x = -1; last_window_y = -1; switch( pr ) { case TS_EXITBUTTON: ts_exitbutton(OFF); xskin_pipe_write("Q"); z=0;break; case TS_PREV: ts_prev(OFF); ts_spectrum( fspe, NULL ); xskin_pipe_write("B"); break; case TS_PLAY: xskin_pipe_write("P"); fplay=1; pauseOff(); ts_play(OFF);ts_pause(OFF); ts_pstate( PSTATE_PLAY ); break; case TS_PAUSE: ts_pause(OFF); if ( fplay ==1 ) { if ( fpause==0 ) { ts_pstate( PSTATE_PAUSE ); ts_spectrum( fspe, NULL ); pauseOn(); } else { ts_pstate( PSTATE_PLAY ); pauseOff(); } } break; case TS_STOP: pauseOff(); fplay=0; ts_pause(OFF);ts_play(OFF);ts_stop(OFF); ts_pstate( PSTATE_STOP ); ts_spectrum( fspe, NULL ); xskin_pipe_write("S"); break; case TS_NEXT: ts_next(OFF); ts_spectrum( fspe, NULL ); xskin_pipe_write("N"); break; case TS_EJECT: ts_eject(OFF);break; case TS_SHUFON: ts_shuf(ON);fshuf=1; fplay=1; pauseOff(); ts_pstate( PSTATE_PLAY ); xskin_pipe_write("D 1"); break; case TS_SHUFOFF: ts_shuf(OFF);fshuf=0; fplay=0; pauseOff(); ts_pstate( PSTATE_STOP ); ts_spectrum( fspe, NULL ); xskin_pipe_write("D 2"); break; case TS_REPON: ts_rep(ON);frep=1; xskin_pipe_write("R 1"); break; case TS_REPOFF: ts_rep(OFF);frep=0; xskin_pipe_write("R 0"); break; case TS_EQUON: ts_equ(ON);fequ=1;break; case TS_EQUOFF: ts_equ(OFF);fequ=0;break; case TS_PLISTON: ts_plist(ON);fpll=1;break; case TS_PLISTOFF: ts_plist(OFF);fpll=0;break; case TS_MENUBUTTON: ts_menubutton(OFF);break; case TS_ICONBUTTON: ts_iconbutton(OFF);break; case TS_MINIBUTTON: ts_minibutton(OFF);break; /* case TS_POS: ts_pos( OFF, -play_val );break; */ case TS_VOLUME: ts_volume( OFF, -vol_val );break; /* case TS_PAN: ts_pan( OFF, -pan_val );break; */ case TS_SPECTRUM: #ifdef SUPPORT_SOUNDSPEC fspe = (fspe+1)%3; if ( fspe==1 ) xskin_pipe_write("W"); /* on */ else if ( fspe==0 ) { xskin_pipe_write("W"); /* off */ ts_spectrum(0,speana_buf); } #endif /* SUPPORT_SOUNDSPEC */ break; default: break; } pr=-1; break; default: break; } } return; }
void dgaux_gauy_filter(float sigma){ int i,j,k,length_gaussian,length_deriv; float gaussian[SIZE1],deriv_gaussian[SIZE1]; matrix dgaux, dgaux_gauy, total_resul, m; float rmin,rmax,rng; /* Fill in the image with background color */ for(i=0; i<IMAGE_WIDTH; i++) for(j=0; j<IMAGE_HEIGHT; j++) XPutPixel(theXImage_2,i,j,bg); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_1),XtWindow(draw_2),0,0,0,0,True); /* Associate the watch cursor with the main window */ XDefineCursor(XtDisplay(draw_1), XtWindow(main_window), theCursor); /* Flush the request buffer and wait for all events */ /* and errors to be processed by the server. */ XSync(XtDisplay(draw_1), False); get_gaussian(sigma,gaussian,&length_gaussian); fprintf(stderr,"long de gaussian es %i \n",length_gaussian); for(i=0;i<=length_gaussian;i++) fprintf(stderr,"el gaussian de [%i] es %f \n",i,gaussian[i]); get_derigaussian(sigma,deriv_gaussian,&length_deriv); fprintf(stderr,"long de deriv gaussian es %i \n",length_deriv); for(i=0;i<=length_deriv;i++) fprintf(stderr,"el deriv_gaussian de [%i] es %f \n",i,deriv_gaussian[i]); for(i=0;i<IMAGE_WIDTH;i++) for(j=0;j<IMAGE_HEIGHT;j++) m[i][j]= XGetPixel(theXImage_1,i,j); /* calculates the convolution of the image with the derivative of a */ /* gaussian for the rows */ convo_vectorx(m,deriv_gaussian,length_deriv,&rmax,&rmin,dgaux); /* calculate the smoothing of a gaussian(x) in y direction.*/ convo_vectory(dgaux,gaussian,length_gaussian,&rmax,&rmin, dgaux_gauy); fprintf(stderr,"Maximum is %f, Minimum is %f\n",rmax,rmin); rng=(rmax-rmin); for(i=0;i<IMAGE_WIDTH;i++) for(j=0;j<IMAGE_HEIGHT;j++) total_resul[i][j]=sqrt(pow(dgaux_gauy[i][j],2)); for(i=0;i<IMAGE_WIDTH;i++) for(j=0;j<IMAGE_HEIGHT;j++) XPutPixel(theXImage_2,i,j,(unsigned long) (((float)(total_resul[i][j]-rmin)/rng)*255.0)); /* Copy image into pixmap */ XPutImage(XtDisplay(draw_2), thePixmap_2,image_gc_2, theXImage_2, 0, 0, 0, 0, theXImage_2->width, theXImage_2->height); /* Disassociate the watch cursor from the main window */ XUndefineCursor(XtDisplay(draw_1), XtWindow(main_window)); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_2),XtWindow(draw_2),0,0,0,0,True); }