Prima

 view release on metacpan or  search on metacpan

Prima/Application.pm  view on Meta::CPAN

If WIDTH and HEIGHT extend beyond the screen dimensions, they are adjusted.  If
the offsets are outside screen boundaries, or WIDTH and HEIGHT are zero or
negative, C<undef> is returned.

Note: When running on MacOSX under XQuartz, the latter does not give access to
the whole screen, so the function will not be able to grab top-level menu bar.
This problem is addressed in C<get_fullscreen_image>.

=item get_indents

Returns 4 integers that corresponds to extensions of eventual desktop
decorations that the windowing system may present on the left, bottom, right,
and top edges of the screen. For example, for win32 this reports the size of
the part of the scraan that windows taskbar may occupies, if any.

=item get_printer

Returns the printer object, attached automatically to Prima::Application
object. The object is of C<::printerClass> class.

=item get_message_font

Prima/Application.pm  view on Meta::CPAN

	sv::SubmenuDelay     - timeout ( in ms ) before a sub-menu shows on
								an implicit selection
	sv::FullDrag         - 1 if the top-level windows are dragged dynamically,
								0 - with marquee mode
	sv::DblClickDelay    - mouse double-click timeout in milliseconds
	sv::ShapeExtension   - 1 if Prima::Widget::shape functionality is supported,
								0 otherwise
	sv::ColorPointer     - 1 if system accepts color pointer icons.
	sv::CanUTF8_Input    - 1 if system can generate key codes in unicode
	sv::CanUTF8_Output   - 1 if system can output utf8 text
	sv::CompositeDisplay - 1 if system uses double-buffering and alpha composition for the desktop,
	                       0 if it doesn't, -1 if unknown
	sv::LayeredWidgets   - 1 if system supports layering
	sv::FixedPointerSize - 0 if system doesn't support arbitrary sized pointers and will resize custom icons to the system size
	sv::MenuCheckSize    - width and height of default menu check icon
	sv::FriBidi          - 1 if Prima is compiled with libfribidi and full bidi unicode support is available
	sv::Antialias        - 1 if system supports antialiasing and alpha layer for primitives
	sv::LibThai          - 1 if Prima is compiled with libthai

The method can be called with a class string instead of an object instance.

Prima/Const.pm  view on Meta::CPAN

	sv::SubmenuDelay     - timeout ( in ms ) before a sub-menu shows on
				an implicit selection
	sv::FullDrag         - 1 if the top-level windows are dragged dynamically,
	                       0 - with marquee mode
	sv::DblClickDelay    - mouse double-click timeout in milliseconds
	sv::ShapeExtension   - 1 if Prima::Widget::shape functionality is supported,
	                       0 otherwise
	sv::ColorPointer     - 1 if system accepts color pointer icons.
	sv::CanUTF8_Input    - 1 if system can generate key codes in unicode
	sv::CanUTF8_Output   - 1 if system can output utf8 text
	sv::CompositeDisplay - 1 if system uses double-buffering and alpha composition for the desktop,
	                       0 if it doesn't, -1 if unknown
	sv::LayeredWidgets   - 1 if system supports layering
	sv::FixedPointerSize - 0 if system doesn't support arbitrary sized pointers and will resize custom icons to the system size
	sv::MenuCheckSize    - width and height of default menu check icon
	sv::FriBidi          - 1 if Prima is compiled with libfribidi and full bidi unicode support is available
	sv::Antialias        - 1 if system supports antialiasing and alpha layer for primitives
	sv::LibThai          - 1 if Prima is compiled with libthai

=head2 ta::  - alignment constants

Prima/MDI.pm  view on Meta::CPAN

	} elsif ( $x >= $size[0] - $bw - $dy * 2) {
		return (( $bi & ( mbi::Close | mbi::Maximize)) == (mbi::Close | mbi::Maximize))
			? (
				($self-> {windowState} == ws::Maximized) ? q(restore) : q(max)
			) : (
				($self-> {windowState} == ws::Minimized) ? q(restore) : q(min)
			);
	} else {
		return ($self-> {windowState} == ws::Minimized) ? q(restore) : q(min);
	}
	return q(desktop);
}

sub post_action
{
	my ( $self, $action) = @_;
	$self-> post_message(q(cmMDI), $action);
}

sub repaint_title
{

Prima/MDI.pm  view on Meta::CPAN


	border   - window border; the window is not sizeable
	client   - client widget
	caption  - titlebar; the window is not moveable
	title    - titlebar; the window is movable
	close    - close button
	min      - minimize button
	max      - maximize button
	restore  - restore button
	menu     - menu button
	desktop  - the point does not belong to the window

In addition, if the window is sizeable, the following constants can be
returned, indicating part of the border:

	SizeN    - upper side
	SizeS    - lower side
	SizeW    - left side
	SizeE    - right side
	SizeSW   - lower left corner
	SizeNW   - upper left corner

include/win32/win32guts.h  view on Meta::CPAN


#ifdef __cplusplus
extern "C" {
#endif


#define SEVERE_DEBUG
typedef HANDLE WINHANDLE;
typedef HANDLE SOCKETHANDLE;
#undef  HWND_DESKTOP
#define HWND_DESKTOP         guts. desktop_window


#ifdef UNICODE
#error This version of apc_Win32 does not support Unicode
#endif

#define DEFAULT_SYSTEM_FONT              "System"
#define DEFAULT_WIDGET_FONT              (((DWORD)(LOBYTE(LOWORD(guts.version)))>5)?"Segoe UI":"MS Shell Dlg")
#define DEFAULT_WIDGET_FONT_SIZE         (((DWORD)(LOBYTE(LOWORD(guts.version)))>5)?9:8)
#define COLOR_TOLERANCE                  4

include/win32/win32guts.h  view on Meta::CPAN

	DWORD          main_thread_id;      // Id of main thread
	Point          display_resolution;  // screen resolution in ppi
	char           default_fixed_font    [256];
	char           default_variable_font [256];
	char           default_system_font   [256];
	Font           window_font;         // window default font
	Font           menu_font;           // menu default font
	Font           msg_font;            // message default font
	Font           cap_font;            // caption default font
	BITMAPINFO     display_bm_info;     // display bpp & size
	HWND           desktop_window;      // GetDesktopWindow() result
	Bool           insert_mode;         // fake insert mode
	Point          icon_size_large;
	Point          icon_size_small;
	Point          pointer_size;
	BYTE           key_state[ 256];      // application key buffer state
	BYTE           empty_key_state[ 256];// just zeros
	BYTE          *current_key_state;    // current virtual key buffer state
	HKL            key_layout;           // key layout, most likely latin for Ctrl+Key mapping
	NONCLIENTMETRICSW ncmData;           // windows system data
	List           transp;               // transparent controls list

pod/Prima/Window.pod  view on Meta::CPAN


There are more about Prima::Window in areas, that it is
specifically designed to - the system window management and
the dialog execution.

=head2 System window management

As noted before, top-level windows are special for the system,
not only in their 'look', but also in 'feel': the system adds
specific functions to the windows, aiding the user to navigate through
the desktop. The system often dictates the size and position for
windows, and some times these rules are hard or even impossible to
circumvent. This document will be long if it would venture to describe the features
of different window management systems, and the task would be
never accomplished - brand new window managers emerge every month,
and the old change their behavior in an unpredictable way. The only
golden rule is to never rely on the behavior of one window manager,
and test programs with at least two.

The Prima toolkit provides simple access to buttons, title bar
and borders of a window. Buttons and title bar are managed by

pod/Prima/X11.pod  view on Meta::CPAN

apply the coordinates given from the program not to the top-level widget
itself, but to its decoration.  mwm defines list of accepted icon sizes so
these can be absurdly high, which adds confusion to a client who can create
icon of any size, but unable to determine the best one.

=head2 Non-standard properties

Prima tries to use WM-specific hints, known for two window managers: mwm and
kwin.  For mwm ( Motif window manager ) Prima sets hints of decoration border
width and icons only. For kwin ( and probably to others, who wish to conform to
specifications of http://www.freedesktop.org/ ) Prima uses C<NET_WM_STATE>
property, in particular its maximization and task-bar visibility hints.

Use of these explicitly contradicts ICCCM, and definitely may lead to bugs in
future ( at least with C<NET_WM_STATE>, since Motif interface can hardly
expected to be changed ).  To disable the use of non-standard WM properties,
C<--icccm> command-line argument can be set.

=head1 Unicode

X does not support unicode, and number of patches were applied to X servers and

t/Object/Application.t  view on Meta::CPAN


my @sz = $a->size;

# Test screen grabbing
SKIP: {
	if ($^O eq 'darwin') {
		skip "not compiled with cocoa", 3 unless $a->get_system_info->{guiDescription} =~ /Cocoa/;
	} elsif ( ($ENV{XDG_SESSION_TYPE} // 'x11') ne 'x11') {
		skip "not compiled with gtk", 3 unless $a->get_system_info->{gui} == gui::GTK;
	} elsif ( $^O =~ /win32/i && $::application->pixel(0,0) == cl::Invalid) {
		skip "rdesktop", 3;
	} elsif ( $::application->get_bpp < 8 ) {
		skip "depth too low", 3;
	}

	reset_flag;
	my $w = $a->insert(
		(($^O =~ /win32/i) ? (
			Window =>
				borderStyle => bs::None,
				borderIcons => 0,

t/Object/Application.t  view on Meta::CPAN

	ok($r < 0x40 && $g > 0x80 && $b < 0x40, "another is green");
	$w->destroy;
}



SKIP: {
	skip "system doesn't allow direct access to screen", 3 unless $a-> begin_paint;
	ok( $a-> get_paint_state, "get_paint_state");
	my $pix = $a-> pixel( 10, 10);
	skip "rdesktop", 2 if $^O =~ /win32/i && $pix == cl::Invalid;

	$a-> pixel( 10, 10, 0);
	my $bl = $a-> pixel( 10, 10);
	$a-> pixel( 10, 10, 0xFFFFFF);
	my $wh = $a-> pixel( 10, 10);
	$a-> pixel( 10, 10, $pix);
	skip "cannot sync display", 2 if $bl == $wh;
	my ( $xr, $xg, $xb) = (( $wh & 0xFF0000) >> 16, ( $wh & 0xFF00) >> 8, $wh & 0xFF);
	$wh =  ( $xr + $xg + $xb ) / 3;
	is( $bl, 0, "black pixel");

t/Object/Clipboard.t  view on Meta::CPAN


plan tests => 11;
my $c = $::application-> Clipboard;
ok( $c && $c-> alive, "alive");

my %rc = map { $_ => 1 } $c-> get_registered_formats;
ok( exists $rc{'Text'} && exists $rc{'Image'}, "predefined formats" );

SKIP: {
$::application->begin_paint;
skip "rdesktop", 9 if $^O =~ /win32/i && $::application->pixel(0,0) == cl::Invalid;
$::application->end_paint;

sub try(&$)
{
	my $sub  = shift;
	my $skip = shift;
	for ( 1..2 ) {
		return 1 if $sub->();
		sleep(1);
	}

t/Object/GP.t  view on Meta::CPAN

		for ( $j = 0; $j < 8; $j++) {
			$xi-> pixel( $i,$j) == 0 ?
				$bl++ : $wh++;
		}
	}
	return $bl;
}

my $bl = text_out_test($x);
if ( $bl == 0 ) {
	# did we hit this bug? https://gitlab.freedesktop.org/xorg/xserver/issues/87
	my $x = Prima::DeviceBitmap-> create( type => dbt::Pixmap, width => 8, height => 8);
	$bl = text_out_test($x);
}

	
cmp_ok( $bl, '>', 5, "text_out");

# 21
my $y = Prima::DeviceBitmap-> create( type => dbt::Bitmap, width => 2, height => 2);
$y-> clear;

t/Widget/Mouse.t  view on Meta::CPAN

my @ppx = $c-> pointerPos;

SKIP: {
	$c-> capture(1) or skip "Can't capture", 1;
	$c-> focus;
	ok( $c-> capture, "capture" );
}

SKIP: {
	$::application->begin_paint;
	skip "rdesktop", 3 if $^O =~ /win32/i && $::application->pixel(0,0) == cl::Invalid;
	$::application->end_paint;

	reset_flag;
	$c-> pointerPos( 10, 10);
	my @pp = $c-> pointerPos;
	is( $pp[0], 10, "positioning" );
	is( $pp[1], 10, "positioning" );
	$c-> pointerPos( 11, 11);
	ok( wait_flag, "simulated movement" );

t/Widget/Paint.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;
use Prima::sys::Test;

reset_flag;
my $window = create_window;

$::application->begin_paint;
plan skip_all => "rdesktop" if $^O =~ /win32/i && $::application->pixel(0,0) == cl::Invalid;
$::application->end_paint;

$Prima::sys::Test::timeout = 5000;

plan tests => 11;

$window-> bring_to_front;
my @rcrect;
my $ww = $window-> insert( Widget => origin => [ 0, 0] => size => [ 8, 8],
                           syncPaint => 0,

unix/app.c  view on Meta::CPAN

apc_application_get_handle( Handle self, ApiHandle apiHandle)
{
	return prima_xw2h(( XWindow) apiHandle);
}

static Bool
wm_net_get_current_workarea( Rect * r)
{
	Bool ret = false;
	unsigned long n;
	unsigned long *desktop = NULL, *workarea = NULL, *w;

	if ( guts. icccm_only) return false;

	desktop = ( unsigned long *) prima_get_window_property( guts. root,
					NET_CURRENT_DESKTOP, XA_CARDINAL,
					NULL, NULL,
					&n);
	if ( desktop == NULL || n < 1) goto EXIT;
	Mdebug("wm: current desktop = %d\n", *desktop);

	workarea = ( unsigned long *) prima_get_window_property( guts. root,
					NET_WORKAREA, XA_CARDINAL,
					NULL, NULL,
					&n);
	if ( desktop == NULL || n < 1 || n <= *desktop ) goto EXIT;

	w = workarea + *desktop * 4; /* XYWH quartets */
	r-> left   = w[0];
	r-> top    = w[1];
	r-> right  = w[2];
	r-> bottom = w[3];
	ret = true;
	Mdebug("wm: current workarea = %d:%d:%d:%d\n", w[0], w[1], w[2], w[3]);

EXIT:
	free( workarea);
	free( desktop);
	return ret;
}

Rect
apc_application_get_indents( Handle self)
{
	Point sz;
	Rect  r;

	bzero( &r, sizeof( r));

unix/dnd.c  view on Meta::CPAN

#include "unix/guts.h"
#include "Window.h"
#include "Application.h"

/* See specs at https://www.freedesktop.org/wiki/Specifications/XDND/ */

#define dndAsk 0x100

static int
xdnd_atom_to_constant( Atom atom )
{
	if ( atom == XdndActionMove)
		return dndMove;
	else if ( atom == XdndActionCopy)
	      return dndCopy;

unix/render.c  view on Meta::CPAN

#ifdef HAVE_X11_EXTENSIONS_XRENDER_H

#define SORT(a,b)	{ int swp; if ((a) > (b)) { swp=(a); (a)=(b); (b)=swp; }}
#define REVERT(a)	(XX-> size. y - (a) - 1)
#define SHIFT(a,b)	{ (a) += XX-> btransform. x; (b) += XX-> btransform. y; }
#define RANGE(a)        { if ((a) < -16383) (a) = -16383; else if ((a) > 16383) a = 16383; }
#define RANGE2(a,b)     RANGE(a) RANGE(b)
#define RANGE4(a,b,c,d) RANGE(a) RANGE(b) RANGE(c) RANGE(d)

/*
https://gitlab.freedesktop.org/xorg/lib/libxrender/-/issues/1:
tesselation in xrender is horribly broken, but for now I'll give it a go to at least not throw a coredump

source is from https://github.com/freedesktop/xorg-libXrender/blob/master/src/Poly.c, (c) Keith Packard

*/
int
my_XRenderCompositeDoublePoly (Display		    *dpy,
			    int			    op,
			    Picture		    src,
			    Picture		    dst,
			    _Xconst XRenderPictFormat	*maskFormat,
			    int			    xSrc,
			    int			    ySrc,

unix/window.c  view on Meta::CPAN

/*                                                         */
/***********************************************************/

#include "unix/guts.h"
#include "Menu.h"
#include "Icon.h"
#include "Window.h"
#include "Application.h"

/* Tell a NET-compliant window manager that the window needs special treatment.
	See freedesktop.org for docs

	params - 0 - clear, 1 - set
*/
static void
set_net_hint(XWindow window, Bool state, Atom prop1, Atom prop2)
{
	XClientMessageEvent ev;

	if ( guts. icccm_only) return;

utils/podview.pl  view on Meta::CPAN


if ( defined $opt{geometry} ) {
	my ( $w, $h, $sx, $x, $sy, $y );
	if ( $opt{geometry} =~ /^(\d+)x(\d+)$/) {
		( $w, $h ) = ( $1, $2 );
	} elsif ( $opt{geometry} =~ /^(\d+)x(\d+)([\+\-])(-?\d+)([\+\-])(-?\d+)$/ ) {
		( $w, $h, $sx, $x, $sy, $y ) = ( $1, $2, $3, $4, $5, $6 );
	} else {
		usage;
	}
	my @desktop = $::application-> size;
	my $p = \ %SoleHelpViewer::profile_default;
	$p->{width}  = $w;
	$p->{height} = $h;
	$p->{sizeDontCare}   = 0;

	if ( defined $x ) {
		$p->{left}   = $x;
		$p->{bottom} = $y;
		$p->{left}   = $desktop[0] - $w - $x if $sx eq '-';
		$p->{bottom} = $desktop[1] - $h - $y - $::application-> get_system_value(sv::YTitleBar) - $::application-> get_system_value(sv::YMenu)
			if $sy eq '+';
		$p->{originDontCare} = 0;
	}
}

$Prima::HelpViewer::windowClass = 'SoleHelpViewer';

my $htx = ( @ARGV ? $ARGV[0] : $0 );
if ( -f $htx) {
	$htx = "file://$htx";

win32/global.c  view on Meta::CPAN

	GetVersionEx( &os);
	guts. utf8_prepend_0x202D =
		(( os.dwMajorVersion > 5) || (os.dwMajorVersion == 5 && os.dwMinorVersion > 1)) ?
					1 : 0;
	guts. alloc_utf8_to_wchar_visual =
		guts. utf8_prepend_0x202D ?
			alloc_utf8_to_wchar_visual :
			alloc_utf8_to_wchar;
	guts. main_thread_id = GetCurrentThreadId();
	guts. error_mode = SetErrorMode( SEM_FAILCRITICALERRORS);
	guts. desktop_window = GetDesktopWindow();
	std_arrow_cursor    = LoadCursor( NULL, IDC_ARROW);

	memset( &wc, 0, sizeof( wc));
	wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
	wc.lpfnWndProc   = ( WNDPROC) generic_app_handler;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = guts. instance;
	wc.hIcon         = LoadIcon( guts. instance, IDI_APPLICATION);
	wc.hCursor       = LoadCursor( NULL, IDC_ARROW);

win32/global.c  view on Meta::CPAN

			ev. gen . P. y = sz. y - ( short) HIWORD( mp2) - sys y_override;
		}
		break;
	}
// case WM_SYSCHAR:return 1;
	case WM_TIMER:
		if ( mp1 == TID_USERMAX) {
			POINT p;
			HWND wp;
			if ( last_mouse_over && !GetCapture() && ( PObject( last_mouse_over)-> stage == csNormal)) {
				HWND desktop = HWND_DESKTOP;
				GetCursorPos( &p);
				wp = WindowFromPoint( p);
				if ( wp) {
					POINT xp = p;
					MapWindowPoints( desktop, wp, &xp, 1);
					wp = ChildWindowFromPointEx( wp, xp, CWP_SKIPINVISIBLE);
				} else
					wp = ChildWindowFromPointEx( wp, p, CWP_SKIPINVISIBLE);
				if ( wp != ( HWND)(( PWidget) last_mouse_over)-> handle)
				{
					HWND old = ( HWND)(( PWidget) last_mouse_over)-> handle;
					Handle s;
					last_mouse_over = NULL_HANDLE;
					SendMessage( old, WM_MOUSEEXIT, 0, 0);
					s = hwnd_to_view( wp);
					if ( s && ( HWND)(( PWidget) s)-> handle == wp)
					{
						MapWindowPoints( desktop, wp, &p, 1);
						SendMessage( wp, WM_MOUSEENTER, 0, MAKELPARAM( p. x, p. y));
						last_mouse_over = s;
					} else if ( guts. mouse_timer) {
						guts. mouse_timer = 0;
						if ( !KillTimer( dsys(prima_guts.application)handle, TID_USERMAX)) apiErr;
					}
				}
			}
			return 0;
		} else {



( run in 0.689 second using v1.01-cache-2.11-cpan-299005ec8e3 )