int show_x_dialog (Display *dpy, Window parent, int x, int y) { if (_dlg_mwin) return -1; if (!_dlg_ctx) { _dlg_ctx = XUniqueContext(); } _parent = parent; XColor dummy; Colormap colormap = DefaultColormap (dpy, DefaultScreen (dpy)); if (!XAllocNamedColor (dpy, colormap, "LightGray", &_c_gray1, &dummy)) return -1; if (!XAllocNamedColor (dpy, colormap, "DarkGray", &_c_gray2, &dummy)) return -1; update_menus(); int items; for (items = 0; mainmenu[items].text; ++items); if (open_x_dialog_win(dpy, &_dlg_mwin, x, y, 0, mainmenu, items)) { return -1; } #if 1 XGrabPointer (dpy, _dlg_mwin, True, ButtonReleaseMask | ButtonPressMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | StructureNotifyMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); XGrabKeyboard (dpy, _dlg_mwin, True, GrabModeAsync, GrabModeAsync, CurrentTime); //XSetInputFocus (dpy, parent, RevertToNone, CurrentTime); #endif return 0; }
void LuaContext::update() { update_drawables(); update_menus(); update_timers(); //main_on_update(); }
void update_winlist() { if(winlist_menudata.nref!=0){ winlist_menudata_deinit(&winlist_menudata); winlist_menudata_init(&winlist_menudata, NULL); update_menus(&winlist_menudata); } if(detachlist_menudata.nref!=0){ winlist_menudata_deinit(&detachlist_menudata); winlist_menudata_init(&detachlist_menudata, NULL); update_menus(&detachlist_menudata); } /* Attachlist is not updated as it is contextual and update should * not occur when the menu is open. */ }
/* Window procedure. All messages are handled here. */ static LRESULT CALLBACK window_proc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) { HDC hdc; PAINTSTRUCT ps; int i; switch (msg) { case WM_CREATE: songs = psid_tunes(&default_song); current_song = default_song; #if 0 if (songs == 0) { log_message(LOG_DEFAULT, "Vsid: no file specified, quitting"); return -1; } #endif DragAcceptFiles(window, TRUE); return 0; case WM_KEYDOWN: switch(wparam) { case 'I': /* infoline on request, just press I */ vsid_disp( 0, VSID_S_LASTLINE, "%s", vsidstrings[VSID_S_LASTLINE]); break; case VK_LEFT: case VK_DOWN: if (current_song > 1) { current_song--; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); InvalidateRect(window, NULL, 0); } break; case VK_RIGHT: case VK_UP: if (current_song < songs) { current_song++; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); InvalidateRect(window, NULL, 0); } break; } return 0; case WM_KEYUP: switch(wparam) { case 'I': /* infoline on request, just press I */ vsid_disp( 0, VSID_S_LASTLINE, "%79s", " "); break; } return 0; case WM_SIZE: return 0; case WM_COMMAND: vsync_suspend_speed_eval(); handle_wm_command(wparam, lparam, window); return 0; case WM_ENTERMENULOOP: vsync_suspend_speed_eval(); update_menus(window); break; case WM_MOVE: break; case WM_CLOSE: vsync_suspend_speed_eval(); vsid_ui_close(); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_DROPFILES: { char dummy[MAX_PATH]; DragQueryFile((HDROP)wparam, 0, dummy, sizeof(dummy) ); if (machine_autodetect_psid(dummy) >= 0) { vsid_disp(0, 0, NULL, NULL); psid_init_driver(); vsid_ui_init(); machine_play_psid(0); for (i = 0; i < VSID_S_LASTLINE; i++) { *vsidstrings[i] = 0; } machine_trigger_reset(MACHINE_RESET_MODE_SOFT); songs = psid_tunes(&default_song); current_song = default_song; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); InvalidateRect(window, NULL, TRUE); } } return 0; case WM_PAINT: { hdc = BeginPaint(window, &ps); if (*vsidstrings[VSID_S_TIMER]) { /* start only when timer string has been filled */ for (i = 0; i < VSID_S_LASTLINE; i++) { vsid_disp(0, i, "%s", vsidstrings[i]); } } EndPaint(window, &ps); return 0; } } return DefWindowProc(window, msg, wparam, lparam); }
int main( int argc, char *argv[] ) { glob_t globdata; int i, j, l, file_arg_start, new_empty = TRUE, get_screenshot = FALSE; if (argc > 1) { if ( strcmp(argv[1], "--version") == 0 ) { printf("%s\n\n", MT_VERSION); exit(0); } if ( strcmp(argv[1], "--help") == 0 ) { printf("%s\n\n" "Usage: mtpaint [option] [imagefile ... ]\n\n" "Options:\n" " --help Output this help\n" " --version Output version information\n" " -s Grab screenshot\n" " -v Start in viewer mode\n\n" , MT_VERSION); exit(0); } } putenv( "G_BROKEN_FILENAMES=1" ); // Needed to read non ASCII filenames in GTK+2 #if GTK2VERSION >= 4 /* Tablet handling in GTK+ 2.18+ is broken beyond repair if this mode * is set; so unset it, if g_unsetenv() is present */ g_unsetenv("GDK_NATIVE_WINDOWS"); #endif #ifdef U_THREADS /* Enable threading for GLib, but NOT for GTK+ (at least, not yet) */ g_thread_init(NULL); #endif inifile_init("/etc/mtpaint/mtpaintrc", "~/.mtpaint"); #ifdef U_NLS #if GTK_MAJOR_VERSION == 1 /* !!! GTK+1 needs locale set up before gtk_init(); GTK+2, *QUITE* * the opposite - WJ */ setup_language(); #endif #endif #ifdef U_THREADS /* !!! Uncomment to allow GTK+ calls from other threads */ /* gdk_threads_init(); */ #endif gtk_init( &argc, &argv ); gtk_init_bugfixes(); #if GTK_MAJOR_VERSION == 2 { char *theme = inifile_get(DEFAULT_THEME_INI, ""); if (theme[0]) gtk_rc_parse(theme); } #endif #ifdef U_NLS #if GTK_MAJOR_VERSION == 2 /* !!! GTK+2 starts acting up if this is before gtk_init() - WJ */ setup_language(); #endif bindtextdomain("mtpaint", MT_LANG_DEST); textdomain("mtpaint"); #if GTK_MAJOR_VERSION == 2 bind_textdomain_codeset("mtpaint", "UTF-8"); #endif #endif file_arg_start = 1; if (argc > 1) // Argument received, so assume user is trying to load a file { if ( strcmp(argv[1], "-g") == 0 ) // Loading GIF animation frames { file_arg_start+=2; sscanf(argv[2], "%i", &preserved_gif_delay); } if ( strcmp(argv[1], "-v") == 0 ) // Viewer mode { file_arg_start++; viewer_mode = TRUE; } if ( strcmp(argv[1], "-s") == 0 ) // Screenshot { file_arg_start++; get_screenshot = TRUE; } if ( strstr(argv[0], "mtv") != NULL ) viewer_mode = TRUE; } /* Something else got passed in */ l = argc - file_arg_start; while (l) { /* First, process wildcarded args */ memset(&globdata, 0, sizeof(globdata)); /* !!! I avoid GLOB_DOOFFS here, because glibc before version 2.2 mishandled it, * and quite a few copycats had cloned those buggy versions, some libc * implementors among them. So it is possible to encounter a broken function * in the wild, and playing it safe doesn't cost all that much - WJ */ for (i = file_arg_start , j = 0; i < argc; i++) { if (strcmp(argv[i], "-w")) continue; j++; if (++i >= argc) break; j++; // Ignore errors - be glad for whatever gets returned glob(argv[i], (j > 2 ? GLOB_APPEND : 0), NULL, &globdata); } files_passed = l - j + globdata.gl_pathc; /* If no wildcarded args */ file_args = argv + file_arg_start; if (!j) break; /* If no normal args */ file_args = globdata.gl_pathv; if (l <= j) break; /* Allocate space for both kinds of args together */ file_args = calloc(files_passed + 1, sizeof(char *)); // !!! Die by SIGSEGV if this allocation fails /* Copy normal args if any */ for (i = file_arg_start , j = 0; i < argc; i++) { if (!strcmp(argv[i], "-w")) i++; // Skip the pair else file_args[j++] = argv[i]; } /* Copy globbed args after them */ if (globdata.gl_pathc) memcpy(file_args + j, globdata.gl_pathv, globdata.gl_pathc * sizeof(char *)); break; } string_init(); // Translate static strings var_init(); // Load INI variables mem_init(); // Set up memory & back end layers_init(); init_cols(); if ( get_screenshot ) { if (load_image(NULL, FS_PNG_LOAD, FT_PIXMAP) == 1) new_empty = FALSE; // Successfully grabbed so no new empty else get_screenshot = FALSE; // Screenshot failed } main_init(); // Create main window if ( get_screenshot ) { do_new_chores(FALSE); notify_changed(); } else { if ((files_passed > 0) && !do_a_load(file_args[0], FALSE)) new_empty = FALSE; } if ( new_empty ) // If no file was loaded, start with a blank canvas { create_default_image(); } update_menus(); THREADS_ENTER(); gtk_main(); THREADS_LEAVE(); spawn_quit(); inifile_quit(); return 0; }