1 /* Copyright (c) 1993, 2015, Oracle and/or its affiliates. All rights reserved.
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
25 * win_grab.c - the client side code for DGA window grabber
31 * Shared window synchronization routines - client side
38 * dga_win_grab(devfd, token)
42 * Grab a window. 'token' is the window-info handle returned by
43 * XDgaGrabWindow. 'devfd' is the file descriptor of the frame buffer
44 * if known, -1 otherwise. If you specify -1, dga_win_grab will open the
45 * frame buffer. The frame buffer fd may be inquired from the returned
46 * Dga_window structure via the dga_win_devfd() routine.
48 * Returns a pointer to the a struct dga_window on success, NULL on
53 * dga_win_ungrab(infop, cflag)
57 * Ungrab a window. All resources allocated by dga_win_grab are freed.
58 * If 'cflag' is nonzero, the framebuffer fd described for the device
61 * The application should call XDgaUnGrabWindow(dpy,win) after
62 * calling dga_win_ungrab() so that the server may free the window-info
63 * page at the other end.
68 * dga_win_clipinfo(win)
71 * Returns pointer to cliplist. Replaces old wx_sh_clipinfo_c() macro.
79 * Returns name of fb. Replaces old wx_devname_c() macro.
84 * dga_win_clipchg(win)
87 * Returns 1 if cliplist changed since last call. Replaces old
88 * wx_modif_c() and wx_seen_c() macros.
93 * dga_win_curschg(win)
96 * Returns 1 if cursor changed since last call.
101 * dga_win_rtnchg(win)
104 * Returns 1 if retained info changed since last call.
112 * Returns framebuffer fd.
116 * dga_win_bbox(win, xp, yp, widthp, heightp)
118 * int *xp, *yp, *widthp, *heightp;
120 * Returns window bounding box
125 * dga_win_singlerect(win)
128 * Returns nonzero if the window is a single rectangle.
136 * Returns nonzero if the window is empty.
141 * dga_win_obscured(win)
144 * Returns nonzero if the window is obscured.
149 * dga_win_cursactive(win)
152 * Returns nonzero if the cursor grabber is active.
157 * dga_win_cursupdate(win, func, data)
162 * Decide if the cursor needs to be taken down, and if so, call
163 * (*func)(data, win, x, y, mem)
167 * Dga_curs_mpr *mem ;
172 * dga_win_dbinfop(win)
175 * Return dbinfo pointer.
180 * dga_win_widinfop(win)
183 * Return window id info pointer.
188 * Return windows depth .
191 * dga_win_borderwidth(win)
194 * Return windows borderwidth .
197 * dga_win_set_client_infop(win, client_info_ptr)
199 * void* client_info_ptr;
200 * Sets a client specific pointer in Dga_window
203 * dga_win_get_client_infop(win)
205 * Returns the client specific pointer
211 #include <sys/types.h>
215 #include "windowstr.h"
216 #include "dga_externaldefs.h"
217 #include "dga/dgawinstr.h"
219 #include <sys/file.h>
220 #include <sys/mman.h>
221 #include <sys/ioctl.h>
223 #include <X11/Xlib.h>
229 #include <sys/fbio.h>
230 #include <sys/fcntl.h>
232 #include <sun/fbio.h>
235 #endif /* SERVER_DGA */
237 #include "dga_incls.h"
238 #include "rtn_grab.h"
240 #define GRABFILE "/tmp/wg"
241 #define CURGFILE "/tmp/curg"
244 #define MINSHMEMSIZE (8*1024)
245 #define MAXSHMEMSIZE (0x00040000)
246 #define WX_PAGESZ (8*1024)
251 extern char *sys_errlist
[] ;
255 extern int _dga_winlockat(u_long cookie
, int **lockp
, int **unlockp
);
256 extern int _dga_winlockdt(int *lockp
, int *unlockp
);
258 /* Some structure definition for internal bookkeeping */
259 typedef struct dga_winlist
{
260 Dga_token w_token
; /* Token associated with win */
261 struct dga_window
*dga_clientplist
;/*List of client ptrs in win */
262 struct dga_window
*dga_clientplist_draw
; /* List of client ptrs in win
263 * using drawable i/f. */
264 struct dga_winlist
*next_winlist
; /* Next link in the dga list */
271 static struct dga_winlist
*dga_wlist
= NULL
;
273 static int dga_win_update(Dga_drawable dgawin
);
274 static int dgai_win_initMbufset (_Dga_window dgawin
);
275 static void release_lockpages(int devfd
, _Dga_window clientp
);
276 static _Dga_window
check_other_curg_windows(WXINFO
*);
277 void dgai_win_ungrab_common(_Dga_window dgawin
, int cflag
,int drawableGrabber
);
278 int dgai_win_check_multiple_grab(_Dga_window dgawin
, int drawableGrabber
);
279 void safe_free_clientp(_Dga_window clientp
);
281 /*bug fix for 4248958: use safe_free_client() to replace free() */
283 safe_free_clientp(clientp
)
288 if(clientp
->back
) free(clientp
->back
);
289 if(clientp
->depth
) free(clientp
->depth
);
290 if(clientp
->stencil
) free(clientp
->stencil
);
291 if(clientp
->accum
) free(clientp
->accum
);
292 if(clientp
->alpha
) free(clientp
->alpha
);
297 /******************************************
299 * dgai_win_grab_common:
301 * create shared memory file for window information
307 * file descriptor of graphics device
309 * Dga_token token; INPUT
310 * magic cookie supplied by the server
312 * returns a user virtual address for a dga_window structure.
313 * returns NULL if anything goes awry.
315 * 'devfd' is the file descriptor of the frame buffer, if known,
316 * -1 otherwise. If you specify -1, wx_grab will open the
317 * frame buffer. The frame buffer fd may be inquired from the returned
318 * Dga_window ptr to the struct dga_window via the dga_win_devfd() routine.
320 *****************************************/
324 ** Shared between both drawable grabber and window compatibility interface.
328 dgai_win_grab_common (Display
*dpy
, int devfd
, Dga_token token
, int drawableGrabber
)
331 _Dga_window clientp
= NULL
;
334 Dga_lockp lockp
, unlockp
;
335 char filename
[sizeof(GRABFILE
)+NDIGITS
+1];
343 if (!_dga_is_X_window(token
, &dpy
, &win
)) {
346 pWin
= (WindowPtr
)LookupIDByType(win
, RT_WINDOW
);
347 #endif /* SERVER_DGA */
349 /* First, check if already grabbed by this client. Note that we
350 always treat the new drawable and old window grabbers separately */
351 for(wlist
= dga_wlist
;wlist
!= NULL
;wlist
= wlist
->next_winlist
) {
352 if (wlist
->w_token
== token
) {
353 _Dga_window orig_clientp
,new_clientp
;
355 /* If multiple clients are grabbing the same
356 * window, then we duplicate the per client info
357 * structure and return that instead of the original
358 * allocated clientp structure. Also remember to add
359 * this new info structure to the linked list. This
360 * change obsoletes the w_grab_count field which
361 * will always be equal to 1
365 (_Dga_window
) malloc(sizeof(struct dga_window
))) == NULL
)
368 if (drawableGrabber
) {
369 if (wlist
->dga_clientplist_draw
)
370 orig_clientp
= wlist
->dga_clientplist_draw
;
372 orig_clientp
= wlist
->dga_clientplist
;
373 *new_clientp
= *orig_clientp
;
374 new_clientp
->w_lockcnt
=0;
375 new_clientp
->w_grab_count
=1;
377 if (wlist
->dga_clientplist_draw
) {
378 /* Add it to the list of clientp structure associated
379 * with this window */
381 new_clientp
->w_next
= orig_clientp
;
384 /* Need to initialize all drawableGrabber
387 infop
= (WXINFO
*)new_clientp
->w_info
;
388 if (infop
->info_sz
!= sizeof(WXINFO
)) {
389 /* mismatch on 64 bit port or other trouble */
391 "wx_grab: mismatch on shared WXINFO size info page is %d sizeof is %d \n",
392 infop
->info_sz
, sizeof(WXINFO
));
396 new_clientp
->drawable_type
= DGA_DRAW_WINDOW
;
397 new_clientp
->w_update_func
=
398 (int(*)())dgai_mbsmemb_update
;
399 new_clientp
->c_mbufseq
= 0;
400 new_clientp
->s_mbufseq_p
= &infop
->w_mbsInfo
.mbufseq
;
401 new_clientp
->c_mbcomposseq
= 0;
402 new_clientp
->s_mbcomposseq_p
=
403 &infop
->w_mbsInfo
.compositionseq
;
404 new_clientp
->s_devinfoseq_p
= &infop
->w_devinfoseq
;
405 new_clientp
->c_devinfoseq
= 0;
406 new_clientp
->siteNotifyFunc
= NULL
;
407 new_clientp
->siteNotifyClientData
= NULL
;
408 new_clientp
->mbNotifyFunc
= NULL
;
409 new_clientp
->mbNotifyClientData
= NULL
;
410 new_clientp
->rendBufNotifyFunc
= NULL
;
411 new_clientp
->rendBufNotifyClientData
= NULL
;
412 new_clientp
->rLockSubj
= DGA_LOCKSUBJ_INVALID
;
413 new_clientp
->eLockSubj
= DGA_LOCKSUBJ_INVALID
;
414 new_clientp
->eLockSubjPrev
= DGA_LOCKSUBJ_INVALID
;
415 new_clientp
->changeMask
= 0;
416 new_clientp
->prevWasMbuffered
= 0;
417 new_clientp
->mbChgReason
= DGA_MBCHG_UNKNOWN
;
418 new_clientp
->siteChgReason
= DGA_SITECHG_UNKNOWN
;
419 new_clientp
->prevLocked
= 0;
420 if ((dpy
!= NULL
) && drawableGrabber
) {
421 if (!dgai_win_initMbufset(new_clientp
)) {
422 dga_win_ungrab(new_clientp
, 0);
425 new_clientp
->w_next
= NULL
;
427 wlist
->dga_clientplist_draw
= new_clientp
;
429 /* the same mbufset is shared between all client
430 * structures for this window */
432 if (orig_clientp
->pMbs
) {
433 dgai_mbufset_incref(orig_clientp
->pMbs
);
436 new_clientp
->mutexp
= &wlist
->mutex
;
437 /* Same window was grabbed 2 or more times via the
438 * drawable interface so turn per-drawable MT
439 * locking on if we are linked with -lthread also.
442 /* Currently, this variable gets set to 1 and
443 * never gets turned off. This could be optimized
452 if (wlist
->dga_clientplist
)
453 orig_clientp
= wlist
->dga_clientplist
;
455 orig_clientp
= wlist
->dga_clientplist_draw
;
456 *new_clientp
= *orig_clientp
;
457 new_clientp
->w_update_func
= dga_win_update
;
458 new_clientp
->w_lockcnt
=0;
459 new_clientp
->w_grab_count
=1;
461 if (wlist
->dga_clientplist
) {
462 /* Add it to the list of clientp structure associated
463 * with this window */
464 new_clientp
->w_next
= orig_clientp
;
466 new_clientp
->w_next
= NULL
;
468 wlist
->dga_clientplist
= new_clientp
;
470 new_clientp
->mutexp
= &wlist
->mutex
;
479 (_Dga_window
) malloc(sizeof(struct dga_window
))) == NULL
)
481 memset(clientp
, 0, sizeof(struct dga_window
));
485 /* Now get a pointer to the shared info page from
486 * pWin's private data */
488 DgaSetupWindow(pWin
);
491 wdev
= pDgaWindow
->pDgaWdev
;
492 infop
= (WXINFO
*)wdev
->infop
;
493 if (infop
== NULL
) return NULL
;
496 sprintf(filename
, "%s%08x", GRABFILE
, token
);
498 if ((filefd
= open(filename
,O_RDWR
,0666))<0) {
499 safe_free_clientp(clientp
) ;
500 return((Dga_window
)NULL
);
503 /* map the wx_winfo area */
504 infop
= (WXINFO
*)mmap(0,
506 PROT_READ
|PROT_WRITE
,
511 if (infop
== (WXINFO
*)-1) {
513 safe_free_clientp(clientp
) ;
514 return((Dga_window
)NULL
);
516 if (infop
->info_sz
!= sizeof(WXINFO
)) {
517 /* mismatch on 64 bit port or other trouble */
520 "wx_grab: mismatch on WXINFO size info page is %d sizeof is %d \n",
521 infop
->info_sz
, sizeof(WXINFO
));
523 munmap((caddr_t
)infop
, MAXSHMEMSIZE
) ;
525 safe_free_clientp(clientp
) ;
529 /* open the frame buffer if not already opened by client */
533 lockfd
= open(infop
->w_devname
, O_RDWR
,0666) ;
536 fprintf(stderr
, "wx_grab: cannot open %s, %s\n",
537 infop
->w_devname
, strerror(errno
)) ;
539 munmap((caddr_t
)infop
, MAXSHMEMSIZE
) ;
541 safe_free_clientp(clientp
) ;
545 #endif /* SERVER_DGA */
547 if (drawableGrabber
) {
548 clientp
->drawable_type
= DGA_DRAW_WINDOW
;
550 clientp
->w_dpy
= dpy
;
551 clientp
->w_info
= (void*)infop
;
552 clientp
->w_infofd
= 0; /* no longer needed */
553 clientp
->w_next
= NULL
;
555 clientp
->curs_info
= NULL
; /* must set up here, may be changed below */
556 clientp
->curs_fd
= -1;
559 clientp
->w_devfd
= infop
->w_sdevfd
; ;
560 clientp
->w_lockp
= (Dga_lockp
)infop
->w_slockp
;
561 clientp
->w_unlockp
= (Dga_lockp
)infop
->w_slockp
;
563 clientp
->w_lib_private
= (void *) infop
; /* PRIVATE DATA */
565 clientp
->w_devfd
= lockfd
;
566 lockp
= NULL
; /* init to NULL for check below */
569 /* On cursor-grabbed devices, find out if we already have a
570 * lockp, unlockp, and cursor page mapping for this device.
571 * We don't want to grab the same lockpage, etc. twice.
573 if (infop
->w_version
>= 2 && infop
->c_sinfo
) {
576 winp
= check_other_curg_windows(infop
);
578 clientp
->curs_fd
= winp
->curs_fd
;
579 clientp
->curs_info
= winp
->curs_info
;
580 lockp
= winp
->w_lockp
;
581 unlockp
= winp
->w_unlockp
;
586 /* only get new lock pages if necessary */
587 locktype
= infop
->w_version
>= 2 ? infop
->w_locktype
: WG_LOCKDEV
;
590 /* map the lock page */
591 lockp
= (Dga_lockp
)mmap(0,
593 PROT_READ
|PROT_WRITE
,
595 lockfd
,(off_t
)infop
->w_cookie
);
597 if (lockp
== (Dga_lockp
)-1) {
599 fprintf(stderr
, "wx_grab: cannot map lock page, %s\n",
602 munmap((caddr_t
)infop
, MAXSHMEMSIZE
) ;
606 safe_free_clientp(clientp
) ;
610 /* map the unlock page */
611 unlockp
= (Dga_lockp
)mmap(0,
613 PROT_READ
|PROT_WRITE
,
615 lockfd
,(off_t
)infop
->w_cookie
) ;
617 if(unlockp
== (Dga_lockp
)-1) {
619 fprintf(stderr
, "wx_grab: cannot map unlock page\n") ;
621 munmap((caddr_t
)lockp
, WX_PAGESZ
) ;
622 munmap((caddr_t
)infop
, MAXSHMEMSIZE
) ;
626 safe_free_clientp(clientp
) ;
632 if( _dga_winlockat(infop
->w_cookie
, &lockp
, &unlockp
) != 0 ) {
633 munmap((caddr_t
)infop
, MAXSHMEMSIZE
);
637 safe_free_clientp(clientp
) ;
644 clientp
->w_lockp
= lockp
;
645 clientp
->w_unlockp
= unlockp
;
647 /* cursor grabber stuff */
648 if ((infop
->w_version
>= 2) && (infop
->c_sinfo
) &&
649 ((clientp
->curs_fd
== -1) || (clientp
->curs_info
== NULL
))) {
650 char cfn
[sizeof(CURGFILE
)+NDIGITS
+1];
653 strcpy(cfn
,CURGFILE
);
654 sprintf(cfn
+sizeof(CURGFILE
)-1,"%08x", infop
->c_filesuffix
);
656 /* open the shared cursor page */
657 if ((curs_fd
= open(cfn
, O_RDWR
,0666))<0) {
659 fprintf(stderr
, "wx_grab: cannot open cursor grabber page\n") ;
661 release_lockpages(devfd
, clientp
);
662 return((Dga_window
)NULL
);
664 clientp
->curs_fd
= curs_fd
;
667 clientp
->curs_info
= (caddr_t
) mmap(0,
669 PROT_READ
|PROT_WRITE
,
674 if (clientp
->curs_info
== (caddr_t
) -1) {
676 fprintf(stderr
, "wx_grab: cannot map cursor page, %s\n",
680 release_lockpages(devfd
, clientp
);
683 /* check to see if you have a good magic number */
684 if (((Dga_cursinfo
*) (clientp
->curs_info
))->c_magic
!=
687 fprintf(stderr
, "wx_grab: wrong cursor page mapped, %s\n",
690 munmap(clientp
->curs_info
, MINSHMEMSIZE
) ;
692 release_lockpages(devfd
, clientp
);
696 #endif /* SERVER_DGA */
698 /* success, fill out rest of structure */
699 clientp
->w_token
= token
;
700 clientp
->w_client
= 0 ;
701 clientp
->c_clipseq
= 0 ;
702 clientp
->s_clipseq_p
= &(infop
->u
.vn
.w_clipseq
) ;
703 if (drawableGrabber
) {
704 clientp
->w_update_func
= (int(*)())dgai_mbsmemb_update
;
707 clientp
->w_update_func
= dga_win_update
;
711 clientp
->w_unlock_func
= dgai_unlock
;
713 clientp
->w_unlock_func
= NULL
;
716 clientp
->w_lock_func
= NULL
;
717 clientp
->w_unlock_func
= NULL
;
719 clientp
->w_lockcnt
= 0;
720 if (infop
->w_version
!= 0) {
721 clientp
->w_clipptr
= (short *)((char *)infop
+infop
->u
.vn
.w_clipoff
);
722 clientp
->w_cliplen
= 0;
724 if (infop
->w_version
< 2) {
725 clientp
->c_chngcnt
= 0;
726 clientp
->s_chngcnt_p
= clientp
->s_clipseq_p
;
728 clientp
->c_chngcnt
= 0;
729 clientp
->s_chngcnt_p
= &(infop
->w_chng_cnt
);
730 for (i
= 0; i
< DGA_MAX_GRABBABLE_BUFS
+ 1; i
++) {
731 clientp
->c_wm_chngcnt
[i
] = 0;
733 clientp
->shadow_chngcnt
[i
] = 0;
737 /* Now initialize the next field to pt to the second member of
738 * c_wm_chngcnt array - this is specifically for performance
739 * tuning of the lock macro
741 clientp
->w_wm_2nd
= clientp
->c_wm_chngcnt
+ 1;
743 if ((infop
->w_version
< 2) || (clientp
->curs_info
== NULL
)) {
744 clientp
->s_curseq_p
= &clientp
->c_curseq
;
745 clientp
->c_curseq
= 0;
747 clientp
->s_curseq_p
=
748 &(((Dga_cursinfo
*) (clientp
->curs_info
))->c_chng_cnt
);
750 ((Dga_cursinfo
*) (clientp
->curs_info
))->c_chng_cnt
- 1;
751 /* so first test of dga_win_curschg will see a change */
754 clientp
->back
= (void *)malloc(sizeof(dga_internal_buffer_rec
));
755 if ( !clientp
->back
)
758 clientp
->depth
= (void *)malloc(sizeof(dga_internal_buffer_rec
));
759 if ( !clientp
->depth
)
762 clientp
->stencil
= (void *)malloc(sizeof(dga_internal_buffer_rec
));
763 if ( !clientp
->stencil
)
766 clientp
->accum
= (void *)malloc(sizeof(dga_internal_buffer_rec
));
767 if ( !clientp
->accum
)
770 clientp
->alpha
= (void *)malloc(sizeof(dga_internal_buffer_rec
));
771 if ( !clientp
->alpha
)
774 ((dga_internal_buffer
)clientp
->back
)->bufferp
= NULL
;
775 ((dga_internal_buffer
)clientp
->depth
)->bufferp
= NULL
;
776 ((dga_internal_buffer
)clientp
->stencil
)->bufferp
= NULL
;
777 ((dga_internal_buffer
)clientp
->accum
)->bufferp
= NULL
;
778 ((dga_internal_buffer
)clientp
->alpha
)->bufferp
= NULL
;
780 ((dga_internal_buffer
)clientp
->back
)->pDraw
= (Dga_drawable
)clientp
;
781 ((dga_internal_buffer
)clientp
->depth
)->pDraw
= (Dga_drawable
)clientp
;
782 ((dga_internal_buffer
)clientp
->stencil
)->pDraw
= (Dga_drawable
)clientp
;
783 ((dga_internal_buffer
)clientp
->accum
)->pDraw
= (Dga_drawable
)clientp
;
784 ((dga_internal_buffer
)clientp
->alpha
)->pDraw
= (Dga_drawable
)clientp
;
786 ((dga_internal_buffer
)clientp
->back
)->buf_size
= 0;
787 ((dga_internal_buffer
)clientp
->depth
)->buf_size
= 0;
788 ((dga_internal_buffer
)clientp
->stencil
)->buf_size
= 0;
789 ((dga_internal_buffer
)clientp
->accum
)->buf_size
= 0;
790 ((dga_internal_buffer
)clientp
->alpha
)->buf_size
= 0;
792 clientp
->buf_resize_flag
= 0;
793 clientp
->c_buffer_swap
= 0;
795 clientp
->db_enabled
= 0;
796 clientp
->c_rtnseq
= 0;
797 clientp
->s_rtnseq_p
= &clientp
->c_rtnseq
;
798 clientp
->rtn_info
= NULL
;
799 clientp
->rtn_flags
= 0;
801 /* initialization for drawable grabber code */
802 clientp
->pMbs
= NULL
;
803 if (drawableGrabber
) {
804 clientp
->c_mbufseq
= 0;
805 clientp
->s_mbufseq_p
= &infop
->w_mbsInfo
.mbufseq
;
806 clientp
->c_mbcomposseq
= 0;
807 clientp
->s_mbcomposseq_p
= &infop
->w_mbsInfo
.compositionseq
;
808 clientp
->s_devinfoseq_p
= &infop
->w_devinfoseq
;
809 clientp
->c_devinfoseq
= 0;
810 clientp
->siteNotifyFunc
= NULL
;
811 clientp
->siteNotifyClientData
= NULL
;
812 clientp
->mbNotifyFunc
= NULL
;
813 clientp
->mbNotifyClientData
= NULL
;
814 clientp
->rendBufNotifyFunc
= NULL
;
815 clientp
->rendBufNotifyClientData
= NULL
;
816 clientp
->rLockSubj
= DGA_LOCKSUBJ_INVALID
;
817 clientp
->eLockSubj
= DGA_LOCKSUBJ_INVALID
;
818 clientp
->eLockSubjPrev
= DGA_LOCKSUBJ_INVALID
;
819 clientp
->changeMask
= 0;
820 clientp
->prevWasMbuffered
= 0;
821 clientp
->mbChgReason
= DGA_MBCHG_UNKNOWN
;
822 clientp
->siteChgReason
= DGA_SITECHG_UNKNOWN
;
823 clientp
->prevLocked
= 0;
826 /* add to linked list of grabbed windows - for internal bookkeeping
827 * Note: this should be done last in order for other code, e.g.
828 * check_other_curg_windows() to work correctly
833 (Dga_winlist
) malloc(sizeof(struct dga_winlist
))) == NULL
)
835 dga_wlist
->w_token
= token
;
836 if (drawableGrabber
) {
837 dga_wlist
->dga_clientplist_draw
= clientp
;
838 dga_wlist
->dga_clientplist
= NULL
;
840 dga_wlist
->dga_clientplist_draw
= NULL
;
841 dga_wlist
->dga_clientplist
= clientp
;
843 dga_wlist
->next_winlist
= NULL
;
845 struct dga_winlist
*new_wlist
;
848 (Dga_winlist
) malloc(sizeof(struct dga_winlist
))) == NULL
)
850 new_wlist
->w_token
= token
;
851 if (drawableGrabber
) {
852 new_wlist
->dga_clientplist_draw
= clientp
;
853 new_wlist
->dga_clientplist
= NULL
;
855 new_wlist
->dga_clientplist_draw
= NULL
;
856 new_wlist
->dga_clientplist
= clientp
;
858 new_wlist
->next_winlist
= dga_wlist
;
859 dga_wlist
= new_wlist
;
863 #endif /* SERVER_DGA */
866 mutex_init(&dga_wlist
->mutex
, USYNC_THREAD
, NULL
);
867 clientp
->mutexp
= &dga_wlist
->mutex
;
870 /* If window is multibuffered, initialize multibuffer set */
871 /* If window is being grabbed through the old interface don't
872 * init the mbufset since mbuffers where not supported int
873 * older versions of DGA */
874 if ((dpy
!= NULL
) && drawableGrabber
) {
875 if (!dgai_win_initMbufset(clientp
)) {
876 dga_win_ungrab(clientp
, 0);
880 return((Dga_window
)clientp
);
885 dga_win_grab(devfd
, token
)
889 /* Call the common grab routine with dpy == NULL to signify that
890 * mbuffers are not to be initialized. */
892 return (dgai_win_grab_common(NULL
, devfd
, token
, 0));
898 check_other_curg_windows(infop
)
905 for(winp
= dga_wlist
; winp
!= NULL
; winp
= winp
->next_winlist
) {
906 if (clientp
= winp
->dga_clientplist_draw
) {
907 linfop
= (WXINFO
*) clientp
->w_info
;
908 if (strcmp(linfop
->w_devname
, infop
->w_devname
) == 0) {
912 if (clientp
= winp
->dga_clientplist
) {
913 linfop
= (WXINFO
*) clientp
->w_info
;
914 if (strcmp(linfop
->w_devname
, infop
->w_devname
) == 0) {
924 release_lockpages(devfd
, clientp
)
928 int lockfd
= clientp
->w_devfd
;
929 WXINFO
*infop
= (WXINFO
*) clientp
->w_info
;
930 Dga_lockp lockp
= clientp
->w_lockp
;
931 Dga_lockp unlockp
= clientp
->w_unlockp
;
934 if ((clientp
->curs_info
||
935 ((infop
->w_version
>= 2) && (infop
->c_sinfo
))) &&
936 ((check_other_curg_windows(infop
) != NULL
) ||
937 (check_other_curg_windows(infop
) == NULL
&& infop
->w_devname
[0] == 0))) {
938 /* don't free lock pages
939 * Note: check both clientp->curs_info and infop->c_sinfo because
940 * this routine is called both at grab and ungrab time. Client
941 * may not have set curs_info non-zero at grab time. Server may
942 * set c_sinfo NULL at window destroy time.
945 locktype
= infop
->w_version
>= 2 ? infop
->w_locktype
: WG_LOCKDEV
;
948 munmap((caddr_t
)lockp
, WX_PAGESZ
) ;
949 munmap((caddr_t
)unlockp
, WX_PAGESZ
) ;
952 (void) _dga_winlockdt((int *)lockp
, (int *)unlockp
) ;
958 munmap((caddr_t
)infop
, MAXSHMEMSIZE
) ;
959 safe_free_clientp(clientp
) ;
961 #endif /* SERVER_DGA */
964 dga_win_ungrab(clientpi
, cflag
)
968 _Dga_window clientp
= (struct dga_window
*)clientpi
;
970 dgai_win_ungrab_common(clientpi
,cflag
, 0);
974 dgai_win_ungrab_common(clientp
, cflag
,drawableGrabber
)
980 WXINFO
*infop
= (WXINFO
*) clientp
->w_info
;
981 int infofd
, devfd
, curs_fd
, match
;
982 struct dga_winlist
*prevwinp
, *winp
;
984 /* remove from linked list of grabbed windows
985 * Note: this should be done first in order for other code, e.g.
986 * check_other_curg_windows() to work correctly
992 if (winp
->w_token
== clientp
->w_token
) {
993 struct dga_window
*clntp
, *prevclntp
;
995 clntp
= winp
->dga_clientplist_draw
;
997 clntp
= winp
->dga_clientplist
;
1001 if (clntp
== clientp
) {
1004 prevclntp
->w_next
= clntp
->w_next
;
1006 if (drawableGrabber
)
1007 winp
->dga_clientplist_draw
= clntp
->w_next
;
1009 winp
->dga_clientplist
= clntp
->w_next
;
1014 clntp
= clntp
->w_next
;
1017 /* Check for old style clients */
1018 clntp
= winp
->dga_clientplist
;
1021 if (clntp
== clientp
) {
1024 prevclntp
->w_next
= clntp
->w_next
;
1026 if (drawableGrabber
)
1027 winp
->dga_clientplist_draw
= clntp
->w_next
;
1029 winp
->dga_clientplist
= clntp
->w_next
;
1034 clntp
= clntp
->w_next
;
1040 winp
= winp
->next_winlist
;
1046 /* TODO: do this for every client, or only once? */
1047 if ((clientp
->rtn_flags
& RTN_GRABBED
) && (!winp
->dga_clientplist
))
1048 dga_rtn_ungrab(clientp
);
1049 if (clientp
->db_enabled
&& (!winp
->dga_clientplist
))
1050 dga_db_release(clientp
);
1051 devfd
= clientp
->w_devfd
;
1054 /* Cursor grabber stuff */
1055 /* TODO: do this for every client, or only once? */
1056 if ((clientp
->curs_info
) && (check_other_curg_windows(infop
) == NULL
) &&
1057 (!infop
->c_sinfo
)) {
1058 curs_fd
= clientp
->curs_fd
;
1059 munmap(clientp
->curs_info
, MINSHMEMSIZE
) ;
1062 #endif /* SERVER_DGA */
1064 /* deref any associated multibuffer set */
1065 if (clientp
->pMbs
) {
1066 dgai_mbufset_decref(clientp
->pMbs
);
1067 clientp
->pMbs
= NULL
;
1070 /* TODO: shouldn't we free the clientp??? */
1071 /* Now check to see if all that needs to be freed has been freed */
1072 if ((winp
->dga_clientplist_draw
== NULL
) &&
1073 (winp
->dga_clientplist
== NULL
)){
1075 release_lockpages( cflag
? -1 : 0, clientp
) ;
1076 #endif /* SERVER_DGA */
1077 /* Then free this node and unlink it from the list */
1078 if( prevwinp
!= NULL
)
1079 prevwinp
->next_winlist
= winp
->next_winlist
;
1081 dga_wlist
= winp
->next_winlist
;
1083 mutex_destroy(&winp
->mutex
);
1090 dgai_win_check_multiple_grab(clientp
, drawableGrabber
)
1091 _Dga_window clientp
;
1094 struct dga_winlist
*winp
;
1097 /* Checking to see if this client is grabbing a multiply grabbed
1104 if (winp
->w_token
== clientp
->w_token
) {
1105 /* Now we have the correct window */
1106 struct dga_window
*clntp
, *prevclntp
;
1108 if (drawableGrabber
)
1109 clntp
= winp
->dga_clientplist_draw
;
1111 clntp
= winp
->dga_clientplist
;
1115 /* Now we have the correct client */
1116 if (clntp
== clientp
) {
1117 /* Check to see if there are any more... */
1118 if (prevclntp
|| clntp
->w_next
) {
1124 clntp
= clntp
->w_next
;
1128 winp
= winp
->next_winlist
;
1134 dga_win_clipinfo(wini
)
1137 _Dga_window win
= (struct dga_window
*)wini
;
1138 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1140 if (wx_shape_flags(infop
) & DGA_SH_RECT_FLAG
)
1141 return((short *)&((struct class_SHAPE_vn
*)((char *)(infop
) +
1142 (infop
)->u
.vn
.w_shapeoff
))->SHAPE_YMIN
);
1143 return(win
->w_clipptr
);
1148 dga_win_fbname(wini
)
1151 _Dga_window win
= (struct dga_window
*)wini
;
1153 return(((WXINFO
*) (win
->w_info
))->w_devname
);
1157 dga_win_clipchg(wini
)
1160 _Dga_window win
= (struct dga_window
*)wini
;
1162 if (win
->c_clipseq
!= *(win
->s_clipseq_p
)) {
1163 ((WXINFO
*) win
->w_info
)->w_flag
&= ~WMODIF
;
1164 win
->c_clipseq
= *(win
->s_clipseq_p
);
1171 dga_win_curschg(wini
)
1174 _Dga_window win
= (struct dga_window
*)wini
;
1176 if (win
->c_curseq
!= *(win
->s_curseq_p
)) {
1177 win
->c_curseq
= *(win
->s_curseq_p
);
1184 dga_win_rtnchg(wini
)
1187 _Dga_window win
= (struct dga_window
*)wini
;
1188 if ((win
->rtn_flags
& RTN_GRABBED
) && !(win
->rtn_flags
& RTN_MAPPED
)) {
1189 /* rtn grabbed, but not currently mapped */
1190 if (win
->rtn_flags
& RTN_MAPCHG
) {
1191 /* just went unmapped */
1192 win
->rtn_flags
&= ~RTN_MAPCHG
;
1197 /* otherwise either not rtn grabbed or have a rtn mapping */
1198 if (win
->c_rtnseq
!= *(win
->s_rtnseq_p
)) {
1199 win
->c_rtnseq
= *(win
->s_rtnseq_p
);
1209 _Dga_window win
= (struct dga_window
*)wini
;
1210 return(win
->w_devfd
);
1214 dga_win_bbox(wini
, xp
, yp
, widthp
, heightp
)
1216 int *xp
, *yp
, *widthp
, *heightp
;
1218 _Dga_window win
= (struct dga_window
*)wini
;
1219 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1221 if (infop
->w_version
< 2) {
1222 *xp
= infop
->w_org
.x
>> 16;
1223 *yp
= infop
->w_org
.y
>> 16;
1224 *widthp
= infop
->w_dim
.x
>> 16;
1225 *heightp
= infop
->w_dim
.y
>> 16;
1228 *xp
= infop
->w_window_boundary
.xleft
;
1229 *yp
= infop
->w_window_boundary
.ytop
;
1230 *widthp
= infop
->w_window_boundary
.width
;
1231 *heightp
= infop
->w_window_boundary
.height
;
1235 dga_win_singlerect(wini
)
1238 _Dga_window win
= (struct dga_window
*)wini
;
1239 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1241 return(wx_shape_flags(infop
) & DGA_SH_RECT_FLAG
);
1248 _Dga_window win
= (struct dga_window
*)wini
;
1249 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1251 return(wx_shape_flags(infop
) & DGA_SH_EMPTY_FLAG
);
1258 _Dga_window win
= (struct dga_window
*)wini
;
1259 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1261 if (infop
->w_version
>= 3)
1262 return(infop
->w_depth
);
1268 dga_win_borderwidth(wini
)
1271 _Dga_window win
= (struct dga_window
*)wini
;
1272 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1274 if (infop
->w_version
>= 3)
1275 return(infop
->w_borderwidth
);
1281 dga_win_obscured(wini
)
1284 _Dga_window win
= (struct dga_window
*)wini
;
1285 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1287 int ytop
, ybot
, xleft
, xright
;
1291 if (wx_shape_flags(infop
) & DGA_SH_RECT_FLAG
) {
1292 dga_win_bbox(win
, &xb
, &yb
, &wb
, &hb
);
1293 ptr
= dga_win_clipinfo(win
);
1294 ytop
= *ptr
++; ybot
= *ptr
++; xleft
= *ptr
++; xright
= *ptr
++;
1296 tmp
= ytop
; ytop
= ybot
; ybot
= tmp
;
1298 if (xleft
> xright
) {
1299 tmp
= xleft
; xleft
= xright
; xright
= tmp
;
1301 if ((yb
== ytop
) && (xb
== xleft
) &&
1302 (hb
== (ybot
- ytop
)) && (wb
== (xright
- xleft
))) {
1310 dgai_win_visibility(Dga_window wini
)
1312 if (dga_win_empty(wini
))
1313 return (DGA_VIS_FULLY_OBSCURED
);
1314 /* This routine returns the reverse of what one would think.
1315 * it returns true if the window is unobscured false otherwise. */
1316 else if (!dga_win_obscured(wini
))
1317 return (DGA_VIS_PARTIALLY_OBSCURED
);
1319 return (DGA_VIS_UNOBSCURED
);
1321 /* This will work when we get to R6 but for now the visibility
1322 * entry in the window structure (which is where this comes from)
1323 * is bogus. I looked at the R6 code and it looks like they
1324 * attempted to get this working.
1325 _Dga_window win = (struct dga_window *)wini;
1326 WXINFO *infop = (WXINFO *) win->w_info;
1328 return (infop->w_visibility);
1332 #define ROUNDUP(i) (((i)+WX_PAGESZ-1)&~(WX_PAGESZ-1))
1335 dgai_win_clip_update (_Dga_window clientp
)
1337 /* Do anything here that may require unlock/relock, because
1341 WXINFO
*infop
= (WXINFO
*) clientp
->w_info
;
1342 unsigned int cliplen
;
1346 char filename
[sizeof(GRABFILE
)+NDIGITS
+1];
1348 #endif /*SERVER_DGA */
1350 cmclip
= (short *)((char *)infop
+infop
->u
.vn
.w_clipoff
);
1353 if (infop
->w_flag
& WEXTEND
) { /* server has an extended mapping */
1354 if (clientp
->w_clipptr
== cmclip
) {
1355 clientp
->w_cliplen
= infop
->w_scliplen
;
1356 clientp
->w_clipptr
= (short *)infop
->u
.vn
.w_sclipptr
;
1359 if (clientp
->w_clipptr
!= cmclip
) {
1360 clientp
->w_clipptr
= cmclip
;
1365 if (infop
->w_flag
& WEXTEND
) {
1366 /* server has an extended mapping */
1367 if (clientp
->w_clipptr
== cmclip
) {
1368 /* ...and we don't. */
1369 cliplen
= infop
->w_scliplen
;
1370 DGA_UNLOCK(clientp
);
1371 sprintf(filename
, "%s%08x", GRABFILE
, clientp
->w_token
);
1373 if ((filefd
= open(filename
,O_RDWR
,0666))<0) {
1376 if (ftruncate(filefd
,MINSHMEMSIZE
+cliplen
)<0) {
1383 clipptr
= (short *)((char *)infop
+ MINSHMEMSIZE
);
1386 if ((int)clipptr
!= -1) {
1387 clientp
->w_cliplen
= cliplen
;
1388 clientp
->w_clipptr
= clipptr
;
1390 continue; /* at while */
1392 if (clientp
->w_cliplen
!= infop
->w_scliplen
) {
1393 /* ...and we do... but the wrong size. */
1394 cliplen
= infop
->w_scliplen
;
1395 DGA_UNLOCK(clientp
);
1396 sprintf(filename
, "%s%08x", GRABFILE
, clientp
->w_token
);
1398 if ((filefd
= open(filename
,O_RDWR
,0666))<0) {
1401 if (ftruncate(filefd
,MINSHMEMSIZE
+cliplen
)<0) {
1406 clipptr
= (short *)((char *)infop
+ MINSHMEMSIZE
);
1409 if ((int)clipptr
== -1)
1410 clientp
->w_clipptr
= cmclip
;
1412 clientp
->w_cliplen
= cliplen
;
1413 clientp
->w_clipptr
= clipptr
;
1415 continue; /* at while */
1418 /* server doesn't have an extended mapping */
1419 if (clientp
->w_clipptr
!= cmclip
) {
1421 DGA_UNLOCK(clientp
);
1422 sprintf(filename
, "%s%08x", GRABFILE
, clientp
->w_token
);
1424 if ((filefd
= open(filename
,O_RDWR
,0666))<0) {
1425 clientp
->w_clipptr
= cmclip
;
1428 if (ftruncate(filefd
,MINSHMEMSIZE
)<0) {
1429 clientp
->w_clipptr
= cmclip
;
1436 clientp
->w_clipptr
= cmclip
;
1437 continue; /* at while */
1447 #endif /* SERVER_DGA */
1451 dgai_win_curs_update(_Dga_window win
)
1453 /* Do anything here that may require unlock/relock, because
1456 * We can add code here in the future to remap the cursor page,
1467 * Do anything here that may require unlock/relock, because
1468 * it takes so long. Remap retained info, etc.
1470 * DGA Retained Window Information Update. This function checks that the
1471 * shared retained information structure hasn't become obsolete. If the
1472 * structure is found to be obsolete, this routine attempts to free and
1473 * re-allocate the resources associated with the retained window. Nothing
1474 * is done in the event that the shared retained information is not obsolete.
1476 * Inputs: Dga_window - Pointer to the dga_window structure for which
1477 * the the shared retained info structure is to
1484 * Externals: DGA_LOCK() DGA MACRO
1485 * DGA_UNLOCK() DGA MACRO
1486 * RTN_INFOP() DGA MACRO
1492 dgai_win_rtn_update (_Dga_window clientp
)
1494 unsigned int mapped
;
1497 mapped
= clientp
->rtn_flags
& RTN_MAPPED
;
1498 if (mapped
&& RTN_INFOP(clientp
)->obsolete
) {
1499 /* mapped, but obsolete */
1500 (void) _dga_rtn_unmap(clientp
);
1501 (void) _dga_rtn_map(clientp
);
1504 if (!mapped
&& (((WXINFO
*) clientp
->w_info
)->w_srtndlink
!= NULL
)) {
1505 /* unmapped on client side, but server has valid w_srtndlink */
1506 (void) _dga_rtn_map(clientp
);
1510 mapped
= clientp
->rtn_flags
& RTN_MAPPED
;
1511 if (mapped
&& RTN_INFOP(clientp
)->obsolete
) {
1512 /* mapped, but obsolete */
1513 DGA_UNLOCK(clientp
);
1514 (void) _dga_rtn_unmap(clientp
);
1515 (void) _dga_rtn_map(clientp
);
1519 if (!mapped
&& (((WXINFO
*) clientp
->w_info
)->w_srtndlink
!= NULL
)) {
1520 /* unmapped on client side, but server has valid w_srtndlink */
1521 DGA_UNLOCK(clientp
);
1522 (void) _dga_rtn_map(clientp
);
1528 #endif /* SERVER_DGA */
1533 dga_win_update(wini
)
1536 _Dga_window win
= (struct dga_window
*)wini
;
1537 WXINFO
*infop
= (WXINFO
*) win
->w_info
;
1538 unsigned int sav_clipseq
, sav_curseq
, sav_rtnseq
;
1540 /* establish the new real lock subject */
1541 win
->rLockSubj
= -1;
1543 /* save last lock subject. This may be used later in the update phase */
1544 win
->eLockSubjPrev
= win
->eLockSubj
;
1546 /* start out assuming we're not aliased. This may change if we detect
1547 aliasing later in the update phase */
1548 win
->eLockSubj
= win
->rLockSubj
;
1550 /* Do anything here that may require unlock/relock, because
1551 * it takes so long. Also, update win->c_chngcnt.
1554 sav_clipseq
= win
->c_clipseq
;
1555 sav_curseq
= win
->c_curseq
;
1556 sav_rtnseq
= win
->c_rtnseq
;
1558 /* repeat update functions as needed
1559 * through possible unlock/relocks
1561 if (sav_clipseq
!= *win
->s_clipseq_p
) {
1562 dgai_win_clip_update(win
);
1563 sav_clipseq
= *win
->s_clipseq_p
;
1565 if (sav_curseq
!= *win
->s_curseq_p
) {
1566 dgai_win_curs_update(win
);
1567 sav_curseq
= *win
->s_curseq_p
;
1569 if ((sav_rtnseq
!= *win
->s_rtnseq_p
) ||
1570 ((win
->rtn_flags
& RTN_GRABBED
) &&
1571 !(win
->rtn_flags
& RTN_MAPPED
))) {
1572 dgai_win_rtn_update(win
);
1573 sav_rtnseq
= *win
->s_rtnseq_p
;
1575 } while ((sav_clipseq
!= *win
->s_clipseq_p
) ||
1576 (sav_curseq
!= *win
->s_curseq_p
) ||
1577 (sav_rtnseq
!= *win
->s_rtnseq_p
));
1579 if (infop
->w_version
< 2) {
1581 win
->c_chngcnt
= *win
->s_chngcnt_p
;
1584 /* post OWV3 beta */
1585 win
->c_chngcnt
= *win
->s_chngcnt_p
;
1591 dga_win_cursactive(wini
)
1594 _Dga_window win
= (struct dga_window
*)wini
;
1601 dga_win_cursupdate(wini
, func
, data
)
1606 _Dga_window win
= (struct dga_window
*)wini
;
1607 /* assumes the window is already locked */
1609 Dga_cursinfo
*curgp
= (Dga_cursinfo
*) (win
->curs_info
);
1610 Dga_curs_mpr
*curg_mpr
;
1611 Dga_curs_memimage curg_mem
;
1614 if ((curgp
== 0) || (curgp
->c_state_flag
!= DGA_CURSOR_UP
))
1617 curg_mpr
= (Dga_curs_mpr
*) ((char *) curgp
+ curgp
->c_offset
);
1619 dga_win_bbox(win
, &x
, &y
, &w
, &h
);
1620 if (((curgp
->c_org
.x
+ curg_mpr
->curg_dim
.x
) < x
) ||
1621 (curgp
->c_org
.x
> (x
+ w
)) ||
1622 ((curgp
->c_org
.y
+ curg_mpr
->curg_dim
.y
) < y
) ||
1623 (curgp
->c_org
.y
> (y
+ h
)))
1627 curg_mem
.width
= curg_mpr
->curg_dim
.x
;
1628 curg_mem
.height
= curg_mpr
->curg_dim
.y
;
1629 curg_mem
.depth
= curg_mpr
->curg_depth
;
1630 curg_mem
.linebytes
= curg_mpr
->curg_linebytes
;
1632 curg_mem
.memptr
= (void *)(curg_mpr
+ 1);
1634 curg_mem
.memptr
= ((caddr_t
) curg_mpr
) + sizeof(Dga_curs_mpr
);
1636 (*func
) (data
, win
, curgp
->c_org
.x
, curgp
->c_org
.y
, &curg_mem
);
1637 curgp
->c_state_flag
= DGA_CURSOR_DOWN
;
1638 /* have to bump the shared memory counter, so update the saved
1641 win
->c_curseq
= ++(curgp
->c_chng_cnt
);
1646 dga_win_dbinfop(wini
)
1649 _Dga_window win
= (struct dga_window
*)wini
;
1650 return ((Dga_dbinfo
*)&(((WXINFO
*) win
->w_info
)->wx_dbuf
));
1654 dga_win_widinfop(wini
)
1657 _Dga_window win
= (struct dga_window
*)wini
;
1658 return ((Dga_widinfo
*)(&(((WXINFO
*) win
->w_info
)->w_wid_info
)));
1662 dga_win_set_client_infop(wini
, client_info_ptr
)
1664 void* client_info_ptr
;
1666 _Dga_window win
= (struct dga_window
*)wini
;
1667 win
->w_client
= client_info_ptr
;
1671 dga_win_get_client_infop(wini
)
1674 _Dga_window win
= (struct dga_window
*)wini
;
1675 return (void *)(win
->w_client
);
1680 dgai_win_initMbufset (_Dga_window dgawin
)
1685 /* Lock the window to see if it is multibuffered */
1688 #endif /* SERVER_DGA */
1690 infop
= (WXINFO
*) dgawin
->w_info
;
1691 if (!infop
->w_mbsInfo
.enabled
) {
1692 /* it's okay if it's not multibuffered; return success */
1693 dgawin
->pMbs
= NULL
;
1698 if (!(dgawin
->pMbs
= dgai_mbufset_create(dgawin
))) {
1702 dgawin
->c_mbcomposseq
= *dgawin
->s_mbcomposseq_p
;
1710 #endif /* SERVER_DGA */
1716 * There is no equivalent for the following function in client side
1717 * The main purpose of this function is to isolate SHAPES header files
1725 _Dga_window wini
= (_Dga_window
)win
;
1727 if (((wini
)->w_lockcnt
)++ == 0) {
1728 wg_lock((WXINFO
*) (wini
->w_lib_private
));
1730 wini
->w_modif
= ((((wini
)->c_chngcnt
) == (*((wini
)->s_chngcnt_p
)))
1731 ? 0 : (*((wini
)->w_update_func
))(wini
));
1737 * There is no equivalent for the following function in client side
1738 * The main purpose of this function is to isolate SHAPES header file
1746 _Dga_window wini
= (_Dga_window
)win
;
1748 if (--((wini
)->w_lockcnt
) == 0) {
1749 wg_unlock((WXINFO
*) (wini
->w_lib_private
));
1750 if ((wini
)->w_unlock_func
)
1751 (*((wini
)->w_unlock_func
))(wini
);
1755 #endif /* SERVER_DGA */
1759 dga_win_dump(clientpi
)
1760 Dga_window clientpi
;
1762 _Dga_window clientp
= (struct dga_window
*)clientpi
;
1763 WXINFO
*infop
= (WXINFO
*) clientp
->w_info
;
1765 printf("client page is %p\n", clientp
) ;
1766 printf(" w_info = %p\n", (WXINFO
*) clientp
->w_info
) ;
1767 printf(" w_next = %p\n", clientp
->w_next
) ;
1768 printf(" w_client = %p\n", clientp
->w_client
) ;
1769 printf(" c_clipseq = %u\n", clientp
->c_clipseq
) ;
1770 printf(" s_clipseq_p = %p\n", clientp
->s_clipseq_p
) ;
1771 printf(" w_update_func = %p\n", clientp
->w_update_func
) ;
1772 printf(" w_infofd = %d\n", clientp
->w_infofd
) ;
1773 printf(" w_devfd = %d\n", clientp
->w_devfd
) ;
1774 printf(" w_lockcnt = %d\n", clientp
->w_lockcnt
) ;
1775 printf(" w_lockp = %p\n", clientp
->w_lockp
) ;
1776 printf(" w_unlockp = %p\n", clientp
->w_unlockp
) ;
1777 printf(" w_clipptr = %p\n", clientp
->w_clipptr
) ;
1778 printf(" w_cliplen = %u\n", clientp
->w_cliplen
) ;
1780 printf("info page is %p\n", infop
) ;
1781 printf(" w_flag = %lu\n", infop
->w_flag
) ;
1782 printf(" w_magic = %ld\n", infop
->w_magic
) ;
1783 printf(" w_version = %ld\n", infop
->w_version
) ;
1784 printf(" w_cunlockp = %p\n", infop
->w_cunlockp
) ;
1785 printf(" w_devname = %s\n", infop
->w_devname
) ;
1786 printf(" w_cookie = %lu\n", infop
->w_cookie
) ;
1787 printf(" w_clipoff = %ld\n", infop
->u
.vn
.w_clipoff
) ;
1788 printf(" w_scliplen = %u\n", infop
->w_scliplen
) ;
1789 printf(" w_org = %u,(%f,%f)\n",
1790 infop
->w_org
.t
, infop
->w_org
.x
/65536., infop
->w_org
.y
/65536.) ;
1791 printf(" w_dim = %u,(%f,%f)\n",
1792 infop
->w_dim
.t
, infop
->w_dim
.x
/65536., infop
->w_dim
.y
/65536.) ;
1793 printf(" &w_shape_hdr = %p\n", &infop
->u
.v0
.w_shape_hdr
) ;
1794 printf(" &w_shape = %p\n", &infop
->w_shape
) ;
1795 printf(" w_shape.SHAPE_FLAGS = %u\n", infop
->w_shape
.SHAPE_FLAGS
) ;
1796 printf(" w_shape.SHAPE_YMIN = %d\n", infop
->w_shape
.SHAPE_YMIN
) ;
1797 printf(" w_shape.SHAPE_YMAX = %d\n", infop
->w_shape
.SHAPE_YMAX
) ;
1798 printf(" w_shape.SHAPE_XMIN = %d\n", infop
->w_shape
.SHAPE_XMIN
) ;
1799 printf(" w_shape.SHAPE_XMAX = %d\n", infop
->w_shape
.SHAPE_XMAX
) ;
1800 printf(" w_shape.SHAPE_X_EOL = %d\n", infop
->w_shape
.SHAPE_X_EOL
) ;
1801 printf(" w_shape.SHAPE_Y_EOL = %d\n", infop
->w_shape
.u
.SHAPE_Y_EOL
) ;
1802 printf(" &w_cliparray = %p\n", &infop
->w_cliparray
) ;
1808 dgai_unlock(Dga_drawable dgadraw
)
1813 dgawin
= (_Dga_window
) dgadraw
;
1814 mutex_unlock(dgawin
->mutexp
);