Аналог SetShape в X Window System

Вопросы программирования на Free Pascal, использования компилятора и утилит.

Модератор: Модераторы

Re: Аналог SetShape в X Window System

Сообщение coyot.rush » 14.12.2010 20:43:07

Код: Выделить всё
typedef struct {
    int   type;          /* of event */
    unsigned long serial;   /* # of last request processed by server */
    Bool send_event;       /* true if this came frome a SendEvent request */
    Display *display;       /* Display the event was read from */
    Window window;       /* window of event */
    int kind;          /* ShapeBounding or ShapeClip */
    int x, y;          /* extents of new region */
    unsigned width, height;
    Time time;          /* server timestamp when region changed */
    Bool shaped;       /* true if the region exists */
} XShapeEvent;

В принципе пока и без него можно попробовать, да и в модуле shape.h не используется
Аватара пользователя
coyot.rush
постоялец
 
Сообщения: 309
Зарегистрирован: 14.08.2009 08:59:48

Re: Аналог SetShape в X Window System

Сообщение Mr.Smart » 14.12.2010 20:49:29

Смотрите как он определён в исходниках
Mr.Smart
долгожитель
 
Сообщения: 1796
Зарегистрирован: 29.03.2008 01:01:11
Откуда: из леса!

Re: Аналог SetShape в X Window System

Сообщение coyot.rush » 14.12.2010 21:12:54

Код: Выделить всё
#include <X11/Xfuncproto.h>
#include <X11/extensions/shapeconst.h>
#ifndef _SHAPE_SERVER_
#include <X11/Xutil.h>


Не в Xfuncproto.h не в Xutil.h нет объявлений для Time, да и в других модулях комментарии для типа Time вида time in ms , т . е. это скорее integer
Аватара пользователя
coyot.rush
постоялец
 
Сообщения: 309
Зарегистрирован: 14.08.2009 08:59:48

Re: Аналог SetShape в X Window System

Сообщение Mr.Smart » 14.12.2010 21:17:03

Скорее всего Integer или что мало вероятно Int64.
Mr.Smart
долгожитель
 
Сообщения: 1796
Зарегистрирован: 29.03.2008 01:01:11
Откуда: из леса!

Re: Аналог SetShape в X Window System

Сообщение coyot.rush » 14.12.2010 22:08:15

Код: Выделить всё
procedure test();
var
prDisplay: PDisplay;  (* Указатель на структуру Display *)
nScreenNum: integer;    (* Номер экрана *)
event_base,error_base :   Logint;
begin
(* Устанавливаем связь с сервером *)
prDisplay := XOpenDisplay ( nil );
if prDisplay = nil  then begin
  writeln('Can not connect to the X server!');
exit;
end;
(* Получаем номер основного экрана *)
nScreenNum := XDefaultScreen ( prDisplay );
(*Данные о Shape расширение*)
XShapeQueryExtension(prDisplay,event_base,error_base);
XCloseDisplay ( prDisplay );
end;


Получаю AV
PS Код C Shape.h
Код: Выделить всё
/* $XFree86: xc/include/extensions/shape.h,v 1.3 2001/12/14 19:53:29 dawes Exp $ */
/************************************************************

Copyright 1989, 1998  The Open Group

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.

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

/* $Xorg: shape.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ */

#ifndef _SHAPE_H_
#define _SHAPE_H_

#include <X11/Xfuncproto.h>
#include <X11/extensions/shapeconst.h>

#ifndef _SHAPE_SERVER_
#include <X11/Xutil.h>

typedef struct {
    int   type;          /* of event */
    unsigned long serial;   /* # of last request processed by server */
    Bool send_event;       /* true if this came frome a SendEvent request */
    Display *display;       /* Display the event was read from */
    Window window;       /* window of event */
    int kind;          /* ShapeBounding or ShapeClip */
    int x, y;          /* extents of new region */
    unsigned width, height;
    Time time;          /* server timestamp when region changed */
    Bool shaped;       /* true if the region exists */
} XShapeEvent;

_XFUNCPROTOBEGIN

extern Bool XShapeQueryExtension (
    Display*   /* display */,
    int*   /* event_base */,
    int*   /* error_base */
);

extern Status XShapeQueryVersion (
    Display*   /* display */,
    int*   /* major_version */,
    int*   /* minor_version */
);

extern void XShapeCombineRegion (
    Display*   /* display */,
    Window   /* dest */,
    int      /* dest_kind */,
    int      /* x_off */,
    int      /* y_off */,
    Region   /* region */,
    int      /* op */
);

extern void XShapeCombineRectangles (
    Display*   /* display */,
    Window   /* dest */,
    int      /* dest_kind */,
    int      /* x_off */,
    int      /* y_off */,
    XRectangle*   /* rectangles */,
    int      /* n_rects */,
    int      /* op */,
    int      /* ordering */
);

extern void XShapeCombineMask (
    Display*   /* display */,
    Window   /* dest */,
    int      /* dest_kind */,
    int      /* x_off */,
    int      /* y_off */,
    Pixmap   /* src */,
    int      /* op */
);

extern void XShapeCombineShape (
    Display*   /* display */,
    Window   /* dest */,
    int      /* dest_kind */,
    int      /* x_off */,
    int      /* y_off */,
    Window   /* src */,
    int      /* src_kind */,
    int      /* op */
);

extern void XShapeOffsetShape (
    Display*   /* display */,
    Window   /* dest */,
    int      /* dest_kind */,
    int      /* x_off */,
    int      /* y_off */
);

extern Status XShapeQueryExtents (
    Display*      /* display */,
    Window      /* window */,
    Bool*      /* bounding_shaped */,
    int*      /* x_bounding */,
    int*      /* y_bounding */,
    unsigned int*   /* w_bounding */,
    unsigned int*   /* h_bounding */,
    Bool*      /* clip_shaped */,
    int*      /* x_clip */,
    int*      /* y_clip */,
    unsigned int*   /* w_clip */,
    unsigned int*   /* h_clip */
);

extern void XShapeSelectInput (
    Display*      /* display */,
    Window      /* window */,
    unsigned long   /* mask */
);

extern unsigned long XShapeInputSelected (
    Display*   /* display */,
    Window   /* window */
);

extern XRectangle *XShapeGetRectangles (
    Display*   /* display */,
    Window   /* window */,
    int      /* kind */,
    int*   /* count */,
    int*   /* ordering */
);

_XFUNCPROTOEND

#endif /* !_SHAPE_SERVER_ */

#endif /* _SHAPE_H_ */


Добавлено спустя 15 минут 6 секунд:
В чем разница int* и int, насколько я понял int* это указатель на int

Добавлено спустя 13 минут 22 секунды:
(C) *int => (Ctype) pcint
(C) unsigned int* => (CType) pculong

Добавлено спустя 15 минут 14 секунд:
Исправленная версия
Код: Выделить всё
unit xshape;
interface
uses
ctypes,x,xlib;

{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}


type
     XShapeEvent = record
          _type : longint;
          serial : dword;
          send_event : CBool;
          display : ^Display;
          window : TWindow;
          kind : longint;
          x : longint;
          y : longint;
          width : dword;
          height : dword;
          time : integer;
          shaped : cBool;
       end;
   
    type
    TBox=record
    x1:SmallInt;
    x2:SmallInt;
    y1:SmallInt;
    y2:SmallInt;
    end;
       
    PBox=^Tbox;

    TRegion=record
    size:Longint;
    numRects:Longint;
    rects:PBox;
    extents:TBox;
    end;

 

const
LibXShape='libXext.so';

SHAPE_MAJOR_VERSION  =   1; //current version numbers
SHAPE_MINOR_VERSION  =   1;
ShapeSet        =   0;
ShapeUnion        =   1;
ShapeIntersect        =   2;
ShapeSubtract        =   3;
ShapeInvert        =   4;

ShapeBounding        =  0;
ShapeClip        =   1;
ShapeInput        =   2;

ShapeNotifyMask   =(1 shl 0);
ShapeNotify     =    0;

ShapeNumberEvents    =   (ShapeNotify + 1);

function  XShapeQueryExtension (
    Display    :   PDisplay;
    event_base :   pcint;
    error_base :   pcint
):cBool;cdecl;external LibXShape;


function XShapeQueryVersion (
    display : PDisplay;
    major_version : pcint;
    minor_version : pcint
):TStatus;cdecl;external LibXShape;

procedure XShapeCombineRegion (
    display :    PDisplay;
    dest :TWindow;
    dest_kind:longint;
    x_off:longint;
    y_off:longint;
    ShapeRegion:TRegion;
    op:longint
);cdecl;external LibXShape;

procedure XShapeCombineRectangles (
    display:PDisplay;
    dest:TWindow;
    dest_kind:longint;
    x_off:longint;
    y_off:longint;
    rectangles:TXRectangle;
    n_rects:longint;
    op:longint;
    ordering:longint
);cdecl;external LibXShape;

procedure XShapeCombineMask (
    display:PDisplay;
    dest:TWindow;
    dest_kind:longint;
    x_off:longint;
    y_off:longint;
    src:TPixmap;
    op:longint
);cdecl;external LibXShape;

procedure XShapeCombineShape (
    display:PDisplay;
    dest:TWindow;
    dest_kind:longint;
    x_off:longint;
    y_off:longint;
    src:TWindow;
    src_kind:longint;
    op:longint
);cdecl;external LibXShape;

procedure XShapeOffsetShape (
    display:PDisplay;
    dest:TWindow;
    dest_kind:longint;
    x_off:longint;
    y_off:longint
);cdecl;external LibXShape;

function  XShapeQueryExtents (
    display:PDisplay;
    window:TWindow;
    bounding_shaped:cBool;
    x_bounding:pcint;
    y_bounding:pcint;
    w_bounding:pculong;
    h_bounding:pculong;
    clip_shaped:pcBool;      
    x_clip:pcint;
    y_clip:pcint;
    w_clip:pculong;
    h_clip:pculong
):TStatus;cdecl;external LibXShape;

procedure XShapeSelectInput (
    display:PDisplay;
    window:TWindow;
    mask:culong
);cdecl;external LibXShape;

function XShapeInputSelected (
    display:PDisplay;
    window:TWindow
):dword;cdecl;external LibXShape;

function XShapeGetRectangles (
    display:PDisplay;
    window:TWindow;
    kind:longint;
    count:pcint;
    ordering:pcint
):PXRectangle;cdecl;external LibXShape;

implementation


end.


Добавлено спустя 16 минут 44 секунды:
Осталось конвертировать С код в fpc ...
Код: Выделить всё
static void Resize (gw)
    Widget   gw;
{
    EyesWidget   w = (EyesWidget) gw;
    XGCValues   xgcv;
    Widget   parent;
    int      x, y;

    if (XtIsRealized (gw))
    {
       XClearWindow (XtDisplay (w), XtWindow (w));
       SetTransform (&w->eyes.t,
             0, w->core.width,
             w->core.height, 0,
             W_MIN_X, W_MAX_X,
             W_MIN_Y, W_MAX_Y);
       if (w->eyes.shape_window) {
           w->eyes.shape_mask = XCreatePixmap (XtDisplay (w), XtWindow (w),
              w->core.width, w->core.height, 1);
           if (!w->eyes.shapeGC)
               w->eyes.shapeGC = XCreateGC (XtDisplay (w), w->eyes.shape_mask, 0, &xgcv);
           XSetForeground (XtDisplay (w), w->eyes.shapeGC, 0);
           XFillRectangle (XtDisplay (w), w->eyes.shape_mask, w->eyes.shapeGC, 0, 0,
          w->core.width, w->core.height);
           XSetForeground (XtDisplay (w), w->eyes.shapeGC, 1);
           eyeLiner (w, w->eyes.shape_mask, w->eyes.shapeGC, (GC) 0, 0);
           eyeLiner (w, w->eyes.shape_mask, w->eyes.shapeGC, (GC) 0, 1);
       x = y = 0;
       for (parent = (Widget) w; XtParent (parent); parent = XtParent (parent)) {
          x += parent->core.x + parent->core.border_width;
          x += parent->core.y + parent->core.border_width;
       }
           XShapeCombineMask (XtDisplay (parent), XtWindow (parent), ShapeBounding,
                       x, y, w->eyes.shape_mask, ShapeSet);
           XFreePixmap (XtDisplay (w), w->eyes.shape_mask);
       }
    }
}


Добавлено спустя 1 час 1 минуту 15 секунд:
Онлайн руководство по X window System http://www.linuxsoft.ru/info/lib/lib/en/xlib/
Аватара пользователя
coyot.rush
постоялец
 
Сообщения: 309
Зарегистрирован: 14.08.2009 08:59:48

Пред.

Вернуться в Free Pascal Compiler

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 5

Рейтинг@Mail.ru