void GetCursorInfo() { CGSConnectionRef connection = getConnection(); CGError err = noErr; int cursorDataSize, depth, components, bitsPerComponent, cursorRowSize; unsigned char* cursorData; CGPoint location, hotspot; CGRect cursorRect; int i, j; err = CGSGetCurrentCursorLocation(connection, &location); printf("location (err %d) = %d, %d\n", err, (int)location.x, (int)location.y); err = CGSGetGlobalCursorDataSize(connection, &cursorDataSize); printf("data size (err %d) = %d\n", err, cursorDataSize); cursorData = (unsigned char*)calloc(cursorDataSize, sizeof(unsigned char)); err = CGSGetGlobalCursorData(connection, cursorData, &cursorDataSize, &cursorRowSize, &cursorRect, &hotspot, &depth, &components, &bitsPerComponent); printf("rect origin (%g, %g), dimensions (%g, %g)\n", cursorRect.origin.x, cursorRect.origin.y, cursorRect.size.width, cursorRect.size.height); printf("hotspot (%g, %g)\n", hotspot.x, hotspot.y); printf("depth: %d\n", depth); printf("components: %d\n", components); printf("bits per component: %d\n", bitsPerComponent); printf("Bytes Per Row: %d\n", cursorRowSize); printf("Components (err %d):\n", err); // Print Colors for (j=0; j < components; j++) { printf("\n"); for (i=0; i < cursorDataSize; i++) { if (i % cursorRowSize == 0) printf("\n"); if (i % components == j) printf("%02x", (int)cursorData[i]); } } printf("released connection (err %d)\n", CGSReleaseConnection(connection)); }
int screen_CloseCapture( demux_t *p_demux ) { screen_data_t *p_data = ( screen_data_t * )p_demux->p_sys->p_data; CGSReleaseConnection( p_data->connection ); CGLSetCurrentContext( NULL ); CGLClearDrawable( p_data->screen ); CGLDestroyContext( p_data->screen ); return VLC_SUCCESS; }
int screen_CloseCapture( demux_t *p_demux ) { screen_data_t *p_data = ( screen_data_t * )p_demux->p_sys->p_data; CGLSetCurrentContext( NULL ); /* Cursor */ glBindTexture( GL_TEXTURE_2D, 0 ); glDeleteTextures( 1, &( p_data->cursor_texture ) ); CGSReleaseConnection( p_data->connection ); /* Screen Image */ if( p_data->screen_image != NULL ) { free( p_data->screen_image ); p_data->screen_image = NULL; } /* Clipped Image */ if( p_data->clipped_image != NULL ) { free( p_data->clipped_image ); p_data->clipped_image = NULL; } /* Clipped Context */ CGLClearDrawable( p_data->clipped ); CGLDestroyContext( p_data->clipped ); /* Screen Context */ if( p_data->myCGDisplayCreateImageForRect == NULL ) { CGLClearDrawable( p_data->screen ); CGLDestroyContext( p_data->screen ); } /* CGImage */ CFRelease( p_data->bundle ); free( p_data ); return VLC_SUCCESS; }