Skip to content

Instantly share code, notes, and snippets.

@jessoclarence
Created July 11, 2012 08:24
Show Gist options
  • Save jessoclarence/3089007 to your computer and use it in GitHub Desktop.
Save jessoclarence/3089007 to your computer and use it in GitHub Desktop.
Understanding LibreOffice Source Code
Menu Dropdown
I put a breakpoint at libo/vcl/source/window/winproc.cxx:2405, at the case SAL_EVENTMOUSEDOWN, to see
what happens when I click a mouse.
I clicked on File Menu, it hit the breakpoint. Then off it goes to calls ImplHandleSalMouseButtonDown ()
with the following details stored in pEvent and pWindow.
pEvent
mnTime = 78764380 //Time
mnX = 18 //x co-ordinate
mnY = 9 //y co-ordinate
mnButton = 1 //left button, 4 for right click, 2 for clicking with the scroller
mnCode = 0 //to find whether click is part of some select etc.
pWindow - the window object.
The ImplHandleSalMouseButtonDown () function is in ./libo/vcl/source/window/winproc.cxx:2068, it checks
whether shift, ctrl or alt keys were pressed in 2076, and then calls ImplGetMouseButtonMode () with pEvent
(function is at ./libo/vcl/source/window/winproc.cxx:2030) to get further details of whether it is a simple
click event or whether it is part of select, multi (ctrl+click?) or range select, using pEvent's mnCode
variable.
The ImplGetMouseButtonMode () function returns nMode as 3. The first two if statements were true, ie.
MOUSE_SIMPLECLICK and MOUSE_SELECT. Once, this returns, ImplHandleSalMouseButtonDown () calls the function
ImplHandleMouseEvent (), with
- the window object - pWindow
- nSVEvent = 1 (EVENT_MOUSEBUTTONDOWN)
- bMouseLeave = False
- x,y co-ordinates
- time of the event nMsgTime
- nCode = 1, to indicate status of shift,ctrl keys
- and mode of click , nMode = 3
The function then does the following,
- gets the details of the frame
- checks the previous location of the mouse.
- updates the frame data with the latest details
- checks whether the mouse has left or entered (?).
- finds the window
- after finding the window
- it checks whether the window was disabled
- it comes to line 666 (after several if conditions turned out to be false), for the mouse click event
- here it checks for double click.
- it then updates the details in the child window object
- It creates the MouseEvent object at line 709
- It notifies the child window of the event. Off to the next function.
- In the next call, first the constructor of ImplDelData is called (maybe due to some
inheritance) ImplDelData::ImplDelData () at /home/jesso/Downloads/libreoffice/libo/vcl/inc/
svdata.hxx:424, this is there to protect against the window from getting destroyed.
- The NotifyEvent object is created.
- It then checks whether it should bring the window into focus, if it previously didn't have focus,
close context menus etc.
- ImplCallPreNotify function
- calls long Application::CallEventHooks () at ./libo/vcl/source/app/svapp.cxx:1657
- that function returns 0
- so it gets the PreNotify () method on the window object in the event object.
- Finally it calls the MouseButtonDown() method on the pChild pointer, which happens to be
MenuBarWindow::MouseButtonDown () at ./libo/vcl/source/window/menu.cxx:5366
The MenuBarWindow::MouseButtonDown () then does the following,
- It first finds the entry on which the action happened.
- It then calls ChangeHighlightItem (which needs to be refactored, btw)
- This decides whether to update the focus etc
- It then finally creates the pop up in line 5477
-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment