JWM Source Documentation
Macros | Typedefs | Functions | Variables
menu.c File Reference
#include "jwm.h"
#include "menu.h"
#include "font.h"
#include "client.h"
#include "icon.h"
#include "cursor.h"
#include "key.h"
#include "button.h"
#include "event.h"
#include "root.h"
#include "settings.h"
#include "desktop.h"
#include "parse.h"
#include "winmenu.h"
#include "screen.h"
#include "hint.h"
#include "misc.h"
#include "popup.h"

Go to the source code of this file.

Macros

#define BASE_ICON_OFFSET   3
 
#define MENU_BORDER_SIZE   1
 
#define MENU_NOSELECTION   0
 
#define MENU_LEAVE   1
 
#define MENU_SUBSELECT   2
 

Typedefs

typedef unsigned char MenuSelectionType
 

Functions

static char ShowSubmenu (Menu *menu, Menu *parent, RunMenuCommandType runner, int x, int y, char keyboard)
 Show a submenu.
 
static void PatchMenu (Menu *menu)
 Prepare a menu to be shown.
 
static void UnpatchMenu (Menu *menu)
 Remove temporary items from a menu.
 
static void MapMenu (Menu *menu, int x, int y, char keyboard)
 Create and map a menu.
 
static void HideMenu (Menu *menu)
 Hide a menu.
 
static void DrawMenu (Menu *menu)
 Draw a menu.
 
static char MenuLoop (Menu *menu, RunMenuCommandType runner)
 Menu process loop.
 
static void MenuCallback (const TimeType *now, int x, int y, Window w, void *data)
 Signal for showing popups.
 
static MenuSelectionType UpdateMotion (Menu *menu, RunMenuCommandType runner, XEvent *event)
 Determine the action to take given an event.
 
static void UpdateMenu (Menu *menu)
 Update the menu selection.
 
static void DrawMenuItem (Menu *menu, MenuItem *item, int index)
 Draw a menu item.
 
static MenuItemGetMenuItem (Menu *menu, int index)
 Get the menu item associated with an index.
 
static int GetNextMenuIndex (Menu *menu)
 Get the next item in the menu.
 
static int GetPreviousMenuIndex (Menu *menu)
 Get the previous item in the menu.
 
static int GetMenuIndex (Menu *menu, int y)
 Get the item in the menu given a y-coordinate.
 
static void SetPosition (Menu *tp, int index)
 Set the active menu item.
 
static char IsMenuValid (const Menu *menu)
 Determine if a menu is valid (and can be shown).
 
MenuCreateMenu ()
 Allocate an empty menu.
 
MenuItemCreateMenuItem (MenuItemType type)
 Create an empty menu item.
 
void InitializeMenu (Menu *menu)
 Initialize a menu.
 
char ShowMenu (Menu *menu, RunMenuCommandType runner, int x, int y, char keyboard)
 Show a menu.
 
void DestroyMenu (Menu *menu)
 Destroy a menu.
 

Variables

int menuShown = 0
 The number of open menus.
 

Macro Definition Documentation

#define BASE_ICON_OFFSET   3

Definition at line 29 of file menu.c.

Referenced by InitializeMenu().

#define MENU_BORDER_SIZE   1

Definition at line 30 of file menu.c.

Referenced by DrawMenuItem(), and InitializeMenu().

#define MENU_LEAVE   1

Definition at line 34 of file menu.c.

Referenced by MenuLoop(), and UpdateMotion().

#define MENU_NOSELECTION   0

Definition at line 33 of file menu.c.

Referenced by MenuLoop(), and UpdateMotion().

#define MENU_SUBSELECT   2

Definition at line 35 of file menu.c.

Referenced by MenuLoop(), and UpdateMotion().

Typedef Documentation

typedef unsigned char MenuSelectionType

Definition at line 32 of file menu.c.

Function Documentation

Menu* CreateMenu ( )
MenuItem* CreateMenuItem ( MenuItemType  type)

Create an empty menu item.

Definition at line 77 of file menu.c.

References Allocate, and MenuItem::type.

Referenced by AddWindowMenuItem(), CreateDesktopMenu(), CreateSendtoMenu(), CreateWindowLayerMenu(), InsertMenuItem(), and ShowClientList().

void DestroyMenu ( Menu menu)
void DrawMenu ( Menu menu)
static
void DrawMenuItem ( Menu menu,
MenuItem item,
int  index 
)
static
int GetMenuIndex ( Menu menu,
int  y 
)
static

Get the item in the menu given a y-coordinate.

Definition at line 944 of file menu.c.

References Menu::itemCount, and Menu::offsets.

Referenced by UpdateMotion().

MenuItem * GetMenuItem ( Menu menu,
int  index 
)
static

Get the menu item associated with an index.

Definition at line 962 of file menu.c.

References Menu::items, and MenuItem::next.

Referenced by GetNextMenuIndex(), GetPreviousMenuIndex(), MenuLoop(), UpdateMenu(), and UpdateMotion().

int GetNextMenuIndex ( Menu menu)
static

Get the next item in the menu.

Definition at line 908 of file menu.c.

References Menu::currentIndex, GetMenuItem(), MENU_ITEM_SEPARATOR, and MenuItem::type.

Referenced by UpdateMotion().

int GetPreviousMenuIndex ( Menu menu)
static

Get the previous item in the menu.

Definition at line 926 of file menu.c.

References Menu::currentIndex, GetMenuItem(), Menu::itemCount, MENU_ITEM_SEPARATOR, and MenuItem::type.

Referenced by UpdateMotion().

void HideMenu ( Menu menu)
static

Hide a menu.

Definition at line 225 of file menu.c.

References display, JXUnmapWindow, Menu::parent, and Menu::window.

Referenced by MenuLoop(), and UpdateMotion().

void InitializeMenu ( Menu menu)
char IsMenuValid ( const Menu menu)
static

Determine if a menu is valid (and can be shown).

Definition at line 1012 of file menu.c.

References Menu::items, MENU_ITEM_SEPARATOR, MenuItem::next, and MenuItem::type.

Referenced by ShowMenu(), and UpdateMotion().

void MapMenu ( Menu menu,
int  x,
int  y,
char  keyboard 
)
static
void MenuCallback ( const TimeType now,
int  x,
int  y,
Window  w,
void *  data 
)
static
char MenuLoop ( Menu menu,
RunMenuCommandType  runner 
)
static
void PatchMenu ( Menu menu)
static
void SetPosition ( Menu tp,
int  index 
)
static

Set the active menu item.

Definition at line 983 of file menu.c.

References display, ScreenType::height, Menu::height, Menu::itemHeight, JXMoveWindow, MoveMouse(), Menu::offsets, Menu::screen, Menu::window, Menu::x, ScreenType::y, and Menu::y.

Referenced by UpdateMotion().

char ShowMenu ( Menu menu,
RunMenuCommandType  runner,
int  x,
int  y,
char  keyboard 
)
char ShowSubmenu ( Menu menu,
Menu parent,
RunMenuCommandType  runner,
int  x,
int  y,
char  keyboard 
)
static

Show a submenu.

Definition at line 280 of file menu.c.

References display, JXDestroyWindow, JXFreePixmap, MapMenu(), MenuLoop(), menuShown, Menu::parent, PatchMenu(), Menu::pixmap, and Menu::window.

Referenced by ShowMenu(), and UpdateMotion().

void UnpatchMenu ( Menu menu)
static

Remove temporary items from a menu.

Definition at line 338 of file menu.c.

References MenuItem::action, DestroyMenu(), Menu::items, MA_ACTION_MASK, MA_DESKTOP_MENU, MA_DYNAMIC, MA_SENDTO_MENU, MA_WINDOW_MENU, MenuItem::next, MenuItem::submenu, and MenuAction::type.

Referenced by ShowMenu().

void UpdateMenu ( Menu menu)
static

Update the menu selection.

Definition at line 804 of file menu.c.

References Menu::currentIndex, display, DrawMenuItem(), GetMenuItem(), Menu::height, JXCopyArea, Menu::lastIndex, Menu::pixmap, rootGC, Menu::width, and Menu::window.

Referenced by UpdateMotion().

MenuSelectionType UpdateMotion ( Menu menu,
RunMenuCommandType  runner,
XEvent *  event 
)
static

Variable Documentation

int menuShown = 0

The number of open menus.

Definition at line 63 of file menu.c.

Referenced by ProcessActionPress(), ProcessActionRelease(), ReloadMenu(), ShowRootMenu(), ShowSubmenu(), and SignalTray().

joewing.net / Projects / JWM