Determine if button press triggered wakeup from STOP mode with STM32F0
You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.



EDIT: I thought this bit would be helpful, but as @foldl found out, this bit seems to be set only in case of a wakeup from the wakeup pins and not from other pins. I haven't seen any other bit which might be useful for this.

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):


  Bit 0 WUF: Wakeup flag
  This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by
  a system reset or by setting the CWUF bit in the Power control register (PWR_CR)
  
  0: No wakeup event occurred
  
  1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC
  alarm.
  
  Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the
  EWUPx bit) when its pin level is already high.


See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:


  Bit 2 CWUF: Clear wakeup flag.
  
  This bit is always read as 0.
  
  0: No effect
  
  1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)