[evince] dvi text select and mouse-dvi alignment




This is probably something really stupid I missed and I was
hoping to discover it while writing the message but
have not found it yet so curious if anyone knows offhand how to
align the mouse coords and dvi coords for text select. 

Apparently my modifications are against evince-3.18.2.

I'm trying to modify the dvi backend from evince to control the visibility
of text blocks defined by new specials using mouse clicks. The basic
code seems to run to some extent- I can create dvi files from latex
with my new specials and view them in the modified evince, expanding
and iconifying the blocks I defined. However, the mouse clicks don't
seem to line up exactly with the dvi cursor and I'm not sure how this
is supposed to work. I took a "normal" latex document and compiled it into
pdf and dvi. The text select feature seems to work in pdf but not dvi-
it is not even implemented AFAICT.

So, that could explain why I could not find the code to copy :)

I think I came pretty close but it looks like there is drift or
round off error that is currently evident in the y position. Empirically
I came up with this gem which kind of works,

ev-view.c, circa line 5100,
,
gint xm,ym;
gtk_widget_get_pointer(widget,&xm,&ym);
// "border.right" was copied from existing code [sic?] 
int ym2=ym- 0*(page_area.y+border.right)/view->scale+view->scroll_y+(3.5*view->scroll_y)/100.0+.5 ;

or , 

int ym2=ym+view->scroll_y+(3.5*view->scroll_y)/100.0+.5 ;

in function ( line 4940 or so ), 
static gboolean ev_view_button_press_event (GtkWidget      *widget, GdkEventButton *event)


For context, the x value is made similarly and sent as a datagram, bypassing the
interfaces, 

d[0]=xm2; // xo; // xo; // event->x+view->scroll_x;
d[1]=ym2; // yo; // event->y+view->scroll_y;
// my code to send a time stamped event coord along with any needed
// pointers - this makes threading of the reload request another issue
// and yes it does segfault sometimes but works ok for testing  :)  
int csock= mjm_send_ts_ints(sname, sock, d, szi);

And when received in my new c++ code, compared to values like this,

 y=dvi->ymargin+ dvi->pos.vv;

Text laid out with this y value is thought to be what the user was clicking on.

Several comments and questions,

1) The code I found looked like an error, the y-coord was apparently
shifted with border.right which sounds incorrect vs say border.top .
2) On the first page without scrolling the above y seems to work ok.
3) With scrolling, the text and mouse seemed to drift at about a 3-4 percent
rate hence the nice kluge. I wanted typeset the document as a single ( long )
page and aside from the obvious hazards of such a drift this becomes
a huge problem here. If this is some kind of fp round off or other known
problem it would be nice to fix- alternatively I can track it down as I wanted
to look at the coords anyway although hopefully mich later. 
4) The use of the view->scale in the empircally working code does not seem 
consistent, it has a value around
1.2 whcn I looked, and misuse should be an obvious problem 
even on a normal page.

 
Was text select disabled on dvi for a reason or am I working with
very old code, apparently by source download is labelled
as evince-3.18.2.

Thanks.

 

-- 

mike marchywka
306 charles cox
canton GA 30115
USA, Earth 
marchywka hotmail com
404-788-1216
ORCID: 0000-0001-9237-455X


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]