Find data about a tag on screen

QNX Windows

I need to find data about a tag on screen. The tag can be in any picture and
if I find more than one I take the first I find. Sounds simple enough,
but…

I though I use ScreenResourceInfo() to find all pictures and then loop
through to find my tag.
The problem is ScreenResourceInfo() returns 0 all the time. No pictures
found.

Am I missing something or is there an easier way?


Thank You

LP

Lorenz Prem <Lorenz.Prem@guidant.com> wrote:

QNX Windows

I need to find data about a tag on screen. The tag can be in any picture and
if I find more than one I take the first I find. Sounds simple enough,
but…

If I were to ask why you need to do this, would I regret it? How are
you ending up with an arbitary tag somewhere, and not knowing what
Window/Picture it is associated with?

Are you also sure that it couldn’t be in a Window Bar/border?

I though I use ScreenResourceInfo() to find all pictures and then loop
through to find my tag.
The problem is ScreenResourceInfo() returns 0 all the time. No pictures
found.

Am I missing something or is there an easier way?

I’d have thought that would work. Hm… what do you pass as the
parameters to ScreenResourceInfo()?

FWIW, the PrintScreen() function uses ScreenResourceInfo() to get
window ids, then works its way through each pane to find all the
potential pictures associated with windows. I know this works.
What happens if you try “W” for the options string rather than “P”?

-David

QNX Training Services
dagibbs@qnx.com

No matter what I put as an argument for ScreenResourceInfo, it comes up with
0 elements found (the return value).
May it be P or W in the options parameter.

I must be missing some other function call, because ScreenResourceInfo does
not work as it is described in the manuals.

Thank You
LP




“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9lcclu$aik$1@nntp.qnx.com

Lorenz Prem <> Lorenz.Prem@guidant.com> > wrote:
QNX Windows

I need to find data about a tag on screen. The tag can be in any picture
and
if I find more than one I take the first I find. Sounds simple enough,
but…

If I were to ask why you need to do this, would I regret it? How are
you ending up with an arbitary tag somewhere, and not knowing what
Window/Picture it is associated with?

Are you also sure that it couldn’t be in a Window Bar/border?

I though I use ScreenResourceInfo() to find all pictures and then loop
through to find my tag.
The problem is ScreenResourceInfo() returns 0 all the time. No pictures
found.

Am I missing something or is there an easier way?

I’d have thought that would work. Hm… what do you pass as the
parameters to ScreenResourceInfo()?

FWIW, the PrintScreen() function uses ScreenResourceInfo() to get
window ids, then works its way through each pane to find all the
potential pictures associated with windows. I know this works.
What happens if you try “W” for the options string rather than “P”?

-David

QNX Training Services
dagibbs@qnx.com

Lorenz Prem <Lorenz.Prem@guidant.com> wrote:

No matter what I put as an argument for ScreenResourceInfo, it comes up with
0 elements found (the return value).
May it be P or W in the options parameter.

I must be missing some other function call, because ScreenResourceInfo does
not work as it is described in the manuals.

If I run the following program in a (minimal) QWindows session:

#include <windows/Qwindows.h>
#include <unistd.h>
void main()
{
int p1, p2;
int res;
short ids[200];
GraphicsOpen(NULL);
p1 = Picture(“test1”, NULL );
p2 = Picture(“test2”, NULL );
Window(“wind”, NULL, NULL, “new wind”);

res = ScreenResourceInfo( ids, sizeof(ids), “W”);
printf("%d windows\n", res);
res = ScreenResourceInfo( ids, sizeof(ids), “P”);
printf("%d pictures\n", res);

GraphicsClose(NULL);
}

I get the following output:

1 windows
4 pictures

which sure looks like it is working properly.

-David

QNX Training Services
dagibbs@qnx.com

David Gibbs <dagibbs@qnx.com> wrote:


If I run the following program in a (minimal) QWindows session:

I get the following output:

1 windows
4 pictures

which sure looks like it is working properly.

What happens if you try the above program?

-David

QNX Training Services
dagibbs@qnx.com

You are right, I got the ScreenResourceInfo() call working.
But now I have another problem:
This is what I am running:



int i,j
SSHORT wndID[100];
int pic_id;
void *element;
RECT_AREA region;
RECT_AREA view;
RECT_BOX box;
char tag[50];
bool found =FALSE;
char format[32];
char buffer[8000];


memset(wndID,0,sizeof(wndID));
ScreenResourceInfo(wndID,sizeof(wndID),“W”);

for(i=0;wndID_!=0;i++){
WindowCurrent(wndID);
PaneInfo(&region,&view,&pic_id);
PictureCurrent(pic_id);
num = CopyElements(ALL,buffer,sizeof(buffer),NULL);
///here is the problem

element = ElementFirst(buffer);
while(element != NULL){
ElementBox(&box);
if(‘T’ == ElementType()){
if((row >= (region.row + box.row - box.height)) &&
(row <= (region.row + box.row)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
} else {
if((row >= (region.row + box.row)) &&
(row <= (region.row + box.row + box.height)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
}
element = ElementNext();
}
if(found == TRUE) break;
}
if(found == TRUE){
strcpy(tag,ElementTag());
memset(format,0,sizeof(format));
ElementFormat(format);
ElementBox(&box);
Tell(format,tag);
}


The problem now lies into accessing the picture elements. CopyElements
returns 0 all the time. Even when there are clearly elements in the picture.

The only time it works is when I use it on the picture this piece of code
executes in. On all others it does not. I believe I might not have access to
see the elements of a picture owned by another process.

If this is so, how can I get access to all pictures in a screen and their
elements?

Thank You
LP_

Lorenz Prem <Lorenz.Prem@guidant.com> wrote:

You are right, I got the ScreenResourceInfo() call working.
But now I have another problem:



int i,j
SSHORT wndID[100];
int pic_id;
void *element;
RECT_AREA region;
RECT_AREA view;
RECT_BOX box;
char tag[50];
bool found =FALSE;
char format[32];
char buffer[8000];



memset(wndID,0,sizeof(wndID));
ScreenResourceInfo(wndID,sizeof(wndID),“W”);

for(i=0;wndID> !=0;i++){
WindowCurrent(wndID> );
PaneInfo(&region,&view,&pic_id);
PictureCurrent(pic_id);
num = CopyElements(ALL,buffer,sizeof(buffer),NULL);
///here is the problem

This following loops looks like you are searching for an element
at a location. You might consider th Hit() function for that.

element = ElementFirst(buffer);
while(element != NULL){
ElementBox(&box);
if(‘T’ == ElementType()){
if((row >= (region.row + box.row - box.height)) &&
(row <= (region.row + box.row)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
} else {
if((row >= (region.row + box.row)) &&
(row <= (region.row + box.row + box.height)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
}
element = ElementNext();
}
if(found == TRUE) break;
}
if(found == TRUE){
strcpy(tag,ElementTag());
memset(format,0,sizeof(format));
ElementFormat(format);
ElementBox(&box);
Tell(format,tag);
}




The problem now lies into accessing the picture elements. CopyElements
returns 0 all the time. Even when there are clearly elements in the picture.

Yes.

The only time it works is when I use it on the picture this piece of code
executes in. On all others it does not. I believe I might not have access to
see the elements of a picture owned by another process.

Yes.

QNX Windows has the idea of “ownership” – in general pictures and windows
are owned by the process that created them, and can only be read and
manipulated by that process. (There are some exceptions, in particular
focus and top/bottom position of windows can be manipulated by other
process, this is usually documented in the functions that perform them.)

If this is so, how can I get access to all pictures in a screen and their
elements?

_Tricky. What are you trying to accomplish? Why do you need to do this?
There may be a better way of doing what you are trying to do – what you
are trying to do is the equivalent of wanting to read the local data of
another process (and if this were Photon, that is exactly what it would
be as widgets are implement client-side rather than server side as in
QWindows.)

QWindows does have the idea of a “screen owner” – sort of a super-user
process in QWindows – that can see & read anyone’s picture. This is the
role of the windows manager – OLWM is the screen owner if it is running,
and will not work properly if it is now.

There is a new function (documented in /windows/readme/toolkit4.2) called
ScreenOwner() that will allow your process to become the screen owner.
If you do so, you may get some more events that you do not expect – you
will get workspace events and such. But, this will allow you read all the
pictures. If you are the screen owner, OLWM (the window manager, if you
use it) will not work as expected. The docs for ScreenOwner() say that if
you call it with a pid of -1, you will relinquish ownership – this suggests
to me that ownership is, effectively, “stacked”, and that if you claim then
relinquish ownership it will be returned to whomever had it before – i.e.
OLWM. I have not tested this, and as this is a fairly recent function
(relatively speaking) I do now know whether it will work as expected or
not. But, it may allow you to do what you want to do.

But, again, what you are trying to do looks… odd… to me, which suggests
that there may be some better way to achieve the end result of what you are
trying to do through searching all the picture elements for a particular
tag/location. (Hm… the one thing that might need something like this
ability would be trying to implement some sort of drag & drop. Is that
what you are trying to do?)

If you could describe what you are trying to do, I might be able to suggest
other/better ways to accomplish it.

-David

QNX Training Services
dagibbs@qnx.com_

David suggested to use ScreenOwner() to get access to all elements on a
screen. Unfortunately this function does not work as it is described in the
docs (toolkit4.2).

Every time I use it, the mouse input is disabled. I believe the reason for
this is the screen ownership. It never gets release.

Both these versions do not work as intended:

ScreenOwner(0,0);

ScreenOwner(0,-1);


int i = ScreenId();
ScreenOwner(i,0);

ScreenOwner(i,-1);

Any suggestions?

Thx
LP


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9lemra$ogi$1@nntp.qnx.com

Lorenz Prem <> Lorenz.Prem@guidant.com> > wrote:
You are right, I got the ScreenResourceInfo() call working.
But now I have another problem:


int i,j
SSHORT wndID[100];
int pic_id;
void *element;
RECT_AREA region;
RECT_AREA view;
RECT_BOX box;
char tag[50];
bool found =FALSE;
char format[32];
char buffer[8000];


memset(wndID,0,sizeof(wndID));
ScreenResourceInfo(wndID,sizeof(wndID),“W”);

for(i=0;wndID> _!=0;i++){
WindowCurrent(wndID> );
PaneInfo(&region,&view,&pic_id);
PictureCurrent(pic_id);
num = CopyElements(ALL,buffer,sizeof(buffer),NULL);
///here is the problem

This following loops looks like you are searching for an element
at a location. You might consider th Hit() function for that.

element = ElementFirst(buffer);
while(element != NULL){
ElementBox(&box);
if(‘T’ == ElementType()){
if((row >= (region.row + box.row - box.height)) &&
(row <= (region.row + box.row)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
} else {
if((row >= (region.row + box.row)) &&
(row <= (region.row + box.row + box.height)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
}
element = ElementNext();
}
if(found == TRUE) break;
}
if(found == TRUE){
strcpy(tag,ElementTag());
memset(format,0,sizeof(format));
ElementFormat(format);
ElementBox(&box);
Tell(format,tag);
}


The problem now lies into accessing the picture elements. CopyElements
returns 0 all the time. Even when there are clearly elements in the
picture.

Yes.

The only time it works is when I use it on the picture this piece of
code
executes in. On all others it does not. I believe I might not have
access to
see the elements of a picture owned by another process.

Yes.

QNX Windows has the idea of “ownership” – in general pictures and windows
are owned by the process that created them, and can only be read and
manipulated by that process. (There are some exceptions, in particular
focus and top/bottom position of windows can be manipulated by other
process, this is usually documented in the functions that perform them.)

If this is so, how can I get access to all pictures in a screen and
their
elements?

Tricky. What are you trying to accomplish? Why do you need to do this?
There may be a better way of doing what you are trying to do – what you
are trying to do is the equivalent of wanting to read the local data of
another process (and if this were Photon, that is exactly what it would
be as widgets are implement client-side rather than server side as in
QWindows.)

QWindows does have the idea of a “screen owner” – sort of a super-user
process in QWindows – that can see & read anyone’s picture. This is the
role of the windows manager – OLWM is the screen owner if it is running,
and will not work properly if it is now.

There is a new function (documented in /windows/readme/toolkit4.2) called
ScreenOwner() that will allow your process to become the screen owner.
If you do so, you may get some more events that you do not expect – you
will get workspace events and such. But, this will allow you read all the
pictures. If you are the screen owner, OLWM (the window manager, if you
use it) will not work as expected. The docs for ScreenOwner() say that if
you call it with a pid of -1, you will relinquish ownership – this
suggests
to me that ownership is, effectively, “stacked”, and that if you claim
then
relinquish ownership it will be returned to whomever had it before – i.e.
OLWM. I have not tested this, and as this is a fairly recent function
(relatively speaking) I do now know whether it will work as expected or
not. But, it may allow you to do what you want to do.

But, again, what you are trying to do looks… odd… to me, which
suggests
that there may be some better way to achieve the end result of what you
are
trying to do through searching all the picture elements for a particular
tag/location. (Hm… the one thing that might need something like this
ability would be trying to implement some sort of drag & drop. Is that
what you are trying to do?)

If you could describe what you are trying to do, I might be able to
suggest
other/better ways to accomplish it.

-David

QNX Training Services
dagibbs@qnx.com_

ScreenOwner is for use by workspace managers only. Calling it causes
workspace events to be rerouted to a different process (e.g., yours). This
is not something you would want to do casually, and should never be called
by a non-w.s. mgr. process. There can be only one owner of the screen, and
it has to take responsibility for everything that happens in the
workspace. If it doesn’t, the UI can become unusable.

The description in the notes is accurate. It says you will get workspace
events. It does not say you will get access to all elements on the screen.
This not possible, as David explained, since QW explicitly protects
resources from access by non-owner processes (unless the owner explicitly
grants public access).

What exactly are you trying to do?

“Lorenz Prem” <Lorenz.Prem@guidant.com> wrote in message
news:9lgrrs$58b$1@inn.qnx.com

David suggested to use ScreenOwner() to get access to all elements on a
screen. Unfortunately this function does not work as it is described in
the
docs (toolkit4.2).

Every time I use it, the mouse input is disabled. I believe the reason for
this is the screen ownership. It never gets release.

Both these versions do not work as intended:

ScreenOwner(0,0);

ScreenOwner(0,-1);


int i = ScreenId();
ScreenOwner(i,0);

ScreenOwner(i,-1);

Any suggestions?

Thx
LP


“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:9lemra$ogi$> 1@nntp.qnx.com> …
Lorenz Prem <> Lorenz.Prem@guidant.com> > wrote:
You are right, I got the ScreenResourceInfo() call working.
But now I have another problem:


int i,j
SSHORT wndID[100];
int pic_id;
void *element;
RECT_AREA region;
RECT_AREA view;
RECT_BOX box;
char tag[50];
bool found =FALSE;
char format[32];
char buffer[8000];


memset(wndID,0,sizeof(wndID));
ScreenResourceInfo(wndID,sizeof(wndID),“W”);

for(i=0;wndID> _!=0;i++){
WindowCurrent(wndID> );
PaneInfo(&region,&view,&pic_id);
PictureCurrent(pic_id);
num = CopyElements(ALL,buffer,sizeof(buffer),NULL);
///here is the problem

This following loops looks like you are searching for an element
at a location. You might consider th Hit() function for that.

element = ElementFirst(buffer);
while(element != NULL){
ElementBox(&box);
if(‘T’ == ElementType()){
if((row >= (region.row + box.row - box.height)) &&
(row <= (region.row + box.row)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
} else {
if((row >= (region.row + box.row)) &&
(row <= (region.row + box.row + box.height)) &&
(col >= (region.col + box.col)) &&
(col <= (region.col + box.col + box.width))){
found = TRUE;
break;
}
}
element = ElementNext();
}
if(found == TRUE) break;
}
if(found == TRUE){
strcpy(tag,ElementTag());
memset(format,0,sizeof(format));
ElementFormat(format);
ElementBox(&box);
Tell(format,tag);
}


The problem now lies into accessing the picture elements. CopyElements
returns 0 all the time. Even when there are clearly elements in the
picture.

Yes.

The only time it works is when I use it on the picture this piece of
code
executes in. On all others it does not. I believe I might not have
access to
see the elements of a picture owned by another process.

Yes.

QNX Windows has the idea of “ownership” – in general pictures and
windows
are owned by the process that created them, and can only be read and
manipulated by that process. (There are some exceptions, in particular
focus and top/bottom position of windows can be manipulated by other
process, this is usually documented in the functions that perform them.)

If this is so, how can I get access to all pictures in a screen and
their
elements?

Tricky. What are you trying to accomplish? Why do you need to do this?
There may be a better way of doing what you are trying to do – what you
are trying to do is the equivalent of wanting to read the local data of
another process (and if this were Photon, that is exactly what it would
be as widgets are implement client-side rather than server side as in
QWindows.)

QWindows does have the idea of a “screen owner” – sort of a super-user
process in QWindows – that can see & read anyone’s picture. This is
the
role of the windows manager – OLWM is the screen owner if it is
running,
and will not work properly if it is now.

There is a new function (documented in /windows/readme/toolkit4.2)
called
ScreenOwner() that will allow your process to become the screen owner.
If you do so, you may get some more events that you do not expect – you
will get workspace events and such. But, this will allow you read all
the
pictures. If you are the screen owner, OLWM (the window manager, if you
use it) will not work as expected. The docs for ScreenOwner() say that
if
you call it with a pid of -1, you will relinquish ownership – this
suggests
to me that ownership is, effectively, “stacked”, and that if you claim
then
relinquish ownership it will be returned to whomever had it before –
i.e.
OLWM. I have not tested this, and as this is a fairly recent function
(relatively speaking) I do now know whether it will work as expected or
not. But, it may allow you to do what you want to do.

But, again, what you are trying to do looks… odd… to me, which
suggests
that there may be some better way to achieve the end result of what you
are
trying to do through searching all the picture elements for a particular
tag/location. (Hm… the one thing that might need something like this
ability would be trying to implement some sort of drag & drop. Is that
what you are trying to do?)

If you could describe what you are trying to do, I might be able to
suggest
other/better ways to accomplish it.

-David

QNX Training Services
dagibbs@qnx.com_