Adding a User Preference for Mouse Lock

Our class is on the final stretch to getting our first patch ready for review and have a real functioning Mouse Lock API available for use with Firefox. One thing @humphd pushed for was for each one of us to have some piece of code in this patch that we could call stake our name to. During our class Tuesday he made sure everyone of us was assigned a feature and set a tentative deadline for this Friday so we had enough time to get a patch ready for early next week. This was a great thing to do because it ensured we all got something in and pushed those that may not have been doing much work with it or just haven’t been involved much.

One of the features left to implement that interested me was implementing a user preference that would allow the user to have a saved preference about whether or not they wanted mouselock to ever be enabled. My original research into this brought me to this directory in mozilla-central. It definitely provided some insight and allowed me to know how I could access preferences and what their current values are. The only problem was I had no idea where I should have been actually defining the preference itself and any default value it had.

After joining up with @northWind87 today we were pointed in the direction of a wiki article Humph had written about preferences in mozilla. From there we found firefox.js and noticed a lot of lines that looked like this:

pref("dom.enable_performance", true);

Clearly we were on to something. We initially tried adding our preference in to this file and rebuilt firefox around that change. It worked instantly but humph then pointed out to us that @TedMielczarek said we should actually be putting them in a file called all.js, which was actually only one directory structure further down that what I originally found. Not too shabby really, pretty close on the first try!

So we changed where we declared this preference and had it working again in no time.

After that all that needed to be done was adding in a couple of lines of code the the method nsDOMMouseLockable::ShouldLock that we already had and bam, presto chango it worked (at least as far as we could tell). The only thing left to do now is figure out why the results of my testing aren’t showing up.

Till next time!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: