xboard-devel
[Top][All Lists]
Advanced

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

Re: [XBoard-devel] gtk version status


From: h.g. muller
Subject: Re: [XBoard-devel] gtk version status
Date: Wed, 20 Jan 2010 00:18:39 +0100


hmm, when you do this, do you actually use calls do X-functions in the
backend?

Of course not; that would completely break WinBoard. The point is that
the mouse handler of both XBoard and WinBoard contained lot of duplicate
code, for figuring out what action should be taken on the mouse click
(which depends on tha variant, the game mode, who is to move, what is
on the square you click, etc.) As XBoard and WinBoard must behave
the same, most of that code is identical. Only some actions involve
the front end (like popping up a menu), and those need to be done
differently. So what I do is move the common code to the back end,
let the primary interrupt handlers call that code with the information
that has to be passed (e.g. coordinates of the click) casted in universal
form. This back-end code then calls back on the front-end for the
most elementary actions.

But when all decisions about what actually has to be done are taken in
the back-end, it becomes very easy to bypass the menus (simply remove
the calls back into the front end), and do something else in stead.

If you take a quick look at the latest commits in the promopopup branch
you will see what I mean. I am done with the refactoring; currently all
Right-clicks on the board invoke the back-end routine RightClick,
like I had already donw for LeftClicks when repairing premove.
Promotion selection is done by leftclicking the piece of choice on
the board. I am now trying to do the same for Edit Position, but
it is a bit more tricky there, as you call up the menu with a right-click
(while a promotion was triggered by releasing a piece on a promotion
rank). So the mouse button is initially down. You can of course
move the mouse pointer with this button down to the piece of the type
that you wanted to drop on the square where it went down. But then, if
you release early, you might have selected something you did not want.
(This ispretty much like it works with the X menus, btw.) An alternative
is to ignore the right upclick, and requite a left down-click on the piece
you want to drop. It seems hard to combine those two modes.

This might be easier when the pieces to be selected appear in a separate
window; you can make this window pop up in a place so that the mouse
pointer is outside it, so when you release without moving it is ignored.
The popup would hang there until you either release the right button
inside it to select something, or push the left buton inside of it.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]