void panel_force_quit (GdkScreen *screen, guint time) { GdkGrabStatus status; GdkCursor *cross; GtkWidget *popup; GdkWindow *root; popup = display_popup_window (screen); root = gdk_screen_get_root_window (screen); gdk_window_add_filter (root, (GdkFilterFunc) popup_filter, popup); cross = gdk_cursor_new (GDK_CROSS); status = gdk_pointer_grab (root, FALSE, GDK_BUTTON_PRESS_MASK, NULL, cross, time); gdk_cursor_unref (cross); if (status != GDK_GRAB_SUCCESS) { g_warning ("Pointer grab failed\n"); remove_popup (popup); return; } status = gdk_keyboard_grab (root, FALSE, time); if (status != GDK_GRAB_SUCCESS) { g_warning ("Keyboard grab failed\n"); remove_popup (popup); return; } gdk_flush (); }
void panel_force_quit (GdkScreen *screen, guint time) { GdkGrabStatus status; GdkCursor *cross; GtkWidget *popup; GdkWindow *root; GdkDisplay *display; GdkDevice *pointer; GdkDevice *keyboard; GdkDeviceManager *device_manager; popup = display_popup_window (screen); root = gdk_screen_get_root_window (screen); gdk_window_add_filter (root, (GdkFilterFunc) popup_filter, popup); cross = gdk_cursor_new (GDK_CROSS); display = gdk_window_get_display (root); device_manager = gdk_display_get_device_manager (display); pointer = gdk_device_manager_get_client_pointer (device_manager); keyboard = gdk_device_get_associated_device (pointer); status = gdk_device_grab (pointer, root, GDK_OWNERSHIP_NONE, FALSE, GDK_BUTTON_PRESS_MASK, cross, time); g_object_unref (cross); if (status != GDK_GRAB_SUCCESS) { g_warning ("Pointer grab failed\n"); remove_popup (popup); return; } status = gdk_device_grab (keyboard, root, GDK_OWNERSHIP_NONE, FALSE, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL, time); if (status != GDK_GRAB_SUCCESS) { g_warning ("Keyboard grab failed\n"); remove_popup (popup); return; } gdk_flush (); }
static void handle_button_press_event (GtkWidget *popup, XKeyEvent *event) { Window window; remove_popup (popup); if (event->subwindow == None) return; if (wm_state_atom == None) wm_state_atom = XInternAtom (event->display, "WM_STATE", FALSE); window = find_managed_window (event->display, event->subwindow); if (window != None) { #if GTK_CHECK_VERSION (3, 0, 0) if (!gdk_x11_window_lookup_for_display (gdk_x11_lookup_xdisplay (event->display), window)) #else if (!gdk_xid_table_lookup_for_display (gdk_x11_lookup_xdisplay (event->display), window)) #endif kill_window_question ((gpointer) window); } }
static GdkFilterReturn popup_filter (GdkXEvent *gdk_xevent, GdkEvent *event, GtkWidget *popup) { XEvent *xevent = (XEvent *) gdk_xevent; XIEvent *xiev; XIDeviceEvent *xidev; switch (xevent->type) { case ButtonPress: handle_button_press_event (popup, xevent->xbutton.display, xevent->xbutton.subwindow); return GDK_FILTER_REMOVE; case KeyPress: if (xevent->xkey.keycode == XKeysymToKeycode (xevent->xany.display, XK_Escape)) { remove_popup (popup); return GDK_FILTER_REMOVE; } break; case GenericEvent: xiev = (XIEvent *) xevent->xcookie.data; xidev = (XIDeviceEvent *) xiev; switch (xiev->evtype) { case XI_KeyPress: if (xidev->detail == XKeysymToKeycode (xevent->xany.display, XK_Escape)) { remove_popup (popup); return GDK_FILTER_REMOVE; } break; case XI_ButtonPress: handle_button_press_event (popup, xidev->display, xidev->child); return GDK_FILTER_REMOVE; } break; default: break; } return GDK_FILTER_CONTINUE; }
static void handle_button_press_event (GtkWidget *popup, XKeyEvent *event) { Window window; remove_popup (popup); if (event->subwindow == None) return; if (wm_state_atom == None) wm_state_atom = XInternAtom (gdk_display, "WM_STATE", FALSE); window = find_managed_window (event->subwindow); if (window != None) { if (!gdk_xid_table_lookup_for_display (gdk_display_get_default (), window)) kill_window_question ((gpointer) window); } }
static void handle_button_press_event (GtkWidget *popup, Display *display, Window subwindow) { Window window; remove_popup (popup); if (subwindow == None) return; if (wm_state_atom == None) wm_state_atom = XInternAtom (display, "WM_STATE", FALSE); window = find_managed_window (display, subwindow); if (window != None) { if (!gdk_x11_window_lookup_for_display (gdk_x11_lookup_xdisplay (display), window)) kill_window_question ((gpointer) window); } }
static GdkFilterReturn popup_filter (GdkXEvent *gdk_xevent, GdkEvent *event, GtkWidget *popup) { XEvent *xevent = (XEvent *) gdk_xevent; switch (xevent->type) { case ButtonPress: handle_button_press_event (popup, &xevent->xkey); return GDK_FILTER_REMOVE; case KeyPress: if (xevent->xkey.keycode == XKeysymToKeycode (xevent->xany.display, XK_Escape)) { remove_popup (popup); return GDK_FILTER_REMOVE; } break; default: break; } return GDK_FILTER_CONTINUE; }
void Screen::process_event (const SDL_Event& event) { Control* under_cursor; Control* par; switch (event.type) { case SDL_KEYDOWN: on_key_pressed (event.key); break; case SDL_MOUSEBUTTONDOWN: under_cursor = control_at_pos (event.button.x, event.button.y); on_mouse_button (event.button); if (event.button.button == SDL_BUTTON_LEFT) { be_clicked = under_cursor; if (be_clicked->is_focusable ()) be_clicked->grab_focus (); } break; case SDL_MOUSEBUTTONUP: under_cursor = control_at_pos (event.button.x, event.button.y); on_mouse_button (event.button); if (event.button.button == SDL_BUTTON_LEFT) { par = under_cursor; while (par != popup && par != NULL) { par = par->get_parent (); } if (under_cursor == be_clicked) { be_clicked->on_clicked (); } if (par == NULL) { remove_popup (!(under_cursor->is_focusable () && under_cursor->is_focused ())); } be_clicked = NULL; } break; case SDL_MOUSEMOTION: under_cursor = control_at_pos (event.motion.x, event.motion.y); set_mouse_target (under_cursor); on_mouse_move (event.motion); break; case SDL_ACTIVEEVENT: switch (event.active.state) { case SDL_APPMOUSEFOCUS: if (event.active.gain) { int x, y; SDL_GetMouseState (&x, &y); under_cursor = control_at_pos (x, y); set_mouse_target (under_cursor); } else { set_mouse_target (NULL); } break; } break; case E_SHOW_POPUP: remove_popup (false); add_popup (static_cast<Control*> (event.user.data1), static_cast<Control*> (event.user.data2)); break; case E_HIDE_POPUP: remove_popup (true); break; } }
Screen::~Screen () { remove_popup (false); }
int spline_win_message(SCREEN *sc,HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { extern SPLINE_EDIT spline_edit; typedef enum CMDMENU{ CMD_ADDKEY,CMD_DELKEY }; static int clickx=0,clicky=0,debounce=0; static PARAM_CONTROL *pcdrag=0; static HMENU hmenu=0; static SPLINE_KEY_CONTROL *selected_key=0; PARAM_CONTROL *p; p=spline_edit.plist.list; if(FALSE) if(msg!=WM_PAINT&&msg!=WM_SETCURSOR&&msg!=WM_NCHITTEST&&msg!=WM_ENTERIDLE) { static DWORD tick; if((GetTickCount()-tick)>500) printf("--\n"); printf("spl"); print_msg(msg,lparam,wparam,hwnd); tick=GetTickCount(); } switch(msg){ case WM_CREATE: { hmenu=CreatePopupMenu(); if(hmenu){ InsertMenu(hmenu,0xFFFFFFFF,MF_BYPOSITION,CMD_ADDKEY,"add key"); InsertMenu(hmenu,0xFFFFFFFF,MF_BYPOSITION,CMD_DELKEY,"delete key"); } } break; case WM_CONTEXTMENU: if(hmenu){ POINT point; int x,y; point.x=x=LOWORD(lparam); point.y=y=HIWORD(lparam); MapWindowPoints(NULL,hwnd,&point,1); clickx=x; clicky=y; point.x+=spline_edit.plist.si.hscroll; point.y+=spline_edit.plist.si.vscroll; if(hittest_param(p,point.x,point.y,0)){ TrackPopupMenu(hmenu,TPM_LEFTALIGN,x,y,0,hwnd,NULL); } } break; case WM_KEYFIRST: switch(wparam){ case VK_DELETE: PostMessage(hwnd,WM_COMMAND,CMD_DELKEY,0); break; } break; case WM_COMMAND: { PARAM_CONTROL *pc=0; if(p){ find_param_type(&spline_edit.plist,CSPLINE,&pc); if(pc){ } } switch(LOWORD(wparam)){ case CMD_ADDKEY: { SPLINE_KEY *sk=0; POINT p; p.x=clickx; p.y=clicky; MapWindowPoints(NULL,hwnd,&p,1); p.x+=spline_edit.plist.si.hscroll; p.y+=spline_edit.plist.si.vscroll; add_splinekey(pc,&sk,p.x,p.y); } break; case CMD_DELKEY: del_sel_keys(pc); break; } } break; case WM_MOUSEWHEEL: { POINT point; PARAM_CONTROL *pc=0; point.x=LOWORD(lparam); point.y=HIWORD(lparam); MapWindowPoints(NULL,hwnd,&point,1); point.x+=spline_edit.plist.si.hscroll; point.y+=spline_edit.plist.si.vscroll; if(hittest_param(p,point.x,point.y,&pc) && pc->control.type==CDROPLIST){ signed short deltay=(HIWORD(wparam)); send_mouse_wheel(pc,deltay); update_spline_selection(&spline_edit.plist); } else{ short w=HIWORD(wparam); int key=LOWORD(wparam); int amount=DEFBUTTONH; int control=0; if(key&MK_SHIFT) amount<<=2; if(key&MK_CONTROL) control=1; if(w>0) amount=-amount; scroll_view(hwnd,sc,&spline_edit.plist.si,amount,control); } } break; case WM_MOUSEMOVE: set_focus(hwnd); if(pcdrag){ int x,y,deltax,deltay; int lmb,mmb,rmb,ctrl,shift; lmb=wparam&MK_LBUTTON; mmb=wparam&MK_MBUTTON; rmb=wparam&MK_RBUTTON; shift=wparam&MK_SHIFT; ctrl=wparam&MK_CONTROL; x=LOWORD(lparam); y=HIWORD(lparam); deltax=x-clickx; deltay=y-clicky; if(debounce==0){ int size=4; if((deltax<-size) || (deltax>size)) debounce=1; if((deltay<-size) || (deltay>size)) debounce=1; if(debounce==0) break; else{ if(deltax<0) deltax+=size; else deltax-=size; if(deltay<0) deltay+=size; else deltay-=size; } } send_mouse_move(pcdrag,deltax,deltay,lmb,mmb,rmb,shift,ctrl); if(selected_key && pcdrag->control.type==CSPLINE) handle_spline_key_move(pcdrag->control.data,selected_key,deltax,deltay); clickx=x; clicky=y; } else{ int x,y; x=LOWORD(lparam); y=HIWORD(lparam); if(!(wparam&MK_LBUTTON)){ spline_edit.plist.si.vscroll_pressed=FALSE; spline_edit.plist.si.hscroll_pressed=FALSE; } if(spline_edit.plist.si.vscroll_pressed){ float delta=y-clicky; RECT rect={0}; int h,bh,range,d; GetWindowRect(hwnd,&rect); h=rect.bottom-rect.top; range=sc->h-h; bh=h-(range/3); if(bh<10){ bh=10; if(h<10) bh=h; } d=h-bh; if(d<=0) d=1; delta=delta*range/d; spline_edit.plist.si.vscroll+=(int)delta; clicky=y; } if(spline_edit.plist.si.hscroll_pressed){ float delta=x-clickx; RECT rect={0}; int w,bw,range,d; GetWindowRect(hwnd,&rect); w=rect.right-rect.left; range=sc->w-w; bw=w-(range/3); if(bw<10){ bw=10; if(w<10) bw=w; } d=w-bw; if(d<=0) d=1; delta=delta*range/d; spline_edit.plist.si.hscroll+=(int)delta; clickx=x; } { int x,y; PARAM_CONTROL *pc=0; x=LOWORD(lparam); y=HIWORD(lparam); if(hittest_param(p,x,y,&pc)){ if(pc->control.type==CPOPUPLIST){ handle_popup_list(&spline_edit.plist,pc,WM_MOUSEMOVE,x,y); } } } } break; case WM_LBUTTONUP: if(pcdrag && pcdrag->control.type==CBUTTON){ BUTTON *b=pcdrag->control.data; if(b) b->pressed=FALSE; } spline_edit.plist.si.hscroll_pressed=0; spline_edit.plist.si.vscroll_pressed=0; pcdrag=0; selected_key=0; break; case WM_LBUTTONDOWN: { int x,y; PARAM_CONTROL *pc=0; clickx=x=LOWORD(lparam); clicky=y=HIWORD(lparam); x+=spline_edit.plist.si.hscroll; y+=spline_edit.plist.si.vscroll; debounce=0; if(check_scroll_hit(sc,&spline_edit.plist.si,hwnd,x,y)) break; clear_param_selected(p); if(hittest_param(p,x,y,&pc)){ int list_handled=FALSE; if(pc->control.type==CDROPLIST){ DROPLIST *dl=pc->control.data; handle_drop_list(&spline_edit.plist,pc); list_handled=TRUE; } else if(pc->control.type==CPOPUPLIST){ handle_popup_list(&spline_edit.plist,pc,WM_LBUTTONDOWN,x,y); update_spline_selection(&spline_edit.plist); list_handled=TRUE; } else if(pc->control.type==CBUTTON){ BUTTON *b=pc->control.data; if(b) b->pressed=TRUE; } else if(pc->control.type==CSPLINE){ handle_spline_click(pc->control.data,x,y,&selected_key,wparam); } if(!list_handled) remove_popup(&spline_edit.plist); pc->has_focus=TRUE; pcdrag=pc; } else{ pcdrag=0; remove_popup(&spline_edit.plist); } } break; } return 0; }
int main(int argc, char *argv[]) { int found = 0; FILE *fd; #ifdef WIN3264 int i; struct stat st; char icon[BUFSIZE]; char path[BUFSIZE]; char popup_path[BUFSIZE]; /* The nsis uninstaller calls us with a "-nsis" argument. */ if (argc == 2 && stricmp(argv[1], "-nsis") == 0) interactive = FALSE; else #endif interactive = TRUE; /* Initialize this program. */ do_inits(argv); printf("This program will remove the following items:\n"); #ifdef WIN3264 if (popup_gvim_path(popup_path)) { printf(" - the \"Edit with Vim\" entry in the popup menu\n"); printf(" which uses \"%s\"\n", popup_path); if (interactive) printf("\nRemove it (y/n)? "); if (!interactive || confirm()) { remove_popup(); /* Assume the "Open With" entry can be removed as well, don't * bother the user with asking him again. */ remove_openwith(); } } else if (openwith_gvim_path(popup_path)) { printf(" - the Vim \"Open With...\" entry in the popup menu\n"); printf(" which uses \"%s\"\n", popup_path); printf("\nRemove it (y/n)? "); if (confirm()) remove_openwith(); } if (get_shell_folder_path(path, "desktop")) { printf("\n"); for (i = 0; i < ICON_COUNT; ++i) { sprintf(icon, "%s\\%s", path, icon_link_names[i]); if (stat(icon, &st) == 0) { printf(" - the \"%s\" icon on the desktop\n", icon_names[i]); ++found; } } if (found > 0) { if (interactive) printf("\nRemove %s (y/n)? ", found > 1 ? "them" : "it"); if (!interactive || confirm()) remove_icons(); } } if (get_shell_folder_path(path, VIM_STARTMENU) && stat(path, &st) == 0) { printf("\n - the \"%s\" entry in the Start Menu\n", VIM_STARTMENU); if (interactive) printf("\nRemove it (y/n)? "); if (!interactive || confirm()) remove_start_menu(); } #endif printf("\n"); found = remove_batfiles(0); if (found > 0) { if (interactive) printf("\nRemove %s (y/n)? ", found > 1 ? "them" : "it"); if (!interactive || confirm()) remove_batfiles(1); } fd = fopen("gvim.exe", "r"); if (fd != NULL) { fclose(fd); printf("gvim.exe detected. Attempting to unregister gvim with OLE\n"); system("gvim.exe -silent -unregister"); } delete_uninstall_key(); if (interactive) { printf("\nYou may now want to delete the Vim executables and runtime files.\n"); printf("(They are still where you unpacked them.)\n"); } if (interactive) { rewind(stdin); printf("\nPress Enter to exit..."); (void)getchar(); } else sleep(3); return 0; }