/*********************************************************************** * * Procedure: * Process message - examines packet types, and takes appropriate action * ***********************************************************************/ void process_message(unsigned long type,unsigned long *body) { switch(type) { case M_CONFIGURE_WINDOW: if(!find_window(body[0])) add_window(body[0],body); break; case M_WINDOW_NAME: { struct list *l; if ((l = find_window(body[0])) != 0) { l->name = (char *)safemalloc(strlen((char *)&body[3])+1); strcpy(l->name,(char *)&body[3]); } } break; case M_NEW_PAGE: list_new_page(body); break; case M_NEW_DESK: CurDesk = (long)body[0]; break; case M_END_WINDOWLIST: do_save(); break; default: break; } }
static XEN g_window_property(XEN winat, XEN name) { #define H_window_property "(" S_window_property " win-name name): get or set the window property." Window window; Display *dpy; Atom type = None; int format; unsigned long len, bytesafter; unsigned char *data[1]; XEN result = XEN_FALSE; XEN_ASSERT_TYPE(XEN_STRING_P(winat), winat, XEN_ARG_1, S_window_property, "a string"); XEN_ASSERT_TYPE(XEN_STRING_P(name), name, XEN_ARG_2, S_window_property, "a string"); dpy = MAIN_DISPLAY(ss); if (((window = find_window(dpy, DefaultRootWindow(dpy), XEN_TO_C_STRING(winat), compare_window))) && ((XGetWindowProperty(dpy, window, XInternAtom(dpy, XEN_TO_C_STRING(name), 0), 0L, (long)BUFSIZ, False, XA_STRING, &type, &format, &len, &bytesafter, (unsigned char **)data)) == Success) && (type != None) && (len > 0)) { if (type == XA_STRING) result = C_TO_XEN_STRING((char *)data[0]); else result = C_TO_XEN_STRINGN((char *)data[0], len * format / 8); if (data[0]) XFree((char *)(data[0])); } return(result); }
void do_update(GR_EVENT_UPDATE *event) { win *window; Dprintf("do_update: wid %d, subwid %d, x %d, y %d, width %d, height %d, " "utype %d\n", event->wid, event->subwid, event->x, event->y, event->width, event->height, event->utype); if(!(window = find_window(event->subwid))) { if (event->utype == GR_UPDATE_MAP) new_client_window(event->subwid); return; } if(window->type == WINDOW_TYPE_CONTAINER) { if (event->utype == GR_UPDATE_ACTIVATE) redraw_ncarea(window); return; } if(window->type != WINDOW_TYPE_CLIENT) return; if(event->utype == GR_UPDATE_DESTROY) client_window_destroy(window); }
void mdm_wm_move_window_now (Window window, int x, int y) { MdmWindow *gw; trap_push (); gw = find_window (window, TRUE); if (gw == NULL) { XMoveWindow (wm_disp, window, x, y); XSync (wm_disp, False); trap_pop (); return; } if (gw->deco != None) XMoveWindow (wm_disp, gw->deco, x - 1, y - 1); else XMoveWindow (wm_disp, gw->win, x, y); if (gw->shadow != None) XMoveWindow (wm_disp, gw->deco, x + 4, y + 4); XSync (wm_disp, False); trap_pop (); }
static void bufed_select(EditState *s, int temp) { BufedState *bs = s->mode_data; StringItem *item; EditBuffer *b; EditState *e; int index; index = list_get_pos(s); if (index < 0 || index >= bs->items.nb_items) return; if (temp && index == bs->last_index) return; item = bs->items.items[index]; b = eb_find(item->str); if (!b) return; e = find_window(s, KEY_RIGHT); if (temp) { if (e) { bs->last_index = index; switch_to_buffer(e, b); } return; } if (e) { /* delete dired window */ do_delete_window(s, 1); switch_to_buffer(e, b); } else { switch_to_buffer(s, b); } }
char * term_minibuf_read (const char *prompt, const char *value, size_t pos, Completion * cp, History * hp) { Window *wp, *old_wp = cur_wp; char *s = NULL; astr as; if (hp) prepare_history (hp); as = do_minibuf_read (prompt, value, pos, cp, hp); if (as) { s = xstrdup (astr_cstr (as)); astr_delete (as); } if (cp != NULL && (get_completion_flags (cp) & CFLAG_POPPEDUP) && (wp = find_window ("*Completions*")) != NULL) { set_current_window (wp); if (get_completion_flags (cp) & CFLAG_CLOSE) FUNCALL (delete_window); else if (get_completion_old_bp (cp)) switch_to_buffer (get_completion_old_bp (cp)); set_current_window (old_wp); } return s; }
static Window find_window_focused(Window top, char* name) { int tmp; Window w; Window cur; Window* children; Window foo; unsigned int n; /* return the currently focused window if it is a direct match or a * subwindow of the named window */ w = find_window(top, name); if (w) { XGetInputFocus(dpy, &cur, &tmp); log_debug("current window: 0x%x named window: 0x%x\n", cur, w); if (w == cur) { /* window matched */ return cur; } else if (XQueryTree(dpy, w, &foo, &foo, &children, &n) && children != NULL) { /* check all the sub windows of named window */ for (; n > 0; n--) { if (children[n - 1] == cur) { XFree(children); return cur; } } XFree(children); } } return 0; }
void about() { FC_TABLE c = {0,RGB555(31,31,0),RGB555(28,28,28),RGB555(24,24,24),RGB555(20,20,20)}; FC_TABLE c2= {0,RGB555(31,16,0),RGB555(28,16,0),RGB555(24,16,0),RGB555(20,16,0)}; FC_TABLE c3= {0,RGB555(0,24,0),RGB555(0,20,0),RGB555(0,16,0),RGB555(0,10,0)}; static about_win = -1; if (find_window(about_win) == NULL) { about_win = def_window(300,200,"About"); waktual->x = 320-150; waktual->y = 140; memcpy(f_default,flat_color(0x0),sizeof(FC_TABLE)); waktual->modal = 1; default_font = vga_font; define(-1,5,25,29,29,0,dtext,"\x8");property(NULL,icones,&c,WINCOLOR); define(-1,75,25,100,29,0,dtext,"MAPEDIT");property(NULL,NULL,&c2,WINCOLOR); define(-1,200,35,60,29,0,label,"verze 2.0");property(NULL,NULL,&c3,WINCOLOR); define(-1,20,80,200,10,0,label,"Naps no pro hru \"Br ny Skeldalu\""); define(-1,20,92,200,10,0,label,"(C) 1997 Napoleon gameS "); define(-1,20,104,200,10,0,label,"Naprogamoval: Ond©ej Nov k "); define(-1,20,116,200,10,0,label,"Tento software sm¡ b˜t pou‘it jen"); define(-1,20,128,200,10,0,label,"ve spojen¡ s v˜vojem hry \"Br ny"); define(-1,20,140,200,10,0,label,"Skeldalu\" (a p©¡padn‚ dal¨¡ verze)"); define(-1,20,152,200,10,0,label,"a to pouze ‡leny v˜vojov‚ho t˜mu."); define(10,110,170,80,20,0,button,"Ok");on_change(close_test); } else select_window(about_win); redraw_window(); }
bool send_mozilla(const char *html_viewer, const char *url) { Window window; Display *dpy; char *command; dpy = MAIN_DISPLAY(ss); command = (char *)CALLOC(snd_strlen(url) + snd_strlen(html_viewer) + 32, sizeof(char)); window = find_window(dpy, DefaultRootWindow(dpy), NS_VERSION, compare_window); if (window) { sprintf(command, "openURL(file:%s)", url); XChangeProperty(dpy, window, XInternAtom(dpy, NS_COMMAND, 0), XA_STRING, 8, PropModeReplace, (unsigned char *)command, strlen(command) + 1); XFlush(dpy); } else { if (!(fork())) { sprintf(command, "%s file:%s", html_viewer, url); if (execl("/bin/sh", "/bin/sh", "-c", command, NULL) == -1) { FREE(command); return(false); } } } FREE(command); return(true); }
static riftwin_t * add_window(riftwm_t *wm, Window window) { riftwin_t *win; // Check whether the window is already managed by us if (!(win = find_window(wm, window))) { win = (riftwin_t*)malloc(sizeof(riftwin_t)); memset(win, 0, sizeof(riftwin_t)); win->window = window; win->next = wm->windows; win->dirty = 1; win->mapped = 0; win->focused = 1; win->pos[0] = 0.0f; win->pos[1] = 0.0f; win->pos[2] = 5.0f; wm->windows = win; wm->window_count++; } return win; }
int save_all_map(void) { int x,y,z; char info[160]; char *txt; if ((z=check_map(&x,&y))!=0) { WINDOW *w; unselect_map(); if ((w=find_window(tool_bar))!=NULL) close_window(w); tool_sel=30; create_map_win(-1); open_sector_win(); jdi_na_sektor(x); } sprintf(info,"Chyba %02d na pozici %d:%d",-z,x,y); switch (z) { case -1:msg_box(info,'\01',"Chyb� definice st�ny!","OK",NULL);break; case -2:msg_box(info,'\01',"Chodba vede do neexistuj�c�ho sektoru!","OK",NULL);break; case -3:msg_box(info,'\01',"Schody jsou �patn� spojen� se sousedn�m� sektory!","OK",NULL);break; case -4:msg_box(info,'\01',"Ud�lost v neexistuj�c�m sektoru!","OK",NULL);break; } if (!backup) { create_backup(filename); create_backup(SHOP_NAME); create_backup(ITEMS_DAT); create_backup(MOB_FILE); create_backup(MOB_SOUND); backup=1; } if (save_map(filename)) { sprintf(info,"Nedok��u ulo�it soubor %s.",filename); msg_box("Chyba I/O",'\01',info,"!Panika!",NULL); } else txt=pripona(filename,TXT); save_items(); if (_access(txt,0)!=0) { FILE *f; f=fopen(txt,"w"); if (f) { fputs("-1\n",f); fclose(f); } } if (!mglob.local_monsters) { save_mobs(); save_sound_map(); } save_all_shops(); validate_sound_map(); return z; }
void movesize_test() { WINDOW *w; w = find_window(map_win); if (w == NULL) return; movesize_win(w,0,0,100,100); redraw_desktop(); }
Window find_window(Window top,char *name) { char *wname,*iname; XClassHint xch; Window *children,foo; int revert_to_return; unsigned int nc; if (!strcmp(active_window_name,name)){ XGetInputFocus(dpy, &foo, &revert_to_return); return(foo); } /* First the base case */ if (XFetchName(dpy,top,&wname)){ if (!strncmp(wname,name,strlen(name))) { XFree(wname); debugprintf("found it by wname %x \n",top); return(top); /* found it! */ }; XFree(wname); }; if(XGetIconName(dpy,top,&iname)){ if (!strncmp(iname,name,strlen(name))) { XFree(iname); debugprintf("found it by iname %x \n",top); return(top); /* found it! */ }; XFree(iname); }; if(XGetClassHint(dpy,top,&xch)) { if(!strcmp(xch.res_class,name)) { XFree(xch.res_name); XFree(xch.res_class); debugprintf("res_class '%s' res_name '%s' %x \n", xch.res_class,xch.res_name,top); return(top); /* found it! */ }; if(!strcmp(xch.res_name,name)) { XFree(xch.res_name); XFree(xch.res_class); debugprintf("res_class '%s' res_name '%s' %x \n", xch.res_class,xch.res_name,top); return(top); /* found it! */ }; XFree(xch.res_name); XFree(xch.res_class); }; if(!XQueryTree(dpy,top,&foo,&foo,&children,&nc) || children==NULL) { return(0); /* no more windows here */ }; /* check all the sub windows */ for(;nc>0;nc--) { top = find_window(children[nc-1],name); if(top) break; /* we found it somewhere */ }; if(children!=NULL) XFree(children); return(top); }
void mdm_wm_save_wm_order (void) { Window *children = NULL; Window xparent, xroot; guint size = 0; int dlen = 0; unsigned long *data; gdk_flush (); XSync (wm_disp, False); trap_push (); XGrabServer (wm_disp); if (XQueryTree (wm_disp, wm_root, &xroot, &xparent, &children, &size)) { int i; Atom atom; data = g_new0 (unsigned long, size); for (i = 0; i < size; i++) { MdmWindow *gw = find_window (children[i], TRUE); /* Ignore unknowns and shadows */ if (gw == NULL || gw->shadow == children[i]) continue; if (gw->win == wm_login_window) { /* Empty spot in the list signifies the * login window */ data [dlen++] = None; } else { data [dlen++] = gw->win; } } atom = XInternAtom (wm_disp, "MDMWM_WINDOW_ORDER", False); XChangeProperty (wm_disp, wm_root, atom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, dlen); if (children != NULL) XFree (children); g_free (data); }
Buffer window_get_buffer(Window window, Error *err) { win_T *win = find_window(window, err); if (!win) { return 0; } return win->w_buffer->handle; }
int clm_send_snd(char *command) { Window window; if (dpy == NULL) clm_init_x("?"); if ((window = find_window(dpy, DefaultRootWindow(dpy), snd_v, compare_window))) { XChangeProperty(dpy, window, snd_c, XA_STRING, 8, PropModeReplace, (unsigned char *)command, strlen(command) + 1); XFlush(dpy); return(0); } return(-1); }
static void select_window (GdkWindow *window) { GtkTreeSelection *selection; GtkTreeIter iter; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); if (window != NULL && find_window (window, &iter)) gtk_tree_selection_select_iter (selection, &iter); }
static Window find_sub_window(Window top, char* name, int* x, int* y) { Window base; Window* children; Window foo; Window target = 0; int rel_x, rel_y, new_x = 1, new_y = 1; unsigned int nc, width, height, border, depth, targetsize = 1000000; base = find_window(top, name); if (!base) return base; ; if (!XQueryTree(dpy, base, &foo, &foo, &children, &nc) || children == NULL) return base; /* no more windows here */ ; log_debug("found subwindows %d\n", nc); /* check if we hit a sub window and find the smallest one */ for (; nc > 0; nc--) { if (XGetGeometry(dpy, children[nc - 1], &foo, &rel_x, &rel_y, &width, &height, &border, &depth)) { if ((rel_x <= *x) && (*x <= (int) (rel_x + width)) && (rel_y <= *y) && (*y <= (int) (rel_y + height))) { log_debug("found a subwindow 0x%x +%d +%d %d x %d\n", children[nc - 1], rel_x, rel_y, width, height); if ((width * height) < targetsize) { target = children[nc - 1]; targetsize = width * height; new_x = *x - rel_x; new_y = *y - rel_y; /*bull's eye ... */ target = find_sub_sub_window(target, &new_x, &new_y); } } } } ; if (children != NULL) XFree(children); if (target) { *x = new_x; *y = new_y; return target; } else { return base; } }
static Window find_window(Display *display, Window starting_window, Atom id, Window (*compare_func)()) { Window rootwindow, window_parent; int i = 0; unsigned int num_children = 0; Window *children = NULL; Window window = (compare_func)(display, starting_window, id); if (window != (Window)None)return (window); if ((XQueryTree(display, starting_window, &rootwindow, &window_parent, &children, &num_children)) == 0) return ((Window)None); while ((i < num_children) && (window == (Window)None)) window = find_window(display, children[i++], id, compare_func); if (children) XFree((char *)children); return(window); }
int fb_ConsoleMultikey( int scancode ) { int i; if ( find_window() != GetForegroundWindow() ) return FB_FALSE; for( i = 0; __fb_keytable[i][0]; i++ ) { if( __fb_keytable[i][0] == scancode ) { return ((GetAsyncKeyState(__fb_keytable[i][1]) | GetAsyncKeyState(__fb_keytable[i][2])) & 0x8000) ? FB_TRUE : FB_FALSE; } } return FB_FALSE; }
void w_redraw_all(Window win) { WINDOW_DESCR *wd; int kind; XWindowAttributes xwa; if ((wd = find_window(win, &kind))) { XGetWindowAttributes(_wndh_gl.display, wd->user_window, &xwa); XClearWindow(_wndh_gl.display, wd->user_window); (wd->redraw)(wd->user_window, xwa.x, xwa.y, xwa.width, xwa.height, wd->slider_xpos, wd->slider_ypos); } else fprintf(stderr, "wndhndlr: w_redraw_all: Warning: Window not found\n"); }
void do_mouse_exit(GR_EVENT_GENERAL *event) { win *window; Dprintf("do_mouse_exit: wid %d\n", event->wid); if(!(window = find_window(event->wid))) return; switch(window->type) { default: printf("Unhandled mouse exit from window %d " "(type %d)\n", window->wid, window->type); break; } }
void TEST_find_window() { char *routine = "TEST_find_window"; printf(testing, routine); //Note that this fails when run in Eclipse... Window active = active_window(); char *name = window_name(active); if(name == NULL) { printf("Aborting %s - conditions are invalid\n", routine); return; } Window found = find_window(name); assert(found == active); free(name); printf(done, routine); }
int WindowHelper_Maximize (guint32 pid) { GSList *windows = NULL; LOG_HARNESS ("[%i shocker] WindowHelper_Maximize (%i)\n", getpid (), pid); find_window (pid, &windows); if (windows != NULL) { Window window; XEvent xev; memset (&xev, 0, sizeof (XEvent)); Display *display = XOpenDisplay (NULL); Atom _NET_WM_STATE = XInternAtom (display, "_NET_WM_STATE", True); Atom _NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom (display, "_NET_WM_STATE_MAXIMIZED_HORZ", True); Atom _NET_WM_STATE_MAXIMIZED_VERT = XInternAtom (display, "_NET_WM_STATE_MAXIMIZED_VERT", True); GSList *next = windows; while (next != NULL) { WindowInfoEx *wix = (WindowInfoEx *) next->data; window = wix->window; LOG_HARNESS ("[%i shocker] WindowHelper_Maximize (%i): Sending maximize request to: %p\n", getpid (), pid, (void *) window); xev.xclient.display = display; xev.xclient.type = ClientMessage; xev.xclient.send_event = True; xev.xclient.window = window; xev.xclient.message_type = _NET_WM_STATE; xev.xclient.format = 32; xev.xclient.data.l [0] = 2; xev.xclient.data.l [1] = _NET_WM_STATE_MAXIMIZED_HORZ; xev.xclient.data.l [2] = _NET_WM_STATE_MAXIMIZED_VERT; xev.xclient.data.l [3] = 0; XSendEvent (display, XDefaultRootWindow (display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); next = next->next; } XCloseDisplay (display); } else { LOG_HARNESS ("[%i shocker] WindowHelper_Maximize (%i): No toplevel windows found for the specified process.\n", getpid (), pid); } g_slist_free (windows); return 0; }
void do_focus_in(GR_EVENT_GENERAL *event) { win *window; printf("do_focus_in: wid %d\n", event->wid); if(!(window = find_window(event->wid))) return; switch(window->type) { default: printf("Unhandled focus in from window %d " "(type %d)\n", window->wid, window->type); break; } }
static void select_windows (GList *windows) { GtkTreeSelection *selection; GtkTreeIter iter; GList *l; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); gtk_tree_selection_unselect_all (selection); for (l = windows; l != NULL; l = l->next) { if (find_window (l->data, &iter)) gtk_tree_selection_select_iter (selection, &iter); } }
/* * Scroll completions up. */ void completion_scroll_up (void) { Window *wp, *old_wp = cur_wp; Point pt; wp = find_window ("*Completions*"); assert (wp != NULL); set_current_window (wp); pt = get_buffer_pt (cur_bp); if (pt.n >= get_buffer_last_line (cur_bp) - get_window_eheight (cur_wp) || !FUNCALL (scroll_up)) gotobob (); set_current_window (old_wp); term_redisplay (); }
static void toggle_selection_window (GdkWindow *window) { GtkTreeSelection *selection; GtkTreeIter iter; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); if (window != NULL && find_window (window, &iter)) { if (gtk_tree_selection_iter_is_selected (selection, &iter)) gtk_tree_selection_unselect_iter (selection, &iter); else gtk_tree_selection_select_iter (selection, &iter); } }
void mdm_wm_focus_window (Window window) { XWindowAttributes attribs = {0}; MdmWindow *win; if (no_focus_login > 0 && window == wm_login_window) return; win = find_window (window, TRUE); if (win != NULL && ! win->takefocus) return; trap_push (); XGetWindowAttributes (wm_disp, window, &attribs); if (attribs.map_state == IsUnmapped) { trap_pop (); return; } if (wm_protocol_check_support (window, XA_WM_TAKE_FOCUS)) { XEvent xevent = { 0, }; xevent.type = ClientMessage; xevent.xclient.window = window; xevent.xclient.message_type = XA_WM_PROTOCOLS; xevent.xclient.format = 32; xevent.xclient.data.l[0] = XA_WM_TAKE_FOCUS; xevent.xclient.data.l[1] = CurrentTime; XSendEvent (wm_disp, window, False, 0, &xevent); XSync (wm_disp, False); } XSetInputFocus (wm_disp, window, RevertToPointerRoot, CurrentTime); trap_pop (); wm_focus_window = window; }
/*********************************************************************** * * Procedure: * Process message - examines packet types, and takes appropriate action * ***********************************************************************/ void process_message(unsigned long type,unsigned long *body) { switch(type) { case M_CONFIGURE_WINDOW: if(!find_window(body[0])) add_window(body[0],body); break; case M_NEW_PAGE: list_new_page(body); break; case M_END_WINDOWLIST: do_save(); break; default: break; } }