diff --git a/ChangeLog b/ChangeLog index 4489eae0..9e92c29a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Changes since version 0.80.1: +............................. + +- Some updates to WINGs WMConnection. See WINGs/ChangeLog for details. +- Fixed empty window list menu, if the window list menu was launched through + the root menu ("Marc-Christian Petersen" ) + + Changes since version 0.80.0: ............................. diff --git a/WINGs/Extras/wtableview.c b/WINGs/Extras/wtableview.c index 3c173ff3..f9703c74 100644 --- a/WINGs/Extras/wtableview.c +++ b/WINGs/Extras/wtableview.c @@ -846,27 +846,28 @@ static void drawGrid(WMTableView *table, WMRect rect) static WMRange columnsInRect(WMTableView *table, WMRect rect) { WMTableColumn *column; - int width; - int i , j; + int pos; + int i, found; int totalColumns = WMGetArrayItemCount(table->columns); WMRange range; - j = 0; - width = 0; + pos = 0; + found = 0; for (i = 0; i < totalColumns; i++) { column = WMGetFromArray(table->columns, i); - if (j == 0) { - if (width <= rect.pos.x && width + column->width > rect.pos.x) { - range.position = i; - j = 1; + if (!found) { + if (rect.pos.x >= pos && rect.pos.x < pos + column->width) { + range.position = i; + range.count = 1; + found = 1; } } else { + if (pos > rect.pos.x + rect.size.width) { + break; + } range.count++; - if (width > rect.pos.x + rect.size.width) { - break; - } } - width += column->width; + pos += column->width; } range.count = WMAX(1, WMIN(range.count, totalColumns - range.position)); return range; diff --git a/src/funcs.h b/src/funcs.h index 7079a1e3..78f2e410 100644 --- a/src/funcs.h +++ b/src/funcs.h @@ -57,6 +57,8 @@ void OpenRootMenu(WScreen *scr, int x, int y, int keyboard); void OpenSwitchMenu(WScreen *scr, int x, int y, int keyboard); +void InitializeSwitchMenu(void); + #endif /* !LITE */ diff --git a/src/screen.c b/src/screen.c index 3ec878a4..8d432a18 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1017,7 +1017,7 @@ wScreenRestoreState(WScreen *scr) WMPropList *state; char *path; - + #ifndef LITE OpenRootMenu(scr, -10000, -10000, False); wMenuUnmap(scr->root_menu); diff --git a/src/startup.c b/src/startup.c index 6f902715..14598cfd 100644 --- a/src/startup.c +++ b/src/startup.c @@ -951,6 +951,10 @@ StartUp(Bool defaultScreenOnly) wScreenCount++; } +#ifndef LITE + InitializeSwitchMenu(); +#endif + /* initialize/restore state for the screens */ for (j = 0; j < wScreenCount; j++) { int crashed; diff --git a/src/switchmenu.c b/src/switchmenu.c index 9147bdd0..e9d60458 100644 --- a/src/switchmenu.c +++ b/src/switchmenu.c @@ -46,6 +46,9 @@ extern WPreferences wPreferences; extern Time LastTimestamp; +static int initialized = 0; + + static void observer(void *self, WMNotification *notif); static void wsobserver(void *self, WMNotification *notif); @@ -84,7 +87,28 @@ focusWindow(WMenu *menu, WMenuEntry *entry) wWindowConfigure(wwin, x, y, wwin->client.width, wwin->client.height); } } - + + +void +InitializeSwitchMenu() +{ + if (!initialized) { + initialized = 1; + + WMAddNotificationObserver(observer, NULL, WMNManaged, NULL); + WMAddNotificationObserver(observer, NULL, WMNUnmanaged, NULL); + WMAddNotificationObserver(observer, NULL, WMNChangedWorkspace, NULL); + WMAddNotificationObserver(observer, NULL, WMNChangedState, NULL); + WMAddNotificationObserver(observer, NULL, WMNChangedFocus, NULL); + WMAddNotificationObserver(observer, NULL, WMNChangedStacking, NULL); + WMAddNotificationObserver(observer, NULL, WMNChangedName, NULL); + + WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceChanged, NULL); + WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceNameChanged, NULL); + } +} + + /* * * Open switch menu @@ -95,22 +119,6 @@ OpenSwitchMenu(WScreen *scr, int x, int y, int keyboard) { WMenu *switchmenu = scr->switch_menu; WWindow *wwin; - static int initialized = 0; - - if (!initialized) { - initialized = 1; - - WMAddNotificationObserver(observer, NULL, WMNManaged, NULL); - WMAddNotificationObserver(observer, NULL, WMNUnmanaged, NULL); - WMAddNotificationObserver(observer, NULL, WMNChangedWorkspace, NULL); - WMAddNotificationObserver(observer, NULL, WMNChangedState, NULL); - WMAddNotificationObserver(observer, NULL, WMNChangedFocus, NULL); - WMAddNotificationObserver(observer, NULL, WMNChangedStacking, NULL); - WMAddNotificationObserver(observer, NULL, WMNChangedName, NULL); - - WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceChanged, NULL); - WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceNameChanged, NULL); - } if (switchmenu) { if (switchmenu->flags.mapped) { @@ -400,24 +408,27 @@ UpdateSwitchMenuWorkspace(WScreen *scr, int workspace) } -static void observer(void *self, WMNotification *notif) +static void +observer(void *self, WMNotification *notif) { WWindow *wwin = (WWindow*)WMGetNotificationObject(notif); const char *name = WMGetNotificationName(notif); void *data = WMGetNotificationClientData(notif); - if (strcmp(name, WMNManaged) == 0 && wwin) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_ADD); - else if (strcmp(name, WMNUnmanaged) == 0 && wwin) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_REMOVE); - else if (strcmp(name, WMNChangedWorkspace) == 0 && wwin) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE); - else if (strcmp(name, WMNChangedFocus) == 0 && wwin) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE); - else if (strcmp(name, WMNChangedName) == 0 && wwin) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE); - else if (strcmp(name, WMNChangedState) == 0 && wwin) { + if (!wwin) + return; + if (strcmp(name, WMNManaged) == 0) + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_ADD); + else if (strcmp(name, WMNUnmanaged) == 0) + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_REMOVE); + else if (strcmp(name, WMNChangedWorkspace) == 0) + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE); + else if (strcmp(name, WMNChangedFocus) == 0) + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE); + else if (strcmp(name, WMNChangedName) == 0) + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE); + else if (strcmp(name, WMNChangedState) == 0) { if (strcmp((char*)data, "omnipresent") == 0) { UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE); } else { @@ -427,7 +438,8 @@ static void observer(void *self, WMNotification *notif) } -static void wsobserver(void *self, WMNotification *notif) +static void +wsobserver(void *self, WMNotification *notif) { WScreen *scr = (WScreen*)WMGetNotificationObject(notif); const char *name = WMGetNotificationName(notif);