Example #1
0
void
FreeMyAppResources()
{
	cleanup_default_balloons();
	destroy_asdatabase();
    mystyle_destroy_all();
    mylook_init( &(ASDefaultScr->Look), True, ASFLAGS_EVERYTHING );
    destroy_image_manager( ASDefaultScr->image_manager, False );
    destroy_font_manager( ASDefaultScr->font_manager, False );
    clientprops_cleanup ();
    destroy_wmprops (ASDefaultScr->wmprops, False);
    wmprops_cleanup ();
    free_func_hash();
	flush_keyword_ids();
    purge_asimage_registry();
	asxml_var_cleanup();
	custom_color_cleanup();
    build_xpm_colormap( NULL );
    destroy_screen_gcs(ASDefaultScr);
	if( ASDefaultScr->RootImage ) 
	{	
		safe_asimage_destroy( ASDefaultScr->RootImage );
		ASDefaultScr->RootImage = NULL ;
	}
	destroy_asvisual( ASDefaultScr->asv, False );
	free_as_app_args();
    destroy_assession( Session );
	Session = NULL ;
	destroy_asenvironment( &Environment );
	is_executable_in_path ( NULL );
#ifdef XSHMIMAGE
	flush_shm_cache();
#endif
	free( ASDefaultScr );
	flush_default_asstorage();
    flush_asbidirlist_memory_pool();
	flush_ashash_memory_pool();
	
}
Example #2
0
int main(int argc, char* argv[])
{
	char *image_file = "rose512.jpg" ;
	ASImage *im ;
	ASVisual *asv ;
	int screen = 0, depth = 24;
	Display *dpy = NULL;

	/* see ASView.1 : */
	set_application_name( argv[0] );
#if (HAVE_AFTERBASE_FLAG==1)
	set_output_threshold(OUTPUT_LEVEL_DEBUG);
#ifdef DEBUG_ALLOCS
	fprintf( stderr, "have DEBUG_ALLOCS\n");
#endif
#ifdef AFTERBASE_DEBUG_ALLOCS
	fprintf( stderr, "have AFTERBASE_DEBUG_ALLOCS\n");
#endif
#endif

	if( argc > 1 )
	{
		if( strcmp( argv[1], "-h" ) == 0 )
		{
			usage();
			return 0;
		}
		image_file = argv[1] ;
	}else
	{
		show_warning( 	"Image filename was not specified. "
						"Using default: \"%s\"", image_file );
		usage();
	}
#ifndef X_DISPLAY_MISSING
	dpy = XOpenDisplay(NULL);
	XSynchronize (dpy, True);
	_XA_WM_DELETE_WINDOW = XInternAtom( dpy, "WM_DELETE_WINDOW", 
										False);
	screen = DefaultScreen(dpy);
	depth = DefaultDepth( dpy, screen );
#endif	
	/* see ASView.3 : */
	asv = create_asvisual( dpy, screen, depth, NULL );
	/* asv = create_asvisual_for_id( dpy, screen, depth, 0x28, None, NULL ); */

	/* see ASView.2 : */
	im = file2ASImage( image_file, 0xFFFFFFFF, SCREEN_GAMMA, 0, getenv("IMAGE_PATH"), NULL );

	/* The following could be used to dump JPEG version of the image into
	 * stdout : */
	/* 	ASImage2file( im, NULL, NULL, ASIT_Jpeg, NULL ); 
		ASImage2file( im, NULL, "asview.png", ASIT_Png, NULL );
		ASImage2file( im, NULL, "asview.gif", ASIT_Gif, NULL );
	*/

	if( im != NULL )
	{
#ifndef X_DISPLAY_MISSING
		Window w ;
#if 0
		/* test example for get_asimage_channel_rects() : */
		XRectangle *rects ;	unsigned int rects_count =0; int i ;
		rects = get_asimage_channel_rects( im, IC_ALPHA, 10, 
											&rects_count );
		fprintf( stderr, " %d rectangles generated : \n", rects_count );
		for( i = 0 ; i < rects_count ; ++i )
			fprintf( stderr, "\trect[%d]=%dx%d%+d%+d;\n", 
					 i, rects[i].width, rects[i].height, 
					 rects[i].x, rects[i].y );
#endif


#if 0		 
		/* test example for fill_asimage : */
		fill_asimage(asv, im, 0, 0, 50, 50, 0xFFFF0000);
		fill_asimage(asv, im, 50, 50, 100, 50, 0xFFFF0000);
		fill_asimage(asv, im, 0, 100, 200, 50, 0xFFFF0000);
		fill_asimage(asv, im, 150, 0, 50, 50, 0xFFFF0000);
#endif
#if 0
		/* test example for conversion to argb32 :*/
		{
			ASImage *tmp = tile_asimage( asv, im, 0, 0, im->width, im->height, TINT_NONE, ASA_ARGB32, 
										  0, ASIMAGE_QUALITY_DEFAULT );	 
			destroy_asimage( &im );
			set_flags( tmp->flags, ASIM_DATA_NOT_USEFUL|ASIM_XIMAGE_NOT_USEFUL );
			im = tmp ;
		}		   
#endif		   
		/* see ASView.4 : */
		w = create_top_level_window( asv, DefaultRootWindow(dpy), 32, 32,
			                         im->width, im->height, 1, 0, NULL,
									 "ASView", image_file );
		if( w != None )
		{
			Pixmap p ;
	  		
			XMapRaised   (dpy, w);
			XSync(dpy,False);
			/* see ASView.5 : */
	  		p = create_visual_pixmap( asv, DefaultRootWindow(dpy), im->width, im->height, 0 );
	
			{
				START_TIME(started);
				/* for( int i = 0 ; i < 100 ; ++i )  To test performance! */
				asimage2drawable( asv, p, im, NULL, 0, 0, 0, 0, im->width, im->height, False);
				SHOW_TIME("", started);
			}
			/* print_storage(NULL); */
			destroy_asimage( &im );
			/* see common.c:set_window_background_and_free(): */
			p = set_window_background_and_free( w, p );
		}
		/* see common.c: wait_closedown() : */
		wait_closedown(w);
		dpy = NULL;
		
		/* no longer need this - lets clean it up :*/
		destroy_asvisual( asv, False );
		asv = NULL ;

#else
		/* writing result into the file */
		ASImage2file( im, NULL, "asview.png", ASIT_Png, NULL );
#endif
	}

#ifdef DEBUG_ALLOCS
    /* different cleanups of static memory pools : */
    flush_ashash_memory_pool();
	asxml_var_cleanup();
	custom_color_cleanup();
    build_xpm_colormap( NULL );
	flush_default_asstorage();
	/* requires libAfterBase */
	print_unfreed_mem();
#endif

    return 0 ;
}
Example #3
0
rxvt_term::~rxvt_term ()
{
  termlist.erase (find (termlist.begin (), termlist.end(), this));

  emergency_cleanup ();

#if ENABLE_STYLES
  for (int i = RS_styleCount; --i; )
    if (fontset[i] != fontset[0])
      delete fontset[i];
#endif
  delete fontset[0];

#ifdef HAVE_BG_PIXMAP
  bgPixmap.destroy ();
#endif
#ifdef HAVE_AFTERIMAGE
  if (asv)
    destroy_asvisual (asv, 0);
  if (asimman)
    destroy_image_manager (asimman, 0);
#endif

  if (display)
    {
      selection_clear ();

#ifdef USE_XIM
      im_destroy ();
#endif
      scrollBar.destroy ();
      if (gc)   XFreeGC (dpy, gc);

      delete drawable;
      // destroy all windows
      if (parent[0])
        XDestroyWindow (dpy, parent[0]);

      for (int i = 0; i < TOTAL_COLORS; i++)
        if (ISSET_PIXCOLOR (i))
          {
            pix_colors_focused   [i].free (this);
#if OFF_FOCUS_FADING
            pix_colors_unfocused [i].free (this);
#endif
          }

      clear ();

      display->flush (); /* ideally .put should do this */
      displays.put (display);
    }

  scr_release ();

  /* clear all resources */
  for (int i = 0; i < allocated.size (); i++)
    free (allocated [i]);

  free (selection.text);
  // TODO: manage env vars in child only(!)
  free (env_display);
  free (env_term);
  free (locale);
  free (v_buffer);
  free (incr_buf);

  delete envv;
  delete argv;

#ifdef KEYSYM_RESOURCE
  delete keyboard;
#endif
#ifndef NO_RESOURCES
  XrmDestroyDatabase (option_db);
#endif
}
Example #4
0
void
CleanupScreen()
{
    int i ;

    if( Scr.Windows )
    {
        grab_server();
        destroy_aswindow_list( &(Scr.Windows), True );
        ungrab_server();
    }

	destroy_balloon_state(&TitlebarBalloons); 
	destroy_balloon_state(&MenuBalloons); 

	release_all_old_background( True );

    DestroyManagementWindows();
    CleanupColormaps();

    if( Scr.RootCanvas )
        destroy_ascanvas( &(Scr.RootCanvas) );

    XSetInputFocus (dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
	XSync (dpy, 0);

#ifdef HAVE_XINERAMA
	if (Scr.xinerama_screens)
	{
		free (Scr.xinerama_screens);
		Scr.xinerama_screens_num = 0;
		Scr.xinerama_screens = NULL;
	}
#endif /* XINERAMA */


    for( i = 0 ; i < MAX_CURSORS; ++i )
        if( Scr.standard_cursors[i] )
        {
            XFreeCursor( dpy, Scr.standard_cursors[i] );
            Scr.standard_cursors[i] = None ;
        }

    InitLook(&Scr.Look, True);
    InitFeel(&Scr.Feel, True);


    /* free display strings; can't do this in main(), because some OS's
     * don't copy the environment variables properly */
    if( Scr.display_string )
    {
        free (Scr.display_string);
        Scr.display_string = NULL ;
    }
    if( Scr.rdisplay_string )
    {
        free (Scr.rdisplay_string);
        Scr.rdisplay_string = NULL ;
    }

    if( Scr.RootBackground )
    {
        if( Scr.RootBackground->pmap )
        {
            if( Scr.wmprops->root_pixmap == Scr.RootBackground->pmap )
			{	
                set_xrootpmap_id (Scr.wmprops, None );
				set_as_background(Scr.wmprops, None );
			}
            XFreePixmap( dpy, Scr.RootBackground->pmap );
            ASSync(False);
            LOCAL_DEBUG_OUT( "root pixmap with id %lX destroyed", Scr.RootBackground->pmap );
            Scr.RootBackground->pmap = None ;
        }
        free( Scr.RootBackground );
    }
LOCAL_DEBUG_OUT("destroying image manager : %p", Scr.image_manager);
    destroy_image_manager( Scr.image_manager, False );
LOCAL_DEBUG_OUT("destroying font manager : %p", Scr.font_manager);
    destroy_font_manager( Scr.font_manager, False );

LOCAL_DEBUG_OUT("destroying visual : %p", Scr.asv);
    destroy_screen_gcs(ASDefaultScr);
	destroy_asvisual( Scr.asv, False );

LOCAL_DEBUG_OUT("selecting input mask for Root window to 0 : %s","");
	/* Must release SubstructureRedirectMask prior to releasing wm selection in
	 * destroy_wmprops() : */
	XSelectInput( dpy, Scr.Root, 0 );
	XUngrabPointer( dpy, CurrentTime );
	XUngrabButton (dpy, AnyButton, AnyModifier, Scr.Root);

LOCAL_DEBUG_OUT("destroying wmprops : %p",Scr.wmprops);
	/* this must be done at the very end !!!! */
	destroy_wmprops( Scr.wmprops, False);
LOCAL_DEBUG_OUT("screen cleanup complete.%s","");
}