int main (int argc, char *argv[]) { if(argc > 1) for (int i = 1; i < argc; ++i) { std::string ar(argv[i]); if( ar == "-d") ad_debug = true; else if( ar == "-s") simulate = true; } readfiles(); GMainLoop *loop; WnckScreen *screen; gdk_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); screen = wnck_screen_get_default (); g_signal_connect (screen, "window-opened", G_CALLBACK (on_window_opened), NULL); g_main_loop_run (loop); g_main_loop_unref (loop); return 0; }
int main(int argc, char **argv) { WnckScreen *screen; WnckWindow *active_window; GList *window_l; gdk_init(&argc, &argv); screen = wnck_screen_get_default(); sleep(5); wnck_screen_force_update(screen); active_window = wnck_screen_get_active_window(screen); for (window_l = wnck_screen_get_windows(screen); window_l != NULL; window_l = window_l->next) { WnckWindow *window = WNCK_WINDOW(window_l->data); if (strcmp(wnck_window_get_name(window), "Terminal") == 0) { wnck_window_activate(window, (guint32)time(NULL)); break; } // g_print("Name: '%s', PID: %d(%lu)%s\n", wnck_window_get_name(window), // wnck_window_get_pid(window), wnck_window_get_xid(window), // window == active_window ? " (active)" : ""); } return 0; }
int main(int argc, char **argv) { gdk_init(NULL, NULL); /* Force to output original string, usually are Traditional Chinese */ if (strstr(argv[0],"hime-trad")) send_hime_message(GDK_DISPLAY(), TRAD_OUTPUT_TOGGLE); /* Force to output Simplified Chinese */ if (strstr(argv[0],"hime-sim")) send_hime_message(GDK_DISPLAY(), SIM_OUTPUT_TOGGLE); /* Toggle between Original string and Simplified Chinese */ if (strstr(argv[0],"hime-gb-toggle")) send_hime_message(GDK_DISPLAY(), GB_OUTPUT_TOGGLE); /* Toggle virtual keyboard */ if (strstr(argv[0],"hime-kbm-toggle")) send_hime_message(GDK_DISPLAY(), KBM_TOGGLE); if (strstr(argv[0],"hime-exit")) { Display *dpy = GDK_DISPLAY(); if (find_hime_window(dpy)==None) return 0; send_hime_message(dpy, HIME_EXIT_MESSAGE); } return 0; }
/* Displays an image, making sure it fits on screen. cvWaitKey() must be called after this function so the event loop is entered and the image is displayed. @param img an image, possibly too large to display on-screen @param title the title of the window in which \a img is displayed */ void display_big_img( IplImage* img, char* title ) { IplImage* small; GdkScreen* scr; int scr_width, scr_height; double img_aspect, scr_aspect, scale; // determine screen size to see if image fits on screen gdk_init( NULL, NULL ); scr = gdk_screen_get_default(); scr_width = gdk_screen_get_width( scr ); scr_height = gdk_screen_get_height( scr ); if( img->width >= 0.90 * scr_width || img->height >= 0.90 * scr_height ) { img_aspect = (double)(img->width) / img->height; scr_aspect = (double)(scr_width) / scr_height; if( img_aspect > scr_aspect ) scale = 0.90 * scr_width / img->width; else scale = 0.90 * scr_height / img->height; small = cvCreateImage( cvSize( img->width * scale, img->height * scale ), img->depth, img->nChannels ); cvResize( img, small, CV_INTER_AREA ); } else small = cvCloneImage( img ); cvNamedWindow( title, 1 ); cvShowImage( title, small ); cvReleaseImage( &small ); }
int main (int argc, char **argv) { gint lastentry = 0; guint32 timestamp; const gchar* startup_id = g_getenv ("DESKTOP_STARTUP_ID"); //printf ("startup id is %s\n", startup_id); if (startup_id && (startup_id[0] != '\0')) { gchar **results = g_strsplit (startup_id, "_TIME", 0); while (results[lastentry] != NULL) lastentry++; timestamp = (guint32) g_strtod (results[lastentry - 1], NULL); g_strfreev (results); } else timestamp = GDK_CURRENT_TIME; gdk_init (&argc, &argv); run_dialog (NULL, NULL, timestamp); gdk_notify_startup_complete (); return 0; }
static void test_unset_display (void) { if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) { GdkDisplayManager *manager; g_unsetenv ("DISPLAY"); g_assert (!gdk_init_check (NULL, NULL)); manager = gdk_display_manager_get (); g_assert (manager != NULL); g_assert (gdk_display_manager_get_default_display (manager) == NULL); exit (0); } g_test_trap_assert_passed (); if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) { g_unsetenv ("DISPLAY"); gdk_init (NULL, NULL); exit (0); } g_test_trap_assert_failed (); g_test_trap_assert_stderr ("*cannot open display*"); }
int main (int argc, char **argv) { static guchar data[99999]; gint height = 8; gint rowstride = 256; gdk_init (&argc, &argv); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data (data, GDK_COLORSPACE_RGB, 0, 8, 2,height, rowstride, NULL, NULL); printf ("%p\n", gdk_pixbuf_get_pixels(pixbuf)); GdkPixbuf *p2 = gdk_pixbuf_copy (pixbuf); printf ("%p\n", gdk_pixbuf_get_pixels(p2)); printf ("%p\n", gdk_pixbuf_get_pixels(p2) + rowstride*height); return 0; }
int main(int argc, char **argv) { signal(SIGINT, fatal_handler); signal(SIGPIPE, fatal_handler); gtk_init(&argc, &argv); gdk_init(&argc, &argv); /*gdk_imlib_init();*/ ng_init(); gtk_main(); exit(0); }
gint main(gint argc, gchar *argv[]) { gint n = 9; gdk_init(&argc, &argv); gtk_timeout_add(60000,(GtkFunction)timeoutfunc, (gpointer)&n); gtk_main(); printf("Bang !!\n"); return 0; }
gint main(gint argc, gchar *argv[]) { GdkImlibImage *im; gdk_init(&argc,&argv); gdk_imlib_init(); im = gdk_imlib_load_image("DSPsystem.jpg"); gdk_imlib_flip_image_horizontal(im); gdk_imlib_save_image(im, "imlibtest.jpg",NULL); return 0; }
int main (int argc, char *argv[]) { /* If gdk_init() is called before gtk_init() the GTK code takes * a different path (why?) */ gdk_init (NULL, NULL); gtk_init (NULL, NULL); g_test_init (&argc, &argv, NULL); g_test_add_func ("/style/init_of_theme", test_init_of_theme); return g_test_run (); }
int main (int argc, char *argv[]) { GdmChooserSession *session; gboolean res; GError *error; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); gdm_log_init (); gdm_log_set_debug (TRUE); g_debug ("Chooser for display %s xauthority:%s", g_getenv ("DISPLAY"), g_getenv ("XAUTHORITY")); gdk_init (&argc, &argv); load_a11y (); gtk_init (&argc, &argv); session = gdm_chooser_session_new (); if (session == NULL) { g_critical ("Unable to create chooser session"); exit (1); } error = NULL; res = gdm_chooser_session_start (session, &error); if (! res) { g_warning ("Unable to start chooser session: %s", error->message); g_error_free (error); exit (1); } gtk_main (); if (session != NULL) { g_object_unref (session); } return 0; }
int main() { gdk_init(NULL, NULL); #if UNIX Display *dpy = GDK_DISPLAY(); if (find_gcin_window(dpy)==None) return; send_gcin_message(dpy, GCIN_EXIT_MESSAGE); #else if (!find_gcin_window()) return 0; send_gcin_message(GCIN_EXIT_MESSAGE); #endif return 0; }
static int lcs_taskbar (int *argc, char ***argv) { gdk_init (argc, argv); lcs_clutter_enable_transparency (TRUE); gtk_init (argc, argv); if (!clutter_init (argc, argv)) { fprintf (stderr, "error initializing clutter"); exit (1); } ClutterActor *stage = clutter_stage_new (); clutter_actor_set_layout_manager ( stage, clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_START)); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_actor_set_background_color (stage, clutter_color_new (255, 255, 255, 96)); ClutterActor *taskbar = lcs_taskbar_new (); clutter_actor_set_margin (taskbar, lcs_clutter_margin_new_full (4, 4, 4, 4)); clutter_actor_add_child (stage, taskbar); g_signal_connect (stage, "destroy", G_CALLBACK (on_stage_destroy), NULL); ClutterAction *drag = clutter_drag_action_new (); g_signal_connect (drag, "drag-motion", G_CALLBACK (on_stage_drag_motion), NULL); clutter_actor_add_action_with_name (stage, "drag", drag); clutter_actor_show (stage); long stagexid = lcs_wm_get_stage_xid (CLUTTER_STAGE(stage)); g_object_set_data (G_OBJECT (stage), "xid", GINT_TO_POINTER (stagexid)); lcs_wm_xwindow_set_decorated (stagexid, FALSE); lcs_wm_xwindow_set_above (stagexid); lcs_wm_xwindow_set_dock (stagexid); clutter_main (); return (0); }
static PyObject * moduleinit (void) { PyObject *module; PyObject *error; #if PY_MAJOR_VERSION >= 3 module = PyModule_Create(&moduledef); #else module = Py_InitModule("osk", osk_methods); #endif if (module == NULL) { fprintf (stderr, "Error: Failed to initialize the \"osk\" module.\n"); return NULL; } error = __osk_exception_get_object (); Py_INCREF (error); PyModule_AddObject (module, "error", error); gdk_init (NULL, NULL); if (__osk_devices_register_type (module) < 0) fprintf (stderr, "Error: Failed to register \"Devices\" type.\n"); if (__osk_device_event_register_type (module) < 0) fprintf (stderr, "Error: Failed to register \"DeviceEvent\" type.\n"); if (__osk_util_register_type (module) < 0) fprintf (stderr, "Error: Failed to register \"Util\" type.\n"); if (__osk_dconf_register_type (module) < 0) fprintf (stderr, "Error: Failed to register \"DConf\" type.\n"); if (__osk_struts_register_type (module) < 0) fprintf (stderr, "Error: Failed to register \"Struts\" type.\n"); if (__osk_audio_register_type (module) < 0) fprintf (stderr, "Error: Failed to register \"Audio\" type.\n"); return module; }
int main (int argc, char **argv) { gdk_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); screen = wnck_screen_get_default (); signal(SIGINT, INThandler); g_signal_connect(screen, "active-window-changed", G_CALLBACK(on_active_window_changed), NULL); g_main_loop_run (loop); stop_application(); return 0; }
int main(int argc, char **argv) { int i; char text[128]; char icon[128]; int duration = 3000; gtk_init(&argc, &argv); if (argc < 3) print_help(); strcpy(text, "-"); strcpy(icon, "-"); for(i=1; i < argc; i+=2) { if (!strcmp(argv[i], "-icon")) { strcpy(icon, argv[i+1]); } else if (!strcmp(argv[i], "-text")) { strcpy(text, argv[i+1]); } else if (!strcmp(argv[i], "-duration")) { duration = atoi(argv[i+1]); } else { dbg("unknown opt %s", argv[i]); } } char message[512]; sprintf(message, "#hime_message %s %s %d", icon, text, duration); gdk_init(NULL, NULL); send_hime_message(GDK_DISPLAY(), message); return 0; }
main (int argc, char *argv[]) { GOptionContext *context = NULL; GError *error = NULL; GdkScreen *screen; GdkRectangle rect; GnomeBG *bg; GSettings *settings; GdkPixbuf *pixbuf; gdk_init (&argc, &argv); context = g_option_context_new ("- refresh wallpaper cache"); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("option parsing failed: %s\n", error->message); g_option_context_free(context); g_error_free (error); return (1); } if (context) g_option_context_free (context); /* cache only the first monitor */ screen = gdk_screen_get_default (); gdk_screen_get_monitor_geometry (screen, 0, &rect); bg = gnome_bg_new (); settings = g_settings_new ("org.cinnamon.desktop.background"); gnome_bg_load_from_preferences (bg, settings); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, rect.width, rect.height); gnome_bg_draw (bg, pixbuf, screen, FALSE); g_object_unref (settings); return (0); }
int main (int argc, char **argv) { GMainLoop *loop; WnckScreen *screen; gdk_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); screen = wnck_screen_get_default (); g_signal_connect (screen, "window-opened", G_CALLBACK (on_window_opened), NULL); g_signal_connect (screen, "active-window-changed", G_CALLBACK (on_active_window_changed), NULL); g_main_loop_run (loop); g_main_loop_unref (loop); return 0; }
/* * Parse argc/argv for lowlevel stuff (display ...) */ void MUI_Init (int *argc, char ***argv) { __global_MUI_Init_called = 1; gdk_init(argc, argv); #ifdef WITH_IMLIB gdk_imlib_init(); #endif zune_check_iptr(); zune_check_varargs(); gdk_event_handler_set ((GdkEventFunc)__zune_main_do_event, NULL, NULL); __zune_clipping_init(); __zune_imspec_init(); __zune_images_init(); /* * init prefs before loading from files - in case there's no file */ __zune_prefs_init(&__zprefs); zune_signals_setup(); }
int main (int argc, char *argv[]) { GtkWidget *dialog; char *command; char *version; char *ret; const char *message; GOptionContext *ctx; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Option parsing */ ctx = g_option_context_new ("- New mdm login"); g_option_context_add_main_entries (ctx, options, _("main options")); g_option_context_parse (ctx, &argc, &argv, NULL); g_option_context_free (ctx); if (monte_carlo_pi) { calc_pi (); return 0; } mdm_log_init (); mdm_log_set_debug (debug_in); if (args_remaining != NULL && args_remaining[0] != NULL) server = args_remaining[0]; if (send_command != NULL) { if ( ! mdmcomm_check (FALSE)) { mdm_common_error (_("Error: MDM (MDM Display Manager) is not running.")); mdm_common_error (_("You might be using a different display manager.")); return 1; } } else { /* * The --command argument does not display anything, so avoid * running gtk_init until it finishes. Sometimes the * --command argument is used when there is no display so it * will fail and cause the program to exit, complaining about * "no display". */ gtk_init (&argc, &argv); if ( ! mdmcomm_check (TRUE)) { return 1; } } /* Start reading config data in bulk */ mdmcomm_comm_bulk_start (); /* Process --command option */ g_type_init (); if (send_command != NULL) { /* gdk_init is needed for cookie code to get display */ gdk_init (&argc, &argv); if (authenticate) auth_cookie = mdmcomm_get_auth_cookie (); /* * If asking for a translatable config value, then try to get * the translated value first. If this fails, then go ahead * and call the normal sockets command. */ if (strncmp (send_command, MDM_SUP_GET_CONFIG " ", strlen (MDM_SUP_GET_CONFIG " ")) == 0) { gchar *value = NULL; const char *key = &send_command[strlen (MDM_SUP_GET_CONFIG " ")]; if (is_key (MDM_KEY_WELCOME, key) || is_key (MDM_KEY_REMOTE_WELCOME, key)) { value = mdm_config_get_translated_string ((gchar *)key); if (value != NULL) { ret = g_strdup_printf ("OK %s", value); } } /* * If the above didn't return a value, then must be a * different key, so call mdmcomm_call_mdm. */ if (value == NULL) ret = mdmcomm_call_mdm (send_command, auth_cookie, "1.0.0.0", 5); } else { ret = mdmcomm_call_mdm (send_command, auth_cookie, "1.0.0.0", 5); } /* At this point we are done using the socket, so close it */ mdmcomm_comm_bulk_stop (); if (ret != NULL) { g_print ("%s\n", ret); return 0; } else { dialog = hig_dialog_new (NULL /* parent */, GTK_DIALOG_MODAL /* flags */, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Cannot communicate with MDM " "(The MDM Display Manager)"), _("Perhaps you have an old version " "of MDM running.")); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return 1; } } /* * Now process what mdmflexiserver is more frequently used to * do, start VT (Virtual Terminal) sesions - at least on * systems where it is supported. On systems where it is not * supporteed VT stands for "Very Tight" and will mess up your * display if you use it. Tight! So do not use it. * * I would accept a patch to disable it on such systems, but it * is easy to avoid not using it as long as your distro does not * put the menu choice in the application launch button on the * panel (don't ship the desktop file). */ /* * Always attempt to get cookie and authenticate. On remote * servers */ auth_cookie = mdmcomm_get_auth_cookie (); if (use_xnest) { char *cookie = mdmcomm_get_a_cookie (FALSE /* binary */); if (cookie == NULL) { /* At this point we are done using the socket, so close it */ mdmcomm_comm_bulk_stop (); dialog = hig_dialog_new (NULL /* parent */, GTK_DIALOG_MODAL /* flags */, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("You do not seem to have the " "authentication needed for this " "operation"), _("Perhaps your .Xauthority " "file is not set up correctly.")); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return 1; } command = g_strdup_printf (MDM_SUP_FLEXI_XNEST " %s %d %s %s", mdmcomm_get_display (), (int)getuid (), cookie, XauFileName ()); g_free (cookie); version = "1.0.0.0"; auth_cookie = NULL; } else { /* check for other displays/logged in users */ check_for_users (); if (auth_cookie == NULL) { /* At this point we are done using the socket, so close it */ mdmcomm_comm_bulk_stop (); dialog = hig_dialog_new (NULL /* parent */, GTK_DIALOG_MODAL /* flags */, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("You do not seem to be logged in on the " "console"), _("Starting a new login only " "works correctly on the console.")); gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return 1; } read_servers (); server = choose_server (); if (server == NULL) command = g_strdup (MDM_SUP_FLEXI_XSERVER); else command = g_strdup_printf (MDM_SUP_FLEXI_XSERVER " %s", server); version = "1.0.0.0"; } ret = mdmcomm_call_mdm (command, auth_cookie, version, 5); g_free (command); g_free (auth_cookie); g_strfreev (args_remaining); /* At this point we are done using the socket, so close it */ mdmcomm_comm_bulk_stop (); if (ret != NULL && strncmp (ret, "OK ", 3) == 0) { /* if we switched to a different screen as a result of this, * lock the current screen */ if ( ! no_lock && ! use_xnest) { maybe_lock_screen (); } /* all fine and dandy */ g_free (ret); return 0; } message = mdmcomm_get_error_message (ret, use_xnest); dialog = hig_dialog_new (NULL /* parent */, GTK_DIALOG_MODAL /* flags */, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Cannot start new display"), message); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); g_free (ret); return 1; }
/** * Program main entry */ int main(int argc, char *argv[]) { static const GOptionEntry options[]={ { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Print debug info to stdout")}, { "emulate", 'e', 0, G_OPTION_ARG_NONE, &emulate, N_("Don't apply any rules, only emulate execution")}, { "folder", 'f', 0, G_OPTION_ARG_STRING, &script_folder, N_("Search for scripts in this folder"),N_("FOLDER")}, { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Show Devilspie2 version and quit")}, #ifdef HAVE_GTK3 // libwnck Version Information is only availible if you have // libwnck 3.0 or later { "wnck-version", 'w', 0, G_OPTION_ARG_NONE, &show_wnck_version, N_("Show libwnck version and quit")}, #endif { NULL } }; GError *error = NULL; GOptionContext *context; // Init gettext stuff setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, ""); textdomain(PACKAGE); gdk_init(&argc, &argv); gchar *devilspie2_description = g_strdup_printf(_("apply rules on windows")); gchar *full_desc_string = g_strdup_printf("- %s", devilspie2_description); context=g_option_context_new(full_desc_string); g_option_context_add_main_entries(context,options,NULL); if (!g_option_context_parse(context, &argc, &argv, &error)) { g_print(_("option parsing failed: %s"), error->message); printf("\n"); exit(EXIT_FAILURE); } g_free(full_desc_string); g_free(devilspie2_description); // if the folder is NULL, default to ~/.config/devilspie2/ if (script_folder == NULL) { temp_folder = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), "devilspie2", NULL); // check if the folder does exist if (!g_file_test(temp_folder, G_FILE_TEST_IS_DIR)) { // - and if it doesn't, create it. if (g_mkdir(temp_folder, 0700) != 0) { printf("%s", _("Couldn't create the default folder for devilspie2 scripts.")); printf("\n"); exit(EXIT_FAILURE); } } script_folder = temp_folder; } if (show_version) { printf("Devilspie2 v%s\n\n", DEVILSPIE2_VERSION); exit(EXIT_SUCCESS); } #ifdef HAVE_GTK3 // libwnck Version Information is only availible if you have // libwnck 3.0 or later if (show_wnck_version) { printf("libwnck v%d.%d.%d\n\n", WNCK_MAJOR_VERSION, WNCK_MINOR_VERSION, WNCK_MICRO_VERSION); exit(EXIT_SUCCESS); } #endif #if (GTK_MAJOR_VERSION >= 3) if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) { printf("%s", _("An X11 display is required for devilspie2.")); printf("\n\n"); return EXIT_FAILURE; } #endif if (init_script_error_messages()!=0) { printf("%s", _("Couldn't init script error messages!")); printf("\n"); exit(EXIT_FAILURE); } config_filename = g_build_filename(script_folder, "devilspie2.lua", NULL); if (load_config(config_filename)!=0) { devilspie_exit(); return EXIT_FAILURE; } if (debug) { if (emulate) { printf("%s", _("Running devilspie2 in debug and emulate mode.")); } else { printf("%s", _("Running devilspie2 in debug mode.")); } printf("\n\n"); printf(_("Using scripts from folder: %s"), script_folder); printf("\n"); devilspie2_debug = TRUE; } // Should we only run an emulation (don't modify any windows) if (emulate) devilspie2_emulate = emulate; GFile *directory_file; directory_file = g_file_new_for_path(script_folder); // mon = g_file_monitor_directory(directory_file, G_FILE_MONITOR_WATCH_MOUNTS, mon = g_file_monitor_directory(directory_file, G_FILE_MONITOR_NONE, NULL, NULL); if (!mon) { printf("%s", _("Couldn't create directory monitor!")); printf("\n"); return EXIT_FAILURE; } g_signal_connect(mon, "changed", G_CALLBACK(folder_changed_callback), (gpointer)(config_filename)); global_lua_state = init_script(); print_script_lists(); if (debug) printf("------------\n"); // remove stuff cleanly atexit(devilspie_exit); struct sigaction signal_action; sigemptyset(&signal_action.sa_mask); signal_action.sa_flags = 0; signal_action.sa_handler = signal_handler; if (sigaction(SIGINT, &signal_action, NULL) == -1) { exit(EXIT_FAILURE); } init_screens(); loop=g_main_loop_new(NULL, TRUE); g_main_loop_run(loop); return EXIT_SUCCESS; }
int main(int argc, char** argv) { gdk_init(&argc, &argv); #if defined(HAVE_LIBXSS) && defined(MOZ_WIDGET_GTK) int event_base, error_base; Bool have_xscreensaver = XScreenSaverQueryExtension(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &event_base, &error_base); if (!have_xscreensaver) { fprintf(stderr, "No XScreenSaver extension on display\n"); } else { XScreenSaverInfo* info = XScreenSaverAllocInfo(); if (!info) { fprintf(stderr, "%s: Out of memory\n", argv[0]); return 1; } XScreenSaverQueryInfo(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW(), info); const char* state; const char* til_or_since = nullptr; switch (info->state) { case ScreenSaverOff: state = "Off"; til_or_since = "XScreenSaver will activate after another %lu seconds idle time\n"; break; case ScreenSaverOn: state = "On"; if (info->til_or_since) { til_or_since = "XScreenSaver idle timer activated %lu seconds ago\n"; } else { til_or_since = "XScreenSaver idle activation is disabled\n"; } break; case ScreenSaverDisabled: state = "Disabled"; break; default: state = "unknown"; } const char* kind; switch (info->kind) { case ScreenSaverBlanked: kind = "Blanked"; break; case ScreenSaverInternal: state = "Internal"; break; case ScreenSaverExternal: state = "External"; break; default: state = "unknown"; } fprintf(stderr, "XScreenSaver state: %s\n", state); if (til_or_since) { fprintf(stderr, "XScreenSaver kind: %s\n", kind); fprintf(stderr, til_or_since, info->til_or_since / 1000); } fprintf(stderr, "User input has been idle for %lu seconds\n", info->idle / 1000); XFree(info); } #endif GdkPixbuf* screenshot = nullptr; GdkWindow* window = gdk_get_default_root_window(); #if (MOZ_WIDGET_GTK == 2) screenshot = gdk_pixbuf_get_from_drawable(nullptr, window, nullptr, 0, 0, 0, 0, gdk_screen_width(), gdk_screen_height()); #else screenshot = gdk_pixbuf_get_from_window(window, 0, 0, gdk_window_get_width(window), gdk_window_get_height(window)); #endif if (!screenshot) { fprintf(stderr, "%s: failed to create screenshot GdkPixbuf\n", argv[0]); return 1; } GError* error = nullptr; if (argc > 1) { gdk_pixbuf_save(screenshot, argv[1], "png", &error, nullptr); } else { gdk_pixbuf_save_to_callback(screenshot, save_to_stdout, nullptr, "png", &error, nullptr); } if (error) { fprintf(stderr, "%s: failed to write screenshot as png: %s\n", argv[0], error->message); return error->code; } return 0; }
int main(int argc, char *argv[]) { GOOGLE_PROTOBUF_VERIFY_VERSION; hu_log_library_versions(); hu_install_crash_handler(); #if defined GDK_VERSION_3_10 printf("GTK VERSION 3.10.0 or higher\n"); //Assuming we are on Gnome, what's the DPI scale factor? gdk_init(&argc, &argv); GdkScreen * primaryDisplay = gdk_screen_get_default(); if (primaryDisplay) { g_dpi_scalefactor = (float) gdk_screen_get_monitor_scale_factor(primaryDisplay, 0); printf("Got gdk_screen_get_monitor_scale_factor() == %f\n", g_dpi_scalefactor); } #else printf("Using hard coded scalefactor\n"); g_dpi_scalefactor = 1; #endif gst_app_t *app = &gst_app; int ret = 0; errno = 0; gst_init(NULL, NULL); struct sigaction action; sigaction(SIGINT, NULL, &action); if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { SDL_Log("Unable to initialize SDL: %s", SDL_GetError()); return 1; } sigaction(SIGINT, &action, NULL); DesktopCommandServerCallbacks commandCallbacks; CommandServer commandServer(commandCallbacks); if (!commandServer.Start()) { loge("Command server failed to start"); } //loop to emulate the caar while(true) { DesktopEventCallbacks callbacks; HUServer headunit(callbacks); /* Start AA processing */ ret = headunit.hu_aap_start(HU_TRANSPORT_TYPE::USB, true); if (ret < 0) { printf("Phone is not connected. Connect a supported phone and restart.\n"); return 0; } callbacks.connected = true; g_hu = &headunit.GetAnyThreadInterface(); commandCallbacks.eventCallbacks = &callbacks; /* Start gstreamer pipeline and main loop */ ret = gst_loop(app); if (ret < 0) { printf("STATUS:gst_loop() ret: %d\n", ret); } callbacks.connected = false; commandCallbacks.eventCallbacks = nullptr; /* Stop AA processing */ ret = headunit.hu_aap_shutdown(); if (ret < 0) { printf("STATUS:hu_aap_stop() ret: %d\n", ret); SDL_Quit(); return (ret); } g_hu = nullptr; } SDL_Quit(); return (ret); }
int main(int argc,char *argv[]) { printf("\n\n // \t EL PROGRAMA SOLO MAXIMIZA Y MINIMIZA LA VENTANA ACTIVA \n"); printf(" // \t SE DEBE CORRER COMO SUPERUSUARIO \n\n\n"); int fd; struct input_event ie; Display *dpy; Window root, child; XWindowAttributes winDD; int rootX, rootY, winX, winY; unsigned int mask; gtk_init(&argc,&argv); gdk_init(&argc,&argv); dpy = XOpenDisplay(NULL); XGetWindowAttributes(dpy,DefaultRootWindow(dpy),&winDD); XQueryPointer(dpy,DefaultRootWindow(dpy),&root,&child, &rootX,&rootY,&winX,&winY,&mask); if((fd = open(MOUSEFILE, O_RDONLY)) == -1) { perror("opening device"); exit(EXIT_FAILURE); } int moves = 0,c = 0; int prevX,prevY; prevX = rootX; prevY = rootY; int mm = 0; int max_min = 0; while(read(fd, &ie, sizeof(struct input_event))) { moves++; c++; if (moves > 90){ XQueryPointer(dpy,DefaultRootWindow(dpy),&root,&child, &rootX,&rootY,&winX,&winY,&mask); int dir = calculaDireccion(prevX,prevY,rootX,rootY); printf("X: %d \t Y: %d \t Direccion: %d \n\n", rootX,rootY,dir); moves = 0; prevX = rootX; prevY = rootY; if(max_min) max_min = 0; else max_min = 1; max_unmax(max_min); } if(c > 200){ mm++; //max_unmax(mm); //allWindows(); if(mm>1) mm = -1; c = 0; } } return 0; }
int main (int argc, char **argv) { GdkWindow *rootwindow; /* RootWindow of X11*/ GMainLoop *loop; /* the event loop */ char *pw_dir; char *xml_file; uid_t uid; struct passwd *pass; /* inits some gdk stuff */ gdk_init(&argc, &argv); #ifdef ENABLE_LIBWNCK screen = wnck_screen_get_default (); wnck_screen_force_update (screen); #endif parse_options(&argc, &argv); uid = getuid(); pass = getpwuid (uid); pw_dir = pass->pw_dir; xml_file = (char*) malloc (sizeof (char) * (strlen (XML_FILE) + strlen (pw_dir) + 1)); sprintf (xml_file, "%s%s", pw_dir, XML_FILE); eventlist = parseDoc (xml_file); if (eventlist == NULL) { g_print ("xml error or no elements in list\n"); exit (1); } free (xml_file); rootwindow = gdk_window_foreign_new (gdk_x11_get_default_root_xwindow()); /*rootwindow = gdk_window_foreign_new (0x1200002); */ if (rootwindow == NULL) { g_print ("rootwindow == NULL\n"); exit (1); } /* check if GDK_BUTTON_PRESS_MASK is available */ gdk_error_trap_push (); /* ... Call the X function which may cause an error here ... */ gdk_window_set_events (rootwindow, GDK_BUTTON_PRESS_MASK); gdk_window_set_events (rootwindow, GDK_SCROLL_MASK); /* Flush the X queue to catch errors now. */ gdk_flush (); if (gdk_error_trap_pop ()) { char error[] = "grootevent: an error occured while querying the X server.\n" "A window manager or an application is already grapping\n" "the buttons from the root window.\n\n" "Please read the documentation to get more help about this.\n"; g_print (error); exit (1); } gdk_event_handler_set (event_func, NULL, NULL); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); return 0; }
int main (int argc, char *argv[]) { GMainLoop *loop; gchar* args[] = { "/usr/bin/xauth", "list", NULL, NULL }; gint in; gchar result[255]; gchar* idx; dbus_bool_t opt_debug = FALSE; while (1) { int c; int option_index = 0; const char *opt; static struct option long_options[] = { {"daemon", 1, NULL, 0}, {"help", 0, NULL, 0}, {"debug", 0, NULL, 0}, {NULL, 0, NULL, 0} }; c = getopt_long (argc, argv, "", long_options, &option_index); if (c == -1) break; switch (c) { case 0: opt = long_options[option_index].name; if (strcmp (opt, "help") == 0) { usage (); return 0; } else if (strcmp (opt, "daemon") == 0) { if (strcmp ("yes", optarg) == 0) { opt_become_daemon = TRUE; } else if (strcmp ("no", optarg) == 0) { opt_become_daemon = FALSE; } else { usage (); return 1; } } else if (strcmp (opt, "debug") == 0) { opt_debug = TRUE; } break; default: usage (); return 1; break; } } memset(result, 0, sizeof(result)); args[2] = getenv("DISPLAY"); g_spawn_async_with_pipes("/", args, NULL, 0, NULL, NULL, NULL, NULL, &in, NULL, NULL); if (read(in, result, sizeof(result)) <= 0) { die("unable to read X11 cookie"); } else { close(in); idx = rindex(result, ' '); if (idx == NULL) { die ("unable to read X11 cookie"); } cookie = g_strdup(idx+1); cookie[strlen(cookie) - 1] = '\0'; if (opt_debug) { g_print("%s: cookie for %s = '%s'\n", argv[0], args[2], cookie); } } if (opt_become_daemon) { int child_pid; int dev_null_fd; if (chdir ("/") < 0) { g_printerr ("Could not chdir to /, errno=%d", errno); return 1; } child_pid = fork (); switch (child_pid) { case -1: g_printerr ("Cannot fork(), errno=%d", errno); break; case 0: /* child */ dev_null_fd = open ("/dev/null", O_RDWR); /* ignore if we can't open /dev/null */ if (dev_null_fd > 0) { /* attach /dev/null to stdout, stdin, stderr */ dup2 (dev_null_fd, 0); if (opt_debug == FALSE) { dup2 (dev_null_fd, 1); dup2 (dev_null_fd, 2); } } umask (022); break; default: /* parent */ exit (0); break; } /* Create session */ setsid (); } gdk_init(&argc, &argv); /* init libnotify */ notify_init("s2u"); loop = g_main_loop_new (NULL, FALSE); /* set up the dbus services */ service_dbus_init (); /* run the main loop and serve clients */ g_main_loop_run (loop); return 0; }
int main (int argc, char **argv) { gchar c; /* used for argument parsing */ const gchar *filename; gint width = 0; gint height = 0; poptContext optCon; /* context for parsing command-line options */ const struct poptOption optionsTable[] = { {"width", 'w', POPT_ARG_INT, &width, 0, "Width of the output image (to be resized)", "Width"}, {"height", 'h', POPT_ARG_INT, &height, 0, "Height of the output image (to be resized)", "Height"}, POPT_AUTOHELP {NULL, 0, 0, NULL, 0} }; optCon = poptGetContext (NULL, argc, (const char **) argv, optionsTable, 0); poptSetOtherOptionHelp (optCon, "[options] <filename>"); if (argc < 2) { poptPrintUsage (optCon, stderr, 0); return 1; } while ((c = poptGetNextOpt (optCon)) >= 0) { switch (c) { case 'w': if (width <= 0) { width = 0; } break; case 'h': if (height <= 0) { height = 0; } break; } } filename = poptGetArg (optCon); if ((filename == NULL) || !(poptPeekArg (optCon) == NULL)) { poptPrintUsage (optCon, stderr, 0); g_printerr ("\n\tYou must to specify the output filename" " such as screenshot.png\n"); return -1; } if (c < -1) { /* an error occurred during option processing */ g_printerr ("%s: %s\n", poptBadOption (optCon, POPT_BADOPTION_NOALIAS), poptStrerror (c)); return 1; } gdk_init (&argc, &argv); take_screenshot (filename, width, height); poptFreeContext (optCon); return 0; }
EC_OBJ ec_gdk_init( void ) { EcTypespec gtkboxed_spec = { /* type */ 0, /* name */ "gtkboxed", /* copy */ NULL, /* mark */ gtkboxed_mark, /* free */ gtkboxed_free, /* print */ gtkboxed_print, /* hash */ NULL, /* compare */ NULL, /* check */ NULL, /* sequence */ NULL, /* numeric */ NULL }; EcTypespec gtkobject_spec = { /* type */ 0, /* name */ "gtkobject", /* copy */ NULL, /* mark */ gtkobject_mark, /* free */ gtkobject_free, /* print */ gtkobject_print, /* hash */ NULL, /* compare */ NULL, /* check */ NULL, /* sequence */ NULL, /* numeric */ NULL }; EC_OBJ pkg_gdk = EC_NIL; /* Register enumeration & flag symbols */ ec_gdk_init_symbols(); /* Register types */ tc_gtkboxed = EcAddType( >kboxed_spec ); if (tc_gtkboxed == 0) return EC_NIL; tc_gtkobject = EcAddType( >kobject_spec ); if (tc_gtkobject == 0) return EC_NIL; /* Register package */ pkg_gdk = EcPackageIntroduce( "gdk" ); /* Register automagically-generated functions in package */ ec_gdk_register_functions(); /* Register hand-written functions in packages */ ec_gdk_register_special(); /* Initialize gdk */ gdk_init( NULL, NULL ); return pkg_gdk; }
Application::Application(int argc, char** argv) : QApplication(argc, argv) { gdk_init (&argc, &argv); }