void mvpw_hide(mvp_widget_t *widget) { mvp_widget_t *top; if (widget) { if (widget == modal_focus) { if ((widget->below->type == MVPW_DIALOG) && widget->below->data.dialog.modal) { modal_focus = widget->below; } else { modal_focus = NULL; } } GrUnmapWindow(widget->wid); if(widget->show) (*widget->show)(widget, 0); if ((top=widget->below)) widget->below->above = widget->above; if (widget->above) { top = widget->above; widget->above->below = widget->below; } if (modal_focus) { GrSetFocus(modal_focus->wid); } else if ((widget->above == NULL) && top) { GrSetFocus(top->wid); } widget->below = NULL; widget->above = NULL; } }
static void GrSetFocusWrapper(void *r) { nxSetFocusReq *req = r; GrSetFocus(req->windowid); }
int XSetInputFocus(Display *dpy, Window focus, int revert_to, Time time) { printf("SetInputFocus %d\n", focus); GrSetFocus(focus); return 1; }
static void raise_widget(mvp_widget_t *widget, mvp_widget_t *top) { int wid; if (widget) { if (top == NULL) { wid = GrGetFocus(); top = find_widget(wid); } if (top == widget) return; if (widget->below) widget->below->above = widget->above; if (widget->above) widget->above->below = widget->below; widget->below = top; widget->above = NULL; if (top) { top->above = widget; } GrSetFocus(widget->wid); } }
static int incall_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux) { printf("EVENT: Incoming call type = %u\n", aux->u.call.type); GrMapWindow(dialer_window); GrSetFocus(dialer_window); GrText(dialer_window, gc, 10, 10, "Incoming call", 0, 0); return 0; }
int NX_LeaveFullScreen (_THIS) { if (currently_fullscreen) { GrUnmapWindow (FSwindow) ; GrMapWindow (SDL_Window) ; GrRaiseWindow (SDL_Window) ; GrSetFocus (SDL_Window) ; currently_fullscreen = 0 ; } return 0 ; }
int NX_EnterFullScreen (_THIS) { if (! currently_fullscreen) { GR_SCREEN_INFO si ; GrGetScreenInfo (& si) ; GrResizeWindow (FSwindow, si.cols, si.rows) ; GrUnmapWindow (SDL_Window) ; GrMapWindow (FSwindow) ; GrRaiseWindow (FSwindow) ; GrSetFocus (FSwindow) ; currently_fullscreen = 1 ; } return 1 ; }
CRJinkeScreen( int width, int height ) : CRGUIScreenBase( width, height, true ) { if( GrOpen() < 0 ) { fprintf(stderr, "Couldn't connect to Nano-X server\n"); return; } GR_WM_PROPERTIES props; //GR_SCREEN_INFO si; //GrGetScreenInfo(&si); _wid = GrNewWindow(GR_ROOT_WINDOW_ID,VIEWER_WINDOW_X,VIEWER_WINDOW_Y, VIEWER_WINDOW_WIDTH,VIEWER_WINDOW_HEIGHT, 0, GR_COLOR_WHITE, 0); _gc = GrNewGC(); GrSetGCForeground(_gc, GR_COLOR_BLACK); GrSetGCBackground(_gc, GR_COLOR_WHITE); GrSelectEvents(_wid, GR_EVENT_MASK_BUTTON_DOWN | \ GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_MOUSE_POSITION |\ GR_EVENT_MASK_EXPOSURE |GR_EVENT_MASK_KEY_UP|\ GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_CLOSE_REQ); //Set Windows style props.flags = GR_WM_FLAGS_PROPS; props.props = GR_WM_PROPS_NODECORATE; GrSetWMProperties(_wid, &props); //#ifndef USE_OLD_NANOX GrMapWindow(_wid); GrSetFocus(_wid); //#endif _canvas = LVRef<LVDrawBuf>( new LVGrayDrawBuf( _width, _height, GRAY_BACKBUFFER_BITS ) ); _front = LVRef<LVDrawBuf>( new LVGrayDrawBuf( _width, _height, GRAY_BACKBUFFER_BITS ) ); _canvas->Clear(0xFFFFFF); //_front->Clear(0xFFFFFF); _front->Clear(0x000000); instance = this; }
static void _nxDelPropData(struct window_props *prop) { /* delete XA_WM_TRANSIENT_FOR data*/ if ((prop->property == XA_WM_TRANSIENT_FOR) && prop->data) { Window prop_window = *((Window*)prop->data); GR_WM_PROPERTIES props; GrGetWMProperties(prop_window, &props); if (props.title) free(props.title); props.flags = GR_WM_FLAGS_PROPS; props.props &= ~(GR_WM_PROPS_NORAISE | GR_WM_PROPS_NOMOVE | GR_WM_PROPS_NOFOCUS); GrSetWMProperties(prop_window, &props); GrSetFocus(prop_window); } if (prop->data) Xfree(prop->data); Xfree(prop); }
void wm_container_buttondown(win *window, GR_EVENT_BUTTON *event) { struct pos_size *pos; GR_RECT r; GR_COORD cxborder = 0, cyborder = 0; GR_WINDOW_INFO info; GR_WINDOW_INFO cinfo; GR_GC_ID gc; Dprintf("wm_container_buttondown window %d\n", window->wid); if(window->active) return; GrGetWindowInfo(window->wid, &info); GrGetWindowInfo(window->clientid, &cinfo); /* calc border sizes*/ if (info.props & GR_WM_PROPS_BORDER) { cxborder = 1; cyborder = 1; } if (info.props & GR_WM_PROPS_APPFRAME) { cxborder = CXBORDER; cyborder = CYBORDER; } /* Check for close box press*/ if ((info.props & (GR_WM_PROPS_CAPTION|GR_WM_PROPS_CLOSEBOX)) == (GR_WM_PROPS_CAPTION|GR_WM_PROPS_CLOSEBOX)) { /* Get close box rect*/ r.x = info.width - CXCLOSEBOX - cxborder - 2; r.y = cyborder + 2; r.width = CXCLOSEBOX; r.height = CYCLOSEBOX; /* Check mousedn in close box*/ if (PtInRect(&r, event->x, event->y)) { /* close on button up*/ window->close = GR_TRUE; return; } } /* * Set focus to the window only if client * or the container itself is clicked. * if any of the children (of the client) * are clicked better not take the focus * away from them. They might require handling * the focus themself. * -- Amit Kulkarni */ if(window->wid==event->subwid) GrSetFocus(window->wid); /* check for corner resize */ r.x = info.width - 5; r.y = info.height - 5; r.width = 5; r.height = 5; if (PtInRect(&r,event->x, event->y) && !(info.props & GR_WM_PROPS_NORESIZE) && !(cinfo.props & GR_WM_PROPS_NORESIZE)) { #if !NO_CORNER_RESIZE struct pos_size * pos; if(!window->data) if(!(window->data = malloc(sizeof(struct pos_size)))) return; window->sizing = GR_TRUE; /* save off the width/height offset from the window manager */ GrGetWindowInfo(window->clientid,&info); pos = (struct pos_size*)window->data; pos->xoff = -info.width; pos->yoff = -info.height; GrGetWindowInfo(window->wid,&info); pos->xoff += info.width; pos->yoff += info.height; gc = GrNewGC(); GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN); GrRect(GR_ROOT_WINDOW_ID,gc,info.x, info.y, info.width, info.height); GrDestroyGC(gc); /* save this rectangle's width/height so we can erase it later */ pos->width = info.width; pos->height = info.height; pos->xorig = event->x; pos->yorig = event->y; /* * This window is being resized. * The client should have focus now. * -- Amit Kulkarni */ GrSetFocus(window->clientid); return; #endif /* !NO_CORNER_RESIZE*/ } else GrSetWindowCursor(window->wid, 0); /* if not in caption, return (FIXME, not calc'd exactly)*/ if (!(info.props & GR_WM_PROPS_CAPTION)) return; /* Get caption box rect*/ r.x = cxborder; r.y = cyborder; r.width = info.width - cxborder*2; r.height = CYCAPTION; /* Check for mousedn in caption box*/ if (!PtInRect(&r, event->x, event->y)) return; /* * Now we have a click on the caption. * So window is active. * Set focus to the client * --Amit Kulkarni */ GrSetFocus(window->clientid); /* Raise window if mouse down and allowed*/ if (!(info.props & GR_WM_PROPS_NORAISE) && !(cinfo.props & GR_WM_PROPS_NORAISE)) GrRaiseWindow(window->wid); /* Don't allow window move if NOMOVE property set*/ if ((info.props & GR_WM_PROPS_NOMOVE) || (cinfo.props & GR_WM_PROPS_NOMOVE)) return; if(!window->data) if(!(window->data = malloc(sizeof(struct pos_size)))) return; GrGetWindowInfo(window->wid,&info); pos = (struct pos_size *)window->data; pos->xoff = event->x; pos->yoff = event->y; #if OUTLINE_MOVE pos->xorig = info.x; pos->yorig = info.y; pos->width = info.width; pos->height = info.height; gc = GrNewGC(); GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN); GrRect(GR_ROOT_WINDOW_ID, gc,info.x, info.y, info.width, info.height); GrDestroyGC(gc); #endif window->active = GR_TRUE; }
int main(int ac,char **av) { GR_WINDOW_ID w; GR_GC_ID gc; GR_FONT_ID font; GR_WINDOW_INFO wi; if (GrOpen() < 0) { GrError("Can't open graphics\n"); return 1; } //w = GrNewWindowEx(GR_WM_PROPS_APPWINDOW|GR_WM_PROPS_NOBACKGROUND, "Nano-X Demo2", //GR_ROOT_WINDOW_ID, 20, 20, 320, 240, BLACK); w = GrNewWindowEx(GR_WM_PROPS_BORDER|GR_WM_PROPS_NOBACKGROUND, "Nano-X Demo2", GR_ROOT_WINDOW_ID, 20, 20, 320, 240, BLACK); gc = GrNewGC(); //font = GrCreateFontEx("lubI24.pcf", 0, 0, NULL); font = GrCreateFontEx("helvB12.pcf.gz", 0, 0, NULL); GrSetGCFont(gc, font); GrSelectEvents(w, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP); GrMapWindow(w); GrSetFocus(w); // pass errors through main loop GrSetErrorHandler(NULL); for (;;) { GR_EVENT event; GrGetNextEvent(&event); switch (event.type) { case GR_EVENT_TYPE_EXPOSURE: GrSetGCForeground(gc,GrGetSysColor(GR_COLOR_APPWINDOW)); GrFillRect(w, gc, event.exposure.x, event.exposure.y, event.exposure.width, event.exposure.height); GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPTEXT)); GrSetGCUseBackground(gc, GR_FALSE); GrText(w, gc, 10, 30, "Hello World", -1, GR_TFASCII); GrRect(w, gc, 5, 5, 300, 60); GrGetWindowInfo(w, &wi); GrError("Exposure:wi.width:%d,wi.height:%d,wi.x:%d,wi.y:%d,wi.parent:%d\n",wi.width,wi.height,wi.x,wi.y,wi.parent); break; case GR_EVENT_TYPE_BUTTON_DOWN: // FIXME unmap window is broken GrUnmapWindow(w); GrFlush(); GrMapWindow(w); //uncomment to test server error on bad syscall //GrMoveWindow(GR_ROOT_WINDOW_ID, 0, 0); GrGetWindowInfo(w, &wi); GrError("Button: wi.width:%d,wi.height:%d,wi.x:%d,wi.y:%d,wi.parent:%d\n",wi.width,wi.height,wi.x,wi.y,wi.parent); break; case GR_EVENT_TYPE_ERROR: GrError("demo2: Error (%s) ", event.error.name); GrError(nxErrorStrings[event.error.code], event.error.id); break; case GR_EVENT_TYPE_CLOSE_REQ: GrClose(); return 0; } } return 0; }
int XSetInputFocus(Display* display, Window focus, int revert_to, Time time) { GrSetFocus(focus); return Success; }
int main(int ac,char **av) { GR_WINDOW_ID w, w2; GR_GC_ID gc; GR_EVENT event; GR_WM_PROPERTIES props; if (GrOpen() < 0) { printf("Can't open graphics\n"); exit(1); } /* pass errors through main loop*/ GrSetErrorHandler(NULL); #define WIDTH 320 #define HEIGHT 240 w = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, WIDTH, HEIGHT, 0, GREEN, BLACK); w2 = GrNewWindow(w, 20, 20, 40, 40, 0, WHITE, BLACK); props.flags = GR_WM_FLAGS_PROPS | GR_WM_FLAGS_TITLE; props.props = GR_WM_PROPS_NOBACKGROUND; props.title = "Nano-X Demo2"; GrSetWMProperties(w, &props); gc = GrNewGC(); GrSelectEvents(w, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP); GrMapWindow(w); GrSetFocus(w); /* serious bug here: when wm running, w2 is mapped anyway!!*/ /*GrMapWindow(w2);*/ for (;;) { /*GR_EVENT_KEYSTROKE *kev;*/ GrGetNextEvent(&event); switch (event.type) { case GR_EVENT_TYPE_EXPOSURE: GrSetGCForeground(gc,GrGetSysColor(GR_COLOR_APPWINDOW)); GrFillRect(w, gc, event.exposure.x, event.exposure.y, event.exposure.width, event.exposure.height); GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPTEXT)); GrSetGCUseBackground(gc, GR_FALSE); GrText(w, gc, 10, 30, "Hello World", -1, GR_TFASCII); GrRect(w, gc, 5, 5, 300, 60); break; case GR_EVENT_TYPE_CLOSE_REQ: GrClose(); exit(0); break; case GR_EVENT_TYPE_ERROR: printf("\7demo2: Error (%s) ", event.error.name); printf(nxErrorStrings[event.error.code],event.error.id); break; #if 0 case GR_EVENT_TYPE_BUTTON_DOWN: /* test server error on bad syscall*/ GrMapWindow(w2); GrMoveWindow(GR_ROOT_WINDOW_ID, 0, 0); { GR_SCREEN_INFO sinfo; GrGetScreenInfo(&sinfo); } break; #endif #if 0 case GR_EVENT_TYPE_KEY_DOWN: kev = (GR_EVENT_KEYSTROKE *)&event; printf("DOWN %d (%04x) %04x\n", kev->ch, kev->ch, kev->modifiers); break; case GR_EVENT_TYPE_KEY_UP: kev = (GR_EVENT_KEYSTROKE *)&event; printf("UP %d (%04x) %04x\n", kev->ch, kev->ch, kev->modifiers); break; #endif } } GrClose(); return 0; }