Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Calculate Window Insets: (11 Items)
   
Calculate Window Insets  
I'm currently using the call PtFrameSize by passing in my render flags to get the insets for my client area of a window 
created with PhWindowOpen. 

My problem is that PtFrameSize is reporting 21, 5, 5, 5, but what is drawn is with 24, 6, 6, 6. I noticed that the black
 line (as if I specified Ph_WM_RENDER_INLINE) is being drawn. That addresses the 6 vs the 5, but still leaves the 21 vs 
23 instead of 24.

Also, since I'm not using widgets, I can't use PtWindowGetFrameSize which is the replacement function for PtFrameSize. 
Anybody know a way to get the correct inset values?

Thx,
Bill
Re: Calculate Window Insets  
#include <Ph.h>
#include <photon/PtConnectionClient.h>
#include <photon/WmMsg.h>
#include <photon/WmReply.h>

int WmSendMessage(PtConnectionClient_t *client, WmMsg_t *request, WmReply_t *reply, unsigned int reply_len);

int get_frame_size( PhRid_t rid, PhRect_t *rect)
{
 WmMsg_t     request;
 WmReply_t   reply;

 request.hdr.type = WM_REQUEST_FRAME_SIZE;
 request.hdr.rid = rid;

 if( -1 == WmSendMessage(NULL, &request, &reply, sizeof(WmReply_t) ) ) {
   return -1;
 } 
 memcpy(rect, &(reply.data.frame.borders), sizeof(PhRect_t));
 return (0);
}

Re: Calculate Window Insets  
Thanks for the quick reply. Unfortunately, I'm getting a GPF when it hits the WmSendMessage line. Any ideas?
Re: Calculate Window Insets  
backtrace?
Re: Calculate Window Insets  
Unfortunately getting a backtrace from our app is difficult because it is a jni library used in j9. However, I wrote a 
simple test app that behaves the same way. The backtrace generated is:

Thread [1] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation fault.)	
	6 PtAppCreatePulse()  0xb82e6af7	
	5 client_attach()  0xb82376f8	
	4 PtConnectionFindName()  0xb82378ae	
	3 WmConnect()  0xb82f09af	
	2 WmSendMessage()  0xb82f0a4a	
	1 main() C:\ide-4.5-workspace\insets\insets.c:77 0x08048a9d	

I've attached the source file as well.

Bill
Attachment: Text insets.c 2.41 KB
Re: Calculate Window Insets  
Try to use PtInit(NULL) instead of PhAttach();
Re: Calculate Window Insets  
Thanks Misha. That did the trick. Since I don't use any widgets and have my own event loop, are there any negatives to 
using PtInit? I couldn't see a change in the memory footprint.
Re: Calculate Window Insets  
I don't think there are any implications for you case.
Re: Calculate Window Insets  
Unfortunately, I ran into a problem with this solution. Calling PtInit prevents me from receiving any events with 
PhEventNext. Any thoughts on how to get around this?
Re: Calculate Window Insets  
You will need to do this manually.
After you created your window, query it with PhRegionQuery(). Save its origin and size. Query it’s parent (if the 
parent is 0, then there is no PWM running). Look at the parent’s region size and calculate the border based on the 
windows origin and size.
Re: Calculate Window Insets  
Thx Misha. I was able to get it to work that way.